2002-04-22 19:12:37 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-04-22 19:12:37 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "thread.h"
|
2002-04-25 00:15:04 +00:00
|
|
|
#include "kernel.h"
|
2002-04-22 19:12:37 +00:00
|
|
|
#include "sh7034.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
2002-04-24 22:46:02 +00:00
|
|
|
void tick_start(unsigned int interval);
|
|
|
|
|
2002-04-22 19:12:37 +00:00
|
|
|
unsigned int s1[256];
|
|
|
|
unsigned int s2[256];
|
|
|
|
|
|
|
|
void t1(void);
|
|
|
|
void t2(void);
|
|
|
|
|
2002-04-29 14:28:37 +00:00
|
|
|
struct event_queue main_q;
|
|
|
|
|
2002-05-05 18:36:13 +00:00
|
|
|
int tick_add_task(void (*f)(void));
|
|
|
|
|
|
|
|
void testfunc(void)
|
|
|
|
{
|
|
|
|
if(current_tick == 5000)
|
|
|
|
debugf("Yippie!\n");
|
|
|
|
}
|
|
|
|
|
2002-04-22 19:12:37 +00:00
|
|
|
int main(void)
|
|
|
|
{
|
2002-04-25 00:15:04 +00:00
|
|
|
char buf[40];
|
|
|
|
char str[32];
|
|
|
|
int i=0;
|
2007-10-16 01:25:17 +00:00
|
|
|
struct queue_event *ev;
|
2002-04-22 19:12:37 +00:00
|
|
|
|
2002-04-25 00:15:04 +00:00
|
|
|
/* Clear it all! */
|
2002-04-22 19:12:37 +00:00
|
|
|
SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER);
|
|
|
|
|
|
|
|
/* This enables the serial Rx interrupt, to be able to exit into the
|
|
|
|
debugger when you hit CTRL-C */
|
|
|
|
SCR1 |= 0x40;
|
|
|
|
SCR1 &= ~0x80;
|
2002-04-25 13:30:41 +00:00
|
|
|
IPRE |= 0xf000; /* Set to highest priority */
|
2002-05-05 18:36:13 +00:00
|
|
|
|
2002-04-22 19:12:37 +00:00
|
|
|
debugf("OK. Let's go\n");
|
|
|
|
|
2002-05-05 18:36:13 +00:00
|
|
|
kernel_init();
|
2002-04-25 00:15:04 +00:00
|
|
|
|
2008-03-26 01:50:41 +00:00
|
|
|
enable_irq();
|
2002-05-11 21:56:33 +00:00
|
|
|
|
2002-05-05 18:36:13 +00:00
|
|
|
tick_add_task(testfunc);
|
|
|
|
|
|
|
|
debugf("sleeping 10s...\n");
|
2002-05-11 21:56:33 +00:00
|
|
|
sleep(HZ*10);
|
2002-05-05 18:36:13 +00:00
|
|
|
debugf("woke up\n");
|
|
|
|
|
2002-04-29 14:28:37 +00:00
|
|
|
queue_init(&main_q);
|
|
|
|
|
2007-10-16 01:25:17 +00:00
|
|
|
create_thread(t1, s1, 1024, 0);
|
|
|
|
create_thread(t2, s2, 1024, 0);
|
2002-04-22 19:12:37 +00:00
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
2002-04-29 14:28:37 +00:00
|
|
|
ev = queue_wait(&main_q);
|
|
|
|
debugf("Thread 0 got an event. ID: %d\n", ev->id);
|
2002-04-22 19:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void t1(void)
|
|
|
|
{
|
2002-04-25 13:30:41 +00:00
|
|
|
debugf("Thread 1 started\n");
|
2002-04-25 00:15:04 +00:00
|
|
|
while(1)
|
|
|
|
{
|
2002-05-11 21:56:33 +00:00
|
|
|
sleep(HZ);
|
2002-04-29 14:28:37 +00:00
|
|
|
debugf("Thread 1 posting an event\n");
|
|
|
|
queue_post(&main_q, 1234, 0);
|
|
|
|
queue_post(&main_q, 5678, 0);
|
2002-04-25 00:15:04 +00:00
|
|
|
}
|
2002-04-22 19:12:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void t2(void)
|
|
|
|
{
|
2002-04-25 13:30:41 +00:00
|
|
|
debugf("Thread 2 started\n");
|
2002-04-25 00:15:04 +00:00
|
|
|
while(1)
|
|
|
|
{
|
2002-05-11 21:56:33 +00:00
|
|
|
sleep(HZ*3);
|
2002-04-25 13:30:41 +00:00
|
|
|
debugf("Thread 2 awakened\n");
|
2002-04-25 00:15:04 +00:00
|
|
|
}
|
2002-04-22 19:12:37 +00:00
|
|
|
}
|