summaryrefslogtreecommitdiff
path: root/firmware/test/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/test/kernel')
-rw-r--r--firmware/test/kernel/Makefile3
-rw-r--r--firmware/test/kernel/main.c35
-rw-r--r--firmware/test/kernel/timer.c18
3 files changed, 29 insertions, 27 deletions
diff --git a/firmware/test/kernel/Makefile b/firmware/test/kernel/Makefile
index f632b3f6de..0740f6809c 100644
--- a/firmware/test/kernel/Makefile
+++ b/firmware/test/kernel/Makefile
@@ -14,7 +14,8 @@ TARGET = -DARCHOS_PLAYER_OLD=1
14CFLAGS = -g -O -Wall -m1 -save-temps -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns -fno-builtin $(INCLUDES) $(TARGET) 14CFLAGS = -g -O -Wall -m1 -save-temps -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns -fno-builtin $(INCLUDES) $(TARGET)
15AFLAGS += -small -relax 15AFLAGS += -small -relax
16 16
17OBJS= ../../crt0.o ../../system.o main.o timer.o ../../thread.o ../../debug.o 17OBJS= ../../crt0.o ../../system.o main.o timer.o \
18 ../../thread.o ../../kernel.o ../../debug.o
18 19
19%.o: %.S 20%.o: %.S
20 $(CC) -o $@ $(CFLAGS) $(INCLUDES) $(DEFS) -c $< 21 $(CC) -o $@ $(CFLAGS) $(INCLUDES) $(DEFS) -c $<
diff --git a/firmware/test/kernel/main.c b/firmware/test/kernel/main.c
index 6ce99c8065..b52ecff21d 100644
--- a/firmware/test/kernel/main.c
+++ b/firmware/test/kernel/main.c
@@ -17,6 +17,7 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19#include "thread.h" 19#include "thread.h"
20#include "kernel.h"
20#include "sh7034.h" 21#include "sh7034.h"
21#include "debug.h" 22#include "debug.h"
22 23
@@ -30,11 +31,11 @@ void t2(void);
30 31
31int main(void) 32int main(void)
32{ 33{
33 char buf[40]; 34 char buf[40];
34 char str[32]; 35 char str[32];
35 int i=0; 36 int i=0;
36 37
37 /* Clear it all! */ 38 /* Clear it all! */
38 SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER); 39 SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER);
39 40
40 /* This enables the serial Rx interrupt, to be able to exit into the 41 /* This enables the serial Rx interrupt, to be able to exit into the
@@ -46,31 +47,31 @@ int main(void)
46 debugf("OK. Let's go\n"); 47 debugf("OK. Let's go\n");
47 48
48 tick_start(40); 49 tick_start(40);
49 50
50 create_thread(t1, s1, 1024); 51 create_thread(t1, s1, 1024);
51 create_thread(t2, s2, 1024); 52 create_thread(t2, s2, 1024);
52 53
53 while(1) 54 while(1)
54 { 55 {
55 debugf("t0\n"); 56 debugf("t0\n");
56 switch_thread(); 57 sleep(100);
57 } 58 }
58} 59}
59 60
60void t1(void) 61void t1(void)
61{ 62{
62 while(1) 63 while(1)
63 { 64 {
64 debugf("t1\n"); 65 debugf("t1\n");
65 switch_thread(); 66 sleep(200);
66 } 67 }
67} 68}
68 69
69void t2(void) 70void t2(void)
70{ 71{
71 while(1) 72 while(1)
72 { 73 {
73 debugf("t2\n"); 74 debugf("t2\n");
74 switch_thread(); 75 sleep(300);
75 } 76 }
76} 77}
diff --git a/firmware/test/kernel/timer.c b/firmware/test/kernel/timer.c
index be253db2b5..31c6f82baa 100644
--- a/firmware/test/kernel/timer.c
+++ b/firmware/test/kernel/timer.c
@@ -19,6 +19,7 @@
19#include "sh7034.h" 19#include "sh7034.h"
20#include "system.h" 20#include "system.h"
21#include "debug.h" 21#include "debug.h"
22#include "kernel.h"
22 23
23void tick_start(unsigned int interval_in_ms) 24void tick_start(unsigned int interval_in_ms)
24{ 25{
@@ -26,6 +27,7 @@ void tick_start(unsigned int interval_in_ms)
26 27
27 count = FREQ / 1000 / 8 * interval_in_ms; 28 count = FREQ / 1000 / 8 * interval_in_ms;
28 29
30 debugf("count = %d\n", count);
29 if(count > 0xffff) 31 if(count > 0xffff)
30 { 32 {
31 debugf("Error! The tick interval is too long (%d ms)\n", 33 debugf("Error! The tick interval is too long (%d ms)\n",
@@ -40,24 +42,22 @@ void tick_start(unsigned int interval_in_ms)
40 TMDR &= ~0x01; /* Operate normally */ 42 TMDR &= ~0x01; /* Operate normally */
41 43
42 TCNT0 = 0; /* Start counting at 0 */ 44 TCNT0 = 0; /* Start counting at 0 */
43 GRA0 = 0xfff0; 45 GRA0 = count;
44 TCR0 = 0x23; /* Clear at GRA match, sysclock/8 */ 46 TCR0 = 0x23; /* Clear at GRA match, sysclock/8 */
45 47
46 TSTR |= 0x01; /* Start timer 1 */
47
48 /* Enable interrupt on level 1 */ 48 /* Enable interrupt on level 1 */
49 IPRC = (IPRC & ~0x00f0) | 0x0010; 49 IPRC = (IPRC & ~0x00f0) | 0x0010;
50
51 TIER0 |= 0x01; /* Enable GRA match interrupt */
52 50
53 while(1) 51 TSR0 &= ~0x01;
54 { 52 TIER0 |= 0x01; /* Enable GRA match interrupt */
55 } 53
54 TSTR |= 0x01; /* Start timer 1 */
56} 55}
57 56
58#pragma interrupt 57#pragma interrupt
59void IMIA0(void) 58void IMIA0(void)
60{ 59{
60 current_tick++;
61
61 TSR0 &= ~0x01; 62 TSR0 &= ~0x01;
62 debugf("Yes\n");
63} 63}