Minor fixes to comments.
[AROS.git] / rom / efi / efi_init.c
blob51c499091a4483a74e03159c2172a6e24585f6d8
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));
13 return FALSE;
16 /* TODO: Check CRC */
18 return TRUE;
21 static int efi_Init(struct EFIBase *EFIBase)
23 APTR KernelBase;
24 struct TagItem *tag;
26 D(bug("[EFI] Entered efi_Init() at 0x%p\n", efi_Init));
28 KernelBase = OpenResource("kernel.resource");
29 if (!KernelBase)
31 return FALSE;
34 tag = LibFindTagItem(KRN_EFISystemTable, KrnGetBootInfo());
35 if (!tag)
37 D(bug("[EFI] No EFI system table from the bootstrap!\n"));
39 return FALSE;
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"));
48 return FALSE;
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));
61 return TRUE;
64 ADD2INITLIB(efi_Init, 0);