Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
02473a0
Setup basic keyboard init
ryuukumar Apr 4, 2026
0099ef1
Add keyboard interrupt handler
ryuukumar Apr 4, 2026
2a9eea9
Merge remote-tracking branch 'origin/main' into hw/keyboard
ryuukumar Apr 4, 2026
465eee9
Merge remote-tracking branch 'origin/main' into hw/keyboard
ryuukumar Apr 5, 2026
a6b7d5a
Merge remote-tracking branch 'origin/main' into hw/keyboard
ryuukumar Apr 24, 2026
502f54b
Ignore compile_commands.json
ryuukumar Apr 24, 2026
e8328a7
Remove return from kb_handler and mark registers unused
ryuukumar Apr 24, 2026
9307478
Fix bug where kb handler would permahang because IRQ would be permaset
ryuukumar Apr 24, 2026
f0862d0
Add a keypress map
ryuukumar Apr 25, 2026
587076d
Include it + minor fixes
ryuukumar Apr 25, 2026
e2acf58
Add some extended keyboard actions
ryuukumar Apr 25, 2026
157136d
Add some util functions
ryuukumar Apr 25, 2026
27a08a5
Add statemachine struct and parser for scancode 1
ryuukumar Apr 25, 2026
bebd51b
Use map_keypress in keyboard handler
ryuukumar Apr 25, 2026
92299d1
Remove the while loop from the handler
ryuukumar Apr 25, 2026
21f49c7
Add pop_next_char
ryuukumar Apr 25, 2026
5cc526e
Expose do_sched_yield
ryuukumar Apr 25, 2026
ce21aed
Add stdin_read
ryuukumar Apr 25, 2026
d910440
Add optional tty handler which keyboard may call
ryuukumar Apr 25, 2026
c4f57ba
Block process while waiting for keyboard input (#34)
ryuukumar Apr 25, 2026
b6306cd
Block process when char unavailable
ryuukumar Apr 25, 2026
08fa608
Fix issue causing a permaloop + format
ryuukumar Apr 25, 2026
a941be9
Hover the user process
ryuukumar Apr 25, 2026
b927741
Change the hover loop of kernel thread to echo keypresses
ryuukumar Apr 25, 2026
fa057ec
Filter by regular character only (no action keys)
ryuukumar Apr 25, 2026
7c2d978
Remove the print statement for every keypress
ryuukumar Apr 25, 2026
b493a10
Handle backspaces in console
ryuukumar Apr 25, 2026
dc671ec
do_sched_yield can be static
ryuukumar Apr 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ iso_root
*.o
.vscode
docs
**/compile_commands.json

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
Expand Down
5 changes: 5 additions & 0 deletions kernel/include/kernel/fs/chardev.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#pragma once

#include <kernel/fs/vfs.h>
#include <kernel/process.h>

struct chardev_info {
process_queue rsrc_wait_queue;
};

void init_tty1 (inode* absolute_root);
7 changes: 7 additions & 0 deletions kernel/include/kernel/fs/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ typedef enum { UNDEF, EFILE, DIRECTORY, LINK, CHAR_DEV } file_type_t;
typedef struct inode inode;
typedef struct file file;

typedef struct chardev_info chardev_info_t;
typedef struct ramfs_info ramfs_info_t;

typedef struct {
int (*lookup) (char*, inode**, inode*);
int (*create) (char*, inode**, inode*);
Expand All @@ -40,6 +43,10 @@ struct inode {
inode_operations* i_iops;
file_operations* i_fops;
file_type_t i_type;
union {
chardev_info_t* chardev_info;
ramfs_info_t* ramfs_info;
} i_info;
};

struct file {
Expand Down
68 changes: 68 additions & 0 deletions kernel/include/kernel/hw/keyboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#pragma once

#include <stdint.h>

constexpr unsigned short kb_ps2_data_port = 0x60;
constexpr unsigned short kb_ps2_status_port = 0x64;
constexpr unsigned short kb_ps2_cmd_port = 0x64;

constexpr unsigned char kb_ps2_cmd_get_ccb = 0x20;
constexpr unsigned char kb_ps2_cmd_set_ccb = 0x60;
constexpr unsigned char kb_ps2_disable_port_2 = 0xA7;
constexpr unsigned char kb_ps2_enable_port_2 = 0xA8;
constexpr unsigned char kb_ps2_test_port_2 = 0xA9;
constexpr unsigned char kb_ps2_test_controller = 0xAA;
constexpr unsigned char kb_ps2_test_port_1 = 0xAB;
constexpr unsigned char kb_ps2_disable_port_1 = 0xAD;
constexpr unsigned char kb_ps2_enable_port_1 = 0xAE;
constexpr unsigned char kb_ps2_read_controller_ip = 0xC0;
constexpr unsigned char kb_ps2_read_controller_op = 0xD0;
constexpr unsigned char kb_ps2_write_controller_op = 0xD0;
constexpr unsigned char kb_ps2_reset = 0xFF;

typedef union {
uint8_t raw;
struct {
uint8_t irq1_enable : 1;
uint8_t irq12_enable : 1;
uint8_t system_flag : 1;
uint8_t reserved1 : 1;
uint8_t port_1_clock_disable : 1;
uint8_t port_2_clock_disable : 1;
uint8_t port_1_tl_enable : 1;
uint8_t reserved2 : 1;
} __attribute__ ((packed));
} kb_ps2_cfg_byte_t;

typedef union {
uint8_t raw;
struct {
uint8_t system_reset : 1;
uint8_t a20_gate : 1;
uint8_t port_2_clock : 1;
uint8_t port_2_data : 1;
uint8_t op_buffer_is_port_1 : 1;
uint8_t op_buffer_is_port_2 : 1;
uint8_t port_1_clock : 1;
uint8_t port_1_data : 1;
} __attribute__ ((packed));
} kb_ps2_controller_output_port_t;

typedef union {
uint8_t raw;
struct {
uint8_t out_buffer_full : 1;
uint8_t in_buffer_full : 1;
uint8_t system_flag : 1;
uint8_t is_controller_command : 1;
uint8_t reserved : 2;
uint8_t is_timeout_error : 1;
uint8_t is_parity_error : 1;
} __attribute__ ((packed));
} kb_ps2_status_register_t;

typedef void (*kb_tty_handler_t) (unsigned char);

void init_kb (void);
void register_kb_tty_handler (kb_tty_handler_t handler);
unsigned char pop_next_char (void);
Loading
Loading