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