]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c
1. PI SMBIOS Checkin. Major change include:
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscSystemSlotDesignationFunction.c
diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c
new file mode 100644 (file)
index 0000000..c42b9d2
--- /dev/null
@@ -0,0 +1,105 @@
+/*++\r
+\r
+Copyright (c) 2009, Intel Corporation. All rights reserved. <BR> \r
+This software and associated documentation (if any) is furnished\r
+under a license and may only be used or copied in accordance\r
+with the terms of the license. Except as permitted by such\r
+license, no part of this software or documentation may be\r
+reproduced, stored in a retrieval system, or transmitted in any\r
+form or by any means without the express written consent of\r
+Intel Corporation.\r
+\r
+\r
+Module Name:\r
+\r
+  MiscSystemSlotDesignatorFunction.c\r
+  \r
+Abstract: \r
+\r
+  BIOS system slot designator information boot time changes.\r
+  SMBIOS type 9.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+/**\r
+  This function makes boot time changes to the contents of the\r
+  MiscSystemSlotDesignator structure (Type 9).\r
+\r
+  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
+\r
+  @retval EFI_SUCCESS                All parameters were valid.\r
+  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
+  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
+\r
+**/\r
+MISC_SMBIOS_TABLE_FUNCTION(MiscSystemSlotDesignation)\r
+{\r
+  CHAR8                              *OptionalStrStart;\r
+  UINTN                              SlotDesignationStrLen;\r
+  EFI_STATUS                         Status;\r
+  EFI_STRING                         SlotDesignation;\r
+  STRING_REF                         TokenToGet;\r
+  SMBIOS_TABLE_TYPE9                 *SmbiosRecord;\r
+  EFI_SMBIOS_HANDLE                  SmbiosHandle;\r
+  EFI_MISC_SYSTEM_SLOT_DESIGNATION*  ForType9InputData;\r
+\r
+  ForType9InputData = (EFI_MISC_SYSTEM_SLOT_DESIGNATION *)RecordData;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  TokenToGet = 0;\r
+  switch (ForType9InputData->SlotDesignation) {\r
+    case STR_MISC_SYSTEM_SLOT_DESIGNATION: \r
+      TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_DESIGNATION);\r
+      break;\r
+    default:\r
+      break;\r
+  }\r
+\r
+  SlotDesignation = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  SlotDesignationStrLen = StrLen(SlotDesignation);\r
+  if (SlotDesignationStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE9) + SlotDesignationStrLen + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE9) +SlotDesignationStrLen + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_SLOTS;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE9);\r
+  SmbiosRecord->Hdr.Handle = 0; \r
+  SmbiosRecord->SlotDesignation = 1;\r
+  SmbiosRecord->SlotType = ForType9InputData->SlotType;\r
+  SmbiosRecord->SlotDataBusWidth = ForType9InputData->SlotDataBusWidth;\r
+  SmbiosRecord->CurrentUsage = ForType9InputData->SlotUsage;\r
+  SmbiosRecord->SlotLength = ForType9InputData->SlotLength;\r
+  SmbiosRecord->SlotID = ForType9InputData->SlotId;\r
+  \r
+  //\r
+  // Slot Characteristics\r
+  //\r
+  CopyMem ((UINT8 *) &SmbiosRecord->SlotCharacteristics1,(UINT8 *) &ForType9InputData->SlotCharacteristics,2);\r
+  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+  UnicodeStrToAsciiStr(SlotDesignation, OptionalStrStart);\r
+  //  \r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r