Move hos.* modules to hulk.*
This commit is contained in:
1 parent
4a431f7d93
commit
476ae7d6fd
9 files changed
+20
-10
No files matched your search
+1
-1
@@ -5,7 +5,7 @@ module hulk.acpi;
|
||||
|
||||
import hulk.hurl;
|
||||
import hulk.klog;
|
||||
import hos.memory;
|
||||
import hulk.memory;
|
||||
|
||||
struct acpi
|
||||
{
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* CPU functionality.
|
||||
*/
|
||||
module hulk.cpu;
|
||||
|
||||
import ldc.llvmasm;
|
||||
|
||||
void cli()
|
||||
{
|
||||
__asm("cli", "");
|
||||
}
|
||||
|
||||
void sti()
|
||||
{
|
||||
__asm("sti", "");
|
||||
}
|
||||
|
||||
void hlt()
|
||||
{
|
||||
__asm("hlt", "");
|
||||
}
|
||||
|
||||
ulong read_cr0()
|
||||
{
|
||||
return __asm!ulong("mov %cr0, %rax", "={rax}");
|
||||
}
|
||||
|
||||
ulong read_cr2()
|
||||
{
|
||||
return __asm!ulong("mov %cr2, %rax", "={rax}");
|
||||
}
|
||||
|
||||
ulong read_cr3()
|
||||
{
|
||||
return __asm!ulong("mov %cr3, %rax", "={rax}");
|
||||
}
|
||||
|
||||
void write_cr3(ulong v)
|
||||
{
|
||||
__asm("mov $0, %cr3", "r", v);
|
||||
}
|
||||
|
||||
ulong read_cr4()
|
||||
{
|
||||
return __asm!ulong("mov %cr4, %rax", "={rax}");
|
||||
}
|
||||
|
||||
ubyte in8(ushort ioaddr)
|
||||
{
|
||||
return __asm!ubyte("inb %dx, %al", "={al},{dx}", ioaddr);
|
||||
}
|
||||
|
||||
ushort in16(ushort ioaddr)
|
||||
{
|
||||
return __asm!ushort("inw %dx, %ax", "={ax},{dx}", ioaddr);
|
||||
}
|
||||
|
||||
ulong in32(ushort ioaddr)
|
||||
{
|
||||
return __asm!ulong("inl %dx, %eax", "={eax},{dx}", ioaddr);
|
||||
}
|
||||
|
||||
void out8(ushort ioaddr, ubyte v)
|
||||
{
|
||||
__asm("outb %al, %dx", "{dx},{al}", ioaddr, v);
|
||||
}
|
||||
|
||||
void out16(ushort ioaddr, ushort v)
|
||||
{
|
||||
__asm("outw %ax, %dx", "{dx},{ax}", ioaddr, v);
|
||||
}
|
||||
|
||||
void out32(ushort ioaddr, ulong v)
|
||||
{
|
||||
__asm("outl %eax, %dx", "{dx},{eax}", ioaddr, v);
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
module hulk.fb;
|
||||
|
||||
import hos.memory;
|
||||
import hulk.memory;
|
||||
import hulk.kfont;
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ module hulk.hulk;
|
||||
import hulk.header;
|
||||
import hulk.fb;
|
||||
import hulk.console;
|
||||
import hos.memory;
|
||||
import hulk.memory;
|
||||
import ldc.attributes;
|
||||
import hulk.kfont;
|
||||
import hulk.klog;
|
||||
@@ -15,7 +15,7 @@ import hulk.hippo;
|
||||
import hulk.pci;
|
||||
import hulk.gdt;
|
||||
import hulk.idt;
|
||||
import hos.cpu;
|
||||
import hulk.cpu;
|
||||
import ldc.llvmasm;
|
||||
import hulk.pic;
|
||||
import hulk.acpi;
|
||||
|
||||
+2
-2
@@ -6,9 +6,9 @@
|
||||
module hulk.hurl;
|
||||
|
||||
public import hulk.pagetable;
|
||||
import hos.cpu;
|
||||
import hulk.cpu;
|
||||
import hulk.hippo;
|
||||
import hos.memory;
|
||||
import hulk.memory;
|
||||
import hulk.klog;
|
||||
import hulk.header;
|
||||
import hulk.linker_addresses;
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Memory-related functions.
|
||||
*/
|
||||
module hulk.memory;
|
||||
|
||||
import ldc.llvmasm;
|
||||
|
||||
void memset(void * dest, ubyte v, size_t n)
|
||||
{
|
||||
__asm("rep stosb",
|
||||
"{al},{rcx},{rdi},~{rcx},~{rdi},~{memory}",
|
||||
v, n, dest);
|
||||
}
|
||||
|
||||
void memset16(void * dest, ushort v, size_t n)
|
||||
{
|
||||
__asm("rep stosw",
|
||||
"{ax},{rcx},{rdi},~{rcx},~{rdi},~{memory}",
|
||||
v, n, dest);
|
||||
}
|
||||
|
||||
void memset32(void * dest, uint v, size_t n)
|
||||
{
|
||||
__asm("rep stosl",
|
||||
"{eax},{rcx},{rdi},~{rcx},~{rdi},~{memory}",
|
||||
v, n, dest);
|
||||
}
|
||||
|
||||
void memset64(void * dest, ulong v, size_t n)
|
||||
{
|
||||
__asm("rep stosq",
|
||||
"{rax},{rcx},{rdi},~{rcx},~{rdi},~{memory}",
|
||||
v, n, dest);
|
||||
}
|
||||
|
||||
void memcpy(void * dest, const(void) * src, size_t n)
|
||||
{
|
||||
__asm("rep movsb",
|
||||
"{rcx},{rsi},{rdi},~{rcx},~{rsi},~{rdi},~{memory}",
|
||||
n, src, dest);
|
||||
}
|
||||
|
||||
void memcpy16(void * dest, const(void) * src, size_t n)
|
||||
{
|
||||
__asm("rep movsw",
|
||||
"{rcx},{rsi},{rdi},~{rcx},~{rsi},~{rdi},~{memory}",
|
||||
n, src, dest);
|
||||
}
|
||||
|
||||
void memcpy32(void * dest, const(void) * src, size_t n)
|
||||
{
|
||||
__asm("rep movsl",
|
||||
"{rcx},{rsi},{rdi},~{rcx},~{rsi},~{rdi},~{memory}",
|
||||
n, src, dest);
|
||||
}
|
||||
|
||||
void memcpy64(void * dest, const(void) * src, size_t n)
|
||||
{
|
||||
__asm("rep movsq",
|
||||
"{rcx},{rsi},{rdi},~{rcx},~{rsi},~{rdi},~{memory}",
|
||||
n, src, dest);
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
module hulk.pci;
|
||||
|
||||
import hos.cpu;
|
||||
import hulk.cpu;
|
||||
import hulk.klog;
|
||||
|
||||
struct pci
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
module hulk.pic;
|
||||
|
||||
import hos.cpu;
|
||||
import hulk.cpu;
|
||||
|
||||
struct pic
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user