MiscOemStringFunction.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /** @file
  2. boot information boot time changes.
  3. SMBIOS type 11.
  4. Copyright (c) 2013-2016 Intel Corporation.
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include "CommonHeader.h"
  8. #include "SmbiosMisc.h"
  9. /**
  10. This function makes boot time changes to the contents of the
  11. MiscOemString (Type 11).
  12. @param RecordData Pointer to copy of RecordData from the Data Table.
  13. @retval EFI_SUCCESS All parameters were valid.
  14. @retval EFI_UNSUPPORTED Unexpected RecordType value.
  15. @retval EFI_INVALID_PARAMETER Invalid parameter was found.
  16. **/
  17. MISC_SMBIOS_TABLE_FUNCTION(MiscOemString)
  18. {
  19. UINTN OemStrLen;
  20. CHAR8 *OptionalStrStart;
  21. EFI_STATUS Status;
  22. EFI_STRING OemStr;
  23. STRING_REF TokenToGet;
  24. EFI_SMBIOS_HANDLE SmbiosHandle;
  25. SMBIOS_TABLE_TYPE11 *SmbiosRecord;
  26. //
  27. // First check for invalid parameters.
  28. //
  29. if (RecordData == NULL) {
  30. return EFI_INVALID_PARAMETER;
  31. }
  32. TokenToGet = STRING_TOKEN (STR_MISC_OEM_EN_US);
  33. OemStr = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);
  34. OemStrLen = StrLen(OemStr);
  35. if (OemStrLen > SMBIOS_STRING_MAX_LENGTH) {
  36. return EFI_UNSUPPORTED;
  37. }
  38. //
  39. // Two zeros following the last string.
  40. //
  41. SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1);
  42. ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1);
  43. SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_OEM_STRINGS;
  44. SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE11);
  45. //
  46. // Make handle chosen by smbios protocol.add automatically.
  47. //
  48. SmbiosRecord->Hdr.Handle = 0;
  49. SmbiosRecord->StringCount = 1;
  50. OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
  51. UnicodeStrToAsciiStrS (OemStr, OptionalStrStart, OemStrLen + 1);
  52. //
  53. // Now we have got the full smbios record, call smbios protocol to add this record.
  54. //
  55. SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
  56. Status = Smbios-> Add(
  57. Smbios,
  58. NULL,
  59. &SmbiosHandle,
  60. (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
  61. );
  62. FreePool(SmbiosRecord);
  63. return Status;
  64. }