From 2cac413f95dc1a0034ccd31b0fc3910f397f6475 Mon Sep 17 00:00:00 2001 From: qiuyiuestc Date: Sun, 29 Nov 2009 14:35:37 +0000 Subject: [PATCH] File system and net for LM3S platform are available. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@181 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- libcpu/arm/lm3s/fault.c | 34 +++++++++++++++++++++++++++++++++ libcpu/arm/lm3s/fault_rvds.S | 33 ++++++++++++++++++++++++++++++++ libcpu/arm/lm3s/start_rvds.S | 8 +++++--- net/lwip/src/lwipopts.h | 6 ++++-- net/lwip/src/netif/ethernetif.c | 2 +- 5 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 libcpu/arm/lm3s/fault.c create mode 100644 libcpu/arm/lm3s/fault_rvds.S diff --git a/libcpu/arm/lm3s/fault.c b/libcpu/arm/lm3s/fault.c new file mode 100644 index 0000000000..c3cf747018 --- /dev/null +++ b/libcpu/arm/lm3s/fault.c @@ -0,0 +1,34 @@ +#include + +struct stack_contex +{ + rt_uint32_t r0; + rt_uint32_t r1; + rt_uint32_t r2; + rt_uint32_t r3; + rt_uint32_t r12; + rt_uint32_t lr; + rt_uint32_t pc; + rt_uint32_t psr; +}; + +extern void rt_hw_interrupt_thread_switch(void); +extern void list_thread(void); +extern rt_thread_t rt_current_thread; +void rt_hw_hard_fault_exception(struct stack_contex* contex) +{ + rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name); + rt_kprintf("psr: 0x%08x\n", contex->psr); + rt_kprintf(" pc: 0x%08x\n", contex->pc); + rt_kprintf(" lr: 0x%08x\n", contex->lr); + rt_kprintf("r12: 0x%08x\n", contex->r12); + rt_kprintf("r03: 0x%08x\n", contex->r3); + rt_kprintf("r02: 0x%08x\n", contex->r2); + rt_kprintf("r01: 0x%08x\n", contex->r1); + rt_kprintf("r00: 0x%08x\n", contex->r0); + +#ifdef RT_USING_FINSH + list_thread(); +#endif + while (1); +} diff --git a/libcpu/arm/lm3s/fault_rvds.S b/libcpu/arm/lm3s/fault_rvds.S new file mode 100644 index 0000000000..19da38da91 --- /dev/null +++ b/libcpu/arm/lm3s/fault_rvds.S @@ -0,0 +1,33 @@ +;/* +; * 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://www.rt-thread.org/license/LICENSE +; * +; * Change Logs: +; * Date Author Notes +; * 2009-01-17 Bernard first version +; */ + + AREA |.text|, CODE, READONLY, ALIGN=2 + THUMB + REQUIRE8 + PRESERVE8 + + IMPORT rt_hw_hard_fault_exception + +rt_hw_hard_fault PROC + EXPORT rt_hw_hard_fault + + ; get current context + MRS r0, psp ; get fault thread stack pointer + BL rt_hw_hard_fault_exception + + ORR lr, lr, #0x04 + BX lr + ENDP + + END \ No newline at end of file diff --git a/libcpu/arm/lm3s/start_rvds.S b/libcpu/arm/lm3s/start_rvds.S index ad5295faab..994d95f7d4 100644 --- a/libcpu/arm/lm3s/start_rvds.S +++ b/libcpu/arm/lm3s/start_rvds.S @@ -65,6 +65,8 @@ __heap_limit IMPORT rt_hw_pend_sv IMPORT rt_hw_timer_handler IMPORT rt_hw_uart_isr_1 + IMPORT luminaryif_isr + IMPORT rt_hw_hard_fault ;****************************************************************************** ; @@ -91,7 +93,7 @@ __Vectors DCD StackMem + Stack ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NmiSR ; NMI Handler - DCD FaultISR ; Hard Fault Handler + DCD rt_hw_hard_fault ; Hard Fault Handler DCD IntDefaultHandler ; MPU Fault Handler DCD IntDefaultHandler ; Bus Fault Handler DCD IntDefaultHandler ; Usage Fault Handler @@ -146,8 +148,8 @@ __Vectors DCD IntDefaultHandler ; CAN0 DCD IntDefaultHandler ; CAN1 DCD IntDefaultHandler ; CAN2 - DCD IntDefaultHandler ; Ethernet - DCD IntDefaultHandler ; Hibernate + DCD luminaryif_isr ; Ethernet + DCD IntDefaultHandler ; Hibernate DCD IntDefaultHandler ; USB0 DCD IntDefaultHandler ; PWM Generator 3 DCD IntDefaultHandler ; uDMA Software Transfer diff --git a/net/lwip/src/lwipopts.h b/net/lwip/src/lwipopts.h index b24b4b0463..c17573bb78 100644 --- a/net/lwip/src/lwipopts.h +++ b/net/lwip/src/lwipopts.h @@ -63,8 +63,8 @@ #define AUTOIP_DEBUG LWIP_DBG_OFF #define DHCP_DEBUG LWIP_DBG_OFF #define IP_DEBUG LWIP_DBG_OFF -#define IP_REASS_DEBUG LWIP_DBG_ON -#define ICMP_DEBUG LWIP_DBG_ON +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF #define IGMP_DEBUG LWIP_DBG_OFF #define UDP_DEBUG LWIP_DBG_OFF #define TCP_DEBUG LWIP_DBG_OFF @@ -142,6 +142,8 @@ link level header. */ #define PBUF_LINK_HLEN 16 +#define ETH_PAD_SIZE 2 // default is 0 + /** SYS_LIGHTWEIGHT_PROT * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection * for certain critical regions during buffer allocation, deallocation and memory diff --git a/net/lwip/src/netif/ethernetif.c b/net/lwip/src/netif/ethernetif.c index 4dfc06d4b2..9eeee00c6c 100644 --- a/net/lwip/src/netif/ethernetif.c +++ b/net/lwip/src/netif/ethernetif.c @@ -63,7 +63,7 @@ err_t eth_input(struct pbuf *p, struct netif *inp) { case ETHTYPE_IP: etharp_ip_input(inp, p); - pbuf_header(p, -14); + pbuf_header(p, -((rt_int16_t)sizeof(struct eth_hdr))); tcpip_input(p, inp); break;