From 872e6f33928d9247bf9901a624611fb6f36190bf Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Wed, 17 May 2023 20:42:59 -0700 Subject: [PATCH] Add a debug output utility. --- zion/CMakeLists.txt | 6 ++++++ zion/debug/debug.cpp | 13 +++++++++++++ zion/debug/debug.h | 3 +++ zion/zion.cpp | 6 ++---- 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 zion/debug/debug.cpp create mode 100644 zion/debug/debug.h diff --git a/zion/CMakeLists.txt b/zion/CMakeLists.txt index 45734b4..eb74bc5 100644 --- a/zion/CMakeLists.txt +++ b/zion/CMakeLists.txt @@ -1,6 +1,12 @@ add_executable(zion + debug/debug.cpp zion.cpp) +target_include_directories(zion + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ) + # -c -- Don't run the linker. # -nostdlib -- Don't include the standard library. # -mabi=sysv -- Explicitly specify the ABI since we will rely on it. diff --git a/zion/debug/debug.cpp b/zion/debug/debug.cpp new file mode 100644 index 0000000..856765e --- /dev/null +++ b/zion/debug/debug.cpp @@ -0,0 +1,13 @@ +#include "debug/debug.h" + +#include "common/port.h" + +#define COM1 0x3f8 + +void dbgln(const char* str) { + while (*str != 0) { + outb(COM1, *str); + str++; + } + outb(COM1, '\n'); +} diff --git a/zion/debug/debug.h b/zion/debug/debug.h new file mode 100644 index 0000000..634a3b7 --- /dev/null +++ b/zion/debug/debug.h @@ -0,0 +1,3 @@ +#pragma once + +void dbgln(const char *str); diff --git a/zion/zion.cpp b/zion/zion.cpp index 8e59f54..c4d5aab 100644 --- a/zion/zion.cpp +++ b/zion/zion.cpp @@ -1,11 +1,9 @@ #include -#include "common/port.h" - -#define COM1 0x3f8 +#include "debug/debug.h" extern "C" void zion() { - outb(COM1, 'a'); + dbgln("Hello World!"); while (1) ;