kernel - Fix auto port assignment collision in network code
[dragonfly.git] / usr.bin / kdump / mkioctls
blob1fe09c909b2d4907d80034d31b22cb43a955f3ba
1 #!/bin/sh
3 # $FreeBSD: src/usr.bin/kdump/mkioctls,v 1.15.2.5 2002/11/15 18:22:31 ru Exp $
5 set -e
7 if [ "x$1" = "x-s" ]; then
8 use_switch=1
9 shift
10 else
11 use_switch=0
14 if [ -z "$1" -o -z "$2" ]; then
15 echo "usage: sh $0 [-s] include-dir current-dir"
16 exit 1
19 LC_ALL=C; export LC_ALL
21 # Build a list of headers that have ioctls in them.
22 # Leave out fake softlinks.
23 ioctl_includes=`
24 cd $1
25 find -s * -name '*.h' -follow |
26 egrep -v '^(cam/)|^(compat/)|^(fs/)|^(isofs/)|^(mfs/)|^(msdosfs/)|^(netkey/)|^(netsmb/)|^(nfs/)|^(ntfs/)|^(pccard/)|^(ufs/)' |
27 xargs egrep -l \
28 '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
29 awk '{printf("#include <%s>\\\\n", $1)}'
30 printf '/*\\\\n'
31 printf ' * We should probably install some of these to /usr/include/sys\\\\n'
32 printf ' */\\\\n'
33 printf '#include <bus/firewire/firewire.h>\\\\n'
34 printf '#include <bus/iicbus/iic.h>\\\\n'
35 printf '#include <bus/u4b/storage/rio500_usb.h>\\\\n'
36 printf '#include <dev/acpica/acpiio_mcall.h>\\\\n'
37 printf '#include <dev/disk/iscsi/initiator/iscsi.h>\\\\n'
38 printf '#include <dev/disk/isp/isp_ioctl.h>\\\\n'
39 printf '#include <dev/disk/nvme/nvme_ident.h>\\\\n'
40 printf '#include <dev/disk/nvme/nvme_log.h>\\\\n'
41 printf '#include <dev/disk/nvme/nvme_ns.h>\\\\n'
42 printf '#include <dev/disk/nvme/nvme_chipset.h>\\\\n'
43 printf '#include <dev/disk/nvme/nvme_ioctl.h>\\\\n'
44 printf '#include <dev/drm/include/uapi/drm/drm.h>\\\\n'
45 printf '#include <dev/drm/include/uapi/drm/i915_drm.h>\\\\n'
46 printf '#include <dev/drm/include/uapi/drm/radeon_drm.h>\\\\n'
47 printf '#include <dev/misc/gpio/gpio.h>\\\\n'
48 printf '#include <netproto/802_11/ieee80211_radiotap.h>\\\\n'
49 printf '#include <dev/netif/ath/ath/if_athioctl.h>\\\\n'
50 printf '#include <dev/netif/iwn/if_iwn_ioctl.h>\\\\n'
51 printf '#include <dev/raid/aac/aac_ioctl.h>\\\\n'
52 printf '#include <dev/raid/amr/amrio.h>\\\\n'
53 printf '#include <dev/raid/arcmsr/arcmsr.h>\\\\n'
54 printf '#include <dev/raid/mlx/mlxio.h>\\\\n'
55 printf '#include <net/gre/if_gre.h>\\\\n'
56 printf '#include <net/netmap/netmap.h>\\\\n'
57 printf '#include <vfs/hpfs/hpfs_ioctl.h>\\\\n'
60 awk -v x="$ioctl_includes" 'BEGIN {print x}' |
61 gcc -D_KERNEL_STRUCTURES -E -I$1 -I$2/../../sys -I$2/../../sys/dev/drm/include -dM - |
62 awk -v ioctl_includes="$ioctl_includes" -v use_switch="$use_switch" '
63 BEGIN {
64 print "/* XXX obnoxious prerequisites. */"
65 print "#define _KERNEL_STRUCTURES"
66 print "#include <sys/tty.h>"
67 print "#include <net/if_arp.h>"
68 print "#include <net/route.h>"
69 print "#include <netinet/in.h>"
70 print "#include <net/ip_mroute/ip_mroute.h>"
71 print "#include <netinet6/nd6.h>"
72 print "#include <netinet6/ip6_mroute.h>"
73 print "#include <stdio.h>"
74 print "#include <bus/cam/cam.h>"
75 print "#define ACPI_DEBUG_OUTPUT"
76 print "#define ACPI_APPLICATION"
77 print "#include <contrib/dev/acpica/source/include/acpi.h>"
78 print "#undef ACPI_APPLICATION"
79 print "#undef ACPI_DEBUG_OUTPUT"
80 print ""
81 print ioctl_includes
82 print "const char *ioctlname(u_long);"
83 print ""
84 print "const char *"
85 print "ioctlname(u_long val)"
86 print "{"
87 if (use_switch)
88 print "\tswitch(val) {"
91 /^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
93 # find where the name starts
94 for (i = 1; i <= NF; i++)
95 if ($i ~ /define/)
96 break;
97 ++i;
99 if (use_switch)
100 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
101 else
102 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
106 /^#[ ]*define[ ]+[^ ]+[ ]+DRM_IO/ {
107 if (use_switch)
108 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $2, $2);
109 else
110 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $2, $2);
113 /^#[ ]*define[ ]+[^ ]+[ ]+MIXER_(READ|WRITE)/ {
114 if (use_switch)
115 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $2, $2);
116 else
117 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $2, $2);
120 END {
121 if (use_switch)
122 print "\t}"
123 print "\n\treturn(NULL);"
124 print "}"