]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c
EmulatorPkg: Replace BSD License with BSD+Patent License
[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
e3ba31da 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
949f388f 7\r
8**/\r
9\r
10#include "MiscSubClassDriver.h"\r
11/**\r
12 This function makes boot time changes to the contents of the\r
13 MiscSystemSlotDesignator structure (Type 9).\r
14\r
d18d8a1d 15 @param RecordData Pointer to copy of RecordData from the Data Table.\r
949f388f 16\r
17 @retval EFI_SUCCESS All parameters were valid.\r
18 @retval EFI_UNSUPPORTED Unexpected RecordType value.\r
19 @retval EFI_INVALID_PARAMETER Invalid parameter was found.\r
20\r
21**/\r
22MISC_SMBIOS_TABLE_FUNCTION(MiscSystemSlotDesignation)\r
23{\r
24 CHAR8 *OptionalStrStart;\r
25 UINTN SlotDesignationStrLen;\r
26 EFI_STATUS Status;\r
27 EFI_STRING SlotDesignation;\r
28 STRING_REF TokenToGet;\r
29 SMBIOS_TABLE_TYPE9 *SmbiosRecord;\r
30 EFI_SMBIOS_HANDLE SmbiosHandle;\r
31 EFI_MISC_SYSTEM_SLOT_DESIGNATION* ForType9InputData;\r
32\r
33 ForType9InputData = (EFI_MISC_SYSTEM_SLOT_DESIGNATION *)RecordData;\r
34\r
35 //\r
36 // First check for invalid parameters.\r
37 //\r
38 if (RecordData == NULL) {\r
39 return EFI_INVALID_PARAMETER;\r
40 }\r
41\r
42 TokenToGet = 0;\r
43 switch (ForType9InputData->SlotDesignation) {\r
d18d8a1d 44 case STR_MISC_SYSTEM_SLOT_DESIGNATION:\r
949f388f 45 TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_DESIGNATION);\r
46 break;\r
47 default:\r
48 break;\r
49 }\r
50\r
51 SlotDesignation = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
52 SlotDesignationStrLen = StrLen(SlotDesignation);\r
53 if (SlotDesignationStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
54 return EFI_UNSUPPORTED;\r
55 }\r
d18d8a1d 56\r
949f388f 57 //\r
58 // Two zeros following the last string.\r
59 //\r
60 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE9) + SlotDesignationStrLen + 1 + 1);\r
61 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE9) +SlotDesignationStrLen + 1 + 1);\r
62\r
63 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_SLOTS;\r
64 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE9);\r
d18d8a1d 65 SmbiosRecord->Hdr.Handle = 0;\r
949f388f 66 SmbiosRecord->SlotDesignation = 1;\r
67 SmbiosRecord->SlotType = ForType9InputData->SlotType;\r
68 SmbiosRecord->SlotDataBusWidth = ForType9InputData->SlotDataBusWidth;\r
69 SmbiosRecord->CurrentUsage = ForType9InputData->SlotUsage;\r
70 SmbiosRecord->SlotLength = ForType9InputData->SlotLength;\r
71 SmbiosRecord->SlotID = ForType9InputData->SlotId;\r
d18d8a1d 72\r
949f388f 73 //\r
74 // Slot Characteristics\r
75 //\r
76 CopyMem ((UINT8 *) &SmbiosRecord->SlotCharacteristics1,(UINT8 *) &ForType9InputData->SlotCharacteristics,2);\r
77 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
78 UnicodeStrToAsciiStr(SlotDesignation, OptionalStrStart);\r
d18d8a1d 79 //\r
949f388f 80 // Now we have got the full smbios record, call smbios protocol to add this record.\r
81 //\r
2bfd90f9
SZ
82 Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);\r
83\r
949f388f 84 FreePool(SmbiosRecord);\r
85 return Status;\r
86}\r