startup.c 2.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * File      : startup.c
 * This file is part of RT-Thread RTOS
 * COPYRIGHT (C) 2006, 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.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 28 29 30 31 32
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);

#ifdef RT_USING_FINSH
extern void finsh_system_init(void);
extern void finsh_set_device(const char* device);
#endif
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

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

/**
 * @addtogroup QEMU
 */
 /*@{*/

/* clear .bss */
void rt_hw_clear_bss()
{
	unsigned char *dst;
	dst = __bss_start;
	while(dst < __bss_end) *dst++ = 0;
}

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

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

61
	/* init the console */
wuyangyong's avatar
wuyangyong 已提交
62 63 64
	rt_hw_console_init();
	rt_console_set_device("console");

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

68
	rt_show_version();
wuyangyong's avatar
wuyangyong 已提交
69

70
	/* init tick */
wuyangyong's avatar
wuyangyong 已提交
71 72
	rt_system_tick_init();

73 74
	/* init kernel object */
	rt_system_object_init();
wuyangyong's avatar
wuyangyong 已提交
75

76 77
	/* init timer system */
	rt_system_timer_init();
wuyangyong's avatar
wuyangyong 已提交
78

79
	/* init memory system */
wuyangyong's avatar
wuyangyong 已提交
80 81
#ifdef RT_USING_HEAP
    rt_system_heap_init((void*)&__bss_end, (void*)(1024UL*1024*8)); /* RAM 16M */
82
#endif
wuyangyong's avatar
wuyangyong 已提交
83

84 85
	/* init scheduler system */
	rt_system_scheduler_init();
wuyangyong's avatar
wuyangyong 已提交
86

87 88
	/* init application */
	rt_application_init();
wuyangyong's avatar
wuyangyong 已提交
89 90

#ifdef RT_USING_FINSH
91 92
	/* init finsh */
	finsh_system_init();
wuyangyong's avatar
wuyangyong 已提交
93 94 95
	finsh_set_device("console");
#endif

96 97
	/* init idle thread */
	rt_thread_idle_init();
wuyangyong's avatar
wuyangyong 已提交
98

99 100
	/* start scheduler */
	rt_system_scheduler_start();
wuyangyong's avatar
wuyangyong 已提交
101

102 103 104 105 106 107
	/* never reach here */
	return ;

}

/*@}*/