#!/bin/sh1#2# Copyright (c) 2015-2016 Landon Fuller <[email protected]>3# Copyright (c) 2004-2005 Poul-Henning Kamp.4# All rights reserved.5#6# Redistribution and use in source and binary forms, with or without7# modification, are permitted provided that the following conditions8# are met:9# 1. Redistributions of source code must retain the above copyright10# notice, this list of conditions and the following disclaimer.11# 2. Redistributions in binary form must reproduce the above copyright12# notice, this list of conditions and the following disclaimer in the13# documentation and/or other materials provided with the distribution.14#15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25# SUCH DAMAGE.26#27#28# Generate the bhnd resource macros at the bottom of dev/bhnd/bhnd.h29#30# Derived from PHK's tools/bus_macros.sh31#3233macro () {34n=${1}35bus_n=$(echo $n | tr "[:lower:]" "[:upper:]")3637shift38echo -n "#define bhnd_bus_${n}(r"39for i40do41echo -n ", ${i}"42done43echo ") \\"44echo " (((r)->direct) ? \\"45echo -n " bus_${n}((r)->res"46for i47do48echo -n ", (${i})"49done50echo ") : \\"51echo " BHND_BUS_${bus_n}( \\"52echo " device_get_parent(rman_get_device((r)->res)), \\"53echo -n " rman_get_device((r)->res), (r)"54for i55do56echo -n ", (${i})"57done58echo "))"5960}6162macro barrier o l f6364for w in 1 2 4 #865do66# macro copy_region_$w so dh do c67# macro copy_region_stream_$w ?68# macro peek_$w69for s in "" stream_70do71macro read_$s$w o72macro read_multi_$s$w o d c73macro read_region_$s$w o d c74macro write_$s$w o v75macro write_multi_$s$w o d c76macro write_region_$s$w o d c77done7879# set_(multi_)?_stream is not supported on ARM/ARM64, and so for80# simplicity, we don't support their use with bhnd resources.81#82# if that changes, these can be merged back into the stream-eanbled83# loop above.84for s in ""85do86macro set_multi_$s$w o v c87macro set_region_$s$w o v c88done89done909192