]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscSystemSlotDesignationFunction.c
CommitLineData
5e973c96 1/** @file\r
1fdd39d3 2 BIOS system slot designator information boot time changes.\r
3 SMBIOS type 9.\r
5e973c96 4 \r
7ee85aa2 5Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
8f2a5f80 6This program and the accompanying materials\r
5e973c96 7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
1fdd39d3 10\r
5e973c96 11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
1fdd39d3 15\r
16#include "MiscSubclassDriver.h"\r
17/**\r
18 This function makes boot time changes to the contents of the\r
19 MiscSystemSlotDesignator structure (Type 9).\r
20\r
21 @param RecordData Pointer to copy of RecordData from the Data Table. \r
22\r
23 @retval EFI_SUCCESS All parameters were valid.\r
24 @retval EFI_UNSUPPORTED Unexpected RecordType value.\r
25 @retval EFI_INVALID_PARAMETER Invalid parameter was found.\r
26\r
27**/\r
28MISC_SMBIOS_TABLE_FUNCTION(MiscSystemSlotDesignation)\r
29{\r
30 CHAR8 *OptionalStrStart;\r
31 UINTN SlotDesignationStrLen;\r
32 EFI_STATUS Status;\r
33 EFI_STRING SlotDesignation;\r
34 STRING_REF TokenToGet;\r
35 SMBIOS_TABLE_TYPE9 *SmbiosRecord;\r
36 EFI_SMBIOS_HANDLE SmbiosHandle;\r
37 EFI_MISC_SYSTEM_SLOT_DESIGNATION* ForType9InputData;\r
38\r
39 ForType9InputData = (EFI_MISC_SYSTEM_SLOT_DESIGNATION *)RecordData;\r
40\r
41 //\r
42 // First check for invalid parameters.\r
43 //\r
44 if (RecordData == NULL) {\r
45 return EFI_INVALID_PARAMETER;\r
46 }\r
47\r
48 TokenToGet = 0;\r
49 switch (ForType9InputData->SlotDesignation) {\r
50 case STR_MISC_SYSTEM_SLOT_DESIGNATION: \r
51 TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_DESIGNATION);\r
52 break;\r
53 default:\r
54 break;\r
55 }\r
56\r
57 SlotDesignation = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
58 SlotDesignationStrLen = StrLen(SlotDesignation);\r
59 if (SlotDesignationStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
60 return EFI_UNSUPPORTED;\r
61 }\r
62 \r
63 //\r
64 // Two zeros following the last string.\r
65 //\r
66 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE9) + SlotDesignationStrLen + 1 + 1);\r
67 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE9) +SlotDesignationStrLen + 1 + 1);\r
68\r
69 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_SLOTS;\r
70 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE9);\r
71 SmbiosRecord->Hdr.Handle = 0; \r
72 SmbiosRecord->SlotDesignation = 1;\r
5b368e7d 73 SmbiosRecord->SlotType = (UINT8)ForType9InputData->SlotType;\r
74 SmbiosRecord->SlotDataBusWidth = (UINT8)ForType9InputData->SlotDataBusWidth;\r
75 SmbiosRecord->CurrentUsage = (UINT8)ForType9InputData->SlotUsage;\r
76 SmbiosRecord->SlotLength = (UINT8)ForType9InputData->SlotLength;\r
1fdd39d3 77 SmbiosRecord->SlotID = ForType9InputData->SlotId;\r
78 \r
79 //\r
80 // Slot Characteristics\r
81 //\r
82 CopyMem ((UINT8 *) &SmbiosRecord->SlotCharacteristics1,(UINT8 *) &ForType9InputData->SlotCharacteristics,2);\r
83 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
84 UnicodeStrToAsciiStr(SlotDesignation, OptionalStrStart);\r
85 // \r
86 // Now we have got the full smbios record, call smbios protocol to add this record.\r
87 //\r
7ee85aa2
SZ
88 Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);\r
89\r
1fdd39d3 90 FreePool(SmbiosRecord);\r
91 return Status;\r
92}\r