+++ /dev/null
-/** @file\r
-\r
-Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>\r
- \r\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
- \r\r
-\r
-\r
-Module Name:\r
-\r
- MiscOnboardDeviceFunction.c\r
-\r
-Abstract:\r
-\r
- Create the device path for the Onboard device.\r
- The Onboard device information is Misc. subclass type 8 and SMBIOS type 10.\r
-\r
-\r
-**/\r
-\r
-\r
-#include "CommonHeader.h"\r
-\r
-#include "MiscSubclassDriver.h"\r
-\r
-\r
-\r
-/**\r
- This is a macro defined function, in fact, the function is\r
- MiscOnboardDeviceFunction (RecordType, RecordLen, RecordData, LogRecordData)\r
- This function makes boot time changes to the contents of the\r
- MiscOnboardDevice structure.\r
-\r
- @param MiscOnboardDevice The string which is used to create the function\r
- The Arguments in fact:\r
- @param RecordType Type of record to be processed from the Data\r
- Table. mMiscSubclassDataTable[].RecordType\r
- @param RecordLen Size of static RecordData from the Data Table.\r
- mMiscSubclassDataTable[].RecordLen\r
- @param RecordData Pointer to RecordData, which will be written to\r
- the Data Hub\r
- @param LogRecordData TRUE to log RecordData to Data Hub. FALSE when\r
- there is no more data to log.\r
-\r
- @retval EFI_SUCCESS *RecordData and *LogRecordData have been set.\r
- @retval EFI_UNSUPPORTED Unexpected RecordType value.\r
- @retval EFI_INVALID_PARAMETER One of the following parameter conditions was\r
- true: RecordLen was zero. RecordData was NULL.\r
- LogRecordData was NULL.\r
-\r
-**/\r
-MISC_SMBIOS_TABLE_FUNCTION (\r
- MiscOnboardDevice\r
- )\r
-{\r
- CHAR8 *OptionalStrStart;\r
- UINT8 StatusAndType;\r
- UINTN DescriptionStrLen;\r
- EFI_STRING DeviceDescription;\r
- STRING_REF TokenToGet;\r
- EFI_STATUS Status;\r
- EFI_SMBIOS_HANDLE SmbiosHandle;\r
- SMBIOS_TABLE_TYPE10 *SmbiosRecord;\r
- EFI_MISC_ONBOARD_DEVICE *ForType10InputData;\r
-\r
- ForType10InputData = (EFI_MISC_ONBOARD_DEVICE *)RecordData;\r
-\r
- //\r
- // First check for invalid parameters.\r
- //\r
- if (RecordData == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- TokenToGet = 0;\r
- switch (ForType10InputData->OnBoardDeviceDescription) {\r
- case STR_MISC_ONBOARD_DEVICE_VIDEO:\r
- TokenToGet = STRING_TOKEN (STR_MISC_ONBOARD_DEVICE_VIDEO);\r
- break;\r
- case STR_MISC_ONBOARD_DEVICE_AUDIO:\r
- TokenToGet = STRING_TOKEN (STR_MISC_ONBOARD_DEVICE_AUDIO);\r
- break;\r
- default:\r
- break;\r
- }\r
-\r
- DeviceDescription = SmbiosMiscGetString (TokenToGet);\r
- DescriptionStrLen = StrLen(DeviceDescription);\r
- if (DescriptionStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- //\r
- // Two zeros following the last string.\r
- //\r
- SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE10) + DescriptionStrLen + 1 + 1);\r
- ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE10) + DescriptionStrLen + 1 + 1);\r
-\r
- SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_ONBOARD_DEVICE_INFORMATION;\r
- SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE10);\r
-\r
- //\r
- // Make handle chosen by smbios protocol.add automatically.\r
- //\r
- SmbiosRecord->Hdr.Handle = 0;\r
-\r
- //\r
- // Status & Type: Bit 7 Devicen Status, Bits 6:0 Type of Device\r
- //\r
- StatusAndType = (UINT8) ForType10InputData->OnBoardDeviceStatus.DeviceType;\r
- if (ForType10InputData->OnBoardDeviceStatus.DeviceEnabled != 0) {\r
- StatusAndType |= 0x80;\r
- } else {\r
- StatusAndType &= 0x7F;\r
- }\r
-\r
- SmbiosRecord->Device[0].DeviceType = StatusAndType;\r
- SmbiosRecord->Device[0].DescriptionString = 1;\r
- OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
- UnicodeStrToAsciiStr(DeviceDescription, OptionalStrStart);\r
-\r
- //\r
- // Now we have got the full smbios record, call smbios protocol to add this record.\r
- //\r
- SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
- Status = Smbios-> Add(\r
- Smbios,\r
- NULL,\r
- &SmbiosHandle,\r
- (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
- );\r
- FreePool(SmbiosRecord);\r
- return Status;\r
-}\r