]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemLanguageStringFunction.c
8abfa4074af9fdfc48697a4101125991c09dab97
[mirror_edk2.git] / Vlv2TbltDevicePkg / SmBiosMiscDxe / MiscSystemLanguageStringFunction.c
1 /*++
2
3 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7
8
9 Module Name:
10
11 MiscResetCapabilitiesFunction.c
12
13 Abstract:
14
15 ResetCapabilities.
16 SMBIOS type 23.
17
18 --*/
19
20
21 #include "CommonHeader.h"
22
23 #include "MiscSubclassDriver.h"
24 /**
25 This function makes boot time changes to the contents of the
26 MiscOemString (Type 11).
27
28 @param RecordData Pointer to copy of RecordData from the Data Table.
29
30 @retval EFI_SUCCESS All parameters were valid.
31 @retval EFI_UNSUPPORTED Unexpected RecordType value.
32 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
33
34 **/
35
36 MISC_SMBIOS_TABLE_FUNCTION(SystemLanguageString)
37 {
38 EFI_STATUS Status;
39 EFI_SMBIOS_HANDLE SmbiosHandle;
40 SMBIOS_TABLE_TYPE13 *SmbiosRecord;
41 UINTN StrLeng;
42 CHAR8 *OptionalStrStart;
43 EFI_STRING Str;
44 STRING_REF TokenToGet;
45
46
47 //
48 // First check for invalid parameters.
49 //
50 if (RecordData == NULL) {
51 return EFI_INVALID_PARAMETER;
52 }
53
54 TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_LANGUAGE_EN_US);
55 Str = SmbiosMiscGetString (TokenToGet);
56 StrLeng = StrLen(Str);
57 if (StrLeng > SMBIOS_STRING_MAX_LENGTH) {
58 return EFI_UNSUPPORTED;
59 }
60
61 //
62 // Two zeros following the last string.
63 //
64 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE13) + StrLeng + 1 + 1);
65 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE13) + StrLeng + 1 + 1);
66
67 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION;
68 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE13);
69
70 //
71 // Make handle chosen by smbios protocol.add automatically.
72 //
73 SmbiosRecord->Hdr.Handle = 0;
74 SmbiosRecord->InstallableLanguages = 1;
75 SmbiosRecord->Flags = 1;
76 SmbiosRecord->CurrentLanguages = 1;
77 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
78 UnicodeStrToAsciiStr(Str, OptionalStrStart);
79
80 //
81 // Now we have got the full smbios record, call smbios protocol to add this record.
82 //
83 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
84 Status = Smbios-> Add(
85 Smbios,
86 NULL,
87 &SmbiosHandle,
88 (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
89 );
90 FreePool(SmbiosRecord);
91 return Status;
92 }
93