alcedo/kernel/kernel.nim

40 lines
1.2 KiB
Nim

{.link: "../boot.o".}
{.passL: "-ffreestanding -target i386 -nostdlib -T arch/i386/linker.ld".}
{.passC: "-ffreestanding -nostdlib --target=i386-pc-none-elf -march=i386".}
import tty, gdt, interrupts, serial
const version {.strdefine.} = "UNKNOWN"
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.writeLine("Version:" & (version))
serial.writeLine("Booting OS")
gdt.gdtInstall()
serial.writeLine("GDT installed")
interrupts.idtInstall()
serial.writeLine("IDT installed")
tty.initialize()
tty.writeLine("Version:" & version)
tty.writeLine("Hello World!")
tty.write("MAX_INT:")
tty.writeLine(high(int))
tty.write("LMIN_INT:")
tty.writeLine((low(int)+1))
tty.write("MAX_UINT:")
tty.writeLine(high(uint32))
asm """int $0x3"""