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