added ps2 service thread, and some small changes
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15947 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7c446ef048
commit
ecc5f8d78c
@ -10,4 +10,5 @@ KernelAddon ps2_hid_new : kernel drivers bin :
|
||||
keyboard.c
|
||||
mouse.c
|
||||
packet_buffer.cpp
|
||||
ps2_service.c
|
||||
;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "ps2_service.h"
|
||||
|
||||
|
||||
#define DEVICE_MOUSE_NAME "input/mouse/ps2/0"
|
||||
@ -285,6 +286,8 @@ init_driver(void)
|
||||
if (gDeviceOpenSemaphore < B_OK)
|
||||
goto err_2;
|
||||
|
||||
status = ps2_service_init();
|
||||
|
||||
status = install_io_interrupt_handler(INT_PS2_KEYBOARD, &ps2_interrupt, NULL, 0);
|
||||
if (status)
|
||||
goto err_3;
|
||||
@ -330,6 +333,7 @@ err_5:
|
||||
err_4:
|
||||
remove_io_interrupt_handler(INT_PS2_KEYBOARD, &ps2_interrupt, NULL);
|
||||
err_3:
|
||||
ps2_service_exit();
|
||||
delete_sem(gDeviceOpenSemaphore);
|
||||
delete_sem(sKbcSem);
|
||||
err_2:
|
||||
@ -344,6 +348,7 @@ uninit_driver(void)
|
||||
{
|
||||
remove_io_interrupt_handler(INT_PS2_MOUSE, &ps2_interrupt, NULL);
|
||||
remove_io_interrupt_handler(INT_PS2_KEYBOARD, &ps2_interrupt, NULL);
|
||||
ps2_service_exit();
|
||||
delete_sem(gDeviceOpenSemaphore);
|
||||
delete_sem(sKbcSem);
|
||||
put_module(B_ISA_MODULE_NAME);
|
||||
|
@ -163,6 +163,11 @@ probe_keyboard(void)
|
||||
// ToDo: for now there just is a keyboard ready to be used...
|
||||
|
||||
// Keyboard detection does not seem to be working always correctly
|
||||
|
||||
// not sure if this is the correct way
|
||||
ps2_keyboard_command(PS2_CTRL_KEYBOARD_SELF_TEST, NULL, 0, NULL, 0);
|
||||
ps2_keyboard_command(PS2_CTRL_KEYBOARD_SELF_TEST, NULL, 0, NULL, 0);
|
||||
|
||||
#if 0
|
||||
// Keyboard self-test
|
||||
|
||||
|
@ -105,13 +105,12 @@ ps2_reset_mouse()
|
||||
*/
|
||||
|
||||
static status_t
|
||||
ps2_set_sample_rate(uint32 rate)
|
||||
ps2_set_sample_rate(uint8 rate)
|
||||
{
|
||||
int32 tries = 5;
|
||||
|
||||
while (--tries > 0) {
|
||||
uint8 d = rate;
|
||||
status_t status = ps2_mouse_command(PS2_CMD_SET_SAMPLE_RATE, &d, 1, NULL, 0);
|
||||
status_t status = ps2_mouse_command(PS2_CMD_SET_SAMPLE_RATE, &rate, 1, NULL, 0);
|
||||
|
||||
if (status == B_OK)
|
||||
return B_OK;
|
||||
|
59
src/add-ons/kernel/drivers/input/ps2_hid_new/ps2_service.c
Normal file
59
src/add-ons/kernel/drivers/input/ps2_hid_new/ps2_service.c
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2005 Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* PS/2 hid device driver
|
||||
*
|
||||
* Authors (in chronological order):
|
||||
* Marcus Overhagen (marcus@overhagen.de)
|
||||
*/
|
||||
|
||||
#include "ps2_service.h"
|
||||
|
||||
static sem_id sServiceSem;
|
||||
static thread_id sServiceThread;
|
||||
static volatile bool sServiceTerminate;
|
||||
|
||||
|
||||
static int32
|
||||
ps2_service_thread(void *arg)
|
||||
{
|
||||
for (;;) {
|
||||
while (B_INTERRUPTED == acquire_sem(sServiceSem))
|
||||
;
|
||||
if (sServiceTerminate)
|
||||
break;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ps2_service_init(void)
|
||||
{
|
||||
sServiceSem = create_sem(0, "ps2 service");
|
||||
if (sServiceSem < B_OK)
|
||||
goto err1;
|
||||
sServiceThread = spawn_kernel_thread(ps2_service_thread, "ps2 service", 20, NULL);
|
||||
if (sServiceThread < B_OK)
|
||||
goto err2;
|
||||
sServiceTerminate = false;
|
||||
resume_thread(sServiceThread);
|
||||
return B_OK;
|
||||
|
||||
err2:
|
||||
delete_sem(sServiceSem);
|
||||
err1:
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ps2_service_exit(void)
|
||||
{
|
||||
sServiceTerminate = true;
|
||||
release_sem(sServiceSem);
|
||||
wait_for_thread(sServiceThread, NULL);
|
||||
delete_sem(sServiceSem);
|
||||
}
|
18
src/add-ons/kernel/drivers/input/ps2_hid_new/ps2_service.h
Normal file
18
src/add-ons/kernel/drivers/input/ps2_hid_new/ps2_service.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2005 Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* PS/2 hid device driver
|
||||
*
|
||||
* Authors (in chronological order):
|
||||
* Marcus Overhagen (marcus@overhagen.de)
|
||||
*/
|
||||
#ifndef __PS2_SERVICE_H
|
||||
#define __PS2_SERVICE_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
status_t ps2_service_init(void);
|
||||
void ps2_service_exit(void);
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user