]> git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Sockets/WebServer/ConfigurationTable.c
0131b9f5579402a7c4a537628c715acf0f3b17dc
[mirror_edk2.git] / AppPkg / Applications / Sockets / WebServer / ConfigurationTable.c
1 /**
2 @file
3 Display the configuration table
4
5 Copyright (c) 2011-2012, Intel Corporation. All rights reserved.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include <WebServer.h>
11 #include <Guid/Acpi.h>
12 #include <Guid/DebugImageInfoTable.h>
13 #include <Guid/DxeServices.h>
14 #include <Guid/HobList.h>
15 #include <Guid/MemoryTypeInformation.h>
16 #include <Guid/LoadModuleAtFixedAddress.h>
17
18
19 typedef struct {
20 CHAR16 * GuidName;
21 EFI_GUID * pGuid;
22 CHAR16 * pWebPage;
23 } GUID_NAME;
24
25 CONST GUID_NAME mGuidName[] = {
26 { L"gEfiAcpi10TableGuid", &gEfiAcpi10TableGuid, PAGE_ACPI_RSDP_10B },
27 { L"gEfiAcpiTableGuid", &gEfiAcpiTableGuid, PAGE_ACPI_RSDP_30 },
28 { L"gEfiDebugImageInfoTableGuid", &gEfiDebugImageInfoTableGuid, NULL },
29 { L"gEfiDxeServicesTableGuid", &gEfiDxeServicesTableGuid, PAGE_DXE_SERVICES_TABLE },
30 { L"gEfiHobListGuid", &gEfiHobListGuid, NULL },
31 { L"gEfiMemoryTypeInformationGuid", &gEfiMemoryTypeInformationGuid, NULL },
32 { L"gLoadFixedAddressConfigurationTableGuid", &gLoadFixedAddressConfigurationTableGuid, NULL }
33 };
34
35 /**
36 Display a row containing a GUID value
37
38 @param [in] SocketFD The socket's file descriptor to add to the list.
39 @param [in] pPort The WSDT_PORT structure address
40 @param [in] pName Address of a zero terminated name string
41 @param [in] pGuid Address of the GUID to display
42
43 @retval EFI_SUCCESS The request was successfully processed
44
45 **/
46 EFI_STATUS
47 RowGuid (
48 IN int SocketFD,
49 IN WSDT_PORT * pPort,
50 IN CONST CHAR8 * pName,
51 IN CONST EFI_GUID * pGuid
52 )
53 {
54 CONST GUID_NAME * pGuidName;
55 CONST GUID_NAME * pGuidNameEnd;
56 EFI_STATUS Status;
57 UINTN Value;
58
59 DBG_ENTER ( );
60
61 //
62 // Use for/break instead of goto
63 //
64 for ( ; ; ) {
65 Status = HttpSendAnsiString ( SocketFD,
66 pPort,
67 "<tr><td>" );
68 if ( EFI_ERROR ( Status )) {
69 break;
70 }
71 Status = HttpSendAnsiString ( SocketFD,
72 pPort,
73 pName );
74 if ( EFI_ERROR ( Status )) {
75 break;
76 }
77 Status = HttpSendAnsiString ( SocketFD,
78 pPort,
79 "</td><td><code>" );
80 if ( EFI_ERROR ( Status )) {
81 break;
82 }
83
84 //
85 // Determine if this is a known GUID
86 //
87 pGuidName = &mGuidName[0];
88 pGuidNameEnd = &pGuidName[ sizeof ( mGuidName ) / sizeof ( mGuidName[0])];
89 while ( pGuidNameEnd > pGuidName ) {
90 if ( CompareGuid ( pGuidName->pGuid, pGuid )) {
91 //
92 // Display the web link if available
93 //
94 if ( NULL != pGuidName->pWebPage ) {
95 Status = HttpSendAnsiString ( SocketFD,
96 pPort,
97 "<a target=\"_blank\" href=\"" );
98 if ( EFI_ERROR ( Status )) {
99 break;
100 }
101 Status = HttpSendUnicodeString ( SocketFD,
102 pPort,
103 pGuidName->pWebPage );
104 if ( EFI_ERROR ( Status )) {
105 break;
106 }
107 Status = HttpSendAnsiString ( SocketFD,
108 pPort,
109 "\">" );
110 if ( EFI_ERROR ( Status )) {
111 break;
112 }
113 }
114
115 //
116 // Display the GUID name
117 //
118 Status = HttpSendUnicodeString ( SocketFD,
119 pPort,
120 pGuidName->GuidName );
121
122 //
123 // Complete the web link if available
124 //
125 if ( NULL != pGuidName->pWebPage ) {
126 if ( EFI_ERROR ( Status )) {
127 break;
128 }
129 Status = HttpSendAnsiString ( SocketFD,
130 pPort,
131 "</a>" );
132 }
133 break;
134 }
135
136 //
137 // Set the next GUID name
138 //
139 pGuidName += 1;
140 }
141 if ( EFI_ERROR ( Status )) {
142 break;
143 }
144
145 //
146 // Only if the entry is not known, display the GUID and type
147 //
148 if ( pGuidNameEnd <= pGuidName ) {
149 //
150 // Display the GUID
151 //
152 Status = HttpSendGuid ( SocketFD,
153 pPort,
154 pGuid );
155 if ( EFI_ERROR ( Status )) {
156 break;
157 }
158
159 //
160 // Display the GUID type
161 //
162 Status = HttpSendAnsiString ( SocketFD,
163 pPort,
164 "<br/><a target=\"_blank\" href=\"http://www.ietf.org/rfc/rfc4122.txt\">Guid Type</a>: " );
165 if ( EFI_ERROR ( Status )) {
166 break;
167 }
168 Value = pGuid->Data4[1];
169 Value >>= 5;
170 if ( 3 >= Value ) {
171 //
172 // Network type
173 //
174 Status = HttpSendAnsiString ( SocketFD,
175 pPort,
176 "Network " );
177 }
178 else if ( 5 >= Value ) {
179 //
180 // Standard type
181 //
182 Status = HttpSendAnsiString ( SocketFD,
183 pPort,
184 "Standard " );
185 if ( EFI_ERROR ( Status )) {
186 break;
187 }
188
189 //
190 // Decode the standard type using RFC 4122
191 //
192 Value = pGuid->Data3;
193 Value >>= 12;
194 switch ( Value ) {
195 default:
196 //
197 // Display the MAC address
198 //
199 Status = HttpSendAnsiString ( SocketFD,
200 pPort,
201 "Version " );
202 if ( EFI_ERROR ( Status )) {
203 break;
204 }
205 Status = HttpSendValue ( SocketFD,
206 pPort,
207 pGuid->Data3 >> 12 );
208 break;
209
210 case 1:
211 Status = HttpSendAnsiString ( SocketFD,
212 pPort,
213 "MAC address" );
214 break;
215
216 case 2:
217 Status = HttpSendAnsiString ( SocketFD,
218 pPort,
219 "DCE Security" );
220 break;
221
222 case 3:
223 Status = HttpSendAnsiString ( SocketFD,
224 pPort,
225 "MD5 hash" );
226 break;
227
228 case 4:
229 Status = HttpSendAnsiString ( SocketFD,
230 pPort,
231 "Random" );
232 break;
233
234 case 5:
235 Status = HttpSendAnsiString ( SocketFD,
236 pPort,
237 "SHA-1 hash" );
238 break;
239 }
240 }
241 else if ( 6 == Value ) {
242 //
243 // Microsoft's Component Object Model (COM) type
244 //
245 Status = HttpSendAnsiString ( SocketFD,
246 pPort,
247 "Microsoft COM" );
248 }
249 else {
250 //
251 // Reserved type
252 //
253 Status = HttpSendAnsiString ( SocketFD,
254 pPort,
255 "Reserved" );
256 }
257 }
258
259 //
260 // Done with this entry
261 //
262 Status = HttpSendAnsiString ( SocketFD,
263 pPort,
264 "</code></td></tr>\r\n" );
265 break;
266 }
267
268 //
269 // Return the operation status
270 //
271 DBG_EXIT_STATUS ( Status );
272 return Status;
273 }
274
275
276 /**
277 Respond with the configuration tables
278
279 @param [in] SocketFD The socket's file descriptor to add to the list.
280 @param [in] pPort The WSDT_PORT structure address
281 @param [out] pbDone Address to receive the request completion status
282
283 @retval EFI_SUCCESS The request was successfully processed
284
285 **/
286 EFI_STATUS
287 ConfigurationTablePage (
288 IN int SocketFD,
289 IN WSDT_PORT * pPort,
290 OUT BOOLEAN * pbDone
291 )
292 {
293 EFI_CONFIGURATION_TABLE * pEnd;
294 EFI_CONFIGURATION_TABLE * pTable;
295 EFI_STATUS Status;
296
297 DBG_ENTER ( );
298
299 //
300 // Send the system table page
301 //
302 for ( ; ; ) {
303 //
304 // Send the page and table header
305 //
306 Status = TableHeader ( SocketFD, pPort, L"Configuration Tables", gST );
307 if ( EFI_ERROR ( Status )) {
308 break;
309 }
310
311 //
312 // Display the table size
313 //
314 Status = RowDecimalValue ( SocketFD,
315 pPort,
316 "Entries",
317 gST->NumberOfTableEntries );
318 if ( EFI_ERROR ( Status )) {
319 break;
320 }
321
322 //
323 // Determine the location of the configuration tables
324 //
325 pTable = gST->ConfigurationTable;
326 pEnd = &pTable[ gST->NumberOfTableEntries ];
327 while ( pEnd > pTable ) {
328 Status = RowGuid ( SocketFD,
329 pPort,
330 "VendorGuid",
331 &pTable->VendorGuid );
332 if ( EFI_ERROR ( Status )) {
333 break;
334 }
335 Status = RowPointer ( SocketFD,
336 pPort,
337 "VendorTable",
338 (VOID *)pTable->VendorTable,
339 NULL );
340 if ( EFI_ERROR ( Status )) {
341 break;
342 }
343
344 //
345 // Set the next row
346 //
347 pTable += 1;
348 }
349
350 //
351 // Build the table trailer
352 //
353 Status = TableTrailer ( SocketFD,
354 pPort,
355 pbDone );
356 break;
357 }
358
359 //
360 // Return the operation status
361 //
362 DBG_EXIT_STATUS ( Status );
363 return Status;
364 }