]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSubclassDriverEntryPoint.c
Hash2 driver to [Components.IA32, Components.X64, Components.IPF] section.
[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
30 #include "MiscSubclassDriver.h"
31 #include <Protocol/HiiString.h>
32
33 EFI_HII_HANDLE mHiiHandle;
34 EFI_HII_STRING_PROTOCOL *mHiiString;
35
36
37 EFI_STRING
38 EFIAPI
39 SmbiosMiscGetString (
40 IN EFI_STRING_ID StringId
41 ){
42
43 EFI_STATUS Status;
44 UINTN StringSize;
45 CHAR16 TempString;
46 EFI_STRING String;
47 String = NULL;
48
49 //
50 // Retrieve the size of the string in the string package for the BestLanguage
51 //
52 StringSize = 0;
53 Status = mHiiString->GetString (
54 mHiiString,
55 "en-US",
56 mHiiHandle,
57 StringId,
58 &TempString,
59 &StringSize,
60 NULL
61 );
62 //
63 // If GetString() returns EFI_SUCCESS for a zero size,
64 // then there are no supported languages registered for HiiHandle. If GetString()
65 // returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is not present
66 // in the HII Database
67 //
68 if (Status != EFI_BUFFER_TOO_SMALL) {
69 goto Error;
70 }
71
72 //
73 // Allocate a buffer for the return string
74 //
75 String = AllocateZeroPool (StringSize);
76 if (String == NULL) {
77 goto Error;
78 }
79
80 //
81 // Retrieve the string from the string package
82 //
83 Status = mHiiString->GetString (
84 mHiiString,
85 "en-US",
86 mHiiHandle,
87 StringId,
88 String,
89 &StringSize,
90 NULL
91 );
92 if (EFI_ERROR (Status)) {
93 //
94 // Free the buffer and return NULL if the supported languages can not be retrieved.
95 //
96 FreePool (String);
97 String = NULL;
98 }
99 Error:
100
101 return String;
102 }
103
104 /**
105 Standard EFI driver point. This driver parses the mMiscSubclassDataTable
106 structure and reports any generated data to the DataHub.
107
108 @param ImageHandle - Handle for the image of this driver
109 @param SystemTable - Pointer to the EFI System Table
110
111 @retval EFI_SUCCESS - The data was successfully reported to the Data Hub.
112 @retval EFI_DEVICE_ERROR - Can not locate any protocols
113
114 **/
115 EFI_STATUS
116 EFIAPI
117 MiscSubclassDriverEntryPoint (
118 IN EFI_HANDLE ImageHandle,
119 IN EFI_SYSTEM_TABLE *SystemTable
120 )
121 {
122 UINTN Index;
123 EFI_STATUS EfiStatus;
124 EFI_SMBIOS_PROTOCOL *Smbios;
125
126 //
127 // Retrieve the pointer to the UEFI HII String Protocol
128 //
129 EfiStatus = gBS->LocateProtocol (
130 &gEfiHiiStringProtocolGuid,
131 NULL,
132 (VOID **) &mHiiString
133 );
134 ASSERT_EFI_ERROR (EfiStatus);
135
136 EfiStatus = gBS->LocateProtocol(
137 &gEfiSmbiosProtocolGuid,
138 NULL,
139 (VOID**)&Smbios
140 );
141
142 if (EFI_ERROR(EfiStatus)) {
143 DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus));
144 return EfiStatus;
145 }
146
147 mHiiHandle = HiiAddPackages (
148 &gEfiCallerIdGuid,
149 NULL,
150 MiscSubclassStrings,
151 NULL
152 );
153 ASSERT (mHiiHandle != NULL);
154
155 for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {
156 //
157 // If the entry have a function pointer, just log the data.
158 //
159 if (mMiscSubclassDataTable[Index].Function != NULL) {
160 EfiStatus = (*mMiscSubclassDataTable[Index].Function)(
161 mMiscSubclassDataTable[Index].RecordData,
162 Smbios
163 );
164
165 if (EFI_ERROR(EfiStatus)) {
166 DEBUG((EFI_D_ERROR, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index, EfiStatus));
167 return EfiStatus;
168 }
169 }
170 }
171
172 return EfiStatus;
173 }
174