Commit 8f1eb461 authored by Ariel Omar Sanhueza Roman's avatar Ariel Omar Sanhueza Roman
Browse files

Implemented modules for keyboard interrupt, his driver and the keyboard...

Implemented modules for keyboard interrupt, his driver and the keyboard buffer. Also a init_drivers functions was created to initialize all drivers (in this case, the keyboard drivers initialize the keyboard buffer
No related merge requests found
Showing with 70 additions and 9 deletions
+70 -9
driver.c 0 → 100644
#include "driver.h"
#include "keyboard.h"
#include "screen.h"
void init_drivers()
{
print_screen("Loading keyboard driver ...");
init_keyboard();
print_screen("DONE.\n");
}
driver.h 0 → 100644
#ifndef _DRIVER_H
#define _DRIVER_H
/* Just a simple function to initialize all drivers */
void init_drivers();
#endif
\ No newline at end of file
......@@ -3,6 +3,7 @@
#include "status.h"
#include "screen.h"
#include "pic.h"
#include "keyboard.h"
/* Exception handler. It will evaluate the value by the interrupt_number
in interrupt_frame */
......@@ -72,11 +73,7 @@ void interrupt_handler(interrupt_frame *frame)
print_screen("PIT interrupt called\n");
break;
case N_KEYBOARD:
// TODO: esto es alpha para sacar los datos del buff del teclado
inb_port(0x64);
char c = inb_port(0x60);
if (c > 0 && c <= 0x58)
print_screen("Keyboard interrupt called\n");
keyboard_handler();
break;
case N_FLOPPY:
print_screen("Floppy disk interrupt called\n");
......
keyboard.c 0 → 100644
#include "keyboard.h"
#include "x86.h"
#include "mutex.h"
#include "pic.h"
/* Buffer to save key pressed. Will be implemeted as a queue.
Queues implemented with arrays use an empty field */
uint8_t keyboard_buffer[KEYBOARD_BUFFER_SIZE + 1];
uint8_t keyboard_buffer_head, keyboard_buffer_tail;
void init_keyboard()
{
keyboard_buffer_tail = 0;
keyboard_buffer_head = -1;
}
void keyboard_handler()
{
uint32_t status;
wait(&keyboard_buffer_mutex);
/* Get status of keyboard */
status = inb_port(KEYBOARD_COMMAND_PORT);
if (status & 0x01) {
/* Get the character */
char keycode = inb_port(KEYBOARD_DATA_PORT);
/* Proccess basic keys (ASCII) */
if (keycode > 0 && keycode < 128) {
print_screen("Keyboard interrupt called.\n");
}
}
signal(&keyboard_buffer_mutex);
}
\ No newline at end of file
keyboard.h 0 → 100644
#ifndef _KEYBOARD_H
#define _KEYBOARD_H
/* Function to manage the keyboard when the keyboard interrupt is called.
Its the driver. */
void keyboard_handler();
/* The size of the keyboard buffer (buffer to save the key pressed) */
#define KEYBOARD_BUFFER_SIZE 100
#endif
\ No newline at end of file
......@@ -2,13 +2,13 @@
#include "x86.h"
#include <stdint.h>
void init_keyboard()
void init_irq_keyboard()
{
/* Init the keyboard doesnt need any special */
/* Init the keyboard doesnt need any special (from PIC), */
return;
}
void init_pit()
void init_irq_pit()
{
/* the PIT frecuency is setted by a divisor. We will set the PIT frequency
to 100 tics per seconds (100Hz) */
......@@ -45,7 +45,7 @@ void init_pic()
outb_port(DATA_SLAVE_PIC, DISABLE_ALL);
/* Now, will init each device drivers one by one */
init_keyboard();
init_irq_keyboard();
/* Enable IRQs */
outb_port(DATA_MASTER_PIC, DISABLE_ALL & KEYBOARD);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment