From fad439c25e58fdb467e4f170b42b7bff315963a7 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Tue, 1 May 2018 19:24:29 +0100 Subject: [PATCH] Added integer hash function. Other minor changes. --- kernel/arch/i386/hash.nim | 9 +++++++++ kernel/arch/i386/interrupts.nim | 2 +- kernel/arch/i386/linker.ld | 1 + kernel/arch/i386/ps2.nim | 16 ---------------- kernel/nim.cfg | 3 ++- 5 files changed, 13 insertions(+), 18 deletions(-) create mode 100644 kernel/arch/i386/hash.nim delete mode 100644 kernel/arch/i386/ps2.nim diff --git a/kernel/arch/i386/hash.nim b/kernel/arch/i386/hash.nim new file mode 100644 index 0000000..e3d5864 --- /dev/null +++ b/kernel/arch/i386/hash.nim @@ -0,0 +1,9 @@ +const + FNVPrime = 16777619'u32 + FNVOffsetBasis = 0x811c9dc5'u32 + +proc fnv1a*(data: varargs[uint8]): uint32 = + result = FNVOffsetBasis + for i in data: + result = result xor i + result = result * FNVPrime \ No newline at end of file diff --git a/kernel/arch/i386/interrupts.nim b/kernel/arch/i386/interrupts.nim index c6458f8..fb8ee6f 100644 --- a/kernel/arch/i386/interrupts.nim +++ b/kernel/arch/i386/interrupts.nim @@ -56,7 +56,7 @@ proc isrCommon(){.asmNoStackFrame,exportc.} = """ ]# -macro generateISR(code: static[uint8], isError: static[bool]): typed = +macro generateISR(code: static[int], isError: static[bool]): typed = result = nnkStmtList.newTree( nnkProcDef.newTree( newIdentNode("isr" & $code), diff --git a/kernel/arch/i386/linker.ld b/kernel/arch/i386/linker.ld index 91ac91c..e496e22 100644 --- a/kernel/arch/i386/linker.ld +++ b/kernel/arch/i386/linker.ld @@ -1,5 +1,6 @@ /* http://wiki.osdev.org/Bare_Bones#Linking_the_Kernel */ ENTRY(_start) +OUTPUT_FORMAT(elf32-i386) SECTIONS { diff --git a/kernel/arch/i386/ps2.nim b/kernel/arch/i386/ps2.nim deleted file mode 100644 index 6c703fe..0000000 --- a/kernel/arch/i386/ps2.nim +++ /dev/null @@ -1,16 +0,0 @@ -import io - -const keyboardAddress = 0x60 - -type - KeypressEvent* = tuple - character: char - pressed: bool - -proc getScancode(): char = - while true: - let c = io.inb(keyboardAddress) - if(c > 0): return c - -proc getChar*(): char = - discard # TODO: Implement lookup to a scan table to get actual character diff --git a/kernel/nim.cfg b/kernel/nim.cfg index 486914a..c8a1e94 100644 --- a/kernel/nim.cfg +++ b/kernel/nim.cfg @@ -7,4 +7,5 @@ deadCodeElim=on boundChecks=on gc=regions cpu=i386 -os=standalone \ No newline at end of file +os=standalone +verbosity=2 \ No newline at end of file