3 # $FreeBSD: src/usr.bin/kdump/mkioctls,v 1.15.2.5 2002/11/15 18:22:31 ru Exp $
7 if [ "x$1" = "x-s" ]; then
14 if [ -z "$1" -o -z "$2" ]; then
15 echo "usage: sh $0 [-s] include-dir current-dir"
19 LC_ALL
=C
; export LC_ALL
21 # Build a list of headers that have ioctls in them.
22 # Leave out fake softlinks.
25 find -s * -name '*.h' -follow |
26 egrep -v '^(cam/)|^(compat/)|^(fs/)|^(isofs/)|^(mfs/)|^(msdosfs/)|^(netkey/)|^(netsmb/)|^(nfs/)|^(ntfs/)|^(pccard/)|^(ufs/)' |
28 '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
29 awk '{printf("#include <%s>\\\\n", $1)}'
31 printf ' * We should probably install some of these to /usr/include/sys\\\\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" '
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"
82 print "const char *ioctlname(u_long);"
85 print "ioctlname(u_long val)"
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++)
100 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
102 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
106 /^#[ ]*define[ ]+[^ ]+[ ]+DRM_IO/ {
108 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $2, $2);
110 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $2, $2);
113 /^#[ ]*define[ ]+[^ ]+[ ]+MIXER_(READ|WRITE)/ {
115 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $2, $2);
117 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $2, $2);
123 print "\n\treturn(NULL);"