Kernel: lol
This commit is contained in:
@@ -16,7 +16,7 @@ INCLUDEDIR?=$(PREFIX)/include
|
||||
CFLAGS:=$(CFLAGS) -D__is_kernel -Iinclude -fstack-protector -ffreestanding -Wall -Wextra -Wno-unused-function
|
||||
CPPFLAGS:=$(CPPFLAGS) -fno-rtti -fno-exceptions
|
||||
LDFLAGS:=$(LDFLAGS)
|
||||
LIBS:=$(LIBS) -nostdlib -lk -lgcc
|
||||
LIBS:=$(LIBS) -nostdlib -lk -lbank -lgcc
|
||||
|
||||
ARCHDIR=arch/$(HOSTARCH)
|
||||
|
||||
|
||||
@@ -1,9 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <BAN/Formatter.h>
|
||||
#include <kernel/PIT.h>
|
||||
|
||||
#define dprint BAN::Formatter::print<Serial::serial_putc>
|
||||
#define dprintln BAN::Formatter::println<Serial::serial_putc>
|
||||
#define dprintln(...) \
|
||||
do { \
|
||||
BAN::Formatter::print<Serial::serial_putc>("[{5.3}] {}({}): ", (float)PIT::ms_since_boot(), __FILE__, __LINE__); \
|
||||
BAN::Formatter::println<Serial::serial_putc>(__VA_ARGS__); \
|
||||
} while(false)
|
||||
|
||||
#define dwarnln(...) \
|
||||
do { \
|
||||
BAN::Formatter::print<Serial::serial_putc>("\e[33m"); \
|
||||
dprintln(__VA_ARGS__); \
|
||||
BAN::Formatter::print<Serial::serial_putc>("\e[m"); \
|
||||
} while(false)
|
||||
|
||||
#define derrorln(...) \
|
||||
do { \
|
||||
BAN::Formatter::print<Serial::serial_putc>("\e[31m"); \
|
||||
dprintln(__VA_ARGS__); \
|
||||
BAN::Formatter::print<Serial::serial_putc>("\e[m"); \
|
||||
} while(false)
|
||||
|
||||
namespace Serial
|
||||
{
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
#include <BAN/Formatter.h>
|
||||
#include <kernel/tty.h>
|
||||
|
||||
#define kprint BAN::Formatter::print<TTY::putchar>
|
||||
#define kprintln BAN::Formatter::println<TTY::putchar>
|
||||
#define kprint(...) BAN::Formatter::print<TTY::putchar>(__VA_ARGS__)
|
||||
#define kprintln(...) BAN::Formatter::println<TTY::putchar>(__VA_ARGS__)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include <BAN/Queue.h>
|
||||
#include <kernel/IDT.h>
|
||||
#include <kernel/IO.h>
|
||||
#include <kernel/Keyboard.h>
|
||||
#include <kernel/kprint.h>
|
||||
#include <kernel/PIC.h>
|
||||
#include <kernel/PIT.h>
|
||||
#include <kernel/Queue.h>
|
||||
#include <kernel/Serial.h>
|
||||
|
||||
#include <kernel/KeyboardLayout/FI.h>
|
||||
@@ -61,7 +61,7 @@
|
||||
namespace Keyboard
|
||||
{
|
||||
|
||||
static bool s_keyboard_state[0xFF] = {};
|
||||
static bool s_keyboard_state[0xFF] = {};
|
||||
|
||||
struct Command
|
||||
{
|
||||
@@ -73,10 +73,10 @@ namespace Keyboard
|
||||
uint8_t _ack = 0;
|
||||
bool _done = false;
|
||||
};
|
||||
static Queue<Command> s_keyboard_command_queue;
|
||||
static uint8_t s_keyboard_command_extra = 0x00;
|
||||
static BAN::Queue<Command> s_keyboard_command_queue;
|
||||
static uint8_t s_keyboard_command_extra = 0x00;
|
||||
|
||||
static Queue<KeyEvent> s_key_event_queue;
|
||||
static BAN::Queue<KeyEvent> s_key_event_queue;
|
||||
static uint8_t s_keyboard_key_buffer[10] = {};
|
||||
static uint8_t s_keyboard_key_buffer_size = 0;
|
||||
|
||||
@@ -290,8 +290,8 @@ namespace Keyboard
|
||||
if (key != Key::INVALID)
|
||||
{
|
||||
auto error_or = s_key_event_queue.Push({ .key = key, .modifiers = modifiers, .pressed = pressed });
|
||||
if (error_or.HasError())
|
||||
dprintln("PS/2 Keyboard: {}", error_or.GetError().message);
|
||||
if (error_or.IsError())
|
||||
dwarnln("{}", error_or.GetError());
|
||||
}
|
||||
s_keyboard_key_buffer_size -= index + 1;
|
||||
memmove(s_keyboard_key_buffer, s_keyboard_key_buffer + index, s_keyboard_key_buffer_size);
|
||||
@@ -384,7 +384,7 @@ namespace Keyboard
|
||||
i8042_controller_command(I8042_TEST_CONTROLLER);
|
||||
if (wait_and_read() != I8042_TEST_CONTROLLER_PASS)
|
||||
{
|
||||
kprintln("\e[33mERROR: PS/2 controller self test failed\e[m");
|
||||
derrorln("PS/2 controller self test failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ namespace Keyboard
|
||||
i8042_controller_command(I8042_TEST_FIRST_PORT);
|
||||
if (wait_and_read() != I8042_TEST_FIRST_PORT_PASS)
|
||||
{
|
||||
kprintln("\e[33mERROR: PS/2 first port test failed\e[m");
|
||||
derrorln("PS/2 first port test failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <kernel/panic.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if UINT32_MAX == UINTPTR_MAX
|
||||
#define STACK_CHK_GUARD 0xe2dee396
|
||||
@@ -15,7 +16,7 @@ __BEGIN_DECLS
|
||||
__attribute__((noreturn))
|
||||
void __stack_chk_fail(void)
|
||||
{
|
||||
printf("Stack smashing detected\n");
|
||||
Kernel::panic("Stack smashing detected");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
@@ -73,8 +73,7 @@ void kmalloc_dump_nodes()
|
||||
for (size_t i = 0; i < s_kmalloc_node_count; i++)
|
||||
{
|
||||
kmalloc_node& node = s_kmalloc_node_head[i];
|
||||
if (i < 10) dprint(" ");
|
||||
dprintln(" ({}) {}, node at {}, free: {}, size: {}", i, (void*)&node, (void*)node.addr, node.free, node.size);
|
||||
dprintln(" ({3}) {}, node at {}, free: {}, size: {}", i, (void*)&node, (void*)node.addr, node.free, node.size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user