First version

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@175 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2002-04-22 19:12:37 +00:00
parent 34f026eb47
commit 1f563bfd29
4 changed files with 196 additions and 0 deletions

View file

@ -0,0 +1,42 @@
CC = sh-elf-gcc
LD = sh-elf-ld
AR = sh-elf-ar
AS = sh-elf-as
OC = sh-elf-objcopy
INCLUDES=-I../../
CFLAGS = -O -Wall -m1 -save-temps -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns -fno-builtin $(INCLUDES)
AFLAGS += -small -relax
OBJS= crt0.o main.o ../../thread.o ../../debug.o
%.o: %.S
$(CC) -o $@ $(CFLAGS) $(INCLUDES) $(DEFS) -c $<
all : archos.mod
archos.elf : $(OBJS) app.lds
$(CC) -nostartfiles -o archos.elf $(OBJS) -lgcc -Tapp.lds -Wl,-Map,archos.map
archos.bin : archos.elf
$(OC) -O binary archos.elf archos.bin
archos.asm: archos.bin
sh2d -sh1 archos.bin > archos.asm
archos.mod : archos.bin
scramble archos.bin archos.mod
archos.mod.gz : archos.mod
gzip -f archos.mod
dist:
tar czvf dist.tar.gz Makefile main.c start.s app.lds
clean:
-rm -f *.x *.i *.o *.elf *.bin *.map *.mod *.bak *~
install:
mount /mnt/archos; cp archos.mod /mnt/archos; umount /mnt/archos

View file

@ -0,0 +1,23 @@
ENTRY(start)
OUTPUT_FORMAT(elf32-sh)
SECTIONS
{
.text 0x09018000 :
{
*(.rodata)
*(.text)
}
.data :
{
*(.data)
}
.bss :
{
*(.bss)
_end = . + 0x8000;
_stack = . + 0x9000;
_edata = .;
}
}

View file

@ -0,0 +1,49 @@
.section .text
.global start
start:
mov.l stack_k,r15
! zero out bss
mov.l edata_k,r0
mov.l end_k,r1
mov #0,r2
start_l:
mov.l r2,@r0
add #4,r0
cmp/ge r0,r1
bt start_l
nop
#if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY)
mov.l set_fpscr_k, r1
jsr @r1
mov #0,r4
lds r3,fpscr
#endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) */
! call the mainline
mov.l main_k,r0
jsr @r0
nop
.hoo:
bra .hoo
.align 2
#if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
set_fpscr_k:
.long ___set_fpscr
#endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(SH4_SINGLE_ONLY) */
stack_k:
.long _stack
edata_k:
.long _edata
end_k:
.long _end
main_k:
.long _main
#ifdef __ELF__
.section .stack,"aw"
#else
.section .stack
#endif

View file

@ -0,0 +1,82 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Linus Nielsen Feltzing
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "thread.h"
#include "sh7034.h"
#include "debug.h"
unsigned int s1[256];
unsigned int s2[256];
void t1(void);
void t2(void);
int main(void)
{
char buf[40];
char str[32];
int i=0;
/* Clear it all! */
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;
asm ("ldc\t%0,sr" : : "r"(0<<4));
debugf("OK. Let's go\n");
create_thread(t1, s1, 1024);
create_thread(t2, s2, 1024);
while(1)
{
debugf("t0\n");
switch_thread();
}
}
void t1(void)
{
while(1)
{
debugf("t1\n");
switch_thread();
}
}
void t2(void)
{
while(1)
{
debugf("t2\n");
switch_thread();
}
}
extern const void stack(void);
const void* vectors[] __attribute__ ((section (".vectors"))) =
{
main, /* Power-on reset */
stack, /* Power-on reset (stack pointer) */
main, /* Manual reset */
stack /* Manual reset (stack pointer) */
};