]>
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 | |
42 | #include <Base.h>\r | |
43 | #include <UefiBaseTypes.h>\r | |
44 | #include <UgaDraw.h>\r | |
45 | #include "EfiUtilityMsgs.h"\r | |
46 | \r | |
47 | #include <Apriori.h>\r | |
48 | #include <AcpiTableStorage.h>\r | |
49 | // #include <Bmp.h>\r | |
50 | \r | |
51 | #define GUID_XREF(varname, guid) { \\r | |
52 | #varname, #guid, guid \\r | |
53 | }\r | |
54 | \r | |
55 | #define NULL_GUID \\r | |
56 | { \\r | |
57 | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 \\r | |
58 | }\r | |
59 | \r | |
60 | typedef struct {\r | |
61 | INT8 *VariableName;\r | |
62 | INT8 *DefineName;\r | |
63 | EFI_GUID Guid;\r | |
64 | } GUID_LIST;\r | |
65 | \r | |
66 | //\r | |
67 | // This is our table of all GUIDs we want to print out to create\r | |
68 | // a GUID-to-name cross reference.\r | |
69 | // Use the #defined name from the GUID definition's source .h file.\r | |
70 | //\r | |
71 | static GUID_LIST mGuidList[] = {\r | |
72 | GUID_XREF(gAprioriGuid, EFI_APRIORI_GUID),\r | |
73 | GUID_XREF(gEfiAcpiTableStorageGuid, EFI_ACPI_TABLE_STORAGE_GUID),\r | |
74 | // FIXME The next line was removed in the port to R9.\r | |
75 | // GUID_XREF(gEfiDefaultBmpLogoGuid, EFI_DEFAULT_BMP_LOGO_GUID),\r | |
76 | GUID_XREF(gEfiAcpiTableStorageGuid, EFI_ACPI_TABLE_STORAGE_GUID),\r | |
77 | //\r | |
78 | // Terminator\r | |
79 | //\r | |
80 | {\r | |
81 | NULL,\r | |
82 | NULL,\r | |
83 | NULL_GUID\r | |
84 | }\r | |
85 | };\r | |
86 | \r | |
87 | void\r | |
88 | PrintGuidText (\r | |
89 | FILE *OutFptr,\r | |
90 | INT8 *VariableName,\r | |
91 | INT8 *DefineName,\r | |
92 | EFI_GUID *Guid\r | |
93 | );\r | |
94 | \r | |
95 | int\r | |
96 | CreateGuidList (\r | |
97 | INT8 *OutFileName\r | |
98 | )\r | |
99 | /*++\r | |
100 | \r | |
101 | Routine Description:\r | |
102 | Print our GUID/name list to the specified output file.\r | |
103 | \r | |
104 | Arguments:\r | |
105 | OutFileName - name of the output file to write our results to.\r | |
106 | \r | |
107 | Returns:\r | |
108 | 0 if successful\r | |
109 | nonzero otherwise\r | |
110 | \r | |
111 | --*/\r | |
112 | {\r | |
113 | FILE *OutFptr;\r | |
114 | int Index;\r | |
115 | \r | |
116 | //\r | |
117 | // Open output file for writing. If the name is NULL, then write to stdout\r | |
118 | //\r | |
119 | if (OutFileName != NULL) {\r | |
120 | OutFptr = fopen (OutFileName, "w");\r | |
121 | if (OutFptr == NULL) {\r | |
122 | Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r | |
123 | return STATUS_ERROR;\r | |
124 | }\r | |
125 | } else {\r | |
126 | OutFptr = stdout;\r | |
127 | }\r | |
128 | \r | |
129 | for (Index = 0; mGuidList[Index].VariableName != NULL; Index++) {\r | |
130 | PrintGuidText (OutFptr, mGuidList[Index].VariableName, mGuidList[Index].DefineName, &mGuidList[Index].Guid);\r | |
131 | }\r | |
132 | //\r | |
133 | // Close the output file if they specified one.\r | |
134 | //\r | |
135 | if (OutFileName != NULL) {\r | |
136 | fclose (OutFptr);\r | |
137 | }\r | |
138 | \r | |
139 | return STATUS_SUCCESS;\r | |
140 | }\r | |
141 | \r | |
142 | void\r | |
143 | PrintGuidText (\r | |
144 | FILE *OutFptr,\r | |
145 | INT8 *VariableName,\r | |
146 | INT8 *DefineName,\r | |
147 | EFI_GUID *Guid\r | |
148 | )\r | |
149 | /*++\r | |
150 | \r | |
151 | Routine Description:\r | |
152 | Print a GUID/name combo in INF-style format\r | |
153 | \r | |
154 | guid-guid-guid-guid DEFINE_NAME gName\r | |
155 | \r | |
156 | Arguments:\r | |
157 | OutFptr - file pointer to which to write the output\r | |
158 | VariableName - the GUID variable's name\r | |
159 | DefineName - the name used in the #define\r | |
160 | Guid - pointer to the GUID value\r | |
161 | \r | |
162 | Returns:\r | |
163 | NA\r | |
164 | \r | |
165 | --*/\r | |
166 | {\r | |
167 | if (OutFptr == NULL) {\r | |
168 | OutFptr = stdout;\r | |
169 | }\r | |
170 | \r | |
171 | fprintf (\r | |
172 | OutFptr,\r | |
173 | "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s %s\n",\r | |
174 | Guid->Data1,\r | |
175 | Guid->Data2,\r | |
176 | Guid->Data3,\r | |
177 | Guid->Data4[0],\r | |
178 | Guid->Data4[1],\r | |
179 | Guid->Data4[2],\r | |
180 | Guid->Data4[3],\r | |
181 | Guid->Data4[4],\r | |
182 | Guid->Data4[5],\r | |
183 | Guid->Data4[6],\r | |
184 | Guid->Data4[7],\r | |
185 | DefineName,\r | |
186 | VariableName\r | |
187 | );\r | |
188 | }\r |