summaryrefslogtreecommitdiff
path: root/bsp/taihu
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2012-10-14 23:28:37 +0000
committerbernard.xiong <[email protected]>2012-10-14 23:28:37 +0000
commit0c1371139684af526c05eee22ff337149332bd2c (patch)
tree60579454b805e888c02d14df26794fee6e1ecc49 /bsp/taihu
parent8ab10598731740fe9264351108aaf4aa9121074f (diff)
Add taihu bsp (PPC405)
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2350 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'bsp/taihu')
-rw-r--r--bsp/taihu/SConscript15
-rw-r--r--bsp/taihu/SConstruct33
-rw-r--r--bsp/taihu/applications/SConscript11
-rw-r--r--bsp/taihu/applications/application.c100
-rw-r--r--bsp/taihu/applications/board.c24
-rw-r--r--bsp/taihu/applications/board.h20
-rw-r--r--bsp/taihu/applications/startup.c77
-rw-r--r--bsp/taihu/rtconfig.h121
-rw-r--r--bsp/taihu/rtconfig.py40
-rw-r--r--bsp/taihu/taihu.lds128
10 files changed, 569 insertions, 0 deletions
diff --git a/bsp/taihu/SConscript b/bsp/taihu/SConscript
new file mode 100644
index 0000000000..e070e9190a
--- /dev/null
+++ b/bsp/taihu/SConscript
@@ -0,0 +1,15 @@
+# RT-Thread building script for bridge
+
+import os
+from building import *
+
+cwd = GetCurrentDir()
+objs = []
+list = os.listdir(cwd)
+
+for d in list:
+ path = os.path.join(cwd, d)
+ if os.path.isfile(os.path.join(path, 'SConscript')):
+ objs = objs + SConscript(os.path.join(d, 'SConscript'))
+
+Return('objs')
diff --git a/bsp/taihu/SConstruct b/bsp/taihu/SConstruct
new file mode 100644
index 0000000000..7c5d76c29c
--- /dev/null
+++ b/bsp/taihu/SConstruct
@@ -0,0 +1,33 @@
+import os
+import sys
+import rtconfig
+
+if os.getenv('RTT_ROOT'):
+ RTT_ROOT = os.getenv('RTT_ROOT')
+else:
+ RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
+sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
+from building import *
+
+TARGET = 'rtthread-taihu.' + rtconfig.TARGET_EXT
+cwd = GetCurrentDir()
+
+# add include path for asm
+rtconfig.AFLAGS = rtconfig.AFLAGS + ' -I' + RTT_ROOT + '/libcpu/ppc/ppc405/include '
+rtconfig.CFLAGS = rtconfig.CFLAGS + ' -I' + RTT_ROOT + '/libcpu/ppc/ppc405/include '
+
+env = Environment(tools = ['mingw'],
+ AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
+ CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
+ AR = rtconfig.AR, ARFLAGS = '-rc',
+ LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
+env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
+
+Export('RTT_ROOT')
+Export('rtconfig')
+
+# prepare building environment
+objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
+
+# build program
+DoBuilding(TARGET, objs)
diff --git a/bsp/taihu/applications/SConscript b/bsp/taihu/applications/SConscript
new file mode 100644
index 0000000000..687705eda7
--- /dev/null
+++ b/bsp/taihu/applications/SConscript
@@ -0,0 +1,11 @@
+# RT-Thread building script for component
+
+from building import *
+
+cwd = GetCurrentDir()
+src = Glob('*.c')
+CPPPATH = [cwd, Dir('#')]
+
+group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
+
+Return('group')
diff --git a/bsp/taihu/applications/application.c b/bsp/taihu/applications/application.c
new file mode 100644
index 0000000000..fde951b663
--- /dev/null
+++ b/bsp/taihu/applications/application.c
@@ -0,0 +1,100 @@
+/*
+ * File : application.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Develop Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-04-16 first version
+ */
+
+#include <rtthread.h>
+
+#define THREAD_STACK_SIZE 1024
+
+#if 0
+struct rt_semaphore sem1, sem2;
+static struct rt_thread thread1;
+ALIGN(4)
+static rt_uint8_t thread1_stack[THREAD_STACK_SIZE];
+static struct rt_thread thread2;
+ALIGN(4)
+static rt_uint8_t thread2_stack[THREAD_STACK_SIZE];
+
+static void thread1_entry(void* parameter)
+{
+ while (1)
+ {
+ rt_sem_release(&sem2);
+ rt_kprintf("thread1..: %s\n", rt_thread_self()->name);
+ rt_sem_take(&sem1, RT_WAITING_FOREVER);
+ rt_kprintf("get semaphore: %s!\n", rt_thread_self()->name);
+ }
+}
+
+static void thread2_entry(void* parameter)
+{
+ while (1)
+ {
+ rt_sem_take(&sem2, RT_WAITING_FOREVER);
+ rt_kprintf("thread2--->: %s\n", rt_thread_self()->name);
+ rt_sem_release(&sem1);
+ }
+}
+
+/* user application */
+int rt_application_init()
+{
+ rt_err_t result;
+
+ rt_sem_init(&sem1, "s1", 0, RT_IPC_FLAG_FIFO);
+ rt_sem_init(&sem2, "s2", 0, RT_IPC_FLAG_FIFO);
+
+ result = rt_thread_init(&thread1, "t1", thread1_entry, RT_NULL,
+ &thread1_stack[0], sizeof(thread1_stack), 10, 10);
+ if (result == RT_EOK)
+ rt_thread_startup(&thread1);
+
+ result = rt_thread_init(&thread2, "t2", thread2_entry, RT_NULL,
+ &thread2_stack[0], sizeof(thread2_stack), 18, 10);
+ if (result == RT_EOK)
+ rt_thread_startup(&thread2);
+
+ return 0;
+}
+#else
+static struct rt_thread thread1;
+ALIGN(4)
+static rt_uint8_t thread1_stack[THREAD_STACK_SIZE];
+rt_timer_t ttimer;
+
+static void thread1_entry(void* parameter)
+{
+ rt_uint32_t count = 0;
+ while (1)
+ {
+ rt_kprintf("%s: count = %d\n", rt_thread_self()->name, count ++);
+
+ rt_thread_delay(10);
+ }
+}
+
+/* user application */
+int rt_application_init()
+{
+ rt_err_t result;
+
+ result = rt_thread_init(&thread1, "t1", thread1_entry, RT_NULL,
+ &thread1_stack[0], sizeof(thread1_stack), 10, 10);
+
+ ttimer = &(thread1.thread_timer);
+ if (result == RT_EOK)
+ rt_thread_startup(&thread1);
+
+ return 0;
+}
+#endif
diff --git a/bsp/taihu/applications/board.c b/bsp/taihu/applications/board.c
new file mode 100644
index 0000000000..507cc0ae22
--- /dev/null
+++ b/bsp/taihu/applications/board.c
@@ -0,0 +1,24 @@
+/*
+ * File : board.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Develop Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-04-16 first version
+ */
+
+#include <rtthread.h>
+#include <rthw.h>
+
+#include "board.h"
+
+void rt_hw_board_init()
+{
+ rt_hw_serial_init();
+ rt_console_set_device("uart1");
+}
diff --git a/bsp/taihu/applications/board.h b/bsp/taihu/applications/board.h
new file mode 100644
index 0000000000..518084aca6
--- /dev/null
+++ b/bsp/taihu/applications/board.h
@@ -0,0 +1,20 @@
+/*
+ * File : board.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Develop Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-04-16 first version
+ */
+
+#ifndef __BOARD_H__
+#define __BOARD_H__
+
+void rt_hw_board_init(void);
+
+#endif
diff --git a/bsp/taihu/applications/startup.c b/bsp/taihu/applications/startup.c
new file mode 100644
index 0000000000..4afa6e4fdb
--- /dev/null
+++ b/bsp/taihu/applications/startup.c
@@ -0,0 +1,77 @@
+/*
+ * File : startup.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Develop Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-04-16 nsj first version
+ */
+
+#include <rthw.h>
+#include <rtthread.h>
+
+#ifdef RT_USING_FINSH
+#include <finsh.h>
+extern void finsh_system_init(void);
+#endif
+
+extern int rt_application_init(void);
+#ifdef RT_USING_DEVICE
+extern rt_err_t rt_hw_serial_init(void);
+#endif
+
+extern int __heap_start;
+extern int __heap_end;
+
+/**
+ * This function will startup RT-Thread RTOS.
+ */
+void rtthread_startup(void)
+{
+ /* init hardware interrupt */
+ rt_hw_interrupt_init();
+
+ /* init board */
+ rt_hw_board_init();
+ rt_show_version();
+
+ /* init tick */
+ rt_system_tick_init();
+
+ /* init timer system */
+ rt_system_timer_init();
+
+ /* init memory system */
+#ifdef RT_USING_HEAP
+ rt_system_heap_init((void*)&__heap_start, (void*)&__heap_end);
+#endif
+
+ /* init scheduler system */
+ rt_system_scheduler_init();
+
+ /* init application */
+ rt_application_init();
+
+#ifdef RT_USING_FINSH
+ /* init finsh */
+ finsh_system_init();
+ finsh_set_device("uart1");
+#endif
+
+ /* init soft timer thread */
+ rt_system_timer_thread_init();
+
+ /* init idle thread */
+ rt_thread_idle_init();
+
+ /* start scheduler */
+ rt_system_scheduler_start();
+
+ /* never reach here */
+ return ;
+}
diff --git a/bsp/taihu/rtconfig.h b/bsp/taihu/rtconfig.h
new file mode 100644
index 0000000000..684f45486b
--- /dev/null
+++ b/bsp/taihu/rtconfig.h
@@ -0,0 +1,121 @@
+/* RT-Thread config file */
+#ifndef __RTTHREAD_CFG_H__
+#define __RTTHREAD_CFG_H__
+
+/* RT_NAME_MAX*/
+#define RT_NAME_MAX 8
+
+/* RT_ALIGN_SIZE*/
+#define RT_ALIGN_SIZE 4
+
+/* PRIORITY_MAX*/
+#define RT_THREAD_PRIORITY_MAX 32
+#define IDLE_THREAD_STACK_SIZE 1024
+
+/* Tick per Second*/
+#define RT_TICK_PER_SECOND 100
+/* CPU Frequency 200MHz */
+#define RT_CPU_FREQ 200
+
+/* SECTION: RT_DEBUG */
+/* open debug for system assert */
+// #define RT_DEBUG
+/* Thread Debug*/
+/* #define RT_THREAD_DEBUG */
+/* #define RT_SCHEDULER_DEBUG */
+
+/* Using Hook*/
+#define RT_USING_HOOK
+
+/* SECTION: IPC */
+/* Using Semaphore*/
+#define RT_USING_SEMAPHORE
+
+/* Using Mutex*/
+#define RT_USING_MUTEX
+
+/* Using Event*/
+#define RT_USING_EVENT
+
+/* Using MailBox*/
+#define RT_USING_MAILBOX
+
+/* Using Message Queue*/
+#define RT_USING_MESSAGEQUEUE
+
+/* SECTION: Memory Management */
+/* Using Memory Pool Management*/
+#define RT_USING_MEMPOOL
+
+/* Using Dynamic Heap Management*/
+#define RT_USING_HEAP
+
+/* Using Small MM*/
+#define RT_USING_SMALL_MEM
+
+// #define RT_USING_NOLIBC
+#define RT_TINY_SIZE
+
+/* SECTION: Device System */
+/* Using Device System*/
+#define RT_USING_DEVICE
+#define RT_USING_UART1
+#define RT_UART_RX_BUFFER_SIZE 64
+
+/* SECTION: Console options */
+#define RT_USING_CONSOLE
+/* the buffer size of console*/
+#define RT_CONSOLEBUF_SIZE 128
+
+/* SECTION: FinSH shell options */
+/* Using FinSH as Shell*/
+#define RT_USING_FINSH
+/* Using symbol table */
+#define FINSH_USING_SYMTAB
+#define FINSH_USING_DESCRIPTION
+
+/* SECTION: lwip, a lighwight TCP/IP protocol stack */
+/* #define RT_USING_LWIP */
+/* LwIP uses RT-Thread Memory Management */
+#define RT_LWIP_USING_RT_MEM
+/* Enable ICMP protocol*/
+#define RT_LWIP_ICMP
+/* Enable UDP protocol*/
+#define RT_LWIP_UDP
+/* Enable TCP protocol*/
+#define RT_LWIP_TCP
+/* Enable DNS */
+#define RT_LWIP_DNS
+
+/* the number of simulatenously active TCP connections*/
+#define RT_LWIP_TCP_PCB_NUM 5
+
+/* ip address of target*/
+#define RT_LWIP_IPADDR0 192
+#define RT_LWIP_IPADDR1 168
+#define RT_LWIP_IPADDR2 1
+#define RT_LWIP_IPADDR3 30
+
+/* gateway address of target*/
+#define RT_LWIP_GWADDR0 192
+#define RT_LWIP_GWADDR1 168
+#define RT_LWIP_GWADDR2 1
+#define RT_LWIP_GWADDR3 1
+
+/* mask address of target*/
+#define RT_LWIP_MSKADDR0 255
+#define RT_LWIP_MSKADDR1 255
+#define RT_LWIP_MSKADDR2 255
+#define RT_LWIP_MSKADDR3 0
+
+/* tcp thread options */
+#define RT_LWIP_TCPTHREAD_PRIORITY 12
+#define RT_LWIP_TCPTHREAD_MBOX_SIZE 4
+#define RT_LWIP_TCPTHREAD_STACKSIZE 1024
+
+/* ethernet if thread options */
+#define RT_LWIP_ETHTHREAD_PRIORITY 15
+#define RT_LWIP_ETHTHREAD_MBOX_SIZE 4
+#define RT_LWIP_ETHTHREAD_STACKSIZE 512
+
+#endif
diff --git a/bsp/taihu/rtconfig.py b/bsp/taihu/rtconfig.py
new file mode 100644
index 0000000000..f6fe0449d6
--- /dev/null
+++ b/bsp/taihu/rtconfig.py
@@ -0,0 +1,40 @@
+# toolchains options
+ARCH='ppc'
+CPU='ppc405'
+CROSS_TOOL='gcc'
+TextBase = '0x00000000'
+
+PLATFORM = 'gcc'
+EXEC_PATH = 'C:/Program Files/CodeSourcery/Sourcery G++ Lite/bin'
+BUILD = 'debug'
+
+if PLATFORM == 'gcc':
+ # toolchains
+ PREFIX = 'powerpc-eabi-'
+ CC = PREFIX + 'gcc'
+ CXX = PREFIX + 'g++'
+ AS = PREFIX + 'gcc'
+ AR = PREFIX + 'ar'
+ LINK = PREFIX + 'gcc'
+ TARGET_EXT = 'elf'
+ SIZE = PREFIX + 'size'
+ OBJDUMP = PREFIX + 'objdump'
+ OBJCPY = PREFIX + 'objcopy'
+
+ DEVICE = ' -mcpu=405 -mno-multiple -mno-string -mno-update -fno-exceptions -fno-builtin -msoft-float'
+
+ CFLAGS = DEVICE + ' -D__KERNEL__'
+ AFLAGS = '-D__ASSEMBLY__ -fno-exceptions -fno-builtin -mregnames -c -Wall -Xassembler -m405 -msoft-float -ffunction-sections'
+ LFLAGS = DEVICE + ' -Wl,--gc-sections,--cref,-Map=rtthread.map -T taihu.lds' + ' -Ttext=' + TextBase
+
+ CPATH = ''
+ LPATH = ''
+
+ if BUILD == 'debug':
+ CFLAGS += ' -O0 -gdwarf-2'
+ AFLAGS += ' -gdwarf-2'
+ else:
+ CFLAGS += ' -O2'
+
+ DASM_ACTION = OBJDUMP + ' -d rtthread-taihu.elf > rtt.asm\n'
+ POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' # + DASM_ACTION
diff --git a/bsp/taihu/taihu.lds b/bsp/taihu/taihu.lds
new file mode 100644
index 0000000000..15d2764c72
--- /dev/null
+++ b/bsp/taihu/taihu.lds
@@ -0,0 +1,128 @@
+OUTPUT_ARCH(powerpc)
+
+/* Do we need any of these for elf?
+ __DYNAMIC = 0; */
+SECTIONS
+{
+ .resetvec 0xFFFFFFFC :
+ {
+ *(.resetvec)
+ } = 0xffff
+
+ /* Read-only sections, merged into text segment: */
+ . = + SIZEOF_HEADERS;
+ .interp : { *(.interp) }
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .rel.text : { *(.rel.text) }
+ .rela.text : { *(.rela.text) }
+ .rel.data : { *(.rel.data) }
+ .rela.data : { *(.rela.data) }
+ .rel.rodata : { *(.rel.rodata) }
+ .rela.rodata : { *(.rela.rodata) }
+ .rel.got : { *(.rel.got) }
+ .rela.got : { *(.rela.got) }
+ .rel.ctors : { *(.rel.ctors) }
+ .rela.ctors : { *(.rela.ctors) }
+ .rel.dtors : { *(.rel.dtors) }
+ .rela.dtors : { *(.rela.dtors) }
+ .rel.bss : { *(.rel.bss) }
+ .rela.bss : { *(.rela.bss) }
+ .rel.plt : { *(.rel.plt) }
+ .rela.plt : { *(.rela.plt) }
+ /* .init : { *(.init) } */
+ .plt : { *(.plt) }
+
+ .text :
+ {
+ KEEP(build\libcpu\ppc\ppc405\start_gcc.o (.text))
+
+ *(.text)
+ *(.fixup)
+ *(.got1)
+ }
+ _etext = .;
+ PROVIDE (etext = .);
+ .rodata :
+ {
+ *(.eh_frame)
+ *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
+ /* section information for finsh shell */
+ . = ALIGN(4);
+ __fsymtab_start = .;
+ KEEP(*(FSymTab))
+ __fsymtab_end = .;
+ . = ALIGN(4);
+ __vsymtab_start = .;
+ KEEP(*(VSymTab))
+ __vsymtab_end = .;
+ }
+ .fini : { *(.fini) } =0
+ .ctors : { *(.ctors) }
+ .dtors : { *(.dtors) }
+
+ /* Read-write section, merged into data segment: */
+ . = (. + 0x00FF) & 0xFFFFFF00;
+ _erotext = .;
+ PROVIDE (erotext = .);
+ .reloc :
+ {
+ *(.got)
+ _GOT2_TABLE_ = .;
+ *(.got2)
+ _FIXUP_TABLE_ = .;
+ *(.fixup)
+ }
+ __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+ __fixup_entries = (. - _FIXUP_TABLE_)>>2;
+
+ .data :
+ {
+ *(.data)
+ *(.data1)
+ *(.sdata)
+ *(.sdata2)
+ *(.dynamic)
+ CONSTRUCTORS
+ }
+ _edata = .;
+ PROVIDE (edata = .);
+
+ . = .;
+ __start___ex_table = .;
+ __ex_table : { *(__ex_table) }
+ __stop___ex_table = .;
+
+ . = ALIGN(256);
+ __init_begin = .;
+ .text.init : { *(.text.init) }
+ .data.init : { *(.data.init) }
+ . = ALIGN(256);
+ __init_end = .;
+
+ __bss_start = .;
+ .bss (NOLOAD) :
+ {
+ *(.sbss) *(.scommon)
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ . = ALIGN(4);
+ }
+ __bss_end = .;
+
+ . = ALIGN(256);
+
+ PROVIDE(__stack_bottom = .);
+ . += 0x100000; /* 1MB */
+ PROVIDE(__stack_top = .);
+
+ . = ALIGN(256);
+ PROVIDE (__heap_start = .);
+ . += 0x500000; /* 5MB */
+ PROVIDE(__heap_end = .);
+
+ _end = . ;
+ PROVIDE (end = .);
+}