TianoCore EDK2 master
Loading...
Searching...
No Matches
IsaBusDxe.c
Go to the documentation of this file.
1
12#include "IsaBusDxe.h"
13#include "ComponentName.h"
14
44EFIAPI
47 IN EFI_HANDLE Controller,
48 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
49 )
50{
51 EFI_STATUS Status;
52 VOID *Instance;
53
54 Status = gBS->OpenProtocol (
55 Controller,
57 &Instance,
58 This->DriverBindingHandle,
59 Controller,
60 EFI_OPEN_PROTOCOL_BY_DRIVER
61 );
62 if (!EFI_ERROR (Status)) {
63 gBS->CloseProtocol (
64 Controller,
66 This->DriverBindingHandle,
67 Controller
68 );
69 }
70
71 if (EFI_ERROR (Status)) {
72 return Status;
73 }
74
75 Status = gBS->OpenProtocol (
76 Controller,
77 &gEfiDevicePathProtocolGuid,
78 &Instance,
79 This->DriverBindingHandle,
80 Controller,
81 EFI_OPEN_PROTOCOL_BY_DRIVER
82 );
83 if (!EFI_ERROR (Status)) {
84 gBS->CloseProtocol (
85 Controller,
86 &gEfiDevicePathProtocolGuid,
87 This->DriverBindingHandle,
88 Controller
89 );
90 }
91
92 return Status;
93}
94
95ISA_BUS_CHILD_PRIVATE_DATA mIsaBusChildPrivateTemplate = {
96 ISA_BUS_CHILD_PRIVATE_DATA_SIGNATURE,
97 FALSE
98};
99
120EFIAPI
123 IN OUT EFI_HANDLE *ChildHandle
124 )
125{
126 EFI_STATUS Status;
127 ISA_BUS_PRIVATE_DATA *Private;
128 EFI_ISA_HC_PROTOCOL *IsaHc;
130
131 Private = ISA_BUS_PRIVATE_DATA_FROM_THIS (This);
132
133 Child = AllocateCopyPool (sizeof (mIsaBusChildPrivateTemplate), &mIsaBusChildPrivateTemplate);
134 if (Child == NULL) {
135 return EFI_OUT_OF_RESOURCES;
136 }
137
138 Status = gBS->InstallMultipleProtocolInterfaces (
139 ChildHandle,
141 Private->IsaHc,
142 &gEfiCallerIdGuid,
143 Child,
144 NULL
145 );
146 if (EFI_ERROR (Status)) {
147 FreePool (Child);
148 return Status;
149 }
150
151 return gBS->OpenProtocol (
152 Private->IsaHcHandle,
154 (VOID **)&IsaHc,
155 gIsaBusDriverBinding.DriverBindingHandle,
156 *ChildHandle,
157 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
158 );
159}
160
180EFIAPI
183 IN EFI_HANDLE ChildHandle
184 )
185{
186 EFI_STATUS Status;
187 ISA_BUS_PRIVATE_DATA *Private;
188 EFI_ISA_HC_PROTOCOL *IsaHc;
190
191 Private = ISA_BUS_PRIVATE_DATA_FROM_THIS (This);
192
193 Status = gBS->OpenProtocol (
194 ChildHandle,
195 &gEfiCallerIdGuid,
196 (VOID **)&Child,
197 gIsaBusDriverBinding.DriverBindingHandle,
198 ChildHandle,
199 EFI_OPEN_PROTOCOL_GET_PROTOCOL
200 );
201 if (EFI_ERROR (Status)) {
202 return Status;
203 }
204
205 ASSERT (Child->Signature == ISA_BUS_CHILD_PRIVATE_DATA_SIGNATURE);
206
207 if (Child->InDestroying) {
208 return EFI_SUCCESS;
209 }
210
211 Child->InDestroying = TRUE;
212 Status = gBS->CloseProtocol (
213 Private->IsaHcHandle,
215 gIsaBusDriverBinding.DriverBindingHandle,
216 ChildHandle
217 );
218 ASSERT_EFI_ERROR (Status);
219 if (!EFI_ERROR (Status)) {
220 Status = gBS->UninstallMultipleProtocolInterfaces (
221 ChildHandle,
223 Private->IsaHc,
224 &gEfiCallerIdGuid,
225 Child,
226 NULL
227 );
228 if (EFI_ERROR (Status)) {
229 gBS->OpenProtocol (
230 Private->IsaHcHandle,
232 (VOID **)&IsaHc,
233 gIsaBusDriverBinding.DriverBindingHandle,
234 ChildHandle,
235 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
236 );
237 }
238 }
239
240 if (EFI_ERROR (Status)) {
241 Child->InDestroying = FALSE;
242 } else {
243 FreePool (Child);
244 }
245
246 return Status;
247}
248
249ISA_BUS_PRIVATE_DATA mIsaBusPrivateTemplate = {
250 ISA_BUS_PRIVATE_DATA_SIGNATURE,
251 {
254 }
255};
256
283EFIAPI
286 IN EFI_HANDLE Controller,
287 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
288 )
289{
290 EFI_STATUS Status;
291 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
292 ISA_BUS_PRIVATE_DATA *Private;
293
294 Status = gBS->OpenProtocol (
295 Controller,
297 (VOID **)&mIsaBusPrivateTemplate.IsaHc,
298 This->DriverBindingHandle,
299 Controller,
300 EFI_OPEN_PROTOCOL_BY_DRIVER
301 );
302 if (EFI_ERROR (Status)) {
303 return Status;
304 }
305
306 Status = gBS->OpenProtocol (
307 Controller,
308 &gEfiDevicePathProtocolGuid,
309 (VOID **)&DevicePath,
310 This->DriverBindingHandle,
311 Controller,
312 EFI_OPEN_PROTOCOL_BY_DRIVER
313 );
314 if (EFI_ERROR (Status)) {
315 gBS->CloseProtocol (
316 Controller,
318 This->DriverBindingHandle,
319 Controller
320 );
321 return Status;
322 }
323
324 Private = AllocateCopyPool (sizeof (mIsaBusPrivateTemplate), &mIsaBusPrivateTemplate);
325 ASSERT (Private != NULL);
326
327 Private->IsaHcHandle = Controller;
328
329 Status = gBS->InstallMultipleProtocolInterfaces (
330 &Controller,
331 &gEfiIsaHcServiceBindingProtocolGuid,
332 &Private->ServiceBinding,
333 NULL
334 );
335 ASSERT_EFI_ERROR (Status);
336
337 return Status;
338}
339
356EFIAPI
359 IN EFI_HANDLE Controller,
360 IN UINTN NumberOfChildren,
361 IN EFI_HANDLE *ChildHandleBuffer
362 )
363{
364 EFI_STATUS Status;
365 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
366 ISA_BUS_PRIVATE_DATA *Private;
367 UINTN Index;
368 BOOLEAN AllChildrenStopped;
369
370 Status = gBS->OpenProtocol (
371 Controller,
372 &gEfiIsaHcServiceBindingProtocolGuid,
373 (VOID **)&ServiceBinding,
374 This->DriverBindingHandle,
375 Controller,
376 EFI_OPEN_PROTOCOL_GET_PROTOCOL
377 );
378 if (EFI_ERROR (Status)) {
379 return Status;
380 }
381
382 Private = ISA_BUS_PRIVATE_DATA_FROM_THIS (ServiceBinding);
383
384 if (NumberOfChildren == 0) {
385 Status = gBS->UninstallMultipleProtocolInterfaces (
386 Controller,
387 &gEfiIsaHcServiceBindingProtocolGuid,
388 &Private->ServiceBinding,
389 NULL
390 );
391 if (!EFI_ERROR (Status)) {
392 gBS->CloseProtocol (
393 Controller,
394 &gEfiDevicePathProtocolGuid,
395 This->DriverBindingHandle,
396 Controller
397 );
398 gBS->CloseProtocol (
399 Controller,
401 This->DriverBindingHandle,
402 Controller
403 );
404 FreePool (Private);
405 }
406
407 return Status;
408 }
409
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;
415 }
416 }
417
418 return AllChildrenStopped ? EFI_SUCCESS : EFI_DEVICE_ERROR;
419}
420
421//
422// ISA Bus Driver Binding Protocol Instance
423//
424EFI_DRIVER_BINDING_PROTOCOL gIsaBusDriverBinding = {
428 0x10,
429 NULL,
430 NULL
431};
432
443EFIAPI
445 IN EFI_HANDLE ImageHandle,
446 IN EFI_SYSTEM_TABLE *SystemTable
447 )
448{
449 EFI_STATUS Status;
450
452 ImageHandle,
453 SystemTable,
454 &gIsaBusDriverBinding,
455 ImageHandle,
456 &gIsaBusComponentName,
457 &gIsaBusComponentName2
458 );
459 ASSERT_EFI_ERROR (Status);
460 return Status;
461}
UINT64 UINTN
NODE Child(IN NODE LoopVar6, IN UINT8 LoopVar5)
Definition: Compress.c:265
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_STATUS EFIAPI IsaBusCreateChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN OUT EFI_HANDLE *ChildHandle)
Definition: IsaBusDxe.c:121
EFI_STATUS EFIAPI IsaBusDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: IsaBusDxe.c:284
EFI_STATUS EFIAPI IsaBusDestroyChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE ChildHandle)
Definition: IsaBusDxe.c:181
EFI_STATUS EFIAPI IsaBusDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: IsaBusDxe.c:357
EFI_STATUS EFIAPI InitializeIsaBus(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: IsaBusDxe.c:444
EFI_STATUS EFIAPI IsaBusDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: IsaBusDxe.c:45
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
EFI_GUID gEfiIsaHcProtocolGuid
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_ISA_HC_PROTOCOL * IsaHc
ISA HC protocol produced by the ISA Host Controller driver.
Definition: IsaBusDxe.h:26
EFI_HANDLE IsaHcHandle
ISA HC handle created by the ISA Host Controller driver.
Definition: IsaBusDxe.h:27