mirror of
https://github.com/BoredDevNL/BoredOS.git
synced 2026-05-15 10:48:38 +00:00
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:
parent
e9888f26b1
commit
fdcfd48a24
6 changed files with 30 additions and 6 deletions
|
|
@ -49,7 +49,6 @@ static void kconsole_putc_nolock(char c) {
|
||||||
cursor_x = 10;
|
cursor_x = 10;
|
||||||
cursor_y += CHAR_HEIGHT;
|
cursor_y += CHAR_HEIGHT;
|
||||||
kconsole_scroll();
|
kconsole_scroll();
|
||||||
graphics_flip_buffer();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,12 +88,9 @@ void kconsole_write(const char *s) {
|
||||||
spinlock_release_irqrestore(&console_lock, flags);
|
spinlock_release_irqrestore(&console_lock, flags);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*s) {
|
while (*s) {
|
||||||
kconsole_putc_nolock(*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);
|
spinlock_release_irqrestore(&console_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,9 @@ uint8_t mouse_read(void) {
|
||||||
|
|
||||||
void mouse_init(void) {
|
void mouse_init(void) {
|
||||||
uint8_t status;
|
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
|
// Enable Aux Device
|
||||||
mouse_wait(0);
|
mouse_wait(0);
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,19 @@
|
||||||
#ifndef PS2_H
|
#ifndef PS2_H
|
||||||
#define 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>
|
#include <stdint.h>
|
||||||
|
|
||||||
void ps2_init(void);
|
void ps2_init(void);
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
|
|
||||||
|
|
||||||
uint64_t timer_handler(registers_t *regs);
|
uint64_t timer_handler(registers_t *regs);
|
||||||
uint64_t keyboard_handler(registers_t *regs);
|
uint64_t keyboard_handler(registers_t *regs);
|
||||||
uint64_t mouse_handler(registers_t *regs);
|
uint64_t mouse_handler(registers_t *regs);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
|
#include "../core/io.h"
|
||||||
|
#include "../dev/ps2.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool e0_prefix;
|
bool e0_prefix;
|
||||||
|
|
@ -88,6 +90,17 @@ static const uint16_t set1_ext[128] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void keyboard_init(void) {
|
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.e0_prefix = false;
|
||||||
g_kb.left_shift = false;
|
g_kb.left_shift = false;
|
||||||
g_kb.right_shift = false;
|
g_kb.right_shift = false;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
#ifndef KEYBOARD_H
|
#ifndef KEYBOARD_H
|
||||||
#define KEYBOARD_H
|
#define KEYBOARD_H
|
||||||
|
|
||||||
|
#define KBD_DATA_PORT 0x60
|
||||||
|
#define KBD_CMD_PORT 0x64
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "keycodes.h"
|
#include "keycodes.h"
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#define MSR_WC 0x277
|
||||||
|
|
||||||
static uint64_t current_pml4_phys = 0;
|
static uint64_t current_pml4_phys = 0;
|
||||||
|
|
||||||
// Get current CR3 value
|
// Get current CR3 value
|
||||||
|
|
@ -37,7 +39,6 @@ static uint64_t alloc_page_table_phys(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void paging_init(void) {
|
void paging_init(void) {
|
||||||
|
|
||||||
current_pml4_phys = read_cr3() & PT_ADDR_MASK;
|
current_pml4_phys = read_cr3() & PT_ADDR_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue