alcedo/kernel/kernel.nim

34 lines
896 B
Nim
Raw Normal View History

{.link: "boot.o".}
{.passL: "-T kernel/arch/i386/linker.ld".}
2017-11-08 02:36:35 +00:00
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"}=
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")
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')