summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--arch/i386/include/kernel/framebuffer.h17
-rw-r--r--arch/i386/include/kernel/keyboard.h32
-rw-r--r--arch/i386/include/kernel/vga.h33
-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
6 files changed, 27 insertions, 99 deletions
diff --git a/Makefile b/Makefile
index 9a50fb6..abab3f7 100644
--- a/Makefile
+++ b/Makefile
@@ -36,15 +36,23 @@ KERNEL_OBJS=$(KERNEL_ARCH_OBJS) \
kernel/sched.o \
kernel/kthread.o \
+DRIVER_OBJS=drivers/video/framebuffer.o \
+ drivers/input/keyboard.o \
+ drivers/pci/pci.o \
+ drivers/pci/ide.o \
+ drivers/tty/tty_vga.o \
+
OBJS=$(ARCHDIR)/boot/crti.o \
$(ARCHDIR)/crtbegin.o \
$(KERNEL_OBJS) \
+ $(DRIVER_OBJS) \
$(LIBK_OBJS) \
$(ARCHDIR)/crtend.o \
$(ARCHDIR)/boot/crtn.o \
LINK_LIST=$(LDFLAGS) \
$(KERNEL_OBJS) \
+ $(DRIVER_OBJS) \
$(LIBK_OBJS) \
$(LIBS) \
diff --git a/arch/i386/include/kernel/framebuffer.h b/arch/i386/include/kernel/framebuffer.h
deleted file mode 100644
index ef0249c..0000000
--- a/arch/i386/include/kernel/framebuffer.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef I386_FRAMEBUFFER_H
-#define I386_FRAMEBUFFER_H
-
-#include <stddef.h>
-#include <stdint.h>
-
-void fb_init(void);
-void fb_setcolor(uint8_t color);
-void fb_putchar(char c);
-void fb_setpos(int x, int y);
-
-static inline void fb_write(const char *data, size_t size) {
- for (size_t i = 0; i < size; i++)
- fb_putchar(data[i]);
-}
-
-#endif
diff --git a/arch/i386/include/kernel/keyboard.h b/arch/i386/include/kernel/keyboard.h
deleted file mode 100644
index 7b63993..0000000
--- a/arch/i386/include/kernel/keyboard.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef I386_KEYBOARD_H
-#define I386_KEYBOARD_H
-
-#include <stdint.h>
-
-#define KB_STAT 0x64
-#define KB_DATA 0x60
-
-#define KB_DIB 0x01
-#define KB_SHIFT (1<<0)
-#define KB_CTL (1<<1)
-#define KB_ALT (1<<2)
-#define KB_CPSLK (1<<3)
-#define KB_NUMLK (1<<4)
-#define KB_SCLLK (1<<5)
-#define KB_E0ESC (1<<6)
-
-#define KB_HOME 0xE0
-#define KB_END 0xE1
-#define KB_UP 0xE2
-#define KB_DOWN 0xE3
-#define KB_LEFT 0xE4
-#define KB_RGHT 0xE5
-#define KB_PGUP 0xE6
-#define KB_PGDN 0xE7
-#define KB_INS 0xE8
-#define KB_DEL 0xE9
-
-char keyboard_getchar(void);
-void keyboard_handler(void);
-
-#endif
diff --git a/arch/i386/include/kernel/vga.h b/arch/i386/include/kernel/vga.h
deleted file mode 100644
index e89f202..0000000
--- a/arch/i386/include/kernel/vga.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef I386_VGA_H
-#define I386_VGA_H
-
-#include <stdint.h>
-
-enum vga_color {
- VGA_COLOR_BLACK = 0,
- VGA_COLOR_BLUE = 1,
- VGA_COLOR_GREEN = 2,
- VGA_COLOR_CYAN = 3,
- VGA_COLOR_RED = 4,
- VGA_COLOR_MAGENTA = 5,
- VGA_COLOR_BROWN = 6,
- VGA_COLOR_LIGHT_GREY = 7,
- VGA_COLOR_DARK_GREY = 8,
- VGA_COLOR_LIGHT_BLUE = 9,
- VGA_COLOR_LIGHT_GREEN = 10,
- VGA_COLOR_LIGHT_CYAN = 11,
- VGA_COLOR_LIGHT_RED = 12,
- VGA_COLOR_LIGHT_MAGENTA = 13,
- VGA_COLOR_LIGHT_BROWN = 14,
- VGA_COLOR_LIGHT_WHITE = 15,
-};
-
-static inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg) {
- return fg | bg << 4;
-}
-
-static inline uint16_t vga_entry(unsigned char uc, uint8_t color) {
- return (uint16_t)uc | (uint16_t)color << 8;
-}
-
-#endif
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) {