]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/DataHubSmBiosRecordsOnPiSmBiosThunk/Thunk.c
Fix bug that that the template does not match fields in structure EFI_BLOCK_IO_MEDIA
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / DataHubSmBiosRecordsOnPiSmBiosThunk / Thunk.c
CommitLineData
024b1029 1/** @file\r
2 Thunk driver's entry that install filter for DataRecord.\r
3 \r
4Copyright (c) 2009 Intel Corporation. <BR>\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "Thunk.h"\r
16\r
17//\r
18// Global variables\r
19//\r
20LIST_ENTRY mStructureList;\r
21\r
22/**\r
23 Entry Point of thunk driver.\r
24\r
25 @param[in] ImageHandle Image handle of this driver.\r
26 @param[in] SystemTable Pointer to EFI system table.\r
27\r
28 @retval EFI_SUCCESS The event handlers were registered.\r
29 @retval EFI_DEVICE_ERROR Failed to register the event handlers\r
30**/ \r
31EFI_STATUS\r
32EFIAPI\r
33ThunkEntry (\r
34 IN EFI_HANDLE ImageHandle,\r
35 IN EFI_SYSTEM_TABLE *SystemTable\r
36 )\r
37{\r
38 EFI_STATUS Status;\r
39 EFI_DATA_HUB_PROTOCOL *DataHub;\r
40 EFI_EVENT FilterEvent;\r
41 \r
42 Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID**) &DataHub);\r
43 ASSERT_EFI_ERROR (Status);\r
44 ASSERT (DataHub != NULL);\r
45\r
46 InitializeListHead (&mStructureList);\r
47\r
48 //\r
49 // Register SmBios Data Filter Function.\r
50 // This function is notified at TPL_CALLBACK.\r
51 //\r
52 Status = gBS->CreateEvent (\r
53 EVT_NOTIFY_SIGNAL,\r
54 TPL_CALLBACK,\r
55 SmbiosDataFilter,\r
56 NULL,\r
57 &FilterEvent\r
58 );\r
59 if (EFI_ERROR (Status)) {\r
60 return Status;\r
61 }\r
62\r
63 Status = DataHub->RegisterFilterDriver (\r
64 DataHub,\r
65 FilterEvent,\r
66 TPL_APPLICATION,\r
67 EFI_DATA_RECORD_CLASS_DATA,\r
68 NULL\r
69 );\r
70 if (EFI_ERROR (Status)) {\r
71 gBS->CloseEvent (FilterEvent);\r
72 return Status;\r
73 }\r
74\r
75 return Status;\r
76\r
77} \r
78\r
79/**\r
80 Smbios data filter function. This function is invoked when there is data records\r
81 available in the Data Hub. \r
82\r
83 @param Event The event that is signaled.\r
84 @param Context not used here.\r
85**/\r
86VOID\r
87EFIAPI\r
88SmbiosDataFilter (\r
89 IN EFI_EVENT Event,\r
90 IN VOID *Context\r
91 )\r
92{\r
93 EFI_STATUS Status;\r
94 EFI_DATA_HUB_PROTOCOL *DataHub;\r
95 EFI_HANDLE DataHubHandle;\r
96 UINTN HandleSize;\r
97 UINT64 MonotonicCount;\r
98 EFI_DATA_RECORD_HEADER *Record;\r
99\r
100 Status = EFI_SUCCESS;\r
101 DataHub = NULL;\r
102\r
103 //\r
104 // Get the Data Hub Protocol. Assume only one instance\r
105 // of Data Hub Protocol is availabe in the system.\r
106 //\r
107 HandleSize = sizeof (EFI_HANDLE);\r
108\r
109 Status = gBS->LocateHandle (\r
110 ByProtocol,\r
111 &gEfiDataHubProtocolGuid,\r
112 NULL,\r
113 &HandleSize,\r
114 &DataHubHandle\r
115 );\r
116\r
117 if (EFI_ERROR (Status)) {\r
118 goto Done;\r
119 }\r
120\r
121 Status = gBS->HandleProtocol (\r
122 DataHubHandle,\r
123 &gEfiDataHubProtocolGuid,\r
124 (VOID **) &DataHub\r
125 );\r
126\r
127 if (EFI_ERROR (Status)) {\r
128 goto Done;\r
129 }\r
130 //\r
131 // Get all available data records from data hub\r
132 //\r
133 MonotonicCount = 0;\r
134 Record = NULL;\r
135\r
136 do {\r
137\r
138 Status = DataHub->GetNextRecord (\r
139 DataHub,\r
140 &MonotonicCount,\r
141 &Event,\r
142 &Record\r
143 );\r
144\r
145 if (!EFI_ERROR (Status)) {\r
146 if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {\r
147 \r
148 //\r
149 // It's of expected Data Type. Process it.\r
150 //\r
151 SmbiosProcessDataRecord (Record);\r
152 }\r
153 }\r
154 } while (!EFI_ERROR (Status) && (MonotonicCount != 0));\r
155\r
156Done:\r
157\r
158 return ;\r
159\r
160}\r