SEP6200 Support

This commit is contained in:
Peng Fan committed 2013-07-17 13:37:31 +08:00
1 parent f0f0e3dd9e
commit 73beced22a
22 files changed
+3043

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
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')
+33
View File
@@ -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-sep6200.' + rtconfig.TARGET_EXT
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)
env.Replace(LINKCOM = ['$LINK $SOURCES $LINKFLAGS -o $TARGET'])
Export('RTT_ROOT')
Export('rtconfig')
# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT)
# build program
env.Program(TARGET, objs)
# end building
EndBuilding(TARGET)
+9
View File
@@ -0,0 +1,9 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = [cwd, str(Dir('#'))]
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
+93
View File
@@ -0,0 +1,93 @@
/*
* File : application.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development 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
* 2007-11-20 Yi.Qiu add rtgui application
* 2008-6-28 Bernard no rtgui init
* 2013-7-14 Peng Fan modified from mini4020
*/
/**
* @addtogroup sep6200
*/
/*@{*/
#include "board.h"
#include <rtthread.h>
#ifdef RT_USING_DFS
#include <dfs_init.h>
#include <dfs_elm.h>
#include <dfs_fs.h>
#include <dfs_posix.h>
#endif
#ifdef RT_USING_RTGUI
#include <rtgui/rtgui.h>
extern void radio_rtgui_init(void);
#endif
#define RT_INIT_THREAD_STACK_SIZE (2*1024)
void rt_init_thread_entry(void *parameter)
{
while(1){
rt_thread_sleep(200);
rt_hw_console_output("init thread\n");
}
}
void rt_test1_thread_entry(void *parameter)
{
while(1){
rt_thread_sleep(800);
rt_hw_console_output("test1 thread\n");
}
}
void rt_test2_thread_entry(void *parameter)
{
while(1){
rt_thread_sleep(300);
rt_hw_console_output("test2 thread\n");
}
}
int rt_application_init(void)
{
rt_thread_t init_thread;
rt_thread_t test1_thread;
rt_thread_t test2_thread;
init_thread = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
RT_INIT_THREAD_STACK_SIZE, 8, 20);
test1_thread = rt_thread_create("test1",
rt_test1_thread_entry, RT_NULL,
512, 200, 20);
test2_thread = rt_thread_create("test2",
rt_test2_thread_entry, RT_NULL,
512, 200, 20);
if (init_thread != RT_NULL)
rt_thread_startup(init_thread);
if (test1_thread != RT_NULL)
rt_thread_startup(test1_thread);
if (test2_thread != RT_NULL)
rt_thread_startup(test2_thread);
return 0;
}
/*@}*/
+121
View File
@@ -0,0 +1,121 @@
/*
* File : application.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2012, RT-Thread Development 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
* 2013-7-14 Peng Fan Modified from mini4020
*/
#include <rthw.h>
#include <rtthread.h>
#include <board.h>
#include <serial.h>
#ifdef RT_USING_FINSH
#include <finsh.h>
#endif
#ifdef RT_USING_LWIP
#include <lwip/sys.h>
#include <netif/ethernetif.h>
#endif
#include <sep6200.h>
rt_uint8_t _irq_stack_start[1024];
rt_uint8_t _fiq_stack_start[1024];
rt_uint8_t _undefined_stack_start[512];
rt_uint8_t _abort_stack_start[512];
rt_uint8_t _priv_stack_start[4096]; SECTION(".nobss");
extern unsigned char __bss_start;
extern unsigned char __bss_end;
extern void rt_hw_board_init(void);
extern void rt_application_init(void);
extern void finsh_system_init(void);
extern void sd_init(void);
void rtthread_startup()
{
/* init hardware interrupt */
rt_hw_interrupt_init();
/* init board */
rt_hw_board_init();
/* show version */
rt_show_version();
/* init tick */
rt_system_tick_init();
/* init kernel object */
rt_system_object_init();
/* init timer system */
rt_system_timer_init();
/* init heap memory system */
rt_system_heap_init(&__bss_end, (void*)0x45000000);
/* init scheduler system */
rt_system_scheduler_init();
#ifdef RT_USING_DEVICE
#ifdef RT_USING_DFS
rt_hw_sdcard_init();
#endif
#ifdef RT_USING_LWIP
eth_system_device_init();
rt_hw_dm9000_init();
#endif
/*init all registed devices */
rt_device_init_all();
#endif
/* init application */
rt_application_init();
#ifdef RT_USING_FINSH
/* init finsh */
finsh_system_init();
#ifdef RT_USING_DEVICE
finsh_set_device("uart0");
#endif
#endif
rt_system_timer_thread_init();
/* init idle thread */
rt_thread_idle_init();
/* start scheduler */
rt_system_scheduler_start();
/* never reach here */
return ;
}
int main()
{
rt_uint32_t UNUSED level;
/* disable interrupt first */
level = rt_hw_interrupt_disable();
/* startup RT-Thread RTOS */
rtthread_startup();
return 0;
}
+25
View File
@@ -0,0 +1,25 @@
/*
* File : board.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2012, RT-Thread Development 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
* 2006-10-08 Bernard add board.h to this bsp
* 2010-10-5 Wangmeng sep4020 implemention
* 2013-7-14 Peng Fan Modified from sep4020
*/
#ifndef __BOARD_H__
#define __BOARD_H__
#include <sep6200.h>
void rt_hw_board_init(void);
void rt_hw_sdcard_init(void);
#endif
+19
View File
@@ -0,0 +1,19 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c')
# remove no need file.
if GetDepend('RT_USING_LWIP') == False:
SrcRemove(src, 'dm9161.c')
if GetDepend('RT_USING_DFS') == False:
SrcRemove(src, 'sdcard.c')
if GetDepend('RT_USING_RTGUI') == False:
SrcRemove(src, 'lcd.c')
SrcRemove(src, 'lcdc.c')
CPPPATH = [cwd]
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
+173
View File
@@ -0,0 +1,173 @@
/*
* File : board.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2012 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://openlab.rt-thread.com/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2013-7-14 Peng Fan sep6200 implementation
*/
#include <rthw.h>
#include <rtthread.h>
#include <serial.h>
#include <sep6200.h>
void rt_hw_serial_putc(const char c);
#define UART0 ((struct uartport *)SEP6200_UART0_BASE)
struct rt_device uart0_device;
struct serial_int_rx uart0_int_rx;
struct serial_device uart0 =
{
UART0,
&uart0_int_rx,
RT_NULL
};
/*
* This function will handle rtos timer
*/
void rt_timer_handler(int vector, void *param)
{
rt_uint32_t clear_int;
/* clear timer interrupt */
if (read_reg(SEP6200_TIMER_T2IMSR) & 0x1)
clear_int = read_reg(SEP6200_TIMER_T2ISCR);
rt_tick_increase();
}
/*
* This function will handle serial interrupt
*/
#if 1
void rt_serial_handler(int vector, void *param)
{
rt_uint32_t num;
switch (vector) {
case INTSRC_UART0:
/*No interrupt*/
if ((*(RP)SEP6200_UART0_IIR & 0x1))
return;
/*Get the serial interrupt num*/
num = (*(RP)SEP6200_UART0_IIR >> 1) & 0x7;
/*Receive or timeout*/
if ((num == 6) || (num == 2))
rt_hw_serial_isr(&uart0_device);
break;
/*1,2,3 not implemented now, do in future*/
case INTSRC_UART1:
break;
case INTSRC_UART2:
break;
case INTSRC_UART3:
break;
}
}
#endif
/*
* This function will init timer2 for system ticks
*/
#define BUS4_FREQ 320000000UL
#define TIMER_CLK BUS4_FREQ
#define HZ 100
void rt_hw_timer_init(void)
{
*(RP)SEP6200_TIMER_T2LCR = (TIMER_CLK + HZ / 2) / HZ;
*(RP)SEP6200_TIMER_T2CR = 0x6;
rt_hw_interrupt_install(INTSRC_TIMER1, rt_timer_handler, RT_NULL, "timer");
rt_hw_interrupt_umask(INTSRC_TIMER1);
/* start the timer */
*(RP)SEP6200_TIMER_T2CR |= 0x1;
}
/*
* This function will init uart
*/
#define UART_CLK 60000000UL
void rt_hw_uart_init(void)
{
const rt_uint32_t uartclk = UART_CLK;
*(RP)(SEP6200_UART0_LCR) = 0x83;
*(RP)(SEP6200_UART0_DLBH) = (uartclk/16/115200) >> 8;
*(RP)(SEP6200_UART0_DLBL) = (uartclk/16/115200) & 0xff;
*(RP)(SEP6200_UART0_LCR) = 0x83 & (~(0x1 << 7));
*(RP)(SEP6200_UART0_FCR) = 0x0;
*(RP)(SEP6200_UART0_MCR) = 0x0;
*(RP)(SEP6200_UART0_IER) = 0x0;
/* Enable rx interrupt*/
*(RP)(SEP6200_UART0_IER) |= 0x1;
/* Disable tx interrupt*/
*(RP)(SEP6200_UART0_IER) &= ~(0x1 << 1);
rt_hw_interrupt_install(INTSRC_UART0, rt_serial_handler, RT_NULL, "uart0");
rt_hw_interrupt_umask(INTSRC_UART0);
rt_hw_serial_register(&uart0_device, "uart0",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
&uart0);
}
void rt_hw_board_init(void)
{
int i = 0;
rt_hw_uart_init();
rt_hw_timer_init();
}
/*
* Write one char to serial, must not trigger interrupt
*/
void rt_hw_serial_putc(const char c)
{
if (c == '\n')
rt_hw_serial_putc('\r');
while (!((*(RP)SEP6200_UART0_LSR) & 0x40));
*(RP)(SEP6200_UART0_TXFIFO) = c;
}
void printhex(unsigned int data)
{
int i = 0,a = 0;
for (i = 0; i < 8; i++) {
a = (data>>(32-(i+1)*4))&0xf;
if (((a<=9)&&(a>=0)))
rt_hw_serial_putc(a + 0x30);
else if ((a <= 0xf) && (a >= 0xa))
rt_hw_serial_putc(a-0xa+0x61);
}
rt_hw_serial_putc('\n');
}
/**
* This function is used by rt_kprintf to display a string on console.
*
* @param str the displayed string^M
*/
void rt_hw_console_output(const char *str)
{
while (*str) {
rt_hw_serial_putc(*str++);
}
}
File diff suppressed because it is too large. Load diff
+57
View File
@@ -0,0 +1,57 @@
import os
# toolchains options
ARCH = 'unicore32'
CPU = 'sep6200'
TextBase = '0x00000000'
CROSS_TOOL = 'gcc'
if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC')
if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
EXEC_PATH = '/usr/unicore/gnu-toolchain-unicore/uc4-1.0-beta-hard-RHELAS5/bin/'
elif CROSS_TOOL == 'keil':
PLATFORM = 'armcc'
EXEC_PATH = 'C:/Keil'
elif CROSS_TOOL == 'iar':
print '================ERROR============================'
print 'Not support yet!'
print '================================================='
exit(0)
if os.getenv('RTT_EXEC_PATH'):
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
#BUILD = 'debug'
BUILD = 'release'
if PLATFORM == 'gcc':
# toolchains
PREFIX = 'unicore32-linux-'
CC = PREFIX + 'gcc'
AS = PREFIX + 'gcc'
AR = PREFIX + 'ar'
LINK = PREFIX + 'ld'
TARGET_EXT = 'elf'
SIZE = PREFIX + 'size'
OBJDUMP = PREFIX + 'objdump'
OBJCPY = PREFIX + 'objcopy'
DEVICE = ' '
CFLAGS = DEVICE
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' + ' -DTEXT_BASE=' + TextBase
LFLAGS = DEVICE + ' -Bstatic --gc-sections -Map=rtthread_sep6200.map -cref -u _start -Ttext 0x40000000 -T sep6200.ld -L/usr/unicore/gnu-toolchain-unicore/uc4-1.0-beta-hard-RHELAS5/lib/gcc/unicore32-linux/4.4.2 -lgcc' + ' -Ttext ' + TextBase
CPATH = ''
LPATH = ''
if BUILD == 'debug':
CFLAGS += ' -O0 -gdwarf-2'
AFLAGS += ' -gdwarf-2'
else:
CFLAGS += ' -O2'
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
+86
View File
@@ -0,0 +1,86 @@
OUTPUT_FORMAT("elf32-littleunicore32", "elf32-bigunicore32", "elf32-littleunicore32")
OUTPUT_ARCH(unicore32)
ENTRY(_start)
SEARCH_DIR("/usr/unicore/gnu-toolchain-unicore/uc4-1.0-beta-hard-RHELAS5/unicore32-linux/lib");
SECTIONS
{
. = 0x00000000;
. = ALIGN(4);
.text :
{
*(.init)
*(.text)
*(.gnu.linkonce.t*)
/* section information for finsh shell */
. = ALIGN(4);
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
. = ALIGN(4);
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .;
. = ALIGN(4);
/* section information for modules */
. = ALIGN(4);
__rtmsymtab_start = .;
KEEP(*(RTMSymTab))
__rtmsymtab_end = .;
}
. = ALIGN(4);
.rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r*) *(.eh_frame) }
. = ALIGN(4);
.ctors :
{
PROVIDE(__ctors_start__ = .);
KEEP(*(SORT(.ctors.*)))
KEEP(*(.ctors))
PROVIDE(__ctors_end__ = .);
}
.dtors :
{
PROVIDE(__dtors_start__ = .);
KEEP(*(SORT(.dtors.*)))
KEEP(*(.dtors))
PROVIDE(__dtors_end__ = .);
}
. = ALIGN(4);
.data :
{
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
}
. = ALIGN(4);
.nobss : { *(.nobss) }
/*. = 0x00300000*/
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
__bss_end = .;
/* stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
_end = .;
}
+164
View File
@@ -0,0 +1,164 @@
/*
* File : clock.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2013-7-16 Peng Fan Just put the file here, should be implemented in
* future
*/
#include <rtthread.h>
#include <sep6200.h>
#define PLL_CFG(_f, _r) {.f = _f, .r = _r} /*f(frequency, MHz); r(config register value)*/
#define MHz 1000000UL
/*
*SEP0611_CLOCK
*├── APLL
*│   └── CPU
*├── DPLL
*│   └── DDR
*└── MPLL
* └── BUS1
* ├── BUS2
* │   ├── DMAC1
* │   ├── ESRAM
* │   ├── LCDC
* │   ├── NAND
* │   ├── NOR
* │   ├── SDIO1
* │   ├── SDIO2
* │   └── VPU
* ├── BUS3
* │   ├── BUS5
* │   │   ├── I2C1
* │   │   ├── I2C2
* │   │   ├── I2C3
* │   │   ├── I2S
* │   │   ├── SPI1
* │   │   ├── SPI2
* │   │   ├── SPI3
* │   │   ├── UART1
* │   │   ├── UART2
* │   │   ├── UART3
* │   │   └── UART4
* │   ├── DMAC2
* │   ├── GPU
* │   └── USB
* ├── BUS4
* │   ├── GPIO
* │   ├── GPSCTRL
* │   ├── PWM
* │   ├── RTC
* │   ├── SYSCTRL
* │   ├── TIMER
* │   └── VIC
* ├── DS1_2
* ├── DS1_3
* └── GPS
*/
enum sep0611_clk_gate{
DDRC = 0, BUS1, BUS2, BUS3, DS1_2,
DS1_3, USBC, DMAC1, NAND, DMAC2,
ESRAM, SDIO1, SDIO2, GPU, VPU,
BUS4, BUS5, VIC_, SYSCTRL, PRTC,
TIMER, GPSCTRL, GPIO, LCDC2HDMI, DDRPHY,
UART1, UART2, UART3, UART4, SPI1,
SPI2, SPI3,
I2C1 = 32, I2C2, I2C3, I2S, PWM,
H2X, LCDC, NOR, GPSHCLK, GPS,
};
typedef struct {
unsigned long f;
unsigned long r;
}pll_t;
static pll_t apll_tab[] = {
PLL_CFG(800*MHz, 0x00010810),
};
static pll_t mpll_tab[] = {
PLL_CFG(480*MHz, 0x00013C12), // 480MHz
};
static pll_t dpll_tab[] = {
PLL_CFG(400*MHz, 0x00010812), // 402MHz
};
static void rt_hw_set_system_clock(void)
{
/*apll, mpll, dpll is set in uboot when system boots up*/
}
static void rt_hw_set_usb_clock(void)
{
}
static void rt_hw_set_peripheral_clock(void)
{
}
/**
* @brief System Clock Configuration
*/
/* apll mpll dpll should be set in u-boot, Here just set clock
* of the pherial
*/
void rt_hw_set_apll_clock(void)
{
}
void rt_hw_set_mpll_clock(void)
{
}
void rt_hw_set_dpll_clock(void)
{
}
void rt_hw_clock_init(void)
{
/* set system clock */
rt_hw_set_system_clock();
}
/**
* @brief Get system clock
*/
rt_uint32_t rt_hw_get_clock(void)
{
}
/**
* @brief Enable module clock
*/
void rt_hw_enable_module_clock(rt_uint8_t module)
{
if (module >= 32) {
write_reg(SEP6200_PMU_CLK_GT_CFG2, (1 << (module - 32)) | read_reg(SEP6200_PMU_CLK_GT_CFG2));
} else {
write_reg(SEP6200_PMU_CLK_GT_CFG1, (1 << module) | read_reg(SEP6200_PMU_CLK_GT_CFG1));
}
}
/**
* @brief Disable module clock
*/
void rt_hw_disable_module_clock(rt_uint8_t module)
{
if (module >= 32) {
write_reg(SEP6200_PMU_CLK_GT_CFG2, ~(1 << (module - 32)) & read_reg(SEP6200_PMU_CLK_GT_CFG2));
} else {
write_reg(SEP6200_PMU_CLK_GT_CFG1, ~(1 << module) & read_reg(SEP6200_PMU_CLK_GT_CFG1));
}
}
+104
View File
@@ -0,0 +1,104 @@
/*
* File : context.S
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2013-7-14 Peng Fan First implementation
*/
/*!
* \addtogroup sep6200
*/
/*@{*/
#define NOINT 0xc0
/*
* rt_base_t rt_hw_interrupt_disable();
*/
.globl rt_hw_interrupt_disable
.type rt_hw_interrupt_disable, %function
rt_hw_interrupt_disable:
stw.w r1, [sp-], #4
mov r0, asr
or r1, r0, #NOINT
mov.a asr, r1
ldw.w r1, [sp]+, #4
mov pc, lr
/*
* void rt_hw_interrupt_enable(rt_base_t level);
*/
.globl rt_hw_interrupt_enable
.type rt_hw_interrupt_disable, %function
rt_hw_interrupt_enable:
mov.a asr, r0
mov pc, lr
/*
* void rt_hw_context_switch(rt_uint32 from, rt_uint32 to);
* r0 --> from
* r1 --> to
*/
.globl rt_hw_context_switch
.type rt_hw_interrupt_disable, %function
rt_hw_context_switch:
stm.w (lr), [sp-]
stm.w (r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, lr), [sp-]
stm.w (r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15), [sp-]
mov r4, asr
stm.w (r4), [sp-]
mov r4, bsr
stm.w (r4), [sp-]
stw sp, [r0+]
ldw sp, [r1+]
ldm.w (r4), [sp]+
mov.a bsr,r4
ldm.w (r4), [sp]+
mov.a asr, r4
ldm.w (r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15), [sp]+
ldm.w (r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, lr, pc), [sp]+
/*
* void rt_hw_context_switch_to(rt_uint32 to);
* r0 --> to
*/
.globl rt_hw_context_switch_to
rt_hw_context_switch_to:
ldw sp, [r0+]
ldm.w (r4), [sp]+
mov.a bsr, r4
ldm.w (r4), [sp]+
mov.a asr, r4
ldm.w (r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15), [sp]+
ldm.w (r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, lr, pc), [sp]+
/*
* void rt_hw_context_switch_interrupt(rt_uint32 from, rt_uint32 to);
*/
.globl rt_thread_switch_interrupt_flag
.globl rt_interrupt_from_thread
.globl rt_interrupt_to_thread
.globl rt_hw_context_switch_interrupt
rt_hw_context_switch_interrupt:
ldw r2, =rt_thread_switch_interrupt_flag
ldw r3, [r2+]
cmpsub.a r3, #1
beq _reswitch
mov r3, #1
stw r3, [r2+]
ldw r2, =rt_interrupt_from_thread
stw r0, [r2+]
_reswitch:
ldw r2, =rt_interrupt_to_thread
stw r1, [r2+]
mov pc, lr
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+96
View File
@@ -0,0 +1,96 @@
/*
* File : serial.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2006-03-13 Bernard first version
* 2009-04-20 yi.qiu modified according bernard's stm32 version
* 2010-10-6 wangmeng added sep4020 surpport
* 2013-7-15 Peng Fan Modified from sep4020
*/
#ifndef __SERIAL_H__
#define __SERIAL_H__
#include <sep6200.h>
#define USTAT_RCV_READY 0x01 /* receive data ready */
#define USTAT_OVERRUN 0x02 /* overrun */
#define USTAT_PARITY_ERR 0x04 /* parity error */
#define USTAT_FRAME_ERROR 0x08 /* frame error */
#define USTAT_BREAK 0x10 /* break */
#define USTAT_TXB_EMPTY 0x40 /* tx buffer empty */
#define USTAT_RCV_ERR 0x80 /* receive error */
#define BPS 115200 /* serial baudrate */
#define UART_RX_BUFFER_SIZE 64
#define UART_TX_BUFFER_SIZE 64
/*For sep6200's uart have several secondary function*/
/*we use union to decribe it*/
union dlbl_fifo
{
rt_uint32_t dlbl;
rt_uint32_t rxfifo;
rt_uint32_t txfifo;
};
union dlbh_ier
{
rt_uint32_t dlbh;
rt_uint32_t ier;
};
union iir_fcr
{
rt_uint32_t iir;
rt_uint32_t fcr;
};
struct serial_int_rx
{
rt_uint8_t rx_buffer[UART_RX_BUFFER_SIZE];
rt_uint32_t read_index, save_index;
};
struct serial_int_tx
{
rt_uint8_t tx_buffer[UART_TX_BUFFER_SIZE];
rt_uint32_t write_index, save_index;
};
typedef struct uartport
{
union dlbl_fifo dlbl_fifo;
union dlbh_ier dlbh_ier;
union iir_fcr iir_fcr;
rt_uint32_t lcr;
rt_uint32_t mcr;
rt_uint32_t lsr;
rt_uint32_t msr;
}uartport;
struct serial_device
{
uartport* uart_device;
/* rx structure */
struct serial_int_rx* int_rx;
/* tx structure */
struct serial_int_tx* int_tx;
};
rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t flag, struct serial_device *serial);
void rt_hw_serial_isr(rt_device_t device);
#endif
+78
View File
@@ -0,0 +1,78 @@
/*
* File : stack.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2013-7-14 Peng Fan Modifiled from sep4020
*/
#include <rtthread.h>
#include <sep6200.h>
/**
* @addtogroup sep6200
*/
/*@{*/
/**
* This function will initialize thread stack
*
* @param tentry the entry of thread
* @param parameter the parameter of entry
* @param stack_addr the beginning stack address
* @param texit the function will be called when thread exit
*
* @return stack address
*/
rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
rt_uint8_t *stack_addr, void *texit)
{
rt_uint32_t *stk;
stk = (rt_uint32_t*)stack_addr;
*(stk) = (rt_uint32_t)tentry; /* entry point */
*(--stk) = (rt_uint32_t)texit; /* lr */
*(--stk) = 0; /* r28 */
*(--stk) = 0; /* r27 */
*(--stk) = 0; /* r26 */
*(--stk) = 0; /* r25 */
*(--stk) = 0; /* r24 */
*(--stk) = 0; /* r23 */
*(--stk) = 0; /* r22 */
*(--stk) = 0; /* r21 */
*(--stk) = 0; /* r20 */
*(--stk) = 0; /* r19 */
*(--stk) = 0; /* r18 */
*(--stk) = 0; /* r17 */
*(--stk) = 0; /* r16 */
*(--stk) = 0; /* r15 */
*(--stk) = 0; /* r14 */
*(--stk) = 0; /* r13 */
*(--stk) = 0; /* r12 */
*(--stk) = 0; /* r11 */
*(--stk) = 0; /* r10 */
*(--stk) = 0; /* r9 */
*(--stk) = 0; /* r8 */
*(--stk) = 0; /* r7 */
*(--stk) = 0; /* r6 */
*(--stk) = 0; /* r5 */
*(--stk) = 0; /* r4 */
*(--stk) = 0; /* r3 */
*(--stk) = 0; /* r2 */
*(--stk) = 0; /* r1 */
*(--stk) = (rt_uint32_t)parameter; /* r0 : argument */
*(--stk) = Mode_PRIV; /* asr */
*(--stk) = Mode_PRIV; /* bsr */ /*why both PRIV do not need switch?*/
/* return task's current stack address */
return (rt_uint8_t *)stk;
}
/*@}*/
File diff suppressed because it is too large. Load diff
+6
View File
@@ -0,0 +1,6 @@
#include <rtthread.h>
void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry)
{
}
+164
View File
@@ -0,0 +1,164 @@
/*
* File : trap.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2013-03-16 Peng Fan Modifiled from sep4020
*/
#include <rtthread.h>
#include <rthw.h>
#include <sep6200.h>
/**
* @addtogroup sep6200
*/
/*@{*/
extern struct rt_thread *rt_current_thread;
/**
* this function will show registers of CPU
*
* @param regs the registers point
*/
void rt_hw_show_register (struct rt_hw_register *regs)
{
rt_kprintf("Execption:\n");
rt_kprintf("r00:0x%08x r01:0x%08x r02:0x%08x r03:0x%08x\n", regs->r0, regs->r1, regs->r2, regs->r3);
rt_kprintf("r04:0x%08x r05:0x%08x r06:0x%08x r07:0x%08x\n", regs->r4, regs->r5, regs->r6, regs->r7);
rt_kprintf("r08:0x%08x r09:0x%08x r10:0x%08x r11:0x%08x\n", regs->r8, regs->r9, regs->r10,regs->r11);
rt_kprintf("r12:0x%08x r13:0x%08x r14:0x%08x r15:0x%08x\n", regs->r12,regs->r13,regs->r14,regs->r15);
rt_kprintf("r16:0x%08x r17:0x%08x r18:0x%08x r19:0x%08x\n", regs->r16,regs->r17,regs->r18,regs->r19);
rt_kprintf("r20:0x%08x r21:0x%08x r22:0x%08x r23:0x%08x\n", regs->r20,regs->r21,regs->r22,regs->r23);
rt_kprintf("r24:0x%08x sb:0x%08x sl:0x%08xfp :0x%08x ip :0x%08x\n",regs->r24,regs->sb,regs->sl,regs->fp,regs->ip);
rt_kprintf("sp :0x%08x lr :0x%08x pc :0x%08x\n", regs->sp, regs->lr, regs->pc);
rt_kprintf("asr:0x%08x bsr:0x%08x\n", regs->asr,regs->bsr);
}
/**
* When unicore comes across an instruction which it cannot handle,
* it takes the extn instruction trap.
*
* @param regs system registers
*
* @note never invoke this function in application
*/
void rt_hw_trap_extn(struct rt_hw_register *regs)
{
rt_hw_show_register(regs);
rt_kprintf("extn instruction\n");
rt_kprintf("thread - %s stack:\n", rt_current_thread->name);
rt_hw_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry);
rt_hw_cpu_shutdown();
}
/**
* The software interrupt instruction (SWI) is used for entering
* Supervisor mode, usually to request a particular supervisor
* function.
*
* @param regs system registers
*
* @note never invoke this function in application
*/
void rt_hw_trap_swi(struct rt_hw_register *regs)
{
rt_hw_show_register(regs);
rt_kprintf("software interrupt\n");
rt_hw_cpu_shutdown();
}
/**
* An abort indicates that the current memory access cannot be completed,
* which occurs during an instruction prefetch.
*
* @param regs system registers
*
* @note never invoke this function in application
*/
void rt_hw_trap_pabt(struct rt_hw_register *regs)
{
rt_hw_show_register(regs);
rt_kprintf("prefetch abort\n");
rt_kprintf("thread - %s stack:\n", rt_current_thread->name);
rt_hw_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry);
rt_hw_cpu_shutdown();
}
/**
* An abort indicates that the current memory access cannot be completed,
* which occurs during a data access.
*
* @param regs system registers
*
* @note never invoke this function in application
*/
void rt_hw_trap_dabt(struct rt_hw_register *regs)
{
rt_hw_show_register(regs);
rt_kprintf("data abort\n");
rt_kprintf("thread - %s stack:\n", rt_current_thread->name);
rt_hw_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry);
rt_hw_cpu_shutdown();
}
/**
* Normally, system will never reach here
*
* @param regs system registers
*
* @note never invoke this function in application
*/
void rt_hw_trap_resv(struct rt_hw_register *regs)
{
rt_kprintf("not used\n");
rt_hw_show_register(regs);
rt_hw_cpu_shutdown();
}
extern struct rt_irq_desc isr_table[];
void rt_hw_trap_irq(void)
{
unsigned long intstat;
rt_uint32_t irq = 0;
rt_isr_handler_t isr_func;
void *param;
/* get the interrupt number */
irq = *(RP)(SEP6200_VIC_IRQ_VECTOR_NUM);
/* get interrupt service routine */
isr_func = isr_table[irq].handler;
param = isr_table[irq].param;
/* turn to interrupt service routine */
isr_func(irq, param);
#ifdef RT_USING_INTERRUPT_INFO
isr_table[irq].counter++;
#endif /* RT_USING_INTERRUPT_INFO */
}
void rt_hw_trap_fiq()
{
rt_kprintf("fast interrupt request\n");
}
/*@}*/