aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2015-02-03 18:23:04 -0500
committerFranklin Wei <frankhwei536@gmail.com>2015-02-03 18:23:04 -0500
commite065a7048aa98d253cdcc9298c934bb7af7feaa9 (patch)
tree99768597eda705f9ea1947c96c899a74e3bdc97c /drivers
parentc8a195e1eb19d346c03c1dfa6ed66c6215caefa2 (diff)
downloadkappa-e065a7048aa98d253cdcc9298c934bb7af7feaa9.zip
kappa-e065a7048aa98d253cdcc9298c934bb7af7feaa9.tar.gz
kappa-e065a7048aa98d253cdcc9298c934bb7af7feaa9.tar.bz2
kappa-e065a7048aa98d253cdcc9298c934bb7af7feaa9.tar.xz
some work
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ps2.c11
-rw-r--r--drivers/tty.c25
2 files changed, 34 insertions, 2 deletions
diff --git a/drivers/ps2.c b/drivers/ps2.c
index ff85091..0d466aa 100644
--- a/drivers/ps2.c
+++ b/drivers/ps2.c
@@ -4,20 +4,31 @@
#include "isr.h"
#include "ps2.h"
+static void ps2_wait(void)
+{
+ /* wait for the keyboard */
+ while(1)
+ if ((inb(0x64) & 2) == 0) break;
+}
+
void ps2_set_leds(uint8_t status)
{
+ ps2_wait();
outb(0x60, 0xED);
outb(0x60, status);
}
static void ps2_handler(struct regs_t regs)
{
+ (void) regs;
uint8_t scancode = inb(0x60);
/* TODO: handle scancode */
+ printf("key %x\n", scancode);
}
static void ps2_set_scancode_set(uint8_t set)
{
+ ps2_wait();
outb(0x60, 0xF0);
outb(0x60, set);
}
diff --git a/drivers/tty.c b/drivers/tty.c
index 6668be7..6b83232 100644
--- a/drivers/tty.c
+++ b/drivers/tty.c
@@ -1,16 +1,37 @@
#include <stdint.h>
#include "io.h"
+#include "panic.h"
#include "tty.h"
#include "vga.h"
static int term_x, term_y;
static uint8_t term_col;
-/* VGA buffer starts at 0xB8000 */
+/* VGA buffer starts at 0xB8000 on color or 0xB0000 on monochrome */
static uint16_t *term_buf;
+static uint16_t video_detect_hardware(void)
+{
+ const uint16_t *ptr = (const uint16_t*)0x410;
+ return *ptr;
+}
+
void tty_init(void)
{
- term_buf = (uint16_t*)0xB8000;
+ uint16_t vid_type = video_detect_hardware() & 0x30;
+ if(vid_type == 0x20)
+ {
+ /* color */
+ term_buf = (uint16_t*)0xB8000;
+ }
+ else if(vid_type == 0x30)
+ {
+ term_buf = (uint16_t*)0xB0000;
+ }
+ else
+ {
+ /* none */
+ panic("TTY init failed!");
+ }
tty_set_color(VGA_MAKE_COLOR(VGA_LIGHT_GRAY, VGA_BLACK));
tty_clear();
}