startup.c 2.0 KB
Newer Older
1
/*
2
 * Copyright (c) 2006-2021, RT-Thread Development Team
3
 *
4
 * SPDX-License-Identifier: Apache-2.0
5 6 7 8
 *
 * Change Logs:
 * Date           Author       Notes
 * 2006-08-31     Bernard      first implementation
9
 * 2011-12-17     nl1031       for MicroBlaze
10 11 12 13 14
 */

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

M
Ming, Bai 已提交
15
#include "board.h"
16

M
Ming, Bai 已提交
17 18
#ifdef RT_USING_FINSH
#include <finsh.h>
19
extern int finsh_system_init(void);
M
Ming, Bai 已提交
20
#endif
21 22 23

extern void rt_hw_led_flash(void);

N
nongli1031@gmail.com 已提交
24

N
nongli1031@gmail.com 已提交
25
/*@{*/
M
Ming, Bai 已提交
26 27 28 29
#ifdef __CC_ARM
extern int Image$$RW_IRAM1$$ZI$$Limit;
#endif

30 31 32
#ifdef __GNUC__
extern unsigned char __bss_start;
extern unsigned char __bss_end;
M
Ming, Bai 已提交
33
#endif
34 35

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

/**
 * This function will startup RT-Thread RTOS.
 */
void rtthread_startup(void)
{
46 47
    /* init hardware interrupt */
    rt_hw_interrupt_init();
48

49 50
    /* init board */
    rt_hw_board_init();
51

52 53 54 55
    rt_show_version();

    /* init timer system */
    rt_system_timer_init();
56

M
Ming, Bai 已提交
57 58
#ifdef RT_USING_HEAP
#ifdef __CC_ARM
59
    rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x204000);
M
Ming, Bai 已提交
60 61 62
#elif __ICCARM__
    rt_system_heap_init(__segment_end("HEAP"), (void*)0x204000);
#else
63
    rt_system_heap_init((void*)&__bss_end, (void*)(&__bss_end+0x4000));
64

M
Ming, Bai 已提交
65 66
#endif
#endif
N
nongli1031@gmail.com 已提交
67

68 69
    /* init scheduler system */
    rt_system_scheduler_init();
70 71

#ifdef RT_USING_HOOK /* if the hook is used */
72 73
    /* set idle thread hook */
    rt_thread_idle_sethook(rt_hw_led_flash);
M
Ming, Bai 已提交
74
#endif
75

M
Ming, Bai 已提交
76
#ifdef RT_USING_DEVICE
77 78
    /* init hardware serial device */
    rt_hw_serial_init();
M
Ming, Bai 已提交
79
#endif
80

81 82
    /* init application */
    rt_application_init();
83 84

#ifdef RT_USING_FINSH
85 86 87
    /* init finsh */
    finsh_system_init();
    finsh_set_device("uart1");
88 89
#endif

90 91
    /* init idle thread */
    rt_thread_idle_init();
92

93 94
    /* start scheduler */
    rt_system_scheduler_start();
95

96 97
    /* never reach here */
    return ;
M
Ming, Bai 已提交
98 99 100 101
}

int main (void)
{
102 103 104 105
    /* invoke rtthread_startup */
    rtthread_startup();

    return 0;
M
Ming, Bai 已提交
106
}
107 108

/*@}*/