Kernel: Move debug printing to its own file
It didn't make sense that dprint was defined in Serial.h. We also now dump dprint to tty if there is no serial and tty is initialized
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
#include <BAN/ScopeGuard.h>
|
||||
#include <kernel/Debug.h>
|
||||
#include <kernel/APIC.h>
|
||||
#include <kernel/CPUID.h>
|
||||
#include <kernel/IDT.h>
|
||||
#include <kernel/IO.h>
|
||||
#include <kernel/MMU.h>
|
||||
#include <kernel/Serial.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
16
kernel/kernel/Debug.cpp
Normal file
16
kernel/kernel/Debug.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <kernel/Debug.h>
|
||||
#include <kernel/Serial.h>
|
||||
#include <kernel/TTY.h>
|
||||
|
||||
namespace Debug
|
||||
{
|
||||
|
||||
void putchar(char ch)
|
||||
{
|
||||
if (Serial::IsInitialized())
|
||||
return Serial::putchar(ch);
|
||||
if (TTY::IsInitialized())
|
||||
return TTY::PutCharCurrent(ch);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
#include <BAN/Queue.h>
|
||||
#include <kernel/Debug.h>
|
||||
#include <kernel/IDT.h>
|
||||
#include <kernel/Input.h>
|
||||
#include <kernel/InterruptController.h>
|
||||
#include <kernel/IO.h>
|
||||
#include <kernel/kprint.h>
|
||||
#include <kernel/PIT.h>
|
||||
#include <kernel/Serial.h>
|
||||
|
||||
#include <kernel/KeyboardLayout/FI.h>
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace Kernel
|
||||
};
|
||||
|
||||
stackframe* frame = (stackframe*)__builtin_frame_address(0);
|
||||
BAN::Formatter::print(Serial::serial_putc, "\e[36mStack trace:\r\n");
|
||||
BAN::Formatter::print(Debug::putchar, "\e[36mStack trace:\r\n");
|
||||
while (frame)
|
||||
{
|
||||
BAN::Formatter::print(Serial::serial_putc, " {}\r\n", (void*)frame->eip);
|
||||
BAN::Formatter::print(Debug::putchar, " {}\r\n", (void*)frame->eip);
|
||||
frame = frame->ebp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <BAN/Errors.h>
|
||||
#include <kernel/IO.h>
|
||||
#include <kernel/Serial.h>
|
||||
|
||||
#define COM1_PORT 0x3f8
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Serial
|
||||
|
||||
static bool s_initialized = false;
|
||||
|
||||
void initialize()
|
||||
void Initialize()
|
||||
{
|
||||
IO::outb(COM1_PORT + 1, 0x00); // Disable all interrupts
|
||||
IO::outb(COM1_PORT + 3, 0x80); // Enable DLAB (set baud rate divisor)
|
||||
@@ -30,14 +30,18 @@ namespace Serial
|
||||
s_initialized = true;
|
||||
}
|
||||
|
||||
int is_transmit_empty() {
|
||||
bool IsInitialized()
|
||||
{
|
||||
return s_initialized;
|
||||
}
|
||||
|
||||
static int is_transmit_empty() {
|
||||
return IO::inb(COM1_PORT + 5) & 0x20;
|
||||
}
|
||||
|
||||
void serial_putc(char c)
|
||||
void putchar(char c)
|
||||
{
|
||||
if (!s_initialized)
|
||||
return;
|
||||
ASSERT(s_initialized);
|
||||
while (is_transmit_empty() == 0);
|
||||
IO::outb(COM1_PORT, c);
|
||||
}
|
||||
|
||||
@@ -2,14 +2,11 @@
|
||||
#include <BAN/StringView.h>
|
||||
#include <BAN/Vector.h>
|
||||
#include <kernel/CPUID.h>
|
||||
#include <kernel/font.h>
|
||||
#include <kernel/Input.h>
|
||||
#include <kernel/IO.h>
|
||||
#include <kernel/PIT.h>
|
||||
#include <kernel/RTC.h>
|
||||
#include <kernel/Serial.h>
|
||||
#include <kernel/Shell.h>
|
||||
#include <kernel/TTY.h>
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <BAN/Errors.h>
|
||||
#include <kernel/Serial.h>
|
||||
#include <kernel/Debug.h>
|
||||
#include <kernel/TTY.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <BAN/Errors.h>
|
||||
#include <kernel/Debug.h>
|
||||
#include <kernel/MMU.h>
|
||||
#include <kernel/multiboot.h>
|
||||
#include <kernel/Serial.h>
|
||||
#include <kernel/VesaTerminalDriver.h>
|
||||
|
||||
extern const struct bitmap_font font;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <kernel/Debug.h>
|
||||
#include <kernel/IDT.h>
|
||||
#include <kernel/Input.h>
|
||||
#include <kernel/InterruptController.h>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <BAN/Errors.h>
|
||||
#include <BAN/Math.h>
|
||||
#include <kernel/kmalloc.h>
|
||||
#include <kernel/kprint.h>
|
||||
#include <kernel/multiboot.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
Reference in New Issue
Block a user