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
/*
 * 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.rt-thread.org/license/LICENSE
 *
 * Change Logs:
 * Date           Author       Notes
 * 2006-08-31     Bernard      first implementation
 * 2011-12-17     nl1031	   for MicroBlaze
 */

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

M
Ming, Bai 已提交
19
#include "board.h"
20

M
Ming, Bai 已提交
21 22
#ifdef RT_USING_FINSH
#include <finsh.h>
23
extern int finsh_system_init(void);
M
Ming, Bai 已提交
24
#endif
25 26 27

extern void rt_hw_led_flash(void);

N
nongli1031@gmail.com 已提交
28

N
nongli1031@gmail.com 已提交
29
/*@{*/
M
Ming, Bai 已提交
30 31 32 33
#ifdef __CC_ARM
extern int Image$$RW_IRAM1$$ZI$$Limit;
#endif

34 35 36
#ifdef __GNUC__
extern unsigned char __bss_start;
extern unsigned char __bss_end;
M
Ming, Bai 已提交
37
#endif
38 39

extern void rt_hw_interrupt_init(void);
N
nongli1031@gmail.com 已提交
40
extern int  rt_application_init(void);
M
Ming, Bai 已提交
41 42 43
#ifdef RT_USING_DEVICE
extern rt_err_t rt_hw_serial_init(void);
#endif
44 45 46 47 48 49

/**
 * This function will startup RT-Thread RTOS.
 */
void rtthread_startup(void)
{
N
nongli1031@gmail.com 已提交
50
	/* init hardware interrupt */
M
Ming, Bai 已提交
51
	rt_hw_interrupt_init();
52

N
nongli1031@gmail.com 已提交
53 54 55 56
	/* init board */
	rt_hw_board_init();
	
	rt_show_version();
57

N
nongli1031@gmail.com 已提交
58 59
	/* init timer system */
	rt_system_timer_init();
60

M
Ming, Bai 已提交
61 62 63 64 65 66
#ifdef RT_USING_HEAP
#ifdef __CC_ARM
	rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x204000);
#elif __ICCARM__
    rt_system_heap_init(__segment_end("HEAP"), (void*)0x204000);
#else
N
nongli1031@gmail.com 已提交
67
	rt_system_heap_init((void*)&__bss_end, (void*)(&__bss_end+0x4000));
68

M
Ming, Bai 已提交
69 70
#endif
#endif
N
nongli1031@gmail.com 已提交
71

N
nongli1031@gmail.com 已提交
72 73
	/* init scheduler system */
	rt_system_scheduler_init();
74 75

#ifdef RT_USING_HOOK /* if the hook is used */
N
nongli1031@gmail.com 已提交
76 77
	/* set idle thread hook */
	rt_thread_idle_sethook(rt_hw_led_flash);
M
Ming, Bai 已提交
78
#endif
79

M
Ming, Bai 已提交
80 81 82 83
#ifdef RT_USING_DEVICE
	/* init hardware serial device */
	rt_hw_serial_init();
#endif
84

N
nongli1031@gmail.com 已提交
85 86
	/* init application */
	rt_application_init();
87 88

#ifdef RT_USING_FINSH
N
nongli1031@gmail.com 已提交
89 90 91
	/* init finsh */
	finsh_system_init();
	finsh_set_device("uart1");
92 93
#endif

N
nongli1031@gmail.com 已提交
94 95
	/* init idle thread */
	rt_thread_idle_init();
96

N
nongli1031@gmail.com 已提交
97 98
	/* start scheduler */
	rt_system_scheduler_start();
99

N
nongli1031@gmail.com 已提交
100 101
	/* never reach here */
	return ;
M
Ming, Bai 已提交
102 103 104 105 106 107 108 109 110
}

int main (void)
{
	/* invoke rtthread_startup */
	rtthread_startup();
	
	return 0;
}
111 112

/*@}*/