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