3 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 MiscSystemOptionStringFunction.c
16 BIOS system option string boot time changes.
22 #include "CommonHeader.h"
24 #include "MiscSubclassDriver.h"
28 This function makes boot time changes to the contents of the
29 MiscSystemOptionString (Type 12).
31 @param RecordData Pointer to copy of RecordData from the Data Table.
33 @retval EFI_SUCCESS All parameters were valid.
34 @retval EFI_UNSUPPORTED Unexpected RecordType value.
35 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
38 MISC_SMBIOS_TABLE_FUNCTION(SystemOptionString
)
40 CHAR8
*OptionalStrStart
;
42 EFI_STRING OptionString
;
44 STRING_REF TokenToGet
;
45 EFI_SMBIOS_HANDLE SmbiosHandle
;
46 SMBIOS_TABLE_TYPE12
*SmbiosRecord
;
49 // First check for invalid parameters.
51 if (RecordData
== NULL
) {
52 return EFI_INVALID_PARAMETER
;
55 TokenToGet
= STRING_TOKEN (STR_MISC_SYSTEM_OPTION_EN_US
);
56 OptionString
= SmbiosMiscGetString (TokenToGet
);
57 OptStrLen
= StrLen(OptionString
);
58 if (OptStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
59 return EFI_UNSUPPORTED
;
63 // Two zeros following the last string.
65 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE12
) + OptStrLen
+ 1 + 1);
66 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE12
) + OptStrLen
+ 1 + 1);
68 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS
;
69 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE12
);
72 // Make handle chosen by smbios protocol.add automatically.
74 SmbiosRecord
->Hdr
.Handle
= 0;
76 SmbiosRecord
->StringCount
= 1;
77 OptionalStrStart
= (CHAR8
*) (SmbiosRecord
+ 1);
78 UnicodeStrToAsciiStr(OptionString
, OptionalStrStart
);
81 // Now we have got the full smbios record, call smbios protocol to add this record.
83 SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;
84 Status
= Smbios
-> Add(
88 (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
91 FreePool(SmbiosRecord
);