feat: cleanup init code, small other refactors
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <myke/libc/ringqueue.h>
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/libk/syscall.h>
|
||||
#include <myke/util/init.h>
|
||||
|
||||
|
||||
const char scancode_map_lowercase[] = {
|
||||
@@ -131,7 +132,7 @@ static void keyboard_callback(isr_registers_t *regs) {
|
||||
publish_key_event(scancode);
|
||||
}
|
||||
|
||||
void init_keyboard() {
|
||||
void keyboard_init() {
|
||||
register_interrupt_handler(IRQ1, keyboard_callback);
|
||||
keyboard_state.shift = 0;
|
||||
keyboard_state.ctrl = 0;
|
||||
@@ -139,3 +140,9 @@ void init_keyboard() {
|
||||
keyboard_state.extended = 0;
|
||||
keyboard_event_buffer = create_buffer(256, sizeof(KeyEvent));
|
||||
}
|
||||
|
||||
INIT_FUNCTION(100) = {
|
||||
.name = "keyboard",
|
||||
.stage = INIT_STAGE_LATE_BOOT,
|
||||
.init = keyboard_init,
|
||||
};
|
||||
@@ -2,9 +2,10 @@
|
||||
// Created by rick on 28-01-21.
|
||||
//
|
||||
|
||||
#include <myke/drivers/serial.h>
|
||||
#include <sys/types.h>
|
||||
#include <myke/drivers/ports.h>
|
||||
#include <myke/libk/kprint.h>
|
||||
#include <myke/util/init.h>
|
||||
|
||||
#define SERIAL_INTERRUPT_DATA_AVAILABLE (1 << 0)
|
||||
#define SERIAL_INTERRUPT_TRANSMITTER_EMPTY (1 << 1)
|
||||
@@ -51,7 +52,7 @@
|
||||
#define MODEM_CONTROL_LOOPBACK_MODE (1 << 4)
|
||||
#define MODEM_CONTROL_AUTOFLOW_CONTROL_ENABLED (1 << 5)
|
||||
|
||||
int serial_init() {
|
||||
int serial_init_hw() {
|
||||
port_byte_out(PORT_SERIAL_0 + PORT_SERIAL_INTERRUPT, 0); // Disable all interrupts
|
||||
port_byte_out(PORT_SERIAL_0 + PORT_SERIAL_LINE_CONTROL,
|
||||
LINE_CONTROL_DIVISOR); // Enable DLAB (set baud rate divisor)
|
||||
@@ -114,4 +115,17 @@ void serial_kprint(const char *msg) {
|
||||
write_serial(c);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void serial_init() {
|
||||
if (serial_init_hw() != 0) {
|
||||
return;
|
||||
}
|
||||
kprint_register(serial_kprint);
|
||||
}
|
||||
|
||||
INIT_FUNCTION(100) = {
|
||||
.name = "serial",
|
||||
.stage = INIT_STAGE_EARLY_BOOT_0,
|
||||
.init = serial_init,
|
||||
};
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
//
|
||||
|
||||
#include <string.h>
|
||||
#include <myke/drivers/vgascreen.h>
|
||||
|
||||
#include <myke/drivers/ports.h>
|
||||
#include <myke/drivers/vgascreen.h>
|
||||
#include <myke/libk/kprint.h>
|
||||
#include <myke/util/init.h>
|
||||
|
||||
char *_vga_character_memory = (char *) VGA_CHARACTER_MEMORY_LOCATION;
|
||||
|
||||
@@ -136,3 +138,14 @@ int get_offset_row(int offset) {
|
||||
int get_offset_col(int offset) {
|
||||
return (offset - (get_offset_row(offset) * 2 * VGA_COL_MAX)) / 2;
|
||||
}
|
||||
|
||||
void vga_init() {
|
||||
vga_clear_screen();
|
||||
kprint_register(vga_kprint);
|
||||
}
|
||||
|
||||
INIT_FUNCTION(100) = {
|
||||
.name = "vga",
|
||||
.stage = INIT_STAGE_EARLY_BOOT_0,
|
||||
.init = vga_init,
|
||||
};
|
||||
Reference in New Issue
Block a user