alcedo/kernel/kernel.nim

34 lines
896 B
Nim

{.link: "boot.o".}
{.passL: "-T kernel/arch/i386/linker.ld".}
import tty, gdt, irq, serial
type
MemoryPointer{.unchecked.} = ptr array[0, char]
proc memcpy*(dest: ByteAddress, src: ByteAddress, count: int){.exportc.} =
var destMem = cast[MemoryPointer](dest)
var srcMem = cast[MemoryPointer](src)
for i in 0..count-1:
destMem[i] = srcMem[i]
proc memset*(dest: ByteAddress, value: char, count: int){.exportc.} =
var destMem = cast[MemoryPointer](dest)
for i in 0..count-1:
destMem[i] = value
proc kernelMain() {.exportc: "kernel_main"}=
serial.init()
serial.write("Booting OS\L")
gdt.gdtInstall()
serial.write("GDT installed\L")
terminalInitialize()
terminalWrite("Hello World!\L")
terminalWrite("MAX_INT:")
terminalWrite(high(int))
terminalWrite("\LMIN_INT:")
terminalWrite(low(int32)+1)
for i in 0..22:
terminalWrite(i)
terminalWrite('\L')