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, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include "IsaBusDxe.h"
19 #include "ComponentName.h"
22 Tests to see if this driver supports a given controller. If a child device is provided,
23 it further tests to see if this driver supports creating a handle for the specified child device.
25 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
26 @param[in] ControllerHandle The handle of the controller to test. This handle
27 must support a protocol interface that supplies
28 an I/O abstraction to the driver.
29 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
30 parameter is ignored by device drivers, and is optional for bus
31 drivers. For bus drivers, if this parameter is not NULL, then
32 the bus driver must determine if the bus controller specified
33 by ControllerHandle and the child controller specified
34 by RemainingDevicePath are both supported by this
37 @retval EFI_SUCCESS The device specified by ControllerHandle and
38 RemainingDevicePath is supported by the driver specified by This.
39 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
40 RemainingDevicePath is already being managed by the driver
42 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
43 RemainingDevicePath is already being managed by a different
44 driver or an application that requires exclusive access.
45 Currently not implemented.
46 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
47 RemainingDevicePath is not supported by the driver specified by This.
51 IsaBusDriverBindingSupported (
52 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
53 IN EFI_HANDLE Controller
,
54 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
60 Status
= gBS
->OpenProtocol (
62 &gEfiIsaHcProtocolGuid
,
64 This
->DriverBindingHandle
,
66 EFI_OPEN_PROTOCOL_BY_DRIVER
68 if (!EFI_ERROR (Status
)) {
71 &gEfiIsaHcProtocolGuid
,
72 This
->DriverBindingHandle
,
77 if (EFI_ERROR (Status
)) {
81 Status
= gBS
->OpenProtocol (
83 &gEfiDevicePathProtocolGuid
,
85 This
->DriverBindingHandle
,
87 EFI_OPEN_PROTOCOL_BY_DRIVER
89 if (!EFI_ERROR (Status
)) {
92 &gEfiDevicePathProtocolGuid
,
93 This
->DriverBindingHandle
,
101 ISA_BUS_CHILD_PRIVATE_DATA mIsaBusChildPrivateTemplate
= {
102 ISA_BUS_CHILD_PRIVATE_DATA_SIGNATURE
,
107 Creates a child handle and installs a protocol.
109 The CreateChild() function installs a protocol on ChildHandle.
110 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
111 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
113 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
114 @param ChildHandle Pointer to the handle of the child to create. If it is NULL,
115 then a new handle is created. If it is a pointer to an existing UEFI handle,
116 then the protocol is added to the existing UEFI handle.
118 @retval EFI_SUCCES The protocol was added to ChildHandle.
119 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
120 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
122 @retval other The child handle was not created
128 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
129 IN OUT EFI_HANDLE
*ChildHandle
133 ISA_BUS_PRIVATE_DATA
*Private
;
134 EFI_ISA_HC_PROTOCOL
*IsaHc
;
135 ISA_BUS_CHILD_PRIVATE_DATA
*Child
;
137 Private
= ISA_BUS_PRIVATE_DATA_FROM_THIS (This
);
139 Child
= AllocateCopyPool (sizeof (mIsaBusChildPrivateTemplate
), &mIsaBusChildPrivateTemplate
);
141 return EFI_OUT_OF_RESOURCES
;
144 Status
= gBS
->InstallMultipleProtocolInterfaces (
146 &gEfiIsaHcProtocolGuid
, Private
->IsaHc
,
147 &gEfiCallerIdGuid
, Child
,
150 if (EFI_ERROR (Status
)) {
155 return gBS
->OpenProtocol (
156 Private
->IsaHcHandle
,
157 &gEfiIsaHcProtocolGuid
,
159 gIsaBusDriverBinding
.DriverBindingHandle
,
161 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
166 Destroys a child handle with a protocol installed on it.
168 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
169 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
170 last protocol on ChildHandle, then ChildHandle is destroyed.
172 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
173 @param ChildHandle Handle of the child to destroy
175 @retval EFI_SUCCES The protocol was removed from ChildHandle.
176 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
177 @retval EFI_INVALID_PARAMETER Child handle is NULL.
178 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
179 because its services are being used.
180 @retval other The child handle was not destroyed
186 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
187 IN EFI_HANDLE ChildHandle
191 ISA_BUS_PRIVATE_DATA
*Private
;
192 EFI_ISA_HC_PROTOCOL
*IsaHc
;
193 ISA_BUS_CHILD_PRIVATE_DATA
*Child
;
195 Private
= ISA_BUS_PRIVATE_DATA_FROM_THIS (This
);
197 Status
= gBS
->OpenProtocol (
201 gIsaBusDriverBinding
.DriverBindingHandle
,
203 EFI_OPEN_PROTOCOL_GET_PROTOCOL
205 if (EFI_ERROR (Status
)) {
209 ASSERT (Child
->Signature
== ISA_BUS_CHILD_PRIVATE_DATA_SIGNATURE
);
211 if (Child
->InDestroying
) {
215 Child
->InDestroying
= TRUE
;
216 Status
= gBS
->CloseProtocol (
217 Private
->IsaHcHandle
,
218 &gEfiIsaHcProtocolGuid
,
219 gIsaBusDriverBinding
.DriverBindingHandle
,
222 ASSERT_EFI_ERROR (Status
);
223 if (!EFI_ERROR (Status
)) {
224 Status
= gBS
->UninstallMultipleProtocolInterfaces (
226 &gEfiIsaHcProtocolGuid
, Private
->IsaHc
,
227 &gEfiCallerIdGuid
, Child
,
230 if (EFI_ERROR (Status
)) {
232 Private
->IsaHcHandle
,
233 &gEfiIsaHcProtocolGuid
,
235 gIsaBusDriverBinding
.DriverBindingHandle
,
237 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
242 if (EFI_ERROR (Status
)) {
243 Child
->InDestroying
= FALSE
;
251 ISA_BUS_PRIVATE_DATA mIsaBusPrivateTemplate
= {
252 ISA_BUS_PRIVATE_DATA_SIGNATURE
,
260 Starts a device controller or a bus controller.
262 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
263 @param[in] ControllerHandle The handle of the controller to start. This handle
264 must support a protocol interface that supplies
265 an I/O abstraction to the driver.
266 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
267 parameter is ignored by device drivers, and is optional for bus
268 drivers. For a bus driver, if this parameter is NULL, then handles
269 for all the children of Controller are created by this driver.
270 If this parameter is not NULL and the first Device Path Node is
271 not the End of Device Path Node, then only the handle for the
272 child device specified by the first Device Path Node of
273 RemainingDevicePath is created by this driver.
274 If the first Device Path Node of RemainingDevicePath is
275 the End of Device Path Node, no child handle is created by this
278 @retval EFI_SUCCESS The device was started.
279 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
280 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
281 @retval Others The driver failded to start the device.
286 IsaBusDriverBindingStart (
287 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
288 IN EFI_HANDLE Controller
,
289 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
293 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
294 ISA_BUS_PRIVATE_DATA
*Private
;
296 Status
= gBS
->OpenProtocol (
298 &gEfiIsaHcProtocolGuid
,
299 (VOID
**) &mIsaBusPrivateTemplate
.IsaHc
,
300 This
->DriverBindingHandle
,
302 EFI_OPEN_PROTOCOL_BY_DRIVER
304 if (EFI_ERROR (Status
)) {
308 Status
= gBS
->OpenProtocol (
310 &gEfiDevicePathProtocolGuid
,
311 (VOID
**) &DevicePath
,
312 This
->DriverBindingHandle
,
314 EFI_OPEN_PROTOCOL_BY_DRIVER
316 if (EFI_ERROR (Status
)) {
319 &gEfiIsaHcProtocolGuid
,
320 This
->DriverBindingHandle
,
326 Private
= AllocateCopyPool (sizeof (mIsaBusPrivateTemplate
), &mIsaBusPrivateTemplate
);
327 ASSERT (Private
!= NULL
);
329 Private
->IsaHcHandle
= Controller
;
331 Status
= gBS
->InstallMultipleProtocolInterfaces (
333 &gEfiIsaHcServiceBindingProtocolGuid
, &Private
->ServiceBinding
,
336 ASSERT_EFI_ERROR (Status
);
342 Stops a device controller or a bus controller.
344 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
345 @param[in] ControllerHandle A handle to the device being stopped. The handle must
346 support a bus specific I/O protocol for the driver
347 to use to stop the device.
348 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
349 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
350 if NumberOfChildren is 0.
352 @retval EFI_SUCCESS The device was stopped.
353 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
358 IsaBusDriverBindingStop (
359 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
360 IN EFI_HANDLE Controller
,
361 IN UINTN NumberOfChildren
,
362 IN EFI_HANDLE
*ChildHandleBuffer
366 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
367 ISA_BUS_PRIVATE_DATA
*Private
;
369 BOOLEAN AllChildrenStopped
;
371 Status
= gBS
->OpenProtocol (
373 &gEfiIsaHcServiceBindingProtocolGuid
,
374 (VOID
**) &ServiceBinding
,
375 This
->DriverBindingHandle
,
377 EFI_OPEN_PROTOCOL_GET_PROTOCOL
379 if (EFI_ERROR (Status
)) {
383 Private
= ISA_BUS_PRIVATE_DATA_FROM_THIS (ServiceBinding
);
385 if (NumberOfChildren
== 0) {
386 Status
= gBS
->UninstallMultipleProtocolInterfaces (
388 &gEfiIsaHcServiceBindingProtocolGuid
, &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
);