startup.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. * 2015-07-06 chinesebear modified for Loongson LS1C
  15. */
  16. #include <rthw.h>
  17. #include <rtthread.h>
  18. #include "board.h"
  19. #define A_K0BASE 0x80000000
  20. /**
  21. * @addtogroup Loongson LS1B
  22. */
  23. /*@{*/
  24. extern unsigned char __bss_end;
  25. extern int rt_application_init(void);
  26. extern void tlb_refill_exception(void);
  27. extern void general_exception(void);
  28. extern void irq_exception(void);
  29. /**
  30. * This function will startup RT-Thread RTOS.
  31. */
  32. void rtthread_startup(void)
  33. {
  34. /* disable interrupt first */
  35. rt_hw_interrupt_disable();
  36. /* init cache */
  37. rt_hw_cache_init();
  38. /* init hardware interrupt */
  39. rt_hw_interrupt_init();
  40. /* copy vector */
  41. rt_memcpy((void *)A_K0BASE, tlb_refill_exception, 0x20);
  42. rt_memcpy((void *)(A_K0BASE + 0x180), general_exception, 0x20);
  43. rt_memcpy((void *)(A_K0BASE + 0x200), irq_exception, 0x20);
  44. /* init board */
  45. rt_hw_board_init();
  46. /* show version */
  47. rt_show_version();
  48. #ifdef RT_USING_HEAP
  49. rt_system_heap_init((void*)&__bss_end, (void*)RT_HW_HEAP_END);
  50. #endif
  51. /* init scheduler system */
  52. rt_system_scheduler_init();
  53. /* initialize timer */
  54. rt_system_timer_init();
  55. /* initialize timer thread */
  56. rt_system_timer_thread_init();
  57. /* init idle thread */
  58. rt_thread_idle_init();
  59. /* init application */
  60. rt_application_init();
  61. /* start scheduler */
  62. rt_system_scheduler_start();
  63. /* never reach here */
  64. return;
  65. }
  66. /*@}*/