2017-11-08 13:46:39 +00:00
|
|
|
{.link: "boot.o".}
|
2018-04-26 04:10:03 +01:00
|
|
|
{.passL: "-ffreestanding -target i386 -nostdlib -T kernel/arch/i386/linker.ld".}
|
|
|
|
{.passC: "-ffreestanding -nostdlib --target=i386-pc-none-elf -march=i386".}
|
2017-11-08 13:46:39 +00:00
|
|
|
|
2018-04-26 04:10:03 +01:00
|
|
|
import tty, gdt, serial
|
2017-10-21 19:23:17 +01:00
|
|
|
|
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()
|
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")
|
2017-10-21 19:23:17 +01:00
|
|
|
terminalInitialize()
|
2017-10-22 00:44:01 +01:00
|
|
|
terminalWrite("Hello World!\L")
|
|
|
|
terminalWrite("MAX_INT:")
|
|
|
|
terminalWrite(high(int))
|
|
|
|
terminalWrite("\LMIN_INT:")
|
|
|
|
terminalWrite(low(int32)+1)
|
2017-10-22 01:54:51 +01:00
|
|
|
for i in 0..22:
|
|
|
|
terminalWrite(i)
|
|
|
|
terminalWrite('\L')
|