mirror of
https://github.com/drasko/codezero.git
synced 2026-02-18 04:43:18 +01:00
Converted all wait/wakeup runqueue lock/unlock paths to irq versions.
Irqs can now touch runqueues and do async wakeups. This necessitated that we implement all wake up wait and runqueue locking work with irqs. All this, assumes that in an SMP setup we may have cross-cpu wake ups, runqueue manipulation. If we later decide that we only wake up threads in the current container, (and lock containers to cpus) we won't really need spinlocks, or irq disabling anymore. The current set up might be trivially less responsive, but is more flexible.
This commit is contained in:
@@ -110,7 +110,8 @@ int timer_setup_devices(void)
|
||||
|
||||
/* Map timers to a virtual address region */
|
||||
if (IS_ERR(l4_map((void *)__pfn_to_addr(timer_cap[i].start),
|
||||
(void *)timer[i].base, timer_cap[i].size, MAP_USR_IO_FLAGS,
|
||||
(void *)timer[i].base, timer_cap[i].size,
|
||||
MAP_USR_IO_FLAGS,
|
||||
self_tid()))) {
|
||||
printf("%s: FATAL: Failed to map TIMER device "
|
||||
"%d to a virtual address\n",
|
||||
|
||||
25
conts/libl4/include/l4lib/arch-arm/irq.h
Normal file
25
conts/libl4/include/l4lib/arch-arm/irq.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef __L4LIB_ARCH_IRQ_H__
|
||||
#define __L4LIB_ARCH_IRQ_H__
|
||||
|
||||
|
||||
/*
|
||||
* Destructive atomic-read.
|
||||
*
|
||||
* Write 0 to byte at @location as its contents are read back.
|
||||
*/
|
||||
static inline char l4_atomic_dest_readb(void *location)
|
||||
{
|
||||
unsigned char zero = 0;
|
||||
unsigned char val;
|
||||
char *loc = location;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"swpb %1, %2, [%0] \n"
|
||||
:: "r" (*loc), "r" (val), "r" (zero)
|
||||
);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
23
conts/libl4/src/irq.c
Normal file
23
conts/libl4/src/irq.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Functions for userspace irq handling.
|
||||
*
|
||||
* Copyright (C) 2009 B Labs Ltd.
|
||||
*/
|
||||
#include <l4lib/arch/irq.h>
|
||||
#include <l4lib/arch/syscalls.h>
|
||||
#include <l4/api/irq.h>
|
||||
|
||||
/*
|
||||
* Reads the irq notification slot. Destructive atomic read ensures that
|
||||
* an irq may write to the slot in sync.
|
||||
*/
|
||||
int l4_irq_read_blocking(int slot, int irqnum)
|
||||
{
|
||||
int irqval = l4_atomic_dest_readb(&l4_get_utcb()->notify[slot]);
|
||||
|
||||
if (!irqval)
|
||||
return l4_irq_control(IRQ_CONTROL_WAIT, 0, irqnum);
|
||||
else
|
||||
return irqval;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user