1 /**
2   @file
3   Display the ACPI tables
4 
5   Copyright (c) 2011-2012, Intel Corporation
6   All rights reserved. This program and the accompanying materials
7   are licensed and made available under the terms and conditions of the BSD License
8   which accompanies this distribution.  The full text of the license may be found at
9   http://opensource.org/licenses/bsd-license.php
10 
11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 
14 **/
15 
16 #include <WebServer.h>
17 #include <Guid/Acpi.h>
18 #include <IndustryStandard/Acpi10.h>
19 #include <IndustryStandard/Acpi30.h>
20 
21 #if defined(_MSC_VER)   //  Handle Microsoft VC++ compiler specifics.
22 #pragma warning ( disable : 4305 )
23 #endif  //  defined(_MSC_VER)
24 
25 //
26 // Ensure proper structure formats
27 //
28 #pragma pack(1)
29 
30 typedef struct {
31   UINT8 AddressSpaceId;
32   UINT8 RegisterBitWidth;
33   UINT8 RegisterBitOffset;
34   UINT8 AccessSize;
35   UINT64 Address;
36 } GENERIC_ADDRESS;
37 
38 
39 typedef struct {
40   UINT32 Signature;           //    0
41   UINT32 Length;              //    4
42   UINT8 Revision;             //    8
43   UINT8 Checksum;             //    9
44   UINT8 OemId[6];             //   10
45   UINT8 OemTableId[8];        //   16
46   UINT32 OemRevision;         //   24
47   UINT32 CreatorId;           //   28
48   UINT32 CreatorRevision;     //   32
49   UINT8 DefinitionBlock[1];   //   36
50 } ACPI_DSDT;
51 
52 
53 typedef struct {
54   UINT32 Signature;           //    0
55   UINT32 Length;              //    4
56   UINT8 Revision;             //    8
57   UINT8 Checksum;             //    9
58   UINT8 OemId[6];             //   10
59   UINT8 OemTableId[8];        //   16
60   UINT32 OemRevision;         //   24
61   UINT32 CreatorId;           //   28
62   UINT32 CreatorRevision;     //   32
63   UINT32 FirmwareCtrl;        //   36
64   UINT32 DSDT;                //   40
65   UINT8 Reserved;             //   44
66   UINT8 PreferredPmProfile;   //   45
67   UINT16 SciInt;              //   46
68   UINT32 SmiCmd;              //   48
69   UINT8 AcpiEnable;           //   52
70   UINT8 AcpiDisable;          //   53
71   UINT8 S4BiosReq;            //   54
72   UINT8 PStateCnt;            //   55
73   UINT32 Pm1aEvtBlk;          //   56
74   UINT32 Pm1bEvtBlk;          //   60
75   UINT32 Pm1aCntBlk;          //   64
76   UINT32 Pm1bCntBlk;          //   68
77   UINT32 Pm2CntBlk;           //   72
78   UINT32 PmTmrBlk;            //   76
79   UINT32 Gpe0Blk;             //   80
80   UINT32 Gpe1Blk;             //   84
81   UINT8 Pm1EvtLen;            //   88
82   UINT8 Pm1CntLen;            //   89
83   UINT8 PM2CntLen;            //   90
84   UINT8 PmTmrLen;             //   91
85   UINT8 Gpe0BlkLen;           //   92
86   UINT8 Gpe1BlkLen;           //   93
87   UINT8 Gpe1Base;             //   94
88   UINT8 CstCnt;               //   95
89   UINT16 PLvl2Lat;            //   96
90   UINT16 PLvl3Lat;            //   98
91   UINT16 FlushSize;           //  100
92   UINT16 FlushStride;         //  102
93   UINT8 DutyOffset;           //  104
94   UINT8 DutyWidth;            //  105
95   UINT8 DayAlrm;              //  106
96   UINT8 MonAlrm;              //  107
97   UINT8 Century;              //  108
98   UINT16 IapcBootArch;        //  109
99   UINT8 Reserved2;            //  111
100   UINT32 Flags;               //  112
101   UINT32 ResetReg[3];         //  116
102   UINT8 ResetValue;           //  128
103   UINT8 Reserved3[3];         //  129
104   UINT64 XFirmwareCtrl;       //  132
105   UINT64 XDsdt;               //  140
106   UINT32 XPm1aEvtBlk[3];      //  148
107   UINT32 XPm1bEvtBlk[3];      //  160
108   UINT32 XPm1aCntBlk[3];      //  172
109   UINT32 XPm1bCntBlk[3];      //  184
110   UINT32 XPm2CntBlk[3];       //  196
111   UINT32 XPmTmrBlk[3];        //  208
112   UINT32 XGpe0Blk[3];         //  220
113   UINT32 XGpe1Blk[3];         //  232
114 } ACPI_FADT;
115 
116 
117 typedef struct {
118   UINT32 Signature;
119   UINT32 Length;
120   UINT8 Revision;
121   UINT8 Checksum;
122   UINT8 OemId[6];
123   UINT8 OemTableId[8];
124   UINT32 OemRevision;
125   UINT32 CreatorId;
126   UINT32 CreatorRevision;
127   UINT32 Entry[1];
128 } ACPI_RSDT;
129 
130 
131 typedef struct {
132   UINT32 Signature;           //    0
133   UINT32 Length;              //    4
134 } ACPI_UNKNOWN;
135 
136 #pragma pack()
137 
138 
139 typedef struct {
140   UINT32 Signature;
141   CONST CHAR8 * pTableName;
142   CONST CHAR16 * pWebPage;
143 } TABLE_SIGNATURE;
144 
145 
146 CONST TABLE_SIGNATURE mTableId[] = {
147   { APIC_SIGNATURE, "APIC", PAGE_ACPI_APIC },
148   { BGRT_SIGNATURE, "BGRT", PAGE_ACPI_BGRT },
149   { DSDT_SIGNATURE, "DSDT", PAGE_ACPI_DSDT },
150   { FADT_SIGNATURE, "FADT", PAGE_ACPI_FADT },
151   { HPET_SIGNATURE, "HPET", PAGE_ACPI_HPET },
152   { MCFG_SIGNATURE, "MCFG", PAGE_ACPI_MCFG },
153   { SSDT_SIGNATURE, "SSDT", PAGE_ACPI_SSDT },
154   { TCPA_SIGNATURE, "TCPA", PAGE_ACPI_TCPA },
155   { UEFI_SIGNATURE, "UEFI", PAGE_ACPI_UEFI }
156 };
157 
158 
159 /**
160   Locate the RSDT table
161 
162   @return  Table address or NULL if not found
163 
164 **/
165 CONST ACPI_RSDT *
LocateRsdt(VOID)166 LocateRsdt (
167   VOID
168   )
169 {
170   CONST EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER * pRsdp10b;
171   CONST EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER * pRsdp30;
172   CONST ACPI_RSDT * pRsdt;
173   EFI_STATUS Status;
174 
175   //
176   //  Use for/break instead of goto
177   //
178   pRsdt = NULL;
179   for ( ; ; ) {
180     //
181     //  Locate the RSDT
182     //
183     Status = EfiGetSystemConfigurationTable ( &gEfiAcpiTableGuid, (VOID **)&pRsdp30 );
184     if ( !EFI_ERROR ( Status )) {
185       pRsdt = (ACPI_RSDT *)(UINTN)pRsdp30->RsdtAddress;
186     }
187     else {
188       Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **)&pRsdp10b );
189       if ( EFI_ERROR ( Status )) {
190         break;
191       }
192       pRsdt = (ACPI_RSDT *)(UINTN)pRsdp10b->RsdtAddress;
193     }
194     break;
195   }
196 
197   //
198   //  The entry was not found
199   //
200   return pRsdt;
201 }
202 
203 
204 /**
205   Locate the specified table
206 
207   @param [in] Signature     Table signature
208 
209   @return  Table address or NULL if not found
210 
211 **/
212 CONST VOID *
LocateTable(IN UINT32 Signature)213 LocateTable (
214   IN UINT32 Signature
215   )
216 {
217   CONST UINT32 * pEnd;
218   CONST UINT32 * pEntry;
219   CONST EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER * pRsdp10b;
220   CONST EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER * pRsdp30;
221   CONST ACPI_RSDT * pRsdt;
222   CONST UINT32 * pSignature;
223   EFI_STATUS Status;
224 
225   //
226   //  Use for/break instead of goto
227   //
228   for ( ; ; ) {
229     //
230     //  Locate the RSDT
231     //
232     Status = EfiGetSystemConfigurationTable ( &gEfiAcpiTableGuid, (VOID **)&pRsdp30 );
233     if ( !EFI_ERROR ( Status )) {
234       pRsdt = (ACPI_RSDT *)(UINTN)pRsdp30->RsdtAddress;
235     }
236     else {
237       Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **)&pRsdp10b );
238       if ( EFI_ERROR ( Status )) {
239         break;
240       }
241       pRsdt = (ACPI_RSDT *)(UINTN)pRsdp10b->RsdtAddress;
242     }
243 
244     //
245     //  Walk the list of entries
246     //
247     pEntry = &pRsdt->Entry[ 0 ];
248     pEnd = &pEntry[(( pRsdt->Length - sizeof ( *pRsdt )) >> 2 ) + 1 ];
249     while ( pEnd > pEntry ) {
250       //
251       //  The entry is actually a 32-bit physical table address
252       //  The first entry in the table is the 32-bit table signature
253       //
254       pSignature = (UINT32 *)(UINTN)*pEntry;
255       if ( *pSignature == Signature ) {
256         return (CONST VOID *)(UINTN)*pEntry;
257       }
258 
259       //
260       //  Set the next entry
261       //
262       pEntry++;
263     }
264     break;
265   }
266 
267   //
268   //  The entry was not found
269   //
270   return NULL;
271 }
272 
273 
274 /**
275   Display a row containing a hex value
276 
277   @param [in] SocketFD      The socket's file descriptor to add to the list.
278   @param [in] pPort         The WSDT_PORT structure address
279   @param [in] pName         Address of a zero terminated name string
280   @param [in] Length        Length in bytes
281   @param [in] pChar         Address of the first character
282 
283   @retval EFI_SUCCESS       The request was successfully processed
284 
285 **/
286 EFI_STATUS
RowAnsiArray(IN int SocketFD,IN WSDT_PORT * pPort,IN CONST CHAR8 * pName,IN UINTN Length,IN CONST CHAR8 * pChar)287 RowAnsiArray (
288   IN int SocketFD,
289   IN WSDT_PORT * pPort,
290   IN CONST CHAR8 * pName,
291   IN UINTN Length,
292   IN CONST CHAR8 * pChar
293   )
294 {
295   CONST CHAR8 * pData;
296   CONST CHAR8 * pEnd;
297   EFI_STATUS Status;
298 
299   DBG_ENTER ( );
300 
301   //
302   //  Use for/break instead of goto
303   //
304   for ( ; ; ) {
305     //
306     //  Start the row
307     //
308     Status = HttpSendAnsiString ( SocketFD,
309                                   pPort,
310                                   "<tr><td>" );
311     if ( EFI_ERROR ( Status )) {
312       break;
313     }
314     Status = HttpSendAnsiString ( SocketFD,
315                                   pPort,
316                                   pName );
317     if ( EFI_ERROR ( Status )) {
318       break;
319     }
320     Status = HttpSendAnsiString ( SocketFD,
321                                   pPort,
322                                   "</td><td><code>" );
323     if ( EFI_ERROR ( Status )) {
324       break;
325     }
326 
327     //
328     //  Display the characters
329     //
330     pData = pChar;
331     pEnd = &pChar[ Length ];
332     while ( pEnd > pData ) {
333       Status = HttpSendCharacter ( SocketFD,
334                                    pPort,
335                                    *pData++,
336                                    " " );
337       if ( EFI_ERROR ( Status )) {
338         break;
339       }
340     }
341     if ( EFI_ERROR ( Status )) {
342       break;
343     }
344 
345     //
346     //  Display the byte values
347     //
348     Status = HttpSendAnsiString ( SocketFD,
349                                   pPort,
350                                   "<br/>0x" );
351     if ( EFI_ERROR ( Status )) {
352       break;
353     }
354     pData = pChar;
355     while ( pEnd > pData ) {
356       Status = HttpSendHexBits ( SocketFD,
357                                  pPort,
358                                  8,
359                                  *pData++ );
360       if ( EFI_ERROR ( Status )) {
361         break;
362       }
363       if ( pEnd > pData ) {
364         Status = HttpSendAnsiString ( SocketFD,
365                                       pPort,
366                                       " 0x" );
367         if ( EFI_ERROR ( Status )) {
368           break;
369         }
370       }
371     }
372 
373     //
374     //  Terminate the row
375     //
376     Status = HttpSendAnsiString ( SocketFD,
377                                   pPort,
378                                   "</code></td></tr>\r\n" );
379     break;
380   }
381 
382   //
383   //  Return the operation status
384   //
385   DBG_EXIT_STATUS ( Status );
386   return Status;
387 }
388 
389 
390 /**
391   Format a row with a list of bytes
392 
393   @param [in] SocketFD      The socket's file descriptor to add to the list.
394   @param [in] pPort         The WSDT_PORT structure address
395   @param [in] pName         Zero terminated name string
396   @param [in] ByteCount     The number of bytes to display
397   @param [in] pData         Address of the byte array
398 
399   @retval EFI_SUCCESS       The request was successfully processed
400 
401 **/
402 EFI_STATUS
RowBytes(IN int SocketFD,IN WSDT_PORT * pPort,IN CHAR8 * pName,IN UINTN ByteCount,IN CONST UINT8 * pData)403 RowBytes (
404   IN int SocketFD,
405   IN WSDT_PORT * pPort,
406   IN CHAR8 * pName,
407   IN UINTN ByteCount,
408   IN CONST UINT8 * pData
409   )
410 {
411   CONST UINT8 * pEnd;
412   EFI_STATUS Status;
413 
414   //
415   //  Use for/break instead of goto
416   //
417   for ( ; ; ) {
418     //
419     //  Start the row
420     //
421     Status = HttpSendAnsiString ( SocketFD,
422                                   pPort,
423                                   "<tr><td>" );
424     if ( EFI_ERROR ( Status )) {
425       break;
426     }
427 
428     //
429     //  Display the field name
430     //
431     Status = HttpSendAnsiString ( SocketFD,
432                                   pPort,
433                                   pName );
434     if ( EFI_ERROR ( Status )) {
435       break;
436     }
437 
438     //
439     //  Display the field value
440     //
441     Status = HttpSendAnsiString ( SocketFD,
442                                   pPort,
443                                   "</td><td><code>0x" );
444     if ( EFI_ERROR ( Status )) {
445       break;
446     }
447     pEnd = &pData[ ByteCount ];
448     while ( pEnd > pData ) {
449       Status = HttpSendHexBits ( SocketFD,
450                                  pPort,
451                                  8,
452                                  *pData++ );
453       if ( EFI_ERROR ( Status )) {
454         break;
455       }
456       if ( pEnd > pData ) {
457         Status = HttpSendAnsiString ( SocketFD,
458                                       pPort,
459                                       " 0x" );
460         if ( EFI_ERROR ( Status )) {
461           break;
462         }
463       }
464     }
465     if ( EFI_ERROR ( Status )) {
466       break;
467     }
468 
469     //
470     //  Terminate the row
471     //
472     Status = HttpSendAnsiString ( SocketFD,
473                                   pPort,
474                                   "</code></td></tr>\r\n" );
475     break;
476   }
477 
478   //
479   //  Return the operation status
480   //
481   return Status;
482 }
483 
484 
485 /**
486   Format a row with a list of bytes
487 
488   @param [in] SocketFD      The socket's file descriptor to add to the list.
489   @param [in] pPort         The WSDT_PORT structure address
490   @param [in] pName         Zero terminated name string
491   @param [in] ByteCount     The number of bytes to display
492   @param [in] pData         Address of the byte array
493 
494   @retval EFI_SUCCESS       The request was successfully processed
495 
496 **/
497 EFI_STATUS
RowDump(IN int SocketFD,IN WSDT_PORT * pPort,IN CHAR8 * pName,IN UINTN ByteCount,IN CONST UINT8 * pData)498 RowDump (
499   IN int SocketFD,
500   IN WSDT_PORT * pPort,
501   IN CHAR8 * pName,
502   IN UINTN ByteCount,
503   IN CONST UINT8 * pData
504   )
505 {
506   EFI_STATUS Status;
507 
508   //
509   //  Use for/break instead of goto
510   //
511   for ( ; ; ) {
512     //
513     //  Start the row
514     //
515     Status = HttpSendAnsiString ( SocketFD,
516                                   pPort,
517                                   "<tr><td>" );
518     if ( EFI_ERROR ( Status )) {
519       break;
520     }
521 
522     //
523     //  Display the field name
524     //
525     Status = HttpSendAnsiString ( SocketFD,
526                                   pPort,
527                                   pName );
528     if ( EFI_ERROR ( Status )) {
529       break;
530     }
531 
532     //
533     //  Start the field value
534     //
535     Status = HttpSendAnsiString ( SocketFD,
536                                   pPort,
537                                   "</td><td>" );
538     if ( EFI_ERROR ( Status )) {
539       break;
540     }
541 
542     //
543     //  Dump the buffer
544     //
545     Status = HttpSendDump ( SocketFD,
546                             pPort,
547                             ByteCount,
548                             pData );
549 
550     //
551     //  Terminate the field value and row
552     //
553     Status = HttpSendAnsiString ( SocketFD,
554                                   pPort,
555                                   "</td></tr>\r\n" );
556     break;
557   }
558 
559   //
560   //  Return the operation status
561   //
562   return Status;
563 }
564 
565 
566 /**
567   Format a row with a general address
568 
569   @param [in] SocketFD      The socket's file descriptor to add to the list.
570   @param [in] pPort         The WSDT_PORT structure address
571   @param [in] pName         Zero terminated name string
572   @param [in] pAddr         Address of the general address buffer
573   @param [in] pWebPage      Zero terminated web page address
574 
575   @retval EFI_SUCCESS       The request was successfully processed
576 
577 **/
578 EFI_STATUS
RowGenericAddress(IN int SocketFD,IN WSDT_PORT * pPort,IN CHAR8 * pName,IN CONST UINT32 * pAddr,IN CONST CHAR16 * pWebPage)579 RowGenericAddress (
580   IN int SocketFD,
581   IN WSDT_PORT * pPort,
582   IN CHAR8 * pName,
583   IN CONST UINT32 * pAddr,
584   IN CONST CHAR16 * pWebPage
585   )
586 {
587   CONST GENERIC_ADDRESS * pGenericAddress;
588   EFI_STATUS Status;
589 
590   //
591   //  Use for/break instead of goto
592   //
593   for ( ; ; ) {
594     //
595     //  Start the row
596     //
597     Status = HttpSendAnsiString ( SocketFD,
598                                   pPort,
599                                   "<tr><td>" );
600     if ( EFI_ERROR ( Status )) {
601       break;
602     }
603 
604     //
605     //  Display the field name
606     //
607     Status = HttpSendAnsiString ( SocketFD,
608                                   pPort,
609                                   pName );
610     if ( EFI_ERROR ( Status )) {
611       break;
612     }
613 
614     //
615     //  Display the field value
616     //
617     Status = HttpSendAnsiString ( SocketFD,
618                                   pPort,
619                                   "</td><td><code>" );
620     if ( EFI_ERROR ( Status )) {
621       break;
622     }
623 
624     //
625     //  Determine the type of address
626     //
627     pGenericAddress = (CONST GENERIC_ADDRESS *)pAddr;
628     if ( 0 == pGenericAddress->AddressSpaceId ) {
629       Status = HttpSendAnsiString ( SocketFD, pPort, "System Memory" );
630     }
631     else if ( 1 == pGenericAddress->AddressSpaceId ) {
632       Status = HttpSendAnsiString ( SocketFD, pPort, "I/O Space" );
633     }
634     else if ( 2 == pGenericAddress->AddressSpaceId ) {
635       Status = HttpSendAnsiString ( SocketFD, pPort, "PCI Configuration Space" );
636     }
637     else if ( 3 == pGenericAddress->AddressSpaceId ) {
638       Status = HttpSendAnsiString ( SocketFD, pPort, "Embedded Controller" );
639     }
640     else if ( 4 == pGenericAddress->AddressSpaceId ) {
641       Status = HttpSendAnsiString ( SocketFD, pPort, "SMBus" );
642     }
643     else if ( 0x7f == pGenericAddress->AddressSpaceId ) {
644       Status = HttpSendAnsiString ( SocketFD, pPort, "Functional Fixed Hardware" );
645     }
646     else if (( 0xc0 <= pGenericAddress->AddressSpaceId )
647       && ( 0xff >= pGenericAddress->AddressSpaceId )) {
648       Status = HttpSendAnsiString ( SocketFD, pPort, "OEM Defined" );
649     }
650     else {
651       Status = HttpSendAnsiString ( SocketFD, pPort, "Reserved" );
652     }
653     if ( EFI_ERROR ( Status )) {
654       break;
655     }
656     Status = HttpSendAnsiString ( SocketFD,
657                                   pPort,
658                                   "<br/>Register Bit Width: " );
659     if ( EFI_ERROR ( Status )) {
660       break;
661     }
662     Status = HttpSendValue ( SocketFD,
663                              pPort,
664                              pGenericAddress->RegisterBitWidth );
665     if ( EFI_ERROR ( Status )) {
666       break;
667     }
668     Status = HttpSendAnsiString ( SocketFD,
669                                   pPort,
670                                   "<br/>Register Bit Offset: " );
671     if ( EFI_ERROR ( Status )) {
672       break;
673     }
674     Status = HttpSendHexValue ( SocketFD,
675                                 pPort,
676                                 pGenericAddress->RegisterBitOffset );
677     if ( EFI_ERROR ( Status )) {
678       break;
679     }
680     Status = HttpSendAnsiString ( SocketFD,
681                                   pPort,
682                                   "<br/>Access Size: " );
683     if ( EFI_ERROR ( Status )) {
684       break;
685     }
686     Status = HttpSendValue ( SocketFD,
687                              pPort,
688                              pGenericAddress->AccessSize );
689     if ( EFI_ERROR ( Status )) {
690       break;
691     }
692     Status = HttpSendAnsiString ( SocketFD,
693                                   pPort,
694                                   "<br/>Address: " );
695     if ( EFI_ERROR ( Status )) {
696       break;
697     }
698 
699     //
700     //  Add the web-page link if necessary
701     //
702     if ( NULL != pWebPage ) {
703       Status = HttpSendAnsiString ( SocketFD,
704                                     pPort,
705                                     "<a target=\"_blank\" href=\"" );
706       if ( EFI_ERROR ( Status )) {
707         break;
708       }
709       Status = HttpSendUnicodeString ( SocketFD,
710                                        pPort,
711                                        pWebPage );
712       if ( EFI_ERROR ( Status )) {
713         break;
714       }
715       Status = HttpSendAnsiString ( SocketFD,
716                                     pPort,
717                                     "\">" );
718       if ( EFI_ERROR ( Status )) {
719         break;
720       }
721     }
722 
723     //
724     //  Display the address
725     //
726     Status = HttpSendAnsiString ( SocketFD,
727                                   pPort,
728                                   "0x" );
729     if ( EFI_ERROR ( Status )) {
730       break;
731     }
732     Status = HttpSendHexBits ( SocketFD,
733                                pPort,
734                                64,
735                                pGenericAddress->Address );
736     if ( EFI_ERROR ( Status )) {
737       break;
738     }
739 
740     //
741     //  Finish the web-page link if necessary
742     //
743     if ( NULL != pWebPage ) {
744       Status = HttpSendAnsiString ( SocketFD,
745                                     pPort,
746                                     "</a>" );
747       if ( EFI_ERROR ( Status )) {
748         break;
749       }
750     }
751 
752     //
753     //  Terminate the row
754     //
755     Status = HttpSendAnsiString ( SocketFD,
756                                   pPort,
757                                   "</code></td></tr>\r\n" );
758     break;
759   }
760 
761   //
762   //  Return the operation status
763   //
764   return Status;
765 }
766 
767 
768 /**
769   Translate a table address into a web page
770 
771   @param [in] pSignature      Address of the table signature
772   @param [out] ppTableName    Address to receive the table name address
773 
774   @return  Zero terminated web page address or NULL if not found
775 
776 **/
777 CONST CHAR16 *
SignatureLookup(IN UINT32 * pSignature,OUT CONST CHAR8 ** ppTableName)778 SignatureLookup (
779   IN UINT32 * pSignature,
780   OUT CONST CHAR8 ** ppTableName
781   )
782 {
783   CONST TABLE_SIGNATURE * pTableId;
784   CONST TABLE_SIGNATURE * pEnd;
785   UINT32 Signature;
786 
787   //
788   //  Walk the list of tables
789   //
790   Signature = *pSignature;
791   pTableId = &mTableId[ 0 ];
792   pEnd = &pTableId[ sizeof ( mTableId ) / sizeof ( mTableId[ 0 ])];
793   while ( pEnd > pTableId ) {
794     //
795     //  Attempt to locate the table signature
796     //
797     if ( pTableId->Signature == Signature ) {
798       //
799       //  The signature was found
800       //  Return the web page
801       //
802       *ppTableName = pTableId->pTableName;
803       return pTableId->pWebPage;
804     }
805 
806     //
807     //  Set the next table
808     //
809     pTableId += 1;
810   }
811 
812   //
813   //  The table was not found
814   //
815   *ppTableName = (CONST CHAR8 *)pSignature;
816   return NULL;
817 }
818 
819 
820 /**
821   Respond with the APIC table
822 
823   @param [in] SocketFD      The socket's file descriptor to add to the list.
824   @param [in] pPort         The WSDT_PORT structure address
825   @param [out] pbDone       Address to receive the request completion status
826 
827   @retval EFI_SUCCESS       The request was successfully processed
828 
829 **/
830 EFI_STATUS
AcpiApicPage(IN int SocketFD,IN WSDT_PORT * pPort,OUT BOOLEAN * pbDone)831 AcpiApicPage (
832   IN int SocketFD,
833   IN WSDT_PORT * pPort,
834   OUT BOOLEAN * pbDone
835   )
836 {
837   CONST ACPI_UNKNOWN * pApic;
838   EFI_STATUS Status;
839 
840   DBG_ENTER ( );
841 
842   //
843   //  Send the APIC page
844   //
845   for ( ; ; ) {
846     //
847     //  Locate the APIC
848     //
849     pApic = (ACPI_UNKNOWN *)LocateTable ( APIC_SIGNATURE );
850     if ( NULL == pApic ) {
851       Status = EFI_NOT_FOUND;
852       break;
853     }
854 
855     //
856     //  Send the page and table header
857     //
858     Status = TableHeader ( SocketFD, pPort, L"APIC Table", pApic );
859     if ( EFI_ERROR ( Status )) {
860       break;
861     }
862 
863     //
864     //  Display the header
865     //
866     Status = RowAnsiArray ( SocketFD,
867                             pPort,
868                             "Signature",
869                             sizeof ( pApic->Signature ),
870                             (CHAR8 *)&pApic->Signature );
871     if ( EFI_ERROR ( Status )) {
872       break;
873     }
874     Status = RowDecimalValue ( SocketFD,
875                                pPort,
876                                "Length",
877                                pApic->Length );
878     if ( EFI_ERROR ( Status )) {
879       break;
880     }
881 
882     //
883     //  Display the data from the table
884     //
885     Status = RowDump ( SocketFD,
886                        pPort,
887                        "Data",
888                        pApic->Length - sizeof ( *pApic ) + 1,
889                        (UINT8 *)( pApic + 1 ));
890     if ( EFI_ERROR ( Status )) {
891       break;
892     }
893 
894     //
895     //  Build the table trailer
896     //
897     Status = TableTrailer ( SocketFD,
898                             pPort,
899                             pbDone );
900     break;
901   }
902 
903   //
904   //  Return the operation status
905   //
906   DBG_EXIT_STATUS ( Status );
907   return Status;
908 }
909 
910 
911 /**
912   Respond with the BGRT table
913 
914   @param [in] SocketFD      The socket's file descriptor to add to the list.
915   @param [in] pPort         The WSDT_PORT structure address
916   @param [out] pbDone       Address to receive the request completion status
917 
918   @retval EFI_SUCCESS       The request was successfully processed
919 
920 **/
921 EFI_STATUS
AcpiBgrtPage(IN int SocketFD,IN WSDT_PORT * pPort,OUT BOOLEAN * pbDone)922 AcpiBgrtPage (
923   IN int SocketFD,
924   IN WSDT_PORT * pPort,
925   OUT BOOLEAN * pbDone
926   )
927 {
928   CONST ACPI_UNKNOWN * pBgrt;
929   EFI_STATUS Status;
930 
931   DBG_ENTER ( );
932 
933   //
934   //  Send the BGRT page
935   //
936   for ( ; ; ) {
937     //
938     //  Locate the BGRT
939     //
940     pBgrt = (ACPI_UNKNOWN *)LocateTable ( BGRT_SIGNATURE );
941     if ( NULL == pBgrt ) {
942       Status = EFI_NOT_FOUND;
943       break;
944     }
945 
946     //
947     //  Send the page and table header
948     //
949     Status = TableHeader ( SocketFD, pPort, L"BGRT Table", pBgrt );
950     if ( EFI_ERROR ( Status )) {
951       break;
952     }
953 
954     //
955     //  Display the header
956     //
957     Status = RowAnsiArray ( SocketFD,
958                             pPort,
959                             "Signature",
960                             sizeof ( pBgrt->Signature ),
961                             (CHAR8 *)&pBgrt->Signature );
962     if ( EFI_ERROR ( Status )) {
963       break;
964     }
965     Status = RowDecimalValue ( SocketFD,
966                                pPort,
967                                "Length",
968                                pBgrt->Length );
969     if ( EFI_ERROR ( Status )) {
970       break;
971     }
972 
973     //
974     //  Display the data from the table
975     //
976     Status = RowDump ( SocketFD,
977                        pPort,
978                        "Data",
979                        pBgrt->Length - sizeof ( *pBgrt ) + 1,
980                        (UINT8 *)( pBgrt + 1 ));
981     if ( EFI_ERROR ( Status )) {
982       break;
983     }
984 
985     //
986     //  Build the table trailer
987     //
988     Status = TableTrailer ( SocketFD,
989                             pPort,
990                             pbDone );
991     break;
992   }
993 
994   //
995   //  Return the operation status
996   //
997   DBG_EXIT_STATUS ( Status );
998   return Status;
999 }
1000 
1001 
1002 /**
1003   Respond with the ACPI DSDT table
1004 
1005   @param [in] SocketFD      The socket's file descriptor to add to the list.
1006   @param [in] pPort         The WSDT_PORT structure address
1007   @param [out] pbDone       Address to receive the request completion status
1008 
1009   @retval EFI_SUCCESS       The request was successfully processed
1010 
1011 **/
1012 EFI_STATUS
AcpiDsdtPage(IN int SocketFD,IN WSDT_PORT * pPort,OUT BOOLEAN * pbDone)1013 AcpiDsdtPage (
1014   IN int SocketFD,
1015   IN WSDT_PORT * pPort,
1016   OUT BOOLEAN * pbDone
1017   )
1018 {
1019   CONST ACPI_DSDT * pDsdt;
1020   CONST ACPI_FADT * pFadt;
1021   EFI_STATUS Status;
1022 
1023   DBG_ENTER ( );
1024 
1025   //
1026   //  Send the DADT page
1027   //
1028   for ( ; ; ) {
1029     //
1030     //  Locate the DADT
1031     //
1032     pFadt = (ACPI_FADT *)LocateTable ( FADT_SIGNATURE );
1033     if ( NULL == pFadt ) {
1034       Status = EFI_NOT_FOUND;
1035       break;
1036     }
1037     pDsdt = (VOID *)(UINTN)pFadt->XDsdt;
1038 
1039     //
1040     //  Send the page and table header
1041     //
1042     Status = TableHeader ( SocketFD, pPort, L"DSDT - Differentiated System Description Table", pDsdt );
1043     if ( EFI_ERROR ( Status )) {
1044       break;
1045     }
1046 
1047     //
1048     //  Display the DSDT header
1049     //
1050     Status = RowAnsiArray ( SocketFD,
1051                             pPort,
1052                             "Signature",
1053                             sizeof ( pDsdt->Signature ),
1054                             (CHAR8 *)&pDsdt->Signature );
1055     if ( EFI_ERROR ( Status )) {
1056       break;
1057     }
1058     Status = RowDecimalValue ( SocketFD,
1059                                pPort,
1060                                "Length",
1061                                pDsdt->Length );
1062     if ( EFI_ERROR ( Status )) {
1063       break;
1064     }
1065     Status = RowDecimalValue ( SocketFD,
1066                                pPort,
1067                                "Revision",
1068                                pDsdt->Revision );
1069     if ( EFI_ERROR ( Status )) {
1070       break;
1071     }
1072     Status = RowHexValue ( SocketFD,
1073                            pPort,
1074                            "Checksum",
1075                            pDsdt->Checksum,
1076                            NULL );
1077     if ( EFI_ERROR ( Status )) {
1078       break;
1079     }
1080     Status = RowAnsiArray ( SocketFD,
1081                             pPort,
1082                             "OEMID",
1083                             sizeof ( pDsdt->OemId ),
1084                             (CONST CHAR8 *)&pDsdt->OemId[ 0 ]);
1085     if ( EFI_ERROR ( Status )) {
1086       break;
1087     }
1088     Status = RowAnsiArray ( SocketFD,
1089                             pPort,
1090                             "OEM Table ID",
1091                             sizeof ( pDsdt->OemTableId ),
1092                             (CONST CHAR8 *)&pDsdt->OemTableId[ 0 ]);
1093     if ( EFI_ERROR ( Status )) {
1094       break;
1095     }
1096     Status = RowRevision ( SocketFD,
1097                            pPort,
1098                            "OEM Revision",
1099                            pDsdt->OemRevision );
1100     if ( EFI_ERROR ( Status )) {
1101       break;
1102     }
1103     Status = RowAnsiArray ( SocketFD,
1104                             pPort,
1105                             "Creator ID",
1106                             sizeof ( pDsdt->CreatorId ),
1107                             (CHAR8 *)&pDsdt->CreatorId );
1108     if ( EFI_ERROR ( Status )) {
1109       break;
1110     }
1111     Status = RowRevision ( SocketFD,
1112                            pPort,
1113                            "Creator Revision",
1114                            pDsdt->CreatorRevision );
1115     if ( EFI_ERROR ( Status )) {
1116       break;
1117     }
1118 
1119     //
1120     //  Display the data from the DSDT
1121     //
1122     Status = RowDump ( SocketFD,
1123                        pPort,
1124                        "Definition Block",
1125                        pDsdt->Length - sizeof ( *pDsdt ) + 1,
1126                        &pDsdt->DefinitionBlock[0]);
1127     if ( EFI_ERROR ( Status )) {
1128       break;
1129     }
1130 
1131     //
1132     //  Build the table trailer
1133     //
1134     Status = TableTrailer ( SocketFD,
1135                             pPort,
1136                             pbDone );
1137     break;
1138   }
1139 
1140   //
1141   //  Return the operation status
1142   //
1143   DBG_EXIT_STATUS ( Status );
1144   return Status;
1145 }
1146 
1147 
1148 /**
1149   Respond with the ACPI FADT table
1150 
1151   @param [in] SocketFD      The socket's file descriptor to add to the list.
1152   @param [in] pPort         The WSDT_PORT structure address
1153   @param [out] pbDone       Address to receive the request completion status
1154 
1155   @retval EFI_SUCCESS       The request was successfully processed
1156 
1157 **/
1158 EFI_STATUS
AcpiFadtPage(IN int SocketFD,IN WSDT_PORT * pPort,OUT BOOLEAN * pbDone)1159 AcpiFadtPage (
1160   IN int SocketFD,
1161   IN WSDT_PORT * pPort,
1162   OUT BOOLEAN * pbDone
1163   )
1164 {
1165   CONST ACPI_FADT * pFadt;
1166   EFI_STATUS Status;
1167 
1168   DBG_ENTER ( );
1169 
1170   //
1171   //  Send the FADT page
1172   //
1173   for ( ; ; ) {
1174     //
1175     //  Locate the FADT
1176     //
1177     pFadt = (ACPI_FADT *)LocateTable ( FADT_SIGNATURE );
1178     if ( NULL == pFadt ) {
1179       Status = EFI_NOT_FOUND;
1180       break;
1181     }
1182 
1183     //
1184     //  Send the page and table header
1185     //
1186     Status = TableHeader ( SocketFD, pPort, L"FADT - Fixed ACPI Description Table", pFadt );
1187     if ( EFI_ERROR ( Status )) {
1188       break;
1189     }
1190 
1191     //
1192     //  Display the FSDT header
1193     //
1194     Status = RowAnsiArray ( SocketFD,
1195                             pPort,
1196                             "Signature",
1197                             sizeof ( pFadt->Signature ),
1198                             (CHAR8 *)&pFadt->Signature );
1199     if ( EFI_ERROR ( Status )) {
1200       break;
1201     }
1202     Status = RowDecimalValue ( SocketFD,
1203                                pPort,
1204                                "Length",
1205                                pFadt->Length );
1206     if ( EFI_ERROR ( Status )) {
1207       break;
1208     }
1209     Status = RowDecimalValue ( SocketFD,
1210                                pPort,
1211                                "Revision",
1212                                pFadt->Revision );
1213     if ( EFI_ERROR ( Status )) {
1214       break;
1215     }
1216     Status = RowHexValue ( SocketFD,
1217                            pPort,
1218                            "Checksum",
1219                            pFadt->Checksum,
1220                            NULL );
1221     if ( EFI_ERROR ( Status )) {
1222       break;
1223     }
1224     Status = RowAnsiArray ( SocketFD,
1225                             pPort,
1226                             "OEMID",
1227                             sizeof ( pFadt->OemId ),
1228                             (CONST CHAR8 *)&pFadt->OemId[ 0 ]);
1229     if ( EFI_ERROR ( Status )) {
1230       break;
1231     }
1232     Status = RowAnsiArray ( SocketFD,
1233                             pPort,
1234                             "OEM Table ID",
1235                             sizeof ( pFadt->OemTableId ),
1236                             (CONST CHAR8 *)&pFadt->OemTableId[ 0 ]);
1237     if ( EFI_ERROR ( Status )) {
1238       break;
1239     }
1240     Status = RowRevision ( SocketFD,
1241                            pPort,
1242                            "OEM Revision",
1243                            pFadt->OemRevision );
1244     if ( EFI_ERROR ( Status )) {
1245       break;
1246     }
1247     Status = RowAnsiArray ( SocketFD,
1248                             pPort,
1249                             "Creator ID",
1250                             sizeof ( pFadt->CreatorId ),
1251                             (CHAR8 *)&pFadt->CreatorId );
1252     if ( EFI_ERROR ( Status )) {
1253       break;
1254     }
1255     Status = RowRevision ( SocketFD,
1256                            pPort,
1257                            "Creator Revision",
1258                            pFadt->CreatorRevision );
1259     if ( EFI_ERROR ( Status )) {
1260       break;
1261     }
1262 
1263     //
1264     //  Display the data from the FADT
1265     //
1266     Status = RowPointer ( SocketFD,
1267                           pPort,
1268                           "FIRMWARE_CTRL",
1269                           (CONST VOID *)(UINTN)pFadt->FirmwareCtrl,
1270                           NULL );
1271     if ( EFI_ERROR ( Status )) {
1272       break;
1273     }
1274     Status = RowPointer ( SocketFD,
1275                           pPort,
1276                           "DSDT",
1277                           (CONST VOID *)(UINTN)pFadt->DSDT,
1278                           ( pFadt->DSDT == pFadt->XDsdt ) ? PAGE_ACPI_DSDT : NULL );
1279     if ( EFI_ERROR ( Status )) {
1280       break;
1281     }
1282     Status = RowHexValue ( SocketFD,
1283                            pPort,
1284                            "Reserved",
1285                            pFadt->Reserved,
1286                            NULL );
1287     if ( EFI_ERROR ( Status )) {
1288       break;
1289     }
1290     Status = RowHexValue ( SocketFD,
1291                            pPort,
1292                            "Preferred_PM_Profile",
1293                            pFadt->PreferredPmProfile,
1294                            NULL );
1295     if ( EFI_ERROR ( Status )) {
1296       break;
1297     }
1298     Status = RowHexValue ( SocketFD,
1299                            pPort,
1300                            "SCI_INT",
1301                            pFadt->SciInt,
1302                            NULL );
1303     if ( EFI_ERROR ( Status )) {
1304       break;
1305     }
1306     Status = RowHexValue ( SocketFD,
1307                            pPort,
1308                            "SMI_CMD",
1309                            pFadt->SmiCmd,
1310                            NULL );
1311     if ( EFI_ERROR ( Status )) {
1312       break;
1313     }
1314     Status = RowHexValue ( SocketFD,
1315                            pPort,
1316                            "ACPI_ENABLE",
1317                            pFadt->AcpiEnable,
1318                            NULL );
1319     if ( EFI_ERROR ( Status )) {
1320       break;
1321     }
1322     Status = RowHexValue ( SocketFD,
1323                            pPort,
1324                            "ACPI_DISABLE",
1325                            pFadt->AcpiDisable,
1326                            NULL );
1327     if ( EFI_ERROR ( Status )) {
1328       break;
1329     }
1330     Status = RowHexValue ( SocketFD,
1331                            pPort,
1332                            "S4BIOS_REQ",
1333                            pFadt->S4BiosReq,
1334                            NULL );
1335     if ( EFI_ERROR ( Status )) {
1336       break;
1337     }
1338     Status = RowHexValue ( SocketFD,
1339                            pPort,
1340                            "PSTATE_CNT",
1341                            pFadt->PStateCnt,
1342                            NULL );
1343     if ( EFI_ERROR ( Status )) {
1344       break;
1345     }
1346     Status = RowHexValue ( SocketFD,
1347                            pPort,
1348                            "PM1a_EVT_BLK",
1349                            pFadt->Pm1aEvtBlk,
1350                            NULL );
1351     if ( EFI_ERROR ( Status )) {
1352       break;
1353     }
1354     Status = RowHexValue ( SocketFD,
1355                            pPort,
1356                            "PM1b_EVT_BLK",
1357                            pFadt->Pm1bEvtBlk,
1358                            NULL );
1359     if ( EFI_ERROR ( Status )) {
1360       break;
1361     }
1362     Status = RowHexValue ( SocketFD,
1363                            pPort,
1364                            "PM1a_CNT_BLK",
1365                            pFadt->Pm1aCntBlk,
1366                            NULL );
1367     if ( EFI_ERROR ( Status )) {
1368       break;
1369     }
1370     Status = RowHexValue ( SocketFD,
1371                            pPort,
1372                            "PM1b_CNT_BLK",
1373                            pFadt->Pm1bCntBlk,
1374                            NULL );
1375     if ( EFI_ERROR ( Status )) {
1376       break;
1377     }
1378     Status = RowHexValue ( SocketFD,
1379                            pPort,
1380                            "PM2_CNT_BLK",
1381                            pFadt->Pm2CntBlk,
1382                            NULL );
1383     if ( EFI_ERROR ( Status )) {
1384       break;
1385     }
1386     Status = RowHexValue ( SocketFD,
1387                            pPort,
1388                            "PM_TMR_BLK",
1389                            pFadt->PmTmrBlk,
1390                            NULL );
1391     if ( EFI_ERROR ( Status )) {
1392       break;
1393     }
1394 
1395     Status = RowHexValue ( SocketFD,
1396                            pPort,
1397                            "GPE0_BLK",
1398                            pFadt->Gpe0Blk,
1399                            NULL );
1400     if ( EFI_ERROR ( Status )) {
1401       break;
1402     }
1403     Status = RowHexValue ( SocketFD,
1404                            pPort,
1405                            "GPE1_BLK",
1406                            pFadt->Gpe1Blk,
1407                            NULL );
1408     if ( EFI_ERROR ( Status )) {
1409       break;
1410     }
1411     Status = RowDecimalValue ( SocketFD,
1412                                pPort,
1413                                "PM1_EVT_LEN",
1414                                pFadt->Pm1EvtLen );
1415     if ( EFI_ERROR ( Status )) {
1416       break;
1417     }
1418     Status = RowDecimalValue ( SocketFD,
1419                                pPort,
1420                                "PM1_CNT_LEN",
1421                                pFadt->Pm1CntLen );
1422     if ( EFI_ERROR ( Status )) {
1423       break;
1424     }
1425     Status = RowDecimalValue ( SocketFD,
1426                                pPort,
1427                                "PM2_CNT_LEN",
1428                                pFadt->PM2CntLen );
1429     if ( EFI_ERROR ( Status )) {
1430       break;
1431     }
1432     Status = RowDecimalValue ( SocketFD,
1433                                pPort,
1434                                "PM_TMR_LEN",
1435                                pFadt->PmTmrLen );
1436     if ( EFI_ERROR ( Status )) {
1437       break;
1438     }
1439     Status = RowDecimalValue ( SocketFD,
1440                                pPort,
1441                                "GPE0_BLK_LEN",
1442                                pFadt->Gpe0BlkLen );
1443     if ( EFI_ERROR ( Status )) {
1444       break;
1445     }
1446     Status = RowDecimalValue ( SocketFD,
1447                                pPort,
1448                                "GPE1_BLK_LEN",
1449                                pFadt->Gpe1BlkLen );
1450     if ( EFI_ERROR ( Status )) {
1451       break;
1452     }
1453     Status = RowHexValue ( SocketFD,
1454                            pPort,
1455                            "GPE1_BASE",
1456                            pFadt->Gpe1Base,
1457                            NULL );
1458     if ( EFI_ERROR ( Status )) {
1459       break;
1460     }
1461     Status = RowDecimalValue ( SocketFD,
1462                                pPort,
1463                                "CST_CNT",
1464                                pFadt->CstCnt );
1465     if ( EFI_ERROR ( Status )) {
1466       break;
1467     }
1468     Status = RowHexValue ( SocketFD,
1469                            pPort,
1470                            "P_LVL2_LAT",
1471                            pFadt->PLvl2Lat,
1472                            NULL );
1473     if ( EFI_ERROR ( Status )) {
1474       break;
1475     }
1476     Status = RowHexValue ( SocketFD,
1477                            pPort,
1478                            "P_LVL3_LAT",
1479                            pFadt->PLvl3Lat,
1480                            NULL );
1481     if ( EFI_ERROR ( Status )) {
1482       break;
1483     }
1484     Status = RowDecimalValue ( SocketFD,
1485                                pPort,
1486                                "FLUSH_SIZE",
1487                                pFadt->FlushSize );
1488     if ( EFI_ERROR ( Status )) {
1489       break;
1490     }
1491     Status = RowDecimalValue ( SocketFD,
1492                                pPort,
1493                                "FLUSH_Stride",
1494                                pFadt->FlushStride );
1495     if ( EFI_ERROR ( Status )) {
1496       break;
1497     }
1498     Status = RowHexValue ( SocketFD,
1499                            pPort,
1500                            "DUTY_OFFSET",
1501                            pFadt->DutyOffset,
1502                            NULL );
1503     if ( EFI_ERROR ( Status )) {
1504       break;
1505     }
1506     Status = RowHexValue ( SocketFD,
1507                            pPort,
1508                            "DUTY_WIDTH",
1509                            pFadt->DutyWidth,
1510                            NULL );
1511     if ( EFI_ERROR ( Status )) {
1512       break;
1513     }
1514     Status = RowHexValue ( SocketFD,
1515                            pPort,
1516                            "DAY_ALRM",
1517                            pFadt->DayAlrm,
1518                            NULL );
1519     if ( EFI_ERROR ( Status )) {
1520       break;
1521     }
1522     Status = RowHexValue ( SocketFD,
1523                            pPort,
1524                            "MON_ALRM",
1525                            pFadt->MonAlrm,
1526                            NULL );
1527     if ( EFI_ERROR ( Status )) {
1528       break;
1529     }
1530     Status = RowHexValue ( SocketFD,
1531                            pPort,
1532                            "CENTURY",
1533                            pFadt->Century,
1534                            NULL );
1535     if ( EFI_ERROR ( Status )) {
1536       break;
1537     }
1538     Status = RowHexValue ( SocketFD,
1539                            pPort,
1540                            "IAPC_BOOT_ARCH",
1541                            pFadt->IapcBootArch,
1542                            NULL );
1543     if ( EFI_ERROR ( Status )) {
1544       break;
1545     }
1546     Status = RowHexValue ( SocketFD,
1547                            pPort,
1548                            "Reserved",
1549                            pFadt->Reserved2,
1550                            NULL );
1551     if ( EFI_ERROR ( Status )) {
1552       break;
1553     }
1554     Status = RowHexValue ( SocketFD,
1555                            pPort,
1556                            "Flags",
1557                            pFadt->Flags,
1558                            NULL );
1559     if ( EFI_ERROR ( Status )) {
1560       break;
1561     }
1562     Status = RowGenericAddress ( SocketFD,
1563                                  pPort,
1564                                  "RESET_REG",
1565                                  &pFadt->ResetReg[0],
1566                                  NULL );
1567     if ( EFI_ERROR ( Status )) {
1568       break;
1569     }
1570     Status = RowHexValue ( SocketFD,
1571                            pPort,
1572                            "RESET_VALUE",
1573                            pFadt->ResetValue,
1574                            NULL );
1575     if ( EFI_ERROR ( Status )) {
1576       break;
1577     }
1578     Status = RowHexValue ( SocketFD,
1579                            pPort,
1580                            "Reserved",
1581                            pFadt->Reserved3[0],
1582                            NULL );
1583     if ( EFI_ERROR ( Status )) {
1584       break;
1585     }
1586     Status = RowHexValue ( SocketFD,
1587                            pPort,
1588                            "Reserved",
1589                            pFadt->Reserved3[1],
1590                            NULL );
1591     if ( EFI_ERROR ( Status )) {
1592       break;
1593     }
1594     Status = RowHexValue ( SocketFD,
1595                            pPort,
1596                            "Reserved",
1597                            pFadt->Reserved3[2],
1598                            NULL );
1599     if ( EFI_ERROR ( Status )) {
1600       break;
1601     }
1602     Status = RowHexValue ( SocketFD,
1603                            pPort,
1604                            "X_FIRMWARE_CTRL",
1605                            pFadt->XFirmwareCtrl,
1606                            NULL );
1607     if ( EFI_ERROR ( Status )) {
1608       break;
1609     }
1610     Status = RowHexValue ( SocketFD,
1611                            pPort,
1612                            "X_DSDT",
1613                            pFadt->XDsdt,
1614                            PAGE_ACPI_DSDT );
1615     if ( EFI_ERROR ( Status )) {
1616       break;
1617     }
1618     Status = RowGenericAddress ( SocketFD,
1619                                  pPort,
1620                                  "X_PM1a_EVT_BLK",
1621                                  &pFadt->XPm1aEvtBlk[0],
1622                                  NULL );
1623     if ( EFI_ERROR ( Status )) {
1624       break;
1625     }
1626     Status = RowGenericAddress ( SocketFD,
1627                                  pPort,
1628                                  "X_PM1b_EVT_BLK",
1629                                  &pFadt->XPm1bEvtBlk[0],
1630                                  NULL );
1631     if ( EFI_ERROR ( Status )) {
1632       break;
1633     }
1634     Status = RowGenericAddress ( SocketFD,
1635                                  pPort,
1636                                  "X_PM1a_CNT_BLK",
1637                                  &pFadt->XPm1aCntBlk[0],
1638                                  NULL );
1639     if ( EFI_ERROR ( Status )) {
1640       break;
1641     }
1642     Status = RowGenericAddress ( SocketFD,
1643                                  pPort,
1644                                  "X_PM1b_CNT_BLK",
1645                                  &pFadt->XPm1bCntBlk[0],
1646                                  NULL );
1647     if ( EFI_ERROR ( Status )) {
1648       break;
1649     }
1650     Status = RowGenericAddress ( SocketFD,
1651                                  pPort,
1652                                  "X_PM2_CNT_BLK",
1653                                  &pFadt->XPm2CntBlk[0],
1654                                  NULL );
1655     if ( EFI_ERROR ( Status )) {
1656       break;
1657     }
1658     Status = RowGenericAddress ( SocketFD,
1659                                  pPort,
1660                                  "X_PM_TMR_BLK",
1661                                  &pFadt->XPmTmrBlk[0],
1662                                  NULL );
1663     if ( EFI_ERROR ( Status )) {
1664       break;
1665     }
1666     Status = RowGenericAddress ( SocketFD,
1667                                  pPort,
1668                                  "X_GPE0_BLK",
1669                                  &pFadt->XGpe0Blk[0],
1670                                  NULL );
1671     if ( EFI_ERROR ( Status )) {
1672       break;
1673     }
1674     Status = RowGenericAddress ( SocketFD,
1675                                  pPort,
1676                                  "X_GPE1_BLK",
1677                                  &pFadt->XGpe1Blk[0],
1678                                  NULL );
1679     if ( EFI_ERROR ( Status )) {
1680       break;
1681     }
1682 
1683     //
1684     //  Build the table trailer
1685     //
1686     Status = TableTrailer ( SocketFD,
1687                             pPort,
1688                             pbDone );
1689     break;
1690   }
1691 
1692   //
1693   //  Return the operation status
1694   //
1695   DBG_EXIT_STATUS ( Status );
1696   return Status;
1697 }
1698 
1699 
1700 /**
1701   Respond with the HPET table
1702 
1703   @param [in] SocketFD      The socket's file descriptor to add to the list.
1704   @param [in] pPort         The WSDT_PORT structure address
1705   @param [out] pbDone       Address to receive the request completion status
1706 
1707   @retval EFI_SUCCESS       The request was successfully processed
1708 
1709 **/
1710 EFI_STATUS
AcpiHpetPage(IN int SocketFD,IN WSDT_PORT * pPort,OUT BOOLEAN * pbDone)1711 AcpiHpetPage (
1712   IN int SocketFD,
1713   IN WSDT_PORT * pPort,
1714   OUT BOOLEAN * pbDone
1715   )
1716 {
1717   CONST ACPI_UNKNOWN * pHpet;
1718   EFI_STATUS Status;
1719 
1720   DBG_ENTER ( );
1721 
1722   //
1723   //  Send the HPET page
1724   //
1725   for ( ; ; ) {
1726     //
1727     //  Locate the HPET
1728     //
1729     pHpet = (ACPI_UNKNOWN *)LocateTable ( HPET_SIGNATURE );
1730     if ( NULL == pHpet ) {
1731       Status = EFI_NOT_FOUND;
1732       break;
1733     }
1734 
1735     //
1736     //  Send the page and table header
1737     //
1738     Status = TableHeader ( SocketFD, pPort, L"HPET Table", pHpet );
1739     if ( EFI_ERROR ( Status )) {
1740       break;
1741     }
1742 
1743     //
1744     //  Display the header
1745     //
1746     Status = RowAnsiArray ( SocketFD,
1747                             pPort,
1748                             "Signature",
1749                             sizeof ( pHpet->Signature ),
1750                             (CHAR8 *)&pHpet->Signature );
1751     if ( EFI_ERROR ( Status )) {
1752       break;
1753     }
1754     Status = RowDecimalValue ( SocketFD,
1755                                pPort,
1756                                "Length",
1757                                pHpet->Length );
1758     if ( EFI_ERROR ( Status )) {
1759       break;
1760     }
1761 
1762     //
1763     //  Display the data from the table
1764     //
1765     Status = RowDump ( SocketFD,
1766                        pPort,
1767                        "Data",
1768                        pHpet->Length - sizeof ( *pHpet ) + 1,
1769                        (UINT8 *)( pHpet + 1 ));
1770     if ( EFI_ERROR ( Status )) {
1771       break;
1772     }
1773 
1774     //
1775     //  Build the table trailer
1776     //
1777     Status = TableTrailer ( SocketFD,
1778                             pPort,
1779                             pbDone );
1780     break;
1781   }
1782 
1783   //
1784   //  Return the operation status
1785   //
1786   DBG_EXIT_STATUS ( Status );
1787   return Status;
1788 }
1789 
1790 
1791 /**
1792   Respond with the MCFG table
1793 
1794   @param [in] SocketFD      The socket's file descriptor to add to the list.
1795   @param [in] pPort         The WSDT_PORT structure address
1796   @param [out] pbDone       Address to receive the request completion status
1797 
1798   @retval EFI_SUCCESS       The request was successfully processed
1799 
1800 **/
1801 EFI_STATUS
AcpiMcfgPage(IN int SocketFD,IN WSDT_PORT * pPort,OUT BOOLEAN * pbDone)1802 AcpiMcfgPage (
1803   IN int SocketFD,
1804   IN WSDT_PORT * pPort,
1805   OUT BOOLEAN * pbDone
1806   )
1807 {
1808   CONST ACPI_UNKNOWN * pMcfg;
1809   EFI_STATUS Status;
1810 
1811   DBG_ENTER ( );
1812 
1813   //
1814   //  Send the MCFG page
1815   //
1816   for ( ; ; ) {
1817     //
1818     //  Locate the MCFG
1819     //
1820     pMcfg = (ACPI_UNKNOWN *)LocateTable ( MCFG_SIGNATURE );
1821     if ( NULL == pMcfg ) {
1822       Status = EFI_NOT_FOUND;
1823       break;
1824     }
1825 
1826     //
1827     //  Send the page and table header
1828     //
1829     Status = TableHeader ( SocketFD, pPort, L"MCFG Table", pMcfg );
1830     if ( EFI_ERROR ( Status )) {
1831       break;
1832     }
1833 
1834     //
1835     //  Display the header
1836     //
1837     Status = RowAnsiArray ( SocketFD,
1838                             pPort,
1839                             "Signature",
1840                             sizeof ( pMcfg->Signature ),
1841                             (CHAR8 *)&pMcfg->Signature );
1842     if ( EFI_ERROR ( Status )) {
1843       break;
1844     }
1845     Status = RowDecimalValue ( SocketFD,
1846                                pPort,
1847                                "Length",
1848                                pMcfg->Length );
1849     if ( EFI_ERROR ( Status )) {
1850       break;
1851     }
1852 
1853     //
1854     //  Display the data from the table
1855     //
1856     Status = RowDump ( SocketFD,
1857                        pPort,
1858                        "Data",
1859                        pMcfg->Length - sizeof ( *pMcfg ) + 1,
1860                        (UINT8 *)( pMcfg + 1 ));
1861     if ( EFI_ERROR ( Status )) {
1862       break;
1863     }
1864 
1865     //
1866     //  Build the table trailer
1867     //
1868     Status = TableTrailer ( SocketFD,
1869                             pPort,
1870                             pbDone );
1871     break;
1872   }
1873 
1874   //
1875   //  Return the operation status
1876   //
1877   DBG_EXIT_STATUS ( Status );
1878   return Status;
1879 }
1880 
1881 
1882 /**
1883   Respond with the ACPI RSDP 1.0b table
1884 
1885   @param [in] SocketFD      The socket's file descriptor to add to the list.
1886   @param [in] pPort         The WSDT_PORT structure address
1887   @param [out] pbDone       Address to receive the request completion status
1888 
1889   @retval EFI_SUCCESS       The request was successfully processed
1890 
1891 **/
1892 EFI_STATUS
AcpiRsdp10Page(IN int SocketFD,IN WSDT_PORT * pPort,OUT BOOLEAN * pbDone)1893 AcpiRsdp10Page (
1894   IN int SocketFD,
1895   IN WSDT_PORT * pPort,
1896   OUT BOOLEAN * pbDone
1897   )
1898 {
1899   CONST EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER * pRsdp10b;
1900   EFI_STATUS Status;
1901 
1902   DBG_ENTER ( );
1903 
1904   //
1905   //  Send the RSDP page
1906   //
1907   for ( ; ; ) {
1908     //
1909     //  Locate the RSDP
1910     //
1911     Status = EfiGetSystemConfigurationTable ( &gEfiAcpi10TableGuid, (VOID **) &pRsdp10b );
1912     if ( EFI_ERROR ( Status )) {
1913       break;
1914     }
1915 
1916     //
1917     //  Send the page and table header
1918     //
1919     Status = TableHeader ( SocketFD, pPort, L"RSDP - ACPI 1.0b Root System Description Pointer", pRsdp10b );
1920     if ( EFI_ERROR ( Status )) {
1921       break;
1922     }
1923 
1924     //
1925     //  Display the RSDP
1926     //
1927     Status = RowAnsiArray ( SocketFD,
1928                             pPort,
1929                             "Signature",
1930                             sizeof ( pRsdp10b->Signature ),
1931                             (CHAR8 *)&pRsdp10b->Signature );
1932     if ( EFI_ERROR ( Status )) {
1933       break;
1934     }
1935     Status = RowHexValue ( SocketFD,
1936                            pPort,
1937                            "Checksum",
1938                            pRsdp10b->Checksum,
1939                            NULL );
1940     if ( EFI_ERROR ( Status )) {
1941       break;
1942     }
1943     Status = RowAnsiArray ( SocketFD,
1944                             pPort,
1945                             "OemId",
1946                             sizeof ( pRsdp10b->OemId ),
1947                             (CONST CHAR8 *)&pRsdp10b->OemId[ 0 ]);
1948     if ( EFI_ERROR ( Status )) {
1949       break;
1950     }
1951     Status = RowHexValue ( SocketFD,
1952                            pPort,
1953                            "Reserved",
1954                            pRsdp10b->Reserved,
1955                            NULL );
1956     if ( EFI_ERROR ( Status )) {
1957       break;
1958     }
1959     Status = RowPointer ( SocketFD,
1960                           pPort,
1961                           "RsdtAddress",
1962                           (VOID *)(UINTN)pRsdp10b->RsdtAddress,
1963                           PAGE_ACPI_RSDT );
1964     if ( EFI_ERROR ( Status )) {
1965       break;
1966     }
1967 
1968     //
1969     //  Build the table trailer
1970     //
1971     Status = TableTrailer ( SocketFD,
1972                             pPort,
1973                             pbDone );
1974     break;
1975   }
1976 
1977   //
1978   //  Return the operation status
1979   //
1980   DBG_EXIT_STATUS ( Status );
1981   return Status;
1982 }
1983 
1984 
1985 /**
1986   Respond with the ACPI RSDP 3.0 table
1987 
1988   @param [in] SocketFD      The socket's file descriptor to add to the list.
1989   @param [in] pPort         The WSDT_PORT structure address
1990   @param [out] pbDone       Address to receive the request completion status
1991 
1992   @retval EFI_SUCCESS       The request was successfully processed
1993 
1994 **/
1995 EFI_STATUS
AcpiRsdp30Page(IN int SocketFD,IN WSDT_PORT * pPort,OUT BOOLEAN * pbDone)1996 AcpiRsdp30Page (
1997   IN int SocketFD,
1998   IN WSDT_PORT * pPort,
1999   OUT BOOLEAN * pbDone
2000   )
2001 {
2002   CONST EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER * pRsdp30;
2003   EFI_STATUS Status;
2004 
2005   DBG_ENTER ( );
2006 
2007   //
2008   //  Send the RSDP page
2009   //
2010   for ( ; ; ) {
2011     //
2012     //  Locate the RSDP
2013     //
2014     Status = EfiGetSystemConfigurationTable ( &gEfiAcpiTableGuid, (VOID **) &pRsdp30 );
2015     if ( EFI_ERROR ( Status )) {
2016       break;
2017     }
2018 
2019     //
2020     //  Send the page and table header
2021     //
2022     Status = TableHeader ( SocketFD, pPort, L"RSDP - ACPI 3.0 Root System Description Pointer", pRsdp30 );
2023     if ( EFI_ERROR ( Status )) {
2024       break;
2025     }
2026 
2027     //
2028     //  Display the RSDP
2029     //
2030     Status = RowAnsiArray ( SocketFD,
2031                             pPort,
2032                             "Signature",
2033                             sizeof ( pRsdp30->Signature ),
2034                             (CHAR8 *)&pRsdp30->Signature );
2035     if ( EFI_ERROR ( Status )) {
2036       break;
2037     }
2038     Status = RowHexValue ( SocketFD,
2039                            pPort,
2040                            "Checksum",
2041                            pRsdp30->Checksum,
2042                            NULL );
2043     if ( EFI_ERROR ( Status )) {
2044       break;
2045     }
2046     Status = RowAnsiArray ( SocketFD,
2047                             pPort,
2048                             "OemId",
2049                             sizeof ( pRsdp30->OemId ),
2050                             (CONST CHAR8 *)&pRsdp30->OemId[ 0 ]);
2051     if ( EFI_ERROR ( Status )) {
2052       break;
2053     }
2054     Status = RowHexValue ( SocketFD,
2055                            pPort,
2056                            "Revision",
2057                            pRsdp30->Revision,
2058                            NULL );
2059     if ( EFI_ERROR ( Status )) {
2060       break;
2061     }
2062     Status = RowPointer ( SocketFD,
2063                           pPort,
2064                           "RsdtAddress",
2065                           (VOID *)(UINTN)pRsdp30->RsdtAddress,
2066                           PAGE_ACPI_RSDT );
2067     if ( EFI_ERROR ( Status )) {
2068       break;
2069     }
2070     Status = RowDecimalValue ( SocketFD,
2071                                pPort,
2072                                "Length",
2073                                pRsdp30->Length );
2074     if ( EFI_ERROR ( Status )) {
2075       break;
2076     }
2077     Status = RowPointer ( SocketFD,
2078                           pPort,
2079                           "XsdtAddress",
2080                           (VOID *)(UINTN)pRsdp30->XsdtAddress,
2081                           NULL );
2082     if ( EFI_ERROR ( Status )) {
2083       break;
2084     }
2085     Status = RowHexValue ( SocketFD,
2086                            pPort,
2087                            "ExtendedChecksum",
2088                            pRsdp30->ExtendedChecksum,
2089                            NULL );
2090     if ( EFI_ERROR ( Status )) {
2091       break;
2092     }
2093     Status = RowBytes ( SocketFD,
2094                         pPort,
2095                         "Reserved",
2096                         sizeof ( pRsdp30->Reserved ),
2097                         &pRsdp30->Reserved[ 0 ]);
2098     if ( EFI_ERROR ( Status )) {
2099       break;
2100     }
2101 
2102     //
2103     //  Build the table trailer
2104     //
2105     Status = TableTrailer ( SocketFD,
2106                             pPort,
2107                             pbDone );
2108     break;
2109   }
2110 
2111   //
2112   //  Return the operation status
2113   //
2114   DBG_EXIT_STATUS ( Status );
2115   return Status;
2116 }
2117 
2118 
2119 /**
2120   Respond with the ACPI RSDT table
2121 
2122   @param [in] SocketFD      The socket's file descriptor to add to the list.
2123   @param [in] pPort         The WSDT_PORT structure address
2124   @param [out] pbDone       Address to receive the request completion status
2125 
2126   @retval EFI_SUCCESS       The request was successfully processed
2127 
2128 **/
2129 EFI_STATUS
AcpiRsdtPage(IN int SocketFD,IN WSDT_PORT * pPort,OUT BOOLEAN * pbDone)2130 AcpiRsdtPage (
2131   IN int SocketFD,
2132   IN WSDT_PORT * pPort,
2133   OUT BOOLEAN * pbDone
2134   )
2135 {
2136   CONST UINT32 * pEnd;
2137   CONST UINT32 * pEntry;
2138   CONST ACPI_RSDT * pRsdt;
2139   CONST CHAR8 * pTableName;
2140   CONST CHAR16 * pWebPage;
2141   EFI_STATUS Status;
2142   UINT32 TableName[ 2 ];
2143 
2144   DBG_ENTER ( );
2145 
2146   //
2147   //  Send the RSDT page
2148   //
2149   for ( ; ; ) {
2150     //
2151     //  Locate the RSDT
2152     //
2153     pRsdt = LocateRsdt ( );
2154     if ( NULL == pRsdt ) {
2155       Status = EFI_NOT_FOUND;
2156       break;
2157     }
2158 
2159     //
2160     //  Send the page and table header
2161     //
2162     Status = TableHeader ( SocketFD, pPort, L"RSDT - ACPI Root System Description Table", pRsdt );
2163     if ( EFI_ERROR ( Status )) {
2164       break;
2165     }
2166 
2167     //
2168     //  Display the RSDT
2169     //
2170     Status = RowAnsiArray ( SocketFD,
2171                             pPort,
2172                             "Signature",
2173                             sizeof ( pRsdt->Signature ),
2174                             (CHAR8 *)&pRsdt->Signature );
2175     if ( EFI_ERROR ( Status )) {
2176       break;
2177     }
2178     Status = RowDecimalValue ( SocketFD,
2179                                pPort,
2180                                "Length",
2181                                pRsdt->Length );
2182     if ( EFI_ERROR ( Status )) {
2183       break;
2184     }
2185     Status = RowDecimalValue ( SocketFD,
2186                                pPort,
2187                                "Revision",
2188                                pRsdt->Revision );
2189     if ( EFI_ERROR ( Status )) {
2190       break;
2191     }
2192     Status = RowHexValue ( SocketFD,
2193                            pPort,
2194                            "Checksum",
2195                            pRsdt->Checksum,
2196                            NULL );
2197     if ( EFI_ERROR ( Status )) {
2198       break;
2199     }
2200     Status = RowAnsiArray ( SocketFD,
2201                             pPort,
2202                             "OEMID",
2203                             sizeof ( pRsdt->OemId ),
2204                             (CONST CHAR8 *)&pRsdt->OemId[ 0 ]);
2205     if ( EFI_ERROR ( Status )) {
2206       break;
2207     }
2208     Status = RowAnsiArray ( SocketFD,
2209                             pPort,
2210                             "OEM Table ID",
2211                             sizeof ( pRsdt->OemTableId ),
2212                             (CONST CHAR8 *)&pRsdt->OemTableId[ 0 ]);
2213     if ( EFI_ERROR ( Status )) {
2214       break;
2215     }
2216     Status = RowRevision ( SocketFD,
2217                            pPort,
2218                            "OEM Revision",
2219                            pRsdt->OemRevision );
2220     if ( EFI_ERROR ( Status )) {
2221       break;
2222     }
2223     Status = RowAnsiArray ( SocketFD,
2224                             pPort,
2225                             "Creator ID",
2226                             sizeof ( pRsdt->CreatorId ),
2227                             (CHAR8 *)&pRsdt->CreatorId );
2228     if ( EFI_ERROR ( Status )) {
2229       break;
2230     }
2231     Status = RowRevision ( SocketFD,
2232                            pPort,
2233                            "Creator Revision",
2234                            pRsdt->CreatorRevision );
2235     if ( EFI_ERROR ( Status )) {
2236       break;
2237     }
2238 
2239     //
2240     //  Walk the list of entries
2241     //
2242     pEntry = &pRsdt->Entry[ 0 ];
2243     pEnd = &pEntry[(( pRsdt->Length - sizeof ( *pRsdt )) >> 2 ) + 1 ];
2244     TableName[ 1 ] = 0;
2245     while ( pEnd > pEntry ) {
2246       //
2247       //  The entry is actually a 32-bit physical table address
2248       //  The first entry in the table is the 32-bit table signature
2249       //
2250       TableName[ 0 ] = *(UINT32 *)(UINTN)*pEntry;
2251       pWebPage = SignatureLookup ( &TableName[ 0 ], &pTableName );
2252 
2253       //
2254       //  Display the table address
2255       //
2256       Status = RowPointer ( SocketFD,
2257                             pPort,
2258                             pTableName,
2259                             (VOID *)(UINTN)*pEntry,
2260                             pWebPage );
2261       if ( EFI_ERROR ( Status )) {
2262         break;
2263       }
2264       pEntry++;
2265     }
2266     if ( EFI_ERROR ( Status )) {
2267       break;
2268     }
2269 
2270     //
2271     //  Build the table trailer
2272     //
2273     Status = TableTrailer ( SocketFD,
2274                             pPort,
2275                             pbDone );
2276     break;
2277   }
2278 
2279   //
2280   //  Return the operation status
2281   //
2282   DBG_EXIT_STATUS ( Status );
2283   return Status;
2284 }
2285 
2286 
2287 /**
2288   Respond with the SSDT table
2289 
2290   @param [in] SocketFD      The socket's file descriptor to add to the list.
2291   @param [in] pPort         The WSDT_PORT structure address
2292   @param [out] pbDone       Address to receive the request completion status
2293 
2294   @retval EFI_SUCCESS       The request was successfully processed
2295 
2296 **/
2297 EFI_STATUS
AcpiSsdtPage(IN int SocketFD,IN WSDT_PORT * pPort,OUT BOOLEAN * pbDone)2298 AcpiSsdtPage (
2299   IN int SocketFD,
2300   IN WSDT_PORT * pPort,
2301   OUT BOOLEAN * pbDone
2302   )
2303 {
2304   CONST ACPI_UNKNOWN * pSsdt;
2305   EFI_STATUS Status;
2306 
2307   DBG_ENTER ( );
2308 
2309   //
2310   //  Send the SSDT page
2311   //
2312   for ( ; ; ) {
2313     //
2314     //  Locate the SSDT
2315     //
2316     pSsdt = (ACPI_UNKNOWN *)LocateTable ( SSDT_SIGNATURE );
2317     if ( NULL == pSsdt ) {
2318       Status = EFI_NOT_FOUND;
2319       break;
2320     }
2321 
2322     //
2323     //  Send the page and table header
2324     //
2325     Status = TableHeader ( SocketFD, pPort, L"SSDT Table", pSsdt );
2326     if ( EFI_ERROR ( Status )) {
2327       break;
2328     }
2329 
2330     //
2331     //  Display the header
2332     //
2333     Status = RowAnsiArray ( SocketFD,
2334                             pPort,
2335                             "Signature",
2336                             sizeof ( pSsdt->Signature ),
2337                             (CHAR8 *)&pSsdt->Signature );
2338     if ( EFI_ERROR ( Status )) {
2339       break;
2340     }
2341     Status = RowDecimalValue ( SocketFD,
2342                                pPort,
2343                                "Length",
2344                                pSsdt->Length );
2345     if ( EFI_ERROR ( Status )) {
2346       break;
2347     }
2348 
2349     //
2350     //  Display the data from the table
2351     //
2352     Status = RowDump ( SocketFD,
2353                        pPort,
2354                        "Data",
2355                        pSsdt->Length - sizeof ( *pSsdt ) + 1,
2356                        (UINT8 *)( pSsdt + 1 ));
2357     if ( EFI_ERROR ( Status )) {
2358       break;
2359     }
2360 
2361     //
2362     //  Build the table trailer
2363     //
2364     Status = TableTrailer ( SocketFD,
2365                             pPort,
2366                             pbDone );
2367     break;
2368   }
2369 
2370   //
2371   //  Return the operation status
2372   //
2373   DBG_EXIT_STATUS ( Status );
2374   return Status;
2375 }
2376 
2377 
2378 /**
2379   Respond with the TCPA table
2380 
2381   @param [in] SocketFD      The socket's file descriptor to add to the list.
2382   @param [in] pPort         The WSDT_PORT structure address
2383   @param [out] pbDone       Address to receive the request completion status
2384 
2385   @retval EFI_SUCCESS       The request was successfully processed
2386 
2387 **/
2388 EFI_STATUS
AcpiTcpaPage(IN int SocketFD,IN WSDT_PORT * pPort,OUT BOOLEAN * pbDone)2389 AcpiTcpaPage (
2390   IN int SocketFD,
2391   IN WSDT_PORT * pPort,
2392   OUT BOOLEAN * pbDone
2393   )
2394 {
2395   CONST ACPI_UNKNOWN * pTcpa;
2396   EFI_STATUS Status;
2397 
2398   DBG_ENTER ( );
2399 
2400   //
2401   //  Send the TCPA page
2402   //
2403   for ( ; ; ) {
2404     //
2405     //  Locate the TCPA
2406     //
2407     pTcpa = (ACPI_UNKNOWN *)LocateTable ( TCPA_SIGNATURE );
2408     if ( NULL == pTcpa ) {
2409       Status = EFI_NOT_FOUND;
2410       break;
2411     }
2412 
2413     //
2414     //  Send the page and table header
2415     //
2416     Status = TableHeader ( SocketFD, pPort, L"TCPA Table", pTcpa );
2417     if ( EFI_ERROR ( Status )) {
2418       break;
2419     }
2420 
2421     //
2422     //  Display the header
2423     //
2424     Status = RowAnsiArray ( SocketFD,
2425                             pPort,
2426                             "Signature",
2427                             sizeof ( pTcpa->Signature ),
2428                             (CHAR8 *)&pTcpa->Signature );
2429     if ( EFI_ERROR ( Status )) {
2430       break;
2431     }
2432     Status = RowDecimalValue ( SocketFD,
2433                                pPort,
2434                                "Length",
2435                                pTcpa->Length );
2436     if ( EFI_ERROR ( Status )) {
2437       break;
2438     }
2439 
2440     //
2441     //  Display the data from the table
2442     //
2443     Status = RowDump ( SocketFD,
2444                        pPort,
2445                        "Data",
2446                        pTcpa->Length - sizeof ( *pTcpa ) + 1,
2447                        (UINT8 *)( pTcpa + 1 ));
2448     if ( EFI_ERROR ( Status )) {
2449       break;
2450     }
2451 
2452     //
2453     //  Build the table trailer
2454     //
2455     Status = TableTrailer ( SocketFD,
2456                             pPort,
2457                             pbDone );
2458     break;
2459   }
2460 
2461   //
2462   //  Return the operation status
2463   //
2464   DBG_EXIT_STATUS ( Status );
2465   return Status;
2466 }
2467 
2468 
2469 /**
2470   Respond with the UEFI table
2471 
2472   @param [in] SocketFD      The socket's file descriptor to add to the list.
2473   @param [in] pPort         The WSDT_PORT structure address
2474   @param [out] pbDone       Address to receive the request completion status
2475 
2476   @retval EFI_SUCCESS       The request was successfully processed
2477 
2478 **/
2479 EFI_STATUS
AcpiUefiPage(IN int SocketFD,IN WSDT_PORT * pPort,OUT BOOLEAN * pbDone)2480 AcpiUefiPage (
2481   IN int SocketFD,
2482   IN WSDT_PORT * pPort,
2483   OUT BOOLEAN * pbDone
2484   )
2485 {
2486   CONST ACPI_UNKNOWN * pUefi;
2487   EFI_STATUS Status;
2488 
2489   DBG_ENTER ( );
2490 
2491   //
2492   //  Send the UEFI page
2493   //
2494   for ( ; ; ) {
2495     //
2496     //  Locate the UEFI
2497     //
2498     pUefi = (ACPI_UNKNOWN *)LocateTable ( UEFI_SIGNATURE );
2499     if ( NULL == pUefi ) {
2500       Status = EFI_NOT_FOUND;
2501       break;
2502     }
2503 
2504     //
2505     //  Send the page and table header
2506     //
2507     Status = TableHeader ( SocketFD, pPort, L"UEFI Table", pUefi );
2508     if ( EFI_ERROR ( Status )) {
2509       break;
2510     }
2511 
2512     //
2513     //  Display the header
2514     //
2515     Status = RowAnsiArray ( SocketFD,
2516                             pPort,
2517                             "Signature",
2518                             sizeof ( pUefi->Signature ),
2519                             (CHAR8 *)&pUefi->Signature );
2520     if ( EFI_ERROR ( Status )) {
2521       break;
2522     }
2523     Status = RowDecimalValue ( SocketFD,
2524                                pPort,
2525                                "Length",
2526                                pUefi->Length );
2527     if ( EFI_ERROR ( Status )) {
2528       break;
2529     }
2530 
2531     //
2532     //  Display the data from the table
2533     //
2534     Status = RowDump ( SocketFD,
2535                        pPort,
2536                        "Data",
2537                        pUefi->Length - sizeof ( *pUefi ) + 1,
2538                        (UINT8 *)( pUefi + 1 ));
2539     if ( EFI_ERROR ( Status )) {
2540       break;
2541     }
2542 
2543     //
2544     //  Build the table trailer
2545     //
2546     Status = TableTrailer ( SocketFD,
2547                             pPort,
2548                             pbDone );
2549     break;
2550   }
2551 
2552   //
2553   //  Return the operation status
2554   //
2555   DBG_EXIT_STATUS ( Status );
2556   return Status;
2557 }
2558