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