bus_autoconf.sh revision 223518
1#!/bin/sh 2# 3# $FreeBSD: head/tools/tools/bus_autoconf/bus_autoconf.sh 223518 2011-06-24 21:27:33Z hselasky $ 4# 5# Copyright (c) 2011 Hans Petter Selasky. All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 2. Redistributions in binary form must reproduce the above copyright 13# notice, this list of conditions and the following disclaimer in the 14# documentation and/or other materials provided with the distribution. 15# 16# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26# SUCH DAMAGE. 27# 28 29OS=FreeBSD 30DOLLAR=$ 31 32cleanup() 33{ 34 # Cleanup 35 rm -f usb_dual.ids 36 rm -f usb_host.ids 37 rm -f usb_device.ids 38} 39 40usb_format() 41{ 42 [ -f ${1} ] || return 43 44 # Split into one and one record 45 split -b 32 ${1} ${1}. 46 47 # Prefix each record by the module name 48 for G in $(ls ${1}.*) 49 do 50 printf "%-32s" ${3} >> ${2} 51 cat ${G} >> ${2} 52 rm -f ${G} 53 done 54} 55 56cat <<EOF 57# 58# ${DOLLAR}${OS}${DOLLAR} 59# 60# This file was automatically generated by "tools/bus_autoconf.sh". 61# Please do not edit! 62# 63 64EOF 65 66# Cleanup 67cleanup 68 69for F in $* 70do 71 72# Get module basename 73H=$(basename ${F} | sed -e "s/\.ko//g") 74 75# USB Host 76objcopy -j usb_host_id -O binary ${F} temp.ids 2> /dev/null 77usb_format temp.ids usb_host.ids ${H} 78 79# USB Device 80objcopy -j usb_device_id -O binary ${F} temp.ids 2> /dev/null 81usb_format temp.ids usb_device.ids ${H} 82 83# USB Dual mode 84objcopy -j usb_dual_id -O binary ${F} temp.ids 2> /dev/null 85usb_format temp.ids usb_dual.ids ${H} 86 87done 88 89# Dump all data 90[ -f usb_dual.ids ] && bus_autoconf -i usb_dual.ids -t usb_dual 91[ -f usb_host.ids ] && bus_autoconf -i usb_host.ids -t usb_host 92[ -f usb_device.ids ] && bus_autoconf -i usb_device.ids -t usb_device 93 94# Cleanup 95cleanup 96