application.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * File : application.c
  3. * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * Change Logs:
  20. * Date Author Notes
  21. * 2017-08-08 Yang the first version
  22. */
  23. #include <rtthread.h>
  24. #ifdef RT_USING_FINSH
  25. #include <shell.h>
  26. #include <finsh.h>
  27. #endif
  28. /* thread phase init */
  29. void rt_init_thread_entry(void *parameter)
  30. {
  31. /* Initialization RT-Thread Components */
  32. #ifdef RT_USING_COMPONENTS_INIT
  33. rt_components_init();
  34. #elif defined(RT_USING_FINSH)
  35. finsh_system_init();
  36. #endif
  37. }
  38. void build_dump(void)
  39. {
  40. #if defined(__CC_ARM)
  41. rt_kprintf("using MDK\n");
  42. #elif defined(__IAR_SYSTEMS_ICC__)
  43. rt_kprintf("using IAR\n");
  44. #elif defined(__GNUC__)
  45. rt_kprintf("using GCC\n");
  46. #else
  47. rt_kprintf("unkown Compiler\n");
  48. #endif
  49. }
  50. void link_dump(void)
  51. {
  52. #ifdef __GNUC__
  53. extern unsigned int _sdata;
  54. extern unsigned int _edata;
  55. extern unsigned int _sidata;
  56. extern unsigned int _sbss;
  57. extern unsigned int _ebss;
  58. #define DUMP_VAR(__VAR) \
  59. rt_kprintf("%-20s %p\n", #__VAR, &__VAR)
  60. DUMP_VAR(_sdata);
  61. DUMP_VAR(_edata);
  62. DUMP_VAR(_sidata);
  63. DUMP_VAR(_sbss);
  64. DUMP_VAR(_ebss);
  65. #endif
  66. }
  67. int rt_application_init(void)
  68. {
  69. rt_thread_t tid;
  70. build_dump();
  71. link_dump();
  72. tid = rt_thread_create("init",
  73. rt_init_thread_entry, RT_NULL,
  74. 2048, RT_THREAD_PRIORITY_MAX / 3, 20);
  75. if (tid != RT_NULL) rt_thread_startup(tid);
  76. return 0;
  77. }