startup.c 2.1 KB
Newer Older
1 2 3
/*
 * File      : startup.c
 * This file is part of RT-Thread RTOS
4
 * COPYRIGHT (C) 2006 - 2012, RT-Thread Develop Team
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.fayfayspace.org/license/LICENSE.
 *
 * Change Logs:
 * Date           Author       Notes
 * 2006-09-15     QiuYi        the first version
 * 2006-10-10     Bernard      update to 0.2.2 version
 */

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

#include "board.h"

wuyangyong's avatar
wuyangyong 已提交
21
extern void rt_hw_console_init(void);
22
extern void rt_hw_board_init(void);
wuyangyong's avatar
wuyangyong 已提交
23 24 25 26 27
extern int  rt_application_init(void);
//extern void rt_hw_interrupt_init(void);
//extern void rt_system_timer_init(void);
//extern void rt_system_scheduler_init(void);
//extern void rt_thread_idle_init(void);
M
Ming, Bai 已提交
28 29

#ifdef RT_USING_FINSH
30
extern int finsh_system_init(void);
M
Ming, Bai 已提交
31 32
extern void finsh_set_device(const char *device);
#endif
33 34 35 36 37 38 39

extern unsigned char __bss_start[];
extern unsigned char __bss_end[];

/**
 * @addtogroup QEMU
 */
40

41 42 43
 /*@{*/

/* clear .bss */
44
void rt_hw_clear_bss(void)
45
{
46 47 48 49
    unsigned char *dst;
    dst = __bss_start;
    while (dst < __bss_end)
        *dst++ = 0;
50 51 52 53 54
}

/**
 * This function will startup RT-Thread RTOS
 */
55
void rtthread_startup(void)
56
{
57 58
    /* clear .bss */
    rt_hw_clear_bss();
wuyangyong's avatar
wuyangyong 已提交
59

60 61
    /* init hardware interrupt */
    rt_hw_interrupt_init();
wuyangyong's avatar
wuyangyong 已提交
62

63
    /* init the console */
M
Ming, Bai 已提交
64
    rt_hw_console_init();
65
    rt_console_set_device("console");
wuyangyong's avatar
wuyangyong 已提交
66

67 68
    /* init board */
    rt_hw_board_init();
wuyangyong's avatar
wuyangyong 已提交
69

70
    rt_show_version();
wuyangyong's avatar
wuyangyong 已提交
71

72 73
    /* init timer system */
    rt_system_timer_init();
wuyangyong's avatar
wuyangyong 已提交
74

75
    /* init memory system */
M
Ming, Bai 已提交
76
#ifdef RT_USING_HEAP
77 78
    /* RAM 16M */
    rt_system_heap_init((void *)&__bss_end, (void *)(1024UL*1024*8));
79
#endif
wuyangyong's avatar
wuyangyong 已提交
80

81 82
    /* init scheduler system */
    rt_system_scheduler_init();
wuyangyong's avatar
wuyangyong 已提交
83

84 85
    /* init application */
    rt_application_init();
wuyangyong's avatar
wuyangyong 已提交
86 87

#ifdef RT_USING_FINSH
88 89
    /* init finsh */
    finsh_system_init();
M
Ming, Bai 已提交
90 91
    finsh_set_device("console");
#endif
wuyangyong's avatar
wuyangyong 已提交
92

93 94
    /* init idle thread */
    rt_thread_idle_init();
wuyangyong's avatar
wuyangyong 已提交
95

96 97
    /* start scheduler */
    rt_system_scheduler_start();
98

99 100
    /* never reach here */
    return ;
101 102 103
}

/*@}*/