1 #include <aros/debug.h>
2 #include <resources/efi.h>
3 #include <proto/arossupport.h>
4 #include <proto/kernel.h>
6 #include "efi_intern.h"
8 static BOOL
CheckTable(struct EFI_TableHeader
*t
, UQUAD sig
)
10 if (t
->Signature
!= sig
)
12 D(bug("[EFI] Table 0x%p bad signature (has 0x%016llX, wanted 0x%016llX)\n", t
, t
->Signature
, sig
));
21 static int efi_Init(struct EFIBase
*EFIBase
)
26 D(bug("[EFI] Entered efi_Init() at 0x%p\n", efi_Init
));
28 KernelBase
= OpenResource("kernel.resource");
34 tag
= LibFindTagItem(KRN_EFISystemTable
, KrnGetBootInfo());
37 D(bug("[EFI] No EFI system table from the bootstrap!\n"));
42 EFIBase
->System
= (struct EFI_SystemTable
*)tag
->ti_Data
;
43 D(bug("Found EFI system table at 0x%p\n", EFIBase
->System
));
45 if (!CheckTable(&EFIBase
->System
->Hdr
, EFI_SYSTEM_TABLE_SIGNATURE
))
47 D(bug("[EFI] System table broken\n"));
51 if (CheckTable(&EFIBase
->System
->RuntimeServices
->Hdr
, EFI_RUNTIME_SERVICES_SIGNATURE
))
53 EFIBase
->Runtime
= EFIBase
->System
->RuntimeServices
;
54 D(bug("[EFI] Valid runtime services table at 0x%p\n", EFIBase
->Runtime
));
56 /* Install ShutdownA() replacement */
57 SetFunction(&SysBase
->LibNode
, -173 * LIB_VECTSIZE
,
58 AROS_SLIB_ENTRY(ShutdownA
, Efi
, 173));
64 ADD2INITLIB(efi_Init
, 0);