startup.c 1.9 KB
Newer Older
D
dzzxzz@gmail.com 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
/*
 * File      : startup.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://www.rt-thread.org/license/LICENSE
 *
 * Change Logs:
 * Date           Author       Notes
 * 2010-06-25     Bernard      first version
 * 2011-08-08     lgnq         modified for Loongson LS1B
 */

#include <rthw.h>
#include <rtthread.h>

#include "board.h"
#define A_K0BASE		0x80000000

/**
 * @addtogroup Loongson LS1B
 */

/*@{*/

extern unsigned char __bss_end;

extern int rt_application_init(void);

extern void tlb_refill_exception(void);
extern void general_exception(void);
extern void irq_exception(void);
35 36 37
extern void rt_hw_cache_init(void);
extern void invalidate_writeback_dcache_all(void);
extern void invalidate_icache_all(void);
D
dzzxzz@gmail.com 已提交
38 39 40 41 42 43

/**
 * This function will startup RT-Thread RTOS.
 */
void rtthread_startup(void)
{
G
Grissiom 已提交
44 45
    /* disable interrupt first */
    rt_hw_interrupt_disable();
D
dzzxzz@gmail.com 已提交
46

G
Grissiom 已提交
47 48 49 50
    /* init cache */
    rt_hw_cache_init();
    /* init hardware interrupt */
    rt_hw_interrupt_init();
D
dzzxzz@gmail.com 已提交
51

G
Grissiom 已提交
52 53 54 55
    /* copy vector */
    rt_memcpy((void *)A_K0BASE, tlb_refill_exception, 0x20);
    rt_memcpy((void *)(A_K0BASE + 0x180), general_exception, 0x20);
    rt_memcpy((void *)(A_K0BASE + 0x200), irq_exception, 0x20);
D
dzzxzz@gmail.com 已提交
56

G
Grissiom 已提交
57 58
    /* init board */
    rt_hw_board_init();
D
dzzxzz@gmail.com 已提交
59

G
Grissiom 已提交
60 61
    /* show version */
    rt_show_version();
D
dzzxzz@gmail.com 已提交
62 63

#ifdef RT_USING_HEAP
G
Grissiom 已提交
64
    rt_system_heap_init((void*)&__bss_end, (void*)RT_HW_HEAP_END);
D
dzzxzz@gmail.com 已提交
65 66
#endif

G
Grissiom 已提交
67 68
    /* init scheduler system */
    rt_system_scheduler_init();
D
dzzxzz@gmail.com 已提交
69

G
Grissiom 已提交
70 71 72
    /* initialize timer */
    rt_system_timer_init();

G
Grissiom 已提交
73 74
    /* initialize timer thread */
    rt_system_timer_thread_init();
D
dzzxzz@gmail.com 已提交
75

G
Grissiom 已提交
76 77
    /* init idle thread */
    rt_thread_idle_init();
D
dzzxzz@gmail.com 已提交
78

G
Grissiom 已提交
79 80
    /* init application */
    rt_application_init();
81

G
Grissiom 已提交
82 83
    /* start scheduler */
    rt_system_scheduler_start();
D
dzzxzz@gmail.com 已提交
84

G
Grissiom 已提交
85 86
    /* never reach here */
    return;
D
dzzxzz@gmail.com 已提交
87 88 89
}

/*@}*/