startup.c 1.9 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. * 2010-06-25 Bernard first version
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include <cache.h>
  17. #include "board.h"
  18. /**
  19. * @addtogroup Loongson SoC3210
  20. */
  21. /*@{*/
  22. extern unsigned char __bss_start;
  23. extern unsigned char __bss_end;
  24. extern int rt_application_init(void);
  25. void dump_mem(const unsigned char* addr)
  26. {
  27. int size;
  28. rt_kprintf("---- memory: 0x%08x ----\n", addr);
  29. for (size = 0; size < 32 * 4; size ++)
  30. {
  31. rt_kprintf("%02x ", (*addr) & 0xff);
  32. addr ++;
  33. if ((size + 1) % 16 == 0)
  34. rt_kprintf("\n");
  35. }
  36. rt_kprintf("\n");
  37. }
  38. /**
  39. * This function will startup RT-Thread RTOS.
  40. */
  41. void rtthread_startup(void)
  42. {
  43. /* init cache */
  44. rt_hw_cache_init();
  45. /* init hardware interrupt */
  46. rt_hw_interrupt_init();
  47. /*
  48. dump_mem((rt_uint8_t*)0x80000000);
  49. dump_mem((rt_uint8_t*)0x80000100);
  50. dump_mem((rt_uint8_t*)0x80000180);
  51. dump_mem((rt_uint8_t*)0x80000200);
  52. */
  53. /* init board */
  54. rt_hw_board_init();
  55. rt_show_version();
  56. /* init tick */
  57. rt_system_tick_init();
  58. /* init timer system */
  59. rt_system_timer_init();
  60. #ifdef RT_USING_HEAP
  61. rt_system_heap_init((void*)&__bss_end, (void*)RT_HW_HEAP_END);
  62. #endif
  63. /* init scheduler system */
  64. rt_system_scheduler_init();
  65. #ifdef RT_USING_DEVICE
  66. /* init all device */
  67. rt_device_init_all();
  68. #endif
  69. /* init application */
  70. rt_application_init();
  71. #ifdef RT_USING_FINSH
  72. /* init finsh */
  73. finsh_system_init();
  74. finsh_set_device(FINSH_DEVICE_NAME);
  75. #endif
  76. /* init idle thread */
  77. rt_thread_idle_init();
  78. /* start scheduler */
  79. rt_system_scheduler_start();
  80. /* never reach here */
  81. return ;
  82. }
  83. /*@}*/