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