]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c
UefiCpuPkg: Remove double \r
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscSystemLanguageStringFunction.c
1 /** @file
2
3 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
5
6 **/
7
8 #include "MiscSubclassDriver.h"
9 /**
10 This function makes boot time changes to the contents of the
11 MiscOemString (Type 11).
12
13 @param RecordData Pointer to copy of RecordData from the Data Table.
14
15 @retval EFI_SUCCESS All parameters were valid.
16 @retval EFI_UNSUPPORTED Unexpected RecordType value.
17 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
18
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
31 //
32 // First check for invalid parameters.
33 //
34 if (RecordData == NULL) {
35 return EFI_INVALID_PARAMETER;
36 }
37
38 TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_LANGUAGE_STRING);
39 Str = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);
40 StrLeng = StrLen(Str);
41 if (StrLeng > SMBIOS_STRING_MAX_LENGTH) {
42 return EFI_UNSUPPORTED;
43 }
44
45 //
46 // Two zeros following the last string.
47 //
48 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE13) + StrLeng + 1 + 1);
49 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE13) + StrLeng + 1 + 1);
50
51 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION;
52 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE13);
53 //
54 // Make handle chosen by smbios protocol.add automatically.
55 //
56 SmbiosRecord->Hdr.Handle = 0;
57 SmbiosRecord->InstallableLanguages = 1;
58 SmbiosRecord->Flags = 1;
59 SmbiosRecord->CurrentLanguages = 1;
60 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
61 UnicodeStrToAsciiStr(Str, OptionalStrStart);
62
63
64 //
65 // Now we have got the full smbios record, call smbios protocol to add this record.
66 //
67 Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);
68
69 FreePool(SmbiosRecord);
70 return Status;
71 }
72