Compare commits

..

No commits in common. "7d2b535df5d5a35f805c7ed2a68332a4e306a3ea" and "7471a846ec1e0f8244b74e67d26987167d9f623a" have entirely different histories.

4 changed files with 4 additions and 116 deletions

View File

@ -28,28 +28,28 @@ void memset64(void * dest, ulong v, size_t n)
v, n, dest); v, n, dest);
} }
void memcpy(void * dest, const(void) * src, size_t n) void memcpy(void * dest, void * src, size_t n)
{ {
__asm("rep movsb", __asm("rep movsb",
"{rcx},{rsi},{rdi},~{rcx},~{rsi},~{rdi},~{memory}", "{rcx},{rsi},{rdi},~{rcx},~{rsi},~{rdi},~{memory}",
n, src, dest); n, src, dest);
} }
void memcpy16(void * dest, const(void) * src, size_t n) void memcpy16(void * dest, void * src, size_t n)
{ {
__asm("rep movsw", __asm("rep movsw",
"{rcx},{rsi},{rdi},~{rcx},~{rsi},~{rdi},~{memory}", "{rcx},{rsi},{rdi},~{rcx},~{rsi},~{rdi},~{memory}",
n, src, dest); n, src, dest);
} }
void memcpy32(void * dest, const(void) * src, size_t n) void memcpy32(void * dest, void * src, size_t n)
{ {
__asm("rep movsl", __asm("rep movsl",
"{rcx},{rsi},{rdi},~{rcx},~{rsi},~{rdi},~{memory}", "{rcx},{rsi},{rdi},~{rcx},~{rsi},~{rdi},~{memory}",
n, src, dest); n, src, dest);
} }
void memcpy64(void * dest, const(void) * src, size_t n) void memcpy64(void * dest, void * src, size_t n)
{ {
__asm("rep movsq", __asm("rep movsq",
"{rcx},{rsi},{rdi},~{rcx},~{rsi},~{rdi},~{memory}", "{rcx},{rsi},{rdi},~{rcx},~{rsi},~{rdi},~{memory}",

View File

@ -1,101 +0,0 @@
/**
* ACPI (Advanced Configuration and Power Interface) functionality.
*/
module hulk.acpi;
import hulk.klog;
import hulk.hurl;
import hulk.klog;
import hos.memory;
struct acpi
{
enum uint APIC_SIGNATURE = 0x43495041u;
enum uint XSDT_SIGNATURE = 0x54445358u;
struct XsdtHeader
{
uint signature;
uint length;
ubyte revision;
ubyte checksum;
char[6] oemid;
ulong oemtableid;
uint oem_revision;
uint creator_id;
uint creator_revision;
};
struct Xsdt
{
XsdtHeader header;
uint _pad;
ulong[0] tables;
}
struct MadtHeader
{
uint signature;
uint length;
ubyte revision;
ubyte checksum;
char[6] oemid;
ulong oemtableid;
uint oem_revision;
uint creator_id;
uint creator_revision;
uint local_apic_address;
uint flags;
}
struct MadtEntry
{
ubyte type;
ubyte length;
}
private static ulong apic_address;
public static void initialize(ulong acpi_xsdt_phys)
{
/* Map the XSDT header. */
Hurl.map_range(acpi_xsdt_phys, Xsdt.sizeof, 0u);
const(Xsdt) * xsdt = cast(const(Xsdt) *)acpi_xsdt_phys;
if (xsdt.header.signature != XSDT_SIGNATURE)
{
klog.writef("XSDT signature invalid\n");
return;
}
/* Map the entire XSDT. */
Hurl.map_range(acpi_xsdt_phys, xsdt.header.length, 0u);
size_t n_entries = (xsdt.header.length - xsdt.header.sizeof) / xsdt.tables[0].sizeof;
for (size_t i = 0u; i < n_entries; i++)
{
ulong address = xsdt.tables[i];
Hurl.map_range(address, 4u, 0u);
uint signature = *cast(const(uint) *)address;
if (signature == APIC_SIGNATURE)
{
parse_apic_table(address);
}
}
}
private static parse_apic_table(ulong address)
{
const(MadtHeader) * madt_header = cast(const(MadtHeader) *)address;
Hurl.map_range(address, madt_header.length, 0u);
apic_address = madt_header.local_apic_address;
const(void) * madt_end = cast(const(void) *)(address + madt_header.length);
const(MadtEntry) * madt_entry = cast(const(MadtEntry) *)(address + 0x2Cu);
while (madt_entry < madt_end)
{
madt_entry = cast(const(MadtEntry) *)(cast(size_t)madt_entry + madt_entry.length);
if (madt_entry.type == 5u)
{
/* Found a 64-bit Local APIC Address Override entry. */
memcpy(cast(void *)&apic_address, cast(const(void) *)madt_entry + 4u, 8u);
}
}
}
}

View File

@ -18,7 +18,6 @@ import hulk.idt;
import hos.cpu; import hos.cpu;
import ldc.llvmasm; import ldc.llvmasm;
import hulk.pic; import hulk.pic;
import hulk.acpi;
extern extern(C) __gshared ubyte _hulk_total_size; extern extern(C) __gshared ubyte _hulk_total_size;
@ -50,7 +49,6 @@ void hulk_start()
hippo.initialize(&hulk_header); hippo.initialize(&hulk_header);
pci.initialize(); pci.initialize();
pic.initialize(); pic.initialize();
acpi.initialize(hulk_header.bootinfo.acpi_xsdt_phys);
sti(); sti();
for (;;) for (;;)

View File

@ -121,13 +121,4 @@ struct Hurl
} }
} }
} }
public static void map_range(size_t address, size_t length, ulong flags)
{
size_t end = address + length;
for (size_t page = address & ~0xFFFu; page < end; page += 0x1000u)
{
map(address, address, flags);
}
}
} }