]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
MdeModulePkg: INF/DEC file updates to EDK II packages
[mirror_edk2.git] / MdeModulePkg / Library / RuntimeDxeReportStatusCodeLib / ReportStatusCodeLib.c
index cbfd8247b91b81df395b317a3195efe19b1b6e79..e533af3d338cca32aa0cfbe43e1b5a23b87561f8 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   API implementation for instance of Report Status Code Library.\r
 \r
-  Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
   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
 #include <Guid/StatusCodeDataTypeDebug.h>\r
 #include <Guid/EventGroup.h>\r
 \r
+\r
+//\r
+// Define the maximum extended data size that is supported when a status code is reported.\r
+//\r
+#define MAX_EXTENDED_DATA_SIZE  0x200\r
+\r
 EFI_STATUS_CODE_PROTOCOL  *mReportStatusCodeLibStatusCodeProtocol = NULL;\r
 EFI_EVENT                 mReportStatusCodeLibVirtualAddressChangeEvent;\r
+EFI_EVENT                 mReportStatusCodeLibExitBootServicesEvent;\r
+BOOLEAN                   mHaveExitedBootServices = FALSE;\r
 \r
 /**\r
   Locate the report status code service.\r
@@ -47,7 +55,7 @@ InternalGetReportStatusCode (
     return;\r
   }\r
   \r
-  if (EfiAtRuntime ()) {\r
+  if (mHaveExitedBootServices) {\r
     return;\r
   }\r
   \r
@@ -82,6 +90,28 @@ ReportStatusCodeLibVirtualAddressChange (
   EfiConvertPointer (0, (VOID **) &mReportStatusCodeLibStatusCodeProtocol);\r
 }\r
 \r
+/**\r
+  Notification function of EVT_SIGNAL_EXIT_BOOT_SERVICES.\r
+\r
+  @param  Event        Event whose notification function is being invoked.\r
+  @param  Context      Pointer to the notification function's context\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ReportStatusCodeLibExitBootServices (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  //\r
+  // Locate the report status code service before enter runtime.\r
+  // \r
+  InternalGetReportStatusCode ();\r
+  \r
+  mHaveExitedBootServices = TRUE;\r
+}\r
+\r
 /**\r
   The constructor function of Runtime DXE Report Status Code Lib.\r
 \r
@@ -121,6 +151,19 @@ ReportStatusCodeLibConstructor (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  //\r
+  // Register notify function for EVT_SIGNAL_EXIT_BOOT_SERVICES\r
+  // \r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
+                  ReportStatusCodeLibExitBootServices,\r
+                  NULL,\r
+                  &gEfiEventExitBootServicesGuid,\r
+                  &mReportStatusCodeLibExitBootServicesEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -149,6 +192,9 @@ ReportStatusCodeLibDestructor (
   Status = gBS->CloseEvent (mReportStatusCodeLibVirtualAddressChangeEvent);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  Status = gBS->CloseEvent (mReportStatusCodeLibExitBootServicesEvent);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -581,13 +627,13 @@ ReportStatusCodeEx (
 {\r
   EFI_STATUS            Status;\r
   EFI_STATUS_CODE_DATA  *StatusCodeData;\r
-  UINT8                 StatusCodeBuffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+  UINT64                StatusCodeBuffer[(MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)) + 1];\r
 \r
   ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
   ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
 \r
-  if (EfiAtRuntime ()) {\r
-    if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > EFI_STATUS_CODE_DATA_MAX_SIZE) {\r
+  if (mHaveExitedBootServices) {\r
+    if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > MAX_EXTENDED_DATA_SIZE) {\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
     StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer;\r
@@ -634,7 +680,7 @@ ReportStatusCodeEx (
   //\r
   // Free the allocated buffer\r
   //\r
-  if (!EfiAtRuntime()) {\r
+  if (!mHaveExitedBootServices) {\r
     gBS->FreePool (StatusCodeData);\r
   }\r
 \r