Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4628 → Rev 4629

/branches/arm/uspace/srv/kbd/Makefile
72,9 → 72,18
genarch/src/kbd.c
endif
ifeq ($(ARCH), arm32)
GENARCH_SOURCES = \
genarch/src/kbd.c
ifeq ($(MACHINE), gxemul_testarm)
ARCH_SOURCES += \
arch/$(ARCH)/src/kbd_gxemul.c
endif
ifeq ($(MACHINE), qemu_icp)
ARCH_SOURCES += \
arch/$(ARCH)/src/kbd_icp.c \
arch/$(ARCH)/src/scanc.c
endif
endif
 
 
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
/branches/arm/uspace/srv/kbd/arch/arm32/include/pl050.h
0,0 → 1,82
/*
* Copyright (c) 2009 Vineeth Pillai
* 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.
*/
 
/** @addtogroup kdbarm32
* @{
*/
/** @file
*/
 
/**
* This file implements pl050 specific functions for keyboard and mouse
*/
 
#ifndef KBD_arm32_PL050_H_
#define KBD_arm32_PL050_H_
 
 
/*
* pl050 register offsets from the base address
*/
#define PL050_CR 0x00
#define PL050_STAT 0x04
#define PL050_DATA 0x08
#define PL050_CLOCKDIV 0x0C
#define PL050_INTRSTAT 0x10
 
/*
* Control Register Bits
*/
#define PL050_CR_TYPE (1 << 5) /* Type 0: PS2/AT mode, 1: No Line control bit mode */
#define PL050_CR_RXINTR (1 << 4) /* Recieve Interrupt Enable */
#define PL050_CR_TXINTR (1 << 3) /* Transmit Interrupt Enable */
#define PL050_CR_INTR (1 << 2) /* Interrupt Enable */
#define PL050_CR_FKMID (1 << 1) /* Force KMI Data Low */
#define PL050_CR_FKMIC 1 /* Force KMI Clock Low */
 
/*
* Status register bits
*/
#define PL050_STAT_TXEMPTY (1 << 6) /* 1: Transmit register empty */
#define PL050_STAT_TXBUSY (1 << 5) /* 1: Busy, sending data */
#define PL050_STAT_RXFULL (1 << 4) /* 1: register Full */
#define PL050_STAT_RXBUSY (1 << 3) /* 1: Busy, recieving Data */
#define PL050_STAT_RXPARITY (1 << 2) /* odd parity of the last bit recieved */
#define PL050_STAT_KMIC (1 << 1) /* status of KMICLKIN */
#define PL050_STAT_KMID 1 /* status of KMIDATAIN */
 
/*
* Interrupt status register bits.
*/
#define PL050_TX_INTRSTAT (1 << 1) /* Transmit intr asserted */
#define PL050_RX_INTRSTAT 1 /* Recieve intr asserted */
 
#endif
 
/** @}
*/
/branches/arm/uspace/srv/kbd/arch/arm32/src/scanc.c
0,0 → 1,233
/*
* Copyright (c) 2009 Vineeth Pillai
* 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.
*/
 
/** @addtogroup genarch
* @{
*/
/**
* @file
* @brief Scan codes for pl050 keyboards.
*/
 
#define FUNCTION_KEYS 0x100
#define SPECIAL 255
 
/** Primary meaning of scancodes. */
int sc_primary_map[] = {
SPECIAL, /* 0x00 */
(FUNCTION_KEYS | 9), /* 0x01 - F9 */
(FUNCTION_KEYS | 7), /* 0x02 - F7 */
(FUNCTION_KEYS | 5), /* 0x03 - F5 */
(FUNCTION_KEYS | 3), /* 0x04 - F3 */
(FUNCTION_KEYS | 1), /* 0x05 - F1 */
(FUNCTION_KEYS | 2), /* 0x06 - F2 */
(FUNCTION_KEYS | 12), /* 0x07 - F12 */
SPECIAL, /* 0x08 - */
(FUNCTION_KEYS | 10), /* 0x09 - F10 */
(FUNCTION_KEYS | 8), /* 0x0A - F8 */
(FUNCTION_KEYS | 6), /* 0x0B - F6 */
(FUNCTION_KEYS | 4), /* 0x0C - F4 */
'\t', /* 0x0D - Tab */
'~',
SPECIAL, /* 0x0F */
SPECIAL, /* 0x10 */
SPECIAL, /* 0x11 - LAlt */
SPECIAL, /* 0x12 - LShift */
SPECIAL, /* ox13 */
SPECIAL, /* 0x14 Ctrl */
'q', '1',
SPECIAL, /* 0x17 */
SPECIAL, /* 0x18 */
SPECIAL, /* 0x19 */
'z', 's', 'a', 'w', '2',
SPECIAL, /* 0x1F */
SPECIAL, /* 0x20 */
'c', 'x', 'd', 'e', '4', '3',
SPECIAL, /* 0x27 */
SPECIAL, /* 0x28 */
' ', 'v', 'f', 't', 'r', '5',
SPECIAL, /* 0x2F */
SPECIAL, /* 0x30 */
'n', 'b', 'h', 'g', 'y', '6',
SPECIAL, /* 0x37 */
SPECIAL, /* 0x38 */
SPECIAL, /* 0x39 */
'm', 'j', 'u', '7', '8',
SPECIAL, /* 0x3F */
SPECIAL, /* 0x40 */
',', 'k', 'i', 'o', '0', '9',
SPECIAL, /* 0x47 */
SPECIAL, /* 0x48 */
'.', '/', 'l', ';', 'p', '-',
SPECIAL, /* 0x4F */
SPECIAL, /* 0x50 */
'\'',
SPECIAL, /* 0x52 */
SPECIAL, /* 0x53 */
'{', '=',
SPECIAL, /* 0x56 */
SPECIAL, /* 0x57 */
SPECIAL, /* 0x58 - Caps Lock */
SPECIAL, /* 0x59 - RShift */
'\n', '}',
SPECIAL, /* 0x5C */
'\\',
SPECIAL, /* 0x5E */
SPECIAL, /* 0x5F */
SPECIAL, /* 0x60 */
SPECIAL, /* 0x61 */
SPECIAL, /* 0x62 */
SPECIAL, /* 0x63 */
SPECIAL, /* 0x64 */
SPECIAL, /* 0x65 */
'\b', /* 0x66 - backspace*/
SPECIAL, /* 0x67 */
SPECIAL, /* 0x68 */
SPECIAL, /* 0x69 */
SPECIAL, /* 0x6a */
SPECIAL, /* 0x6b - Left Arrow */
SPECIAL, /* 0x6c */
SPECIAL, /* 0x6d */
SPECIAL, /* 0x6e */
SPECIAL, /* 0x6f */
SPECIAL, /* 0x70 - Del */
SPECIAL, /* 0x71 */
SPECIAL, /* 0x72 Down Arrow */
SPECIAL, /* 0x73 */
SPECIAL, /* 0x74 - Right Arrow */
SPECIAL, /* 0x75 Up Arrow */
SPECIAL, /* 0x76 Esc */
SPECIAL, /* 0x77 - NumLock*/
SPECIAL, /* 0x78 F11*/
SPECIAL, /* 0x79 */
SPECIAL, /* 0x7a */
SPECIAL, /* 0x7b */
SPECIAL, /* 0x7c */
SPECIAL, /* 0x7d */
SPECIAL, /* 0x7e */
SPECIAL /* 0x7f */
};
 
/** Secondary meaning of scancodes. */
int sc_secondary_map[] = {
SPECIAL, /* 0x00 */
SPECIAL, /* 0x01 - F9 */
SPECIAL, /* 0x02 - F7 */
SPECIAL, /* 0x03 - F5 */
SPECIAL, /* 0x04 - F3 */
SPECIAL, /* 0x05 - F1 */
SPECIAL, /* 0x06 - F2 */
SPECIAL, /* 0x07 - F12 */
SPECIAL, /* 0x08 - */
SPECIAL, /* 0x09 - F10 */
SPECIAL, /* 0x0A - F8 */
SPECIAL, /* 0x0B - F10 */
SPECIAL, /* 0x0C - F4 */
'\t', /* 0x0D - Tab */
'~',
SPECIAL, /* 0x0F */
SPECIAL, /* 0x10 */
SPECIAL, /* 0x11 - LAlt */
SPECIAL, /* 0x12 - LShift */
SPECIAL, /* ox13 */
SPECIAL, /* 0x14 Ctrl */
'Q', '!',
SPECIAL, /* 0x17 */
SPECIAL, /* 0x18 */
SPECIAL, /* 0x19 */
'Z', 'S', 'A', 'W', '@',
SPECIAL, /* 0x1F */
SPECIAL, /* 0x20 */
'C', 'X', 'D', 'E', '$', '#',
SPECIAL, /* 0x27 */
SPECIAL, /* 0x28 */
' ', 'V', 'F', 'T', 'R', '%',
SPECIAL, /* 0x2F */
SPECIAL, /* 0x30 */
'N', 'B', 'H', 'G', 'Y', '^',
SPECIAL, /* 0x37 */
SPECIAL, /* 0x38 */
SPECIAL, /* 0x39 */
'M', 'J', 'U', '&', '*',
SPECIAL, /* 0x3F */
SPECIAL, /* 0x40 */
'<', 'K', 'I', 'O', ')', '(',
SPECIAL, /* 0x47 */
SPECIAL, /* 0x48 */
'>', '?', 'L', ':', 'P', '_',
SPECIAL, /* 0x4F */
SPECIAL, /* 0x50 */
'"',
SPECIAL, /* 0x52 */
SPECIAL, /* 0x53 */
'{', '+',
SPECIAL, /* 0x56 */
SPECIAL, /* 0x57 */
SPECIAL, /* 0x58 - Caps Lock */
SPECIAL, /* 0x59 - RShift */
'\n', '}',
SPECIAL, /* 0x5C */
'|',
SPECIAL, /* 0x5E */
SPECIAL, /* 0x5F */
SPECIAL, /* 0x60 */
SPECIAL, /* 0x61 */
SPECIAL, /* 0x62 */
SPECIAL, /* 0x63 */
SPECIAL, /* 0x64 */
SPECIAL, /* 0x65 */
'\b', /* 0x66 - backspace*/
SPECIAL, /* 0x67 */
SPECIAL, /* 0x68 */
SPECIAL, /* 0x69 */
SPECIAL, /* 0x6a */
SPECIAL, /* 0x6b - Left Arrow */
SPECIAL, /* 0x6c */
SPECIAL, /* 0x6d */
SPECIAL, /* 0x6e */
SPECIAL, /* 0x6f */
SPECIAL, /* 0x70 - Del */
SPECIAL, /* 0x71 */
SPECIAL, /* 0x72 Down Arrow */
SPECIAL, /* 0x73 */
SPECIAL, /* 0x74 - Right Arrow */
SPECIAL, /* 0x75 Up Arrow */
SPECIAL, /* 0x76 Esc */
SPECIAL, /* 0x77 - NumLock*/
SPECIAL, /* 0x78 F11*/
SPECIAL, /* 0x79 */
SPECIAL, /* 0x7a */
SPECIAL, /* 0x7b */
SPECIAL, /* 0x7c */
SPECIAL, /* 0x7d */
SPECIAL, /* 0x7e */
SPECIAL /* 0x7f */
};
 
/** @}
*/
/branches/arm/uspace/srv/kbd/arch/arm32/src/kbd_icp.c
0,0 → 1,116
/*
* Copyright (c) 2001-2004 Jakub Jermar
* Copyright (c) 2006 Josef Cejka
* Copyright (c) 2009 Vineeth Pillai
* 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.
*/
 
/** @addtogroup kbdarm32 arm32
* @brief HelenOS arm32/integratorcp arch dependent parts of uspace keyboard handler.
* @ingroup kbd
* @{
*/
/** @file
* @ingroup kbdarm32
*/
#include <stdio.h>
#include <arch/kbd.h>
#include <ipc/ipc.h>
#include <unistd.h>
#include <kbd.h>
#include <arch/pl050.h>
#include <keys.h>
#include <genarch/kbd.h>
#include <sysinfo.h>
#include <as.h>
#include <ipc/ipc.h>
#include <ipc/ns.h>
#include <ipc/services.h>
#include <ddi.h>
#include <align.h>
 
#define PL050_KEY_RELEASE 0xF0
#define PL050_ESC_KEY 0xE0
 
irq_cmd_t pl050_cmds[] = {
{ CMD_MEM_READ_1, (void *) 0, 0, 1 },
{ CMD_MEM_READ_1, (void *) 0, 0, 2}
};
 
irq_code_t pl050_kbd = {
2,
pl050_cmds
};
 
 
static void *kbd_physaddr;
static void *kbd_addr;
 
/** Register uspace irq handler
* @return
*/
int kbd_arch_init(void)
{
kbd_physaddr = (void *)sysinfo_value("kbd.pbase");
 
kbd_addr = (void*)sysinfo_value("kbd.vbase");
 
pl050_cmds[0].addr = (void *)(kbd_addr+PL050_DATA);
pl050_cmds[1].addr = (void *)(kbd_addr+PL050_STAT);
 
/* Enable kbd */
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &pl050_kbd);
 
return 0;
}
 
/** Process keyboard & mouse events */
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
{
static int key_released_flag = 0;
static uint8_t prev_char = 0xFF;
int scan_code = IPC_GET_ARG1(*call);
 
if (scan_code == PL050_KEY_RELEASE) {
key_released_flag = 1;
} else {
if (key_released_flag && prev_char == scan_code) {
prev_char = 0xFF;
key_released(keybuffer, scan_code);
} else {
key_pressed(keybuffer, scan_code);
prev_char = scan_code;
}
key_released_flag = 0;
}
 
return 1;
}
 
/**
* @}
*/