maintenance
This commit is contained in:
@@ -195,8 +195,8 @@ long_mode_start:
|
||||
mov fs, ax
|
||||
mov gs, ax
|
||||
|
||||
extern kmain
|
||||
call kmain
|
||||
extern kernel_main
|
||||
call kernel_main
|
||||
|
||||
cli
|
||||
.hang:
|
||||
|
||||
@@ -8,12 +8,11 @@ void keyboard_handler(const keyboard_event_t* event)
|
||||
{
|
||||
if (event->pressed)
|
||||
{
|
||||
vga_print_int(event->scan_code);
|
||||
vga_print("\n");
|
||||
vga_print_char(event->ascii);
|
||||
}
|
||||
}
|
||||
|
||||
void kmain(void)
|
||||
void kernel_main(void)
|
||||
{
|
||||
vga_clear();
|
||||
vga_print_success();
|
||||
@@ -36,7 +35,7 @@ void kmain(void)
|
||||
}
|
||||
}
|
||||
|
||||
void kpanic()
|
||||
void kernel_panic()
|
||||
{
|
||||
vga_print("Kernel panic!\n");
|
||||
__asm__ volatile("cli; hlt");
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
void kpanic();
|
||||
void kernel_panic();
|
||||
|
||||
@@ -11,6 +11,14 @@
|
||||
|
||||
#define KEYBOARD_HANDLERS_LENGTH 32
|
||||
|
||||
unsigned const char us_keymap[128] = {
|
||||
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', '\t', 'q', 'w',
|
||||
'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0, 'a', 's', 'd', 'f', 'g', 'h',
|
||||
'j', 'k', 'l', ';', '\'', '`', 0, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/',
|
||||
0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, '-', 0, 0, 0, '+', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
bool shift = false;
|
||||
bool caps_lock = false;
|
||||
|
||||
@@ -47,6 +55,7 @@ void handle_keyboard(const isr_frame_t* frame)
|
||||
.pressed = pressed,
|
||||
.caps_lock = caps_lock,
|
||||
.shift = shift,
|
||||
.ascii = us_keymap[scan_code],
|
||||
};
|
||||
|
||||
for (int i = 0; i < handler_index; i++)
|
||||
@@ -65,7 +74,7 @@ void register_keypress_handler(const keyboard_handler_t handler)
|
||||
{
|
||||
vga_print_error();
|
||||
vga_print(" Maximum keyboard handlers reached\n");
|
||||
kpanic();
|
||||
kernel_panic();
|
||||
}
|
||||
|
||||
keyboard_handlers[handler_index] = handler;
|
||||
|
||||
16
src/vga.c
16
src/vga.c
@@ -69,6 +69,12 @@ void vga_print_char_colored(char character, vga_color_t color)
|
||||
cursor_col = 0;
|
||||
break;
|
||||
}
|
||||
case '\t':
|
||||
{
|
||||
uint8_t remainter = cursor_col % 4;
|
||||
cursor_col += remainter == 0 ? 4 : remainter;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
vga_char c = {
|
||||
@@ -110,11 +116,6 @@ void vga_print_char_colored(char character, vga_color_t color)
|
||||
}
|
||||
}
|
||||
|
||||
void vga_print_char(char character)
|
||||
{
|
||||
vga_print_char_colored(character, vga_default_color());
|
||||
}
|
||||
|
||||
void vga_print_colored(const char* string, vga_color_t color)
|
||||
{
|
||||
for (uint8_t i = 0; string[i] != '\0'; i++)
|
||||
@@ -123,11 +124,6 @@ void vga_print_colored(const char* string, vga_color_t color)
|
||||
}
|
||||
}
|
||||
|
||||
void vga_print(const char* string)
|
||||
{
|
||||
vga_print_colored(string, vga_default_color());
|
||||
}
|
||||
|
||||
void vga_print_success(void)
|
||||
{
|
||||
vga_print("[ ");
|
||||
|
||||
13
src/vga.h
13
src/vga.h
@@ -24,9 +24,8 @@ typedef uint8_t vga_color_t;
|
||||
void vga_clear(void);
|
||||
void vga_set_cursor_position(uint8_t row, uint8_t col);
|
||||
|
||||
void vga_print_char(char character);
|
||||
void vga_print_char_colored(char character, vga_color_t color);
|
||||
void vga_print_colored(const char* string, vga_color_t color);
|
||||
void vga_print(const char* string);
|
||||
|
||||
void vga_print_success(void);
|
||||
void vga_print_error(void);
|
||||
@@ -42,4 +41,14 @@ static inline vga_color_t vga_color(vga_color_t fg_color, vga_color_t bg_color)
|
||||
static inline vga_color_t vga_default_color()
|
||||
{
|
||||
return vga_color(VGA_LIGHT_GRAY, VGA_BLACK);
|
||||
}
|
||||
|
||||
static inline void vga_print_char(char character)
|
||||
{
|
||||
vga_print_char_colored(character, vga_default_color());
|
||||
}
|
||||
|
||||
static inline void vga_print(const char* string)
|
||||
{
|
||||
vga_print_colored(string, vga_default_color());
|
||||
}
|
||||
Reference in New Issue
Block a user