From ffbc2ebc23ec7a4dd054a23f171fac1bb4f5a981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 18 Aug 2003 03:53:01 +0000 Subject: [PATCH] Moved the driver initialization from init_hardware() to the more common init_driver() - also added a matching uninit_driver() (just in case :)). Replaced in8()/out8() with calls to the ISA bus manager (NewOS change 1804). Removed unused includes. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4301 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../drivers/arch/x86/keyboard/keyboard.c | 77 +++++++++++-------- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/src/add-ons/kernel/drivers/arch/x86/keyboard/keyboard.c b/src/add-ons/kernel/drivers/arch/x86/keyboard/keyboard.c index d5ac6c4b16..6a4d53d6a1 100644 --- a/src/add-ons/kernel/drivers/arch/x86/keyboard/keyboard.c +++ b/src/add-ons/kernel/drivers/arch/x86/keyboard/keyboard.c @@ -3,16 +3,14 @@ ** Distributed under the terms of the NewOS License. */ -#include -#include -#include -#include + +#include +#include #include +#include + #include #include -#include -#include -#include #define DEVICE_NAME "keyboard" @@ -54,6 +52,7 @@ static sem_id keyboard_sem; static mutex keyboard_read_mutex; static char keyboard_buf[1024]; static unsigned int head, tail; +static isa_module_info *gISA; // stolen from nujeffos const char unshifted_keymap[128] = { @@ -93,7 +92,7 @@ const char caps_keymap[128] = { static void wait_for_output(void) { - while (in8(0x64) & 0x2) + while (gISA->read_io_8(0x64) & 0x2) ; } @@ -102,9 +101,9 @@ static void set_leds(void) { wait_for_output(); - out8(0xed, 0x60); + gISA->write_io_8(0xed, 0x60); wait_for_output(); - out8(leds, 0x60); + gISA->write_io_8(leds, 0x60); } @@ -132,7 +131,7 @@ handle_keyboard_interrupt(void *data) unsigned char key; int32 retval = B_HANDLED_INTERRUPT; - key = in8(0x60); + key = gISA->read_io_8(0x60); TRACE(("handle_keyboard_interrupt: key = 0x%x\n", key)); if (key & 0x80) { @@ -215,6 +214,9 @@ handle_keyboard_interrupt(void *data) } +// #pragma mark - + + static status_t keyboard_open(const char *name, uint32 flags, void **cookie) { @@ -330,31 +332,14 @@ device_hooks keyboard_hooks = { }; +// #pragma mark - /***** driver hooks *****/ + status_t init_hardware() { - keyboard_sem = create_sem(0, "keyboard_sem"); - if (keyboard_sem < 0) - panic("could not create keyboard sem!\n"); - - if (mutex_init(&keyboard_read_mutex, "keyboard_read_mutex") < 0) - panic("could not create keyboard read mutex!\n"); - - shift = 0; - leds = 0; - - // have the scroll lock reflect the state of serial debugging - if (dbg_get_serial_debug()) - leds |= LED_SCROLL; - set_leds(); - - head = tail = 0; - - install_io_interrupt_handler(0x01, &handle_keyboard_interrupt, NULL, 0); - - return 0; + return B_OK; } @@ -383,11 +368,39 @@ find_device(const char *name) status_t init_driver() { - return 0; + if (get_module(B_ISA_MODULE_NAME, (module_info **)&gISA) < B_OK) + panic("could not get ISA module\n"); + + keyboard_sem = create_sem(0, "keyboard_sem"); + if (keyboard_sem < 0) + panic("could not create keyboard sem!\n"); + + if (mutex_init(&keyboard_read_mutex, "keyboard_read_mutex") < 0) + panic("could not create keyboard read mutex!\n"); + + shift = 0; + leds = 0; + + // have the scroll lock reflect the state of serial debugging + if (dbg_get_serial_debug()) + leds |= LED_SCROLL; + set_leds(); + + head = tail = 0; + + install_io_interrupt_handler(0x01, &handle_keyboard_interrupt, NULL, 0); + + return B_OK; } void uninit_driver() { + remove_io_interrupt_handler(0x01, &handle_keyboard_interrupt, NULL); + + delete_sem(keyboard_sem); + mutex_destroy(&keyboard_read_mutex); + + put_module(B_ISA_MODULE_NAME); }