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