Our devfs currently keeps drivers around, so it's not a good idea to

install interrupt handlers in init_driver().
The downside of this is that you can now only use F12 to drop into
the debugger when the console appeared (not before).
This way, the driver no longer causes ps2_hid to not be able to
disable or enable the keyboard (which means you can keep them both
installed without worries).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12732 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-05-19 14:30:27 +00:00
parent fe9bc5ae27
commit d1783112af

View File

@ -64,6 +64,8 @@ static mutex keyboard_read_mutex;
static char keyboard_buf[1024];
static unsigned int head, tail;
static isa_module_info *gISA;
static int32 sOpenCount = 0;
// begins with HOME, end with CURSOR_DOWN
static const char sControlKeys[] = {'@', 'A', 0, 0, 'D', 0, 'C', 0, '[', 'B'};
@ -254,22 +256,57 @@ handle_keyboard_interrupt(void *data)
static status_t
keyboard_open(const char *name, uint32 flags, void **cookie)
{
if (atomic_add(&sOpenCount, 1) != 0) {
*cookie = NULL;
return 0;
return B_OK;
}
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 = false;
sControl = false;
leds = 0;
// have the scroll lock reflect the state of serial debugging
#if 0
if (dbg_get_serial_debug())
leds |= LED_SCROLL;
#endif
set_leds();
head = tail = 0;
install_io_interrupt_handler(0x01, &handle_keyboard_interrupt, NULL, 0);
*cookie = NULL;
return B_OK;
}
static status_t
keyboard_close(void *cookie)
{
return 0;
if (atomic_add(&sOpenCount, -1) != 1)
return B_OK;
remove_io_interrupt_handler(0x01, &handle_keyboard_interrupt, NULL);
delete_sem(keyboard_sem);
mutex_destroy(&keyboard_read_mutex);
return B_OK;
}
static status_t
keyboard_freecookie(void *cookie)
{
return 0;
return B_OK;
}
@ -371,7 +408,7 @@ device_hooks keyboard_hooks = {
status_t
init_hardware()
init_hardware(void)
{
return B_OK;
}
@ -400,44 +437,17 @@ find_device(const char *name)
status_t
init_driver()
init_driver(void)
{
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 = false;
sControl = false;
leds = 0;
// have the scroll lock reflect the state of serial debugging
#if 0
if (dbg_get_serial_debug())
leds |= LED_SCROLL;
#endif
set_leds();
head = tail = 0;
install_io_interrupt_handler(0x01, &handle_keyboard_interrupt, NULL, 0);
return B_ENTRY_NOT_FOUND;
return B_OK;
}
void
uninit_driver()
uninit_driver(void)
{
remove_io_interrupt_handler(0x01, &handle_keyboard_interrupt, NULL);
delete_sem(keyboard_sem);
mutex_destroy(&keyboard_read_mutex);
put_module(B_ISA_MODULE_NAME);
}