1169689Skan#!/bin/sh
2169689Skan#
3169689Skan# $FreeBSD$
4169689Skan#
5169689Skan# Copyright (c) 2011 Hans Petter Selasky. All rights reserved.
6169689Skan#
7169689Skan# Redistribution and use in source and binary forms, with or without
8169689Skan# modification, are permitted provided that the following conditions
9169689Skan# are met:
10169689Skan# 1. Redistributions of source code must retain the above copyright
11169689Skan#    notice, this list of conditions and the following disclaimer.
12169689Skan# 2. Redistributions in binary form must reproduce the above copyright
13169689Skan#    notice, this list of conditions and the following disclaimer in the
14169689Skan#    documentation and/or other materials provided with the distribution.
15169689Skan#
16169689Skan# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17169689Skan# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18169689Skan# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19169689Skan# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20169689Skan# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21169689Skan# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22169689Skan# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23169689Skan# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24169689Skan# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25169689Skan# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26169689Skan# SUCH DAMAGE.
27169689Skan#
28169689Skan
29169689SkanOS=FreeBSD
30169689SkanDOLLAR=$
31169689SkanOBJCOPY=objcopy
32169689Skan
33169689Skancat <<EOF
34169689Skan#
35169689Skan# ${DOLLAR}${OS}${DOLLAR}
36169689Skan#
37169689Skan# This file was automatically generated by "tools/tools/bus_autoconf/bus_autoconf.sh".
38169689Skan# Please do not edit!
39169689Skan#
40169689Skan
41169689SkanEOF
42169689Skan
43169689Skanrm -f bus_autoconf_format.bin
44169689Skanrm -f bus_autoconf_args.txt
45169689Skanrm -f bus_autoconf.ids
46169689Skan
47169689Skanfor F in $*
48169689Skando
49169689Skan
50169689SkanG=$(basename ${F})
51169689Skan
52169689Skan# Format information
53169689Skan${OBJCOPY} -j bus_autoconf_format -O binary ${F} bus_autoconf.ids 2> /dev/null
54169689Skan[ -f bus_autoconf.ids ] && cat bus_autoconf.ids >> bus_autoconf_format.bin
55169689Skan
56169689Skan# USB Host mode
57169689Skan${OBJCOPY} -j usb_host_id -O binary ${F} "usb_host_id,${G}" 2> /dev/null
58169689Skan[ -f "usb_host_id,${G}" ] && (echo -n " -i usb_host_id,${G}" >> bus_autoconf_args.txt)
59169689Skan
60169689Skan# USB Device mode
61169689Skan${OBJCOPY} -j usb_device_id -O binary ${F} "usb_device_id,${G}" 2> /dev/null
62169689Skan[ -f "usb_device_id,${G}" ] && (echo -n " -i usb_device_id,${G}" >> bus_autoconf_args.txt)
63169689Skan
64169689Skan# USB Dual mode
65169689Skan${OBJCOPY} -j usb_dual_id -O binary ${F} "usb_dual_id,${G}" 2> /dev/null
66169689Skan[ -f "usb_dual_id,${G}" ] && (echo -n " -i usb_dual_id,${G}" >> bus_autoconf_args.txt)
67169689Skan
68169689Skandone
69169689Skan
70169689Skan# Dump all data
71169689Skanbus_autoconf -F bus_autoconf_format.bin $(cat bus_autoconf_args.txt)
72169689Skan
73169689Skan# Cleanup
74169689Skanrm -f -- \
75169689Skan    $(cat bus_autoconf_args.txt) \
76169689Skan    bus_autoconf_args.txt \
77169689Skan    bus_autoconf_format.bin \
78169689Skan    bus_autoconf.ids
79169689Skan