]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemStringFunction.c
8624481149760e350dea488947926d4fd9d3db83
[mirror_edk2.git] / Vlv2TbltDevicePkg / SmBiosMiscDxe / MiscOemStringFunction.c
1 /*++
2
3 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7
8
9 Module Name:
10
11 MiscOemStringFunction.c
12
13 Abstract:
14
15 boot information boot time changes.
16 SMBIOS type 11.
17
18 --*/
19
20
21 #include "CommonHeader.h"
22
23 #include "MiscSubclassDriver.h"
24
25 /**
26 This function makes boot time changes to the contents of the
27 MiscOemString (Type 11).
28
29 @param RecordData Pointer to copy of RecordData from the Data Table.
30
31 @retval EFI_SUCCESS All parameters were valid.
32 @retval EFI_UNSUPPORTED Unexpected RecordType value.
33 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
34
35 **/
36 MISC_SMBIOS_TABLE_FUNCTION(OemString)
37 {
38 UINTN OemStrLen;
39 CHAR8 *OptionalStrStart;
40 EFI_STATUS Status;
41 EFI_STRING OemStr;
42 STRING_REF TokenToGet;
43 EFI_SMBIOS_HANDLE SmbiosHandle;
44 SMBIOS_TABLE_TYPE11 *SmbiosRecord;
45
46 //
47 // First check for invalid parameters.
48 //
49 if (RecordData == NULL) {
50 return EFI_INVALID_PARAMETER;
51 }
52
53 TokenToGet = STRING_TOKEN (STR_MISC_OEM_EN_US);
54 OemStr = SmbiosMiscGetString (TokenToGet);
55 OemStrLen = StrLen(OemStr);
56 if (OemStrLen > SMBIOS_STRING_MAX_LENGTH) {
57 return EFI_UNSUPPORTED;
58 }
59
60 //
61 // Two zeros following the last string.
62 //
63 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1);
64 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1);
65
66 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_OEM_STRINGS;
67 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE11);
68
69 //
70 // Make handle chosen by smbios protocol.add automatically.
71 //
72 SmbiosRecord->Hdr.Handle = 0;
73 SmbiosRecord->StringCount = 1;
74 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
75 UnicodeStrToAsciiStr(OemStr, OptionalStrStart);
76
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 FreePool(SmbiosRecord);
88 return Status;
89 }