|
发表于 2005-3-24 15:43:36
|
显示全部楼层
uCOSii -TCP/IP for s3c4510 的移植
---------------------------------------------------------------
; ?CSTARTUP
;---------------------------------------------------------------
PROGRAM ?CSTARTUP
; RTMODEL attributes ensure that
RTMODEL "__endian", ENDIAN_MODE
RTMODEL "__thumb_aware", "enabled"
RTMODEL "__cpu_mode", "*" ; CPU_MODE_NAME
RTMODEL "__code_model", "*" ; Match all code models
; Declare segment used with SFE below
#ifdef _ECPLUSPLUS
RSEG DIFUNCT(2)
#endif /* _ECPLUSPLUS */
RSEG IRQ_STACK:DATA(2)
RSEG ABT_STACK:DATA(2)
RSEG UND_STACK:DATA(2)
RSEG FIQ_STACK:DATA(2)
RSEG SVC_STACK:DATA:NOROOT(2)
RSEG CSTACK:DATA(2)
RSEG ICODE:CODE:NOROOT(2)
PUBLIC ?cstartup
#ifdef __THUMB_LIBRARY__
PUBLIC ?thumb_entry
#endif /* __THUMB_LIBRARY__ */
EXTERN __segment_init
EXTERN __low_level_init
#ifdef _ECPLUSPLUS
EXTERN __call_ctors
#endif /* _ECPLUSPLUS */
EXTERN main
EXTERN exit
EXTERN _exit
; Execution starts here.
; After a reset, the mode is ARM, Supervisor, interrupts disabled.
LTORG
CODE32
?cstartup
;清中断
LDR r1, =IntMask
LDR r0, =0xFFFFFFFF
STR r0, [r1]
IMPORT SystemSwiHandler
;设置super mode
LDR r0, =HandleSwi ; SWI exception table address
LDR r1, =SystemSwiHandler
STR r1, [r0]
swi 0xff ;/* Call SWI Vector */
;B InitRemap
;内存为sdram
LDR r0, =0x3FF0000
LDR r1, =0x83FFFFa0 ; SetValue = 0x83FFFF91
STR r1, [r0] ; Cache,WB disable
; Start_addr = 0x3FF00000
;remap
ldr r13,RemapJump
ldr r0, =SystemInitDataSDRAM
LDMIA r0, {r1-r12}
LDR r0, =0x3FF0000 + 0x3010 ; ROMCntr Offset : 0x3010
STMIA r0, {r1-r12}
mov pc,r13
;b RemapJump
RemapJump
DCD InitRemap
/************************************************************************/
/* UCOS-II 2.6x & LWIP 0.5.3 for s3c4510b */
/
/*demo演示功能:ping echo */
/* simple web server */
/* telnet echo */
/* */
/*测试方法:ping 192.168.0.2 */
/* telnet 192.168.0.2 7 */
/* http://192.168.0.2/. */
/* 上电后应看到led闪烁,表明os已经启动 */
/* */
/*已知bug:在编译的时候可能出现字节对齐问题, */
/* */
/************************************************************************/
#include <ios3c4510b.h>
//#include "includes.h"
#include "timer.h"
#include "isr.h"
#include "lwip/include/lwip/debug.h"
#include "lwip/include/lwip/opt.h"
#include "lwip/include/lwip/def.h"
#include "lwip/include/lwip/mem.h"
#include "lwip/include/lwip/memp.h"
#include "lwip/include/lwip/pbuf.h"
#include "lwip/include/lwip/sys.h"
#include "lwip/include/lwip/tcpip.h"
#include "lwip/include/lwip/api.h"
#include "netif/arp.h"
#include "netif/loopif.h"
#include "netif/cs8900.h"
#include "arch/sys_arch.h"
#include "os_api.h"
#include "httpdemo.h"
#include "tcpecho.h"
//周期10ms
#define OS_TICK ONE_SECOND/(TICKS_PER_SECOND)
#define STACKSIZE 4096
OS_STK lwip_init_stk[STACKSIZE];
OS_STK os_led_stk[STACKSIZE];
struct ethernetif *csif;
void os_led(void *i)
{
//int Task3_i;
while(1)
{
/* set LED */
__IOPDATA |= 0x01;
/* wait a short while */
OSTimeDly(150);
/* clear LED */
__IOPDATA &= ~0x01;
/* wait a short while */
OSTimeDly(15);
}
}
/*-----------------------------------------------------------------------------------*/
void led_init(void)
{
int LineNo15 = 15;
OSTaskCreate(os_led, &LineNo15, (void *)&os_led_stk[STACKSIZE - 1], (OS_LOWEST_PRIO-2));
}
/*-----------------------------------------------------------------------------------*/
//清除中断
void ClrIntStatus(void)
{
__INTMSK = 0x3fffff; // All interrupt disabled include global bit
__INTPND = 0x1fffff; // All clear pending
__INTMOD = 0x0; // All IRQ mode
}
//初始化硬件
void OSHardwareInit(void)
{
__IOPMOD = 0xff; //gpio 设置为输出
__IOPDATA = 0xff;
//设置external i/o 使用external i/o bank3
#define DSX3 (0x2 << 26)
#define LTCOS3 (0x7 << 16)
#define LTACS3 (0x6 << 19)
#define LTCOH3 (0x2 << 22)
#define LTACC3 (0x7 << 25)
__EXTDBWTH &= 0xF3FFFFFF ; //设置external i/o bank3 宽度为16
__EXTDBWTH |= DSX3 ;
__EXTACON1 = LTCOS3 | LTACS3 | LTCOH3 | LTACC3 ; //设置external i/o bank1的时序
}
/*-----------------------------------------------------------------------------------*/
void
tcpip_init_done(void *arg)
{
sys_sem_t *sem;
sem = arg;
sys_sem_signal(*sem);
}
/*-----------------------------------------------------------------------------------*/
void lwip_init_task(void * pParam)
{
struct ip_addr ipaddr, netmask, gw;
sys_sem_t sem;
#ifdef STATS
stats_init();
#endif /* STATS */
sys_init();
mem_init();
memp_init();
pbuf_init();
//PRINT("System initialized.\n");
netif_init();
//开启系统始终,多任务真正开始
os_timer_start(OS_TICK);
//全局中断使能
Enable_Int(nGLOBAL_INT); // enable timer counter interrupt
sem = sys_sem_new(0);
tcpip_init(tcpip_init_done, &sem);
sys_sem_wait(sem);
sys_sem_free(sem);
//PRINT("TCP/IP initialized.\n");
//add loop interface
IP4_ADDR(&gw, 127,0,0,1);
IP4_ADDR(&ipaddr, 127,0,0,1);
IP4_ADDR(&netmask, 255,0,0,0);
netif_add(&ipaddr, &netmask, &gw, loopif_init,
tcpip_input);
//add ne2k interface
IP4_ADDR(&gw, 210,13,59,1);
IP4_ADDR(&ipaddr, 210,13,59,3;
IP4_ADDR(&netmask, 255,255,255,0);
netif_set_default(netif_add(&ipaddr, &netmask, &gw, ethernetif_init,
tcpip_input));
//PRINT("Applications started.\n");
tcpecho_init();
http_init();
led_init();
//Enable_Int(nEXT1_INT);
/* Block for ever. */
sem = sys_sem_new(0);
sys_sem_wait(sem);
//PRINT(" never goes here, should not appear!");
}
/*-----------------------------------------------------------------------------------*/
void main(void)
{
int LineNo11 = 1;
//清楚所有中断
ClrIntStatus();
//初始化系统启动前必要的硬件
OSHardwareInit();
//初始化默认中断服务程序
os_set_default_interrupt();
//设置系统始终中断服务程序
SysSetInterrupt(nTIMER0_INT, OSTimeTick);
/* needed by uC/OS */
OSInit();
OSTimeSet(0);
/* create the start task */
OSTaskCreate(lwip_init_task, &LineNo11, &lwip_init_stk[STACKSIZE-1], 0);
/* start the operating system */
OSStart();
} |
|