]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c
StdLib/LibC/StdLib/Malloc.c: Make the free() function conform to the ISO/IEC 9899...
[mirror_edk2.git] / EmulatorPkg / MiscSubClassPlatformDxe / MiscSystemSlotDesignationFunction.c
CommitLineData
949f388f 1/** @file\r
2 BIOS system slot designator information boot time changes.\r
3 SMBIOS type 9.\r
4\r
2bfd90f9 5 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
949f388f 6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
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
d18d8a1d 21 @param RecordData Pointer to copy of RecordData from the Data Table.\r
949f388f 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
d18d8a1d 50 case STR_MISC_SYSTEM_SLOT_DESIGNATION:\r
949f388f 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
d18d8a1d 62\r
949f388f 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
d18d8a1d 71 SmbiosRecord->Hdr.Handle = 0;\r
949f388f 72 SmbiosRecord->SlotDesignation = 1;\r
73 SmbiosRecord->SlotType = ForType9InputData->SlotType;\r
74 SmbiosRecord->SlotDataBusWidth = ForType9InputData->SlotDataBusWidth;\r
75 SmbiosRecord->CurrentUsage = ForType9InputData->SlotUsage;\r
76 SmbiosRecord->SlotLength = ForType9InputData->SlotLength;\r
77 SmbiosRecord->SlotID = ForType9InputData->SlotId;\r
d18d8a1d 78\r
949f388f 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
d18d8a1d 85 //\r
949f388f 86 // Now we have got the full smbios record, call smbios protocol to add this record.\r
87 //\r
2bfd90f9
SZ
88 Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);\r
89\r
949f388f 90 FreePool(SmbiosRecord);\r
91 return Status;\r
92}\r