pr: Removed Unnessisary Flipping on kconsole leading to Vastly Faster Boot Times & PS/2 Hardware Correctness (#12)

* Flush PS/2 Devices on boot to avoid Locking dependent on the out buffer on real hardware / emulated PS2 over USB

Removed Slow and Unnessisarty flipping causing kconsole write slowdowns consequently speeding up the boot process

* sod wc
This commit is contained in:
Myles "Mellurboo" Wilson 2026-05-10 10:22:18 +01:00 committed by GitHub
parent e9888f26b1
commit fdcfd48a24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 30 additions and 6 deletions

View file

@ -49,7 +49,6 @@ static void kconsole_putc_nolock(char c) {
cursor_x = 10;
cursor_y += CHAR_HEIGHT;
kconsole_scroll();
graphics_flip_buffer();
return;
}
@ -93,8 +92,5 @@ void kconsole_write(const char *s) {
while (*s) {
kconsole_putc_nolock(*s++);
}
// Flip once after a write batch to keep console updates coherent.
graphics_flip_buffer();
spinlock_release_irqrestore(&console_lock, flags);
}

View file

@ -109,6 +109,9 @@ uint8_t mouse_read(void) {
void mouse_init(void) {
uint8_t status;
int limit = 128;
while (limit-- > 0 && (inb(PS2_STATUS_PORT) & PS2_STATUS_OUT_FULL))
(void)inb(PS2_DATA_PORT);
// Enable Aux Device
mouse_wait(0);

View file

@ -4,11 +4,19 @@
#ifndef PS2_H
#define PS2_H
#define PS2_DATA_PORT 0x60
#define PS2_CMD_PORT 0x64
#define PS2_STATUS_PORT 0x64
#define PS2_STATUS_OUT_FULL 0x01
#define PS2_STATUS_IN_FULL 0x02
#define PS2_STATUS_AUX_DATA 0x20
#include <stdint.h>
void ps2_init(void);
#include "process.h"
uint64_t timer_handler(registers_t *regs);
uint64_t keyboard_handler(registers_t *regs);
uint64_t mouse_handler(registers_t *regs);

View file

@ -1,5 +1,7 @@
#include "keyboard.h"
#include "keymap.h"
#include "../core/io.h"
#include "../dev/ps2.h"
typedef struct {
bool e0_prefix;
@ -88,6 +90,17 @@ static const uint16_t set1_ext[128] = {
};
void keyboard_init(void) {
/*
Flush all data in the controller output buffer
this can cause the PS/2 Keyboard device to not work
on real hardware specifically
(even when Legacy USB keyboard Emulation is emulating the PS/2 keyboard)
Myles
*/
int limit = 128;
while (limit-- > 0 && (inb(PS2_STATUS_PORT) & PS2_STATUS_OUT_FULL))
(void)inb(KBD_DATA_PORT);
g_kb.e0_prefix = false;
g_kb.left_shift = false;
g_kb.right_shift = false;

View file

@ -1,6 +1,9 @@
#ifndef KEYBOARD_H
#define KEYBOARD_H
#define KBD_DATA_PORT 0x60
#define KBD_CMD_PORT 0x64
#include <stdint.h>
#include <stdbool.h>
#include "keycodes.h"

View file

@ -6,6 +6,8 @@
#include "platform.h"
#include <stddef.h>
#define MSR_WC 0x277
static uint64_t current_pml4_phys = 0;
// Get current CR3 value
@ -37,7 +39,6 @@ static uint64_t alloc_page_table_phys(void) {
}
void paging_init(void) {
current_pml4_phys = read_cr3() & PT_ADDR_MASK;
}