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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [uos/] [task.c] - Blame information for rev 178

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

Line No. Rev Author Line
1 90 jeremybenn
/* task.c.  Microkernel task handler for Or1ksim
2
 
3
   Copyright (C) 2000 Damjan Lampret
4
   Copyright (C) 2010 Embecosm Limited
5
 
6
   Contributor Damjan Lampret <lampret@opencores.org>
7
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
 
9
   This file is part of OpenRISC 1000 Architectural Simulator.
10
 
11
   This program is free software; you can redistribute it and/or modify it
12
   under the terms of the GNU General Public License as published by the Free
13
   Software Foundation; either version 3 of the License, or (at your option)
14
   any later version.
15
 
16
   This program is distributed in the hope that it will be useful, but WITHOUT
17
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
19
   more details.
20
 
21
   You should have received a copy of the GNU General Public License along
22
   with this program.  If not, see <http:  www.gnu.org/licenses/>.  */
23
 
24
/* ----------------------------------------------------------------------------
25
   This code is commented throughout for use with Doxygen.
26
   --------------------------------------------------------------------------*/
27
 
28
/* This file is part of test microkernel for OpenRISC 1000. */
29
 
30
#include "support.h"
31
#include "uos.h"
32
#include "ipc.h"
33
#include "int.h"
34
 
35
extern struct tcb tasks[MAX_TASKS+1];
36
 
37
int task(int id)
38
{
39
        struct _msg {
40
                char            id;
41
                unsigned long   count;
42
        } msg;
43
 
44
        printf("Task %d started\n", id);
45
 
46
        if(id == 1) {
47
                msg.id = 1;
48
                msg.count = 0;
49
                uos_msgsnd(2, (char *)&msg, sizeof(msg));
50
        }
51
 
52
        for(;;) {
53
                uos_msgrcv(0, (char *)&msg, sizeof(msg));
54
 
55
                printf("Task %d: Got massage from task %d: 0x%.8x. "
56
                       "Sending message to task %d: 0x%.8x \n", id, msg.id,
57
                       (int)msg.count, (id == 3 ? 1 : (id + 1)),
58
                       (int)(msg.count  + 1));
59
                msg.id = id;
60
 
61
                if((id == 1) && (msg.count > 15)) {
62
                  report(msg.count + 0xdeadde9c);
63
                  exit(0);
64
 
65
 
66
                        msg.count += 1;
67
                        uos_msgsnd((id == 3 ? 1 : (id + 1)), (char *)&msg, sizeof(msg));
68
                }
69
        }
70
}
71
 
72
/* Called by kernel_init to collect all tasks entries. */
73
void tasks_entries()
74
{
75
        tasks[1].regs.pc = (unsigned long)task;
76
        tasks[2].regs.pc = (unsigned long)task;
77
        tasks[3].regs.pc = (unsigned long)task;
78
}
79
 

powered by: WebSVN 2.1.0

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