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.
5 * Copyright 2002-2003 Rusty Russell, IBM Corporation
6 * 2003 Kai Germaschewski
9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference.
14 #include "devicetable-offsets.h"
16 /* We use the ELF typedefs for kernel_ulong_t but bite the bullet and
17 * use either stdint.h or inttypes.h for the rest. */
18 #if KERNEL_ELFCLASS == ELFCLASS32
19 typedef Elf32_Addr kernel_ulong_t
;
20 #define BITS_PER_LONG 32
22 typedef Elf64_Addr kernel_ulong_t
;
23 #define BITS_PER_LONG 64
34 typedef uint32_t __u32
;
35 typedef uint16_t __u16
;
36 typedef unsigned char __u8
;
38 /* Big exception to the "don't include kernel headers into userspace, which
39 * even potentially has different endianness and word sizes, since
40 * we handle those differences explicitly below */
41 #include "../../include/linux/mod_devicetable.h"
43 /* This array collects all instances that use the generic do_table */
45 const char *device_id
; /* name of table, __mod_<name>__*_device_table. */
46 unsigned long id_size
;
50 #define ___cat(a,b) a ## b
51 #define __cat(a,b) ___cat(a,b)
53 /* we need some special handling for this host tool running eventually on
54 * Darwin. The Mach-O section handling is a bit different than ELF section
55 * handling. The differnces in detail are:
56 * a) we have segments which have sections
57 * b) we need a API call to get the respective section symbols */
59 #include <mach-o/getsect.h>
61 #define INIT_SECTION(name) do { \
62 unsigned long name ## _len; \
63 char *__cat(pstart_,name) = getsectdata("__TEXT", \
64 #name, &__cat(name,_len)); \
65 char *__cat(pstop_,name) = __cat(pstart_,name) + \
67 __cat(__start_,name) = (void *)__cat(pstart_,name); \
68 __cat(__stop_,name) = (void *)__cat(pstop_,name); \
70 #define SECTION(name) __attribute__((section("__TEXT, " #name)))
72 struct devtable
**__start___devtable
, **__stop___devtable
;
74 #define INIT_SECTION(name) /* no-op for ELF */
75 #define SECTION(name) __attribute__((section(#name)))
77 /* We construct a table of pointers in an ELF section (pointers generally
78 * go unpadded by gcc). ld creates boundary syms for us. */
79 extern struct devtable
*__start___devtable
[], *__stop___devtable
[];
83 # if __GNUC__ == 3 && __GNUC_MINOR__ < 3
84 # define __used __attribute__((__unused__))
86 # define __used __attribute__((__used__))
90 /* Define a variable f that holds the value of field f of struct devid
93 #define DEF_FIELD(m, devid, f) \
94 typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
95 /* Define a variable f that holds the address of field f of struct devid
96 * based at address m. Due to the way typeof works, for a field of type
97 * T[N] the variable has type T(*)[N], _not_ T*.
99 #define DEF_FIELD_ADDR(m, devid, f) \
100 typeof(((struct devid *)0)->f) *f = ((m) + OFF_##devid##_##f)
102 /* Add a table entry. We test function type matches while we're here. */
103 #define ADD_TO_DEVTABLE(device_id, type, function) \
104 static struct devtable __cat(devtable,__LINE__) = { \
105 device_id + 0*sizeof((function)((const char *)NULL, \
108 SIZE_##type, (function) }; \
109 static struct devtable *SECTION(__devtable) __used \
110 __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__)
112 #define ADD(str, sep, cond, field) \
116 sprintf(str + strlen(str), \
117 sizeof(field) == 1 ? "%02X" : \
118 sizeof(field) == 2 ? "%04X" : \
119 sizeof(field) == 4 ? "%08X" : "", \
122 sprintf(str + strlen(str), "*"); \
125 /* Always end in a wildcard, for future extension */
126 static inline void add_wildcard(char *str
)
128 int len
= strlen(str
);
130 if (str
[len
- 1] != '*')
131 strcat(str
+ len
, "*");
135 * Check that sizeof(device_id type) are consistent with size of section
136 * in .o file. If in-consistent then userspace and kernel does not agree
137 * on actual size which is a bug.
138 * Also verify that the final entry in the table is all zeros.
139 * Ignore both checks if build host differ from target host and size differs.
141 static void device_id_check(const char *modname
, const char *device_id
,
142 unsigned long size
, unsigned long id_size
,
147 if (size
% id_size
|| size
< id_size
) {
148 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
150 "section __mod_%s__<identifier>_device_table=%lu.\n"
151 "Fix definition of struct %s_device_id "
152 "in mod_devicetable.h\n",
153 modname
, device_id
, id_size
, device_id
, size
, device_id
);
155 /* Verify last one is a terminator */
156 for (i
= 0; i
< id_size
; i
++ ) {
157 if (*(uint8_t*)(symval
+size
-id_size
+i
)) {
158 fprintf(stderr
,"%s: struct %s_device_id is %lu bytes. "
159 "The last of %lu is:\n",
160 modname
, device_id
, id_size
, size
/ id_size
);
161 for (i
= 0; i
< id_size
; i
++ )
162 fprintf(stderr
,"0x%02x ",
163 *(uint8_t*)(symval
+size
-id_size
+i
) );
164 fprintf(stderr
,"\n");
165 fatal("%s: struct %s_device_id is not terminated "
166 "with a NULL entry!\n", modname
, device_id
);
171 /* USB is special because the bcdDevice can be matched against a numeric range */
172 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
173 static void do_usb_entry(void *symval
,
174 unsigned int bcdDevice_initial
, int bcdDevice_initial_digits
,
175 unsigned char range_lo
, unsigned char range_hi
,
176 unsigned char max
, struct module
*mod
)
179 DEF_FIELD(symval
, usb_device_id
, match_flags
);
180 DEF_FIELD(symval
, usb_device_id
, idVendor
);
181 DEF_FIELD(symval
, usb_device_id
, idProduct
);
182 DEF_FIELD(symval
, usb_device_id
, bcdDevice_lo
);
183 DEF_FIELD(symval
, usb_device_id
, bDeviceClass
);
184 DEF_FIELD(symval
, usb_device_id
, bDeviceSubClass
);
185 DEF_FIELD(symval
, usb_device_id
, bDeviceProtocol
);
186 DEF_FIELD(symval
, usb_device_id
, bInterfaceClass
);
187 DEF_FIELD(symval
, usb_device_id
, bInterfaceSubClass
);
188 DEF_FIELD(symval
, usb_device_id
, bInterfaceProtocol
);
189 DEF_FIELD(symval
, usb_device_id
, bInterfaceNumber
);
191 strcpy(alias
, "usb:");
192 ADD(alias
, "v", match_flags
&USB_DEVICE_ID_MATCH_VENDOR
,
194 ADD(alias
, "p", match_flags
&USB_DEVICE_ID_MATCH_PRODUCT
,
198 if (bcdDevice_initial_digits
)
199 sprintf(alias
+ strlen(alias
), "%0*X",
200 bcdDevice_initial_digits
, bcdDevice_initial
);
201 if (range_lo
== range_hi
)
202 sprintf(alias
+ strlen(alias
), "%X", range_lo
);
203 else if (range_lo
> 0 || range_hi
< max
) {
204 if (range_lo
> 0x9 || range_hi
< 0xA)
205 sprintf(alias
+ strlen(alias
),
210 sprintf(alias
+ strlen(alias
),
211 range_lo
< 0x9 ? "[%X-9" : "[%X",
213 sprintf(alias
+ strlen(alias
),
214 range_hi
> 0xA ? "A-%X]" : "%X]",
218 if (bcdDevice_initial_digits
< (sizeof(bcdDevice_lo
) * 2 - 1))
221 ADD(alias
, "dc", match_flags
&USB_DEVICE_ID_MATCH_DEV_CLASS
,
223 ADD(alias
, "dsc", match_flags
&USB_DEVICE_ID_MATCH_DEV_SUBCLASS
,
225 ADD(alias
, "dp", match_flags
&USB_DEVICE_ID_MATCH_DEV_PROTOCOL
,
227 ADD(alias
, "ic", match_flags
&USB_DEVICE_ID_MATCH_INT_CLASS
,
229 ADD(alias
, "isc", match_flags
&USB_DEVICE_ID_MATCH_INT_SUBCLASS
,
231 ADD(alias
, "ip", match_flags
&USB_DEVICE_ID_MATCH_INT_PROTOCOL
,
233 ADD(alias
, "in", match_flags
&USB_DEVICE_ID_MATCH_INT_NUMBER
,
237 buf_printf(&mod
->dev_table_buf
,
238 "MODULE_ALIAS(\"%s\");\n", alias
);
241 /* Handles increment/decrement of BCD formatted integers */
242 /* Returns the previous value, so it works like i++ or i-- */
243 static unsigned int incbcd(unsigned int *bcd
,
248 unsigned int init
= *bcd
, i
, j
;
249 unsigned long long c
, dec
= 0;
251 /* If bcd is not in BCD format, just increment */
257 /* Convert BCD to Decimal */
258 for (i
=0 ; i
< chars
; i
++) {
259 c
= (*bcd
>> (i
<< 2)) & 0xf;
260 c
= c
> 9 ? 9 : c
; /* force to bcd just in case */
261 for (j
=0 ; j
< i
; j
++)
266 /* Do our increment/decrement */
270 /* Convert back to BCD */
271 for (i
=0 ; i
< chars
; i
++) {
272 for (c
=1,j
=0 ; j
< i
; j
++)
275 *bcd
+= c
<< (i
<< 2);
280 static void do_usb_entry_multi(void *symval
, struct module
*mod
)
282 unsigned int devlo
, devhi
;
283 unsigned char chi
, clo
, max
;
286 DEF_FIELD(symval
, usb_device_id
, match_flags
);
287 DEF_FIELD(symval
, usb_device_id
, idVendor
);
288 DEF_FIELD(symval
, usb_device_id
, idProduct
);
289 DEF_FIELD(symval
, usb_device_id
, bcdDevice_lo
);
290 DEF_FIELD(symval
, usb_device_id
, bcdDevice_hi
);
291 DEF_FIELD(symval
, usb_device_id
, bDeviceClass
);
292 DEF_FIELD(symval
, usb_device_id
, bInterfaceClass
);
294 devlo
= match_flags
& USB_DEVICE_ID_MATCH_DEV_LO
?
296 devhi
= match_flags
& USB_DEVICE_ID_MATCH_DEV_HI
?
297 bcdDevice_hi
: ~0x0U
;
299 /* Figure out if this entry is in bcd or hex format */
300 max
= 0x9; /* Default to decimal format */
301 for (ndigits
= 0 ; ndigits
< sizeof(bcdDevice_lo
) * 2 ; ndigits
++) {
302 clo
= (devlo
>> (ndigits
<< 2)) & 0xf;
303 chi
= ((devhi
> 0x9999 ? 0x9999 : devhi
) >> (ndigits
<< 2)) & 0xf;
304 if (clo
> max
|| chi
> max
) {
311 * Some modules (visor) have empty slots as placeholder for
312 * run-time specification that results in catch-all alias
314 if (!(idVendor
| idProduct
| bDeviceClass
| bInterfaceClass
))
317 /* Convert numeric bcdDevice range into fnmatch-able pattern(s) */
318 for (ndigits
= sizeof(bcdDevice_lo
) * 2 - 1; devlo
<= devhi
; ndigits
--) {
321 if (chi
> max
) /* If we are in bcd mode, truncate if necessary */
326 if (devlo
== devhi
|| !ndigits
) {
327 do_usb_entry(symval
, devlo
, ndigits
, clo
, chi
, max
, mod
);
333 incbcd(&devlo
, 1, max
,
334 sizeof(bcdDevice_lo
) * 2),
335 ndigits
, clo
, max
, max
, mod
);
339 incbcd(&devhi
, -1, max
,
340 sizeof(bcdDevice_lo
) * 2),
341 ndigits
, 0x0, chi
, max
, mod
);
345 static void do_usb_table(void *symval
, unsigned long size
,
349 const unsigned long id_size
= SIZE_usb_device_id
;
351 device_id_check(mod
->name
, "usb", size
, id_size
, symval
);
353 /* Leave last one: it's the terminator. */
356 for (i
= 0; i
< size
; i
+= id_size
)
357 do_usb_entry_multi(symval
+ i
, mod
);
360 /* Looks like: hid:bNvNpN */
361 static int do_hid_entry(const char *filename
,
362 void *symval
, char *alias
)
364 DEF_FIELD(symval
, hid_device_id
, bus
);
365 DEF_FIELD(symval
, hid_device_id
, group
);
366 DEF_FIELD(symval
, hid_device_id
, vendor
);
367 DEF_FIELD(symval
, hid_device_id
, product
);
369 sprintf(alias
, "hid:");
370 ADD(alias
, "b", bus
!= HID_BUS_ANY
, bus
);
371 ADD(alias
, "g", group
!= HID_GROUP_ANY
, group
);
372 ADD(alias
, "v", vendor
!= HID_ANY_ID
, vendor
);
373 ADD(alias
, "p", product
!= HID_ANY_ID
, product
);
377 ADD_TO_DEVTABLE("hid", hid_device_id
, do_hid_entry
);
379 /* Looks like: ieee1394:venNmoNspNverN */
380 static int do_ieee1394_entry(const char *filename
,
381 void *symval
, char *alias
)
383 DEF_FIELD(symval
, ieee1394_device_id
, match_flags
);
384 DEF_FIELD(symval
, ieee1394_device_id
, vendor_id
);
385 DEF_FIELD(symval
, ieee1394_device_id
, model_id
);
386 DEF_FIELD(symval
, ieee1394_device_id
, specifier_id
);
387 DEF_FIELD(symval
, ieee1394_device_id
, version
);
389 strcpy(alias
, "ieee1394:");
390 ADD(alias
, "ven", match_flags
& IEEE1394_MATCH_VENDOR_ID
,
392 ADD(alias
, "mo", match_flags
& IEEE1394_MATCH_MODEL_ID
,
394 ADD(alias
, "sp", match_flags
& IEEE1394_MATCH_SPECIFIER_ID
,
396 ADD(alias
, "ver", match_flags
& IEEE1394_MATCH_VERSION
,
402 ADD_TO_DEVTABLE("ieee1394", ieee1394_device_id
, do_ieee1394_entry
);
404 /* Looks like: pci:vNdNsvNsdNbcNscNiN. */
405 static int do_pci_entry(const char *filename
,
406 void *symval
, char *alias
)
408 /* Class field can be divided into these three. */
409 unsigned char baseclass
, subclass
, interface
,
410 baseclass_mask
, subclass_mask
, interface_mask
;
412 DEF_FIELD(symval
, pci_device_id
, vendor
);
413 DEF_FIELD(symval
, pci_device_id
, device
);
414 DEF_FIELD(symval
, pci_device_id
, subvendor
);
415 DEF_FIELD(symval
, pci_device_id
, subdevice
);
416 DEF_FIELD(symval
, pci_device_id
, class);
417 DEF_FIELD(symval
, pci_device_id
, class_mask
);
419 strcpy(alias
, "pci:");
420 ADD(alias
, "v", vendor
!= PCI_ANY_ID
, vendor
);
421 ADD(alias
, "d", device
!= PCI_ANY_ID
, device
);
422 ADD(alias
, "sv", subvendor
!= PCI_ANY_ID
, subvendor
);
423 ADD(alias
, "sd", subdevice
!= PCI_ANY_ID
, subdevice
);
425 baseclass
= (class) >> 16;
426 baseclass_mask
= (class_mask
) >> 16;
427 subclass
= (class) >> 8;
428 subclass_mask
= (class_mask
) >> 8;
430 interface_mask
= class_mask
;
432 if ((baseclass_mask
!= 0 && baseclass_mask
!= 0xFF)
433 || (subclass_mask
!= 0 && subclass_mask
!= 0xFF)
434 || (interface_mask
!= 0 && interface_mask
!= 0xFF)) {
435 warn("Can't handle masks in %s:%04X\n",
436 filename
, class_mask
);
440 ADD(alias
, "bc", baseclass_mask
== 0xFF, baseclass
);
441 ADD(alias
, "sc", subclass_mask
== 0xFF, subclass
);
442 ADD(alias
, "i", interface_mask
== 0xFF, interface
);
446 ADD_TO_DEVTABLE("pci", pci_device_id
, do_pci_entry
);
448 /* looks like: "ccw:tNmNdtNdmN" */
449 static int do_ccw_entry(const char *filename
,
450 void *symval
, char *alias
)
452 DEF_FIELD(symval
, ccw_device_id
, match_flags
);
453 DEF_FIELD(symval
, ccw_device_id
, cu_type
);
454 DEF_FIELD(symval
, ccw_device_id
, cu_model
);
455 DEF_FIELD(symval
, ccw_device_id
, dev_type
);
456 DEF_FIELD(symval
, ccw_device_id
, dev_model
);
458 strcpy(alias
, "ccw:");
459 ADD(alias
, "t", match_flags
&CCW_DEVICE_ID_MATCH_CU_TYPE
,
461 ADD(alias
, "m", match_flags
&CCW_DEVICE_ID_MATCH_CU_MODEL
,
463 ADD(alias
, "dt", match_flags
&CCW_DEVICE_ID_MATCH_DEVICE_TYPE
,
465 ADD(alias
, "dm", match_flags
&CCW_DEVICE_ID_MATCH_DEVICE_MODEL
,
470 ADD_TO_DEVTABLE("ccw", ccw_device_id
, do_ccw_entry
);
472 /* looks like: "ap:tN" */
473 static int do_ap_entry(const char *filename
,
474 void *symval
, char *alias
)
476 DEF_FIELD(symval
, ap_device_id
, dev_type
);
478 sprintf(alias
, "ap:t%02X*", dev_type
);
481 ADD_TO_DEVTABLE("ap", ap_device_id
, do_ap_entry
);
483 /* looks like: "css:tN" */
484 static int do_css_entry(const char *filename
,
485 void *symval
, char *alias
)
487 DEF_FIELD(symval
, css_device_id
, type
);
489 sprintf(alias
, "css:t%01X", type
);
492 ADD_TO_DEVTABLE("css", css_device_id
, do_css_entry
);
494 /* Looks like: "serio:tyNprNidNexN" */
495 static int do_serio_entry(const char *filename
,
496 void *symval
, char *alias
)
498 DEF_FIELD(symval
, serio_device_id
, type
);
499 DEF_FIELD(symval
, serio_device_id
, proto
);
500 DEF_FIELD(symval
, serio_device_id
, id
);
501 DEF_FIELD(symval
, serio_device_id
, extra
);
503 strcpy(alias
, "serio:");
504 ADD(alias
, "ty", type
!= SERIO_ANY
, type
);
505 ADD(alias
, "pr", proto
!= SERIO_ANY
, proto
);
506 ADD(alias
, "id", id
!= SERIO_ANY
, id
);
507 ADD(alias
, "ex", extra
!= SERIO_ANY
, extra
);
512 ADD_TO_DEVTABLE("serio", serio_device_id
, do_serio_entry
);
514 /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */
515 static int do_acpi_entry(const char *filename
,
516 void *symval
, char *alias
)
518 DEF_FIELD_ADDR(symval
, acpi_device_id
, id
);
519 sprintf(alias
, "acpi*:%s:*", *id
);
522 ADD_TO_DEVTABLE("acpi", acpi_device_id
, do_acpi_entry
);
524 /* looks like: "pnp:dD" */
525 static void do_pnp_device_entry(void *symval
, unsigned long size
,
528 const unsigned long id_size
= SIZE_pnp_device_id
;
529 const unsigned int count
= (size
/ id_size
)-1;
532 device_id_check(mod
->name
, "pnp", size
, id_size
, symval
);
534 for (i
= 0; i
< count
; i
++) {
535 DEF_FIELD_ADDR(symval
+ i
*id_size
, pnp_device_id
, id
);
536 char acpi_id
[sizeof(*id
)];
539 buf_printf(&mod
->dev_table_buf
,
540 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id
);
542 /* fix broken pnp bus lowercasing */
543 for (j
= 0; j
< sizeof(acpi_id
); j
++)
544 acpi_id
[j
] = toupper((*id
)[j
]);
545 buf_printf(&mod
->dev_table_buf
,
546 "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id
);
550 /* looks like: "pnp:dD" for every device of the card */
551 static void do_pnp_card_entries(void *symval
, unsigned long size
,
554 const unsigned long id_size
= SIZE_pnp_card_device_id
;
555 const unsigned int count
= (size
/ id_size
)-1;
558 device_id_check(mod
->name
, "pnp", size
, id_size
, symval
);
560 for (i
= 0; i
< count
; i
++) {
562 DEF_FIELD_ADDR(symval
+ i
*id_size
, pnp_card_device_id
, devs
);
564 for (j
= 0; j
< PNP_MAX_DEVICES
; j
++) {
565 const char *id
= (char *)(*devs
)[j
].id
;
572 /* find duplicate, already added value */
573 for (i2
= 0; i2
< i
&& !dup
; i2
++) {
574 DEF_FIELD_ADDR(symval
+ i2
*id_size
, pnp_card_device_id
, devs
);
576 for (j2
= 0; j2
< PNP_MAX_DEVICES
; j2
++) {
577 const char *id2
= (char *)(*devs
)[j2
].id
;
582 if (!strcmp(id
, id2
)) {
589 /* add an individual alias for every device entry */
591 char acpi_id
[PNP_ID_LEN
];
594 buf_printf(&mod
->dev_table_buf
,
595 "MODULE_ALIAS(\"pnp:d%s*\");\n", id
);
597 /* fix broken pnp bus lowercasing */
598 for (k
= 0; k
< sizeof(acpi_id
); k
++)
599 acpi_id
[k
] = toupper(id
[k
]);
600 buf_printf(&mod
->dev_table_buf
,
601 "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id
);
607 /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */
608 static int do_pcmcia_entry(const char *filename
,
609 void *symval
, char *alias
)
612 DEF_FIELD(symval
, pcmcia_device_id
, match_flags
);
613 DEF_FIELD(symval
, pcmcia_device_id
, manf_id
);
614 DEF_FIELD(symval
, pcmcia_device_id
, card_id
);
615 DEF_FIELD(symval
, pcmcia_device_id
, func_id
);
616 DEF_FIELD(symval
, pcmcia_device_id
, function
);
617 DEF_FIELD(symval
, pcmcia_device_id
, device_no
);
618 DEF_FIELD_ADDR(symval
, pcmcia_device_id
, prod_id_hash
);
620 for (i
=0; i
<4; i
++) {
621 (*prod_id_hash
)[i
] = TO_NATIVE((*prod_id_hash
)[i
]);
624 strcpy(alias
, "pcmcia:");
625 ADD(alias
, "m", match_flags
& PCMCIA_DEV_ID_MATCH_MANF_ID
,
627 ADD(alias
, "c", match_flags
& PCMCIA_DEV_ID_MATCH_CARD_ID
,
629 ADD(alias
, "f", match_flags
& PCMCIA_DEV_ID_MATCH_FUNC_ID
,
631 ADD(alias
, "fn", match_flags
& PCMCIA_DEV_ID_MATCH_FUNCTION
,
633 ADD(alias
, "pfn", match_flags
& PCMCIA_DEV_ID_MATCH_DEVICE_NO
,
635 ADD(alias
, "pa", match_flags
& PCMCIA_DEV_ID_MATCH_PROD_ID1
, (*prod_id_hash
)[0]);
636 ADD(alias
, "pb", match_flags
& PCMCIA_DEV_ID_MATCH_PROD_ID2
, (*prod_id_hash
)[1]);
637 ADD(alias
, "pc", match_flags
& PCMCIA_DEV_ID_MATCH_PROD_ID3
, (*prod_id_hash
)[2]);
638 ADD(alias
, "pd", match_flags
& PCMCIA_DEV_ID_MATCH_PROD_ID4
, (*prod_id_hash
)[3]);
643 ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id
, do_pcmcia_entry
);
645 static int do_of_entry (const char *filename
, void *symval
, char *alias
)
649 DEF_FIELD_ADDR(symval
, of_device_id
, name
);
650 DEF_FIELD_ADDR(symval
, of_device_id
, type
);
651 DEF_FIELD_ADDR(symval
, of_device_id
, compatible
);
653 len
= sprintf(alias
, "of:N%sT%s", (*name
)[0] ? *name
: "*",
654 (*type
)[0] ? *type
: "*");
657 sprintf(&alias
[len
], "%sC%s", (*type
)[0] ? "*" : "",
660 /* Replace all whitespace with underscores */
661 for (tmp
= alias
; tmp
&& *tmp
; tmp
++)
668 ADD_TO_DEVTABLE("of", of_device_id
, do_of_entry
);
670 static int do_vio_entry(const char *filename
, void *symval
,
674 DEF_FIELD_ADDR(symval
, vio_device_id
, type
);
675 DEF_FIELD_ADDR(symval
, vio_device_id
, compat
);
677 sprintf(alias
, "vio:T%sS%s", (*type
)[0] ? *type
: "*",
678 (*compat
)[0] ? *compat
: "*");
680 /* Replace all whitespace with underscores */
681 for (tmp
= alias
; tmp
&& *tmp
; tmp
++)
688 ADD_TO_DEVTABLE("vio", vio_device_id
, do_vio_entry
);
690 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
692 static void do_input(char *alias
,
693 kernel_ulong_t
*arr
, unsigned int min
, unsigned int max
)
697 for (i
= min
/ BITS_PER_LONG
; i
< max
/ BITS_PER_LONG
+ 1; i
++)
698 arr
[i
] = TO_NATIVE(arr
[i
]);
699 for (i
= min
; i
< max
; i
++)
700 if (arr
[i
/ BITS_PER_LONG
] & (1L << (i
%BITS_PER_LONG
)))
701 sprintf(alias
+ strlen(alias
), "%X,*", i
);
704 /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */
705 static int do_input_entry(const char *filename
, void *symval
,
708 DEF_FIELD(symval
, input_device_id
, flags
);
709 DEF_FIELD(symval
, input_device_id
, bustype
);
710 DEF_FIELD(symval
, input_device_id
, vendor
);
711 DEF_FIELD(symval
, input_device_id
, product
);
712 DEF_FIELD(symval
, input_device_id
, version
);
713 DEF_FIELD_ADDR(symval
, input_device_id
, evbit
);
714 DEF_FIELD_ADDR(symval
, input_device_id
, keybit
);
715 DEF_FIELD_ADDR(symval
, input_device_id
, relbit
);
716 DEF_FIELD_ADDR(symval
, input_device_id
, absbit
);
717 DEF_FIELD_ADDR(symval
, input_device_id
, mscbit
);
718 DEF_FIELD_ADDR(symval
, input_device_id
, ledbit
);
719 DEF_FIELD_ADDR(symval
, input_device_id
, sndbit
);
720 DEF_FIELD_ADDR(symval
, input_device_id
, ffbit
);
721 DEF_FIELD_ADDR(symval
, input_device_id
, swbit
);
723 sprintf(alias
, "input:");
725 ADD(alias
, "b", flags
& INPUT_DEVICE_ID_MATCH_BUS
, bustype
);
726 ADD(alias
, "v", flags
& INPUT_DEVICE_ID_MATCH_VENDOR
, vendor
);
727 ADD(alias
, "p", flags
& INPUT_DEVICE_ID_MATCH_PRODUCT
, product
);
728 ADD(alias
, "e", flags
& INPUT_DEVICE_ID_MATCH_VERSION
, version
);
730 sprintf(alias
+ strlen(alias
), "-e*");
731 if (flags
& INPUT_DEVICE_ID_MATCH_EVBIT
)
732 do_input(alias
, *evbit
, 0, INPUT_DEVICE_ID_EV_MAX
);
733 sprintf(alias
+ strlen(alias
), "k*");
734 if (flags
& INPUT_DEVICE_ID_MATCH_KEYBIT
)
735 do_input(alias
, *keybit
,
736 INPUT_DEVICE_ID_KEY_MIN_INTERESTING
,
737 INPUT_DEVICE_ID_KEY_MAX
);
738 sprintf(alias
+ strlen(alias
), "r*");
739 if (flags
& INPUT_DEVICE_ID_MATCH_RELBIT
)
740 do_input(alias
, *relbit
, 0, INPUT_DEVICE_ID_REL_MAX
);
741 sprintf(alias
+ strlen(alias
), "a*");
742 if (flags
& INPUT_DEVICE_ID_MATCH_ABSBIT
)
743 do_input(alias
, *absbit
, 0, INPUT_DEVICE_ID_ABS_MAX
);
744 sprintf(alias
+ strlen(alias
), "m*");
745 if (flags
& INPUT_DEVICE_ID_MATCH_MSCIT
)
746 do_input(alias
, *mscbit
, 0, INPUT_DEVICE_ID_MSC_MAX
);
747 sprintf(alias
+ strlen(alias
), "l*");
748 if (flags
& INPUT_DEVICE_ID_MATCH_LEDBIT
)
749 do_input(alias
, *ledbit
, 0, INPUT_DEVICE_ID_LED_MAX
);
750 sprintf(alias
+ strlen(alias
), "s*");
751 if (flags
& INPUT_DEVICE_ID_MATCH_SNDBIT
)
752 do_input(alias
, *sndbit
, 0, INPUT_DEVICE_ID_SND_MAX
);
753 sprintf(alias
+ strlen(alias
), "f*");
754 if (flags
& INPUT_DEVICE_ID_MATCH_FFBIT
)
755 do_input(alias
, *ffbit
, 0, INPUT_DEVICE_ID_FF_MAX
);
756 sprintf(alias
+ strlen(alias
), "w*");
757 if (flags
& INPUT_DEVICE_ID_MATCH_SWBIT
)
758 do_input(alias
, *swbit
, 0, INPUT_DEVICE_ID_SW_MAX
);
761 ADD_TO_DEVTABLE("input", input_device_id
, do_input_entry
);
763 static int do_eisa_entry(const char *filename
, void *symval
,
766 DEF_FIELD_ADDR(symval
, eisa_device_id
, sig
);
768 sprintf(alias
, EISA_DEVICE_MODALIAS_FMT
"*", *sig
);
773 ADD_TO_DEVTABLE("eisa", eisa_device_id
, do_eisa_entry
);
775 /* Looks like: parisc:tNhvNrevNsvN */
776 static int do_parisc_entry(const char *filename
, void *symval
,
779 DEF_FIELD(symval
, parisc_device_id
, hw_type
);
780 DEF_FIELD(symval
, parisc_device_id
, hversion
);
781 DEF_FIELD(symval
, parisc_device_id
, hversion_rev
);
782 DEF_FIELD(symval
, parisc_device_id
, sversion
);
784 strcpy(alias
, "parisc:");
785 ADD(alias
, "t", hw_type
!= PA_HWTYPE_ANY_ID
, hw_type
);
786 ADD(alias
, "hv", hversion
!= PA_HVERSION_ANY_ID
, hversion
);
787 ADD(alias
, "rev", hversion_rev
!= PA_HVERSION_REV_ANY_ID
, hversion_rev
);
788 ADD(alias
, "sv", sversion
!= PA_SVERSION_ANY_ID
, sversion
);
793 ADD_TO_DEVTABLE("parisc", parisc_device_id
, do_parisc_entry
);
795 /* Looks like: sdio:cNvNdN. */
796 static int do_sdio_entry(const char *filename
,
797 void *symval
, char *alias
)
799 DEF_FIELD(symval
, sdio_device_id
, class);
800 DEF_FIELD(symval
, sdio_device_id
, vendor
);
801 DEF_FIELD(symval
, sdio_device_id
, device
);
803 strcpy(alias
, "sdio:");
804 ADD(alias
, "c", class != (__u8
)SDIO_ANY_ID
, class);
805 ADD(alias
, "v", vendor
!= (__u16
)SDIO_ANY_ID
, vendor
);
806 ADD(alias
, "d", device
!= (__u16
)SDIO_ANY_ID
, device
);
810 ADD_TO_DEVTABLE("sdio", sdio_device_id
, do_sdio_entry
);
812 /* Looks like: ssb:vNidNrevN. */
813 static int do_ssb_entry(const char *filename
,
814 void *symval
, char *alias
)
816 DEF_FIELD(symval
, ssb_device_id
, vendor
);
817 DEF_FIELD(symval
, ssb_device_id
, coreid
);
818 DEF_FIELD(symval
, ssb_device_id
, revision
);
820 strcpy(alias
, "ssb:");
821 ADD(alias
, "v", vendor
!= SSB_ANY_VENDOR
, vendor
);
822 ADD(alias
, "id", coreid
!= SSB_ANY_ID
, coreid
);
823 ADD(alias
, "rev", revision
!= SSB_ANY_REV
, revision
);
827 ADD_TO_DEVTABLE("ssb", ssb_device_id
, do_ssb_entry
);
829 /* Looks like: bcma:mNidNrevNclN. */
830 static int do_bcma_entry(const char *filename
,
831 void *symval
, char *alias
)
833 DEF_FIELD(symval
, bcma_device_id
, manuf
);
834 DEF_FIELD(symval
, bcma_device_id
, id
);
835 DEF_FIELD(symval
, bcma_device_id
, rev
);
836 DEF_FIELD(symval
, bcma_device_id
, class);
838 strcpy(alias
, "bcma:");
839 ADD(alias
, "m", manuf
!= BCMA_ANY_MANUF
, manuf
);
840 ADD(alias
, "id", id
!= BCMA_ANY_ID
, id
);
841 ADD(alias
, "rev", rev
!= BCMA_ANY_REV
, rev
);
842 ADD(alias
, "cl", class != BCMA_ANY_CLASS
, class);
846 ADD_TO_DEVTABLE("bcma", bcma_device_id
, do_bcma_entry
);
848 /* Looks like: virtio:dNvN */
849 static int do_virtio_entry(const char *filename
, void *symval
,
852 DEF_FIELD(symval
, virtio_device_id
, device
);
853 DEF_FIELD(symval
, virtio_device_id
, vendor
);
855 strcpy(alias
, "virtio:");
856 ADD(alias
, "d", device
!= VIRTIO_DEV_ANY_ID
, device
);
857 ADD(alias
, "v", vendor
!= VIRTIO_DEV_ANY_ID
, vendor
);
862 ADD_TO_DEVTABLE("virtio", virtio_device_id
, do_virtio_entry
);
865 * Looks like: vmbus:guid
866 * Each byte of the guid will be represented by two hex characters
870 static int do_vmbus_entry(const char *filename
, void *symval
,
874 DEF_FIELD_ADDR(symval
, hv_vmbus_device_id
, guid
);
875 char guid_name
[(sizeof(*guid
) + 1) * 2];
877 for (i
= 0; i
< (sizeof(*guid
) * 2); i
+= 2)
878 sprintf(&guid_name
[i
], "%02x", TO_NATIVE((*guid
)[i
/2]));
880 strcpy(alias
, "vmbus:");
881 strcat(alias
, guid_name
);
885 ADD_TO_DEVTABLE("vmbus", hv_vmbus_device_id
, do_vmbus_entry
);
887 /* Looks like: i2c:S */
888 static int do_i2c_entry(const char *filename
, void *symval
,
891 DEF_FIELD_ADDR(symval
, i2c_device_id
, name
);
892 sprintf(alias
, I2C_MODULE_PREFIX
"%s", *name
);
896 ADD_TO_DEVTABLE("i2c", i2c_device_id
, do_i2c_entry
);
898 /* Looks like: spi:S */
899 static int do_spi_entry(const char *filename
, void *symval
,
902 DEF_FIELD_ADDR(symval
, spi_device_id
, name
);
903 sprintf(alias
, SPI_MODULE_PREFIX
"%s", *name
);
907 ADD_TO_DEVTABLE("spi", spi_device_id
, do_spi_entry
);
909 static const struct dmifield
{
913 { "bvn", DMI_BIOS_VENDOR
},
914 { "bvr", DMI_BIOS_VERSION
},
915 { "bd", DMI_BIOS_DATE
},
916 { "svn", DMI_SYS_VENDOR
},
917 { "pn", DMI_PRODUCT_NAME
},
918 { "pvr", DMI_PRODUCT_VERSION
},
919 { "rvn", DMI_BOARD_VENDOR
},
920 { "rn", DMI_BOARD_NAME
},
921 { "rvr", DMI_BOARD_VERSION
},
922 { "cvn", DMI_CHASSIS_VENDOR
},
923 { "ct", DMI_CHASSIS_TYPE
},
924 { "cvr", DMI_CHASSIS_VERSION
},
928 static void dmi_ascii_filter(char *d
, const char *s
)
930 /* Filter out characters we don't want to see in the modalias string */
932 if (*s
> ' ' && *s
< 127 && *s
!= ':')
939 static int do_dmi_entry(const char *filename
, void *symval
,
943 DEF_FIELD_ADDR(symval
, dmi_system_id
, matches
);
944 sprintf(alias
, "dmi*");
946 for (i
= 0; i
< ARRAY_SIZE(dmi_fields
); i
++) {
947 for (j
= 0; j
< 4; j
++) {
948 if ((*matches
)[j
].slot
&&
949 (*matches
)[j
].slot
== dmi_fields
[i
].field
) {
950 sprintf(alias
+ strlen(alias
), ":%s*",
951 dmi_fields
[i
].prefix
);
952 dmi_ascii_filter(alias
+ strlen(alias
),
953 (*matches
)[j
].substr
);
962 ADD_TO_DEVTABLE("dmi", dmi_system_id
, do_dmi_entry
);
964 static int do_platform_entry(const char *filename
,
965 void *symval
, char *alias
)
967 DEF_FIELD_ADDR(symval
, platform_device_id
, name
);
968 sprintf(alias
, PLATFORM_MODULE_PREFIX
"%s", *name
);
971 ADD_TO_DEVTABLE("platform", platform_device_id
, do_platform_entry
);
973 static int do_mdio_entry(const char *filename
,
974 void *symval
, char *alias
)
977 DEF_FIELD(symval
, mdio_device_id
, phy_id
);
978 DEF_FIELD(symval
, mdio_device_id
, phy_id_mask
);
980 alias
+= sprintf(alias
, MDIO_MODULE_PREFIX
);
982 for (i
= 0; i
< 32; i
++) {
983 if (!((phy_id_mask
>> (31-i
)) & 1))
985 else if ((phy_id
>> (31-i
)) & 1)
991 /* Terminate the string */
996 ADD_TO_DEVTABLE("mdio", mdio_device_id
, do_mdio_entry
);
998 /* Looks like: zorro:iN. */
999 static int do_zorro_entry(const char *filename
, void *symval
,
1002 DEF_FIELD(symval
, zorro_device_id
, id
);
1003 strcpy(alias
, "zorro:");
1004 ADD(alias
, "i", id
!= ZORRO_WILDCARD
, id
);
1007 ADD_TO_DEVTABLE("zorro", zorro_device_id
, do_zorro_entry
);
1009 /* looks like: "pnp:dD" */
1010 static int do_isapnp_entry(const char *filename
,
1011 void *symval
, char *alias
)
1013 DEF_FIELD(symval
, isapnp_device_id
, vendor
);
1014 DEF_FIELD(symval
, isapnp_device_id
, function
);
1015 sprintf(alias
, "pnp:d%c%c%c%x%x%x%x*",
1016 'A' + ((vendor
>> 2) & 0x3f) - 1,
1017 'A' + (((vendor
& 3) << 3) | ((vendor
>> 13) & 7)) - 1,
1018 'A' + ((vendor
>> 8) & 0x1f) - 1,
1019 (function
>> 4) & 0x0f, function
& 0x0f,
1020 (function
>> 12) & 0x0f, (function
>> 8) & 0x0f);
1023 ADD_TO_DEVTABLE("isapnp", isapnp_device_id
, do_isapnp_entry
);
1025 /* Looks like: "ipack:fNvNdN". */
1026 static int do_ipack_entry(const char *filename
,
1027 void *symval
, char *alias
)
1029 DEF_FIELD(symval
, ipack_device_id
, format
);
1030 DEF_FIELD(symval
, ipack_device_id
, vendor
);
1031 DEF_FIELD(symval
, ipack_device_id
, device
);
1032 strcpy(alias
, "ipack:");
1033 ADD(alias
, "f", format
!= IPACK_ANY_FORMAT
, format
);
1034 ADD(alias
, "v", vendor
!= IPACK_ANY_ID
, vendor
);
1035 ADD(alias
, "d", device
!= IPACK_ANY_ID
, device
);
1036 add_wildcard(alias
);
1039 ADD_TO_DEVTABLE("ipack", ipack_device_id
, do_ipack_entry
);
1042 * Append a match expression for a single masked hex digit.
1043 * outp points to a pointer to the character at which to append.
1044 * *outp is updated on return to point just after the appended text,
1045 * to facilitate further appending.
1047 static void append_nibble_mask(char **outp
,
1048 unsigned int nibble
, unsigned int mask
)
1059 p
+= sprintf(p
, "%X", nibble
);
1064 * Dumbly emit a match pattern for all possible matching
1065 * digits. This could be improved in some cases using ranges,
1066 * but it has the advantage of being trivially correct, and is
1070 for (i
= 0; i
< 0x10; i
++)
1071 if ((i
& mask
) == nibble
)
1072 p
+= sprintf(p
, "%X", i
);
1076 /* Ensure that the string remains NUL-terminated: */
1079 /* Advance the caller's end-of-string pointer: */
1084 * looks like: "amba:dN"
1086 * N is exactly 8 digits, where each is an upper-case hex digit, or
1087 * a ? or [] pattern matching exactly one digit.
1089 static int do_amba_entry(const char *filename
,
1090 void *symval
, char *alias
)
1094 DEF_FIELD(symval
, amba_id
, id
);
1095 DEF_FIELD(symval
, amba_id
, mask
);
1097 if ((id
& mask
) != id
)
1098 fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: "
1099 "id=0x%08X, mask=0x%08X. Please fix this driver.\n",
1100 filename
, id
, mask
);
1102 p
+= sprintf(alias
, "amba:d");
1103 for (digit
= 0; digit
< 8; digit
++)
1104 append_nibble_mask(&p
,
1105 (id
>> (4 * (7 - digit
))) & 0xf,
1106 (mask
>> (4 * (7 - digit
))) & 0xf);
1110 ADD_TO_DEVTABLE("amba", amba_id
, do_amba_entry
);
1113 * looks like: "mipscdmm:tN"
1115 * N is exactly 2 digits, where each is an upper-case hex digit, or
1116 * a ? or [] pattern matching exactly one digit.
1118 static int do_mips_cdmm_entry(const char *filename
,
1119 void *symval
, char *alias
)
1121 DEF_FIELD(symval
, mips_cdmm_device_id
, type
);
1123 sprintf(alias
, "mipscdmm:t%02X*", type
);
1126 ADD_TO_DEVTABLE("mipscdmm", mips_cdmm_device_id
, do_mips_cdmm_entry
);
1128 /* LOOKS like cpu:type:x86,venVVVVfamFFFFmodMMMM:feature:*,FEAT,*
1129 * All fields are numbers. It would be nicer to use strings for vendor
1130 * and feature, but getting those out of the build system here is too
1134 static int do_x86cpu_entry(const char *filename
, void *symval
,
1137 DEF_FIELD(symval
, x86_cpu_id
, feature
);
1138 DEF_FIELD(symval
, x86_cpu_id
, family
);
1139 DEF_FIELD(symval
, x86_cpu_id
, model
);
1140 DEF_FIELD(symval
, x86_cpu_id
, vendor
);
1142 strcpy(alias
, "cpu:type:x86,");
1143 ADD(alias
, "ven", vendor
!= X86_VENDOR_ANY
, vendor
);
1144 ADD(alias
, "fam", family
!= X86_FAMILY_ANY
, family
);
1145 ADD(alias
, "mod", model
!= X86_MODEL_ANY
, model
);
1146 strcat(alias
, ":feature:*");
1147 if (feature
!= X86_FEATURE_ANY
)
1148 sprintf(alias
+ strlen(alias
), "%04X*", feature
);
1151 ADD_TO_DEVTABLE("x86cpu", x86_cpu_id
, do_x86cpu_entry
);
1153 /* LOOKS like cpu:type:*:feature:*FEAT* */
1154 static int do_cpu_entry(const char *filename
, void *symval
, char *alias
)
1156 DEF_FIELD(symval
, cpu_feature
, feature
);
1158 sprintf(alias
, "cpu:type:*:feature:*%04X*", feature
);
1161 ADD_TO_DEVTABLE("cpu", cpu_feature
, do_cpu_entry
);
1163 /* Looks like: mei:S */
1164 static int do_mei_entry(const char *filename
, void *symval
,
1167 DEF_FIELD_ADDR(symval
, mei_cl_device_id
, name
);
1169 sprintf(alias
, MEI_CL_MODULE_PREFIX
"%s", *name
);
1173 ADD_TO_DEVTABLE("mei", mei_cl_device_id
, do_mei_entry
);
1175 /* Looks like: rapidio:vNdNavNadN */
1176 static int do_rio_entry(const char *filename
,
1177 void *symval
, char *alias
)
1179 DEF_FIELD(symval
, rio_device_id
, did
);
1180 DEF_FIELD(symval
, rio_device_id
, vid
);
1181 DEF_FIELD(symval
, rio_device_id
, asm_did
);
1182 DEF_FIELD(symval
, rio_device_id
, asm_vid
);
1184 strcpy(alias
, "rapidio:");
1185 ADD(alias
, "v", vid
!= RIO_ANY_ID
, vid
);
1186 ADD(alias
, "d", did
!= RIO_ANY_ID
, did
);
1187 ADD(alias
, "av", asm_vid
!= RIO_ANY_ID
, asm_vid
);
1188 ADD(alias
, "ad", asm_did
!= RIO_ANY_ID
, asm_did
);
1190 add_wildcard(alias
);
1193 ADD_TO_DEVTABLE("rapidio", rio_device_id
, do_rio_entry
);
1195 /* Does namelen bytes of name exactly match the symbol? */
1196 static bool sym_is(const char *name
, unsigned namelen
, const char *symbol
)
1198 if (namelen
!= strlen(symbol
))
1201 return memcmp(name
, symbol
, namelen
) == 0;
1204 static void do_table(void *symval
, unsigned long size
,
1205 unsigned long id_size
,
1206 const char *device_id
,
1212 int (*do_entry
)(const char *, void *entry
, char *alias
) = function
;
1214 device_id_check(mod
->name
, device_id
, size
, id_size
, symval
);
1215 /* Leave last one: it's the terminator. */
1218 for (i
= 0; i
< size
; i
+= id_size
) {
1219 if (do_entry(mod
->name
, symval
+i
, alias
)) {
1220 buf_printf(&mod
->dev_table_buf
,
1221 "MODULE_ALIAS(\"%s\");\n", alias
);
1226 /* Create MODULE_ALIAS() statements.
1227 * At this time, we cannot write the actual output C source yet,
1228 * so we write into the mod->dev_table_buf buffer. */
1229 void handle_moddevtable(struct module
*mod
, struct elf_info
*info
,
1230 Elf_Sym
*sym
, const char *symname
)
1234 const char *name
, *identifier
;
1235 unsigned int namelen
;
1237 /* We're looking for a section relative symbol */
1238 if (!sym
->st_shndx
|| get_secindex(info
, sym
) >= info
->num_sections
)
1241 /* We're looking for an object */
1242 if (ELF_ST_TYPE(sym
->st_info
) != STT_OBJECT
)
1245 /* All our symbols are of form <prefix>__mod_<name>__<identifier>_device_table. */
1246 name
= strstr(symname
, "__mod_");
1249 name
+= strlen("__mod_");
1250 namelen
= strlen(name
);
1251 if (namelen
< strlen("_device_table"))
1253 if (strcmp(name
+ namelen
- strlen("_device_table"), "_device_table"))
1255 identifier
= strstr(name
, "__");
1258 namelen
= identifier
- name
;
1260 /* Handle all-NULL symbols allocated into .bss */
1261 if (info
->sechdrs
[get_secindex(info
, sym
)].sh_type
& SHT_NOBITS
) {
1262 zeros
= calloc(1, sym
->st_size
);
1265 symval
= (void *)info
->hdr
1266 + info
->sechdrs
[get_secindex(info
, sym
)].sh_offset
1270 /* First handle the "special" cases */
1271 if (sym_is(name
, namelen
, "usb"))
1272 do_usb_table(symval
, sym
->st_size
, mod
);
1273 else if (sym_is(name
, namelen
, "pnp"))
1274 do_pnp_device_entry(symval
, sym
->st_size
, mod
);
1275 else if (sym_is(name
, namelen
, "pnp_card"))
1276 do_pnp_card_entries(symval
, sym
->st_size
, mod
);
1278 struct devtable
**p
;
1279 INIT_SECTION(__devtable
);
1281 for (p
= __start___devtable
; p
< __stop___devtable
; p
++) {
1282 if (sym_is(name
, namelen
, (*p
)->device_id
)) {
1283 do_table(symval
, sym
->st_size
, (*p
)->id_size
,
1284 (*p
)->device_id
, (*p
)->function
, mod
);
1292 /* Now add out buffered information to the generated C source */
1293 void add_moddevtable(struct buffer
*buf
, struct module
*mod
)
1295 buf_printf(buf
, "\n");
1296 buf_write(buf
, mod
->dev_table_buf
.p
, mod
->dev_table_buf
.pos
);
1297 free(mod
->dev_table_buf
.p
);