Fix braces + init_paging args

This commit is contained in:
2026-03-11 19:58:00 +01:00
parent 9d409317e2
commit 8e2a612d88
29 changed files with 147 additions and 229 deletions

View File

@@ -161,11 +161,9 @@ void keyboard_handler()
unsigned char scancode = inb(0x60);
// Key release (bit 7 set)
if (scancode & 0x80)
{
if (scancode & 0x80) {
unsigned char code = scancode & 0x7F;
switch (code)
{
switch (code) {
// Clear the corresponding bit if corresponding key is released
case LEFT_SHIFT_PRESSED:
case RIGHT_SHIFT_PRESSED:
@@ -179,12 +177,9 @@ void keyboard_handler()
break;
}
return;
}
else
{
} else {
// Key press
switch (scancode)
{
switch (scancode) {
// Set bits for corresponding special key press
case LEFT_SHIFT_PRESSED:
case RIGHT_SHIFT_PRESSED:
@@ -200,15 +195,12 @@ void keyboard_handler()
default:
{
// Avoiding buffer overflow from extended keys lol
if (scancode < 128)
{
if (scancode < 128) {
// Should we get a SHIFTED char or a regular one?
unsigned char c = (key_status & SHIFT_PRESSED_BIT) ? keymap_shifted[scancode] : keymap[scancode];
if (c)
{
if (c == '\n')
{
if (c) {
if (c == '\n') {
_putchar('\r');
}
// Should probably have a keyboard buffer here... instead of this
@@ -225,8 +217,7 @@ void keyboard_init(unsigned char layout)
// Here we might go and select PS/2, USB, or other... (once we implement multiple keyboard protocols)
// Keyboard layout selection
switch (layout)
{
switch (layout) {
case US:
keymap = kbdus;
keymap_shifted = kbdus_shifted;
@@ -242,8 +233,7 @@ void keyboard_init(unsigned char layout)
}
// Flush keyboard buffer
while (inb(0x64) & 1)
{
while (inb(0x64) & 1) {
inb(0x60);
}

View File

@@ -13,15 +13,13 @@ void keyboard_handler();
#define ALT_PRESSED_BIT 0b00000010
#define CTRL_PRESSED_BIT 0b00000100
enum SpecialKeys
{
enum SpecialKeys {
SHIFT = 255,
ALT = 254,
CTRL = 253
};
enum SpecialScancodes
{
enum SpecialScancodes {
LEFT_SHIFT_PRESSED = 0x2A,
LEFT_SHIFT_RELEASED = 0xAA,
RIGHT_SHIFT_PRESSED = 0x36,
@@ -32,8 +30,7 @@ enum SpecialScancodes
ALT_RELEASED = 0xB8
};
enum KeyboardLayout
{
enum KeyboardLayout {
US,
FR
};

View File

@@ -21,9 +21,6 @@ unsigned char inb(int port)
return data;
}
// COM1
#define PORT 0x3F8
int serial_init()
{
outb(PORT + 1, 0x00); // Disable all interrupts
@@ -36,8 +33,7 @@ int serial_init()
outb(PORT + 4, 0x1E); // Set in loopback mode, test the serial chip
outb(PORT + 0, 0xAE); // Test serial chip (send byte 0xAE and check if serial returns same byte)
if (inb(PORT) != 0xAE)
{
if (inb(PORT) != 0xAE) {
return -EIO;
}
@@ -66,8 +62,7 @@ void skputc(char c)
void skputs(const char* str)
{
unsigned int i=0;
while (str[i])
{
while (str[i]) {
skputc(str[i]);
i++;
}

View File

@@ -7,6 +7,9 @@
#ifndef SERIAL_H
#define SERIAL_H
// COM1
#define PORT 0x3F8
void outb(int port, unsigned char data);
unsigned char inb(int port);

View File

@@ -34,8 +34,7 @@ void _putchar(char character)
void kputs(const char* str)
{
size_t i=0;
while (str[i] != 0)
{
while (str[i] != 0) {
_putchar(str[i]);
i++;
}