]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1) Initialize gBS, gST, gImageHandle in UefiBootServicesTableLib.c to NULL
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Apr 2007 06:36:47 +0000 (06:36 +0000)
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Apr 2007 06:36:47 +0000 (06:36 +0000)
2) Add DxeCore infix to the module local variable gBS, gST, gRT, gDS in DxeMain.c. This is to solve the name conflict with UefiBootServicesTableLib which is defined in MDE Library Spec.
3) Add in check for gBS and gST in UefiDebugLibConOut/DebugLib.c and UefiDebugLibStdErr/DebugLib.c and MdePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c. If they are not initialized, the API will just return with a error message.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2546 6f19259b-4bc3-4df7-8a09-765794883524

EdkModulePkg/Core/Dxe/DxeMain.h
EdkModulePkg/Core/Dxe/DxeMain/DxeMain.c
EdkModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c
EdkModulePkg/Core/Dxe/Hand/handle.c
EdkModulePkg/Core/Dxe/Image/Image.c
EdkModulePkg/Core/Dxe/Misc/DebugImageInfo.c
EdkModulePkg/Core/Dxe/Misc/InstallConfigurationTable.c
MdePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c
MdePkg/Library/UefiDebugLibConOut/DebugLib.c
MdePkg/Library/UefiDebugLibStdErr/DebugLib.c

index d655cd338183bee7c8592e4f595128be2ccae7a4..b4cd76a2a1b25805b407148bfb5c415c605c76c4 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2007, 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
@@ -116,10 +116,10 @@ typedef struct {
 //\r
 // DXE Core Global Variables\r
 //\r
-extern EFI_SYSTEM_TABLE                         *gST;\r
-extern EFI_BOOT_SERVICES                        *gBS;\r
-extern EFI_RUNTIME_SERVICES                     *gRT;\r
-extern EFI_DXE_SERVICES                         *gDS;\r
+extern EFI_SYSTEM_TABLE                         *gDxeCoreST;\r
+extern EFI_BOOT_SERVICES                        *gDxeCoreBS;\r
+extern EFI_RUNTIME_SERVICES                     *gDxeCoreRT;\r
+extern EFI_DXE_SERVICES                         *gDxeCoreDS;\r
 extern EFI_HANDLE                               gDxeCoreImageHandle;\r
 \r
 extern EFI_DECOMPRESS_PROTOCOL                  gEfiDecompress;\r
index 427e6b8ca50a005811afc880826d6e80707e1f57..1e31a8899e753e33737722b7bb73f49a805af4e7 100644 (file)
@@ -211,16 +211,16 @@ EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = &gRuntimeTemplate;
 // DXE Core Global Variables for the EFI System Table, Boot Services Table,\r
 // DXE Services Table, and Runtime Services Table\r
 //\r
-EFI_BOOT_SERVICES     *gBS = &mBootServices;\r
-EFI_DXE_SERVICES      *gDS = &mDxeServices;\r
-EFI_SYSTEM_TABLE      *gST = NULL;\r
+EFI_BOOT_SERVICES     *gDxeCoreBS = &mBootServices;\r
+EFI_DXE_SERVICES      *gDxeCoreDS = &mDxeServices;\r
+EFI_SYSTEM_TABLE      *gDxeCoreST = NULL;\r
 \r
 //\r
-// For debug initialize gRT to template. gRT must be allocated from RT memory\r
-//  but gRT is used for ASSERT () and DEBUG () type macros so lets give it\r
+// For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory\r
+//  but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it\r
 //  a value that will not cause debug infrastructure to crash early on.\r
 //\r
-EFI_RUNTIME_SERVICES  *gRT = &mEfiRuntimeServicesTableTemplate;\r
+EFI_RUNTIME_SERVICES  *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate;\r
 EFI_HANDLE            gDxeCoreImageHandle = NULL;\r
 \r
 VOID  *mHobStart;\r
@@ -288,13 +288,13 @@ Returns:
   // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData\r
   // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table\r
   //\r
-  gST = CoreAllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);\r
-  ASSERT (gST != NULL);\r
+  gDxeCoreST = CoreAllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);\r
+  ASSERT (gDxeCoreST != NULL);\r
 \r
-  gRT = CoreAllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);\r
-  ASSERT (gRT != NULL);\r
+  gDxeCoreRT = CoreAllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);\r
+  ASSERT (gDxeCoreRT != NULL);\r
 \r
-  gST->RuntimeServices = gRT;\r
+  gDxeCoreST->RuntimeServices = gDxeCoreRT;\r
 \r
   //\r
   // Start the Image Services.\r
@@ -305,7 +305,7 @@ Returns:
   //\r
   // Call constructor for all libraries\r
   //\r
-  ProcessLibraryConstructorList (gDxeCoreImageHandle, gST);\r
+  ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST);\r
   PERF_END   (0,PEI_TOK, NULL, 0) ;\r
   PERF_START (0,DXE_TOK, NULL, 0) ;\r
 \r
@@ -318,7 +318,7 @@ Returns:
   //\r
   // Install the DXE Services Table into the EFI System Tables's Configuration Table\r
   //\r
-  Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDS);\r
+  Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDxeCoreDS);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
@@ -400,16 +400,16 @@ Returns:
   //\r
   // Produce Firmware Volume Protocols, one for each FV in the HOB list.\r
   //\r
-  Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gST);\r
+  Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gDxeCoreST);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  Status = FwVolDriverInit (gDxeCoreImageHandle, gST);\r
+  Status = FwVolDriverInit (gDxeCoreImageHandle, gDxeCoreST);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
   // Produce the Section Extraction Protocol\r
   //\r
-  Status = InitializeSectionExtraction (gDxeCoreImageHandle, gST);\r
+  Status = InitializeSectionExtraction (gDxeCoreImageHandle, gDxeCoreST);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
@@ -742,11 +742,11 @@ Returns:
   Hdr->CRC32 = 0;\r
 \r
   //\r
-  // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then\r
+  // If gDxeCoreBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then\r
   //  Crc will come back as zero if we set it to zero here\r
   //\r
   Crc = 0;\r
-  gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc);\r
+  gDxeCoreBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc);\r
   Hdr->CRC32 = Crc;\r
 }\r
 \r
@@ -812,24 +812,24 @@ Returns:
   //\r
   // Clear the non-runtime values of the EFI System Table\r
   //\r
-  gST->BootServices        = NULL;\r
-  gST->ConIn               = NULL;\r
-  gST->ConsoleInHandle     = NULL;\r
-  gST->ConOut              = NULL;\r
-  gST->ConsoleOutHandle    = NULL;\r
-  gST->StdErr              = NULL;\r
-  gST->StandardErrorHandle = NULL;\r
+  gDxeCoreST->BootServices        = NULL;\r
+  gDxeCoreST->ConIn               = NULL;\r
+  gDxeCoreST->ConsoleInHandle     = NULL;\r
+  gDxeCoreST->ConOut              = NULL;\r
+  gDxeCoreST->ConsoleOutHandle    = NULL;\r
+  gDxeCoreST->StdErr              = NULL;\r
+  gDxeCoreST->StandardErrorHandle = NULL;\r
 \r
   //\r
   // Recompute the 32-bit CRC of the EFI System Table\r
   //\r
-  CalculateEfiHdrCrc (&gST->Hdr);\r
+  CalculateEfiHdrCrc (&gDxeCoreST->Hdr);\r
 \r
   //\r
   // Zero out the Boot Service Table\r
   //\r
-  SetMem (gBS, sizeof (EFI_BOOT_SERVICES), 0);\r
-  gBS = NULL;\r
+  SetMem (gDxeCoreBS, sizeof (EFI_BOOT_SERVICES), 0);\r
+  gDxeCoreBS = NULL;\r
 \r
   //\r
   // Update the AtRuntime field in Runtiem AP.\r
index 24ccc49a9b8c412fd6dd7ac5d1f396bd210724bb..8f389d02b49ce73738159129b6fe6f61ff21c39c 100644 (file)
@@ -181,10 +181,10 @@ Returns:
   // It's over kill to do them all every time, but it saves a lot of code.\r
   //\r
   if (Found) {\r
-    CalculateEfiHdrCrc (&gRT->Hdr);\r
-    CalculateEfiHdrCrc (&gBS->Hdr);\r
-    CalculateEfiHdrCrc (&gST->Hdr);\r
-    CalculateEfiHdrCrc (&gDS->Hdr);\r
+    CalculateEfiHdrCrc (&gDxeCoreRT->Hdr);\r
+    CalculateEfiHdrCrc (&gDxeCoreBS->Hdr);\r
+    CalculateEfiHdrCrc (&gDxeCoreST->Hdr);\r
+    CalculateEfiHdrCrc (&gDxeCoreDS->Hdr);\r
   }\r
 }\r
 \r
index 2f43dc02b10049ca102e5c4af76352ce6e27beb0..dd0801a96f85658fdc8649f264ff331f5d9fd530 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2007, 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
@@ -455,7 +455,7 @@ Returns:
   Prot = NULL;\r
   Handle = NULL;\r
 \r
-  ASSERT (NULL != gBS);\r
+  ASSERT (NULL != gDxeCoreBS);\r
 \r
   if (*UserHandle != NULL_HANDLE) {\r
     Status = CoreHandleProtocol (*UserHandle, Protocol, (VOID **)&ExistingInterface);\r
index 3696400072e6f6be71090466699a6ef877228256..901182e5113b250452275973dbbb1e189d29c727 100644 (file)
@@ -132,7 +132,7 @@ Returns:
   Image->ImageBasePage      = DxeCoreImageBaseAddress;\r
   Image->NumberOfPages      = (UINTN)(EFI_SIZE_TO_PAGES((UINTN)(DxeCoreImageLength)));\r
   Image->Tpl                = gEfiCurrentTpl;\r
-  Image->Info.SystemTable   = gST;\r
+  Image->Info.SystemTable   = gDxeCoreST;\r
   Image->Info.ImageBase     = (VOID *)(UINTN)DxeCoreImageBaseAddress;\r
   Image->Info.ImageSize     = DxeCoreImageLength;\r
 \r
@@ -650,7 +650,7 @@ Returns:
   // Initialize the fields for an internal driver\r
   //\r
   Image->Signature         = LOADED_IMAGE_PRIVATE_DATA_SIGNATURE;\r
-  Image->Info.SystemTable  = gST;\r
+  Image->Info.SystemTable  = gDxeCoreST;\r
   Image->Info.DeviceHandle = DeviceHandle;\r
   Image->Info.Revision     = EFI_LOADED_IMAGE_INFORMATION_REVISION;\r
   Image->Info.FilePath     = CoreDuplicateDevicePath (FilePath);\r
index 3ba1eca41895508768701aaf47186414f6dc16a4..3512477c8f83eb88e53724e060d3d8bf071651b4 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2007, 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
@@ -97,7 +97,7 @@ Notes:
   //\r
   mDebugTable = (EFI_SYSTEM_TABLE_POINTER *)(UINTN)Mem;\r
   mDebugTable->Signature = EFI_SYSTEM_TABLE_SIGNATURE;\r
-  mDebugTable->EfiSystemTableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) gST;\r
+  mDebugTable->EfiSystemTableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) gDxeCoreST;\r
   mDebugTable->Crc32 = 0;\r
   Status = CoreInstallConfigurationTable (&gEfiDebugImageInfoTableGuid, &mDebugInfoTableHeader);\r
   ASSERT_EFI_ERROR (Status);\r
@@ -127,7 +127,7 @@ Returns:
 {\r
   ASSERT(mDebugTable != NULL);\r
   mDebugTable->Crc32 = 0;\r
-  gBS->CalculateCrc32 ((VOID *)mDebugTable, sizeof (EFI_SYSTEM_TABLE_POINTER), &mDebugTable->Crc32);\r
+  gDxeCoreBS->CalculateCrc32 ((VOID *)mDebugTable, sizeof (EFI_SYSTEM_TABLE_POINTER), &mDebugTable->Crc32);\r
 }\r
 \r
 VOID\r
index e81fcad35ae275ca54c5fee23425ea7557ba9bc1..ee42f224e85dd15842fdbb1309bb9b99a3888b0f 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2007, 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
@@ -54,9 +54,9 @@ Returns:
 {\r
   UINTN Index;\r
 \r
-  for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {\r
-    if (CompareGuid (Guid, &(gST->ConfigurationTable[Index].VendorGuid))) {\r
-      *Table = gST->ConfigurationTable[Index].VendorTable;\r
+  for (Index = 0; Index < gDxeCoreST->NumberOfTableEntries; Index++) {\r
+    if (CompareGuid (Guid, &(gDxeCoreST->ConfigurationTable[Index].VendorGuid))) {\r
+      *Table = gDxeCoreST->ConfigurationTable[Index].VendorTable;\r
       return EFI_SUCCESS;\r
     }\r
   }\r
@@ -104,18 +104,18 @@ Returns:
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  EfiConfigurationTable = gST->ConfigurationTable;\r
+  EfiConfigurationTable = gDxeCoreST->ConfigurationTable;\r
 \r
   //\r
   // Search all the table for an entry that matches Guid\r
   //\r
-  for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {\r
-    if (CompareGuid (Guid, &(gST->ConfigurationTable[Index].VendorGuid))) {\r
+  for (Index = 0; Index < gDxeCoreST->NumberOfTableEntries; Index++) {\r
+    if (CompareGuid (Guid, &(gDxeCoreST->ConfigurationTable[Index].VendorGuid))) {\r
       break;\r
     }\r
   }\r
 \r
-  if (Index < gST->NumberOfTableEntries) {\r
+  if (Index < gDxeCoreST->NumberOfTableEntries) {\r
     //\r
     // A match was found, so this is either a modify or a delete operation\r
     //\r
@@ -124,22 +124,22 @@ Returns:
       // If Table is not NULL, then this is a modify operation.\r
       // Modify the table enty and return.\r
       //\r
-      gST->ConfigurationTable[Index].VendorTable = Table;\r
+      gDxeCoreST->ConfigurationTable[Index].VendorTable = Table;\r
       return EFI_SUCCESS;\r
     }\r
 \r
     //\r
     // A match was found and Table is NULL, so this is a delete operation.\r
     //\r
-    gST->NumberOfTableEntries--;\r
+    gDxeCoreST->NumberOfTableEntries--;\r
 \r
     //\r
     // Copy over deleted entry\r
     //\r
     CopyMem (\r
       &(EfiConfigurationTable[Index]),\r
-      &(gST->ConfigurationTable[Index + 1]),\r
-      (gST->NumberOfTableEntries - Index) * sizeof (EFI_CONFIGURATION_TABLE)\r
+      &(gDxeCoreST->ConfigurationTable[Index + 1]),\r
+      (gDxeCoreST->NumberOfTableEntries - Index) * sizeof (EFI_CONFIGURATION_TABLE)\r
       );\r
 \r
   } else {\r
@@ -156,7 +156,7 @@ Returns:
     }\r
 \r
     //\r
-    // Assume that Index == gST->NumberOfTableEntries\r
+    // Assume that Index == gDxeCoreST->NumberOfTableEntries\r
     //\r
     if ((Index * sizeof (EFI_CONFIGURATION_TABLE)) >= mSystemTableAllocateSize) {\r
       //\r
@@ -171,26 +171,26 @@ Returns:
         return EFI_OUT_OF_RESOURCES;\r
       }\r
 \r
-      if (gST->ConfigurationTable != NULL) {\r
+      if (gDxeCoreST->ConfigurationTable != NULL) {\r
         //\r
         // Copy the old table to the new table.\r
         //\r
         CopyMem (\r
           EfiConfigurationTable,\r
-          gST->ConfigurationTable,\r
+          gDxeCoreST->ConfigurationTable,\r
           Index * sizeof (EFI_CONFIGURATION_TABLE)\r
           );\r
 \r
         //\r
         // Free Old Table\r
         //\r
-        CoreFreePool (gST->ConfigurationTable);\r
+        CoreFreePool (gDxeCoreST->ConfigurationTable);\r
       }\r
 \r
       //\r
       // Update System Table\r
       //\r
-      gST->ConfigurationTable = EfiConfigurationTable;\r
+      gDxeCoreST->ConfigurationTable = EfiConfigurationTable;\r
     }\r
 \r
     //\r
@@ -202,13 +202,13 @@ Returns:
     //\r
     // This is an add operation, so increment the number of table entries\r
     //\r
-    gST->NumberOfTableEntries++;\r
+    gDxeCoreST->NumberOfTableEntries++;\r
   }\r
 \r
   //\r
   // Fix up the CRC-32 in the EFI System Table\r
   //\r
-  CalculateEfiHdrCrc (&gST->Hdr);\r
+  CalculateEfiHdrCrc (&gDxeCoreST->Hdr);\r
 \r
   return EFI_SUCCESS;\r
 }\r
index 4e140c61c85a7cb6c85f1123c79e5dfd5faf91c4..28649f72cc3b126f8d433edea2c07414cdbedc6b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Report Status Code Library for DXE Phase.\r
 \r
-  Copyright (c) 2006, Intel Corporation<BR>\r
+  Copyright (c) 2006 - 2007, Intel Corporation<BR>\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
@@ -57,6 +57,9 @@ InternalReportStatusCode (
   // in the handle database.\r
   //\r
   if (gStatusCode == NULL) {\r
+    if (gBS == NULL) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
     Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
     if (EFI_ERROR (Status) || gStatusCode == NULL) {\r
       return EFI_UNSUPPORTED;\r
@@ -476,6 +479,10 @@ ReportStatusCodeEx (
   ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
   ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
 \r
+  if (gBS == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
   //\r
   // Allocate space for the Status Code Header and its buffer\r
   //\r
index 0db4707e292ffb56ce3e98ac50df5a827038f619..26f62f6c953220601d28e933a843f7eaa9aad7b3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Boot Services Table Library.\r
 \r
-  Copyright (c) 2006, Intel Corporation<BR>\r
+  Copyright (c) 2006 - 2007, Intel Corporation<BR>\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
@@ -14,9 +14,9 @@
 \r
 **/\r
 \r
-EFI_HANDLE         gImageHandle;\r
-EFI_SYSTEM_TABLE   *gST;\r
-EFI_BOOT_SERVICES  *gBS;\r
+EFI_HANDLE         gImageHandle = NULL;\r
+EFI_SYSTEM_TABLE   *gST         = NULL;\r
+EFI_BOOT_SERVICES  *gBS         = NULL;\r
 \r
 /**\r
   The constructor function caches the pointer of Boot Services Table.\r
@@ -43,6 +43,7 @@ UefiBootServicesTableLibConstructor (
   // Cache the Image Handle\r
   //\r
   gImageHandle = ImageHandle;\r
+  ASSERT (gImageHandle != NULL);\r
 \r
   //\r
   // Cache pointer to the EFI System Table\r
index 3fe3b6e043f4d2cd1c468fb6979573223355011e..b3e83894c8ab9c4bdb78fe323432cdd37c1f74a1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Debug Library that uses PrintLib to send messages to CONOUT.\r
 \r
-  Copyright (c) 2006, Intel Corporation<BR>\r
+  Copyright (c) 2006 - 2007, Intel Corporation<BR>\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
@@ -65,7 +65,7 @@ DebugPrint (
   //\r
   // Send the print string to the Console Output device\r
   //\r
-  if (gST->ConOut != NULL) {\r
+  if ((gST != NULL) && (gST->ConOut != NULL)) {\r
     gST->ConOut->OutputString (gST->ConOut, Buffer);\r
   }\r
 }\r
@@ -112,7 +112,7 @@ DebugAssert (
   //\r
   // Send the print string to the Console Output device\r
   //\r
-  if (gST->ConOut != NULL) {\r
+  if ((gST != NULL) && (gST->ConOut != NULL)) {\r
     gST->ConOut->OutputString (gST->ConOut, Buffer);\r
   }\r
 \r
index 9338217762a6becc9f9e1b68db1b6635f70c6eea..d2fb46e23f340f2aec64b6dce50101c391f138f0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Debug Library that uses PrintLib to send messages to STDERR.\r
 \r
-  Copyright (c) 2006, Intel Corporation<BR>\r
+  Copyright (c) 2006 - 2007, Intel Corporation<BR>\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
@@ -65,7 +65,7 @@ DebugPrint (
   //\r
   // Send the print string to the Standard Error device\r
   //\r
-  if (gST->StdErr != NULL) {\r
+  if ((gST != NULL) && (gST->StdErr != NULL)) {\r
     gST->StdErr->OutputString (gST->StdErr, Buffer);\r
   }\r
 }\r
@@ -112,7 +112,7 @@ DebugAssert (
   //\r
   // Send the print string to the Standard Error device\r
   //\r
-  if (gST->StdErr != NULL) {\r
+  if ((gST != NULL) && (gST->StdErr != NULL)) {\r
     gST->StdErr->OutputString (gST->StdErr, Buffer);\r
   }\r
 \r