startup.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-02-16 Bernard first implementation
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #ifdef RT_USING_FINSH
  17. #include <finsh.h>
  18. #endif
  19. #include "board.h"
  20. #ifdef RT_USING_LWIP
  21. #include <netif/ethernetif.h>
  22. #include "dm9000.h"
  23. #endif
  24. #ifdef RT_USING_DFS
  25. #include "sd.h"
  26. #endif
  27. /**
  28. * @addtogroup lpc2148
  29. */
  30. /*@{*/
  31. extern int rt_application_init(void);
  32. extern void rt_show_version(void);
  33. #ifdef RT_USING_DEVICE
  34. extern rt_err_t rt_hw_serial_init(void);
  35. #endif
  36. #ifdef __CC_ARM
  37. extern int Image$$RW_IRAM1$$ZI$$Limit;
  38. #else
  39. extern int __bss_end;
  40. #endif
  41. /**
  42. * This function will startup RT-Thread RTOS.
  43. */
  44. void rtthread_startup(void)
  45. {
  46. /* init hardware interrupt */
  47. rt_hw_interrupt_init();
  48. /* init board */
  49. rt_hw_board_init();
  50. /* init tick */
  51. rt_system_tick_init();
  52. /* init kernel object */
  53. rt_system_object_init();
  54. rt_show_version();
  55. /* init timer system */
  56. rt_system_timer_init();
  57. #ifdef RT_USING_HEAP
  58. #ifdef __CC_ARM
  59. rt_system_heap_init((void *)&Image$$RW_IRAM1$$ZI$$Limit, (void *)0x40008000);
  60. #else
  61. /* init memory system */
  62. rt_system_heap_init((void *)&__bss_end, (void *)0x40008000);
  63. #endif
  64. #endif
  65. /* init scheduler system */
  66. rt_system_scheduler_init();
  67. /* init application */
  68. rt_application_init();
  69. /* init idle thread */
  70. rt_thread_idle_init();
  71. /* start scheduler */
  72. rt_system_scheduler_start();
  73. /* never reach here */
  74. return ;
  75. }
  76. int main(void)
  77. {
  78. /* invoke rtthread_startup */
  79. rtthread_startup();
  80. return 0;
  81. }
  82. /*@}*/