]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c
c42b9d2d5d79d5d18d65678cd820a6b50d60c052
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscSystemSlotDesignationFunction.c
1 /*++
2
3 Copyright (c) 2009, Intel Corporation. All rights reserved. <BR>
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
10 Intel Corporation.
11
12
13 Module Name:
14
15 MiscSystemSlotDesignatorFunction.c
16
17 Abstract:
18
19 BIOS system slot designator information boot time changes.
20 SMBIOS type 9.
21
22 --*/
23
24 #include "MiscSubclassDriver.h"
25 /**
26 This function makes boot time changes to the contents of the
27 MiscSystemSlotDesignator structure (Type 9).
28
29 @param RecordData Pointer to copy of RecordData from the Data Table.
30
31 @retval EFI_SUCCESS All parameters were valid.
32 @retval EFI_UNSUPPORTED Unexpected RecordType value.
33 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
34
35 **/
36 MISC_SMBIOS_TABLE_FUNCTION(MiscSystemSlotDesignation)
37 {
38 CHAR8 *OptionalStrStart;
39 UINTN SlotDesignationStrLen;
40 EFI_STATUS Status;
41 EFI_STRING SlotDesignation;
42 STRING_REF TokenToGet;
43 SMBIOS_TABLE_TYPE9 *SmbiosRecord;
44 EFI_SMBIOS_HANDLE SmbiosHandle;
45 EFI_MISC_SYSTEM_SLOT_DESIGNATION* ForType9InputData;
46
47 ForType9InputData = (EFI_MISC_SYSTEM_SLOT_DESIGNATION *)RecordData;
48
49 //
50 // First check for invalid parameters.
51 //
52 if (RecordData == NULL) {
53 return EFI_INVALID_PARAMETER;
54 }
55
56 TokenToGet = 0;
57 switch (ForType9InputData->SlotDesignation) {
58 case STR_MISC_SYSTEM_SLOT_DESIGNATION:
59 TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_DESIGNATION);
60 break;
61 default:
62 break;
63 }
64
65 SlotDesignation = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);
66 SlotDesignationStrLen = StrLen(SlotDesignation);
67 if (SlotDesignationStrLen > SMBIOS_STRING_MAX_LENGTH) {
68 return EFI_UNSUPPORTED;
69 }
70
71 //
72 // Two zeros following the last string.
73 //
74 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE9) + SlotDesignationStrLen + 1 + 1);
75 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE9) +SlotDesignationStrLen + 1 + 1);
76
77 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_SLOTS;
78 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE9);
79 SmbiosRecord->Hdr.Handle = 0;
80 SmbiosRecord->SlotDesignation = 1;
81 SmbiosRecord->SlotType = ForType9InputData->SlotType;
82 SmbiosRecord->SlotDataBusWidth = ForType9InputData->SlotDataBusWidth;
83 SmbiosRecord->CurrentUsage = ForType9InputData->SlotUsage;
84 SmbiosRecord->SlotLength = ForType9InputData->SlotLength;
85 SmbiosRecord->SlotID = ForType9InputData->SlotId;
86
87 //
88 // Slot Characteristics
89 //
90 CopyMem ((UINT8 *) &SmbiosRecord->SlotCharacteristics1,(UINT8 *) &ForType9InputData->SlotCharacteristics,2);
91 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
92 UnicodeStrToAsciiStr(SlotDesignation, OptionalStrStart);
93 //
94 // Now we have got the full smbios record, call smbios protocol to add this record.
95 //
96 SmbiosHandle = 0;
97 Status = Smbios-> Add(
98 Smbios,
99 NULL,
100 &SmbiosHandle,
101 (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
102 );
103 FreePool(SmbiosRecord);
104 return Status;
105 }