]>
Commit | Line | Data |
---|---|---|
3cbfba02 DW |
1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>\r | |
4 | \r\r | |
9dc8036d MK |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
6 | \r | |
3cbfba02 DW |
7 | \r\r |
8 | \r | |
9 | \r | |
10 | Module Name:\r | |
11 | \r | |
12 | MiscOnboardDeviceFunction.c\r | |
13 | \r | |
14 | Abstract:\r | |
15 | \r | |
16 | Create the device path for the Onboard device.\r | |
17 | The Onboard device information is Misc. subclass type 8 and SMBIOS type 10.\r | |
18 | \r | |
19 | \r | |
20 | **/\r | |
21 | \r | |
22 | \r | |
23 | #include "CommonHeader.h"\r | |
24 | \r | |
25 | #include "MiscSubclassDriver.h"\r | |
26 | \r | |
27 | \r | |
28 | \r | |
29 | /**\r | |
30 | This is a macro defined function, in fact, the function is\r | |
31 | MiscOnboardDeviceFunction (RecordType, RecordLen, RecordData, LogRecordData)\r | |
32 | This function makes boot time changes to the contents of the\r | |
33 | MiscOnboardDevice structure.\r | |
34 | \r | |
35 | @param MiscOnboardDevice The string which is used to create the function\r | |
36 | The Arguments in fact:\r | |
37 | @param RecordType Type of record to be processed from the Data\r | |
38 | Table. mMiscSubclassDataTable[].RecordType\r | |
39 | @param RecordLen Size of static RecordData from the Data Table.\r | |
40 | mMiscSubclassDataTable[].RecordLen\r | |
41 | @param RecordData Pointer to RecordData, which will be written to\r | |
42 | the Data Hub\r | |
43 | @param LogRecordData TRUE to log RecordData to Data Hub. FALSE when\r | |
44 | there is no more data to log.\r | |
45 | \r | |
46 | @retval EFI_SUCCESS *RecordData and *LogRecordData have been set.\r | |
47 | @retval EFI_UNSUPPORTED Unexpected RecordType value.\r | |
48 | @retval EFI_INVALID_PARAMETER One of the following parameter conditions was\r | |
49 | true: RecordLen was zero. RecordData was NULL.\r | |
50 | LogRecordData was NULL.\r | |
51 | \r | |
52 | **/\r | |
53 | MISC_SMBIOS_TABLE_FUNCTION (\r | |
54 | MiscOnboardDevice\r | |
55 | )\r | |
56 | {\r | |
57 | CHAR8 *OptionalStrStart;\r | |
58 | UINT8 StatusAndType;\r | |
59 | UINTN DescriptionStrLen;\r | |
60 | EFI_STRING DeviceDescription;\r | |
61 | STRING_REF TokenToGet;\r | |
62 | EFI_STATUS Status;\r | |
63 | EFI_SMBIOS_HANDLE SmbiosHandle;\r | |
64 | SMBIOS_TABLE_TYPE10 *SmbiosRecord;\r | |
65 | EFI_MISC_ONBOARD_DEVICE *ForType10InputData;\r | |
66 | \r | |
67 | ForType10InputData = (EFI_MISC_ONBOARD_DEVICE *)RecordData;\r | |
68 | \r | |
69 | //\r | |
70 | // First check for invalid parameters.\r | |
71 | //\r | |
72 | if (RecordData == NULL) {\r | |
73 | return EFI_INVALID_PARAMETER;\r | |
74 | }\r | |
75 | \r | |
76 | TokenToGet = 0;\r | |
77 | switch (ForType10InputData->OnBoardDeviceDescription) {\r | |
78 | case STR_MISC_ONBOARD_DEVICE_VIDEO:\r | |
79 | TokenToGet = STRING_TOKEN (STR_MISC_ONBOARD_DEVICE_VIDEO);\r | |
80 | break;\r | |
81 | case STR_MISC_ONBOARD_DEVICE_AUDIO:\r | |
82 | TokenToGet = STRING_TOKEN (STR_MISC_ONBOARD_DEVICE_AUDIO);\r | |
83 | break;\r | |
84 | default:\r | |
85 | break;\r | |
86 | }\r | |
87 | \r | |
88 | DeviceDescription = SmbiosMiscGetString (TokenToGet);\r | |
89 | DescriptionStrLen = StrLen(DeviceDescription);\r | |
90 | if (DescriptionStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
91 | return EFI_UNSUPPORTED;\r | |
92 | }\r | |
93 | \r | |
94 | //\r | |
95 | // Two zeros following the last string.\r | |
96 | //\r | |
97 | SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE10) + DescriptionStrLen + 1 + 1);\r | |
98 | ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE10) + DescriptionStrLen + 1 + 1);\r | |
99 | \r | |
100 | SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_ONBOARD_DEVICE_INFORMATION;\r | |
101 | SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE10);\r | |
102 | \r | |
103 | //\r | |
104 | // Make handle chosen by smbios protocol.add automatically.\r | |
105 | //\r | |
106 | SmbiosRecord->Hdr.Handle = 0;\r | |
107 | \r | |
108 | //\r | |
109 | // Status & Type: Bit 7 Devicen Status, Bits 6:0 Type of Device\r | |
110 | //\r | |
111 | StatusAndType = (UINT8) ForType10InputData->OnBoardDeviceStatus.DeviceType;\r | |
112 | if (ForType10InputData->OnBoardDeviceStatus.DeviceEnabled != 0) {\r | |
113 | StatusAndType |= 0x80;\r | |
114 | } else {\r | |
115 | StatusAndType &= 0x7F;\r | |
116 | }\r | |
117 | \r | |
118 | SmbiosRecord->Device[0].DeviceType = StatusAndType;\r | |
119 | SmbiosRecord->Device[0].DescriptionString = 1;\r | |
120 | OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r | |
121 | UnicodeStrToAsciiStr(DeviceDescription, OptionalStrStart);\r | |
122 | \r | |
123 | //\r | |
124 | // Now we have got the full smbios record, call smbios protocol to add this record.\r | |
125 | //\r | |
126 | SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r | |
127 | Status = Smbios-> Add(\r | |
128 | Smbios,\r | |
129 | NULL,\r | |
130 | &SmbiosHandle,\r | |
131 | (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r | |
132 | );\r | |
133 | FreePool(SmbiosRecord);\r | |
134 | return Status;\r | |
135 | }\r |