Split Nt32OemHookStatusCodeLib to PEI/DXE instances
authorqhuang8 <qhuang8@de2fecce-e211-0410-80a6-f3fac2684e05>
Tue, 13 Feb 2007 05:00:26 +0000 (05:00 +0000)
committerqhuang8 <qhuang8@de2fecce-e211-0410-80a6-f3fac2684e05>
Tue, 13 Feb 2007 05:00:26 +0000 (05:00 +0000)
git-svn-id: https://edk2.tianocore.org/svn/edk2/trunk@2378 de2fecce-e211-0410-80a6-f3fac2684e05

edk2/EdkNt32Pkg/EdkNt32Pkg.spd
edk2/EdkNt32Pkg/Library/DxeNt32OemHookStatusCodeLib/DxeNt32OemHookStatusCodeLib.msa [new file with mode: 0644]
edk2/EdkNt32Pkg/Library/DxeNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c [new file with mode: 0644]
edk2/EdkNt32Pkg/Library/PeiNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c [new file with mode: 0644]
edk2/EdkNt32Pkg/Library/PeiNt32OemHookStatusCodeLib/PeiNt32OemHookStatusCodeLib.msa [new file with mode: 0644]
edk2/EdkNt32Pkg/Nt32.fpd

index 4c7837a..2044857 100644 (file)
@@ -109,7 +109,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     <Filename>Library/EdkGenericBdsLib/EdkGenericBdsLib.msa</Filename>\r
     <Filename>Library/EdkNt32PeiPeCoffGetEntryPointLib/EdkNt32PeiPeCoffGetEntryPointLib.msa</Filename>\r
     <Filename>Library/Nt32PeCoffLoaderLib/Nt32PeCoffLoaderLib.msa</Filename>\r
-    <Filename>Library/Nt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.msa</Filename>\r
+    <Filename>Library/PeiNt32OemHookStatusCodeLib/PeiNt32OemHookStatusCodeLib.msa</Filename>\r
+    <Filename>Library/DxeNt32OemHookStatusCodeLib/DxeNt32OemHookStatusCodeLib.msa</Filename>\r
     <Filename>Logo/Logo.msa</Filename>\r
     <Filename>Pei/Autoscan/WinNtAutoScan.msa</Filename>\r
     <Filename>Pei/BootMode/BootMode.msa</Filename>\r
@@ -353,15 +354,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
         such as "My EFI Console".\r
         The item type of this PCD can only be "DYNAMIC".</HelpText>\r
     </PcdEntry>\r
-    <PcdEntry>\r
-      <C_Name>PcdNt32StatusCodeLibUseForPei</C_Name>\r
-      <Token>0x0000100b</Token>\r
-      <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-      <DatumType>BOOLEAN</DatumType>\r
-      <ValidUsage>FEATURE_FLAG</ValidUsage>\r
-      <DefaultValue>FALSE</DefaultValue>\r
-      <HelpText>Select which type of driver the library links against.</HelpText>\r
-    </PcdEntry>\r
     <PcdEntry>\r
       <C_Name>PcdWinNtMemorySizeForSecMain</C_Name>\r
       <Token>0x0000100c</Token>\r
diff --git a/edk2/EdkNt32Pkg/Library/DxeNt32OemHookStatusCodeLib/DxeNt32OemHookStatusCodeLib.msa b/edk2/EdkNt32Pkg/Library/DxeNt32OemHookStatusCodeLib/DxeNt32OemHookStatusCodeLib.msa
new file mode 100644 (file)
index 0000000..463c607
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>DxeNt32OemHookStatusCodeLib</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>EF172A23-C7C5-47b7-B24E-D10DFE15540F</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Memory Status Code Library for UEFI drivers</Abstract>\r
+    <Description>Lib to provide memory journal status code reporting Routines</Description>\r
+    <Copyright>Copyright (c) 2007, Intel Corporation.</Copyright>\r
+    <License>All rights reserved.
+      This software and associated documentation (if any) is furnished
+      under a license and may only be used or copied in accordance
+      with the terms of the license. Except as permitted by such
+      license, no part of this software or documentation may be
+      reproduced, stored in a retrieval system, or transmitted in any
+      form or by any means without the express written consent of
+      Intel Corporation.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>DxeNt32OemHookStatusCodeLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER">\r
+      <Keyword>OemHookStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PrintLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>ReportStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>Nt32OemHookStatusCodeLib.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiWinNtThunkProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiStatusCodeSpecificDataGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/edk2/EdkNt32Pkg/Library/DxeNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c b/edk2/EdkNt32Pkg/Library/DxeNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c
new file mode 100644 (file)
index 0000000..942d7ea
--- /dev/null
@@ -0,0 +1,231 @@
+/** @file\r
+  OEM hook status code library functions with no library constructor/destructor\r
+\r
+  Copyright (c) 2006, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+  Module Name:  Nt32OemHookStatusCodeLib.c\r
+\r
+**/\r
+\r
+//\r
+// Cache of WinNtThunk protocol \r
+//\r
+STATIC\r
+EFI_WIN_NT_THUNK_PROTOCOL   *mWinNt;\r
+\r
+//\r
+// Cache of standard output handle . \r
+//\r
+STATIC\r
+HANDLE                      mStdOut;\r
+\r
+/**\r
+\r
+  Initialize OEM status code device .\r
+\r
+  @return    Always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+OemHookStatusCodeInitialize (\r
+  VOID\r
+  )\r
+{\r
+  EFI_HOB_GUID_TYPE   *GuidHob;\r
+\r
+  //\r
+  // Retrieve WinNtThunkProtocol from GUID'ed HOB\r
+  //\r
+  GuidHob = GetFirstGuidHob (&gEfiWinNtThunkProtocolGuid);\r
+  ASSERT (GuidHob != NULL);\r
+  mWinNt = (EFI_WIN_NT_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r
+  ASSERT (mWinNt != NULL);\r
+\r
+  //\r
+  // Cache standard output handle.\r
+  //\r
+  mStdOut = mWinNt->GetStdHandle (STD_OUTPUT_HANDLE);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Report status code to OEM device.\r
\r
+  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\r
+  @param  Value         Describes the current status of a hardware or software entity.  \r
+                        This included information about the class and subclass that is used to classify the entity \r
+                        as well as an operation.  For progress codes, the operation is the current activity. \r
+                        For error codes, it is the exception.  For debug codes, it is not defined at this time. \r
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing. \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
+\r
+\r
+  @param  CallerId      This optional parameter may be used to identify the caller. \r
+                        This parameter allows the status code driver to apply different rules to different callers. \r
+                        Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.\r
+\r
+\r
+  @param  Data          This optional parameter may be used to pass additional data\r
\r
+  @return               The function always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+OemHookStatusCodeReport (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId, OPTIONAL\r
+  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
+  )\r
+{\r
+  CHAR8           *Filename;\r
+  CHAR8           *Description;\r
+  CHAR8           *Format;\r
+  CHAR8           Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+  UINT32          ErrorLevel;\r
+  UINT32          LineNumber;\r
+  UINTN           CharCount;\r
+  VA_LIST         Marker;\r
+  EFI_DEBUG_INFO  *DebugInfo;\r
+\r
+  Buffer[0] = '\0';\r
+\r
+  if (Data != NULL &&\r
+      ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
+    //\r
+    // Print ASSERT() information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer,\r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE,\r
+                  "\n\rASSERT!: %a (%d): %a\n\r",\r
+                  Filename,\r
+                  LineNumber,\r
+                  Description\r
+                  );\r
+\r
+    //\r
+    // Callout to standard output.\r
+    //\r
+    mWinNt->WriteFile (\r
+              mStdOut,\r
+              Buffer,\r
+              CharCount,\r
+              &CharCount,\r
+              NULL\r
+              );\r
+\r
+    return EFI_SUCCESS;\r
+\r
+  } else if (Data != NULL &&\r
+             ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
+    //\r
+    // Print DEBUG() information into output buffer.\r
+    //\r
+    CharCount = AsciiVSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  Format, \r
+                  Marker\r
+                  );\r
+  } else if (Data != NULL && \r
+             CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&\r
+             (CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r
+    //\r
+    // Print specific data into output buffer.\r
+    //\r
+    DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);\r
+    Marker    = (VA_LIST) (DebugInfo + 1);\r
+    Format    = (CHAR8 *) (((UINT64 *) Marker) + 12);\r
+\r
+    CharCount = AsciiVSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);\r
+  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
+    //\r
+    // Print ERROR information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "ERROR: C%x:V%x I%x", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+\r
+    //\r
+    // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.\r
+    //\r
+    \r
+    if (CallerId != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %g",\r
+                     CallerId\r
+                     );\r
+    }\r
+\r
+    if (Data != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %x",\r
+                     Data\r
+                     );\r
+    }\r
+\r
+    CharCount += AsciiSPrint (\r
+                   &Buffer[CharCount - 1],\r
+                   (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                   "\n\r"\r
+                   );\r
+  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "PROGRESS CODE: V%x I%x\n\r", \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  } else {\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "Undefined: C%x:V%x I%x\n\r", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  }\r
+\r
+  //\r
+  // Callout to standard output.\r
+  //\r
+  mWinNt->WriteFile (\r
+            mStdOut,\r
+            Buffer,\r
+            CharCount,\r
+            &CharCount,\r
+            NULL\r
+            );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/edk2/EdkNt32Pkg/Library/PeiNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c b/edk2/EdkNt32Pkg/Library/PeiNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c
new file mode 100644 (file)
index 0000000..629982f
--- /dev/null
@@ -0,0 +1,240 @@
+/** @file\r
+  OEM hook status code library functions with no library constructor/destructor\r
+\r
+  Copyright (c) 2006, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+  Module Name:  Nt32OemHookStatusCodeLib.c\r
+\r
+**/\r
+\r
+//\r
+// Cache of WinNtThunk protocol \r
+//\r
+STATIC\r
+EFI_WIN_NT_THUNK_PROTOCOL   *mWinNt;\r
+\r
+//\r
+// Cache of standard output handle . \r
+//\r
+STATIC\r
+HANDLE                      mStdOut;\r
+\r
+/**\r
+\r
+  Initialize OEM status code device .\r
+\r
+  @return    Always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+OemHookStatusCodeInitialize (\r
+  VOID\r
+  )\r
+{\r
+  PEI_NT_THUNK_PPI  *NtThunkPpi;\r
+  EFI_STATUS        Status;\r
+\r
+  \r
+  //\r
+  // Locate NtThunkPpi for retrieving standard output handle\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+              &gPeiNtThunkPpiGuid,\r
+              0,\r
+              NULL,\r
+              (VOID **) &NtThunkPpi\r
+              );\r
+\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  mWinNt  = (EFI_WIN_NT_THUNK_PROTOCOL *) NtThunkPpi->NtThunk ();\r
+  \r
+\r
+  //\r
+  // Cache standard output handle.\r
+  //\r
+  mStdOut = mWinNt->GetStdHandle (STD_OUTPUT_HANDLE);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Report status code to OEM device.\r
\r
+  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\r
+  @param  Value         Describes the current status of a hardware or software entity.  \r
+                        This included information about the class and subclass that is used to classify the entity \r
+                        as well as an operation.  For progress codes, the operation is the current activity. \r
+                        For error codes, it is the exception.  For debug codes, it is not defined at this time. \r
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing. \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
+\r
+\r
+  @param  CallerId      This optional parameter may be used to identify the caller. \r
+                        This parameter allows the status code driver to apply different rules to different callers. \r
+                        Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.\r
+\r
+\r
+  @param  Data          This optional parameter may be used to pass additional data\r
\r
+  @return               The function always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+OemHookStatusCodeReport (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId, OPTIONAL\r
+  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
+  )\r
+{\r
+  CHAR8           *Filename;\r
+  CHAR8           *Description;\r
+  CHAR8           *Format;\r
+  CHAR8           Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+  UINT32          ErrorLevel;\r
+  UINT32          LineNumber;\r
+  UINTN           CharCount;\r
+  VA_LIST         Marker;\r
+  EFI_DEBUG_INFO  *DebugInfo;\r
+\r
+  Buffer[0] = '\0';\r
+\r
+  if (Data != NULL &&\r
+      ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
+    //\r
+    // Print ASSERT() information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer,\r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE,\r
+                  "\n\rASSERT!: %a (%d): %a\n\r",\r
+                  Filename,\r
+                  LineNumber,\r
+                  Description\r
+                  );\r
+\r
+    //\r
+    // Callout to standard output.\r
+    //\r
+    mWinNt->WriteFile (\r
+              mStdOut,\r
+              Buffer,\r
+              CharCount,\r
+              &CharCount,\r
+              NULL\r
+              );\r
+\r
+    return EFI_SUCCESS;\r
+\r
+  } else if (Data != NULL &&\r
+             ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
+    //\r
+    // Print DEBUG() information into output buffer.\r
+    //\r
+    CharCount = AsciiVSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  Format, \r
+                  Marker\r
+                  );\r
+  } else if (Data != NULL && \r
+             CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&\r
+             (CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r
+    //\r
+    // Print specific data into output buffer.\r
+    //\r
+    DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);\r
+    Marker    = (VA_LIST) (DebugInfo + 1);\r
+    Format    = (CHAR8 *) (((UINT64 *) Marker) + 12);\r
+\r
+    CharCount = AsciiVSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);\r
+  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
+    //\r
+    // Print ERROR information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "ERROR: C%x:V%x I%x", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+\r
+    //\r
+    // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.\r
+    //\r
+    \r
+    if (CallerId != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %g",\r
+                     CallerId\r
+                     );\r
+    }\r
+\r
+    if (Data != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %x",\r
+                     Data\r
+                     );\r
+    }\r
+\r
+    CharCount += AsciiSPrint (\r
+                   &Buffer[CharCount - 1],\r
+                   (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                   "\n\r"\r
+                   );\r
+  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "PROGRESS CODE: V%x I%x\n\r", \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  } else {\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "Undefined: C%x:V%x I%x\n\r", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  }\r
+\r
+  //\r
+  // Callout to standard output.\r
+  //\r
+  mWinNt->WriteFile (\r
+            mStdOut,\r
+            Buffer,\r
+            CharCount,\r
+            &CharCount,\r
+            NULL\r
+            );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/edk2/EdkNt32Pkg/Library/PeiNt32OemHookStatusCodeLib/PeiNt32OemHookStatusCodeLib.msa b/edk2/EdkNt32Pkg/Library/PeiNt32OemHookStatusCodeLib/PeiNt32OemHookStatusCodeLib.msa
new file mode 100644 (file)
index 0000000..3fd99ae
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>PeiNt32OemHookStatusCodeLib</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>0C2070F9-02A7-4e8e-B584-84EA922363FB</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Memory Status Code Library for UEFI drivers</Abstract>\r
+    <Description>Lib to provide memory journal status code reporting Routines</Description>\r
+    <Copyright>Copyright (c) 2007, Intel Corporation.</Copyright>\r
+    <License>All rights reserved.
+      This software and associated documentation (if any) is furnished
+      under a license and may only be used or copied in accordance
+      with the terms of the license. Except as permitted by such
+      license, no part of this software or documentation may be
+      reproduced, stored in a retrieval system, or transmitted in any
+      form or by any means without the express written consent of
+      Intel Corporation.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>PeiNt32OemHookStatusCodeLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="PEIM">\r
+      <Keyword>OemHookStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PrintLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>ReportStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>Nt32OemHookStatusCodeLib.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3"/>\r
+  </PackageDependencies>\r
+  <PPIs>\r
+    <Ppi Usage="ALWAYS_CONSUMED">\r
+      <PpiCName>gPeiNtThunkPpiGuid</PpiCName>\r
+    </Ppi>\r
+  </PPIs>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiStatusCodeSpecificDataGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
index 99e972d..02583a3 100644 (file)
           <MaxDatumSize>4</MaxDatumSize>\r
           <Value>10000000</Value>\r
         </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugPropertyMask</C_Name>\r
-          <Token>0x00000005</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT8</DatumType>\r
-          <MaxDatumSize>1</MaxDatumSize>\r
-          <Value>0x1f</Value>\r
-        </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugClearMemoryValue</C_Name>\r
-          <Token>0x00000008</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT8</DatumType>\r
-          <MaxDatumSize>1</MaxDatumSize>\r
-          <Value>0xAF</Value>\r
-        </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugPrintErrorLevel</C_Name>\r
-          <Token>0x00000006</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT32</DatumType>\r
-          <MaxDatumSize>4</MaxDatumSize>\r
-          <Value>0x80000000</Value>\r
-        </PcdData>\r
       </PcdBuildDefinition>\r
       <ModuleSaBuildOptions>\r
         <FvBinding>NULL</FvBinding>\r
         <Instance ModuleGuid="e6e9c1f8-2c8a-4f4b-a27c-c382e4bb8e67" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>\r
         <Instance ModuleGuid="b5a05743-9b71-489b-a0ed-a0eb3950d23b" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>\r
         <Instance ModuleGuid="E4541241-8897-411a-91F8-7D7E45837146" ModuleVersion="1.0" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" PackageVersion="0.3"/>\r
-        <Instance ModuleGuid="F3E4E221-D5CA-4dc9-8CB2-C5123C4827D5" ModuleVersion="1.0" PackageGuid="0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3" PackageVersion="0.3"/>\r
+        <!--Pkg: EdkNt32Pkg Mod: PeiNt32OemHookStatusCodeLib Path: EdkNt32Pkg\Library\PeiNt32OemHookStatusCodeLib\PeiNt32OemHookStatusCodeLib.msa-->\r
+        <Instance ModuleGuid="0C2070F9-02A7-4e8e-B584-84EA922363FB" ModuleVersion="1.0" PackageGuid="0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3" PackageVersion="0.3"/>\r
       </Libraries>\r
       <PcdBuildDefinition>\r
         <PcdData ItemType="FEATURE_FLAG">\r
           <MaxDatumSize>1</MaxDatumSize>\r
           <Value>0x06</Value>\r
         </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugPropertyMask</C_Name>\r
-          <Token>0x00000005</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT8</DatumType>\r
-          <MaxDatumSize>1</MaxDatumSize>\r
-          <Value>0x1f</Value>\r
-        </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugClearMemoryValue</C_Name>\r
-          <Token>0x00000008</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT8</DatumType>\r
-          <MaxDatumSize>1</MaxDatumSize>\r
-          <Value>0xAF</Value>\r
-        </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugPrintErrorLevel</C_Name>\r
-          <Token>0x00000006</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT32</DatumType>\r
-          <MaxDatumSize>4</MaxDatumSize>\r
-          <Value>0x80000000</Value>\r
-        </PcdData>\r
         <PcdData ItemType="FIXED_AT_BUILD">\r
           <C_Name>PcdMaximumUnicodeStringLength</C_Name>\r
           <Token>0x00000001</Token>\r
           <MaxDatumSize>4</MaxDatumSize>\r
           <Value>10000000</Value>\r
         </PcdData>\r
-        <PcdData ItemType="FEATURE_FLAG">\r
-          <C_Name>PcdNt32StatusCodeLibUseForPei</C_Name>\r
-          <Token>0x0000100b</Token>\r
-          <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>BOOLEAN</DatumType>\r
-          <MaxDatumSize>1</MaxDatumSize>\r
-          <Value>TRUE</Value>\r
-        </PcdData>\r
         <PcdData ItemType="FIXED_AT_BUILD">\r
           <C_Name>PcdFSBClock</C_Name>\r
           <Token>0x0000000c</Token>\r
         <Instance ModuleGuid="926c9cd0-4bb8-479b-9ac4-8a2a23f85307" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
         <Instance ModuleGuid="E4541241-8897-411a-91F8-7D7E45837146" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
         <Instance ModuleGuid="b1ee6c28-54aa-4d17-b705-3e28ccb27b2e" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
-        <Instance ModuleGuid="F3E4E221-D5CA-4dc9-8CB2-C5123C4827D5" PackageGuid="0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3"/>\r
-        <Instance ModuleGuid="1c747f6b-0a58-49ae-8ea3-0327a4fa10e3" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>\r
-        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>\r
         <!--Pkg: EdkNt32Pkg Mod: DxeWinNtLib Path: EdkNt32Pkg\Library\DxeWinNtLib\DxeWinNtLib.msa-->\r
         <Instance ModuleGuid="f6b5871d-5226-41b3-a569-3ff893fdc7bc" ModuleVersion="1.0" PackageGuid="0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3" PackageVersion="0.3"/>\r
         <!--Pkg: MdePkg Mod: UefiRuntimeServicesTableLib Path: MdePkg\Library\UefiRuntimeServicesTableLib\UefiRuntimeServicesTableLib.msa-->\r
         <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>\r
         <!--Pkg: MdePkg Mod: BaseTimerLibNullTemplate Path: MdePkg\Library\BaseTimerLibNullTemplate\BaseTimerLibNullTemplate.msa-->\r
         <Instance ModuleGuid="f4731d79-537e-4505-bd52-c03f9b1f6b89" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>\r
+        <!--Pkg: EdkNt32Pkg Mod: DxeNt32OemHookStatusCodeLib Path: EdkNt32Pkg\Library\DxeNt32OemHookStatusCodeLib\DxeNt32OemHookStatusCodeLib.msa-->\r
+        <Instance ModuleGuid="EF172A23-C7C5-47b7-B24E-D10DFE15540F" ModuleVersion="1.0" PackageGuid="0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3" PackageVersion="0.3"/>\r
       </Libraries>\r
       <PcdBuildDefinition>\r
         <PcdData ItemType="FEATURE_FLAG">\r
           <MaxDatumSize>1</MaxDatumSize>\r
           <Value>0x06</Value>\r
         </PcdData>\r
-        <PcdData ItemType="FEATURE_FLAG">\r
-          <C_Name>PcdNt32StatusCodeLibUseForPei</C_Name>\r
-          <Token>0x0000100b</Token>\r
-          <TokenSpaceGuidCName>gEfiEdkNt32PkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>BOOLEAN</DatumType>\r
-          <MaxDatumSize>1</MaxDatumSize>\r
-          <Value>FALSE</Value>\r
-        </PcdData>\r
       </PcdBuildDefinition>\r
       <ModuleSaBuildOptions>\r
         <FvBinding>FV_RECOVERY</FvBinding>\r
           <MaxDatumSize>1</MaxDatumSize>\r
           <Value>0x06</Value>\r
         </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugPropertyMask</C_Name>\r
-          <Token>0x00000005</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT8</DatumType>\r
-          <MaxDatumSize>1</MaxDatumSize>\r
-          <Value>0x1f</Value>\r
-        </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugClearMemoryValue</C_Name>\r
-          <Token>0x00000008</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT8</DatumType>\r
-          <MaxDatumSize>1</MaxDatumSize>\r
-          <Value>0xAF</Value>\r
-        </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugPrintErrorLevel</C_Name>\r
-          <Token>0x00000006</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT32</DatumType>\r
-          <MaxDatumSize>4</MaxDatumSize>\r
-          <Value>0x80000000</Value>\r
-        </PcdData>\r
       </PcdBuildDefinition>\r
       <ModuleSaBuildOptions>\r
         <FvBinding>FV_RECOVERY</FvBinding>\r
           <MaxDatumSize>4</MaxDatumSize>\r
           <Value>10000000</Value>\r
         </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugPropertyMask</C_Name>\r
-          <Token>0x00000005</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT8</DatumType>\r
-          <MaxDatumSize>1</MaxDatumSize>\r
-          <Value>0x1f</Value>\r
-        </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugClearMemoryValue</C_Name>\r
-          <Token>0x00000008</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT8</DatumType>\r
-          <MaxDatumSize>1</MaxDatumSize>\r
-          <Value>0xAF</Value>\r
-        </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugPrintErrorLevel</C_Name>\r
-          <Token>0x00000006</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT32</DatumType>\r
-          <MaxDatumSize>4</MaxDatumSize>\r
-          <Value>0x80000000</Value>\r
-        </PcdData>\r
       </PcdBuildDefinition>\r
       <ModuleSaBuildOptions>\r
         <FvBinding>FV_RECOVERY</FvBinding>\r
           <MaxDatumSize>4</MaxDatumSize>\r
           <Value>10000000</Value>\r
         </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugPropertyMask</C_Name>\r
-          <Token>0x00000005</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT8</DatumType>\r
-          <MaxDatumSize>1</MaxDatumSize>\r
-          <Value>0x0f</Value>\r
-        </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugClearMemoryValue</C_Name>\r
-          <Token>0x00000008</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT8</DatumType>\r
-          <MaxDatumSize>1</MaxDatumSize>\r
-          <Value>0xAF</Value>\r
-        </PcdData>\r
-        <PcdData ItemType="FIXED_AT_BUILD">\r
-          <C_Name>PcdDebugPrintErrorLevel</C_Name>\r
-          <Token>0x00000006</Token>\r
-          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
-          <DatumType>UINT32</DatumType>\r
-          <MaxDatumSize>4</MaxDatumSize>\r
-          <Value>0x80000000</Value>\r
-        </PcdData>\r
         <PcdData ItemType="FEATURE_FLAG">\r
           <C_Name>PcdComponentNameDisable</C_Name>\r
           <Token>0x0000000d</Token>\r