]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmulatorPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / EmulatorPkg / MiscSubClassPlatformDxe / MiscSubclassDriverEntryPoint.c
index 065ab6fef8bf856491cc10415d731467c0fb2647..65fec01158866570105eac31fe11fe40adc3a22e 100644 (file)
@@ -1,6 +1,6 @@
 /*++\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
@@ -51,7 +51,7 @@ LogMemorySmbiosRecord (
 \r
   Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
   ASSERT_EFI_ERROR (Status);\r
-  \r
+\r
   NumSlots        = 1;\r
 \r
   //\r
@@ -63,7 +63,7 @@ LogMemorySmbiosRecord (
     TotalMemorySize += StrDecimalToUint64 (MemString);\r
     while (*MemString != '\0') {\r
       if (*MemString == '!') {\r
-        MemString++;       \r
+        MemString++;\r
         break;\r
       }\r
       MemString++;\r
@@ -77,21 +77,20 @@ LogMemorySmbiosRecord (
   //\r
   // Generate Memory Array Mapped Address info\r
   //\r
-  Type19Record = AllocatePool(sizeof (SMBIOS_TABLE_TYPE19));\r
-  ZeroMem(Type19Record, sizeof(SMBIOS_TABLE_TYPE19));\r
+  Type19Record = AllocateZeroPool(sizeof (SMBIOS_TABLE_TYPE19) + 2);\r
   Type19Record->Hdr.Type = EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS;\r
   Type19Record->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE19);\r
   Type19Record->Hdr.Handle = 0;\r
   Type19Record->StartingAddress = 0;\r
   Type19Record->EndingAddress =  (UINT32)RShiftU64(TotalMemorySize, 10) - 1;\r
   Type19Record->MemoryArrayHandle = 0;\r
-  Type19Record->PartitionWidth = (UINT8)(NumSlots); \r
+  Type19Record->PartitionWidth = (UINT8)(NumSlots);\r
 \r
   //\r
   // Generate Memory Array Mapped Address info (TYPE 19)\r
   //\r
-  MemArrayMappedAddrSmbiosHandle = 0;\r
-  Status = Smbios->Add (Smbios, NULL, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record);\r
+  Status = AddSmbiosRecord (Smbios, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record);\r
+\r
   FreePool(Type19Record);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
@@ -128,7 +127,7 @@ Returns:
 {\r
   UINTN                Index;\r
   EFI_STATUS           EfiStatus;\r
-  EFI_SMBIOS_PROTOCOL  *Smbios;  \r
+  EFI_SMBIOS_PROTOCOL  *Smbios;\r
 \r
   EfiStatus = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
 \r
@@ -168,3 +167,34 @@ Returns:
   EfiStatus = LogMemorySmbiosRecord();\r
   return EfiStatus;\r
 }\r
+\r
+/**\r
+  Add an SMBIOS record.\r
+\r
+  @param  Smbios                The EFI_SMBIOS_PROTOCOL instance.\r
+  @param  SmbiosHandle          A unique handle will be assigned to the SMBIOS record.\r
+  @param  Record                The data for the fixed portion of the SMBIOS record. The format of the record is\r
+                                determined by EFI_SMBIOS_TABLE_HEADER.Type. The size of the formatted area is defined \r
+                                by EFI_SMBIOS_TABLE_HEADER.Length and either followed by a double-null (0x0000) or \r
+                                a set of null terminated strings and a null.\r
+\r
+  @retval EFI_SUCCESS           Record was added.\r
+  @retval EFI_OUT_OF_RESOURCES  Record was not added due to lack of system resources.\r
+\r
+**/\r
+EFI_STATUS\r
+AddSmbiosRecord (\r
+  IN EFI_SMBIOS_PROTOCOL        *Smbios,\r
+  OUT EFI_SMBIOS_HANDLE         *SmbiosHandle,\r
+  IN EFI_SMBIOS_TABLE_HEADER    *Record\r
+  )\r
+{\r
+  *SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
+  return Smbios->Add (\r
+                   Smbios,\r
+                   NULL,\r
+                   SmbiosHandle,\r
+                   Record\r
+                   );\r
+}\r
+\r