Compare commits

..

No commits in common. "b1be5b888f00094860b78a38744c0891993c1c1f" and "90711adadaf8aaf1deea24e9eb153c436787ceb4" have entirely different histories.

4 changed files with 4 additions and 29 deletions

View File

@ -3,6 +3,7 @@
*/ */
module hulk.acpi; module hulk.acpi;
import hulk.klog;
import hulk.hurl; import hulk.hurl;
import hulk.klog; import hulk.klog;
import hos.memory; import hos.memory;
@ -53,7 +54,7 @@ struct acpi
ubyte length; ubyte length;
} }
public static __gshared ulong apic_address; private static ulong apic_address;
public static void initialize(ulong acpi_xsdt_phys) public static void initialize(ulong acpi_xsdt_phys)
{ {
@ -85,7 +86,6 @@ struct acpi
const(MadtHeader) * madt_header = cast(const(MadtHeader) *)address; const(MadtHeader) * madt_header = cast(const(MadtHeader) *)address;
Hurl.map_range(address, madt_header.length, 0u); Hurl.map_range(address, madt_header.length, 0u);
apic_address = madt_header.local_apic_address; apic_address = madt_header.local_apic_address;
klog.writefln("Found 32-bit APIC address: 0x%x", apic_address);
const(void) * madt_end = cast(const(void) *)(address + madt_header.length); const(void) * madt_end = cast(const(void) *)(address + madt_header.length);
const(MadtEntry) * madt_entry = cast(const(MadtEntry) *)(address + 0x2Cu); const(MadtEntry) * madt_entry = cast(const(MadtEntry) *)(address + 0x2Cu);
while (madt_entry < madt_end) while (madt_entry < madt_end)
@ -95,7 +95,6 @@ struct acpi
{ {
/* Found a 64-bit Local APIC Address Override entry. */ /* Found a 64-bit Local APIC Address Override entry. */
memcpy(cast(void *)&apic_address, cast(const(void) *)madt_entry + 4u, 8u); memcpy(cast(void *)&apic_address, cast(const(void) *)madt_entry + 4u, 8u);
klog.writefln("Found 64-bit APIC address: 0x%x", apic_address);
} }
} }
} }

View File

@ -1,22 +0,0 @@
/**
* APIC (Advanced Programmable Interrupt Controller) functionality.
*/
module hulk.apic;
import hulk.klog;
import hulk.hurl;
import hulk.acpi;
struct apic
{
public enum uint * local_apic_registers = cast(uint *)0xFEE0_0000u;
public static void initialize()
{
Hurl.map(cast(ulong)local_apic_registers,
cast(ulong)local_apic_registers,
MAP_WRITABLE | MAP_WRITE_THROUGH | MAP_DISABLE_CACHE | MAP_NO_EXECUTE);
klog.writefln("LAPIC ID: 0x%08x", local_apic_registers[0x20/4]);
klog.writefln("LAPIC version: 0x%08x", local_apic_registers[0x30/4]);
}
}

View File

@ -19,7 +19,6 @@ import hos.cpu;
import ldc.llvmasm; import ldc.llvmasm;
import hulk.pic; import hulk.pic;
import hulk.acpi; import hulk.acpi;
import hulk.apic;
extern extern(C) __gshared ubyte _hulk_total_size; extern extern(C) __gshared ubyte _hulk_total_size;
@ -53,7 +52,6 @@ void hulk_start()
pci.initialize(); pci.initialize();
pic.initialize(); pic.initialize();
acpi.initialize(hulk_header.bootinfo.acpi_xsdt_phys); acpi.initialize(hulk_header.bootinfo.acpi_xsdt_phys);
apic.initialize();
sti(); sti();
for (;;) for (;;)

View File

@ -83,7 +83,7 @@ struct Hurl
return opIndexAssign(pte, cast(ulong)address, level); return opIndexAssign(pte, cast(ulong)address, level);
} }
public ulong pt_index(ulong address, ulong level) private ulong pt_index(ulong address, ulong level)
{ {
return (address >> (39u - (9u * level))) & 0x1FFu; return (address >> (39u - (9u * level))) & 0x1FFu;
} }
@ -140,7 +140,7 @@ struct Hurl
for (size_t level = 0; level < 4u; level++) for (size_t level = 0; level < 4u; level++)
{ {
PageTableEntry entry = (*pt)[address, level]; PageTableEntry entry = (*pt)[address, level];
klog.writefln("Level %u, index %u, entry = 0x%x", level, pt.pt_index(cast(ulong)address, level), entry); klog.writefln("Level %u, entry = 0x%x", level, entry);
if (entry.present) if (entry.present)
{ {
pt = entry.follow(); pt = entry.follow();