aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /scripts/mod
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'scripts/mod')
-rw-r--r--scripts/mod/Makefile16
-rw-r--r--scripts/mod/empty.c1
-rw-r--r--scripts/mod/file2alias.c308
-rw-r--r--scripts/mod/mk_elfconfig.c65
-rw-r--r--scripts/mod/modpost.c797
-rw-r--r--scripts/mod/modpost.h107
-rw-r--r--scripts/mod/sumversion.c498
7 files changed, 1792 insertions, 0 deletions
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile
new file mode 100644
index 00000000000..11d69c35e5b
--- /dev/null
+++ b/scripts/mod/Makefile
@@ -0,0 +1,16 @@
1hostprogs-y := modpost mk_elfconfig
2always := $(hostprogs-y) empty.o
3
4modpost-objs := modpost.o file2alias.o sumversion.o
5
6# dependencies on generated files need to be listed explicitly
7
8$(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h
9
10quiet_cmd_elfconfig = MKELF $@
11 cmd_elfconfig = $(obj)/mk_elfconfig $(ARCH) < $< > $@
12
13$(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE
14 $(call if_changed,elfconfig)
15
16targets += elfconfig.h
diff --git a/scripts/mod/empty.c b/scripts/mod/empty.c
new file mode 100644
index 00000000000..49839cc4ff2
--- /dev/null
+++ b/scripts/mod/empty.c
@@ -0,0 +1 @@
/* empty file to figure out endianness / word size */
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
new file mode 100644
index 00000000000..d54b52d3bb6
--- /dev/null
+++ b/scripts/mod/file2alias.c
@@ -0,0 +1,308 @@
1/* Simple code to turn various tables in an ELF file into alias definitions.
2 * This deals with kernel datastructures where they should be
3 * dealt with: in the kernel source.
4 *
5 * Copyright 2002-2003 Rusty Russell, IBM Corporation
6 * 2003 Kai Germaschewski
7 *
8 *
9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference.
11 */
12
13#include "modpost.h"
14
15/* We use the ELF typedefs for kernel_ulong_t but bite the bullet and
16 * use either stdint.h or inttypes.h for the rest. */
17#if KERNEL_ELFCLASS == ELFCLASS32
18typedef Elf32_Addr kernel_ulong_t;
19#else
20typedef Elf64_Addr kernel_ulong_t;
21#endif
22#ifdef __sun__
23#include <inttypes.h>
24#else
25#include <stdint.h>
26#endif
27
28typedef uint32_t __u32;
29typedef uint16_t __u16;
30typedef unsigned char __u8;
31
32/* Big exception to the "don't include kernel headers into userspace, which
33 * even potentially has different endianness and word sizes, since
34 * we handle those differences explicitly below */
35#include "../../include/linux/mod_devicetable.h"
36
37#define ADD(str, sep, cond, field) \
38do { \
39 strcat(str, sep); \
40 if (cond) \
41 sprintf(str + strlen(str), \
42 sizeof(field) == 1 ? "%02X" : \
43 sizeof(field) == 2 ? "%04X" : \
44 sizeof(field) == 4 ? "%08X" : "", \
45 field); \
46 else \
47 sprintf(str + strlen(str), "*"); \
48} while(0)
49
50/* Looks like "usb:vNpNdlNdhNdcNdscNdpNicNiscNipN" */
51static int do_usb_entry(const char *filename,
52 struct usb_device_id *id, char *alias)
53{
54 id->match_flags = TO_NATIVE(id->match_flags);
55 id->idVendor = TO_NATIVE(id->idVendor);
56 id->idProduct = TO_NATIVE(id->idProduct);
57 id->bcdDevice_lo = TO_NATIVE(id->bcdDevice_lo);
58 id->bcdDevice_hi = TO_NATIVE(id->bcdDevice_hi);
59
60 /*
61 * Some modules (visor) have empty slots as placeholder for
62 * run-time specification that results in catch-all alias
63 */
64 if (!(id->idVendor | id->bDeviceClass | id->bInterfaceClass))
65 return 1;
66
67 strcpy(alias, "usb:");
68 ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR,
69 id->idVendor);
70 ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT,
71 id->idProduct);
72 ADD(alias, "dl", id->match_flags&USB_DEVICE_ID_MATCH_DEV_LO,
73 id->bcdDevice_lo);
74 ADD(alias, "dh", id->match_flags&USB_DEVICE_ID_MATCH_DEV_HI,
75 id->bcdDevice_hi);
76 ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS,
77 id->bDeviceClass);
78 ADD(alias, "dsc",
79 id->match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS,
80 id->bDeviceSubClass);
81 ADD(alias, "dp",
82 id->match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL,
83 id->bDeviceProtocol);
84 ADD(alias, "ic",
85 id->match_flags&USB_DEVICE_ID_MATCH_INT_CLASS,
86 id->bInterfaceClass);
87 ADD(alias, "isc",
88 id->match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS,
89 id->bInterfaceSubClass);
90 ADD(alias, "ip",
91 id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL,
92 id->bInterfaceProtocol);
93 return 1;
94}
95
96/* Looks like: ieee1394:venNmoNspNverN */
97static int do_ieee1394_entry(const char *filename,
98 struct ieee1394_device_id *id, char *alias)
99{
100 id->match_flags = TO_NATIVE(id->match_flags);
101 id->vendor_id = TO_NATIVE(id->vendor_id);
102 id->model_id = TO_NATIVE(id->model_id);
103 id->specifier_id = TO_NATIVE(id->specifier_id);
104 id->version = TO_NATIVE(id->version);
105
106 strcpy(alias, "ieee1394:");
107 ADD(alias, "ven", id->match_flags & IEEE1394_MATCH_VENDOR_ID,
108 id->vendor_id);
109 ADD(alias, "mo", id->match_flags & IEEE1394_MATCH_MODEL_ID,
110 id->model_id);
111 ADD(alias, "sp", id->match_flags & IEEE1394_MATCH_SPECIFIER_ID,
112 id->specifier_id);
113 ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION,
114 id->version);
115
116 return 1;
117}
118
119/* Looks like: pci:vNdNsvNsdNbcNscNiN. */
120static int do_pci_entry(const char *filename,
121 struct pci_device_id *id, char *alias)
122{
123 /* Class field can be divided into these three. */
124 unsigned char baseclass, subclass, interface,
125 baseclass_mask, subclass_mask, interface_mask;
126
127 id->vendor = TO_NATIVE(id->vendor);
128 id->device = TO_NATIVE(id->device);
129 id->subvendor = TO_NATIVE(id->subvendor);
130 id->subdevice = TO_NATIVE(id->subdevice);
131 id->class = TO_NATIVE(id->class);
132 id->class_mask = TO_NATIVE(id->class_mask);
133
134 strcpy(alias, "pci:");
135 ADD(alias, "v", id->vendor != PCI_ANY_ID, id->vendor);
136 ADD(alias, "d", id->device != PCI_ANY_ID, id->device);
137 ADD(alias, "sv", id->subvendor != PCI_ANY_ID, id->subvendor);
138 ADD(alias, "sd", id->subdevice != PCI_ANY_ID, id->subdevice);
139
140 baseclass = (id->class) >> 16;
141 baseclass_mask = (id->class_mask) >> 16;
142 subclass = (id->class) >> 8;
143 subclass_mask = (id->class_mask) >> 8;
144 interface = id->class;
145 interface_mask = id->class_mask;
146
147 if ((baseclass_mask != 0 && baseclass_mask != 0xFF)
148 || (subclass_mask != 0 && subclass_mask != 0xFF)
149 || (interface_mask != 0 && interface_mask != 0xFF)) {
150 fprintf(stderr,
151 "*** Warning: Can't handle masks in %s:%04X\n",
152 filename, id->class_mask);
153 return 0;
154 }
155
156 ADD(alias, "bc", baseclass_mask == 0xFF, baseclass);
157 ADD(alias, "sc", subclass_mask == 0xFF, subclass);
158 ADD(alias, "i", interface_mask == 0xFF, interface);
159 return 1;
160}
161
162/* looks like: "ccw:tNmNdtNdmN" */
163static int do_ccw_entry(const char *filename,
164 struct ccw_device_id *id, char *alias)
165{
166 id->match_flags = TO_NATIVE(id->match_flags);
167 id->cu_type = TO_NATIVE(id->cu_type);
168 id->cu_model = TO_NATIVE(id->cu_model);
169 id->dev_type = TO_NATIVE(id->dev_type);
170 id->dev_model = TO_NATIVE(id->dev_model);
171
172 strcpy(alias, "ccw:");
173 ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE,
174 id->cu_type);
175 ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL,
176 id->cu_model);
177 ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
178 id->dev_type);
179 ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
180 id->dev_model);
181 ret