Switch to logging functions everywhere
This commit is contained in:
parent
d2856d8812
commit
985d45ddfb
@ -1,4 +1,5 @@
|
||||
#include "arch/Timer.h"
|
||||
#include "Log.h"
|
||||
#include "arch/Serial.h"
|
||||
#include "boot/bootboot.h"
|
||||
#include <Result.h>
|
||||
@ -46,8 +47,7 @@ static u64 bootloader_time_to_unix(u8 boottime[8])
|
||||
int second = bcd_number_to_decimal(boottime[6]);
|
||||
// "The last byte can store 1/100th second precision, but in lack of support on most platforms, it is 0x00".
|
||||
// Therefore, let's not rely on it.
|
||||
Serial::printf("Current time: %.2d/%.2d/%d %.2d:%.2d:%.2d UTC\n", day, month, year, hour, minute, second)
|
||||
.release_value();
|
||||
kinfoln("Current time: %.2d/%.2d/%d %.2d:%.2d:%.2d UTC", day, month, year, hour, minute, second).release_value();
|
||||
return broken_down_to_unix(year - 1900, make_yday(year, month) + (day - 1), hour, minute, second);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "arch/x86_64/CPU.h"
|
||||
#include "Log.h"
|
||||
#include "arch/Serial.h"
|
||||
#include "arch/Timer.h"
|
||||
#include "arch/x86_64/IO.h"
|
||||
@ -275,7 +276,7 @@ static void setup_idt()
|
||||
// Interrupt handling
|
||||
|
||||
#define FIXME_UNHANDLED_INTERRUPT(name) \
|
||||
Serial::println("FIXME(interrupt): " name); \
|
||||
kerrorln("FIXME(interrupt): %s", name); \
|
||||
CPU::efficient_halt();
|
||||
|
||||
extern "C" void handle_x86_exception([[maybe_unused]] Registers* regs)
|
||||
@ -315,20 +316,20 @@ extern "C" void arch_interrupt_entry(Registers* regs)
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial::println("IRQ catched! Halting.");
|
||||
kwarnln("IRQ catched! Halting.");
|
||||
CPU::efficient_halt();
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" [[noreturn]] void arch_double_fault()
|
||||
{
|
||||
Serial::println("ERROR: Catched double fault");
|
||||
kerrorln("ERROR: Catched double fault");
|
||||
CPU::efficient_halt();
|
||||
}
|
||||
|
||||
extern "C" [[noreturn]] void arch_machine_check()
|
||||
{
|
||||
Serial::println("ERROR: Machine check failed");
|
||||
kerrorln("ERROR: Machine check failed");
|
||||
CPU::efficient_halt();
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ void Init::check_magic()
|
||||
{
|
||||
if (memcmp(bootboot.magic, BOOTBOOT_MAGIC, 4))
|
||||
{
|
||||
Serial::println("ERROR: Invalid magic value from bootloader");
|
||||
kerrorln("ERROR: Invalid magic value from bootloader");
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
|
@ -11,11 +11,11 @@
|
||||
|
||||
Result<void> init()
|
||||
{
|
||||
Serial::println("Hello, world!");
|
||||
kinfoln("Hello, world!");
|
||||
|
||||
Serial::printf("Current platform: %s\n", CPU::platform_string());
|
||||
kinfoln("Current platform: %s", CPU::platform_string());
|
||||
|
||||
Serial::println(TRY(CPU::identify()));
|
||||
kinfoln("Current processor: %s", TRY(CPU::identify()));
|
||||
|
||||
Timer::init();
|
||||
|
||||
@ -41,6 +41,6 @@ extern "C" [[noreturn]] void _start()
|
||||
Init::check_magic();
|
||||
Init::early_init();
|
||||
auto rc = init();
|
||||
rc.release_value();
|
||||
if (rc.has_error()) kerrorln("Runtime error: %s", rc.error_string());
|
||||
CPU::efficient_halt();
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include "memory/Heap.h"
|
||||
#include "Log.h"
|
||||
#include "arch/MMU.h"
|
||||
#include "arch/Serial.h"
|
||||
#include "memory/MemoryManager.h"
|
||||
@ -240,17 +241,17 @@ Result<void> kfree(void* ptr)
|
||||
{
|
||||
if (block->magic == BLOCK_DEAD)
|
||||
{
|
||||
Serial::printf("ERROR: Attempt to free memory at %p, which was already freed\n", ptr);
|
||||
kerrorln("ERROR: Attempt to free memory at %p, which was already freed", ptr);
|
||||
}
|
||||
else
|
||||
Serial::printf("ERROR: Attempt to free memory at %p, which wasn't allocated with kmalloc\n", ptr);
|
||||
kerrorln("ERROR: Attempt to free memory at %p, which wasn't allocated with kmalloc", ptr);
|
||||
|
||||
return err(EFAULT);
|
||||
}
|
||||
|
||||
if (is_block_free(block))
|
||||
{
|
||||
Serial::printf("ERROR: Attempt to free memory at %p, which was already freed\n", ptr);
|
||||
kerrorln("ERROR: Attempt to free memory at %p, which was already freed", ptr);
|
||||
return err(EFAULT);
|
||||
}
|
||||
else
|
||||
@ -296,10 +297,10 @@ Result<void*> krealloc(void* ptr, usize size)
|
||||
{
|
||||
if (block->magic == BLOCK_DEAD)
|
||||
{
|
||||
Serial::printf("ERROR: Attempt to realloc memory at %p, which was already freed\n", ptr);
|
||||
kerrorln("ERROR: Attempt to realloc memory at %p, which was already freed", ptr);
|
||||
}
|
||||
else
|
||||
Serial::printf("ERROR: Attempt to realloc memory at %p, which wasn't allocated with kmalloc\n", ptr);
|
||||
kerrorln("ERROR: Attempt to realloc memory at %p, which wasn't allocated with kmalloc", ptr);
|
||||
|
||||
return err(EFAULT);
|
||||
}
|
||||
@ -308,7 +309,7 @@ Result<void*> krealloc(void* ptr, usize size)
|
||||
|
||||
if (is_block_free(block))
|
||||
{
|
||||
Serial::printf("ERROR: Attempt to realloc memory at %p, which was already freed\n", ptr);
|
||||
kerrorln("ERROR: Attempt to realloc memory at %p, which was already freed", ptr);
|
||||
return err(EFAULT);
|
||||
}
|
||||
|
||||
@ -336,10 +337,10 @@ Result<void*> kcalloc(usize nmemb, usize size)
|
||||
|
||||
void dump_heap_usage()
|
||||
{
|
||||
Serial::println("-- Dumping usage stats for kernel heap:");
|
||||
kdbgln("-- Dumping usage stats for kernel heap:");
|
||||
if (!heap_start)
|
||||
{
|
||||
Serial::println("- Heap is not currently being used");
|
||||
kdbgln("- Heap is not currently being used");
|
||||
return;
|
||||
}
|
||||
usize alloc_total = 0;
|
||||
@ -349,19 +350,18 @@ void dump_heap_usage()
|
||||
{
|
||||
if (is_block_free(block))
|
||||
{
|
||||
Serial::printf("- Available block, of size %zu\n", block->full_size);
|
||||
kdbgln("- Available block, of size %zu", block->full_size);
|
||||
alloc_total += block->full_size + sizeof(HeapBlock);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial::printf("- Used block, of size %zu, of which %zu bytes are being used\n", block->full_size,
|
||||
block->req_size);
|
||||
kdbgln("- Used block, of size %zu, of which %zu bytes are being used", block->full_size, block->req_size);
|
||||
alloc_total += block->full_size + sizeof(HeapBlock);
|
||||
alloc_used += block->req_size;
|
||||
}
|
||||
block = block->next;
|
||||
}
|
||||
|
||||
Serial::printf("-- Total memory allocated for heap: %zu bytes\n", alloc_total);
|
||||
Serial::printf("-- Heap memory in use by the kernel: %zu bytes\n", alloc_used);
|
||||
kdbgln("-- Total memory allocated for heap: %zu bytes", alloc_total);
|
||||
kdbgln("-- Heap memory in use by the kernel: %zu bytes", alloc_used);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#include "memory/MemoryManager.h"
|
||||
#include "Log.h"
|
||||
#include "arch/MMU.h"
|
||||
#include "arch/Serial.h"
|
||||
#include "boot/bootboot.h"
|
||||
#include <Alignment.h>
|
||||
#include <String.h>
|
||||
@ -88,7 +88,7 @@ namespace MemoryManager
|
||||
page_virtual_bitmap_addr = page_bitmap_addr; // we'll map this to virtual memory as soon as the MMU is ready
|
||||
if ((total_mem / ARCH_PAGE_SIZE / 8) >= biggest_memory_block_size)
|
||||
{
|
||||
Serial::println("ERROR: No single memory block is enough to hold the page bitmap");
|
||||
kerrorln("ERROR: No single memory block is enough to hold the page bitmap");
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user