RDFU  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
EfiScanner.c
Go to the documentation of this file.
1 
11 #include "EfiScannerHeaders.h"
12 #include "EfiScanner.h"
13 
14 
15 
16 
17 
18 
19 
24 EFI_STATUS EFIAPI EfiScannerEntryPoint(EFI_HANDLE ImageHandle,
25  EFI_SYSTEM_TABLE *SystemTable)
26 {
27 
28  EFI_STATUS Status;
29  EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
30  BOOLEAN WantsResidency;
31 
32 
33 
34  Status = EfiScannerInitialize(ImageHandle, TRUE, TRUE, TRUE);
35 
36  if (EFI_ERROR(Status))
37  return Status;
38 
39 
41 
42  Status = EfiLibInstallDriverBindingComponentName2
43  (ImageHandle, SystemTable,
44  &gEfiScannerDriverBinding, ImageHandle,
47 
48  if (EFI_ERROR(Status))
49  {
50  LogFullAscii("EfiScannerEntryPoint: unable to install DriverBindingComponentName2 \r\n");
51  return Status;
52  }
53 
54 
55  // register our unload handler
56  Status = gBS->OpenProtocol(ImageHandle,
57  &gEfiLoadedImageProtocolGuid,
58  &LoadedImage,
59  ImageHandle,
60  NULL,
61  EFI_OPEN_PROTOCOL_GET_PROTOCOL);
62 
63  if (EFI_ERROR(Status))
64  {
65  LogFullAscii("EfiScannerEntryPoint: unable to register unload handler \r\n");
66  return Status;
67  }
68 
69  LoadedImage->Unload = EfiScannerDriverUnload;
70 
71 
72  // execute the main loop
73  WantsResidency = MainLoop();
74 
75  // no residency so force exit
76  if (!WantsResidency)
77  {
78  CloseLogFile();
79  return EFI_NOT_FOUND;
80  }
81 
82  LogFullAscii("%a: Driver loaded!\n", __FUNCTION__);
83  return Status;
84 }
85 
86 EFI_STATUS EFIAPI EfiScannerDriverUnload(EFI_HANDLE ImageHandle)
87 {
88  // now uninstall the protocols
89  gBS->UninstallMultipleProtocolInterfaces(ImageHandle,
90  &gEfiDriverBindingProtocolGuid, &gEfiScannerDriverBinding,
91  &gEfiComponentNameProtocolGuid, &gEfiScannerComponentName,
92  &gEfiComponentName2ProtocolGuid, &gEfiScannerComponentName2,
93  NULL);
94 
95  return EFI_SUCCESS;
96 }