KMI patch for devel branch on bahadir's repo.

Important points:
----------------
1. Works fine for pb926 + qemu.

2. Scan code logic for kryboard is not complete.
We just have generic keys and shift working.

3. Mouse scancodes are collected but not decoded.

4. Right now we are doing enable_irq(), just before we go for waiting
again for new irqs. This is not correct but we had latency issues.
This needs to be fixed immediately.

5. Also it seems like the notify_clot count should be an atomic
variable. Needs to be discussed.
This commit is contained in:
Amit Mahajan
2010-03-30 10:54:04 +05:30
parent 17c2336613
commit 92645be6ff
28 changed files with 1898 additions and 32 deletions

View File

@@ -111,6 +111,16 @@ int irq_wait(l4id_t irq_index)
if ((ret = tcb_check_and_lazy_map_utcb(current, 1)) < 0)
return ret;
/*
* In case user has asked for unmasking the irq only after
* user hanlder is done, unmask the irq
*
* FIXME: This is not the correct place for this call,
* fix this.
*/
if (desc->user_ack)
irq_enable(irq_index);
/* Wait until the irq changes slot value */
WAIT_EVENT(&desc->wqh_irq,
utcb->notify[desc->task_notify_slot] != 0,

View File

@@ -152,7 +152,11 @@ void do_irq(void)
BUG();
}
irq_enable(irq_index);
/*
* Do not enable irq if user wants to do it explicitely
*/
if (!this_irq->user_ack)
irq_enable(irq_index);
}

View File

@@ -65,6 +65,23 @@ static int platform_timer_user_handler(struct irq_desc *desc)
return 0;
}
/*
* Keyboard handler for userspace
*/
static int platform_keyboard_user_handler(struct irq_desc *desc)
{
irq_thread_notify(desc);
return 0;
}
/*
* Mouse handler for userspace
*/
static int platform_mouse_user_handler(struct irq_desc *desc)
{
irq_thread_notify(desc);
return 0;
}
/*
* Built-in irq handlers initialised at compile time.
@@ -75,11 +92,25 @@ struct irq_desc irq_desc_array[IRQS_MAX] = {
.name = "Timer0",
.chip = &irq_chip_array[0],
.handler = platform_timer_handler,
.user_ack = 0,
},
[IRQ_TIMER1] = {
.name = "Timer1",
.chip = &irq_chip_array[0],
.handler = platform_timer_user_handler,
.user_ack = 0,
},
[IRQ_KEYBOARD0] = {
.name = "Keyboard",
.chip = &irq_chip_array[1],
.handler = platform_keyboard_user_handler,
.user_ack = 1,
},
[IRQ_MOUSE0] = {
.name = "Mouse",
.chip = &irq_chip_array[1],
.handler = platform_mouse_user_handler,
.user_ack = 1,
},
};

View File

@@ -30,45 +30,66 @@
*/
int platform_setup_device_caps(struct kernel_resources *kres)
{
struct capability *uart[4], *timer[2];
struct capability *uart[3], *timer[1],
*keyboard[1], *mouse[1];
/* Setup capabilities for userspace uarts and timers */
uart[0] = alloc_bootmem(sizeof(*uart[0]), 0);
uart[0]->start = __pfn(PLATFORM_UART1_BASE);
uart[0]->end = uart[0]->start + 1;
uart[0]->size = uart[0]->end - uart[1]->start;
cap_set_devtype(uart[0], CAP_DEVTYPE_UART);
cap_set_devnum(uart[0], 1);
link_init(&uart[0]->list);
cap_list_insert(uart[0], &kres->devmem_free);
uart[1] = alloc_bootmem(sizeof(*uart[1]), 0);
uart[1]->start = __pfn(PLATFORM_UART1_BASE);
uart[1]->start = __pfn(PLATFORM_UART2_BASE);
uart[1]->end = uart[1]->start + 1;
uart[1]->size = uart[1]->end - uart[1]->start;
cap_set_devtype(uart[1], CAP_DEVTYPE_UART);
cap_set_devnum(uart[1], 1);
cap_set_devnum(uart[1], 2);
link_init(&uart[1]->list);
cap_list_insert(uart[1], &kres->devmem_free);
uart[2] = alloc_bootmem(sizeof(*uart[2]), 0);
uart[2]->start = __pfn(PLATFORM_UART2_BASE);
uart[2]->start = __pfn(PLATFORM_UART3_BASE);
uart[2]->end = uart[2]->start + 1;
uart[2]->size = uart[2]->end - uart[2]->start;
cap_set_devtype(uart[2], CAP_DEVTYPE_UART);
cap_set_devnum(uart[2], 2);
cap_set_devnum(uart[2], 3);
link_init(&uart[2]->list);
cap_list_insert(uart[2], &kres->devmem_free);
uart[3] = alloc_bootmem(sizeof(*uart[3]), 0);
uart[3]->start = __pfn(PLATFORM_UART3_BASE);
uart[3]->end = uart[3]->start + 1;
uart[3]->size = uart[3]->end - uart[3]->start;
cap_set_devtype(uart[3], CAP_DEVTYPE_UART);
cap_set_devnum(uart[3], 3);
link_init(&uart[3]->list);
cap_list_insert(uart[3], &kres->devmem_free);
/* Setup timer1 capability as free */
timer[1] = alloc_bootmem(sizeof(*timer[1]), 0);
timer[1]->start = __pfn(PLATFORM_TIMER1_BASE);
timer[1]->end = timer[1]->start + 1;
timer[1]->size = timer[1]->end - timer[1]->start;
cap_set_devtype(timer[1], CAP_DEVTYPE_TIMER);
cap_set_devnum(timer[1], 1);
link_init(&timer[1]->list);
cap_list_insert(timer[1], &kres->devmem_free);
timer[0] = alloc_bootmem(sizeof(*timer[0]), 0);
timer[0]->start = __pfn(PLATFORM_TIMER1_BASE);
timer[0]->end = timer[0]->start + 1;
timer[0]->size = timer[0]->end - timer[0]->start;
cap_set_devtype(timer[0], CAP_DEVTYPE_TIMER);
cap_set_devnum(timer[0], 1);
link_init(&timer[0]->list);
cap_list_insert(timer[0], &kres->devmem_free);
/* Setup keyboard capability as free */
keyboard[0] = alloc_bootmem(sizeof(*keyboard[0]), 0);
keyboard[0]->start = __pfn(PLATFORM_KEYBOARD0_BASE);
keyboard[0]->end = keyboard[0]->start + 1;
keyboard[0]->size = keyboard[0]->end - keyboard[0]->start;
cap_set_devtype(keyboard[0], CAP_DEVTYPE_KEYBOARD);
cap_set_devnum(keyboard[0], 0);
link_init(&keyboard[0]->list);
cap_list_insert(keyboard[0], &kres->devmem_free);
/* Setup mouse capability as free */
mouse[0] = alloc_bootmem(sizeof(*mouse[0]), 0);
mouse[0]->start = __pfn(PLATFORM_MOUSE0_BASE);
mouse[0]->end = mouse[0]->start + 1;
mouse[0]->size = mouse[0]->end - mouse[0]->start;
cap_set_devtype(mouse[0], CAP_DEVTYPE_MOUSE);
cap_set_devnum(mouse[0], 0);
link_init(&mouse[0]->list);
cap_list_insert(mouse[0], &kres->devmem_free);
return 0;
}
@@ -116,11 +137,21 @@ void init_platform_irq_controller()
irq_controllers_init();
}
/* Add userspace devices here as you develop their irq handlers */
void init_platform_devices()
{
/* Add userspace devices here as you develop their irq handlers */
/* TIMER23 */
add_boot_mapping(PLATFORM_TIMER1_BASE, PLATFORM_TIMER1_VBASE,
PAGE_SIZE, MAP_IO_DEFAULT);
/* KEYBOARD - KMI0 */
add_boot_mapping(PLATFORM_KEYBOARD0_BASE, PLATFORM_KEYBOARD0_VBASE,
PAGE_SIZE, MAP_IO_DEFAULT);
/* MOUSE - KMI1 */
add_boot_mapping(PLATFORM_MOUSE0_BASE, PLATFORM_MOUSE0_VBASE,
PAGE_SIZE, MAP_IO_DEFAULT);
}
/* If these bits are off, 32Khz OSC source is used */