Fixed all compilation errors with timer service

This commit is contained in:
Bahadir Balban
2009-12-12 15:31:01 +02:00
parent 8681c1d8c9
commit 8fe15ba811
4 changed files with 27 additions and 16 deletions

View File

@@ -5,8 +5,10 @@
#include <l4lib/arch/syscalls.h> #include <l4lib/arch/syscalls.h>
#include <l4lib/addr.h> #include <l4lib/addr.h>
#include <l4lib/exregs.h> #include <l4lib/exregs.h>
#include <l4lib/irq.h>
#include <l4lib/ipcdefs.h> #include <l4lib/ipcdefs.h>
#include <l4/api/errno.h> #include <l4/api/errno.h>
#include <l4/api/irq.h>
#include <l4/api/space.h> #include <l4/api/space.h>
#include <malloc/malloc.h> #include <malloc/malloc.h>
@@ -15,6 +17,7 @@
#include "sp804_timer.h" #include "sp804_timer.h"
#include <linker.h> #include <linker.h>
#include <timer.h> #include <timer.h>
#include <thread.h>
/* Frequency of timer in MHz */ /* Frequency of timer in MHz */
#define TIMER_FREQUENCY 1 #define TIMER_FREQUENCY 1
@@ -25,7 +28,6 @@ static struct capability caparray[32];
static int total_caps = 0; static int total_caps = 0;
static struct timer timer[TIMERS_TOTAL]; static struct timer timer[TIMERS_TOTAL];
static int notify_slot = 0;
int cap_read_all() int cap_read_all()
{ {
@@ -81,9 +83,11 @@ int timer_probe_devices(void)
return 0; return 0;
} }
void timer_irq_handler(void *arg) int timer_irq_handler(void *arg)
{ {
int err;
struct timer *timer = (struct timer *)arg; struct timer *timer = (struct timer *)arg;
const int slot = 0;
/* Initialise timer */ /* Initialise timer */
sp804_init(timer->base, SP804_TIMER_RUNMODE_PERIODIC, sp804_init(timer->base, SP804_TIMER_RUNMODE_PERIODIC,
@@ -91,8 +95,8 @@ void timer_irq_handler(void *arg)
SP804_TIMER_WIDTH32BIT, SP804_TIMER_IRQENABLE); SP804_TIMER_WIDTH32BIT, SP804_TIMER_IRQENABLE);
/* Register self for timer irq, using notify slot 0 */ /* Register self for timer irq, using notify slot 0 */
if ((err = l4_irq_control(IRQ_CONTROL_REGISTER, 0, if ((err = l4_irq_control(IRQ_CONTROL_REGISTER, slot,
timer->cap.irqnum)) < 0) { timer->cap.irq)) < 0) {
printf("%s: FATAL: Timer irq could not be registered. " printf("%s: FATAL: Timer irq could not be registered. "
"err=%d\n", __FUNCTION__, err); "err=%d\n", __FUNCTION__, err);
BUG(); BUG();
@@ -106,7 +110,7 @@ void timer_irq_handler(void *arg)
int count; int count;
/* Block on irq */ /* Block on irq */
count = l4_irq_wait(timer->cap.irqnum); count = l4_irq_wait(slot, timer->cap.irq);
/* Update timer count */ /* Update timer count */
timer->count += count; timer->count += count;
@@ -120,12 +124,13 @@ void timer_irq_handler(void *arg)
int timer_setup_devices(void) int timer_setup_devices(void)
{ {
struct task_ids irq_tids; struct task_ids irq_tids;
int err;
for (int i = 0; i < TIMERS_TOTAL; i++) { for (int i = 0; i < TIMERS_TOTAL; i++) {
/* Get one page from address pool */ /* Get one page from address pool */
timer[i].base = (unsigned long)l4_new_virtual(1); timer[i].base = (unsigned long)l4_new_virtual(1);
timer[i].count = 0; timer[i].count = 0;
link_init(&timer[i].tasklist); link_init(&timer[i].task_list);
l4_mutex_init(&timer[i].lock); l4_mutex_init(&timer[i].lock);
/* Map timer to a virtual address region */ /* Map timer to a virtual address region */
@@ -136,7 +141,7 @@ int timer_setup_devices(void)
printf("%s: FATAL: Failed to map TIMER device " printf("%s: FATAL: Failed to map TIMER device "
"%d to a virtual address\n", "%d to a virtual address\n",
__CONTAINER_NAME__, __CONTAINER_NAME__,
cap_devnum(&timer_cap[i])); cap_devnum(&timer[i].cap));
BUG(); BUG();
} }
@@ -148,7 +153,7 @@ int timer_setup_devices(void)
* wait on irqs. * wait on irqs.
*/ */
if ((err = thread_create(timer_irq_handler, &timer[i], if ((err = thread_create(timer_irq_handler, &timer[i],
TC_SHARED_SPACE, TC_SHARE_SPACE,
&irq_tids)) < 0) { &irq_tids)) < 0) {
printf("FATAL: Creation of irq handler " printf("FATAL: Creation of irq handler "
"thread failed.\n"); "thread failed.\n");

View File

@@ -14,8 +14,8 @@ char *__utcb_ptr = &utcb[1][0];
extern void local_setup_new_thread(void); extern void local_setup_new_thread(void);
l4id_t thread_create(int (*func)(void *), void *args, unsigned int flags, int thread_create(int (*func)(void *), void *args, unsigned int flags,
struct task_ids *new_ids) struct task_ids *new_ids)
{ {
struct task_ids ids; struct task_ids ids;
struct exregs_data exregs; struct exregs_data exregs;
@@ -44,10 +44,10 @@ l4id_t thread_create(int (*func)(void *), void *args, unsigned int flags,
return -ENOMEM; return -ENOMEM;
/* First word of new stack is arg */ /* First word of new stack is arg */
*(((unsigned long *)__stack_ptr)[-1]) = (unsigned long)args; ((unsigned long *)__stack_ptr)[-1] = (unsigned long)args;
/* Second word of new stack is function address */ /* Second word of new stack is function address */
*(((unsigned long *)__stack_ptr)[-2]) = (unsigned long)func; ((unsigned long *)__stack_ptr)[-2] = (unsigned long)func;
/* Setup new thread pc, sp, utcb */ /* Setup new thread pc, sp, utcb */
memset(&exregs, 0, sizeof(exregs)); memset(&exregs, 0, sizeof(exregs));
@@ -63,9 +63,8 @@ l4id_t thread_create(int (*func)(void *), void *args, unsigned int flags,
__utcb_ptr += UTCB_SIZE; __utcb_ptr += UTCB_SIZE;
/* Start the new thread */ /* Start the new thread */
if (flags & THREAD_RUN) if ((err = l4_thread_control(THREAD_RUN, &ids)) < 0)
if ((err = l4_thread_control(THREAD_RUN, &ids)) < 0) return err;
return err;
memcpy(new_ids, &ids, sizeof(ids)); memcpy(new_ids, &ids, sizeof(ids));

View File

@@ -0,0 +1,7 @@
#ifndef __L4LIB_IRQ_H__
#define __L4LIB_IRQ_H__
int l4_irq_wait(int slot, int irqnum);
#endif /* __L4LIB_IRQ_H__ */

View File

@@ -11,7 +11,7 @@
* Reads the irq notification slot. Destructive atomic read ensures that * Reads the irq notification slot. Destructive atomic read ensures that
* an irq may write to the slot in sync. * an irq may write to the slot in sync.
*/ */
int l4_irq_read_blocking(int slot, int irqnum) int l4_irq_wait(int slot, int irqnum)
{ {
int irqval = l4_atomic_dest_readb(&l4_get_utcb()->notify[slot]); int irqval = l4_atomic_dest_readb(&l4_get_utcb()->notify[slot]);