45 lines
1.3 KiB
Nim
45 lines
1.3 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.write("Version:")
|
|
serial.write(version)
|
|
serial.write("\L")
|
|
serial.write("Booting OS\L")
|
|
gdt.gdtInstall()
|
|
serial.write("GDT installed\L")
|
|
interrupts.idtInstall()
|
|
serial.write("IDT installed\L")
|
|
terminalInitialize()
|
|
terminalWrite("Version:")
|
|
terminalWrite(version)
|
|
terminalWrite("\L")
|
|
terminalWrite("Hello World!\L")
|
|
terminalWrite("MAX_INT:")
|
|
terminalWrite(high(int))
|
|
terminalWrite("\LMIN_INT:")
|
|
terminalWrite(low(int)+1)
|
|
terminalWrite("\LMAX_UINT:")
|
|
terminalWrite(high(uint32))
|
|
terminalWrite("\L")
|
|
asm """int $0x3""" |