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
, Private
->IsaHc
,
141 &gEfiCallerIdGuid
, Child
,
144 if (EFI_ERROR (Status
)) {
149 return gBS
->OpenProtocol (
150 Private
->IsaHcHandle
,
151 &gEfiIsaHcProtocolGuid
,
153 gIsaBusDriverBinding
.DriverBindingHandle
,
155 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
160 Destroys a child handle with a protocol installed on it.
162 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
163 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
164 last protocol on ChildHandle, then ChildHandle is destroyed.
166 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
167 @param ChildHandle Handle of the child to destroy
169 @retval EFI_SUCCESS The protocol was removed from ChildHandle.
170 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
171 @retval EFI_INVALID_PARAMETER Child handle is NULL.
172 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
173 because its services are being used.
174 @retval other The child handle was not destroyed
180 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
181 IN EFI_HANDLE ChildHandle
185 ISA_BUS_PRIVATE_DATA
*Private
;
186 EFI_ISA_HC_PROTOCOL
*IsaHc
;
187 ISA_BUS_CHILD_PRIVATE_DATA
*Child
;
189 Private
= ISA_BUS_PRIVATE_DATA_FROM_THIS (This
);
191 Status
= gBS
->OpenProtocol (
195 gIsaBusDriverBinding
.DriverBindingHandle
,
197 EFI_OPEN_PROTOCOL_GET_PROTOCOL
199 if (EFI_ERROR (Status
)) {
203 ASSERT (Child
->Signature
== ISA_BUS_CHILD_PRIVATE_DATA_SIGNATURE
);
205 if (Child
->InDestroying
) {
209 Child
->InDestroying
= TRUE
;
210 Status
= gBS
->CloseProtocol (
211 Private
->IsaHcHandle
,
212 &gEfiIsaHcProtocolGuid
,
213 gIsaBusDriverBinding
.DriverBindingHandle
,
216 ASSERT_EFI_ERROR (Status
);
217 if (!EFI_ERROR (Status
)) {
218 Status
= gBS
->UninstallMultipleProtocolInterfaces (
220 &gEfiIsaHcProtocolGuid
, Private
->IsaHc
,
221 &gEfiCallerIdGuid
, Child
,
224 if (EFI_ERROR (Status
)) {
226 Private
->IsaHcHandle
,
227 &gEfiIsaHcProtocolGuid
,
229 gIsaBusDriverBinding
.DriverBindingHandle
,
231 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
236 if (EFI_ERROR (Status
)) {
237 Child
->InDestroying
= FALSE
;
245 ISA_BUS_PRIVATE_DATA mIsaBusPrivateTemplate
= {
246 ISA_BUS_PRIVATE_DATA_SIGNATURE
,
254 Starts a device controller or a bus controller.
256 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
257 @param[in] ControllerHandle The handle of the controller to start. This handle
258 must support a protocol interface that supplies
259 an I/O abstraction to the driver.
260 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
261 parameter is ignored by device drivers, and is optional for bus
262 drivers. For a bus driver, if this parameter is NULL, then handles
263 for all the children of Controller are created by this driver.
264 If this parameter is not NULL and the first Device Path Node is
265 not the End of Device Path Node, then only the handle for the
266 child device specified by the first Device Path Node of
267 RemainingDevicePath is created by this driver.
268 If the first Device Path Node of RemainingDevicePath is
269 the End of Device Path Node, no child handle is created by this
272 @retval EFI_SUCCESS The device was started.
273 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
274 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
275 @retval Others The driver failed to start the device.
280 IsaBusDriverBindingStart (
281 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
282 IN EFI_HANDLE Controller
,
283 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
287 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
288 ISA_BUS_PRIVATE_DATA
*Private
;
290 Status
= gBS
->OpenProtocol (
292 &gEfiIsaHcProtocolGuid
,
293 (VOID
**) &mIsaBusPrivateTemplate
.IsaHc
,
294 This
->DriverBindingHandle
,
296 EFI_OPEN_PROTOCOL_BY_DRIVER
298 if (EFI_ERROR (Status
)) {
302 Status
= gBS
->OpenProtocol (
304 &gEfiDevicePathProtocolGuid
,
305 (VOID
**) &DevicePath
,
306 This
->DriverBindingHandle
,
308 EFI_OPEN_PROTOCOL_BY_DRIVER
310 if (EFI_ERROR (Status
)) {
313 &gEfiIsaHcProtocolGuid
,
314 This
->DriverBindingHandle
,
320 Private
= AllocateCopyPool (sizeof (mIsaBusPrivateTemplate
), &mIsaBusPrivateTemplate
);
321 ASSERT (Private
!= NULL
);
323 Private
->IsaHcHandle
= Controller
;
325 Status
= gBS
->InstallMultipleProtocolInterfaces (
327 &gEfiIsaHcServiceBindingProtocolGuid
, &Private
->ServiceBinding
,
330 ASSERT_EFI_ERROR (Status
);
336 Stops a device controller or a bus controller.
338 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
339 @param[in] ControllerHandle A handle to the device being stopped. The handle must
340 support a bus specific I/O protocol for the driver
341 to use to stop the device.
342 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
343 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
344 if NumberOfChildren is 0.
346 @retval EFI_SUCCESS The device was stopped.
347 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
352 IsaBusDriverBindingStop (
353 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
354 IN EFI_HANDLE Controller
,
355 IN UINTN NumberOfChildren
,
356 IN EFI_HANDLE
*ChildHandleBuffer
360 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
361 ISA_BUS_PRIVATE_DATA
*Private
;
363 BOOLEAN AllChildrenStopped
;
365 Status
= gBS
->OpenProtocol (
367 &gEfiIsaHcServiceBindingProtocolGuid
,
368 (VOID
**) &ServiceBinding
,
369 This
->DriverBindingHandle
,
371 EFI_OPEN_PROTOCOL_GET_PROTOCOL
373 if (EFI_ERROR (Status
)) {
377 Private
= ISA_BUS_PRIVATE_DATA_FROM_THIS (ServiceBinding
);
379 if (NumberOfChildren
== 0) {
380 Status
= gBS
->UninstallMultipleProtocolInterfaces (
382 &gEfiIsaHcServiceBindingProtocolGuid
, &Private
->ServiceBinding
,
385 if (!EFI_ERROR (Status
)) {
388 &gEfiDevicePathProtocolGuid
,
389 This
->DriverBindingHandle
,
394 &gEfiIsaHcProtocolGuid
,
395 This
->DriverBindingHandle
,
404 AllChildrenStopped
= TRUE
;
405 for (Index
= 0; Index
< NumberOfChildren
; Index
++) {
406 Status
= ServiceBinding
->DestroyChild (ServiceBinding
, ChildHandleBuffer
[Index
]);
407 if (EFI_ERROR (Status
)) {
408 AllChildrenStopped
= FALSE
;
412 return AllChildrenStopped
? EFI_SUCCESS
: EFI_DEVICE_ERROR
;
416 // ISA Bus Driver Binding Protocol Instance
418 EFI_DRIVER_BINDING_PROTOCOL gIsaBusDriverBinding
= {
419 IsaBusDriverBindingSupported
,
420 IsaBusDriverBindingStart
,
421 IsaBusDriverBindingStop
,
428 Entry point of the IsaBusDxe driver.
430 @param[in] ImageHandle The firmware allocated handle for the EFI image.
431 @param[in] SystemTable A pointer to the EFI System Table.
433 @retval EFI_SUCCESS The entry point is executed successfully.
434 @retval other Some error occurs when executing this entry point.
439 IN EFI_HANDLE ImageHandle
,
440 IN EFI_SYSTEM_TABLE
*SystemTable
445 Status
= EfiLibInstallDriverBindingComponentName2 (
448 &gIsaBusDriverBinding
,
450 &gIsaBusComponentName
,
451 &gIsaBusComponentName2
453 ASSERT_EFI_ERROR (Status
);