Subversion Repositories HelenOS-historic

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1693 → Rev 1694

/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"
 
62,10 → 63,10
static void irq_handler(ipc_callid_t iid, ipc_call_t *call)
{
int chr;
 
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())) {
return -1;
};
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,9 → 69,9
{
if(sysinfo_value("kbd")) {
ipc_register_irq(sysinfo_value("kbd.irq"), &ski_kbd);
return 1;
return 0;
}
return 1;
}
 
/*
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,14 → 183,16
 
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,21 → 379,87
}
}
 
 
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;
 
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;
}
 
int kbd_arch_process(keybuffer_t *keybuffer, int scan_code)
/** Process keyboard & mouse events */
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
{
if (scan_code != IGNORE_CODE) {
if (scan_code & KEY_RELEASE)
key_released(keybuffer, scan_code ^ KEY_RELEASE);
else
key_pressed(keybuffer, scan_code);
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);
else
key_pressed(keybuffer, scan_code);
}
}
return 1;
}
/uspace/trunk/console/console.c
36,10 → 36,9
/* TODO: remove */
#include <stdio.h>
 
 
#include <kbd.h>
#include <fb.h>
#include <ipc/ipc.h>
#include <keys.h>
#include <ipc/fb.h>
#include <ipc/services.h>
#include <errno.h>
/uspace/trunk/fb/ega.c
49,6 → 49,7
#include <ipc/ipc.h>
#include <ipc/ns.h>
#include <ipc/services.h>
#include <libarch/ddi.h>
 
#include "ega.h"
#include "../console/screenbuffer.h"
70,11 → 71,6
 
#define EGA_STYLE(fg,bg) ((fg) > (bg) ? NORMAL_COLOR : INVERTED_COLOR)
 
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
 
 
/* Allow only 1 connection */
static int client_connected = 0;
 
84,48 → 80,6
 
static unsigned int style = NORMAL_COLOR;
 
static inline void outb(u16 port, u8 b)
{
asm volatile ("outb %0, %1\n" :: "a" (b), "d" (port));
}
 
static inline void outw(u16 port, u16 w)
{
asm volatile ("outw %0, %1\n" :: "a" (w), "d" (port));
}
 
static inline void outl(u16 port, u32 l)
{
asm volatile ("outl %0, %1\n" :: "a" (l), "d" (port));
}
 
static inline u8 inb(u16 port)
{
u8 val;
 
asm volatile ("inb %1, %0 \n" : "=a" (val) : "d"(port));
return val;
}
 
static inline u16 inw(u16 port)
{
u16 val;
 
asm volatile ("inw %1, %0 \n" : "=a" (val) : "d"(port));
return val;
}
 
static inline u32 inl(u16 port)
{
u32 val;
 
asm volatile ("inl %1, %0 \n" : "=a" (val) : "d"(port));
return val;
}
 
 
 
 
static void clrscr(void)
{
int i;
150,7 → 104,8
 
static void cursor_disable(void)
{
u8 stat;
uint8_t stat;
 
outb(EGA_IO_ADDRESS , 0xa);
stat=inb(EGA_IO_ADDRESS + 1);
outb(EGA_IO_ADDRESS , 0xa);
159,7 → 114,8
 
static void cursor_enable(void)
{
u8 stat;
uint8_t stat;
 
outb(EGA_IO_ADDRESS , 0xa);
stat=inb(EGA_IO_ADDRESS + 1);
outb(EGA_IO_ADDRESS , 0xa);
/uspace/trunk/libc/generic/async.c
448,12 → 448,14
static void handle_call(ipc_callid_t callid, ipc_call_t *call)
{
/* Unrouted call - do some default behaviour */
switch (IPC_GET_METHOD(*call)) {
case IPC_M_INTERRUPT:
if ((callid & IPC_CALLID_NOTIFICATION)) {
in_interrupt_handler = 1;
(*interrupt_received)(callid,call);
in_interrupt_handler = 0;
return;
}
 
switch (IPC_GET_METHOD(*call)) {
case IPC_M_CONNECT_ME_TO:
/* Open new connection with thread etc. */
async_new_connection(IPC_GET_ARG3(*call), callid, call, client_connection);
/uspace/trunk/libc/arch/amd64/include/ddi.h
0,0 → 1,0
link ../../ia32/include/ddi.h
Property changes:
Added: svn:special
+*
\ No newline at end of property
/uspace/trunk/libc/arch/ia32/include/ddi.h
0,0 → 1,72
/*
* Copyright (C) 2006 Ondrej Palkovsky
* 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 __ia32_libc_DDI_H_
#define __ia32_libc_DDI_H_
 
static inline void outb(int16_t port, uint8_t b)
{
asm volatile ("outb %0, %1\n" :: "a" (b), "d" (port));
}
 
static inline void outw(int16_t port, int16_t w)
{
asm volatile ("outw %0, %1\n" :: "a" (w), "d" (port));
}
 
static inline void outl(int16_t port, uint32_t l)
{
asm volatile ("outl %0, %1\n" :: "a" (l), "d" (port));
}
 
static inline uint8_t inb(int16_t port)
{
uint8_t val;
 
asm volatile ("inb %1, %0 \n" : "=a" (val) : "d"(port));
return val;
}
 
static inline int16_t inw(int16_t port)
{
int16_t val;
 
asm volatile ("inw %1, %0 \n" : "=a" (val) : "d"(port));
return val;
}
 
static inline uint32_t inl(int16_t port)
{
uint32_t val;
 
asm volatile ("inl %1, %0 \n" : "=a" (val) : "d"(port));
return val;
}
 
 
#endif
/uspace/trunk/klog/klog.c
49,8 → 49,8
int i;
async_serialize_start();
for (i=0; klog[i + IPC_GET_ARG2(*call)] && i < IPC_GET_ARG3(*call); i++)
putchar(klog[i + IPC_GET_ARG2(*call)]);
for (i=0; klog[i + IPC_GET_ARG1(*call)] && i < IPC_GET_ARG2(*call); i++)
putchar(klog[i + IPC_GET_ARG1(*call)]);
putchar('\n');
async_serialize_end();
}