mkioctls revision 1.54
11.14Schristos#!/bin/sh 21.54Schristos# $NetBSD: mkioctls,v 1.54 2020/04/02 17:40:33 christos Exp $ 31.7Sjtc# 41.7Sjtc# Copyright (c) 1994 51.7Sjtc# The Regents of the University of California. All rights reserved. 61.7Sjtc# 71.7Sjtc# Redistribution and use in source and binary forms, with or without 81.7Sjtc# modification, are permitted provided that the following conditions 91.7Sjtc# are met: 101.7Sjtc# 1. Redistributions of source code must retain the above copyright 111.7Sjtc# notice, this list of conditions and the following disclaimer. 121.7Sjtc# 2. Redistributions in binary form must reproduce the above copyright 131.7Sjtc# notice, this list of conditions and the following disclaimer in the 141.7Sjtc# documentation and/or other materials provided with the distribution. 151.7Sjtc# 3. All advertising materials mentioning features or use of this software 161.7Sjtc# must display the following acknowledgement: 171.7Sjtc# This product includes software developed by the University of 181.7Sjtc# California, Berkeley and its contributors. 191.7Sjtc# 4. Neither the name of the University nor the names of its contributors 201.7Sjtc# may be used to endorse or promote products derived from this software 211.7Sjtc# without specific prior written permission. 221.7Sjtc# 231.7Sjtc# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 241.7Sjtc# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 251.7Sjtc# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 261.7Sjtc# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 271.7Sjtc# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 281.7Sjtc# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 291.7Sjtc# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 301.7Sjtc# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 311.7Sjtc# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 321.7Sjtc# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 331.7Sjtc# SUCH DAMAGE. 341.7Sjtc# 351.7Sjtc# @(#)mkioctls 8.2 (Berkeley) 4/28/95 361.3Smycroft# 371.37Sapb 381.38Sapb: ${AWK:=awk} 391.37Sapb: ${CC:=cc} 401.38Sapb: ${SED:=sed} 411.37Sapb 421.54Schristosset -x 431.54SchristosAWK=gawk 441.54Schristos 451.16Schristosecho "/* Automatically generated file, do not edit! */" 461.21Schristos#echo "#define const" # XXX: timepps lossage 471.14Schristosecho "#define COMPAT_43" 481.35Sjoergecho "#define COMPAT_FREEBSD_NET80211" 491.14Schristosecho "struct lwp;" 501.24Schristosecho "struct crap { int _xxx; };" # XXX arm video lossage 511.24Schristosecho "typedef struct crap videomemory_t;" # XXX arm video lossage 521.24Schristosecho "typedef struct crap RF_AccTotals_t;" # XXX Raidframe lossage 531.24Schristosecho "struct rf_test_acc { int _xxx; };" # XXX Raidframe lossage 541.42Schristosecho "struct map_info { int _xxx[22]; };" # XXX Xorg lossage 551.24Schristosecho "#include <stdio.h>" 561.14Schristosecho "#include <sys/types.h>" 571.14Schristosecho "#include <sys/param.h>" 581.51Smrgecho "#include <sys/mutex.h>" 591.29Sheecho "#ifndef NBPG" 601.29Sheecho "#define NBPG 4096 /* workaround / dummy for sparc */" 611.29Sheecho "#endif /* NBPG */" 621.14Schristosecho "#include <sys/disk.h>" 631.17Shannkenecho "#include <sys/dkbad.h>" 641.14Schristosecho "#include <sys/mount.h>" 651.14Schristosecho "#include <sys/termios.h>" 661.16Schristosecho "#include <sys/disklabel.h>" 671.43Smattecho "#include <sys/exec_elf.h>" 681.14Schristosecho "#include <net/if.h>" 691.24Schristosecho "#include <net/if_ether.h>" 701.14Schristosecho "#include <net/route.h>" 711.14Schristosecho "#include <net/ppp_defs.h>" 721.14Schristosecho "#include <netinet/in.h>" 731.14Schristosecho "#include <netinet/in_systm.h>" 741.14Schristosecho "#include <netinet/ip.h>" 751.14Schristosecho "#include <netinet/ip_mroute.h>" 761.14Schristosecho "#include <netinet/ip_compat.h>" 771.14Schristosecho "#include <net80211/ieee80211.h>" 781.24Schristosecho "#include <net80211/ieee80211_radiotap.h>" 791.24Schristosecho "#include <netinet6/in6_var.h>" 801.24Schristosecho "#include <netinet6/nd6.h>" 811.24Schristosecho "#include <dev/ic/hd44780reg.h>" 821.24Schristosecho "#include <dev/pci/mlyreg.h>" 831.24Schristosecho "#include <prop/proplib.h>" 841.53Srmindecho "#include <nv.h>" 851.41Sdslecho 861.37Sapb 871.46Schristos# kernel headers <sys/*.h> and <net/*.h> should not include stdbool.h 881.46Schristos# but they do; then xf86Opt.h needs a bool struct field. 891.46Schristos 901.46Schristosneedundef=true 911.14Schristosfor i 921.14Schristosdo 931.46Schristos case $i in 941.46Schristos *X11*) 951.46Schristos if $needundef; then 961.46Schristos echo "#undef bool" 971.46Schristos needundef=false; 981.46Schristos fi;; 991.46Schristos esac 1001.14Schristos echo "#include <$i>" 1011.52Schristosdone | ${SED} -e "s,${DESTDIR}/usr/include/,,g" \ 1021.52Schristos -e "s,${DESTDIR}/usr/X11R7/include/,,g" \ 1031.52Schristos -e "s,${NETBSDSRCDIR}/external/cddl/osnet/dist/uts/common/,,g" 1041.14Schristos 1051.46Schristosif ! $needundef; then 1061.46Schristos echo "#define bool _Bool" 1071.46Schristosfi 1081.46Schristos 1091.52Schristos${CC} -E -nostdinc -isystem ${DESTDIR}/usr/include ${CPPFLAGS} -dM "${@}" | \ 1101.52Schristos ${AWK} ' 1111.1ScgdBEGIN { 1121.17Shannken keep["SLIOCGUNIT"] = 1; # Same as PPPIOCGASYNCMAP 1131.19Schristos keep["TUNSLMODE"] = 1; # Same as PPPIOCGASYNCMAP 1141.17Shannken keep["SIOCRMNAT"] = 1; # Same as SIOCRMAFR 1151.17Shannken keep["SIOCADNAT"] = 1; # Same as SIOCADAFR 1161.17Shannken keep["SIOCDELST"] = 1; # Same as SIOCRMNAT 1171.22Schristos keep["SIOCPROXY"] = 1; # Same as SIOCLOOKUPSTAT 1181.17Shannken keep["CHIOGPICKER"] = 1; # Same as CDIOREADTOCHEADER 1191.20Schristos keep["KBDSTPMAT"] = 1; # Same as LMREADY, pcvt is gone so ok. 1201.24Schristos keep["SIOCSLOWAT"] = 1; # Same as SATIOSBUFSIZE 1211.24Schristos keep["UTOPPYIOTURBO"] = 1; # Same as OTIOCSETD 1221.24Schristos keep["TIOCHPCL"] = 1; # Same as UTOPPYIOCANCEL 1231.24Schristos keep["TIOCCBRK"] = 1; # Same as CONSOLE_X_MODE_OFF 1241.24Schristos keep["TIOCSDTR"] = 1; # Same as CONSOLE_X_MODE_ON 1251.24Schristos keep["APM_IOC_SUSPEND"] = 1; # Same as AGPIOC_RELEASE 1261.24Schristos keep["APM_IOC_STANDBY"] = 1; # Same as AGPIOC_ACQUIRE 1271.24Schristos keep["BTDEV_GETINFO"] = 1; # Same as BTSCO_GETINFO 1281.24Schristos keep["BTHSET_GETINFO"] = 1; # Same as BTSCO_GETINFO 1291.24Schristos keep["JOY_GET_X_OFFSET"] = 1; # Same as GDT_IOCTL_CTRCNT 1301.24Schristos keep["JOY_GET_X_OFFSET"] = 1; # Same as GDT_IOCTL_CTRCNT 1311.24Schristos keep["SCIOC_USE_ADF"] = 1; # Same as STICIO_STARTQ 1321.24Schristos keep["SCBUSIOLLSCAN"] = 1; # Same as USB_DISCOVER 1331.26Schristos keep["OPIOCGETNEXT"] = 1; # Same as OFIOCGETNEXT 1341.26Schristos keep["OPIOCGET"] = 1; # Same as OFIOCGET 1351.26Schristos keep["OPIOCGETCHILD"] = 1; # Same as OFIOCGETCHILD 1361.26Schristos keep["OPIOCFINDDEVICE"] = 1; # Same as OFIOCFINDDEVICE 1371.26Schristos keep["OPIOCGETOPTNODE"] = 1; # Same as OFIOCGETOPTNODE 1381.26Schristos keep["OPIOCNEXTPROP"] = 1; # Same as OFIOCNEXTPROP 1391.26Schristos keep["OPIOCSET"] = 1; # Same as OFIOCSET 1401.27She keep["MBPPIOCSPARAM"] = 1; # Same as PARIOCSPARAM 1411.27She keep["MBPPIOCGPARAM"] = 1; # Same as PARIOCGPARAM 1421.28She keep["CLOCKCTL_ADJTIME"] = 1; # Same as TCTRL_MODEM_PWR 1431.32She keep["OFIOCNEXTPROP"] = 1; # Same as PNVIOCGETNUMGE 1441.32She keep["OFIOCGET"] = 1; # Same as PNVIOCGET 1451.35Sjoerg keep["SIOCPHASE2"] = 1; # Same as GRESADDRS 1461.35Sjoerg keep["I4B_CTL_CLR_CHIPSTAT"] = 1; # Same as CLOCKCTL_NTP_ADJTIME 1471.35Sjoerg keep["STICIO_STARTQ"] = 1; # Same as SPKRTONE 1481.35Sjoerg keep["STICIO_RESET860"] = 1; # Same as SCIOCRESTART 1491.35Sjoerg keep["STICIO_START860"] = 1; # Same as SPKRTUNE 1501.35Sjoerg keep["I4B_CTL_SET_DEBUG"] = 1; # Same as CLOCKCTL_SETTIMEOFDAY 1511.35Sjoerg 1521.35Sjoerg keep["SIOCGETSGCNT_IN6"] = 1; # Type sioc_sg_req6 not exported 1531.35Sjoerg keep["SIOCGPRLST_IN6"] = 1; Type in6_oprlist not exported 1541.35Sjoerg keep["SIOCGETMIFCNT_IN6"] = 1; Type sioc_mif_req6 not exported 1551.24Schristos 1561.24Schristos i = 1; 1571.24Schristos altqt[i++] = "RED"; 1581.24Schristos altqt[i++] = "BLUE"; 1591.24Schristos altqt[i++] = "RIO"; 1601.24Schristos altqt[i++] = "FIFOQ"; 1611.24Schristos altqt[i++] = "HFSC"; 1621.24Schristos altqt[i++] = "PRIQ"; 1631.24Schristos altqt[i++] = "WFQ"; 1641.24Schristos altqt[i++] = "CBQ"; 1651.24Schristos altqt[i++] = "CNDR"; 1661.24Schristos 1671.24Schristos i = 1; 1681.24Schristos altqf[i++] = "IF_ATTACH"; 1691.24Schristos altqf[i++] = "DISABLE"; 1701.24Schristos altqf[i++] = "ENABLE"; 1711.24Schristos altqf[i++] = "CONFIG"; 1721.24Schristos altqf[i++] = "GETSTATS"; 1731.24Schristos altqf[i++] = "IF_DETACH"; 1741.24Schristos altqf[i++] = "ADD_CLASS"; 1751.24Schristos altqf[i++] = "DEL_CLASS"; 1761.24Schristos altqf[i++] = "MOD_CLASS"; 1771.24Schristos altqf[i++] = "ADD_FILTER"; 1781.24Schristos altqf[i++] = "DEL_FILTER"; 1791.24Schristos altqf[i++] = "CLEAR_HIERARCHY"; 1801.24Schristos 1811.24Schristos for (t in altqt) { 1821.24Schristos for (f in altqf) { 1831.24Schristos keep[altqt[t] "_" altqf[f]] = 1; 1841.24Schristos } 1851.24Schristos } 1861.16Schristos 1871.10Slukem print "" 1881.21Schristos print "#include \"ktrace.h\"" 1891.1Scgd print "" 1901.21Schristos print "const char *" 1911.21Schristos print "ioctlname(u_long val)" 1921.1Scgd print "{" 1931.1Scgd print "" 1941.16Schristos print "\tswitch (val) {\n" 1951.1Scgd} 1961.1Scgd 1971.42Schristos/^#[ ]*define[ ]*[A-Z0-9_]*[ ]*[D]*[R]*[M]*_IO[W]*[R]*[ ]*\(/ { 1981.1Scgd 1991.1Scgd # find where the name starts 2001.1Scgd for (i = 1; i <= NF; i++) 2011.1Scgd if ($i ~ /define/) 2021.1Scgd break; 2031.1Scgd ++i; 2041.54Schristos name = $i; 2051.54Schristos printf("/* %s [%s] */\n", $0, name); 2061.1Scgd # 2071.54Schristos if (name !~ /^[A-Z0-9a-z_]*$/) 2081.54Schristos next; 2091.54Schristos if (keep[name] == 1) 2101.54Schristos next; 2111.54Schristos keep[name] = 1; 2121.54Schristos printf("\t#ifdef %s\n", name); 2131.54Schristos printf("\tcase %s:\n\t\treturn \"%s\";\n", name, name); 2141.54Schristos printf("\t#endif /* %s */\n", $i); 2151.54Schristos name = name; 2161.54Schristos names[name] = name; 2171.54Schristos exprs[name] = ""; 2181.54Schristos files[name] = filename; 2191.54Schristos do { 2201.54Schristos ++i; 2211.54Schristos exprs[name] = exprs[name] " " $i; 2221.54Schristos } while ($i !~ /.*)/); 2231.54Schristos exprs[name] = substr(exprs[name], 2); 2241.1Scgd} 2251.1ScgdEND { 2261.16Schristos print "\tdefault:\n\t\treturn NULL;\n" 2271.16Schristos print "\t}\n" 2281.1Scgd print "}" 2291.54Schristos print "const struct ioctlinfo ioctlinfo[] = {\n"; 2301.54Schristos for (name in names) { 2311.54Schristos printf("\t{ .name = \"%s\", .expr = \"%s\", .value = %s },\n", 2321.54Schristos names[name], exprs[name], names[name]); 2331.54Schristos } 2341.54Schristos print "\t{ .name = NULL, .expr = NULL, .value = 0 },\n};"; 2351.1Scgd} 2361.5Smycroft' 237