OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [testbench/] [uos/] [task.c] - Blame information for rev 1419

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 222 markom
/* This file is part of test microkernel for OpenRISC 1000. */
2
/* (C) 2000 Damjan Lampret, lampret@opencores.org */
3
 
4
#include "support.h"
5
#include "uos.h"
6
#include "ipc.h"
7
#include "int.h"
8
 
9
extern struct tcb tasks[MAX_TASKS+1];
10
 
11
int task(int id)
12
{
13
        int rc;
14
        struct _msg {
15
                char            id;
16
                unsigned long   count;
17
        } msg;
18
 
19 1024 simons
        printf("Task %d started\n", id);
20 222 markom
 
21
        if(id == 1) {
22
                msg.id = 1;
23
                msg.count = 0;
24
                uos_msgsnd(2, (char *)&msg, sizeof(msg));
25
        }
26
 
27
        for(;;) {
28
                rc = uos_msgrcv(0, (char *)&msg, sizeof(msg));
29
 
30
                if(rc != 0) {
31 1024 simons
                        printf("Task %d: Waiting for massage\n", id);
32 222 markom
                } else {
33 1024 simons
                        printf("Task %d: Got massage from task %d: 0x%.8x. Sending message to task %d: 0x%.8x \n", id, msg.id, (int)msg.count, (id == 3 ? 1 : (id + 1)), (int)(msg.count  + 1));
34 222 markom
                        msg.id = id;
35
 
36
                        if((id == 1) && (msg.count > 15)) {
37
                                report(msg.count + 0xdeadde9c);
38
                                exit(0);
39
                        }
40
 
41
                        msg.count += 1;
42
                        uos_msgsnd((id == 3 ? 1 : (id + 1)), (char *)&msg, sizeof(msg));
43
                }
44
        }
45
}
46
 
47
/* Called by kernel_init to collect all tasks entries. */
48
void tasks_entries()
49
{
50
        tasks[1].regs.pc = (unsigned long)task;
51
        tasks[2].regs.pc = (unsigned long)task;
52
        tasks[3].regs.pc = (unsigned long)task;
53
}
54
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.