• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2 BIOS system option string boot time changes.
3 SMBIOS type 12.
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 
19 #include "CommonHeader.h"
20 #include "SmbiosMisc.h"
21 
22 
23 /**
24   This function makes boot time changes to the contents of the
25   MiscSystemOptionString (Type 12).
26 
27   @param  RecordData                 Pointer to copy of RecordData from the Data Table.
28 
29   @retval EFI_SUCCESS                All parameters were valid.
30   @retval EFI_UNSUPPORTED            Unexpected RecordType value.
31   @retval EFI_INVALID_PARAMETER      Invalid parameter was found.
32 
33 **/
MISC_SMBIOS_TABLE_FUNCTION(SystemOptionString)34 MISC_SMBIOS_TABLE_FUNCTION(SystemOptionString)
35 {
36   CHAR8                             *OptionalStrStart;
37   UINTN                             OptStrLen;
38   EFI_STRING                        OptionString;
39   EFI_STATUS                        Status;
40   STRING_REF                        TokenToGet;
41   EFI_SMBIOS_HANDLE                 SmbiosHandle;
42   SMBIOS_TABLE_TYPE12               *SmbiosRecord;
43 
44   //
45   // First check for invalid parameters.
46   //
47   if (RecordData == NULL) {
48     return EFI_INVALID_PARAMETER;
49   }
50 
51   TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_OPTION_STRING);
52   OptionString = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);
53   OptStrLen = StrLen(OptionString);
54   if (OptStrLen > SMBIOS_STRING_MAX_LENGTH) {
55     return EFI_UNSUPPORTED;
56   }
57 
58   //
59   // Two zeros following the last string.
60   //
61   SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1);
62   ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1);
63 
64   SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS;
65   SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE12);
66   //
67   // Make handle chosen by smbios protocol.add automatically.
68   //
69   SmbiosRecord->Hdr.Handle = 0;
70 
71   SmbiosRecord->StringCount = 1;
72   OptionalStrStart = (CHAR8*) (SmbiosRecord + 1);
73   UnicodeStrToAsciiStr(OptionString, OptionalStrStart);
74   //
75   // Now we have got the full smbios record, call smbios protocol to add this record.
76   //
77   SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
78   Status = Smbios-> Add(
79                       Smbios,
80                       NULL,
81                       &SmbiosHandle,
82                       (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
83                       );
84 
85   FreePool(SmbiosRecord);
86   return Status;
87 }
88