Moved from a flat directory structure to a more sane one.
This commit is contained in:
parent
2b59ba0f2e
commit
77e4e91b73
@ -1,27 +1,4 @@
|
||||
type
|
||||
VGA_Colour {.pure.} = enum
|
||||
black = 0,
|
||||
blue = 1,
|
||||
green = 2,
|
||||
cyan = 3,
|
||||
red = 4,
|
||||
magenta = 5,
|
||||
brown = 6,
|
||||
lightGrey = 7,
|
||||
darkGrey = 8,
|
||||
lightBlue = 9,
|
||||
lightGreen = 10,
|
||||
lightCyan = 11,
|
||||
lightRed = 12,
|
||||
lightMagenta = 13,
|
||||
lightBrown = 14,
|
||||
white = 15
|
||||
|
||||
proc vgaEntryColour(fg: VGA_Colour, bg: VGA_Colour): int =
|
||||
result = ord(fg) or (ord(bg) shl 4)
|
||||
|
||||
proc vgaEntry(c: char, colour: int): int16 =
|
||||
result = int16(int(c) or (colour shl 8))
|
||||
import vga
|
||||
|
||||
const
|
||||
vgaWidth = 80
|
||||
@ -35,9 +12,9 @@ var
|
||||
|
||||
proc terminalWriteAtPoint(writeChar: char, colour: int, xPos: int, yPos: int) =
|
||||
let index = terminalBufferBaseAddress + (yPos * bufferWidthSkip + (xPos * 2))
|
||||
cast[ptr int16](index)[] = vgaEntry(writeChar, terminalColour) # Write directly to display memory
|
||||
cast[ptr int16](index)[] = vga.vgaEntry(writeChar, terminalColour) # Write directly to display memory
|
||||
|
||||
proc terminalInitialize() =
|
||||
proc terminalInitialize*() =
|
||||
terminalColour = vgaEntryColour(VGA_Colour.lightGreen, VGA_Colour.red)
|
||||
for x in 0..<vgaWidth:
|
||||
for y in 0..<vgaHeight:
|
||||
@ -59,11 +36,6 @@ proc terminalWriteChar(writeChar: char) =
|
||||
inc(terminalRow)
|
||||
if(terminalRow == vgaHeight): terminalRow = 0
|
||||
|
||||
proc terminalWrite(data: string) =
|
||||
proc terminalWrite*(data: string) =
|
||||
for character in data:
|
||||
terminalWriteChar(character)
|
||||
|
||||
proc kernelMain() {.exportc: "kernel_main"}=
|
||||
terminalInitialize()
|
||||
terminalWrite("Hello World!\LNim here!")
|
||||
|
24
kernel/arch/i386/vga.nim
Normal file
24
kernel/arch/i386/vga.nim
Normal file
@ -0,0 +1,24 @@
|
||||
type
|
||||
VGA_Colour* {.pure.} = enum
|
||||
black = 0,
|
||||
blue = 1,
|
||||
green = 2,
|
||||
cyan = 3,
|
||||
red = 4,
|
||||
magenta = 5,
|
||||
brown = 6,
|
||||
lightGrey = 7,
|
||||
darkGrey = 8,
|
||||
lightBlue = 9,
|
||||
lightGreen = 10,
|
||||
lightCyan = 11,
|
||||
lightRed = 12,
|
||||
lightMagenta = 13,
|
||||
lightBrown = 14,
|
||||
white = 15
|
||||
|
||||
proc vgaEntryColour*(fg: VGA_Colour, bg: VGA_Colour): int =
|
||||
result = ord(fg) or (ord(bg) shl 4)
|
||||
|
||||
proc vgaEntry*(c: char, colour: int): int16 =
|
||||
result = int16(int(c) or (colour shl 8))
|
5
kernel/kernel.nim
Normal file
5
kernel/kernel.nim
Normal file
@ -0,0 +1,5 @@
|
||||
import tty
|
||||
|
||||
proc kernelMain() {.exportc: "kernel_main"}=
|
||||
terminalInitialize()
|
||||
terminalWrite("Hello World!\LNim here!")
|
6
makefile
6
makefile
@ -1,10 +1,10 @@
|
||||
all: kernel
|
||||
|
||||
kernel: bootloader
|
||||
nim cc kernel.nim
|
||||
nim cc --skipCfg kernel/kernel.nim
|
||||
|
||||
bootloader:
|
||||
nasm -felf32 boot.s -o boot.o
|
||||
nasm -felf32 kernel/arch/i386/boot.s -o boot.o
|
||||
|
||||
clean:
|
||||
rm -r kernel nimcache/ boot.o
|
||||
rm -r myos.bin nimcache/ boot.o
|
||||
|
7
nim.cfg
7
nim.cfg
@ -1,9 +1,10 @@
|
||||
--cc:clang
|
||||
--clang.linkerexe=clang
|
||||
--clang.linkerexe="clang"
|
||||
--gc:none
|
||||
--deadCodeElim:on
|
||||
--path:"kernel/arch/i386"
|
||||
--cpu:i386
|
||||
--os:standalone
|
||||
--passC:"-ffreestanding -nostdlib --target=i686-pc-none-elf -march=i686"
|
||||
--passL:"-target i386 -nostdlib -T linker.ld boot.o"
|
||||
-o:myos.bin
|
||||
--passL:"-target i386 -nostdlib -T ./kernel/arch/i386/linker.ld boot.o"
|
||||
--out:"myos.bin"
|
||||
|
Loading…
Reference in New Issue
Block a user