Draft of keyboard driver

This commit is contained in:
Baptiste Wicht 2014-01-29 19:28:24 +01:00
parent 3dbeaf7480
commit 9feb5c8ffb
3 changed files with 25 additions and 1 deletions

View File

@ -24,6 +24,8 @@ char get_char();
char key_to_ascii(uint8_t key);
char shift_key_to_ascii(uint8_t key);
char get_char_blocking();
}
#endif

View File

@ -8,6 +8,8 @@
#include "keyboard.hpp"
#include "interrupts.hpp"
#include "kernel_utils.hpp"
#include "semaphore.hpp"
#include "spinlock.hpp"
namespace {
@ -95,6 +97,9 @@ char input_buffer[BUFFER_SIZE];
volatile uint8_t start;
volatile uint8_t count;
spinlock lock;
semaphore sem;
void keyboard_handler(const interrupt::syscall_regs&){
auto key = static_cast<char>(in_byte(0x60));
@ -107,15 +112,22 @@ void keyboard_handler(const interrupt::syscall_regs&){
}
}
}
} //end of anonymous namespace
void keyboard::install_driver(){
interrupt::register_irq_handler(1, keyboard_handler);
start = 0;
count = 0;
sem.init(0);
}
char blocking::get_char_blocking(){
//TODO
}
//TODO Once shell is user mode, can be removed
char keyboard::get_char(){
//Wait for the buffer to contains something
while(count == 0){

View File

@ -8,6 +8,7 @@
#include "system_calls.hpp"
#include "console.hpp"
#include "scheduler.hpp"
#include "keyboard.hpp"
namespace {
@ -23,6 +24,11 @@ void sc_print_digit(const interrupt::syscall_regs& regs){
k_print(regs.rbx);
}
void sc_get_char(const interrupt::syscall_regs& regs){
auto c = keyboard::get_char_blocking();
//TODO
}
} //End of anonymous namespace
void system_call_entry(const interrupt::syscall_regs& regs){
@ -41,6 +47,10 @@ void system_call_entry(const interrupt::syscall_regs& regs){
sc_print_digit(regs);
break;
case 3:
sc_get_char(regs);
break;
case 0x666:
scheduler::kill_current_process(regs);
break;