3 Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 MiscOnboardDeviceFunction.c
16 Create the device path for the Onboard device.
17 The Onboard device information is Misc. subclass type 8 and SMBIOS type 10.
23 #include "CommonHeader.h"
25 #include "MiscSubclassDriver.h"
30 This is a macro defined function, in fact, the function is
31 MiscOnboardDeviceFunction (RecordType, RecordLen, RecordData, LogRecordData)
32 This function makes boot time changes to the contents of the
33 MiscOnboardDevice structure.
35 @param MiscOnboardDevice The string which is used to create the function
36 The Arguments in fact:
37 @param RecordType Type of record to be processed from the Data
38 Table. mMiscSubclassDataTable[].RecordType
39 @param RecordLen Size of static RecordData from the Data Table.
40 mMiscSubclassDataTable[].RecordLen
41 @param RecordData Pointer to RecordData, which will be written to
43 @param LogRecordData TRUE to log RecordData to Data Hub. FALSE when
44 there is no more data to log.
46 @retval EFI_SUCCESS *RecordData and *LogRecordData have been set.
47 @retval EFI_UNSUPPORTED Unexpected RecordType value.
48 @retval EFI_INVALID_PARAMETER One of the following parameter conditions was
49 true: RecordLen was zero. RecordData was NULL.
50 LogRecordData was NULL.
53 MISC_SMBIOS_TABLE_FUNCTION (
57 CHAR8
*OptionalStrStart
;
59 UINTN DescriptionStrLen
;
60 EFI_STRING DeviceDescription
;
61 STRING_REF TokenToGet
;
63 EFI_SMBIOS_HANDLE SmbiosHandle
;
64 SMBIOS_TABLE_TYPE10
*SmbiosRecord
;
65 EFI_MISC_ONBOARD_DEVICE
*ForType10InputData
;
67 ForType10InputData
= (EFI_MISC_ONBOARD_DEVICE
*)RecordData
;
70 // First check for invalid parameters.
72 if (RecordData
== NULL
) {
73 return EFI_INVALID_PARAMETER
;
77 switch (ForType10InputData
->OnBoardDeviceDescription
) {
78 case STR_MISC_ONBOARD_DEVICE_VIDEO
:
79 TokenToGet
= STRING_TOKEN (STR_MISC_ONBOARD_DEVICE_VIDEO
);
81 case STR_MISC_ONBOARD_DEVICE_AUDIO
:
82 TokenToGet
= STRING_TOKEN (STR_MISC_ONBOARD_DEVICE_AUDIO
);
88 DeviceDescription
= SmbiosMiscGetString (TokenToGet
);
89 DescriptionStrLen
= StrLen(DeviceDescription
);
90 if (DescriptionStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
91 return EFI_UNSUPPORTED
;
95 // Two zeros following the last string.
97 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE10
) + DescriptionStrLen
+ 1 + 1);
98 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE10
) + DescriptionStrLen
+ 1 + 1);
100 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_ONBOARD_DEVICE_INFORMATION
;
101 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE10
);
104 // Make handle chosen by smbios protocol.add automatically.
106 SmbiosRecord
->Hdr
.Handle
= 0;
109 // Status & Type: Bit 7 Devicen Status, Bits 6:0 Type of Device
111 StatusAndType
= (UINT8
) ForType10InputData
->OnBoardDeviceStatus
.DeviceType
;
112 if (ForType10InputData
->OnBoardDeviceStatus
.DeviceEnabled
!= 0) {
113 StatusAndType
|= 0x80;
115 StatusAndType
&= 0x7F;
118 SmbiosRecord
->Device
[0].DeviceType
= StatusAndType
;
119 SmbiosRecord
->Device
[0].DescriptionString
= 1;
120 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
121 UnicodeStrToAsciiStr(DeviceDescription
, OptionalStrStart
);
124 // Now we have got the full smbios record, call smbios protocol to add this record.
126 SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;
127 Status
= Smbios
-> Add(
131 (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
133 FreePool(SmbiosRecord
);