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