summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/test/kernel/Makefile42
-rw-r--r--firmware/test/kernel/app.lds23
-rw-r--r--firmware/test/kernel/crt0.S49
-rw-r--r--firmware/test/kernel/main.c82
4 files changed, 196 insertions, 0 deletions
diff --git a/firmware/test/kernel/Makefile b/firmware/test/kernel/Makefile
new file mode 100644
index 0000000000..fdeb9b159b
--- /dev/null
+++ b/firmware/test/kernel/Makefile
@@ -0,0 +1,42 @@
1CC = sh-elf-gcc
2LD = sh-elf-ld
3AR = sh-elf-ar
4AS = sh-elf-as
5OC = sh-elf-objcopy
6
7INCLUDES=-I../../
8
9CFLAGS = -O -Wall -m1 -save-temps -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns -fno-builtin $(INCLUDES)
10AFLAGS += -small -relax
11
12OBJS= crt0.o main.o ../../thread.o ../../debug.o
13
14%.o: %.S
15 $(CC) -o $@ $(CFLAGS) $(INCLUDES) $(DEFS) -c $<
16
17
18all : archos.mod
19
20archos.elf : $(OBJS) app.lds
21 $(CC) -nostartfiles -o archos.elf $(OBJS) -lgcc -Tapp.lds -Wl,-Map,archos.map
22
23archos.bin : archos.elf
24 $(OC) -O binary archos.elf archos.bin
25
26archos.asm: archos.bin
27 sh2d -sh1 archos.bin > archos.asm
28
29archos.mod : archos.bin
30 scramble archos.bin archos.mod
31
32archos.mod.gz : archos.mod
33 gzip -f archos.mod
34
35dist:
36 tar czvf dist.tar.gz Makefile main.c start.s app.lds
37
38clean:
39 -rm -f *.x *.i *.o *.elf *.bin *.map *.mod *.bak *~
40
41install:
42 mount /mnt/archos; cp archos.mod /mnt/archos; umount /mnt/archos
diff --git a/firmware/test/kernel/app.lds b/firmware/test/kernel/app.lds
new file mode 100644
index 0000000000..4b7e5f4c6f
--- /dev/null
+++ b/firmware/test/kernel/app.lds
@@ -0,0 +1,23 @@
1ENTRY(start)
2OUTPUT_FORMAT(elf32-sh)
3SECTIONS
4{
5 .text 0x09018000 :
6 {
7 *(.rodata)
8 *(.text)
9 }
10
11 .data :
12 {
13 *(.data)
14 }
15
16 .bss :
17 {
18 *(.bss)
19 _end = . + 0x8000;
20 _stack = . + 0x9000;
21 _edata = .;
22 }
23}
diff --git a/firmware/test/kernel/crt0.S b/firmware/test/kernel/crt0.S
new file mode 100644
index 0000000000..5f0ef2d64e
--- /dev/null
+++ b/firmware/test/kernel/crt0.S
@@ -0,0 +1,49 @@
1 .section .text
2 .global start
3start:
4 mov.l stack_k,r15
5
6 ! zero out bss
7 mov.l edata_k,r0
8 mov.l end_k,r1
9 mov #0,r2
10start_l:
11 mov.l r2,@r0
12 add #4,r0
13 cmp/ge r0,r1
14 bt start_l
15 nop
16
17#if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY)
18 mov.l set_fpscr_k, r1
19 jsr @r1
20 mov #0,r4
21 lds r3,fpscr
22#endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) */
23
24 ! call the mainline
25 mov.l main_k,r0
26 jsr @r0
27 nop
28.hoo:
29 bra .hoo
30
31 .align 2
32#if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
33set_fpscr_k:
34 .long ___set_fpscr
35#endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(SH4_SINGLE_ONLY) */
36stack_k:
37 .long _stack
38edata_k:
39 .long _edata
40end_k:
41 .long _end
42main_k:
43 .long _main
44
45#ifdef __ELF__
46 .section .stack,"aw"
47#else
48 .section .stack
49#endif
diff --git a/firmware/test/kernel/main.c b/firmware/test/kernel/main.c
new file mode 100644
index 0000000000..7e0bd3e3f8
--- /dev/null
+++ b/firmware/test/kernel/main.c
@@ -0,0 +1,82 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "thread.h"
20#include "sh7034.h"
21#include "debug.h"
22
23unsigned int s1[256];
24unsigned int s2[256];
25
26void t1(void);
27void t2(void);
28
29int main(void)
30{
31 char buf[40];
32 char str[32];
33 int i=0;
34
35 /* Clear it all! */
36 SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER);
37
38 /* This enables the serial Rx interrupt, to be able to exit into the
39 debugger when you hit CTRL-C */
40 SCR1 |= 0x40;
41 SCR1 &= ~0x80;
42 asm ("ldc\t%0,sr" : : "r"(0<<4));
43
44 debugf("OK. Let's go\n");
45
46 create_thread(t1, s1, 1024);
47 create_thread(t2, s2, 1024);
48
49 while(1)
50 {
51 debugf("t0\n");
52 switch_thread();
53 }
54}
55
56void t1(void)
57{
58 while(1)
59 {
60 debugf("t1\n");
61 switch_thread();
62 }
63}
64
65void t2(void)
66{
67 while(1)
68 {
69 debugf("t2\n");
70 switch_thread();
71 }
72}
73
74extern const void stack(void);
75
76const void* vectors[] __attribute__ ((section (".vectors"))) =
77{
78 main, /* Power-on reset */
79 stack, /* Power-on reset (stack pointer) */
80 main, /* Manual reset */
81 stack /* Manual reset (stack pointer) */
82};