]> git.proxmox.com Git - mirror_edk2.git/blob - QuarkPlatformPkg/Platform/Dxe/SmbiosMiscDxe/MiscSystemOptionStringFunction.c
QuarkPlatformPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / QuarkPlatformPkg / Platform / Dxe / SmbiosMiscDxe / MiscSystemOptionStringFunction.c
1 /** @file
2 BIOS system option string boot time changes.
3 SMBIOS type 12.
4
5 Copyright (c) 2013-2016 Intel Corporation.
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9
10 **/
11
12
13 #include "CommonHeader.h"
14 #include "SmbiosMisc.h"
15
16
17 /**
18 This function makes boot time changes to the contents of the
19 MiscSystemOptionString (Type 12).
20
21 @param RecordData Pointer to copy of RecordData from the Data Table.
22
23 @retval EFI_SUCCESS All parameters were valid.
24 @retval EFI_UNSUPPORTED Unexpected RecordType value.
25 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
26
27 **/
28 MISC_SMBIOS_TABLE_FUNCTION(SystemOptionString)
29 {
30 CHAR8 *OptionalStrStart;
31 UINTN OptStrLen;
32 EFI_STRING OptionString;
33 EFI_STATUS Status;
34 STRING_REF TokenToGet;
35 EFI_SMBIOS_HANDLE SmbiosHandle;
36 SMBIOS_TABLE_TYPE12 *SmbiosRecord;
37
38 //
39 // First check for invalid parameters.
40 //
41 if (RecordData == NULL) {
42 return EFI_INVALID_PARAMETER;
43 }
44
45 TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_OPTION_STRING);
46 OptionString = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);
47 OptStrLen = StrLen(OptionString);
48 if (OptStrLen > SMBIOS_STRING_MAX_LENGTH) {
49 return EFI_UNSUPPORTED;
50 }
51
52 //
53 // Two zeros following the last string.
54 //
55 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1);
56 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1);
57
58 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS;
59 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE12);
60 //
61 // Make handle chosen by smbios protocol.add automatically.
62 //
63 SmbiosRecord->Hdr.Handle = 0;
64
65 SmbiosRecord->StringCount = 1;
66 OptionalStrStart = (CHAR8*) (SmbiosRecord + 1);
67 UnicodeStrToAsciiStr(OptionString, OptionalStrStart);
68 //
69 // Now we have got the full smbios record, call smbios protocol to add this record.
70 //
71 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
72 Status = Smbios-> Add(
73 Smbios,
74 NULL,
75 &SmbiosHandle,
76 (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
77 );
78
79 FreePool(SmbiosRecord);
80 return Status;
81 }