startup.c 1.8 KB

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