]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2004, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | GuidList.c \r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Utility to create a GUID-to-name listing file that can\r | |
19 | be used by other utilities. Basic operation is to take the\r | |
20 | table of name+GUIDs that we have compiled into this utility,\r | |
21 | and create a text file that can be parsed by other utilities\r | |
22 | to do replacement of "name" with "GUID".\r | |
23 | \r | |
24 | Notes:\r | |
25 | To add a new GUID to this database:\r | |
26 | 1. Add a "#include EFI_GUID_DEFINITION(name)" statement below\r | |
27 | 2. Modify the mGuidList[] array below to add the new GUID name\r | |
28 | \r | |
29 | The only issue that may come up is that, if the source GUID file\r | |
30 | is not in the standard GUID directory, then this utility won't\r | |
31 | compile because the #include fails. In this case you'd need\r | |
32 | to define a new macro (if it's in a standard place) or modify\r | |
33 | this utility's makefile to add the path to your new .h file.\r | |
34 | \r | |
35 | --*/\r | |
36 | \r | |
37 | #include <stdio.h>\r | |
38 | #include <string.h>\r | |
39 | #include <stdlib.h>\r | |
40 | #include <ctype.h>\r | |
41 | \r | |
ce53a8c3 | 42 | #include <Common/UefiBaseTypes.h>\r |
43 | #include <Guid/Apriori.h>\r | |
44 | #include <Guid/AcpiTableStorage.h>\r | |
45 | \r | |
878ddf1f | 46 | #include "EfiUtilityMsgs.h"\r |
47 | \r | |
878ddf1f | 48 | \r |
49 | #define GUID_XREF(varname, guid) { \\r | |
50 | #varname, #guid, guid \\r | |
51 | }\r | |
52 | \r | |
53 | #define NULL_GUID \\r | |
54 | { \\r | |
55 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 \\r | |
56 | }\r | |
57 | \r | |
58 | typedef struct {\r | |
59 | INT8 *VariableName;\r | |
60 | INT8 *DefineName;\r | |
61 | EFI_GUID Guid;\r | |
62 | } GUID_LIST;\r | |
63 | \r | |
64 | //\r | |
65 | // This is our table of all GUIDs we want to print out to create\r | |
66 | // a GUID-to-name cross reference.\r | |
67 | // Use the #defined name from the GUID definition's source .h file.\r | |
68 | //\r | |
69 | static GUID_LIST mGuidList[] = {\r | |
70 | GUID_XREF(gAprioriGuid, EFI_APRIORI_GUID),\r | |
71 | GUID_XREF(gEfiAcpiTableStorageGuid, EFI_ACPI_TABLE_STORAGE_GUID),\r | |
72 | // FIXME The next line was removed in the port to R9.\r | |
73 | // GUID_XREF(gEfiDefaultBmpLogoGuid, EFI_DEFAULT_BMP_LOGO_GUID),\r | |
74 | GUID_XREF(gEfiAcpiTableStorageGuid, EFI_ACPI_TABLE_STORAGE_GUID),\r | |
75 | //\r | |
76 | // Terminator\r | |
77 | //\r | |
78 | {\r | |
79 | NULL,\r | |
80 | NULL,\r | |
81 | NULL_GUID\r | |
82 | }\r | |
83 | };\r | |
84 | \r | |
85 | void\r | |
86 | PrintGuidText (\r | |
87 | FILE *OutFptr,\r | |
88 | INT8 *VariableName,\r | |
89 | INT8 *DefineName,\r | |
90 | EFI_GUID *Guid\r | |
91 | );\r | |
92 | \r | |
93 | int\r | |
94 | CreateGuidList (\r | |
95 | INT8 *OutFileName\r | |
96 | )\r | |
97 | /*++\r | |
98 | \r | |
99 | Routine Description:\r | |
100 | Print our GUID/name list to the specified output file.\r | |
101 | \r | |
102 | Arguments:\r | |
103 | OutFileName - name of the output file to write our results to.\r | |
104 | \r | |
105 | Returns:\r | |
106 | 0 if successful\r | |
107 | nonzero otherwise\r | |
108 | \r | |
109 | --*/\r | |
110 | {\r | |
111 | FILE *OutFptr;\r | |
112 | int Index;\r | |
113 | \r | |
114 | //\r | |
115 | // Open output file for writing. If the name is NULL, then write to stdout\r | |
116 | //\r | |
117 | if (OutFileName != NULL) {\r | |
118 | OutFptr = fopen (OutFileName, "w");\r | |
119 | if (OutFptr == NULL) {\r | |
120 | Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r | |
121 | return STATUS_ERROR;\r | |
122 | }\r | |
123 | } else {\r | |
124 | OutFptr = stdout;\r | |
125 | }\r | |
126 | \r | |
127 | for (Index = 0; mGuidList[Index].VariableName != NULL; Index++) {\r | |
128 | PrintGuidText (OutFptr, mGuidList[Index].VariableName, mGuidList[Index].DefineName, &mGuidList[Index].Guid);\r | |
129 | }\r | |
130 | //\r | |
131 | // Close the output file if they specified one.\r | |
132 | //\r | |
133 | if (OutFileName != NULL) {\r | |
134 | fclose (OutFptr);\r | |
135 | }\r | |
136 | \r | |
137 | return STATUS_SUCCESS;\r | |
138 | }\r | |
139 | \r | |
140 | void\r | |
141 | PrintGuidText (\r | |
142 | FILE *OutFptr,\r | |
143 | INT8 *VariableName,\r | |
144 | INT8 *DefineName,\r | |
145 | EFI_GUID *Guid\r | |
146 | )\r | |
147 | /*++\r | |
148 | \r | |
149 | Routine Description:\r | |
150 | Print a GUID/name combo in INF-style format\r | |
151 | \r | |
152 | guid-guid-guid-guid DEFINE_NAME gName\r | |
153 | \r | |
154 | Arguments:\r | |
155 | OutFptr - file pointer to which to write the output\r | |
156 | VariableName - the GUID variable's name\r | |
157 | DefineName - the name used in the #define\r | |
158 | Guid - pointer to the GUID value\r | |
159 | \r | |
160 | Returns:\r | |
161 | NA\r | |
162 | \r | |
163 | --*/\r | |
164 | {\r | |
165 | if (OutFptr == NULL) {\r | |
166 | OutFptr = stdout;\r | |
167 | }\r | |
168 | \r | |
169 | fprintf (\r | |
170 | OutFptr,\r | |
171 | "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s %s\n",\r | |
172 | Guid->Data1,\r | |
173 | Guid->Data2,\r | |
174 | Guid->Data3,\r | |
175 | Guid->Data4[0],\r | |
176 | Guid->Data4[1],\r | |
177 | Guid->Data4[2],\r | |
178 | Guid->Data4[3],\r | |
179 | Guid->Data4[4],\r | |
180 | Guid->Data4[5],\r | |
181 | Guid->Data4[6],\r | |
182 | Guid->Data4[7],\r | |
183 | DefineName,\r | |
184 | VariableName\r | |
185 | );\r | |
186 | }\r |