MiscOemStringFunction.c 2.5 KB

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