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