]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c
EmulatorPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmulatorPkg / MiscSubClassPlatformDxe / MiscOemStringFunction.c
1 /** @file
2 boot information boot time changes.
3 SMBIOS type 11.
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 This function makes boot time changes to the contents of the
13 MiscOemString (Type 11).
14
15 @param RecordData Pointer to copy of RecordData from the Data Table.
16
17 @retval EFI_SUCCESS All parameters were valid.
18 @retval EFI_UNSUPPORTED Unexpected RecordType value.
19 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
20
21 **/
22 MISC_SMBIOS_TABLE_FUNCTION(OemString)
23 {
24 UINTN OemStrLen;
25 CHAR8 *OptionalStrStart;
26 EFI_STATUS Status;
27 EFI_STRING OemStr;
28 STRING_REF TokenToGet;
29 EFI_SMBIOS_HANDLE SmbiosHandle;
30 SMBIOS_TABLE_TYPE11 *SmbiosRecord;
31
32 //
33 // First check for invalid parameters.
34 //
35 if (RecordData == NULL) {
36 return EFI_INVALID_PARAMETER;
37 }
38
39 TokenToGet = STRING_TOKEN (STR_MISC_OEM_STRING);
40 OemStr = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);
41 OemStrLen = StrLen(OemStr);
42 if (OemStrLen > SMBIOS_STRING_MAX_LENGTH) {
43 return EFI_UNSUPPORTED;
44 }
45
46 //
47 // Two zeros following the last string.
48 //
49 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1);
50 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1);
51
52 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_OEM_STRINGS;
53 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE11);
54 //
55 // Make handle chosen by smbios protocol.add automatically.
56 //
57 SmbiosRecord->Hdr.Handle = 0;
58 SmbiosRecord->StringCount = 1;
59 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
60 UnicodeStrToAsciiStr(OemStr, OptionalStrStart);
61
62 //
63 // Now we have got the full smbios record, call smbios protocol to add this record.
64 //
65 Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);
66
67 FreePool(SmbiosRecord);
68 return Status;
69 }