]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemOptionStringFunction.c
UefiCpuPkg CpuIo2Dxe: Update INF to refer to NASM source file
[mirror_edk2.git] / Vlv2TbltDevicePkg / SmBiosMiscDxe / MiscSystemOptionStringFunction.c
1 /*++
2
3 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13
14
15 Module Name:
16
17 MiscSystemOptionStringFunction.c
18
19 Abstract:
20
21 BIOS system option string boot time changes.
22 SMBIOS type 12.
23
24 --*/
25
26
27 #include "CommonHeader.h"
28
29 #include "MiscSubclassDriver.h"
30
31
32 /**
33 This function makes boot time changes to the contents of the
34 MiscSystemOptionString (Type 12).
35
36 @param RecordData Pointer to copy of RecordData from the Data Table.
37
38 @retval EFI_SUCCESS All parameters were valid.
39 @retval EFI_UNSUPPORTED Unexpected RecordType value.
40 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
41
42 **/
43 MISC_SMBIOS_TABLE_FUNCTION(SystemOptionString)
44 {
45 CHAR8 *OptionalStrStart;
46 UINTN OptStrLen;
47 EFI_STRING OptionString;
48 EFI_STATUS Status;
49 STRING_REF TokenToGet;
50 EFI_SMBIOS_HANDLE SmbiosHandle;
51 SMBIOS_TABLE_TYPE12 *SmbiosRecord;
52
53 //
54 // First check for invalid parameters.
55 //
56 if (RecordData == NULL) {
57 return EFI_INVALID_PARAMETER;
58 }
59
60 TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_OPTION_EN_US);
61 OptionString = SmbiosMiscGetString (TokenToGet);
62 OptStrLen = StrLen(OptionString);
63 if (OptStrLen > SMBIOS_STRING_MAX_LENGTH) {
64 return EFI_UNSUPPORTED;
65 }
66
67 //
68 // Two zeros following the last string.
69 //
70 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1);
71 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1);
72
73 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS;
74 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE12);
75
76 //
77 // Make handle chosen by smbios protocol.add automatically.
78 //
79 SmbiosRecord->Hdr.Handle = 0;
80
81 SmbiosRecord->StringCount = 1;
82 OptionalStrStart = (CHAR8*) (SmbiosRecord + 1);
83 UnicodeStrToAsciiStr(OptionString, OptionalStrStart);
84
85 //
86 // Now we have got the full smbios record, call smbios protocol to add this record.
87 //
88 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
89 Status = Smbios-> Add(
90 Smbios,
91 NULL,
92 &SmbiosHandle,
93 (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
94 );
95
96 FreePool(SmbiosRecord);
97 return Status;
98 }