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