2018-04-26 04:12:16 +01:00
|
|
|
{.link: "../boot.o".}
|
|
|
|
{.passL: "-ffreestanding -target i386 -nostdlib -T arch/i386/linker.ld".}
|
2018-04-26 04:10:03 +01:00
|
|
|
{.passC: "-ffreestanding -nostdlib --target=i386-pc-none-elf -march=i386".}
|
2017-11-08 13:46:39 +00:00
|
|
|
|
2018-04-26 05:36:16 +01:00
|
|
|
import tty, gdt, interrupts, serial
|
2017-10-21 19:23:17 +01:00
|
|
|
|
2018-04-28 16:01:26 +01:00
|
|
|
const version {.strdefine.} = "UNKNOWN"
|
|
|
|
|
2017-11-16 17:07:52 +00:00
|
|
|
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
|
|
|
|
|
2017-10-21 19:23:17 +01:00
|
|
|
proc kernelMain() {.exportc: "kernel_main"}=
|
2017-11-08 02:36:35 +00:00
|
|
|
serial.init()
|
2018-04-28 22:22:05 +01:00
|
|
|
serial.writeLine("Version:" & (version))
|
|
|
|
serial.writeLine("Booting OS")
|
2017-11-06 21:44:17 +00:00
|
|
|
gdt.gdtInstall()
|
2018-04-28 22:22:05 +01:00
|
|
|
serial.writeLine("GDT installed")
|
2018-04-26 05:36:16 +01:00
|
|
|
interrupts.idtInstall()
|
2018-04-28 22:22:05 +01:00
|
|
|
serial.writeLine("IDT installed")
|
2018-05-02 23:02:46 +01:00
|
|
|
tty.init()
|
2018-04-28 22:22:05 +01:00
|
|
|
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))
|
2018-04-28 21:39:28 +01:00
|
|
|
asm """int $0x3"""
|