Home | History | Annotate | Line # | Download | only in kdump
mkioctls revision 1.52.2.2
      1      1.14  christos #!/bin/sh
      2  1.52.2.2    martin #	$NetBSD: mkioctls,v 1.52.2.2 2020/04/08 14:09:16 martin Exp $
      3       1.7       jtc #
      4       1.7       jtc # Copyright (c) 1994
      5       1.7       jtc #	The Regents of the University of California.  All rights reserved.
      6       1.7       jtc #
      7       1.7       jtc # Redistribution and use in source and binary forms, with or without
      8       1.7       jtc # modification, are permitted provided that the following conditions
      9       1.7       jtc # are met:
     10       1.7       jtc # 1. Redistributions of source code must retain the above copyright
     11       1.7       jtc #    notice, this list of conditions and the following disclaimer.
     12       1.7       jtc # 2. Redistributions in binary form must reproduce the above copyright
     13       1.7       jtc #    notice, this list of conditions and the following disclaimer in the
     14       1.7       jtc #    documentation and/or other materials provided with the distribution.
     15       1.7       jtc # 3. All advertising materials mentioning features or use of this software
     16       1.7       jtc #    must display the following acknowledgement:
     17       1.7       jtc #	This product includes software developed by the University of
     18       1.7       jtc #	California, Berkeley and its contributors.
     19       1.7       jtc # 4. Neither the name of the University nor the names of its contributors
     20       1.7       jtc #    may be used to endorse or promote products derived from this software
     21       1.7       jtc #    without specific prior written permission.
     22       1.7       jtc #
     23       1.7       jtc # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24       1.7       jtc # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25       1.7       jtc # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26       1.7       jtc # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27       1.7       jtc # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28       1.7       jtc # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29       1.7       jtc # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30       1.7       jtc # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31       1.7       jtc # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32       1.7       jtc # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33       1.7       jtc # SUCH DAMAGE.
     34       1.7       jtc #
     35       1.7       jtc #	@(#)mkioctls	8.2 (Berkeley) 4/28/95
     36       1.3   mycroft #
     37      1.37       apb 
     38      1.38       apb : ${AWK:=awk}
     39      1.37       apb : ${CC:=cc}
     40      1.38       apb : ${SED:=sed}
     41      1.37       apb 
     42      1.16  christos echo "/* Automatically generated file, do not edit! */"
     43      1.21  christos #echo "#define const" 	# XXX: timepps lossage
     44      1.14  christos echo "#define COMPAT_43"
     45      1.35     joerg echo "#define COMPAT_FREEBSD_NET80211"
     46      1.14  christos echo "struct lwp;"
     47      1.24  christos echo "struct crap { int _xxx; };" # XXX arm video lossage
     48      1.24  christos echo "typedef struct crap videomemory_t;" # XXX arm video lossage
     49      1.24  christos echo "typedef struct crap RF_AccTotals_t;" # XXX Raidframe lossage
     50      1.24  christos echo "struct rf_test_acc { int _xxx; };" # XXX Raidframe lossage
     51      1.42  christos echo "struct map_info { int _xxx[22]; };" # XXX Xorg lossage
     52      1.24  christos echo "#include <stdio.h>"
     53      1.14  christos echo "#include <sys/types.h>"
     54      1.14  christos echo "#include <sys/param.h>"
     55      1.51       mrg echo "#include <sys/mutex.h>"
     56      1.29        he echo "#ifndef NBPG"
     57      1.29        he echo "#define NBPG 4096 /* workaround / dummy for sparc */"
     58      1.29        he echo "#endif /* NBPG */"
     59      1.14  christos echo "#include <sys/disk.h>"
     60      1.17   hannken echo "#include <sys/dkbad.h>"
     61      1.14  christos echo "#include <sys/mount.h>"
     62      1.14  christos echo "#include <sys/termios.h>"
     63      1.16  christos echo "#include <sys/disklabel.h>"
     64      1.43      matt echo "#include <sys/exec_elf.h>"
     65      1.14  christos echo "#include <net/if.h>"
     66      1.24  christos echo "#include <net/if_ether.h>"
     67      1.14  christos echo "#include <net/route.h>"
     68      1.14  christos echo "#include <net/ppp_defs.h>"
     69      1.14  christos echo "#include <netinet/in.h>"
     70      1.14  christos echo "#include <netinet/in_systm.h>"
     71      1.14  christos echo "#include <netinet/ip.h>"
     72      1.14  christos echo "#include <netinet/ip_mroute.h>"
     73      1.14  christos echo "#include <netinet/ip_compat.h>"
     74      1.14  christos echo "#include <net80211/ieee80211.h>"
     75      1.24  christos echo "#include <net80211/ieee80211_radiotap.h>"
     76      1.24  christos echo "#include <netinet6/in6_var.h>"
     77      1.24  christos echo "#include <netinet6/nd6.h>"
     78      1.24  christos echo "#include <dev/ic/hd44780reg.h>"
     79      1.24  christos echo "#include <dev/pci/mlyreg.h>"
     80      1.24  christos echo "#include <prop/proplib.h>"
     81  1.52.2.1  christos echo "#include <nv.h>"
     82      1.41       dsl echo
     83      1.37       apb 
     84      1.46  christos # kernel headers <sys/*.h> and <net/*.h> should not include stdbool.h
     85      1.46  christos # but they do; then xf86Opt.h needs a bool struct field.
     86      1.46  christos 
     87      1.46  christos needundef=true
     88      1.14  christos for i
     89      1.14  christos do
     90      1.46  christos 	case $i in
     91      1.46  christos 	*X11*)
     92      1.46  christos 		if $needundef; then
     93      1.46  christos 			echo "#undef bool"
     94      1.46  christos 			needundef=false;
     95      1.46  christos 		fi;;
     96      1.46  christos 	esac
     97      1.14  christos 	echo "#include <$i>"
     98      1.52  christos done | ${SED} -e "s,${DESTDIR}/usr/include/,,g" \
     99      1.52  christos 	-e "s,${DESTDIR}/usr/X11R7/include/,,g" \
    100      1.52  christos 	-e "s,${NETBSDSRCDIR}/external/cddl/osnet/dist/uts/common/,,g"
    101      1.14  christos 
    102      1.46  christos if ! $needundef; then
    103      1.46  christos     echo "#define bool _Bool"
    104      1.46  christos fi
    105      1.46  christos 
    106      1.52  christos ${CC} -E -nostdinc -isystem ${DESTDIR}/usr/include ${CPPFLAGS} -dM "${@}" | \
    107      1.52  christos     ${AWK} '
    108       1.1       cgd BEGIN {
    109      1.17   hannken 	keep["SLIOCGUNIT"] = 1;	# Same as PPPIOCGASYNCMAP
    110      1.19  christos 	keep["TUNSLMODE"] = 1;	# Same as PPPIOCGASYNCMAP
    111      1.17   hannken 	keep["SIOCRMNAT"] = 1;	# Same as SIOCRMAFR
    112      1.17   hannken 	keep["SIOCADNAT"] = 1;	# Same as SIOCADAFR
    113      1.17   hannken 	keep["SIOCDELST"] = 1;	# Same as SIOCRMNAT
    114      1.22  christos 	keep["SIOCPROXY"] = 1; # Same as SIOCLOOKUPSTAT
    115      1.17   hannken 	keep["CHIOGPICKER"] = 1; # Same as CDIOREADTOCHEADER
    116      1.20  christos 	keep["KBDSTPMAT"] = 1;	# Same as LMREADY, pcvt is gone so ok.
    117      1.24  christos 	keep["SIOCSLOWAT"] = 1;	# Same as SATIOSBUFSIZE
    118      1.24  christos 	keep["UTOPPYIOTURBO"] = 1; # Same as OTIOCSETD
    119      1.24  christos 	keep["TIOCHPCL"] = 1; # Same as UTOPPYIOCANCEL
    120      1.24  christos 	keep["TIOCCBRK"] = 1; # Same as CONSOLE_X_MODE_OFF
    121      1.24  christos 	keep["TIOCSDTR"] = 1; # Same as CONSOLE_X_MODE_ON
    122      1.24  christos 	keep["APM_IOC_SUSPEND"] = 1; # Same as AGPIOC_RELEASE
    123      1.24  christos 	keep["APM_IOC_STANDBY"] = 1; # Same as AGPIOC_ACQUIRE
    124      1.24  christos 	keep["BTDEV_GETINFO"] = 1; # Same as BTSCO_GETINFO
    125      1.24  christos 	keep["BTHSET_GETINFO"] = 1; # Same as BTSCO_GETINFO
    126      1.24  christos 	keep["JOY_GET_X_OFFSET"] = 1; # Same as GDT_IOCTL_CTRCNT
    127      1.24  christos 	keep["JOY_GET_X_OFFSET"] = 1; # Same as GDT_IOCTL_CTRCNT
    128      1.24  christos 	keep["SCIOC_USE_ADF"] = 1; # Same as STICIO_STARTQ
    129      1.24  christos 	keep["SCBUSIOLLSCAN"] = 1; # Same as USB_DISCOVER
    130      1.26  christos 	keep["OPIOCGETNEXT"] = 1; # Same as OFIOCGETNEXT
    131      1.26  christos 	keep["OPIOCGET"] = 1; # Same as OFIOCGET
    132      1.26  christos 	keep["OPIOCGETCHILD"] = 1; # Same as OFIOCGETCHILD
    133      1.26  christos 	keep["OPIOCFINDDEVICE"] = 1; # Same as OFIOCFINDDEVICE
    134      1.26  christos 	keep["OPIOCGETOPTNODE"] = 1; # Same as OFIOCGETOPTNODE
    135      1.26  christos 	keep["OPIOCNEXTPROP"] = 1; # Same as OFIOCNEXTPROP
    136      1.26  christos 	keep["OPIOCSET"] = 1; # Same as OFIOCSET
    137      1.27        he 	keep["MBPPIOCSPARAM"] = 1; # Same as PARIOCSPARAM
    138      1.27        he 	keep["MBPPIOCGPARAM"] = 1; # Same as PARIOCGPARAM
    139      1.28        he 	keep["CLOCKCTL_ADJTIME"] = 1; # Same as TCTRL_MODEM_PWR
    140      1.32        he 	keep["OFIOCNEXTPROP"] = 1; # Same as PNVIOCGETNUMGE
    141      1.32        he 	keep["OFIOCGET"] = 1; # Same as PNVIOCGET
    142      1.35     joerg 	keep["SIOCPHASE2"] = 1; # Same as GRESADDRS
    143      1.35     joerg 	keep["I4B_CTL_CLR_CHIPSTAT"] = 1; # Same as CLOCKCTL_NTP_ADJTIME
    144      1.35     joerg 	keep["STICIO_STARTQ"] = 1; # Same as SPKRTONE
    145      1.35     joerg 	keep["STICIO_RESET860"] = 1; # Same as SCIOCRESTART
    146      1.35     joerg 	keep["STICIO_START860"] = 1; # Same as SPKRTUNE
    147      1.35     joerg 	keep["I4B_CTL_SET_DEBUG"] = 1; # Same as CLOCKCTL_SETTIMEOFDAY
    148      1.35     joerg 
    149      1.35     joerg 	keep["SIOCGETSGCNT_IN6"] = 1; # Type sioc_sg_req6 not exported
    150      1.35     joerg 	keep["SIOCGPRLST_IN6"] = 1; Type in6_oprlist not exported
    151      1.35     joerg 	keep["SIOCGETMIFCNT_IN6"] = 1; Type sioc_mif_req6 not exported
    152      1.24  christos 
    153      1.24  christos 	i = 1;
    154      1.24  christos 	altqt[i++] = "RED";
    155      1.24  christos 	altqt[i++] = "BLUE";
    156      1.24  christos 	altqt[i++] = "RIO";
    157      1.24  christos 	altqt[i++] = "FIFOQ";
    158      1.24  christos 	altqt[i++] = "HFSC";
    159      1.24  christos 	altqt[i++] = "PRIQ";
    160      1.24  christos 	altqt[i++] = "WFQ";
    161      1.24  christos 	altqt[i++] = "CBQ";
    162      1.24  christos 	altqt[i++] = "CNDR";
    163      1.24  christos 
    164      1.24  christos 	i = 1;
    165      1.24  christos 	altqf[i++] = "IF_ATTACH";
    166      1.24  christos 	altqf[i++] = "DISABLE";
    167      1.24  christos 	altqf[i++] = "ENABLE";
    168      1.24  christos 	altqf[i++] = "CONFIG";
    169      1.24  christos 	altqf[i++] = "GETSTATS";
    170      1.24  christos 	altqf[i++] = "IF_DETACH";
    171      1.24  christos 	altqf[i++] = "ADD_CLASS";
    172      1.24  christos 	altqf[i++] = "DEL_CLASS";
    173      1.24  christos 	altqf[i++] = "MOD_CLASS";
    174      1.24  christos 	altqf[i++] = "ADD_FILTER";
    175      1.24  christos 	altqf[i++] = "DEL_FILTER";
    176      1.24  christos 	altqf[i++] = "CLEAR_HIERARCHY";
    177      1.24  christos 
    178      1.24  christos 	for (t in altqt) {
    179      1.24  christos 		for (f in altqf) {
    180      1.24  christos 			keep[altqt[t] "_" altqf[f]] = 1;
    181      1.24  christos 		}
    182      1.24  christos 	}
    183      1.16  christos 
    184      1.10     lukem 	print ""
    185      1.21  christos 	print "#include \"ktrace.h\""
    186       1.1       cgd 	print ""
    187      1.21  christos 	print "const char *"
    188      1.21  christos 	print "ioctlname(u_long val)"
    189       1.1       cgd 	print "{"
    190       1.1       cgd 	print ""
    191      1.16  christos 	print "\tswitch (val) {\n"
    192       1.1       cgd }
    193       1.1       cgd 
    194      1.42  christos /^#[ 	]*define[ 	]*[A-Z0-9_]*[ 	]*[D]*[R]*[M]*_IO[W]*[R]*[ 	]*\(/ {
    195       1.1       cgd 	
    196       1.1       cgd 	# find where the name starts
    197       1.1       cgd 	for (i = 1; i <= NF; i++)
    198       1.1       cgd 		if ($i ~ /define/)
    199       1.1       cgd 			break;
    200       1.1       cgd 	++i;
    201  1.52.2.2    martin 	name = $i;
    202  1.52.2.2    martin 	printf("/* %s [%s] */\n", $0, name);
    203       1.1       cgd 	# 
    204  1.52.2.2    martin 	if (name !~ /^[A-Z0-9a-z_]*$/)
    205  1.52.2.2    martin 		next;
    206  1.52.2.2    martin 	if (keep[name] == 1)
    207  1.52.2.2    martin 		next;
    208  1.52.2.2    martin 	keep[name] = 1;
    209  1.52.2.2    martin 	printf("\t#ifdef %s\n", name);
    210  1.52.2.2    martin 	printf("\tcase %s:\n\t\treturn \"%s\";\n", name, name);
    211  1.52.2.2    martin 	printf("\t#endif /* %s */\n", $i);
    212  1.52.2.2    martin 	name = name;
    213  1.52.2.2    martin 	names[name] = name;
    214  1.52.2.2    martin 	exprs[name] = "";
    215  1.52.2.2    martin 	files[name] = filename;
    216  1.52.2.2    martin 	do {
    217  1.52.2.2    martin 		++i;
    218  1.52.2.2    martin 		exprs[name] = exprs[name] " " $i;
    219  1.52.2.2    martin 	} while ($i !~ /.*)/);
    220  1.52.2.2    martin 	exprs[name] = substr(exprs[name], 2);
    221       1.1       cgd }
    222       1.1       cgd END {
    223      1.16  christos 	print "\tdefault:\n\t\treturn NULL;\n"
    224      1.16  christos 	print "\t}\n"
    225       1.1       cgd 	print "}"
    226  1.52.2.2    martin 	print "const struct ioctlinfo ioctlinfo[] = {\n";
    227  1.52.2.2    martin 	for (name in names) {
    228  1.52.2.2    martin 		printf("\t{ .name = \"%s\", .expr = \"%s\", .value = %s },\n",
    229  1.52.2.2    martin 		    names[name], exprs[name], names[name]);
    230  1.52.2.2    martin 	}
    231  1.52.2.2    martin 	print "\t{ .name = NULL, .expr = NULL, .value = 0 },\n};";
    232       1.1       cgd }
    233       1.5   mycroft '
    234