]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSubclassDriverEntryPoint.c
e2cdb0352619763fb5a4269c63354eb80c11a27d
[mirror_edk2.git] / Vlv2TbltDevicePkg / SmBiosMiscDxe / MiscSubclassDriverEntryPoint.c
1 /** @file
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13
14
15 Module Name:
16
17 MiscSubclassDriverEntryPoint.c
18
19 Abstract:
20
21 This driver parses the mMiscSubclassDataTable structure and reports
22 any generated data to the DataHub.
23
24
25 **/
26
27
28 #include "CommonHeader.h"
29 #include "MiscSubclassDriver.h"
30 #include <Protocol/HiiString.h>
31 #include <Guid/PlatformInfo.h>
32
33
34 EFI_HII_HANDLE mHiiHandle;
35 EFI_HII_STRING_PROTOCOL *mHiiString;
36 EFI_PLATFORM_INFO_HOB *mPlatformInfo=NULL;
37
38 EFI_STRING
39 EFIAPI
40 SmbiosMiscGetString (
41 IN EFI_STRING_ID StringId
42 ){
43
44 EFI_STATUS Status;
45 UINTN StringSize;
46 CHAR16 TempString;
47 EFI_STRING String;
48 String = NULL;
49
50 //
51 // Retrieve the size of the string in the string package for the BestLanguage
52 //
53 StringSize = 0;
54 Status = mHiiString->GetString (
55 mHiiString,
56 "en-US",
57 mHiiHandle,
58 StringId,
59 &TempString,
60 &StringSize,
61 NULL
62 );
63 //
64 // If GetString() returns EFI_SUCCESS for a zero size,
65 // then there are no supported languages registered for HiiHandle. If GetString()
66 // returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is not present
67 // in the HII Database
68 //
69 if (Status != EFI_BUFFER_TOO_SMALL) {
70 goto Error;
71 }
72
73 //
74 // Allocate a buffer for the return string
75 //
76 String = AllocateZeroPool (StringSize);
77 if (String == NULL) {
78 goto Error;
79 }
80
81 //
82 // Retrieve the string from the string package
83 //
84 Status = mHiiString->GetString (
85 mHiiString,
86 "en-US",
87 mHiiHandle,
88 StringId,
89 String,
90 &StringSize,
91 NULL
92 );
93 if (EFI_ERROR (Status)) {
94 //
95 // Free the buffer and return NULL if the supported languages can not be retrieved.
96 //
97 FreePool (String);
98 String = NULL;
99 }
100 Error:
101
102 return String;
103 }
104
105 /**
106 Standard EFI driver point. This driver parses the mMiscSubclassDataTable
107 structure and reports any generated data to the DataHub.
108
109 @param ImageHandle - Handle for the image of this driver
110 @param SystemTable - Pointer to the EFI System Table
111
112 @retval EFI_SUCCESS - The data was successfully reported to the Data Hub.
113 @retval EFI_DEVICE_ERROR - Can not locate any protocols
114
115 **/
116 EFI_STATUS
117 EFIAPI
118 MiscSubclassDriverEntryPoint (
119 IN EFI_HANDLE ImageHandle,
120 IN EFI_SYSTEM_TABLE *SystemTable
121 )
122 {
123 UINTN Index;
124 EFI_STATUS EfiStatus;
125 EFI_SMBIOS_PROTOCOL *Smbios;
126 EFI_PEI_HOB_POINTERS GuidHob;
127
128
129
130 GuidHob.Raw = GetHobList ();
131 if (GuidHob.Raw != NULL) {
132 if ((GuidHob.Raw = GetNextGuidHob (&gEfiPlatformInfoGuid, GuidHob.Raw)) != NULL) {
133 mPlatformInfo = GET_GUID_HOB_DATA (GuidHob.Guid);
134 }
135 }
136
137 DEBUG ((EFI_D_ERROR, "PlatformInfoHob->BoardId [0x%x]\n", mPlatformInfo->BoardId));
138
139 //
140 // Retrieve the pointer to the UEFI HII String Protocol
141 //
142 EfiStatus = gBS->LocateProtocol (
143 &gEfiHiiStringProtocolGuid,
144 NULL,
145 (VOID **) &mHiiString
146 );
147 ASSERT_EFI_ERROR (EfiStatus);
148
149 EfiStatus = gBS->LocateProtocol(
150 &gEfiSmbiosProtocolGuid,
151 NULL,
152 (VOID**)&Smbios
153 );
154
155 if (EFI_ERROR(EfiStatus)) {
156 DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus));
157 return EfiStatus;
158 }
159
160 mHiiHandle = HiiAddPackages (
161 &gEfiCallerIdGuid,
162 NULL,
163 MiscSubclassStrings,
164 NULL
165 );
166 ASSERT (mHiiHandle != NULL);
167
168 for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {
169 //
170 // If the entry have a function pointer, just log the data.
171 //
172 if (mMiscSubclassDataTable[Index].Function != NULL) {
173 EfiStatus = (*mMiscSubclassDataTable[Index].Function)(
174 mMiscSubclassDataTable[Index].RecordData,
175 Smbios
176 );
177
178 if (EFI_ERROR(EfiStatus)) {
179 DEBUG((EFI_D_ERROR, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index, EfiStatus));
180 return EfiStatus;
181 }
182 }
183 }
184
185 return EfiStatus;
186 }
187