startup.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006-2012, 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. /* show version */
  46. rt_show_version();
  47. #ifdef RT_USING_HEAP
  48. rt_system_heap_init((void*)&__bss_end, (void*)RT_HW_HEAP_END);
  49. #endif
  50. /* init scheduler system */
  51. rt_system_scheduler_init();
  52. #ifdef RT_USING_DEVICE
  53. /* init all device */
  54. rt_device_init_all();
  55. #endif
  56. /* init application */
  57. rt_application_init();
  58. /* initialize timer */
  59. rt_system_timer_init();
  60. /* initialize timer thread */
  61. rt_system_timer_thread_init();
  62. /* init idle thread */
  63. rt_thread_idle_init();
  64. /* start scheduler */
  65. rt_system_scheduler_start();
  66. /* never reach here */
  67. return;
  68. }
  69. /*@}*/