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