MiscSystemLanguageStringFunction.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*++
  2. Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. Module Name:
  5. MiscResetCapabilitiesFunction.c
  6. Abstract:
  7. ResetCapabilities.
  8. SMBIOS type 23.
  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(SystemLanguageString)
  21. {
  22. EFI_STATUS Status;
  23. EFI_SMBIOS_HANDLE SmbiosHandle;
  24. SMBIOS_TABLE_TYPE13 *SmbiosRecord;
  25. UINTN StrLeng;
  26. CHAR8 *OptionalStrStart;
  27. EFI_STRING Str;
  28. STRING_REF TokenToGet;
  29. //
  30. // First check for invalid parameters.
  31. //
  32. if (RecordData == NULL) {
  33. return EFI_INVALID_PARAMETER;
  34. }
  35. TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_LANGUAGE_EN_US);
  36. Str = SmbiosMiscGetString (TokenToGet);
  37. StrLeng = StrLen(Str);
  38. if (StrLeng > SMBIOS_STRING_MAX_LENGTH) {
  39. return EFI_UNSUPPORTED;
  40. }
  41. //
  42. // Two zeros following the last string.
  43. //
  44. SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE13) + StrLeng + 1 + 1);
  45. ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE13) + StrLeng + 1 + 1);
  46. SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION;
  47. SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE13);
  48. //
  49. // Make handle chosen by smbios protocol.add automatically.
  50. //
  51. SmbiosRecord->Hdr.Handle = 0;
  52. SmbiosRecord->InstallableLanguages = 1;
  53. SmbiosRecord->Flags = 1;
  54. SmbiosRecord->CurrentLanguages = 1;
  55. OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
  56. UnicodeStrToAsciiStrS (Str, OptionalStrStart, StrLeng + 1 + 1);
  57. //
  58. // Now we have got the full smbios record, call smbios protocol to add this record.
  59. //
  60. SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
  61. Status = Smbios-> Add(
  62. Smbios,
  63. NULL,
  64. &SmbiosHandle,
  65. (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
  66. );
  67. FreePool(SmbiosRecord);
  68. return Status;
  69. }