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