/uspace/trunk/kbd/include/keys.h |
---|
0,0 → 1,48 |
/* |
* Copyright (C) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef _KBD_KEYS_H_ |
#define _KBD_KEYS_H_ |
#define KBD_PUSHCHAR 1024 |
#define KBD_KEY_F1 0x3b |
#define KBD_KEY_F2 0x3c |
#define KBD_KEY_F3 0x3d |
#define KBD_KEY_F4 0x3e |
#define KBD_KEY_F5 0x3f |
#define KBD_KEY_F6 0x40 |
#define KBD_KEY_F7 0x41 |
#define KBD_KEY_F8 0x42 |
#define KBD_KEY_F9 0x43 |
#define KBD_KEY_F10 0x44 |
#define KBD_KEY_F11 0x45 |
#define KBD_KEY_F12 0x46 |
#endif |
/uspace/trunk/kbd/include/kbd.h |
---|
37,20 → 37,8 |
#ifndef __KBD_H__ |
#define __KBD_H__ |
#define KBD_PUSHCHAR 1024 |
#define KBD_KEY_F1 0x3b |
#define KBD_KEY_F2 0x3c |
#define KBD_KEY_F3 0x3d |
#define KBD_KEY_F4 0x3e |
#define KBD_KEY_F5 0x3f |
#define KBD_KEY_F6 0x40 |
#define KBD_KEY_F7 0x41 |
#define KBD_KEY_F8 0x42 |
#define KBD_KEY_F9 0x43 |
#define KBD_KEY_F10 0x44 |
#define KBD_KEY_F11 0x45 |
#define KBD_KEY_F12 0x46 |
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call); |
#endif |
/uspace/trunk/kbd/generic/kbd.c |
---|
52,6 → 52,7 |
#include <libadt/fifo.h> |
#include <key_buffer.h> |
#include <async.h> |
#include <keys.h> |
#define NAME "KBD" |
65,7 → 66,7 |
if (cons_connected && phone2cons != -1) { |
/* recode to ASCII - one interrupt can produce more than one code so result is stored in fifo */ |
kbd_arch_process(&keybuffer, IPC_GET_ARG2(*call)); |
kbd_arch_process(&keybuffer, call); |
while (!keybuffer_empty(&keybuffer)) { |
if (!keybuffer_pop(&keybuffer, (int *)&chr)) |
123,9 → 124,8 |
ipcarg_t retval, arg1, arg2; |
/* Initialize arch dependent parts */ |
if (!(res = kbd_arch_init())) { |
if (kbd_arch_init()) |
return -1; |
}; |
/* Initialize key buffer */ |
keybuffer_init(&keybuffer); |
/uspace/trunk/kbd/arch/ia64/include/kbd.h |
---|
41,7 → 41,6 |
#include <key_buffer.h> |
int kbd_arch_init(void); |
int kbd_arch_process(keybuffer_t *keybuffer, int scan_code); |
#endif |
/uspace/trunk/kbd/arch/ia64/src/kbd.c |
---|
37,6 → 37,8 |
#include <arch/kbd.h> |
#include <ipc/ipc.h> |
#include <sysinfo.h> |
#include <kbd.h> |
#include <keys.h> |
#define KEY_F1 0x504f1b |
#define KEY_F2 0x514f1b |
55,7 → 57,7 |
#define FUNCTION_KEYS 0x100 |
irq_cmd_t ski_cmds[1] = { |
{ CMD_IA64_GETCHAR, 0, 0 } |
{ CMD_IA64_GETCHAR, 0, 0, 2 } |
}; |
irq_code_t ski_kbd = { |
67,11 → 69,11 |
{ |
if(sysinfo_value("kbd")) { |
ipc_register_irq(sysinfo_value("kbd.irq"), &ski_kbd); |
return 0; |
} |
return 1; |
} |
} |
/* |
* Please preserve this code (it can be used to determine scancodes) |
* |
81,11 → 83,12 |
} |
*/ |
int kbd_arch_process(keybuffer_t *keybuffer, int scan_code) |
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
static unsigned long long buf=0; |
static int count=0; |
static int esc_count=0; |
int scan_code = IPC_GET_ARG2(*call); |
/* |
/uspace/trunk/kbd/arch/ppc32/include/kbd.h |
---|
40,7 → 40,6 |
#include <key_buffer.h> |
int kbd_arch_init(void); |
int kbd_arch_process(keybuffer_t *keybuffer, int scan_code); |
#endif |
/uspace/trunk/kbd/arch/ppc32/src/kbd.c |
---|
37,9 → 37,11 |
#include <arch/kbd.h> |
#include <ipc/ipc.h> |
#include <sysinfo.h> |
#include <kbd.h> |
#include <keys.h> |
irq_cmd_t cuda_cmds[1] = { |
{ CMD_PPC32_GETCHAR, 0, 0 } |
{ CMD_PPC32_GETCHAR, 0, 0, 2 } |
}; |
irq_code_t cuda_kbd = { |
181,15 → 183,17 |
int kbd_arch_init(void) |
{ |
return (!ipc_register_irq(sysinfo_value("cuda.irq"), &cuda_kbd)); |
return ipc_register_irq(sysinfo_value("cuda.irq"), &cuda_kbd); |
} |
int kbd_arch_process(keybuffer_t *keybuffer, int scan_code) |
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
if (scan_code != -1) { |
uint8_t scancode = (uint8_t) scan_code; |
int param = IPC_GET_ARG2(*call); |
if (param != -1) { |
uint8_t scancode = (uint8_t) param; |
if ((scancode & 0x80) != 0x80) { |
int key = lchars[scancode & 0x7f]; |
/uspace/trunk/kbd/arch/mips32/include/kbd.h |
---|
40,7 → 40,6 |
#include <key_buffer.h> |
int kbd_arch_init(void); |
int kbd_arch_process(keybuffer_t *keybuffer, int scan_code); |
#endif |
/uspace/trunk/kbd/arch/mips32/src/kbd.c |
---|
36,8 → 36,9 |
#include <arch/kbd.h> |
#include <ipc/ipc.h> |
#include <sysinfo.h> |
#include <kbd.h> |
#include <keys.h> |
#define MSIM_KEY_F1 0x504f1bL |
#define MSIM_KEY_F2 0x514f1bL |
#define MSIM_KEY_F3 0x524f1bL |
70,7 → 71,7 |
irq_cmd_t msim_cmds[1] = { |
{ CMD_MEM_READ_1, (void *)0xB0000000, 0 } |
{ CMD_MEM_READ_1, (void *)0xB0000000, 0, 2 } |
}; |
irq_code_t msim_kbd = { |
85,7 → 86,7 |
ipc_register_irq(2, &msim_kbd); |
msim=sysinfo_value("machine.msim"); |
gxemul=sysinfo_value("machine.lgxemul"); |
return 1; |
return 0; |
} |
373,9 → 374,9 |
return 1; |
} |
int kbd_arch_process(keybuffer_t *keybuffer, int scan_code) |
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
int scan_code = IPC_GET_ARG2(*call); |
static int esc_count=0; |
/uspace/trunk/kbd/arch/ia32/include/kbd.h |
---|
27,7 → 27,7 |
*/ |
/** @addtogroup kbdamd64 amd64 |
* @brief HelenOS ia32 / amd64 arch dependent parts of uspace keyboard handler. |
* @brief HelenOS ia32 / amd64 arch dependent parts of uspace keyboard and mouse handler. |
* @ingroup kbd |
* @{ |
*/ |
40,9 → 40,40 |
#define __ia32_KBD_H__ |
#include <key_buffer.h> |
#include <ddi.h> |
#include <libarch/ddi.h> |
#define KBD_IRQ 1 |
#define MOUSE_IRQ 12 |
#define i8042_DATA 0x60 |
#define i8042_STATUS 0X64 |
typedef unsigned char u8; |
typedef short u16; |
static inline void i8042_data_write(u8 data) |
{ |
outb(i8042_DATA, data); |
} |
static inline u8 i8042_data_read(void) |
{ |
return inb(i8042_DATA); |
} |
static inline u8 i8042_status_read(void) |
{ |
return inb(i8042_STATUS); |
} |
static inline void i8042_command_write(u8 command) |
{ |
outb(i8042_STATUS, command); |
} |
int kbd_arch_init(void); |
int kbd_arch_process(keybuffer_t *keybuffer, int scan_code); |
#endif |
/uspace/trunk/kbd/arch/ia32/src/kbd.c |
---|
38,7 → 38,31 |
#include <arch/kbd.h> |
#include <ipc/ipc.h> |
#include <unistd.h> |
#include <kbd.h> |
#include <keys.h> |
/* Interesting bits for status register */ |
#define i8042_OUTPUT_FULL 0x1 |
#define i8042_INPUT_FULL 0x2 |
#define i8042_MOUSE_DATA 0x20 |
/* Command constants */ |
#define i8042_CMD_KBD 0x60 |
#define i8042_CMD_MOUSE 0xd4 |
/* Keyboard cmd byte */ |
#define i8042_KBD_IE 0x1 |
#define i8042_MOUSE_IE 0x2 |
#define i8042_KBD_DISABLE 0x10 |
#define i8042_MOUSE_DISABLE 0x20 |
#define i8042_KBD_TRANSLATE 0x40 |
/* Mouse constants */ |
#define MOUSE_OUT_INIT 0xf4 |
#define MOUSE_ACK 0xfa |
#define SPECIAL 255 |
#define KEY_RELEASE 0x80 |
231,12 → 255,13 |
SPECIAL, /* 0x7f */ |
}; |
irq_cmd_t i8042_cmds[1] = { |
{ CMD_PORT_READ_1, (void *)0x60, 0 } |
irq_cmd_t i8042_cmds[2] = { |
{ CMD_PORT_READ_1, (void *)0x64, 0, 1 }, |
{ CMD_PORT_READ_1, (void *)0x60, 0, 2 } |
}; |
irq_code_t i8042_kbd = { |
1, |
2, |
i8042_cmds |
}; |
354,16 → 379,81 |
} |
} |
static void wait_ready(void) { |
while (i8042_status_read() & i8042_INPUT_FULL) |
; |
} |
/** Register uspace irq handler |
* @return |
*/ |
int kbd_arch_init(void) |
{ |
return !(ipc_register_irq(1, &i8042_kbd)); |
int rc1, i; |
int mouseenabled = 0; |
iospace_enable(task_get_id(),(void *)i8042_DATA, 5); |
/* Disable kbd, enable mouse */ |
i8042_command_write(i8042_CMD_KBD); |
wait_ready(); |
i8042_command_write(i8042_CMD_KBD); |
wait_ready(); |
i8042_data_write(i8042_KBD_DISABLE); |
wait_ready(); |
/* Flush all current IO */ |
while (i8042_status_read() & i8042_OUTPUT_FULL) |
i8042_data_read(); |
/* Initialize mouse */ |
i8042_command_write(i8042_CMD_MOUSE); |
wait_ready(); |
i8042_data_write(MOUSE_OUT_INIT); |
wait_ready(); |
int mouseanswer = 0; |
for (i=0;i < 1000; i++) { |
int status = i8042_status_read(); |
if (status & i8042_OUTPUT_FULL) { |
int data = i8042_data_read(); |
if (status & i8042_MOUSE_DATA) { |
mouseanswer = data; |
break; |
} |
} |
usleep(1000); |
} |
if (mouseanswer == MOUSE_ACK) { |
/* enable mouse */ |
mouseenabled = 1; |
int kbd_arch_process(keybuffer_t *keybuffer, int scan_code) |
ipc_register_irq(MOUSE_IRQ, &i8042_kbd); |
} |
/* Enable kbd */ |
ipc_register_irq(KBD_IRQ, &i8042_kbd); |
int newcontrol = i8042_KBD_IE | i8042_KBD_TRANSLATE; |
if (mouseenabled) |
newcontrol |= i8042_MOUSE_IE; |
i8042_command_write(i8042_CMD_KBD); |
wait_ready(); |
i8042_data_write(newcontrol); |
wait_ready(); |
return 0; |
} |
/** Process keyboard & mouse events */ |
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) |
{ |
int status = IPC_GET_ARG1(*call); |
if ((status & i8042_MOUSE_DATA)) { |
; |
} else { |
int scan_code = IPC_GET_ARG2(*call); |
if (scan_code != IGNORE_CODE) { |
if (scan_code & KEY_RELEASE) |
key_released(keybuffer, scan_code ^ KEY_RELEASE); |
370,6 → 460,7 |
else |
key_pressed(keybuffer, scan_code); |
} |
} |
return 1; |
} |