]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c
a4aeb3113cf998e30f9259bcb5bfb1d13409800a
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscSystemOptionStringFunction.c
1 /*++
2
3 Copyright (c) 2009, Intel Corporation. All rights reserved. <BR>
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
10 Intel Corporation.
11
12
13 Module Name:
14
15 MiscSystemOptionStringFunction.c
16
17 Abstract:
18
19 BIOS system option string boot time changes.
20 SMBIOS type 12.
21
22 --*/
23
24 #include "MiscSubclassDriver.h"
25
26
27 /**
28 This function makes boot time changes to the contents of the
29 MiscSystemOptionString (Type 12).
30
31 @param RecordData Pointer to copy of RecordData from the Data Table.
32
33 @retval EFI_SUCCESS All parameters were valid.
34 @retval EFI_UNSUPPORTED Unexpected RecordType value.
35 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
36
37 **/
38 MISC_SMBIOS_TABLE_FUNCTION(SystemOptionString)
39 {
40 CHAR8 *OptionalStrStart;
41 UINTN OptStrLen;
42 EFI_STRING OptionString;
43 EFI_STATUS Status;
44 STRING_REF TokenToGet;
45 EFI_SMBIOS_HANDLE SmbiosHandle;
46 SMBIOS_TABLE_TYPE12 *SmbiosRecord;
47
48 //
49 // First check for invalid parameters.
50 //
51 if (RecordData == NULL) {
52 return EFI_INVALID_PARAMETER;
53 }
54
55 TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_OPTION_STRING);
56 OptionString = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);
57 OptStrLen = StrLen(OptionString);
58 if (OptStrLen > SMBIOS_STRING_MAX_LENGTH) {
59 return EFI_UNSUPPORTED;
60 }
61
62 //
63 // Two zeros following the last string.
64 //
65 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1);
66 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1);
67
68 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS;
69 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE12);
70 //
71 // Make handle chosen by smbios protocol.add automatically.
72 //
73 SmbiosRecord->Hdr.Handle = 0;
74
75 SmbiosRecord->StringCount = 1;
76 OptionalStrStart = (CHAR8*) (SmbiosRecord + 1);
77 UnicodeStrToAsciiStr(OptionString, OptionalStrStart);
78 //
79 // Now we have got the full smbios record, call smbios protocol to add this record.
80 //
81 SmbiosHandle = 0;
82 Status = Smbios-> Add(
83 Smbios,
84 NULL,
85 &SmbiosHandle,
86 (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
87 );
88
89 FreePool(SmbiosRecord);
90 return Status;
91 }