alcedo/kernel/kernel.nim

36 lines
1.1 KiB
Nim
Raw Normal View History

{.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
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"}=
2017-11-08 02:36:35 +00:00
serial.init()
2017-11-09 23:21:18 +00:00
serial.write("Booting OS\L")
2017-11-06 21:44:17 +00:00
gdt.gdtInstall()
2017-11-09 23:21:18 +00:00
serial.write("GDT installed\L")
interrupts.idtInstall()
serial.write("IDT installed\L")
terminalInitialize()
terminalWrite("Hello World!\L")
terminalWrite("MAX_INT:")
terminalWrite(high(int))
terminalWrite("\LMIN_INT:")
2018-04-28 01:04:09 +01:00
terminalWrite(low(int)+1)
terminalWrite("\LMAX_UINT:")
terminalWrite(high(uint32))
terminalWrite("\L")