xref: /freebsd/sys/tools/bus_macro.sh (revision 031beb4e239bfce798af17f5fe8dba8bcaf13d99)
16db1c434SPoul-Henning Kamp#!/bin/sh
26db1c434SPoul-Henning Kamp#
3*4d846d26SWarner Losh# SPDX-License-Identifier: BSD-2-Clause
4fe267a55SPedro F. Giffuni#
56db1c434SPoul-Henning Kamp# Copyright (c) 2004-2005 Poul-Henning Kamp.
66db1c434SPoul-Henning Kamp# All rights reserved.
76db1c434SPoul-Henning Kamp#
86db1c434SPoul-Henning Kamp# Redistribution and use in source and binary forms, with or without
96db1c434SPoul-Henning Kamp# modification, are permitted provided that the following conditions
106db1c434SPoul-Henning Kamp# are met:
116db1c434SPoul-Henning Kamp# 1. Redistributions of source code must retain the above copyright
126db1c434SPoul-Henning Kamp#    notice, this list of conditions and the following disclaimer.
136db1c434SPoul-Henning Kamp# 2. Redistributions in binary form must reproduce the above copyright
146db1c434SPoul-Henning Kamp#    notice, this list of conditions and the following disclaimer in the
156db1c434SPoul-Henning Kamp#    documentation and/or other materials provided with the distribution.
166db1c434SPoul-Henning Kamp#
176db1c434SPoul-Henning Kamp# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
186db1c434SPoul-Henning Kamp# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
196db1c434SPoul-Henning Kamp# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
206db1c434SPoul-Henning Kamp# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
216db1c434SPoul-Henning Kamp# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
226db1c434SPoul-Henning Kamp# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
236db1c434SPoul-Henning Kamp# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
246db1c434SPoul-Henning Kamp# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
256db1c434SPoul-Henning Kamp# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
266db1c434SPoul-Henning Kamp# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
276db1c434SPoul-Henning Kamp# SUCH DAMAGE.
286db1c434SPoul-Henning Kamp#
296db1c434SPoul-Henning Kamp#
306db1c434SPoul-Henning Kamp# Generate the convenience macros at the bottom of sys/bus.h
316db1c434SPoul-Henning Kamp#
326db1c434SPoul-Henning Kamp
336db1c434SPoul-Henning Kampmacro () {
346db1c434SPoul-Henning Kamp
356db1c434SPoul-Henning Kamp	n=${1}
366db1c434SPoul-Henning Kamp	shift
376db1c434SPoul-Henning Kamp	echo -n "#define bus_${n}(r"
386db1c434SPoul-Henning Kamp	for i
396db1c434SPoul-Henning Kamp	do
406db1c434SPoul-Henning Kamp		echo -n ", ${i}"
416db1c434SPoul-Henning Kamp	done
426db1c434SPoul-Henning Kamp	echo ") \\"
436db1c434SPoul-Henning Kamp	echo -n "	bus_space_${n}((r)->r_bustag, (r)->r_bushandle"
446db1c434SPoul-Henning Kamp	for i
456db1c434SPoul-Henning Kamp	do
466db1c434SPoul-Henning Kamp		echo -n ", (${i})"
476db1c434SPoul-Henning Kamp	done
486db1c434SPoul-Henning Kamp	echo ")"
496db1c434SPoul-Henning Kamp}
506db1c434SPoul-Henning Kamp
516db1c434SPoul-Henning Kampmacro barrier o l f
526db1c434SPoul-Henning Kamp
536db1c434SPoul-Henning Kampfor w in 1 2 4 8
546db1c434SPoul-Henning Kampdo
556db1c434SPoul-Henning Kamp	# macro copy_region_$w so dh do c
566db1c434SPoul-Henning Kamp	# macro copy_region_stream_$w ?
5795a85c12SMichal Meloun	macro poke_$w o v
5895a85c12SMichal Meloun	macro peek_$w o vp
596db1c434SPoul-Henning Kamp	for s in "" stream_
606db1c434SPoul-Henning Kamp	do
616db1c434SPoul-Henning Kamp		macro read_$s$w o
626db1c434SPoul-Henning Kamp		macro read_multi_$s$w o d c
636db1c434SPoul-Henning Kamp		macro read_region_$s$w o d c
646db1c434SPoul-Henning Kamp		macro set_multi_$s$w o v c
656db1c434SPoul-Henning Kamp		macro set_region_$s$w o v c
666db1c434SPoul-Henning Kamp		macro write_$s$w o v
676db1c434SPoul-Henning Kamp		macro write_multi_$s$w o d c
686db1c434SPoul-Henning Kamp		macro write_region_$s$w o d c
696db1c434SPoul-Henning Kamp	done
706db1c434SPoul-Henning Kampdone
71