aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/file2alias.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mod/file2alias.c')
-rw-r--r--scripts/mod/file2alias.c82
1 files changed, 78 insertions, 4 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index e614ef689eee..5f2088209132 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -34,6 +34,9 @@ typedef Elf64_Addr kernel_ulong_t;
34typedef uint32_t __u32; 34typedef uint32_t __u32;
35typedef uint16_t __u16; 35typedef uint16_t __u16;
36typedef unsigned char __u8; 36typedef unsigned char __u8;
37typedef struct {
38 __u8 b[16];
39} uuid_le;
37 40
38/* Big exception to the "don't include kernel headers into userspace, which 41/* Big exception to the "don't include kernel headers into userspace, which
39 * even potentially has different endianness and word sizes, since 42 * even potentially has different endianness and word sizes, since
@@ -131,6 +134,15 @@ static inline void add_wildcard(char *str)
131 strcat(str + len, "*"); 134 strcat(str + len, "*");
132} 135}
133 136
137static inline void add_uuid(char *str, uuid_le uuid)
138{
139 int len = strlen(str);
140 int i;
141
142 for (i = 0; i < 16; i++)
143 sprintf(str + len + (i << 1), "%02x", uuid.b[i]);
144}
145
134/** 146/**
135 * Check that sizeof(device_id type) are consistent with size of section 147 * 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 148 * in .o file. If in-consistent then userspace and kernel does not agree
@@ -511,12 +523,40 @@ static int do_serio_entry(const char *filename,
511} 523}
512ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_entry); 524ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_entry);
513 525
514/* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ 526/* looks like: "acpi:ACPI0003" or "acpi:PNP0C0B" or "acpi:LNXVIDEO" or
527 * "acpi:bbsspp" (bb=base-class, ss=sub-class, pp=prog-if)
528 *
529 * NOTE: Each driver should use one of the following : _HID, _CIDs
530 * or _CLS. Also, bb, ss, and pp can be substituted with ??
531 * as don't care byte.
532 */
515static int do_acpi_entry(const char *filename, 533static int do_acpi_entry(const char *filename,
516 void *symval, char *alias) 534 void *symval, char *alias)
517{ 535{
518 DEF_FIELD_ADDR(symval, acpi_device_id, id); 536 DEF_FIELD_ADDR(symval, acpi_device_id, id);
519 sprintf(alias, "acpi*:%s:*", *id); 537 DEF_FIELD_ADDR(symval, acpi_device_id, cls);
538 DEF_FIELD_ADDR(symval, acpi_device_id, cls_msk);
539
540 if (id && strlen((const char *)*id))
541 sprintf(alias, "acpi*:%s:*", *id);
542 else if (cls) {
543 int i, byte_shift, cnt = 0;
544 unsigned int msk;
545
546 sprintf(&alias[cnt], "acpi*:");
547 cnt = 6;
548 for (i = 1; i <= 3; i++) {
549 byte_shift = 8 * (3-i);
550 msk = (*cls_msk >> byte_shift) & 0xFF;
551 if (msk)
552 sprintf(&alias[cnt], "%02x",
553 (*cls >> byte_shift) & 0xFF);
554 else
555 sprintf(&alias[cnt], "??");
556 cnt += 2;
557 }
558 sprintf(&alias[cnt], ":*");
559 }
520 return 1; 560 return 1;
521} 561}
522ADD_TO_DEVTABLE("acpi", acpi_device_id, do_acpi_entry); 562ADD_TO_DEVTABLE("acpi", acpi_device_id, do_acpi_entry);
@@ -1109,6 +1149,22 @@ static int do_amba_entry(const char *filename,
1109} 1149}
1110ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry); 1150ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry);
1111 1151
1152/*
1153 * looks like: "mipscdmm:tN"
1154 *
1155 * N is exactly 2 digits, where each is an upper-case hex digit, or
1156 * a ? or [] pattern matching exactly one digit.
1157 */
1158static int do_mips_cdmm_entry(const char *filename,
1159 void *symval, char *alias)
1160{
1161 DEF_FIELD(symval, mips_cdmm_device_id, type);
1162
1163 sprintf(alias, "mipscdmm:t%02X*", type);
1164 return 1;
1165}
1166ADD_TO_DEVTABLE("mipscdmm", mips_cdmm_device_id, do_mips_cdmm_entry);
1167
1112/* LOOKS like cpu:type:x86,venVVVVfamFFFFmodMMMM:feature:*,FEAT,* 1168/* LOOKS like cpu:type:x86,venVVVVfamFFFFmodMMMM:feature:*,FEAT,*
1113 * All fields are numbers. It would be nicer to use strings for vendor 1169 * All fields are numbers. It would be nicer to use strings for vendor
1114 * and feature, but getting those out of the build system here is too 1170 * and feature, but getting those out of the build system here is too
@@ -1144,13 +1200,18 @@ static int do_cpu_entry(const char *filename, void *symval, char *alias)
1144} 1200}
1145ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry); 1201ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry);
1146 1202
1147/* Looks like: mei:S */ 1203/* Looks like: mei:S:uuid */
1148static int do_mei_entry(const char *filename, void *symval, 1204static int do_mei_entry(const char *filename, void *symval,
1149 char *alias) 1205 char *alias)
1150{ 1206{
1151 DEF_FIELD_ADDR(symval, mei_cl_device_id, name); 1207 DEF_FIELD_ADDR(symval, mei_cl_device_id, name);
1208 DEF_FIELD_ADDR(symval, mei_cl_device_id, uuid);
1209
1210 sprintf(alias, MEI_CL_MODULE_PREFIX);
1211 sprintf(alias + strlen(alias), "%s:", (*name)[0] ? *name : "*");
1212 add_uuid(alias, *uuid);
1152 1213
1153 sprintf(alias, MEI_CL_MODULE_PREFIX "%s", *name); 1214 strcat(alias, ":*");
1154 1215
1155 return 1; 1216 return 1;
1156} 1217}
@@ -1176,6 +1237,19 @@ static int do_rio_entry(const char *filename,
1176} 1237}
1177ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry); 1238ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry);
1178 1239
1240/* Looks like: ulpi:vNpN */
1241static int do_ulpi_entry(const char *filename, void *symval,
1242 char *alias)
1243{
1244 DEF_FIELD(symval, ulpi_device_id, vendor);
1245 DEF_FIELD(symval, ulpi_device_id, product);
1246
1247 sprintf(alias, "ulpi:v%04xp%04x", vendor, product);
1248
1249 return 1;
1250}
1251ADD_TO_DEVTABLE("ulpi", ulpi_device_id, do_ulpi_entry);
1252
1179/* Does namelen bytes of name exactly match the symbol? */ 1253/* Does namelen bytes of name exactly match the symbol? */
1180static bool sym_is(const char *name, unsigned namelen, const char *symbol) 1254static bool sym_is(const char *name, unsigned namelen, const char *symbol)
1181{ 1255{