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