summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2024-05-27 13:58:00 -0500
committerDanny Holman <dholman@gymli.org>2024-05-27 13:58:00 -0500
commit61760f9301427ea56a62ec02af3d0d8ae4745be7 (patch)
treec63057d16075b2b411eab36424f1d481b4a8c9f1 /drivers
parentlibk: create a subset libc for kernel use (diff)
downloadbox-61760f9301427ea56a62ec02af3d0d8ae4745be7.tar.gz
box-61760f9301427ea56a62ec02af3d0d8ae4745be7.tar.zst
box-61760f9301427ea56a62ec02af3d0d8ae4745be7.zip
drivers: create a subdir just for driver code
Create a subdirectory branching from the project root. This directory will contain nothing but driver and device code. Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to '')
-rw-r--r--drivers/input/keyboard.c (renamed from arch/i386/kernel/keyboard.c)16
-rw-r--r--drivers/video/framebuffer.c (renamed from arch/i386/kernel/framebuffer.c)20
2 files changed, 19 insertions, 17 deletions
diff --git a/arch/i386/kernel/keyboard.c b/drivers/input/keyboard.c
index 96aea3a..f2a8eba 100644
--- a/arch/i386/kernel/keyboard.c
+++ b/drivers/input/keyboard.c
@@ -1,8 +1,9 @@
-#include <kernel/keyboard.h>
-#include <kernel/framebuffer.h>
+#include <kernel/input/keyboard.h>
+#include <kernel/tty/tty_vga.h>
+#include <kernel/tty.h>
+#include <kernel/kthread.h>
#include <kernel/pic.h>
-
-#define C(k) (k - '@')
+#include <libk/string.h>
static uint8_t keymap_modifiers[256] = {
[0x1D] KB_CTL,
@@ -100,9 +101,6 @@ static uint8_t* keymaps[4] = {
keymap_control,
};
-char keyboard_buffer[4096];
-int kbuf_pos = 0;
-
char keyboard_getchar(void) {
static int shift = 0;
uint8_t st = inb(KB_STAT);
@@ -136,9 +134,9 @@ char keyboard_getchar(void) {
return c;
}
-void keyboard_handler(void) {
+void keyboard_handler(struct isr_frame *frame) {
char c = keyboard_getchar();
if (c != -1)
- keyboard_buffer[kbuf_pos++];
+ tty_getchar(c);
return;
}
diff --git a/arch/i386/kernel/framebuffer.c b/drivers/video/framebuffer.c
index 602bddb..3df3df4 100644
--- a/arch/i386/kernel/framebuffer.c
+++ b/drivers/video/framebuffer.c
@@ -1,14 +1,13 @@
-#include <kernel/vga.h>
+#include <kernel/video/framebuffer.h>
+#include <kernel/video/vga.h>
+#include <kernel/asm.h>
+#include <kernel/kthread.h>
#include <kernel/paging.h>
#include <kernel/pic.h>
-#include <kernel/string.h>
+#include <libk/string.h>
#include <stddef.h>
#include <stdint.h>
-static const size_t VGA_WIDTH = 80;
-static const size_t VGA_HEIGHT = 25;
-static uint16_t *const VGA_MEMORY = (uint16_t*)0xC03FF000;
-
static size_t fb_row;
static size_t fb_column;
static uint8_t fb_color;
@@ -44,8 +43,6 @@ void _fb_scroll(void) {
}
void fb_init(void) {
- map_page(NULL, 0xB8000, (uintptr_t)VGA_MEMORY, 0x003);
-
fb_row = 0;
fb_column = 0;
fb_color = vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK);
@@ -65,6 +62,13 @@ void fb_setcolor(uint8_t color) {
void fb_setpos(int x, int y) {
fb_row = y;
fb_column = x;
+ _update_cursor(fb_column, fb_row+1);
+}
+
+void fb_offsetpos(int dx, int dy) {
+ fb_row += dy;
+ fb_column += dx;
+ _update_cursor(fb_column, fb_row+1);
}
void fb_putchar(char c) {