Merge pull request #314 from grissiom/ls1b

Ls1b
This commit is contained in:
Bernard Xiong
2014-08-19 10:48:49 +08:00
4 changed files with 137 additions and 131 deletions

View File

@@ -47,9 +47,9 @@ void rtthread_startup(void)
rt_hw_interrupt_init(); rt_hw_interrupt_init();
/* copy vector */ /* copy vector */
memcpy((void *)A_K0BASE, tlb_refill_exception, 0x20); rt_memcpy((void *)A_K0BASE, tlb_refill_exception, 0x20);
memcpy((void *)(A_K0BASE + 0x180), general_exception, 0x20); rt_memcpy((void *)(A_K0BASE + 0x180), general_exception, 0x20);
memcpy((void *)(A_K0BASE + 0x200), irq_exception, 0x20); rt_memcpy((void *)(A_K0BASE + 0x200), irq_exception, 0x20);
/* init board */ /* init board */
rt_hw_board_init(); rt_hw_board_init();
@@ -64,9 +64,6 @@ void rtthread_startup(void)
/* init scheduler system */ /* init scheduler system */
rt_system_scheduler_init(); rt_system_scheduler_init();
/* init application */
rt_application_init();
/* initialize timer */ /* initialize timer */
rt_system_timer_init(); rt_system_timer_init();
@@ -76,6 +73,9 @@ void rtthread_startup(void)
/* init idle thread */ /* init idle thread */
rt_thread_idle_init(); rt_thread_idle_init();
/* init application */
rt_application_init();
/* start scheduler */ /* start scheduler */
rt_system_scheduler_start(); rt_system_scheduler_start();

View File

@@ -71,6 +71,23 @@ void rt_hw_board_init(void)
rt_kprintf("current sr: 0x%08x\n", read_c0_status()); rt_kprintf("current sr: 0x%08x\n", read_c0_status());
} }
#define __raw_out_put(unr) \
while (*ptr) \
{ \
if (*ptr == '\n') \
{ \
/* FIFO status, contain valid data */ \
while (!(UART_LSR(UART##unr##_BASE) & (UARTLSR_TE | UARTLSR_TFE))); \
/* write data */ \
UART_DAT(UART##unr##_BASE) = '\r'; \
} \
/* FIFO status, contain valid data */ \
while (!(UART_LSR(UART##unr##_BASE) & (UARTLSR_TE | UARTLSR_TFE))); \
/* write data */ \
UART_DAT(UART##unr##_BASE) = *ptr; \
ptr ++; \
}
/* UART line status register value */ /* UART line status register value */
#define UARTLSR_ERROR (1 << 7) #define UARTLSR_ERROR (1 << 7)
#define UARTLSR_TE (1 << 6) #define UARTLSR_TE (1 << 6)
@@ -82,24 +99,13 @@ void rt_hw_board_init(void)
#define UARTLSR_DR (1 << 0) #define UARTLSR_DR (1 << 0)
void rt_hw_console_output(const char *ptr) void rt_hw_console_output(const char *ptr)
{ {
/* stream mode */ #if defined(RT_USING_UART0)
while (*ptr) __raw_out_put(0);
{ #elif defined(RT_USING_UART1)
if (*ptr == '\n') __raw_out_put(1);
{ #elif defined(RT_USING_UART3)
/* FIFO status, contain valid data */ __raw_out_put(3);
while (!(UART_LSR(UART0_BASE) & (UARTLSR_TE | UARTLSR_TFE))); #endif
/* write data */
UART_DAT(UART0_BASE) = '\r';
}
/* FIFO status, contain valid data */
while (!(UART_LSR(UART0_BASE) & (UARTLSR_TE | UARTLSR_TFE)));
/* write data */
UART_DAT(UART0_BASE) = *ptr;
ptr ++;
}
} }
/*@}*/ /*@}*/

View File

@@ -256,6 +256,9 @@ void rt_hw_uart_init(void)
#elif defined(RT_USING_UART1) #elif defined(RT_USING_UART1)
uart->hw_base = UART1_BASE; uart->hw_base = UART1_BASE;
uart->irq = LS1B_UART1_IRQ; uart->irq = LS1B_UART1_IRQ;
#elif defined(RT_USING_UART3)
uart->hw_base = UART3_BASE;
uart->irq = LS1B_UART3_IRQ;
#endif #endif
/* device interface */ /* device interface */

View File

@@ -104,15 +104,12 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
{ {
old_handler = irq_handle_table[vector].handler; old_handler = irq_handle_table[vector].handler;
if (handler != RT_NULL)
{
#ifdef RT_USING_INTERRUPT_INFO #ifdef RT_USING_INTERRUPT_INFO
rt_strncpy(irq_handle_table[vector].name, name, RT_NAME_MAX); rt_strncpy(irq_handle_table[vector].name, name, RT_NAME_MAX);
#endif /* RT_USING_INTERRUPT_INFO */ #endif /* RT_USING_INTERRUPT_INFO */
irq_handle_table[vector].handler = handler; irq_handle_table[vector].handler = handler;
irq_handle_table[vector].param = param; irq_handle_table[vector].param = param;
} }
}
return old_handler; return old_handler;
} }
@@ -159,7 +156,7 @@ void rt_interrupt_dispatch(void *ptreg)
param = irq_handle_table[irq].param; param = irq_handle_table[irq].param;
/* do interrupt */ /* do interrupt */
(*irq_func)(irq, param); irq_func(irq, param);
#ifdef RT_USING_INTERRUPT_INFO #ifdef RT_USING_INTERRUPT_INFO
irq_handle_table[irq].counter++; irq_handle_table[irq].counter++;