rewrite the device subsystem interfaces (#48)
[lunaix-os.git] / lunaix-os / hal / acpi / acpi.c
index 5732ec8e176802ece8c38383b0a95e3c589a8830..b4faf630eb1f10d58d5602fd875ecebc91aa8018 100644 (file)
@@ -1,6 +1,6 @@
 #include <hal/acpi/acpi.h>
 
-#include <lunaix/device.h>
+#include <lunaix/owloysius.h>
 #include <lunaix/mm/valloc.h>
 #include <lunaix/spike.h>
 #include <lunaix/syslog.h>
@@ -68,7 +68,7 @@ acpi_locate_rsdp()
 }
 
 static int
-acpi_init(struct device_def* devdef)
+__gather_acpi_table()
 {
     acpi_rsdp_t* rsdp = acpi_locate_rsdp();
 
@@ -85,15 +85,14 @@ acpi_init(struct device_def* devdef)
 
     size_t entry_n = (rsdt->header.length - sizeof(acpi_sdthdr_t)) >> 2;
     for (size_t i = 0; i < entry_n; i++) {
-        acpi_sdthdr_t* sdthdr =
-          (acpi_sdthdr_t*)((acpi_apic_t**)&(rsdt->entry))[i];
+        acpi_sdthdr_t* sdthdr = __acpi_sdthdr(rsdt->entry[i]);
         switch (sdthdr->signature) {
             case ACPI_MADT_SIG:
-                madt_parse((acpi_madt_t*)sdthdr, ctx);
+                madt_parse(__acpi_madt(sdthdr), ctx);
                 break;
             case ACPI_FADT_SIG:
                 // FADT just a plain structure, no need to parse.
-                ctx->fadt = *(acpi_fadt_t*)sdthdr;
+                ctx->fadt = *__acpi_fadt(sdthdr);
                 break;
             case ACPI_MCFG_SIG:
                 mcfg_parse(sdthdr, ctx);
@@ -106,8 +105,4 @@ acpi_init(struct device_def* devdef)
     return 0;
 }
 
-struct device_def acpi_sysdev = { .name = "ACPI Proxy",
-                                  .class =
-                                    DEVCLASS(DEVIF_FMW, DEVFN_CFG, DEV_ACPI),
-                                  .init = acpi_init };
-EXPORT_DEVICE(acpi, &acpi_sysdev, load_sysconf);
\ No newline at end of file
+owloysius_fetch_init(__gather_acpi_table, on_sysconf);
\ No newline at end of file