diff --git a/kernel/arch/i386/gdt.nim b/kernel/arch/i386/gdt.nim index 9fbe04e..a3d4617 100644 --- a/kernel/arch/i386/gdt.nim +++ b/kernel/arch/i386/gdt.nim @@ -69,7 +69,6 @@ proc gdtInstall*() = #gdtSetGate(4, 0'u16, 0xFFFFFFFF'u32, 0xF2, createFlags(true, true)); serial.write("GDT Address:") - serial.write(gdt.descriptor.base) - serial.write("\L") - serial.write("Flushing GDT.\L") + serial.writeLine(gdt.descriptor.base) + serial.writeLine("Flushing GDT.") gdtFlush() diff --git a/kernel/arch/i386/interrupts.nim b/kernel/arch/i386/interrupts.nim index 6475a8b..c6458f8 100644 --- a/kernel/arch/i386/interrupts.nim +++ b/kernel/arch/i386/interrupts.nim @@ -80,17 +80,10 @@ macro generateISR(code: static[uint8], isError: static[bool]): typed = nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("serial"), - newIdentNode("write") + newIdentNode("writeLine") ), newLit(code) ), - nnkCall.newTree( - nnkDotExpr.newTree( - newIdentNode("serial"), - newIdentNode("write") - ), - newLit("\x0A") - ), nnkAsmStmt.newTree( newEmptyNode(), newLit((if isError: "" else: "push 0\x0A") & "push " & $code & "\x0A") @@ -181,5 +174,5 @@ proc idtInstall*() = idtSetGate(29, cast[uint32](isr29), selector, flags) idtSetGate(30, cast[uint32](isr30), selector, flags) idtSetGate(31, cast[uint32](isr31), selector, flags) - serial.write("Flushing IDT.\L") + serial.writeLine("Flushing IDT.") idtFlush() \ No newline at end of file diff --git a/kernel/arch/i386/serial.nim b/kernel/arch/i386/serial.nim index 28ea0ec..39b3614 100644 --- a/kernel/arch/i386/serial.nim +++ b/kernel/arch/i386/serial.nim @@ -21,18 +21,18 @@ proc write*(input: char) = proc write*(input: string) = for i in 0 .. input.len - 1: - write(input[i]) + serial.write(input[i]) var parsedData: array[0..9, char] proc write*(data: SomeSignedInt) = if(data == 0): - write('0') + serial.write('0') return var input = data var i = 0 if(input < 0): - write('-') + serial.write('-') input = input * -1 while(input != 0): let parsedChar: char = char(48 + (input mod 10)) @@ -41,11 +41,11 @@ proc write*(data: SomeSignedInt) = input = input div 10 while i > 0: i = i - 1 - write(parsedData[i]) + serial.write(parsedData[i]) proc write*(data: SomeUnsignedInt) = if(data == 0): - write('0') + serial.write('0') return var input = data var i = 0 @@ -56,6 +56,10 @@ proc write*(data: SomeUnsignedInt) = input = input div 10 while i > 0: i = i - 1 - write(parsedData[i]) + serial.write(parsedData[i]) proc newLine*() = write('\L') + +proc writeLine*(data: any) = + serial.write(data) + newLine() diff --git a/kernel/arch/i386/tty.nim b/kernel/arch/i386/tty.nim index 5817093..2ba31ec 100644 --- a/kernel/arch/i386/tty.nim +++ b/kernel/arch/i386/tty.nim @@ -26,7 +26,7 @@ proc terminalClear*() = terminalRow = 0 terminalColumn = 0 -proc terminalInitialize*() = +proc initialize*() = terminalColour = vgaEntryColour(VGA_Colour.lightGreen, VGA_Colour.red) terminalClear() @@ -58,22 +58,22 @@ proc terminalWriteChar(writeChar: char) = if(terminalColumn == vgaWidth): scrollCheckAndSet() -proc terminalWrite*(data: string) = +proc write*(data: string) = for i in 0 .. data.len - 1: terminalWriteChar(data[i]) -proc terminalWrite*(data: char) = +proc write*(data: char) = terminalWriteChar(data) -proc terminalWrite*(data: SomeSignedInt) = +proc write*(data: SomeSignedInt) = var parsedData: array[0..9, char] if(data == 0): - terminalWrite('0') + tty.write('0') return var input = data var i = 0 if(input < 0): - terminalWrite('-') + tty.write('-') input = input * -1 while(input != 0): let parsedChar: char = char(48 + (input mod 10)) @@ -82,12 +82,12 @@ proc terminalWrite*(data: SomeSignedInt) = input = input div 10 while i > 0: i = i - 1 - terminalWrite(parsedData[i]) + tty.write(parsedData[i]) -proc terminalWrite*(data: SomeUnsignedInt) = +proc write*(data: SomeUnsignedInt) = var parsedData: array[0..9, char] if(data == 0): - terminalWrite('0') + tty.write('0') return var input = data var i = 0 @@ -98,4 +98,8 @@ proc terminalWrite*(data: SomeUnsignedInt) = input = input div 10 while i > 0: i = i - 1 - terminalWrite(parsedData[i]) + tty.write(parsedData[i]) + +proc writeLine*(data: any) = + tty.write(data) + tty.write('\L') \ No newline at end of file diff --git a/kernel/kernel.nim b/kernel/kernel.nim index c7d2a82..fbe8ad2 100644 --- a/kernel/kernel.nim +++ b/kernel/kernel.nim @@ -22,24 +22,19 @@ proc memset*(dest: ByteAddress, value: char, count: int){.exportc.} = proc kernelMain() {.exportc: "kernel_main"}= serial.init() - serial.write("Version:") - serial.write(version) - serial.write("\L") - serial.write("Booting OS\L") + serial.writeLine("Version:" & (version)) + serial.writeLine("Booting OS") gdt.gdtInstall() - serial.write("GDT installed\L") + serial.writeLine("GDT installed") 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") + serial.writeLine("IDT installed") + tty.initialize() + 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)) asm """int $0x3""" \ No newline at end of file diff --git a/kernel/panicoverride.nim b/kernel/panicoverride.nim index 235eecf..7ee166f 100644 --- a/kernel/panicoverride.nim +++ b/kernel/panicoverride.nim @@ -3,7 +3,7 @@ import tty {.push stack_trace: off, profiler:off.} proc rawoutput(s: string) = - tty.terminalWrite(s) + tty.write(s) proc panic(s: string) = rawoutput(s)