119e4b9c5Schristos#!/bin/sh 2*3f011d89Sroy# $NetBSD: mkioctls,v 1.57 2020/09/12 01:36:26 roy Exp $ 39cffeee5Sjtc# 49cffeee5Sjtc# Copyright (c) 1994 59cffeee5Sjtc# The Regents of the University of California. All rights reserved. 69cffeee5Sjtc# 79cffeee5Sjtc# Redistribution and use in source and binary forms, with or without 89cffeee5Sjtc# modification, are permitted provided that the following conditions 99cffeee5Sjtc# are met: 109cffeee5Sjtc# 1. Redistributions of source code must retain the above copyright 119cffeee5Sjtc# notice, this list of conditions and the following disclaimer. 129cffeee5Sjtc# 2. Redistributions in binary form must reproduce the above copyright 139cffeee5Sjtc# notice, this list of conditions and the following disclaimer in the 149cffeee5Sjtc# documentation and/or other materials provided with the distribution. 159cffeee5Sjtc# 3. All advertising materials mentioning features or use of this software 169cffeee5Sjtc# must display the following acknowledgement: 179cffeee5Sjtc# This product includes software developed by the University of 189cffeee5Sjtc# California, Berkeley and its contributors. 199cffeee5Sjtc# 4. Neither the name of the University nor the names of its contributors 209cffeee5Sjtc# may be used to endorse or promote products derived from this software 219cffeee5Sjtc# without specific prior written permission. 229cffeee5Sjtc# 239cffeee5Sjtc# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 249cffeee5Sjtc# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 259cffeee5Sjtc# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 269cffeee5Sjtc# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 279cffeee5Sjtc# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 289cffeee5Sjtc# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 299cffeee5Sjtc# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 309cffeee5Sjtc# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 319cffeee5Sjtc# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 329cffeee5Sjtc# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 339cffeee5Sjtc# SUCH DAMAGE. 349cffeee5Sjtc# 359cffeee5Sjtc# @(#)mkioctls 8.2 (Berkeley) 4/28/95 362fd45120Smycroft# 37cd5c0f94Sapb 38cd5c0f94Sapb: ${AWK:=awk} 39125b7c8cSapb: ${CC:=cc} 40125b7c8cSapb: ${SED:=sed} 41cd5c0f94Sapb 42ff5de511Schristosecho "/* Automatically generated file, do not edit! */" 4358fc70c4Schristos#echo "#define const" # XXX: timepps lossage 4419e4b9c5Schristosecho "#define COMPAT_43" 45e1032da5Sjoergecho "#define COMPAT_FREEBSD_NET80211" 4619e4b9c5Schristosecho "struct lwp;" 4756991565Schristosecho "struct crap { int _xxx; };" # XXX arm video lossage 4856991565Schristosecho "typedef struct crap videomemory_t;" # XXX arm video lossage 4956991565Schristosecho "typedef struct crap RF_AccTotals_t;" # XXX Raidframe lossage 5056991565Schristosecho "struct rf_test_acc { int _xxx; };" # XXX Raidframe lossage 51e4344b28Schristosecho "struct map_info { int _xxx[22]; };" # XXX Xorg lossage 5256991565Schristosecho "#include <stdio.h>" 5319e4b9c5Schristosecho "#include <sys/types.h>" 5419e4b9c5Schristosecho "#include <sys/param.h>" 55446e08b1Smrgecho "#include <sys/mutex.h>" 560b5587a8Sheecho "#ifndef NBPG" 570b5587a8Sheecho "#define NBPG 4096 /* workaround / dummy for sparc */" 580b5587a8Sheecho "#endif /* NBPG */" 5919e4b9c5Schristosecho "#include <sys/disk.h>" 6097b2d151Shannkenecho "#include <sys/dkbad.h>" 6119e4b9c5Schristosecho "#include <sys/mount.h>" 6219e4b9c5Schristosecho "#include <sys/termios.h>" 63ff5de511Schristosecho "#include <sys/disklabel.h>" 642a4267c6Smattecho "#include <sys/exec_elf.h>" 6519e4b9c5Schristosecho "#include <net/if.h>" 6656991565Schristosecho "#include <net/if_ether.h>" 6719e4b9c5Schristosecho "#include <net/route.h>" 6819e4b9c5Schristosecho "#include <net/ppp_defs.h>" 6919e4b9c5Schristosecho "#include <netinet/in.h>" 70*3f011d89Sroyecho "#include <netinet/in_var.h>" 7119e4b9c5Schristosecho "#include <netinet/in_systm.h>" 7219e4b9c5Schristosecho "#include <netinet/ip.h>" 7319e4b9c5Schristosecho "#include <netinet/ip_mroute.h>" 7419e4b9c5Schristosecho "#include <netinet/ip_compat.h>" 7519e4b9c5Schristosecho "#include <net80211/ieee80211.h>" 7656991565Schristosecho "#include <net80211/ieee80211_radiotap.h>" 7756991565Schristosecho "#include <netinet6/in6_var.h>" 7856991565Schristosecho "#include <netinet6/nd6.h>" 7956991565Schristosecho "#include <dev/ic/hd44780reg.h>" 8056991565Schristosecho "#include <dev/pci/mlyreg.h>" 8156991565Schristosecho "#include <prop/proplib.h>" 8239013e66Srmindecho "#include <nv.h>" 835df8622dSdslecho 84cd5c0f94Sapb 85d4d3ff8aSchristos# kernel headers <sys/*.h> and <net/*.h> should not include stdbool.h 86d4d3ff8aSchristos# but they do; then xf86Opt.h needs a bool struct field. 87d4d3ff8aSchristos 88d4d3ff8aSchristosneedundef=true 8919e4b9c5Schristosfor i 9019e4b9c5Schristosdo 91d4d3ff8aSchristos case $i in 92d4d3ff8aSchristos *X11*) 93d4d3ff8aSchristos if $needundef; then 94d4d3ff8aSchristos echo "#undef bool" 95d4d3ff8aSchristos needundef=false; 96d4d3ff8aSchristos fi;; 97d4d3ff8aSchristos esac 9819e4b9c5Schristos echo "#include <$i>" 99bf830a41Schristosdone | ${SED} -e "s,${DESTDIR}/usr/include/,,g" \ 100bf830a41Schristos -e "s,${DESTDIR}/usr/X11R7/include/,,g" \ 101bf830a41Schristos -e "s,${NETBSDSRCDIR}/external/cddl/osnet/dist/uts/common/,,g" 10219e4b9c5Schristos 103d4d3ff8aSchristosif ! $needundef; then 104d4d3ff8aSchristos echo "#define bool _Bool" 105d4d3ff8aSchristosfi 106d4d3ff8aSchristos 107bf830a41Schristos${CC} -E -nostdinc -isystem ${DESTDIR}/usr/include ${CPPFLAGS} -dM "${@}" | \ 108cd5c0f94Sapb ${AWK} ' 10957935c67ScgdBEGIN { 11097b2d151Shannken keep["SLIOCGUNIT"] = 1; # Same as PPPIOCGASYNCMAP 111ab5ca5c5Schristos keep["TUNSLMODE"] = 1; # Same as PPPIOCGASYNCMAP 11297b2d151Shannken keep["SIOCRMNAT"] = 1; # Same as SIOCRMAFR 11397b2d151Shannken keep["SIOCADNAT"] = 1; # Same as SIOCADAFR 11497b2d151Shannken keep["SIOCDELST"] = 1; # Same as SIOCRMNAT 1157042b963Schristos keep["SIOCPROXY"] = 1; # Same as SIOCLOOKUPSTAT 11697b2d151Shannken keep["CHIOGPICKER"] = 1; # Same as CDIOREADTOCHEADER 117750fc375Schristos keep["KBDSTPMAT"] = 1; # Same as LMREADY, pcvt is gone so ok. 11856991565Schristos keep["SIOCSLOWAT"] = 1; # Same as SATIOSBUFSIZE 11956991565Schristos keep["UTOPPYIOTURBO"] = 1; # Same as OTIOCSETD 12056991565Schristos keep["TIOCHPCL"] = 1; # Same as UTOPPYIOCANCEL 12156991565Schristos keep["TIOCCBRK"] = 1; # Same as CONSOLE_X_MODE_OFF 12256991565Schristos keep["TIOCSDTR"] = 1; # Same as CONSOLE_X_MODE_ON 12356991565Schristos keep["APM_IOC_SUSPEND"] = 1; # Same as AGPIOC_RELEASE 12456991565Schristos keep["APM_IOC_STANDBY"] = 1; # Same as AGPIOC_ACQUIRE 12556991565Schristos keep["BTDEV_GETINFO"] = 1; # Same as BTSCO_GETINFO 12656991565Schristos keep["BTHSET_GETINFO"] = 1; # Same as BTSCO_GETINFO 12756991565Schristos keep["JOY_GET_X_OFFSET"] = 1; # Same as GDT_IOCTL_CTRCNT 12856991565Schristos keep["JOY_GET_X_OFFSET"] = 1; # Same as GDT_IOCTL_CTRCNT 12956991565Schristos keep["SCIOC_USE_ADF"] = 1; # Same as STICIO_STARTQ 13056991565Schristos keep["SCBUSIOLLSCAN"] = 1; # Same as USB_DISCOVER 131659537b3Schristos keep["OPIOCGETNEXT"] = 1; # Same as OFIOCGETNEXT 132659537b3Schristos keep["OPIOCGET"] = 1; # Same as OFIOCGET 133659537b3Schristos keep["OPIOCGETCHILD"] = 1; # Same as OFIOCGETCHILD 134659537b3Schristos keep["OPIOCFINDDEVICE"] = 1; # Same as OFIOCFINDDEVICE 135659537b3Schristos keep["OPIOCGETOPTNODE"] = 1; # Same as OFIOCGETOPTNODE 136659537b3Schristos keep["OPIOCNEXTPROP"] = 1; # Same as OFIOCNEXTPROP 137659537b3Schristos keep["OPIOCSET"] = 1; # Same as OFIOCSET 138061f5e87She keep["MBPPIOCSPARAM"] = 1; # Same as PARIOCSPARAM 139061f5e87She keep["MBPPIOCGPARAM"] = 1; # Same as PARIOCGPARAM 140276f9c83She keep["CLOCKCTL_ADJTIME"] = 1; # Same as TCTRL_MODEM_PWR 141b2898f29She keep["OFIOCNEXTPROP"] = 1; # Same as PNVIOCGETNUMGE 142b2898f29She keep["OFIOCGET"] = 1; # Same as PNVIOCGET 143e1032da5Sjoerg keep["SIOCPHASE2"] = 1; # Same as GRESADDRS 144e1032da5Sjoerg keep["I4B_CTL_CLR_CHIPSTAT"] = 1; # Same as CLOCKCTL_NTP_ADJTIME 145e1032da5Sjoerg keep["STICIO_STARTQ"] = 1; # Same as SPKRTONE 146e1032da5Sjoerg keep["STICIO_RESET860"] = 1; # Same as SCIOCRESTART 147e1032da5Sjoerg keep["STICIO_START860"] = 1; # Same as SPKRTUNE 148e1032da5Sjoerg keep["I4B_CTL_SET_DEBUG"] = 1; # Same as CLOCKCTL_SETTIMEOFDAY 149e1032da5Sjoerg 150e1032da5Sjoerg keep["SIOCGETSGCNT_IN6"] = 1; # Type sioc_sg_req6 not exported 151e1032da5Sjoerg keep["SIOCGPRLST_IN6"] = 1; Type in6_oprlist not exported 152e1032da5Sjoerg keep["SIOCGETMIFCNT_IN6"] = 1; Type sioc_mif_req6 not exported 15356991565Schristos 15456991565Schristos i = 1; 15556991565Schristos altqt[i++] = "RED"; 15656991565Schristos altqt[i++] = "BLUE"; 15756991565Schristos altqt[i++] = "RIO"; 15856991565Schristos altqt[i++] = "FIFOQ"; 15956991565Schristos altqt[i++] = "HFSC"; 16056991565Schristos altqt[i++] = "PRIQ"; 16156991565Schristos altqt[i++] = "WFQ"; 16256991565Schristos altqt[i++] = "CBQ"; 16356991565Schristos altqt[i++] = "CNDR"; 16456991565Schristos 16556991565Schristos i = 1; 16656991565Schristos altqf[i++] = "IF_ATTACH"; 16756991565Schristos altqf[i++] = "DISABLE"; 16856991565Schristos altqf[i++] = "ENABLE"; 16956991565Schristos altqf[i++] = "CONFIG"; 17056991565Schristos altqf[i++] = "GETSTATS"; 17156991565Schristos altqf[i++] = "IF_DETACH"; 17256991565Schristos altqf[i++] = "ADD_CLASS"; 17356991565Schristos altqf[i++] = "DEL_CLASS"; 17456991565Schristos altqf[i++] = "MOD_CLASS"; 17556991565Schristos altqf[i++] = "ADD_FILTER"; 17656991565Schristos altqf[i++] = "DEL_FILTER"; 17756991565Schristos altqf[i++] = "CLEAR_HIERARCHY"; 17856991565Schristos 17956991565Schristos for (t in altqt) { 18056991565Schristos for (f in altqf) { 18156991565Schristos keep[altqt[t] "_" altqf[f]] = 1; 18256991565Schristos } 18356991565Schristos } 184ff5de511Schristos 18557935c67Scgd print "" 18658fc70c4Schristos print "#include \"ktrace.h\"" 1870dd4a8e6Slukem print "" 18858fc70c4Schristos print "const char *" 18958fc70c4Schristos print "ioctlname(u_long val)" 19057935c67Scgd print "{" 19157935c67Scgd print "" 192ff5de511Schristos print "\tswitch (val) {\n" 19357935c67Scgd} 19457935c67Scgd 195e4344b28Schristos/^#[ ]*define[ ]*[A-Z0-9_]*[ ]*[D]*[R]*[M]*_IO[W]*[R]*[ ]*\(/ { 19657935c67Scgd 19757935c67Scgd # find where the name starts 19857935c67Scgd for (i = 1; i <= NF; i++) 19957935c67Scgd if ($i ~ /define/) 20057935c67Scgd break; 20157935c67Scgd ++i; 202e30be371Schristos name = $i; 203e30be371Schristos printf("/* %s [%s] */\n", $0, name); 20457935c67Scgd # 205e30be371Schristos if (name !~ /^[A-Z0-9a-z_]*$/) 206e30be371Schristos next; 207e30be371Schristos if (keep[name] == 1) 208e30be371Schristos next; 209e30be371Schristos keep[name] = 1; 210e30be371Schristos printf("\t#ifdef %s\n", name); 211e30be371Schristos printf("\tcase %s:\n\t\treturn \"%s\";\n", name, name); 212e82b090fSchristos printf("\t#endif /* %s */\n", $i); 213e30be371Schristos name = name; 214e30be371Schristos names[name] = name; 215e30be371Schristos exprs[name] = ""; 216e30be371Schristos files[name] = filename; 217e30be371Schristos do { 218e30be371Schristos ++i; 219e30be371Schristos exprs[name] = exprs[name] " " $i; 220e30be371Schristos } while ($i !~ /.*)/); 221e30be371Schristos exprs[name] = substr(exprs[name], 2); 222ab5ca5c5Schristos} 22357935c67ScgdEND { 224ff5de511Schristos print "\tdefault:\n\t\treturn NULL;\n" 225ff5de511Schristos print "\t}\n" 22657935c67Scgd print "}" 227e30be371Schristos print "const struct ioctlinfo ioctlinfo[] = {\n"; 228e30be371Schristos for (name in names) { 229e30be371Schristos printf("\t{ .name = \"%s\", .expr = \"%s\", .value = %s },\n", 230e30be371Schristos names[name], exprs[name], names[name]); 231e30be371Schristos } 232e30be371Schristos print "\t{ .name = NULL, .expr = NULL, .value = 0 },\n};"; 23357935c67Scgd} 2347a7adcb7Smycroft' 235