2 This file consumes the ISA Host Controller protocol produced by the ISA Host
3 Controller and installs the ISA Host Controller Service Binding protocol
4 on the ISA Host Controller's handle.
6 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include "IsaBusDxe.h"
13 #include "ComponentName.h"
16 Tests to see if this driver supports a given controller. If a child device is provided,
17 it further tests to see if this driver supports creating a handle for the specified child device.
19 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
20 @param[in] ControllerHandle The handle of the controller to test. This handle
21 must support a protocol interface that supplies
22 an I/O abstraction to the driver.
23 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
24 parameter is ignored by device drivers, and is optional for bus
25 drivers. For bus drivers, if this parameter is not NULL, then
26 the bus driver must determine if the bus controller specified
27 by ControllerHandle and the child controller specified
28 by RemainingDevicePath are both supported by this
31 @retval EFI_SUCCESS The device specified by ControllerHandle and
32 RemainingDevicePath is supported by the driver specified by This.
33 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
34 RemainingDevicePath is already being managed by the driver
36 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
37 RemainingDevicePath is already being managed by a different
38 driver or an application that requires exclusive access.
39 Currently not implemented.
40 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
41 RemainingDevicePath is not supported by the driver specified by This.
45 IsaBusDriverBindingSupported (
46 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
47 IN EFI_HANDLE Controller
,
48 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
54 Status
= gBS
->OpenProtocol (
56 &gEfiIsaHcProtocolGuid
,
58 This
->DriverBindingHandle
,
60 EFI_OPEN_PROTOCOL_BY_DRIVER
62 if (!EFI_ERROR (Status
)) {
65 &gEfiIsaHcProtocolGuid
,
66 This
->DriverBindingHandle
,
71 if (EFI_ERROR (Status
)) {
75 Status
= gBS
->OpenProtocol (
77 &gEfiDevicePathProtocolGuid
,
79 This
->DriverBindingHandle
,
81 EFI_OPEN_PROTOCOL_BY_DRIVER
83 if (!EFI_ERROR (Status
)) {
86 &gEfiDevicePathProtocolGuid
,
87 This
->DriverBindingHandle
,
95 ISA_BUS_CHILD_PRIVATE_DATA mIsaBusChildPrivateTemplate
= {
96 ISA_BUS_CHILD_PRIVATE_DATA_SIGNATURE
,
101 Creates a child handle and installs a protocol.
103 The CreateChild() function installs a protocol on ChildHandle.
104 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
105 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
107 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
108 @param ChildHandle Pointer to the handle of the child to create. If it is NULL,
109 then a new handle is created. If it is a pointer to an existing UEFI handle,
110 then the protocol is added to the existing UEFI handle.
112 @retval EFI_SUCCESS The protocol was added to ChildHandle.
113 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
114 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
116 @retval other The child handle was not created
122 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
123 IN OUT EFI_HANDLE
*ChildHandle
127 ISA_BUS_PRIVATE_DATA
*Private
;
128 EFI_ISA_HC_PROTOCOL
*IsaHc
;
129 ISA_BUS_CHILD_PRIVATE_DATA
*Child
;
131 Private
= ISA_BUS_PRIVATE_DATA_FROM_THIS (This
);
133 Child
= AllocateCopyPool (sizeof (mIsaBusChildPrivateTemplate
), &mIsaBusChildPrivateTemplate
);
135 return EFI_OUT_OF_RESOURCES
;
138 Status
= gBS
->InstallMultipleProtocolInterfaces (
140 &gEfiIsaHcProtocolGuid
,
146 if (EFI_ERROR (Status
)) {
151 return gBS
->OpenProtocol (
152 Private
->IsaHcHandle
,
153 &gEfiIsaHcProtocolGuid
,
155 gIsaBusDriverBinding
.DriverBindingHandle
,
157 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
162 Destroys a child handle with a protocol installed on it.
164 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
165 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
166 last protocol on ChildHandle, then ChildHandle is destroyed.
168 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
169 @param ChildHandle Handle of the child to destroy
171 @retval EFI_SUCCESS The protocol was removed from ChildHandle.
172 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
173 @retval EFI_INVALID_PARAMETER Child handle is NULL.
174 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
175 because its services are being used.
176 @retval other The child handle was not destroyed
182 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
183 IN EFI_HANDLE ChildHandle
187 ISA_BUS_PRIVATE_DATA
*Private
;
188 EFI_ISA_HC_PROTOCOL
*IsaHc
;
189 ISA_BUS_CHILD_PRIVATE_DATA
*Child
;
191 Private
= ISA_BUS_PRIVATE_DATA_FROM_THIS (This
);
193 Status
= gBS
->OpenProtocol (
197 gIsaBusDriverBinding
.DriverBindingHandle
,
199 EFI_OPEN_PROTOCOL_GET_PROTOCOL
201 if (EFI_ERROR (Status
)) {
205 ASSERT (Child
->Signature
== ISA_BUS_CHILD_PRIVATE_DATA_SIGNATURE
);
207 if (Child
->InDestroying
) {
211 Child
->InDestroying
= TRUE
;
212 Status
= gBS
->CloseProtocol (
213 Private
->IsaHcHandle
,
214 &gEfiIsaHcProtocolGuid
,
215 gIsaBusDriverBinding
.DriverBindingHandle
,
218 ASSERT_EFI_ERROR (Status
);
219 if (!EFI_ERROR (Status
)) {
220 Status
= gBS
->UninstallMultipleProtocolInterfaces (
222 &gEfiIsaHcProtocolGuid
,
228 if (EFI_ERROR (Status
)) {
230 Private
->IsaHcHandle
,
231 &gEfiIsaHcProtocolGuid
,
233 gIsaBusDriverBinding
.DriverBindingHandle
,
235 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
240 if (EFI_ERROR (Status
)) {
241 Child
->InDestroying
= FALSE
;
249 ISA_BUS_PRIVATE_DATA mIsaBusPrivateTemplate
= {
250 ISA_BUS_PRIVATE_DATA_SIGNATURE
,
258 Starts a device controller or a bus controller.
260 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
261 @param[in] ControllerHandle The handle of the controller to start. This handle
262 must support a protocol interface that supplies
263 an I/O abstraction to the driver.
264 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
265 parameter is ignored by device drivers, and is optional for bus
266 drivers. For a bus driver, if this parameter is NULL, then handles
267 for all the children of Controller are created by this driver.
268 If this parameter is not NULL and the first Device Path Node is
269 not the End of Device Path Node, then only the handle for the
270 child device specified by the first Device Path Node of
271 RemainingDevicePath is created by this driver.
272 If the first Device Path Node of RemainingDevicePath is
273 the End of Device Path Node, no child handle is created by this
276 @retval EFI_SUCCESS The device was started.
277 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
278 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
279 @retval Others The driver failed to start the device.
284 IsaBusDriverBindingStart (
285 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
286 IN EFI_HANDLE Controller
,
287 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
291 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
292 ISA_BUS_PRIVATE_DATA
*Private
;
294 Status
= gBS
->OpenProtocol (
296 &gEfiIsaHcProtocolGuid
,
297 (VOID
**)&mIsaBusPrivateTemplate
.IsaHc
,
298 This
->DriverBindingHandle
,
300 EFI_OPEN_PROTOCOL_BY_DRIVER
302 if (EFI_ERROR (Status
)) {
306 Status
= gBS
->OpenProtocol (
308 &gEfiDevicePathProtocolGuid
,
309 (VOID
**)&DevicePath
,
310 This
->DriverBindingHandle
,
312 EFI_OPEN_PROTOCOL_BY_DRIVER
314 if (EFI_ERROR (Status
)) {
317 &gEfiIsaHcProtocolGuid
,
318 This
->DriverBindingHandle
,
324 Private
= AllocateCopyPool (sizeof (mIsaBusPrivateTemplate
), &mIsaBusPrivateTemplate
);
325 ASSERT (Private
!= NULL
);
327 Private
->IsaHcHandle
= Controller
;
329 Status
= gBS
->InstallMultipleProtocolInterfaces (
331 &gEfiIsaHcServiceBindingProtocolGuid
,
332 &Private
->ServiceBinding
,
335 ASSERT_EFI_ERROR (Status
);
341 Stops a device controller or a bus controller.
343 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
344 @param[in] ControllerHandle A handle to the device being stopped. The handle must
345 support a bus specific I/O protocol for the driver
346 to use to stop the device.
347 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
348 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
349 if NumberOfChildren is 0.
351 @retval EFI_SUCCESS The device was stopped.
352 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
357 IsaBusDriverBindingStop (
358 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
359 IN EFI_HANDLE Controller
,
360 IN UINTN NumberOfChildren
,
361 IN EFI_HANDLE
*ChildHandleBuffer
365 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
366 ISA_BUS_PRIVATE_DATA
*Private
;
368 BOOLEAN AllChildrenStopped
;
370 Status
= gBS
->OpenProtocol (
372 &gEfiIsaHcServiceBindingProtocolGuid
,
373 (VOID
**)&ServiceBinding
,
374 This
->DriverBindingHandle
,
376 EFI_OPEN_PROTOCOL_GET_PROTOCOL
378 if (EFI_ERROR (Status
)) {
382 Private
= ISA_BUS_PRIVATE_DATA_FROM_THIS (ServiceBinding
);
384 if (NumberOfChildren
== 0) {
385 Status
= gBS
->UninstallMultipleProtocolInterfaces (
387 &gEfiIsaHcServiceBindingProtocolGuid
,
388 &Private
->ServiceBinding
,
391 if (!EFI_ERROR (Status
)) {
394 &gEfiDevicePathProtocolGuid
,
395 This
->DriverBindingHandle
,
400 &gEfiIsaHcProtocolGuid
,
401 This
->DriverBindingHandle
,
410 AllChildrenStopped
= TRUE
;
411 for (Index
= 0; Index
< NumberOfChildren
; Index
++) {
412 Status
= ServiceBinding
->DestroyChild (ServiceBinding
, ChildHandleBuffer
[Index
]);
413 if (EFI_ERROR (Status
)) {
414 AllChildrenStopped
= FALSE
;
418 return AllChildrenStopped
? EFI_SUCCESS
: EFI_DEVICE_ERROR
;
422 // ISA Bus Driver Binding Protocol Instance
424 EFI_DRIVER_BINDING_PROTOCOL gIsaBusDriverBinding
= {
425 IsaBusDriverBindingSupported
,
426 IsaBusDriverBindingStart
,
427 IsaBusDriverBindingStop
,
434 Entry point of the IsaBusDxe driver.
436 @param[in] ImageHandle The firmware allocated handle for the EFI image.
437 @param[in] SystemTable A pointer to the EFI System Table.
439 @retval EFI_SUCCESS The entry point is executed successfully.
440 @retval other Some error occurs when executing this entry point.
445 IN EFI_HANDLE ImageHandle
,
446 IN EFI_SYSTEM_TABLE
*SystemTable
451 Status
= EfiLibInstallDriverBindingComponentName2 (
454 &gIsaBusDriverBinding
,
456 &gIsaBusComponentName
,
457 &gIsaBusComponentName2
459 ASSERT_EFI_ERROR (Status
);