/branches/arm/kernel/genarch/src/kbrd/kbrd_pl050.c |
---|
0,0 → 1,209 |
/* |
* 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 pl050 Keyboard processing. |
*/ |
#include <genarch/kbrd/kbrd.h> |
#include <genarch/kbrd/scanc.h> |
#include <genarch/kbrd/scanc_pl050.h> |
#include <synch/spinlock.h> |
#include <console/chardev.h> |
#include <console/console.h> |
#include <proc/thread.h> |
#include <arch.h> |
#include <macros.h> |
#define PRESSED_SHIFT (1 << 0) |
#define PRESSED_CAPSLOCK (1 << 1) |
#define LOCKED_CAPSLOCK (1 << 0) |
#define PL050_KEY_RELEASE 0xF0 |
#define PL050_ESC_KEY 0xE0 |
#define PL050_CAPS_SCAN_CODE 0x58 |
#define PL050_NUM_SCAN_CODE 0x77 |
#define PL050_SCROLL_SCAN_CODE 0x7E |
static bool is_lock_key(wchar_t); |
static indev_operations_t kbrd_raw_ops = { |
.poll = NULL |
}; |
/** Process release of key. |
* |
* @param sc Scancode of the key being released. |
*/ |
static void key_released(kbrd_instance_t *instance, wchar_t sc) |
{ |
spinlock_lock(&instance->keylock); |
switch (sc) { |
case SC_LSHIFT: |
case SC_RSHIFT: |
instance->keyflags &= ~PRESSED_SHIFT; |
break; |
case SC_CAPSLOCK: |
instance->keyflags &= ~PRESSED_CAPSLOCK; |
if (instance->lockflags & LOCKED_CAPSLOCK) |
instance->lockflags &= ~LOCKED_CAPSLOCK; |
else |
instance->lockflags |= LOCKED_CAPSLOCK; |
break; |
default: |
break; |
} |
spinlock_unlock(&instance->keylock); |
} |
/** Process keypress. |
* |
* @param sc Scancode of the key being pressed. |
*/ |
static void key_pressed(kbrd_instance_t *instance, wchar_t sc) |
{ |
bool letter; |
bool shift; |
bool capslock; |
spinlock_lock(&instance->keylock); |
switch (sc) { |
case SC_LSHIFT: |
case SC_RSHIFT: |
instance->keyflags |= PRESSED_SHIFT; |
break; |
case SC_CAPSLOCK: |
instance->keyflags |= PRESSED_CAPSLOCK; |
break; |
case SC_SCAN_ESCAPE: |
break; |
default: |
letter = islower(sc_primary_map[sc]); |
shift = instance->keyflags & PRESSED_SHIFT; |
capslock = (instance->keyflags & PRESSED_CAPSLOCK) || |
(instance->lockflags & LOCKED_CAPSLOCK); |
if ((letter) && (capslock)) |
shift = !shift; |
if (shift) |
indev_push_character(instance->sink, sc_secondary_map[sc]); |
else |
indev_push_character(instance->sink, sc_primary_map[sc]); |
break; |
} |
spinlock_unlock(&instance->keylock); |
} |
static void kkbrd(void *arg) |
{ |
static int key_released_flag = 0; |
static int is_locked = 0; |
kbrd_instance_t *instance = (kbrd_instance_t *) arg; |
while (true) { |
wchar_t sc = indev_pop_character(&instance->raw); |
if (sc == PL050_KEY_RELEASE) { |
key_released_flag = 1; |
} else { |
if (key_released_flag) { |
key_released_flag = 0; |
if (is_lock_key(sc)) { |
if (!is_locked) { |
is_locked = 1; |
} else { |
is_locked = 0; |
continue; |
} |
} |
key_released(instance, sc); |
} else { |
if (is_lock_key(sc) && is_locked) |
continue; |
key_pressed(instance, sc); |
} |
} |
} |
} |
kbrd_instance_t *kbrd_init(void) |
{ |
kbrd_instance_t *instance |
= malloc(sizeof(kbrd_instance_t), FRAME_ATOMIC); |
if (instance) { |
instance->thread |
= thread_create(kkbrd, (void *) instance, TASK, 0, "kkbrd", false); |
if (!instance->thread) { |
free(instance); |
return NULL; |
} |
instance->sink = NULL; |
indev_initialize("kbrd", &instance->raw, &kbrd_raw_ops); |
spinlock_initialize(&instance->keylock, "instance_keylock"); |
instance->keyflags = 0; |
instance->lockflags = 0; |
} |
return instance; |
} |
indev_t *kbrd_wire(kbrd_instance_t *instance, indev_t *sink) |
{ |
ASSERT(instance); |
ASSERT(sink); |
instance->sink = sink; |
thread_ready(instance->thread); |
return &instance->raw; |
} |
static bool is_lock_key(wchar_t sc) |
{ |
return ((sc == PL050_CAPS_SCAN_CODE) || (sc == PL050_NUM_SCAN_CODE) || |
(sc == PL050_SCROLL_SCAN_CODE)); |
} |
/** @} |
*/ |
/branches/arm/kernel/genarch/src/kbrd/scanc_pl050.c |
---|
0,0 → 1,234 |
/* |
* 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, U_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. |
*/ |
#include <genarch/kbrd/scanc.h> |
#include <typedefs.h> |
#include <string.h> |
/** Primary meaning of scancodes. */ |
wchar_t sc_primary_map[] = { |
U_NULL, /* 0x00 */ |
U_SPECIAL, /* 0x01 - F9 */ |
U_SPECIAL, /* 0x02 - F7 */ |
U_SPECIAL, /* 0x03 - F5 */ |
U_SPECIAL, /* 0x04 - F3 */ |
U_SPECIAL, /* 0x05 - F1 */ |
U_SPECIAL, /* 0x06 - F2 */ |
U_SPECIAL, /* 0x07 - F12 */ |
U_SPECIAL, /* 0x08 - */ |
U_SPECIAL, /* 0x09 - F10 */ |
U_SPECIAL, /* 0x0A - F8 */ |
U_SPECIAL, /* 0x0B - F10 */ |
U_SPECIAL, /* 0x0C - F4 */ |
'\t', /* 0x0D - Tab */ |
'`', |
U_SPECIAL, /* 0x0F */ |
U_SPECIAL, /* 0x10 */ |
U_SPECIAL, /* 0x11 - LAlt */ |
U_SPECIAL, /* 0x12 - LShift */ |
U_SPECIAL, /* ox13 */ |
U_SPECIAL, /* 0x14 Ctrl */ |
'q', '1', |
U_SPECIAL, /* 0x17 */ |
U_SPECIAL, /* 0x18 */ |
U_SPECIAL, /* 0x19 */ |
'z', 's', 'a', 'w', '2', |
U_SPECIAL, /* 0x1F */ |
U_SPECIAL, /* 0x20 */ |
'c', 'x', 'd', 'e', '4', '3', |
U_SPECIAL, /* 0x27 */ |
U_SPECIAL, /* 0x28 */ |
' ', 'v', 'f', 't', 'r', '5', |
U_SPECIAL, /* 0x2F */ |
U_SPECIAL, /* 0x30 */ |
'n', 'b', 'h', 'g', 'y', '6', |
U_SPECIAL, /* 0x37 */ |
U_SPECIAL, /* 0x38 */ |
U_SPECIAL, /* 0x39 */ |
'm', 'j', 'u', '7', '8', |
U_SPECIAL, /* 0x3F */ |
U_SPECIAL, /* 0x40 */ |
',', 'k', 'i', 'o', '0', '9', |
U_SPECIAL, /* 0x47 */ |
U_SPECIAL, /* 0x48 */ |
'.', '/', 'l', ';', 'p', '-', |
U_SPECIAL, /* 0x4F */ |
U_SPECIAL, /* 0x50 */ |
U_SPECIAL, /* 0x51 */ |
'\'', |
U_SPECIAL, /* 0x53 */ |
'[', '=', |
U_SPECIAL, /* 0x56 */ |
U_SPECIAL, /* 0x57 */ |
U_SPECIAL, /* 0x58 - Caps Lock */ |
U_SPECIAL, /* 0x59 - RShift */ |
'\n', ']', |
U_SPECIAL, /* 0x5C */ |
'\\', |
U_SPECIAL, /* 0x5E */ |
U_SPECIAL, /* 0x5F */ |
U_SPECIAL, /* 0x60 */ |
U_SPECIAL, /* 0x61 */ |
U_SPECIAL, /* 0x62 */ |
U_SPECIAL, /* 0x63 */ |
U_SPECIAL, /* 0x64 */ |
U_SPECIAL, /* 0x65 */ |
'\b', /* 0x66 - backspace*/ |
U_SPECIAL, /* 0x67 */ |
U_SPECIAL, /* 0x68 */ |
U_END_ARROW, /* 0x69 */ |
U_SPECIAL, /* 0x6a */ |
U_LEFT_ARROW, /* 0x6b - Left Arrow */ |
U_SPECIAL, /* 0x6c */ |
U_SPECIAL, /* 0x6d */ |
U_SPECIAL, /* 0x6e */ |
U_SPECIAL, /* 0x6f */ |
U_SPECIAL, /* 0x70 */ |
U_DELETE, /* 0x71 - Del*/ |
U_DOWN_ARROW, /* 0x72 Down Arrow */ |
U_SPECIAL, /* 0x73 */ |
U_RIGHT_ARROW, /* 0x74 - Right Arrow */ |
U_UP_ARROW, /* 0x75 Up Arrow */ |
U_ESCAPE, /* 0x76 Esc */ |
U_SPECIAL, /* 0x77 - NumLock*/ |
U_SPECIAL, /* 0x78 F11*/ |
U_SPECIAL, /* 0x79 */ |
U_PAGE_DOWN, /* 0x7a */ |
U_SPECIAL, /* 0x7b */ |
U_SPECIAL, /* 0x7c */ |
U_PAGE_UP, /* 0x7d */ |
U_SPECIAL, /* 0x7e */ |
U_SPECIAL /* 0x7f */ |
}; |
/** Secondary meaning of scancodes. */ |
wchar_t sc_secondary_map[] = { |
U_NULL, /* 0x00 */ |
U_SPECIAL, /* 0x01 - F9 */ |
U_SPECIAL, /* 0x02 - F7 */ |
U_SPECIAL, /* 0x03 - F5 */ |
U_SPECIAL, /* 0x04 - F3 */ |
U_SPECIAL, /* 0x05 - F1 */ |
U_SPECIAL, /* 0x06 - F2 */ |
U_SPECIAL, /* 0x07 - F12 */ |
U_SPECIAL, /* 0x08 - */ |
U_SPECIAL, /* 0x09 - F10 */ |
U_SPECIAL, /* 0x0A - F8 */ |
U_SPECIAL, /* 0x0B - F10 */ |
U_SPECIAL, /* 0x0C - F4 */ |
'\t', /* 0x0D - Tab */ |
'~', |
U_SPECIAL, /* 0x0F */ |
U_SPECIAL, /* 0x10 */ |
U_SPECIAL, /* 0x11 - LAlt */ |
U_SPECIAL, /* 0x12 - LShift */ |
U_SPECIAL, /* ox13 */ |
U_SPECIAL, /* 0x14 Ctrl */ |
'Q', '!', |
U_SPECIAL, /* 0x17 */ |
U_SPECIAL, /* 0x18 */ |
U_SPECIAL, /* 0x19 */ |
'Z', 'S', 'A', 'W', '@', |
U_SPECIAL, /* 0x1F */ |
U_SPECIAL, /* 0x20 */ |
'C', 'X', 'D', 'E', '$', '#', |
U_SPECIAL, /* 0x27 */ |
U_SPECIAL, /* 0x28 */ |
' ', 'V', 'F', 'T', 'R', '%', |
U_SPECIAL, /* 0x2F */ |
U_SPECIAL, /* 0x30 */ |
'N', 'B', 'H', 'G', 'Y', '^', |
U_SPECIAL, /* 0x37 */ |
U_SPECIAL, /* 0x38 */ |
U_SPECIAL, /* 0x39 */ |
'M', 'J', 'U', '&', '*', |
U_SPECIAL, /* 0x3F */ |
U_SPECIAL, /* 0x40 */ |
'<', 'K', 'I', 'O', ')', '(', |
U_SPECIAL, /* 0x47 */ |
U_SPECIAL, /* 0x48 */ |
'>', '?', 'L', ':', 'P', '_', |
U_SPECIAL, /* 0x4F */ |
U_SPECIAL, /* 0x50 */ |
U_SPECIAL, /* 0x51 */ |
'"', |
U_SPECIAL, /* 0x53 */ |
'{', '+', |
U_SPECIAL, /* 0x56 */ |
U_SPECIAL, /* 0x57 */ |
U_SPECIAL, /* 0x58 - Caps Lock */ |
U_SPECIAL, /* 0x59 - RShift */ |
'\n', '}', |
U_SPECIAL, /* 0x5C */ |
'|', |
U_SPECIAL, /* 0x5E */ |
U_SPECIAL, /* 0x5F */ |
U_SPECIAL, /* 0x60 */ |
U_SPECIAL, /* 0x61 */ |
U_SPECIAL, /* 0x62 */ |
U_SPECIAL, /* 0x63 */ |
U_SPECIAL, /* 0x64 */ |
U_SPECIAL, /* 0x65 */ |
'\b', /* 0x66 - backspace*/ |
U_SPECIAL, /* 0x67 */ |
U_SPECIAL, /* 0x68 */ |
U_END_ARROW, /* 0x69 */ |
U_SPECIAL, /* 0x6a */ |
U_LEFT_ARROW, /* 0x6b - Left Arrow */ |
U_SPECIAL, /* 0x6c */ |
U_SPECIAL, /* 0x6d */ |
U_SPECIAL, /* 0x6e */ |
U_SPECIAL, /* 0x6f */ |
U_SPECIAL, /* 0x70 */ |
U_DELETE, /* 0x71 - Del*/ |
U_DOWN_ARROW, /* 0x72 Down Arrow */ |
U_SPECIAL, /* 0x73 */ |
U_RIGHT_ARROW, /* 0x74 - Right Arrow */ |
U_UP_ARROW, /* 0x75 Up Arrow */ |
U_ESCAPE, /* 0x76 Esc */ |
U_SPECIAL, /* 0x77 - NumLock*/ |
U_SPECIAL, /* 0x78 F11*/ |
U_SPECIAL, /* 0x79 */ |
U_PAGE_DOWN, /* 0x7a */ |
U_SPECIAL, /* 0x7b */ |
U_SPECIAL, /* 0x7c */ |
U_PAGE_UP, /* 0x7d */ |
U_SPECIAL, /* 0x7e */ |
U_SPECIAL /* 0x7f */ |
}; |
/** @} |
*/ |
/branches/arm/kernel/genarch/src/fb/fb.c |
---|
116,7 → 116,14 |
= (BLUE(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | RED(rgb, 8); |
} |
static void rgb_8880(void *dst, uint32_t rgb) |
{ |
*((uint32_t *) dst) |
= (RED(rgb, 8) << 24) | (GREEN(rgb, 8) << 16) | (BLUE(rgb, 8) << 8); |
} |
/** RGB 8:8:8 conversion |
* |
*/ |
470,7 → 477,7 |
pixelbytes = 3; |
break; |
case VISUAL_RGB_8_8_8_0: |
rgb_conv = rgb_888; |
rgb_conv = rgb_8880; |
pixelbytes = 4; |
break; |
case VISUAL_RGB_0_8_8_8: |
/branches/arm/kernel/genarch/src/drivers/pl050/pl050.c |
---|
0,0 → 1,117 |
/* |
* 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 pl050 keyboard/mouse driver. |
* |
* It takes care of low-level keyboard functions. |
*/ |
#include <genarch/drivers/pl050/pl050.h> |
#include <arch/asm.h> |
#include <console/chardev.h> |
#include <mm/slab.h> |
#include <ddi/device.h> |
#define PL050_KEY_RELEASE 0xF0 |
#define PL050_ESC_KEY 0xE0 |
#define PL050_CAPS_SCAN_CODE 0x58 |
/** Structure for pl050's IRQ. */ |
static pl050_t *pl050; |
static irq_ownership_t pl050_claim(irq_t *irq) |
{ |
uint8_t status; |
if ((status = pio_read_8(pl050->status)) & PL050_STAT_RXFULL) |
return IRQ_ACCEPT; |
else { |
return IRQ_DECLINE; |
} |
} |
static void pl050_irq_handler(irq_t *irq) |
{ |
uint8_t data; |
uint8_t status; |
pl050_instance_t *instance = irq->instance; |
while ((status = pio_read_8(pl050->status)) & PL050_STAT_RXFULL) { |
data = pio_read_8(pl050->data); |
indev_push_character(instance->kbrdin, data); |
} |
} |
/** Initialize pl050. */ |
pl050_instance_t *pl050_init(pl050_t *dev, inr_t inr) |
{ |
pl050_instance_t *instance = |
malloc(sizeof(pl050_instance_t), FRAME_ATOMIC); |
pl050 = dev; |
if (instance) { |
instance->pl050 = dev; |
instance->kbrdin = NULL; |
irq_initialize(&instance->irq); |
instance->irq.devno = device_assign_devno(); |
instance->irq.inr = inr; |
instance->irq.claim = pl050_claim; |
instance->irq.handler = pl050_irq_handler; |
instance->irq.instance = instance; |
} |
return instance; |
} |
void pl050_wire(pl050_instance_t *instance, indev_t *kbrdin) |
{ |
uint8_t val; |
instance->kbrdin = kbrdin; |
irq_register(&instance->irq); |
val = PL050_CR_RXINTR | PL050_CR_INTR; |
pio_write_8(pl050->ctrl, val); |
/* reset the data buffer */ |
pio_read_8(pl050->data); |
} |
/** @} |
*/ |