1 /** @file
2 boot information boot time changes.
3 SMBIOS type 11.
4 
5 Copyright (c) 2013-2015 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 **/
MISC_SMBIOS_TABLE_FUNCTION(MiscOemString)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   EFI_MISC_OEM_STRING      *ForType11InputData;
42 
43   ForType11InputData = (EFI_MISC_OEM_STRING *)RecordData;
44 
45   //
46   // First check for invalid parameters.
47   //
48   if (RecordData == NULL) {
49     return EFI_INVALID_PARAMETER;
50   }
51 
52   TokenToGet = STRING_TOKEN (STR_MISC_OEM_EN_US);
53   OemStr = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);
54   OemStrLen = StrLen(OemStr);
55   if (OemStrLen > SMBIOS_STRING_MAX_LENGTH) {
56     return EFI_UNSUPPORTED;
57   }
58 
59   //
60   // Two zeros following the last string.
61   //
62   SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1);
63   ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1);
64 
65   SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_OEM_STRINGS;
66   SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE11);
67   //
68   // Make handle chosen by smbios protocol.add automatically.
69   //
70   SmbiosRecord->Hdr.Handle = 0;
71   SmbiosRecord->StringCount = 1;
72   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
73   UnicodeStrToAsciiStr(OemStr, OptionalStrStart);
74 
75   //
76   // Now we have got the full smbios record, call smbios protocol to add this record.
77   //
78   SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
79   Status = Smbios-> Add(
80                       Smbios,
81                       NULL,
82                       &SmbiosHandle,
83                       (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
84                       );
85   FreePool(SmbiosRecord);
86   return Status;
87 }
88