EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

AppPkg/Applications/Sockets/WebServer/SystemTable.c

Go to the documentation of this file.
00001 /*++
00002   This file contains an 'Intel UEFI Application' and is        
00003   licensed for Intel CPUs and chipsets under the terms of your  
00004   license agreement with Intel or your vendor.  This file may   
00005   be modified by the user, subject to additional terms of the   
00006   license agreement                                             
00007 --*/
00008 /*++
00009 
00010 Copyright (c)  2011 Intel Corporation. All rights reserved
00011 This software and associated documentation (if any) is furnished
00012 under a license and may only be used or copied in accordance
00013 with the terms of the license. Except as permitted by such
00014 license, no part of this software or documentation may be
00015 reproduced, stored in a retrieval system, or transmitted in any
00016 form or by any means without the express written consent of
00017 Intel Corporation.
00018 
00019 --*/
00020 
00026 #include <WebServer.h>
00027 
00028 
00039 EFI_STATUS
00040 EfiTableHeader (
00041   IN int SocketFD,
00042   IN WSDT_PORT * pPort,
00043   IN EFI_TABLE_HEADER * pHeader
00044   )
00045 {
00046   EFI_STATUS Status;
00047 
00048   DBG_ENTER ( );
00049   
00050   //
00051   //  Send the handles page
00052   //
00053   for ( ; ; ) {
00059     Status = RowHexValue ( SocketFD,
00060                            pPort,
00061                            "Hdr.Signature",
00062                            pHeader->Signature,
00063                            NULL );
00064     if ( EFI_ERROR ( Status )) {
00065       break;
00066     }
00067 
00074     Status = RowRevision ( SocketFD,
00075                            pPort,
00076                            "Hdr.Revision",
00077                            pHeader->Revision );
00078     if ( EFI_ERROR ( Status )) {
00079       break;
00080     }
00081 
00085     Status = RowDecimalValue ( SocketFD,
00086                                pPort,
00087                                "Hdr.HeaderSize",
00088                                pHeader->HeaderSize );
00089     if ( EFI_ERROR ( Status )) {
00090       break;
00091     }
00092 
00097     Status = RowHexValue ( SocketFD,
00098                            pPort,
00099                            "Hdr.CRC",
00100                            pHeader->CRC32,
00101                            NULL );
00102     if ( EFI_ERROR ( Status )) {
00103       break;
00104     }
00105 
00109     Status = RowHexValue ( SocketFD,
00110                            pPort,
00111                            "Hdr.Reserved",
00112                            pHeader->Reserved,
00113                            NULL );
00114     break;
00115   }
00116 
00117   //
00118   //  Return the operation status
00119   //
00120   DBG_EXIT_STATUS ( Status );
00121   return Status;
00122 }
00123 
00124 
00136 EFI_STATUS
00137 RowDecimalValue (
00138   IN int SocketFD,
00139   IN WSDT_PORT * pPort,
00140   IN CONST CHAR8 * pName,
00141   IN UINT64 Value
00142   )
00143 {
00144   EFI_STATUS Status;
00145 
00146   DBG_ENTER ( );
00147 
00148   //
00149   //  Use for/break instead of goto
00150   //
00151   for ( ; ; ) {
00152     Status = HttpSendAnsiString ( SocketFD,
00153                                   pPort,
00154                                   "<tr><td>" );
00155     if ( EFI_ERROR ( Status )) {
00156       break;
00157     }
00158     Status = HttpSendAnsiString ( SocketFD,
00159                                   pPort,
00160                                   pName );
00161     if ( EFI_ERROR ( Status )) {
00162       break;
00163     }
00164     Status = HttpSendAnsiString ( SocketFD,
00165                                   pPort,
00166                                   "</td><td><code>" );
00167     if ( EFI_ERROR ( Status )) {
00168       break;
00169     }
00170     Status = HttpSendValue ( SocketFD,
00171                              pPort,
00172                              Value );
00173     if ( EFI_ERROR ( Status )) {
00174       break;
00175     }
00176     Status = HttpSendAnsiString ( SocketFD,
00177                                   pPort,
00178                                   "</code></td></tr>\r\n" );
00179     break;
00180   }
00181 
00182   //
00183   //  Return the operation status
00184   //
00185   DBG_EXIT_STATUS ( Status );
00186   return Status;
00187 }
00188 
00189 
00202 EFI_STATUS
00203 RowHexValue (
00204   IN int SocketFD,
00205   IN WSDT_PORT * pPort,
00206   IN CONST CHAR8 * pName,
00207   IN UINT64 Value,
00208   IN CONST CHAR16 * pWebPage
00209   )
00210 {
00211   EFI_STATUS Status;
00212 
00213   DBG_ENTER ( );
00214 
00215   //
00216   //  Use for/break instead of goto
00217   //
00218   for ( ; ; ) {
00219     Status = HttpSendAnsiString ( SocketFD,
00220                                   pPort,
00221                                   "<tr><td>" );
00222     if ( EFI_ERROR ( Status )) {
00223       break;
00224     }
00225     Status = HttpSendAnsiString ( SocketFD,
00226                                   pPort,
00227                                   pName );
00228     if ( EFI_ERROR ( Status )) {
00229       break;
00230     }
00231     Status = HttpSendAnsiString ( SocketFD,
00232                                   pPort,
00233                                   "</td><td><code>0x" );
00234     if ( EFI_ERROR ( Status )) {
00235       break;
00236     }
00237     if ( NULL != pWebPage ) {
00238       Status = HttpSendAnsiString ( SocketFD,
00239                                     pPort,
00240                                     "<a target=\"_blank\" href=\"" );
00241       if ( EFI_ERROR ( Status )) {
00242         break;
00243       }
00244       Status = HttpSendUnicodeString ( SocketFD,
00245                                        pPort,
00246                                        pWebPage );
00247       if ( EFI_ERROR ( Status )) {
00248         break;
00249       }
00250       Status = HttpSendAnsiString ( SocketFD,
00251                                     pPort,
00252                                     "\">" );
00253       if ( EFI_ERROR ( Status )) {
00254         break;
00255       }
00256     }
00257     Status = HttpSendHexValue ( SocketFD,
00258                                 pPort,
00259                                 Value );
00260     if ( EFI_ERROR ( Status )) {
00261       break;
00262     }
00263     if ( NULL != pWebPage ) {
00264       Status = HttpSendAnsiString ( SocketFD,
00265                                     pPort,
00266                                     "</a>" );
00267       if ( EFI_ERROR ( Status )) {
00268         break;
00269       }
00270     }
00271     Status = HttpSendAnsiString ( SocketFD,
00272                                   pPort,
00273                                   "</code></td></tr>\r\n" );
00274     break;
00275   }
00276 
00277   //
00278   //  Return the operation status
00279   //
00280   DBG_EXIT_STATUS ( Status );
00281   return Status;
00282 }
00283 
00284 
00297 EFI_STATUS
00298 RowPointer (
00299   IN int SocketFD,
00300   IN WSDT_PORT * pPort,
00301   IN CONST CHAR8 * pName,
00302   IN CONST VOID * pAddress,
00303   IN CONST CHAR16 * pWebPage
00304   )
00305 {
00306   EFI_STATUS Status;
00307 
00308   DBG_ENTER ( );
00309 
00310   //
00311   //  Use for/break instead of goto
00312   //
00313   for ( ; ; ) {
00314     Status = HttpSendAnsiString ( SocketFD,
00315                                   pPort,
00316                                   "<tr><td>" );
00317     if ( EFI_ERROR ( Status )) {
00318       break;
00319     }
00320     Status = HttpSendAnsiString ( SocketFD,
00321                                   pPort,
00322                                   pName );
00323     if ( EFI_ERROR ( Status )) {
00324       break;
00325     }
00326     Status = HttpSendAnsiString ( SocketFD,
00327                                   pPort,
00328                                   "</td><td><code>" );
00329     if ( EFI_ERROR ( Status )) {
00330       break;
00331     }
00332     if ( NULL != pWebPage ) {
00333       Status = HttpSendAnsiString ( SocketFD,
00334                                     pPort,
00335                                     "<a target=\"_blank\" href=\"" );
00336       if ( EFI_ERROR ( Status )) {
00337         break;
00338       }
00339       Status = HttpSendUnicodeString ( SocketFD,
00340                                        pPort,
00341                                        pWebPage );
00342       if ( EFI_ERROR ( Status )) {
00343         break;
00344       }
00345       Status = HttpSendAnsiString ( SocketFD,
00346                                     pPort,
00347                                     "\">" );
00348       if ( EFI_ERROR ( Status )) {
00349         break;
00350       }
00351     }
00352     Status = HttpSendAnsiString ( SocketFD,
00353                                   pPort,
00354                                   "0x" );
00355     if ( EFI_ERROR ( Status )) {
00356       break;
00357     }
00358     Status = HttpSendHexBits ( SocketFD,
00359                                pPort,
00360                                sizeof ( pAddress ) * 8,
00361                                (UINT64) pAddress );
00362     if ( EFI_ERROR ( Status )) {
00363       break;
00364     }
00365     if ( NULL != pWebPage ) {
00366       Status = HttpSendAnsiString ( SocketFD,
00367                                     pPort,
00368                                     "</a>" );
00369       if ( EFI_ERROR ( Status )) {
00370         break;
00371       }
00372     }
00373     Status = HttpSendAnsiString ( SocketFD,
00374                                   pPort,
00375                                   "</code></td></tr>\r\n" );
00376     break;
00377   }
00378 
00379   //
00380   //  Return the operation status
00381   //
00382   DBG_EXIT_STATUS ( Status );
00383   return Status;
00384 }
00385 
00386 
00398 EFI_STATUS
00399 RowRevision (
00400   IN int SocketFD,
00401   IN WSDT_PORT * pPort,
00402   IN CONST CHAR8 * pName,
00403   IN UINT32 Revision
00404   )
00405 {
00406   EFI_STATUS Status;
00407 
00408   DBG_ENTER ( );
00409 
00410   //
00411   //  Use for/break instead of goto
00412   //
00413   for ( ; ; ) {
00414     Status = HttpSendAnsiString ( SocketFD,
00415                                   pPort,
00416                                   "<tr><td>" );
00417     if ( EFI_ERROR ( Status )) {
00418       break;
00419     }
00420     Status = HttpSendAnsiString ( SocketFD,
00421                                   pPort,
00422                                   pName );
00423     if ( EFI_ERROR ( Status )) {
00424       break;
00425     }
00426     Status = HttpSendAnsiString ( SocketFD,
00427                                   pPort,
00428                                   "</td><td><code>" );
00429     if ( EFI_ERROR ( Status )) {
00430       break;
00431     }
00432     Status = HttpSendValue ( SocketFD,
00433                              pPort,
00434                              Revision >> 16 );
00435     if ( EFI_ERROR ( Status )) {
00436       break;
00437     }
00438     Status = HttpSendByte ( SocketFD,
00439                             pPort,
00440                             '.' );
00441     if ( EFI_ERROR ( Status )) {
00442       break;
00443     }
00444     Status = HttpSendValue ( SocketFD,
00445                              pPort,
00446                              Revision & 0xFFFF );
00447     if ( EFI_ERROR ( Status )) {
00448       break;
00449     }
00450     Status = HttpSendAnsiString ( SocketFD,
00451                                   pPort,
00452                                   "</code></td></tr>\r\n" );
00453     break;
00454   }
00455 
00456   //
00457   //  Return the operation status
00458   //
00459   DBG_EXIT_STATUS ( Status );
00460   return Status;
00461 }
00462 
00463 
00475 EFI_STATUS
00476 RowUnicodeString (
00477   IN int SocketFD,
00478   IN WSDT_PORT * pPort,
00479   IN CONST CHAR8 * pName,
00480   IN CONST CHAR16 * pString
00481   )
00482 {
00483   EFI_STATUS Status;
00484 
00485   DBG_ENTER ( );
00486 
00487   //
00488   //  Use for/break instead of goto
00489   //
00490   for ( ; ; ) {
00491     Status = HttpSendAnsiString ( SocketFD,
00492                                   pPort,
00493                                   "<tr><td>" );
00494     if ( EFI_ERROR ( Status )) {
00495       break;
00496     }
00497     Status = HttpSendAnsiString ( SocketFD,
00498                                   pPort,
00499                                   pName );
00500     if ( EFI_ERROR ( Status )) {
00501       break;
00502     }
00503     Status = HttpSendAnsiString ( SocketFD,
00504                                   pPort,
00505                                   "</td><td>" );
00506     if ( EFI_ERROR ( Status )) {
00507       break;
00508     }
00509     Status = HttpSendUnicodeString ( SocketFD,
00510                                      pPort,
00511                                      pString );
00512     if ( EFI_ERROR ( Status )) {
00513       break;
00514     }
00515     Status = HttpSendAnsiString ( SocketFD,
00516                                   pPort,
00517                                   "</td></tr>\r\n" );
00518     break;
00519   }
00520 
00521   //
00522   //  Return the operation status
00523   //
00524   DBG_EXIT_STATUS ( Status );
00525   return Status;
00526 }
00527 
00528 
00540 EFI_STATUS
00541 TableHeader (
00542   IN int SocketFD,
00543   IN WSDT_PORT * pPort,
00544   IN CONST CHAR16 * pName,
00545   IN CONST VOID * pTable
00546   )
00547 {
00548   EFI_STATUS Status;
00549 
00550   DBG_ENTER ( );
00551 
00552   //
00553   //  Use for/break instead of goto
00554   //
00555   for ( ; ; ) {
00556     //
00557     //  Send the page header
00558     //
00559     Status = HttpPageHeader ( SocketFD, pPort, pName );
00560     if ( EFI_ERROR ( Status )) {
00561       break;
00562     }
00563     
00564     //
00565     //  Build the table header
00566     //
00567     Status = HttpSendAnsiString ( SocketFD,
00568                                   pPort,
00569                                   "<h1>" );
00570     if ( EFI_ERROR ( Status )) {
00571       break;
00572     }
00573     Status = HttpSendUnicodeString ( SocketFD,
00574                                      pPort,
00575                                      pName );
00576     if ( EFI_ERROR ( Status )) {
00577       break;
00578     }
00579     if ( NULL != pTable ) {
00580       Status = HttpSendAnsiString ( SocketFD,
00581                                     pPort,
00582                                     ": 0x" );
00583       if ( EFI_ERROR ( Status )) {
00584         break;
00585       }
00586       Status = HttpSendHexBits ( SocketFD,
00587                                  pPort,
00588                                  sizeof ( pTable ) *  8,
00589                                  (UINT64)pTable );
00590       if ( EFI_ERROR ( Status )) {
00591         break;
00592       }
00593     }
00594     Status = HttpSendAnsiString ( SocketFD,
00595                                   pPort,
00596                                   "</h1>\r\n"
00597                                   "<table border=\"1\">\r\n"
00598                                   "  <tr bgcolor=\"c0c0ff\"><th>Field Name</th><th>Value</th></tr>\r\n" );
00599     break;
00600   }
00601 
00602   //
00603   //  Return the operation status
00604   //
00605   DBG_EXIT_STATUS ( Status );
00606   return Status;
00607 }
00608 
00609 
00620 EFI_STATUS
00621 TableTrailer (
00622   IN int SocketFD,
00623   IN WSDT_PORT * pPort,
00624   OUT BOOLEAN *pbDone
00625   )
00626 {
00627   EFI_STATUS Status;
00628 
00629   DBG_ENTER ( );
00630 
00631   //
00632   //  Use for/break instead of goto
00633   //
00634   for ( ; ; ) {
00635     //
00636     //  Build the table trailer
00637     //
00638     Status = HttpSendAnsiString ( SocketFD,
00639                                   pPort,
00640                                   "</table>\r\n" );
00641     if ( EFI_ERROR ( Status )) {
00642       break;
00643     }
00644     
00645     //
00646     //  Send the page trailer
00647     //
00648     Status = HttpPageTrailer ( SocketFD, pPort, pbDone );
00649     break;
00650   }
00651 
00652   //
00653   //  Return the operation status
00654   //
00655   DBG_EXIT_STATUS ( Status );
00656   return Status;
00657 }
00658 
00659 
00670 EFI_STATUS
00671 SystemTablePage (
00672   IN int SocketFD,
00673   IN WSDT_PORT * pPort,
00674   OUT BOOLEAN * pbDone
00675   )
00676 {
00677   EFI_STATUS Status;
00678 
00679   DBG_ENTER ( );
00680   
00681   //
00682   //  Send the system table page
00683   //
00684   for ( ; ; ) {
00685     //
00686     //  Send the page and table header
00687     //
00688     Status = TableHeader ( SocketFD, pPort, L"System Table", gST );
00689     if ( EFI_ERROR ( Status )) {
00690       break;
00691     }
00692 
00696     Status = EfiTableHeader ( SocketFD,
00697                               pPort,
00698                               &gST->Hdr );
00699     if ( EFI_ERROR ( Status )) {
00700       break;
00701     }
00702 
00707     Status = RowUnicodeString ( SocketFD,
00708                                 pPort,
00709                                 "FirmwareVendor",
00710                                 gST->FirmwareVendor );
00711     if ( EFI_ERROR ( Status )) {
00712       break;
00713     }
00714 
00719     Status = RowRevision ( SocketFD,
00720                            pPort,
00721                            "FirmwareRevision",
00722                            gST->FirmwareRevision );
00723     if ( EFI_ERROR ( Status )) {
00724       break;
00725     }
00726 
00731     Status = RowPointer ( SocketFD,
00732                           pPort,
00733                           "ConsoleInHandle",
00734                           (VOID *)gST->ConsoleInHandle,
00735                           NULL );
00736     if ( EFI_ERROR ( Status )) {
00737       break;
00738     }
00739 
00744     Status = RowPointer ( SocketFD,
00745                           pPort,
00746                           "ConIn",
00747                           (VOID *)gST->ConIn,
00748                           NULL );
00749     if ( EFI_ERROR ( Status )) {
00750       break;
00751     }
00752 
00756     Status = RowPointer ( SocketFD,
00757                           pPort,
00758                           "ConsoleOutHandle",
00759                           (VOID *)gST->ConsoleOutHandle,
00760                           NULL );
00761     if ( EFI_ERROR ( Status )) {
00762       break;
00763     }
00764 
00769     Status = RowPointer ( SocketFD,
00770                           pPort,
00771                           "ConOut",
00772                           (VOID *)gST->ConOut,
00773                           NULL );
00774     if ( EFI_ERROR ( Status )) {
00775       break;
00776     }
00777 
00782     Status = RowPointer ( SocketFD,
00783                           pPort,
00784                           "StandardErrorHandle",
00785                           (VOID *)gST->StandardErrorHandle,
00786                           NULL );
00787     if ( EFI_ERROR ( Status )) {
00788       break;
00789     }
00790 
00795     Status = RowPointer ( SocketFD,
00796                           pPort,
00797                           "StdErr",
00798                           (VOID *)gST->StdErr,
00799                           NULL );
00800     if ( EFI_ERROR ( Status )) {
00801       break;
00802     }
00803 
00807     Status = RowPointer ( SocketFD,
00808                           pPort,
00809                           "RuntimeServices",
00810                           (VOID *)gST->RuntimeServices,
00811                           PAGE_RUNTIME_SERVICES_TABLE );
00812 
00816     Status = RowPointer ( SocketFD,
00817                           pPort,
00818                           "BootServices",
00819                           (VOID *)gST->BootServices,
00820                           PAGE_BOOT_SERVICES_TABLE );
00821     if ( EFI_ERROR ( Status )) {
00822       break;
00823     }
00824 
00828     Status = RowDecimalValue ( SocketFD,
00829                                pPort,
00830                                "NumberOfTableEntries",
00831                                gST->NumberOfTableEntries );
00832     if ( EFI_ERROR ( Status )) {
00833       break;
00834     }
00835 
00840     Status = RowPointer ( SocketFD,
00841                           pPort,
00842                           "ConfigurationTable",
00843                           (VOID *)gST->ConfigurationTable,
00844                           PAGE_CONFIGURATION_TABLE );
00845     if ( EFI_ERROR ( Status )) {
00846       break;
00847     }
00848 
00849     //
00850     //  Build the table trailer
00851     //
00852     Status = TableTrailer ( SocketFD,
00853                             pPort,
00854                             pbDone );
00855     break;
00856   }
00857     
00858   //
00859   //  Return the operation status
00860   //
00861   DBG_EXIT_STATUS ( Status );
00862   return Status;
00863 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines