From d1866c5e93c08215bc9d11206ebdb639ff116a87 Mon Sep 17 00:00:00 2001 From: shockrah Date: Sat, 9 Nov 2019 17:24:41 -0800 Subject: [PATCH] added kprintf and kprintp as random useful things to have also changed bochsrc master path to jos.iso --- bochsrc.conf | 2 +- kernel.c | 15 +++++++++++++++ kernel.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bochsrc.conf b/bochsrc.conf index b8ca884..c3dfabf 100644 --- a/bochsrc.conf +++ b/bochsrc.conf @@ -2,7 +2,7 @@ megs: 32 display_library: x, options="gui_debug" romimage: file=/usr/share/bochs/BIOS-bochs-latest vgaromimage: file=/usr/share/bochs/VGABIOS-lgpl-latest -ata0-master: type=cdrom, path=os.iso, status=inserted +ata0-master: type=cdrom, path=jos.iso, status=inserted boot: cdrom log: bochslog.txt clock: sync=realtime, time0=local diff --git a/kernel.c b/kernel.c index 4621e21..ff452ff 100644 --- a/kernel.c +++ b/kernel.c @@ -11,6 +11,21 @@ void kinit() { test_dispatcher(); } +void kprintp(const u32 ptr) { + // Prints our hex version of whatever is given + const char _chars[] = "0123456789abcdef"; + u32 idx = 0; // used as hash into the _chars mapping + // iterate over each nibble + for(u32 i = 0 ;i < 7;i++) { + idx = (ptr << (i * 4)) & 0xf0000000; + idx = idx >> 28; + putch(_chars[idx]); + } +} + +void kprints(const char* s) { + printf(s); +} void kmain() { kinit(); diff --git a/kernel.h b/kernel.h index 0cf4dc0..9b1f01f 100644 --- a/kernel.h +++ b/kernel.h @@ -1,4 +1,6 @@ #include "types.h" void kinit(); +void kprintp(const u32); +void kprints(const char*); void kmain();