rtm.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /*
  2. * File : rtm.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2010, 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-04-12 yi.qiu first version
  13. */
  14. #include <rtthread.h>
  15. #include <assert.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include <stdio.h>
  19. /* some buildin kernel symbol */
  20. #ifdef RT_USING_MODULE
  21. #include <rtm.h>
  22. /*
  23. * thread interface symbol
  24. */
  25. RTM_EXPORT(rt_thread_init);
  26. RTM_EXPORT(rt_thread_detach);
  27. RTM_EXPORT(rt_thread_create);
  28. RTM_EXPORT(rt_thread_self);
  29. RTM_EXPORT(rt_thread_find);
  30. RTM_EXPORT(rt_thread_startup);
  31. RTM_EXPORT(rt_thread_delete);
  32. RTM_EXPORT(rt_thread_yield);
  33. RTM_EXPORT(rt_thread_delay);
  34. RTM_EXPORT(rt_thread_control);
  35. RTM_EXPORT(rt_thread_suspend);
  36. RTM_EXPORT(rt_thread_resume);
  37. RTM_EXPORT(rt_thread_timeout);
  38. #ifdef RT_USING_SEMAPHORE
  39. /*
  40. * semaphore interface symbol
  41. */
  42. RTM_EXPORT(rt_sem_init);
  43. RTM_EXPORT(rt_sem_detach);
  44. RTM_EXPORT(rt_sem_create);
  45. RTM_EXPORT(rt_sem_delete);
  46. RTM_EXPORT(rt_sem_take);
  47. RTM_EXPORT(rt_sem_trytake);
  48. RTM_EXPORT(rt_sem_release);
  49. RTM_EXPORT(rt_sem_control);
  50. #endif
  51. #ifdef RT_USING_MUTEX
  52. /*
  53. * mutex interface symbol
  54. */
  55. RTM_EXPORT(rt_mutex_init);
  56. RTM_EXPORT(rt_mutex_detach);
  57. RTM_EXPORT(rt_mutex_create);
  58. RTM_EXPORT(rt_mutex_delete);
  59. RTM_EXPORT(rt_mutex_take);
  60. RTM_EXPORT(rt_mutex_release);
  61. RTM_EXPORT(rt_mutex_control);
  62. #endif
  63. #ifdef RT_USING_EVENT
  64. /*
  65. * event interface symbol
  66. */
  67. RTM_EXPORT(rt_event_init);
  68. RTM_EXPORT(rt_event_detach);
  69. RTM_EXPORT(rt_event_create);
  70. RTM_EXPORT(rt_event_delete);
  71. RTM_EXPORT(rt_event_send);
  72. RTM_EXPORT(rt_event_recv);
  73. RTM_EXPORT(rt_event_control);
  74. #endif
  75. #ifdef RT_USING_MAILBOX
  76. /*
  77. * mailbox interface symbol
  78. */
  79. RTM_EXPORT(rt_mb_init);
  80. RTM_EXPORT(rt_mb_detach);
  81. RTM_EXPORT(rt_mb_create);
  82. RTM_EXPORT(rt_mb_delete);
  83. RTM_EXPORT(rt_mb_send);
  84. RTM_EXPORT(rt_mb_recv);
  85. RTM_EXPORT(rt_mb_control);
  86. #endif
  87. #ifdef RT_USING_MESSAGEQUEUE
  88. /*
  89. * message queue interface symbol
  90. */
  91. RTM_EXPORT(rt_mq_init);
  92. RTM_EXPORT(rt_mq_detach);
  93. RTM_EXPORT(rt_mq_create);
  94. RTM_EXPORT(rt_mq_delete);
  95. RTM_EXPORT(rt_mq_send);
  96. RTM_EXPORT(rt_mq_urgent);
  97. RTM_EXPORT(rt_mq_recv);
  98. RTM_EXPORT(rt_mq_control);
  99. #endif
  100. #ifdef RT_USING_MEMPOOL
  101. /*
  102. * memory pool interface symbol
  103. */
  104. RTM_EXPORT(rt_mp_init);
  105. RTM_EXPORT(rt_mp_detach);
  106. RTM_EXPORT(rt_mp_create);
  107. RTM_EXPORT(rt_mp_delete);
  108. RTM_EXPORT(rt_mp_alloc);
  109. RTM_EXPORT(rt_mp_free);
  110. #endif
  111. #ifdef RT_USING_HEAP
  112. /*
  113. * heap memory interface symbol
  114. */
  115. RTM_EXPORT(rt_malloc);
  116. RTM_EXPORT(rt_free);
  117. RTM_EXPORT(rt_realloc);
  118. RTM_EXPORT(rt_calloc);
  119. #endif
  120. /*
  121. * clock & timer interface symbol
  122. */
  123. RTM_EXPORT(rt_tick_get);
  124. RTM_EXPORT(rt_tick_from_millisecond);
  125. RTM_EXPORT(rt_system_timer_init);
  126. RTM_EXPORT(rt_system_timer_thread_init);
  127. RTM_EXPORT(rt_timer_init);
  128. RTM_EXPORT(rt_timer_detach);
  129. RTM_EXPORT(rt_timer_create);
  130. RTM_EXPORT(rt_timer_delete);
  131. RTM_EXPORT(rt_timer_start);
  132. RTM_EXPORT(rt_timer_stop);
  133. RTM_EXPORT(rt_timer_control);
  134. /*
  135. * kservice interface symbol
  136. */
  137. RTM_EXPORT(rt_memcpy)
  138. RTM_EXPORT(rt_memcmp)
  139. RTM_EXPORT(rt_memset)
  140. RTM_EXPORT(rt_kprintf)
  141. RTM_EXPORT(rt_sprintf)
  142. RTM_EXPORT(rt_strstr)
  143. RTM_EXPORT(rt_snprintf)
  144. /*
  145. * misc interface symbol
  146. */
  147. extern int __aeabi_idiv;
  148. extern int __aeabi_ddiv;
  149. extern int __aeabi_dmul;
  150. extern int __aeabi_i2d;
  151. extern int __aeabi_uidiv;
  152. extern int __aeabi_uidivmod;
  153. extern int __aeabi_idivmod;
  154. extern int __aeabi_d2iz;
  155. RTM_EXPORT(__aeabi_ddiv)
  156. RTM_EXPORT(__aeabi_dmul)
  157. RTM_EXPORT(__aeabi_i2d)
  158. RTM_EXPORT(__aeabi_uidiv)
  159. RTM_EXPORT(__aeabi_idiv)
  160. RTM_EXPORT(__aeabi_idivmod)
  161. RTM_EXPORT(__aeabi_uidivmod)
  162. RTM_EXPORT(__aeabi_d2iz)
  163. RTM_EXPORT(strcmp)
  164. RTM_EXPORT(strcpy)
  165. RTM_EXPORT(strlen)
  166. RTM_EXPORT(rand)
  167. RTM_EXPORT(memset)
  168. RTM_EXPORT(memcpy)
  169. #ifdef RT_USING_NEWLIB
  170. #include <unistd.h>
  171. RTM_EXPORT(snprintf)
  172. RTM_EXPORT(access)
  173. RTM_EXPORT(__assert_func)
  174. #include <time.h>
  175. RTM_EXPORT(localtime)
  176. RTM_EXPORT(time)
  177. #endif
  178. #ifdef RT_USING_DFS
  179. #include <dfs_posix.h>
  180. RTM_EXPORT(open)
  181. RTM_EXPORT(close)
  182. RTM_EXPORT(read)
  183. RTM_EXPORT(write)
  184. RTM_EXPORT(stat)
  185. #endif
  186. #ifdef RT_USING_RTGUI
  187. /* FIX ME , should be removed from here */
  188. #include <rtgui/dc.h>
  189. #include <rtgui/rtgui_server.h>
  190. #include <rtgui/rtgui_system.h>
  191. #include <rtgui/widgets/view.h>
  192. #include <rtgui/widgets/workbench.h>
  193. #include <rtgui/widgets/widget.h>
  194. #include <rtgui/widgets/button.h>
  195. #include <rtgui/widgets/list_view.h>
  196. #include <rtgui/widgets/filelist_view.h>
  197. RTM_EXPORT(rtgui_view_show)
  198. RTM_EXPORT(rtgui_view_create)
  199. RTM_EXPORT(rtgui_view_destroy)
  200. RTM_EXPORT(rtgui_view_event_handler)
  201. RTM_EXPORT(rtgui_dc_draw_text)
  202. RTM_EXPORT(rtgui_dc_begin_drawing)
  203. RTM_EXPORT(rtgui_dc_end_drawing)
  204. RTM_EXPORT(rtgui_workbench_event_loop)
  205. RTM_EXPORT(rtgui_workbench_event_handler)
  206. RTM_EXPORT(rtgui_workbench_add_view)
  207. RTM_EXPORT(rtgui_workbench_create)
  208. RTM_EXPORT(rtgui_workbench_destroy)
  209. RTM_EXPORT(rtgui_workbench_close)
  210. RTM_EXPORT(rtgui_timer_start)
  211. RTM_EXPORT(rtgui_timer_create)
  212. RTM_EXPORT(rtgui_timer_destory)
  213. RTM_EXPORT(rtgui_timer_stop)
  214. RTM_EXPORT(rtgui_thread_register)
  215. RTM_EXPORT(rtgui_thread_deregister)
  216. RTM_EXPORT(rtgui_widget_focus)
  217. RTM_EXPORT(rtgui_widget_set_event_handler)
  218. RTM_EXPORT(rtgui_widget_rect_to_device)
  219. RTM_EXPORT(rtgui_widget_update)
  220. RTM_EXPORT(rtgui_widget_get_rect)
  221. RTM_EXPORT(rtgui_widget_set_rect)
  222. RTM_EXPORT(rtgui_widget_get_toplevel)
  223. RTM_EXPORT(rtgui_panel_register)
  224. RTM_EXPORT(rtgui_panel_set_default_focused)
  225. RTM_EXPORT(rtgui_button_create)
  226. RTM_EXPORT(rtgui_button_destroy)
  227. RTM_EXPORT(rtgui_button_set_onbutton)
  228. RTM_EXPORT(rtgui_container_add_child)
  229. RTM_EXPORT(rtgui_filelist_view_create)
  230. RTM_EXPORT(rtgui_filelist_view_get_fullpath)
  231. RTM_EXPORT(rtgui_list_view_create)
  232. RTM_EXPORT(rtgui_list_view_destroy)
  233. #endif
  234. #endif