Do core interrupt masking in a less general fashion and save some instructions to...
[kugel-rb.git] / firmware / test / kernel / main.c
blobcc0d93a6b486370aa1259cc3dc97fe99a4aeb408
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include "thread.h"
20 #include "kernel.h"
21 #include "sh7034.h"
22 #include "debug.h"
24 void tick_start(unsigned int interval);
26 unsigned int s1[256];
27 unsigned int s2[256];
29 void t1(void);
30 void t2(void);
32 struct event_queue main_q;
34 int tick_add_task(void (*f)(void));
36 void testfunc(void)
38 if(current_tick == 5000)
39 debugf("Yippie!\n");
42 int main(void)
44 char buf[40];
45 char str[32];
46 int i=0;
47 struct queue_event *ev;
49 /* Clear it all! */
50 SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER);
52 /* This enables the serial Rx interrupt, to be able to exit into the
53 debugger when you hit CTRL-C */
54 SCR1 |= 0x40;
55 SCR1 &= ~0x80;
56 IPRE |= 0xf000; /* Set to highest priority */
58 debugf("OK. Let's go\n");
60 kernel_init();
62 enable_irq();
64 tick_add_task(testfunc);
66 debugf("sleeping 10s...\n");
67 sleep(HZ*10);
68 debugf("woke up\n");
70 queue_init(&main_q);
72 create_thread(t1, s1, 1024, 0);
73 create_thread(t2, s2, 1024, 0);
75 while(1)
77 ev = queue_wait(&main_q);
78 debugf("Thread 0 got an event. ID: %d\n", ev->id);
82 void t1(void)
84 debugf("Thread 1 started\n");
85 while(1)
87 sleep(HZ);
88 debugf("Thread 1 posting an event\n");
89 queue_post(&main_q, 1234, 0);
90 queue_post(&main_q, 5678, 0);
94 void t2(void)
96 debugf("Thread 2 started\n");
97 while(1)
99 sleep(HZ*3);
100 debugf("Thread 2 awakened\n");