startup.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006-2011, 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. * 2010-06-25 Bernard first version
  13. * 2011-08-08 lgnq modified for Loongson LS1B
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include "board.h"
  18. #define A_K0BASE 0x80000000
  19. /**
  20. * @addtogroup Loongson LS1B
  21. */
  22. /*@{*/
  23. extern unsigned char __bss_end;
  24. extern int rt_application_init(void);
  25. extern void tlb_refill_exception(void);
  26. extern void general_exception(void);
  27. extern void irq_exception(void);
  28. /**
  29. * This function will startup RT-Thread RTOS.
  30. */
  31. void rtthread_startup(void)
  32. {
  33. /* disable interrupt first */
  34. rt_hw_interrupt_disable();
  35. /* init cache */
  36. rt_hw_cache_init();
  37. /* init hardware interrupt */
  38. rt_hw_interrupt_init();
  39. /* copy vector */
  40. memcpy((void *)A_K0BASE, tlb_refill_exception, 0x20);
  41. memcpy((void *)(A_K0BASE + 0x180), general_exception, 0x20);
  42. memcpy((void *)(A_K0BASE + 0x200), irq_exception, 0x20);
  43. /* init board */
  44. rt_hw_board_init();
  45. rt_show_version();
  46. /* init tick */
  47. rt_system_tick_init();
  48. /* init timer system */
  49. rt_system_timer_init();
  50. #ifdef RT_USING_HEAP
  51. rt_system_heap_init((void*)&__bss_end, (void*)RT_HW_HEAP_END);
  52. #endif
  53. /* init scheduler system */
  54. rt_system_scheduler_init();
  55. #ifdef RT_USING_DEVICE
  56. /* init all device */
  57. rt_device_init_all();
  58. #endif
  59. /* init application */
  60. rt_application_init();
  61. #ifdef RT_USING_FINSH
  62. /* init finsh */
  63. finsh_system_init();
  64. finsh_set_device(FINSH_DEVICE_NAME);
  65. #endif
  66. /* init idle thread */
  67. rt_thread_idle_init();
  68. /* start scheduler */
  69. rt_system_scheduler_start();
  70. /* never reach here */
  71. return ;
  72. }
  73. /*@}*/