]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/SioBusDxe/SioBusDxe.h
OvmfPkg/Csm/LegacyBiosDxe: Fix Legacy16GetTableAddress call for E820 data
[mirror_edk2.git] / OvmfPkg / SioBusDxe / SioBusDxe.h
CommitLineData
a5cc178a
HW
1/** @file\r
2 The SioBusDxe driver is used to create child devices on the ISA bus and\r
3 installs the Super I/O protocols on them.\r
4\r
5 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
6\r
b26f0cf9 7 SPDX-License-Identifier: BSD-2-Clause-Patent\r
a5cc178a
HW
8\r
9**/\r
10\r
11#ifndef __SIO_BUS_DXE_H__\r
12#define __SIO_BUS_DXE_H__\r
13\r
14#include <Uefi.h>\r
15\r
16#include <IndustryStandard/Pci.h>\r
17\r
18#include <Protocol/PciIo.h>\r
19#include <Protocol/SuperIo.h>\r
20\r
21#include <Library/UefiDriverEntryPoint.h>\r
22#include <Library/UefiLib.h>\r
23#include <Library/UefiBootServicesTableLib.h>\r
24#include <Library/DebugLib.h>\r
25#include <Library/ReportStatusCodeLib.h>\r
26#include <Library/MemoryAllocationLib.h>\r
27#include <Library/BaseMemoryLib.h>\r
28#include <Library/DevicePathLib.h>\r
29\r
30#include "SioService.h"\r
31\r
32//\r
33// SIO Bus driver private data structure\r
34//\r
35typedef struct {\r
36 EFI_PCI_IO_PROTOCOL *PciIo;\r
37 UINT64 OriginalAttributes;\r
38} SIO_BUS_DRIVER_PRIVATE_DATA;\r
39\r
40\r
41//\r
42// Global Variables\r
43//\r
44extern EFI_COMPONENT_NAME_PROTOCOL gSioBusComponentName;\r
45extern EFI_COMPONENT_NAME2_PROTOCOL gSioBusComponentName2;\r
46\r
47\r
48//\r
49// EFI Component Name Functions\r
50//\r
51\r
52/**\r
53 Retrieves a Unicode string that is the user readable name of the driver.\r
54\r
55 This function retrieves the user readable name of a driver in the form of a\r
56 Unicode string. If the driver specified by This has a user readable name in\r
57 the language specified by Language, then a pointer to the driver name is\r
58 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
59 by This does not support the language specified by Language, then\r
60 EFI_UNSUPPORTED is returned.\r
61\r
62 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL\r
63 or EFI_COMPONENT_NAME_PROTOCOL instance.\r
64 @param[in] Language A pointer to a Null-terminated ASCII string\r
65 array indicating the language. This is the\r
66 language of the driver name that the caller is\r
67 requesting, and it must match one of the\r
68 languages specified in SupportedLanguages. The\r
69 number of languages supported by a driver is up\r
70 to the driver writer. Language is specified\r
71 in RFC 4646 or ISO 639-2 language code format.\r
72 @param[out] DriverName A pointer to the Unicode string to return. This\r
73 Unicode string is the name of the driver\r
74 specified by This in the language specified by\r
75 Language.\r
76\r
77 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
78 This and the language specified by Language was\r
79 returned in DriverName.\r
80 @retval EFI_INVALID_PARAMETER Language is NULL.\r
81 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
82 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
83 the language specified by Language.\r
84\r
85**/\r
86EFI_STATUS\r
87EFIAPI\r
88SioBusComponentNameGetDriverName (\r
89 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
90 IN CHAR8 *Language,\r
91 OUT CHAR16 **DriverName\r
92 );\r
93\r
94/**\r
95 Retrieves a Unicode string that is the user readable name of the controller\r
96 that is being managed by a driver.\r
97\r
98 This function retrieves the user readable name of the controller specified by\r
99 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
100 driver specified by This has a user readable name in the language specified\r
101 by Language, then a pointer to the controller name is returned in\r
102 ControllerName, and EFI_SUCCESS is returned. If the driver specified by This\r
103 is not currently managing the controller specified by ControllerHandle and\r
104 ChildHandle, then EFI_UNSUPPORTED is returned. If the driver specified by\r
105 This does not support the language specified by Language, then\r
106 EFI_UNSUPPORTED is returned.\r
107\r
108 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL\r
109 or EFI_COMPONENT_NAME_PROTOCOL instance.\r
110 @param[in] ControllerHandle The handle of a controller that the driver\r
111 specified by This is managing. This handle\r
112 specifies the controller whose name is to be\r
113 returned.\r
114 @param[in] ChildHandle The handle of the child controller to retrieve\r
115 the name of. This is an optional parameter\r
116 that may be NULL. It will be NULL for device\r
117 drivers. It will also be NULL for a bus\r
118 drivers that wish to retrieve the name of the\r
119 bus controller. It will not be NULL for a bus\r
120 driver that wishes to retrieve the name of a\r
121 child controller.\r
122 @param[in] Language A pointer to a Null-terminated ASCII string\r
123 array indicating the language. This is the\r
124 language of the driver name that the caller is\r
125 requesting, and it must match one of the\r
126 languages specified in SupportedLanguages. The\r
127 number of languages supported by a driver is up\r
128 to the driver writer. Language is specified in\r
129 RFC 4646 or ISO 639-2 language code format.\r
130 @param[out] ControllerName A pointer to the Unicode string to return.\r
131 This Unicode string is the name of the\r
132 controller specified by ControllerHandle and\r
133 ChildHandle in the language specified by\r
134 Language from the point of view of the driver\r
135 specified by This.\r
136\r
137 @retval EFI_SUCCESS The Unicode string for the user readable name\r
138 in the language specified by Language for the\r
139 driver specified by This was returned in\r
140 DriverName.\r
141 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
142 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
143 EFI_HANDLE.\r
144 @retval EFI_INVALID_PARAMETER Language is NULL.\r
145 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
146 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
147 managing the controller specified by\r
148 ControllerHandle and ChildHandle.\r
149 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
150 the language specified by Language.\r
151\r
152**/\r
153EFI_STATUS\r
154EFIAPI\r
155SioBusComponentNameGetControllerName (\r
156 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
157 IN EFI_HANDLE ControllerHandle,\r
158 IN EFI_HANDLE ChildHandle OPTIONAL,\r
159 IN CHAR8 *Language,\r
160 OUT CHAR16 **ControllerName\r
161 );\r
162\r
163\r
164//\r
165// Driver Binding Protocol interfaces\r
166//\r
167\r
168/**\r
169 Tests to see if this driver supports a given controller. If a child device is\r
170 provided, it further tests to see if this driver supports creating a handle\r
171 for the specified child device.\r
172\r
173 This function checks to see if the driver specified by This supports the\r
174 device specified by ControllerHandle. Drivers will typically use the device\r
175 path attached to ControllerHandle and/or the services from the bus I/O\r
176 abstraction attached to ControllerHandle to determine if the driver supports\r
177 ControllerHandle. This function may be called many times during platform\r
178 initialization. In order to reduce boot times, the tests performed by this\r
179 function must be very small, and take as little time as possible to execute.\r
180 This function must not change the state of any hardware devices, and this\r
181 function must be aware that the device specified by ControllerHandle may\r
182 already be managed by the same driver or a different driver. This function\r
183 must match its calls to AllocatePages() with FreePages(), AllocatePool() with\r
184 FreePool(), and OpenProtocol() with CloseProtocol(). Since ControllerHandle\r
185 may have been previously started by the same driver, if a protocol is already\r
186 in the opened state, then it must not be closed with CloseProtocol(). This is\r
187 required to guarantee the state of ControllerHandle is not modified by this\r
188 function.\r
189\r
190 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL\r
191 instance.\r
192 @param[in] ControllerHandle The handle of the controller to test. This\r
193 handle must support a protocol interface\r
194 that supplies an I/O abstraction to the\r
195 driver.\r
196 @param[in] RemainingDevicePath A pointer to the remaining portion of a\r
197 device path. This parameter is ignored by\r
198 device drivers, and is optional for bus\r
199 drivers. For bus drivers, if this parameter\r
200 is not NULL, then the bus driver must\r
201 determine if the bus controller specified by\r
202 ControllerHandle and the child controller\r
203 specified by RemainingDevicePath are both\r
204 supported by this bus driver.\r
205\r
206 @retval EFI_SUCCESS The device specified by ControllerHandle and\r
207 RemainingDevicePath is supported by the\r
208 driver specified by This.\r
209 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r
210 RemainingDevicePath is already being managed\r
211 by the driver specified by This.\r
212 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r
213 RemainingDevicePath is already being managed\r
214 by a different driver or an application that\r
215 requires exclusive access.\r
216 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r
217 RemainingDevicePath is not supported by the\r
218 driver specified by This.\r
219\r
220**/\r
221EFI_STATUS\r
222EFIAPI\r
223SioBusDriverBindingSupported (\r
224 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
225 IN EFI_HANDLE Controller,\r
226 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
227 );\r
228\r
229/**\r
230 Starts a device controller or a bus controller.\r
231\r
232 The Start() function is designed to be invoked from the EFI boot service\r
233 ConnectController(). As a result, much of the error checking on the\r
234 parameters to Start() has been moved into this common boot service. It is\r
235 legal to call Start() from other locations, but the following calling\r
236 restrictions must be followed or the system behavior will not be\r
237 deterministic.\r
238 1. ControllerHandle must be a valid EFI_HANDLE.\r
239 2. If RemainingDevicePath is not NULL, then it must be a pointer to a\r
240 naturally aligned EFI_DEVICE_PATH_PROTOCOL.\r
241 3. Prior to calling Start(), the Supported() function for the driver\r
242 specified by This must have been called with the same calling parameters,\r
243 and Supported() must have returned EFI_SUCCESS.\r
244\r
245 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL\r
246 instance.\r
247 @param[in] ControllerHandle The handle of the controller to start. This\r
248 handle must support a protocol interface\r
249 that supplies an I/O abstraction to the\r
250 driver.\r
251 @param[in] RemainingDevicePath A pointer to the remaining portion of a\r
252 device path. This parameter is ignored by\r
253 device drivers, and is optional for bus\r
254 drivers. For a bus driver, if this parameter\r
255 is NULL, then handles for all the children\r
256 of Controller are created by this driver. If\r
257 this parameter is not NULL and the first\r
258 Device Path Node is not the End of Device\r
259 Path Node, then only the handle for the\r
260 child device specified by the first Device\r
261 Path Node of RemainingDevicePath is created\r
262 by this driver. If the first Device Path\r
263 Node of RemainingDevicePath is the End of\r
264 Device Path Node, no child handle is created\r
265 by this driver.\r
266\r
267 @retval EFI_SUCCESS The device was started.\r
268 @retval EFI_DEVICE_ERROR The device could not be started due to a\r
269 device error.\r
270 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a\r
271 lack of resources.\r
272 @retval Others The driver failded to start the device.\r
273\r
274**/\r
275EFI_STATUS\r
276EFIAPI\r
277SioBusDriverBindingStart (\r
278 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
279 IN EFI_HANDLE Controller,\r
280 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
281 );\r
282\r
283/**\r
284 Stops a device controller or a bus controller.\r
285\r
286 The Stop() function is designed to be invoked from the EFI boot service\r
287 DisconnectController(). As a result, much of the error checking on the\r
288 parameters to Stop() has been moved into this common boot service. It is\r
289 legal to call Stop() from other locations, but the following calling\r
290 restrictions must be followed or the system behavior will not be\r
291 deterministic.\r
292 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous\r
293 call to this same driver's Start() function.\r
294 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a\r
295 valid EFI_HANDLE. In addition, all of these handles must have been created\r
296 in this driver's Start() function, and the Start() function must have\r
297 called OpenProtocol() on ControllerHandle with an Attribute of\r
298 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
299\r
300 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL\r
301 instance.\r
302 @param[in] ControllerHandle A handle to the device being stopped. The\r
303 handle must support a bus specific I/O\r
304 protocol for the driver to use to stop the\r
305 device.\r
306 @param[in] NumberOfChildren The number of child device handles in\r
307 ChildHandleBuffer.\r
308 @param[in] ChildHandleBuffer An array of child handles to be freed. May be\r
309 NULL if NumberOfChildren is 0.\r
310\r
311 @retval EFI_SUCCESS The device was stopped.\r
312 @retval EFI_DEVICE_ERROR The device could not be stopped due to a\r
313 device error.\r
314\r
315**/\r
316EFI_STATUS\r
317EFIAPI\r
318SioBusDriverBindingStop (\r
319 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
320 IN EFI_HANDLE Controller,\r
321 IN UINTN NumberOfChildren,\r
322 IN EFI_HANDLE *ChildHandleBuffer\r
323 );\r
324\r
325#endif // __SIO_BUS_DXE_H__\r