rtdef.h 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2007-01-10 Bernard the first version
  9. * 2008-07-12 Bernard remove all rt_int8, rt_uint32_t etc typedef
  10. * 2010-10-26 yi.qiu add module support
  11. * 2010-11-10 Bernard add cleanup callback function in thread exit.
  12. * 2011-05-09 Bernard use builtin va_arg in GCC 4.x
  13. * 2012-11-16 Bernard change RT_NULL from ((void*)0) to 0.
  14. * 2012-12-29 Bernard change the RT_USING_MEMPOOL location and add
  15. * RT_USING_MEMHEAP condition.
  16. * 2012-12-30 Bernard add more control command for graphic.
  17. * 2013-01-09 Bernard change version number.
  18. * 2015-02-01 Bernard change version number to v2.1.0
  19. * 2017-08-31 Bernard change version number to v3.0.0
  20. * 2017-11-30 Bernard change version number to v3.0.1
  21. * 2017-12-27 Bernard change version number to v3.0.2
  22. * 2018-02-24 Bernard change version number to v3.0.3
  23. * 2018-04-25 Bernard change version number to v3.0.4
  24. * 2018-05-31 Bernard change version number to v3.1.0
  25. * 2018-09-04 Bernard change version number to v3.1.1
  26. * 2018-09-14 Bernard apply Apache License v2.0 to RT-Thread Kernel
  27. * 2018-10-13 Bernard change version number to v4.0.0
  28. * 2018-10-02 Bernard add 64bit arch support
  29. * 2018-11-22 Jesven add smp member to struct rt_thread
  30. * add struct rt_cpu
  31. * add smp relevant macros
  32. * 2019-01-27 Bernard change version number to v4.0.1
  33. * 2019-05-17 Bernard change version number to v4.0.2
  34. * 2019-12-20 Bernard change version number to v4.0.3
  35. * 2020-08-10 Meco Man add macro for struct rt_device_ops
  36. * 2020-10-23 Meco Man define maximum value of ipc type
  37. */
  38. #ifndef __RT_DEF_H__
  39. #define __RT_DEF_H__
  40. /* include rtconfig header to import configuration */
  41. #include <rtconfig.h>
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45. /**
  46. * @addtogroup BasicDef
  47. */
  48. /**@{*/
  49. /* RT-Thread version information */
  50. #define RT_VERSION 4L /**< major version number */
  51. #define RT_SUBVERSION 0L /**< minor version number */
  52. #define RT_REVISION 3L /**< revise version number */
  53. /* RT-Thread version */
  54. #define RTTHREAD_VERSION ((RT_VERSION * 10000) + \
  55. (RT_SUBVERSION * 100) + RT_REVISION)
  56. /* RT-Thread basic data type definitions */
  57. #ifndef RT_USING_ARCH_DATA_TYPE
  58. typedef signed char rt_int8_t; /**< 8bit integer type */
  59. typedef signed short rt_int16_t; /**< 16bit integer type */
  60. typedef signed int rt_int32_t; /**< 32bit integer type */
  61. typedef unsigned char rt_uint8_t; /**< 8bit unsigned integer type */
  62. typedef unsigned short rt_uint16_t; /**< 16bit unsigned integer type */
  63. typedef unsigned int rt_uint32_t; /**< 32bit unsigned integer type */
  64. #ifdef ARCH_CPU_64BIT
  65. typedef signed long rt_int64_t; /**< 64bit integer type */
  66. typedef unsigned long rt_uint64_t; /**< 64bit unsigned integer type */
  67. #else
  68. typedef signed long long rt_int64_t; /**< 64bit integer type */
  69. typedef unsigned long long rt_uint64_t; /**< 64bit unsigned integer type */
  70. #endif
  71. #endif
  72. typedef int rt_bool_t; /**< boolean type */
  73. typedef long rt_base_t; /**< Nbit CPU related date type */
  74. typedef unsigned long rt_ubase_t; /**< Nbit unsigned CPU related data type */
  75. typedef rt_base_t rt_err_t; /**< Type for error number */
  76. typedef rt_uint32_t rt_time_t; /**< Type for time stamp */
  77. typedef rt_uint32_t rt_tick_t; /**< Type for tick count */
  78. typedef rt_base_t rt_flag_t; /**< Type for flags */
  79. typedef rt_ubase_t rt_size_t; /**< Type for size number */
  80. typedef rt_ubase_t rt_dev_t; /**< Type for device */
  81. typedef rt_base_t rt_off_t; /**< Type for offset */
  82. /* boolean type definitions */
  83. #define RT_TRUE 1 /**< boolean true */
  84. #define RT_FALSE 0 /**< boolean fails */
  85. /**@}*/
  86. /* maximum value of base type */
  87. #define RT_UINT8_MAX 0xff /**< Maxium number of UINT8 */
  88. #define RT_UINT16_MAX 0xffff /**< Maxium number of UINT16 */
  89. #define RT_UINT32_MAX 0xffffffff /**< Maxium number of UINT32 */
  90. #define RT_TICK_MAX RT_UINT32_MAX /**< Maxium number of tick */
  91. /* maximum value of ipc type */
  92. #define RT_SEM_VALUE_MAX RT_UINT16_MAX /**< Maxium number of semaphore .value */
  93. #define RT_MUTEX_VALUE_MAX RT_UINT16_MAX /**< Maxium number of mutex .value */
  94. #define RT_MUTEX_HOLD_MAX RT_UINT8_MAX /**< Maxium number of mutex .hold */
  95. #define RT_MB_ENTRY_MAX RT_UINT16_MAX /**< Maxium number of mailbox .entry */
  96. #define RT_MQ_ENTRY_MAX RT_UINT16_MAX /**< Maxium number of message queue .entry */
  97. #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  98. #define __CLANG_ARM
  99. #endif
  100. /* Compiler Related Definitions */
  101. #if defined(__CC_ARM) || defined(__CLANG_ARM) /* ARM Compiler */
  102. #include <stdarg.h>
  103. #define RT_SECTION(x) __attribute__((section(x)))
  104. #define RT_UNUSED __attribute__((unused))
  105. #define RT_USED __attribute__((used))
  106. #define ALIGN(n) __attribute__((aligned(n)))
  107. #define RT_WEAK __attribute__((weak))
  108. #define rt_inline static __inline
  109. /* module compiling */
  110. #ifdef RT_USING_MODULE
  111. #define RTT_API __declspec(dllimport)
  112. #else
  113. #define RTT_API __declspec(dllexport)
  114. #endif
  115. #elif defined (__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
  116. #include <stdarg.h>
  117. #define RT_SECTION(x) @ x
  118. #define RT_UNUSED
  119. #define RT_USED __root
  120. #define PRAGMA(x) _Pragma(#x)
  121. #define ALIGN(n) PRAGMA(data_alignment=n)
  122. #define RT_WEAK __weak
  123. #define rt_inline static inline
  124. #define RTT_API
  125. #elif defined (__GNUC__) /* GNU GCC Compiler */
  126. #ifdef RT_USING_NEWLIB
  127. #include <stdarg.h>
  128. #else
  129. /* the version of GNU GCC must be greater than 4.x */
  130. typedef __builtin_va_list __gnuc_va_list;
  131. typedef __gnuc_va_list va_list;
  132. #define va_start(v,l) __builtin_va_start(v,l)
  133. #define va_end(v) __builtin_va_end(v)
  134. #define va_arg(v,l) __builtin_va_arg(v,l)
  135. #endif
  136. #define RT_SECTION(x) __attribute__((section(x)))
  137. #define RT_UNUSED __attribute__((unused))
  138. #define RT_USED __attribute__((used))
  139. #define ALIGN(n) __attribute__((aligned(n)))
  140. #define RT_WEAK __attribute__((weak))
  141. #define rt_inline static __inline
  142. #define RTT_API
  143. #elif defined (__ADSPBLACKFIN__) /* for VisualDSP++ Compiler */
  144. #include <stdarg.h>
  145. #define RT_SECTION(x) __attribute__((section(x)))
  146. #define RT_UNUSED __attribute__((unused))
  147. #define RT_USED __attribute__((used))
  148. #define ALIGN(n) __attribute__((aligned(n)))
  149. #define RT_WEAK __attribute__((weak))
  150. #define rt_inline static inline
  151. #define RTT_API
  152. #elif defined (_MSC_VER)
  153. #include <stdarg.h>
  154. #define RT_SECTION(x)
  155. #define RT_UNUSED
  156. #define RT_USED
  157. #define ALIGN(n) __declspec(align(n))
  158. #define RT_WEAK
  159. #define rt_inline static __inline
  160. #define RTT_API
  161. #elif defined (__TI_COMPILER_VERSION__)
  162. #include <stdarg.h>
  163. /* The way that TI compiler set section is different from other(at least
  164. * GCC and MDK) compilers. See ARM Optimizing C/C++ Compiler 5.9.3 for more
  165. * details. */
  166. #define RT_SECTION(x)
  167. #define RT_UNUSED
  168. #define RT_USED
  169. #define PRAGMA(x) _Pragma(#x)
  170. #define ALIGN(n)
  171. #define RT_WEAK
  172. #define rt_inline static inline
  173. #define RTT_API
  174. #elif defined (__TASKING__)
  175. #include <stdarg.h>
  176. #define RT_SECTION(x) __attribute__((section(x)))
  177. #define RT_UNUSED __attribute__((unused))
  178. #define RT_USED __attribute__((used, protect))
  179. #define PRAGMA(x) _Pragma(#x)
  180. #define ALIGN(n) __attribute__((__align(n)))
  181. #define RT_WEAK __attribute__((weak))
  182. #define rt_inline static inline
  183. #define RTT_API
  184. #else
  185. #error not supported tool chain
  186. #endif
  187. /* initialization export */
  188. #ifdef RT_USING_COMPONENTS_INIT
  189. typedef int (*init_fn_t)(void);
  190. #ifdef _MSC_VER /* we do not support MS VC++ compiler */
  191. #pragma section("rti_fn$f",read)
  192. #if RT_DEBUG_INIT
  193. struct rt_init_desc
  194. {
  195. const char* level;
  196. const init_fn_t fn;
  197. const char* fn_name;
  198. };
  199. #define INIT_EXPORT(fn, level) \
  200. const char __rti_level_##fn[] = level"__rt_init_"#fn; \
  201. const char __rti_##fn##_name[] = #fn; \
  202. __declspec(allocate("rti_fn$f")) \
  203. RT_USED const struct rt_init_desc __rt_init_msc_##fn = \
  204. {__rti_level_##fn, fn, __rti_##fn##_name};
  205. #else
  206. struct rt_init_desc
  207. {
  208. const char* level;
  209. const init_fn_t fn;
  210. };
  211. #define INIT_EXPORT(fn, level) \
  212. const char __rti_level_##fn[] = level"__rt_init_"#fn; \
  213. __declspec(allocate("rti_fn$f")) \
  214. RT_USED const struct rt_init_desc __rt_init_msc_##fn = \
  215. {__rti_level_##fn, fn };
  216. #endif
  217. #else
  218. #if RT_DEBUG_INIT
  219. struct rt_init_desc
  220. {
  221. const char* fn_name;
  222. const init_fn_t fn;
  223. };
  224. #define INIT_EXPORT(fn, level) \
  225. const char __rti_##fn##_name[] = #fn; \
  226. RT_USED const struct rt_init_desc __rt_init_desc_##fn RT_SECTION(".rti_fn." level) = \
  227. { __rti_##fn##_name, fn};
  228. #else
  229. #define INIT_EXPORT(fn, level) \
  230. RT_USED const init_fn_t __rt_init_##fn RT_SECTION(".rti_fn." level) = fn
  231. #endif
  232. #endif
  233. #else
  234. #define INIT_EXPORT(fn, level)
  235. #endif
  236. /* board init routines will be called in board_init() function */
  237. #define INIT_BOARD_EXPORT(fn) INIT_EXPORT(fn, "1")
  238. /* pre/device/component/env/app init routines will be called in init_thread */
  239. /* components pre-initialization (pure software initilization) */
  240. #define INIT_PREV_EXPORT(fn) INIT_EXPORT(fn, "2")
  241. /* device initialization */
  242. #define INIT_DEVICE_EXPORT(fn) INIT_EXPORT(fn, "3")
  243. /* components initialization (dfs, lwip, ...) */
  244. #define INIT_COMPONENT_EXPORT(fn) INIT_EXPORT(fn, "4")
  245. /* environment initialization (mount disk, ...) */
  246. #define INIT_ENV_EXPORT(fn) INIT_EXPORT(fn, "5")
  247. /* appliation initialization (rtgui application etc ...) */
  248. #define INIT_APP_EXPORT(fn) INIT_EXPORT(fn, "6")
  249. #if !defined(RT_USING_FINSH)
  250. /* define these to empty, even if not include finsh.h file */
  251. #define FINSH_FUNCTION_EXPORT(name, desc)
  252. #define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc)
  253. #define FINSH_VAR_EXPORT(name, type, desc)
  254. #define MSH_CMD_EXPORT(command, desc)
  255. #define MSH_CMD_EXPORT_ALIAS(command, alias, desc)
  256. #elif !defined(FINSH_USING_SYMTAB)
  257. #define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc)
  258. #endif
  259. /* event length */
  260. #define RT_EVENT_LENGTH 32
  261. /* memory management option */
  262. #define RT_MM_PAGE_SIZE 4096
  263. #define RT_MM_PAGE_MASK (RT_MM_PAGE_SIZE - 1)
  264. #define RT_MM_PAGE_BITS 12
  265. /* kernel malloc definitions */
  266. #ifndef RT_KERNEL_MALLOC
  267. #define RT_KERNEL_MALLOC(sz) rt_malloc(sz)
  268. #endif
  269. #ifndef RT_KERNEL_FREE
  270. #define RT_KERNEL_FREE(ptr) rt_free(ptr)
  271. #endif
  272. #ifndef RT_KERNEL_REALLOC
  273. #define RT_KERNEL_REALLOC(ptr, size) rt_realloc(ptr, size)
  274. #endif
  275. /**
  276. * @addtogroup Error
  277. */
  278. /**@{*/
  279. /* RT-Thread error code definitions */
  280. #define RT_EOK 0 /**< There is no error */
  281. #define RT_ERROR 1 /**< A generic error happens */
  282. #define RT_ETIMEOUT 2 /**< Timed out */
  283. #define RT_EFULL 3 /**< The resource is full */
  284. #define RT_EEMPTY 4 /**< The resource is empty */
  285. #define RT_ENOMEM 5 /**< No memory */
  286. #define RT_ENOSYS 6 /**< No system */
  287. #define RT_EBUSY 7 /**< Busy */
  288. #define RT_EIO 8 /**< IO error */
  289. #define RT_EINTR 9 /**< Interrupted system call */
  290. #define RT_EINVAL 10 /**< Invalid argument */
  291. /**@}*/
  292. /**
  293. * @ingroup BasicDef
  294. *
  295. * @def RT_ALIGN(size, align)
  296. * Return the most contiguous size aligned at specified width. RT_ALIGN(13, 4)
  297. * would return 16.
  298. */
  299. #define RT_ALIGN(size, align) (((size) + (align) - 1) & ~((align) - 1))
  300. /**
  301. * @ingroup BasicDef
  302. *
  303. * @def RT_ALIGN_DOWN(size, align)
  304. * Return the down number of aligned at specified width. RT_ALIGN_DOWN(13, 4)
  305. * would return 12.
  306. */
  307. #define RT_ALIGN_DOWN(size, align) ((size) & ~((align) - 1))
  308. /**
  309. * @ingroup BasicDef
  310. *
  311. * @def RT_NULL
  312. * Similar as the \c NULL in C library.
  313. */
  314. #define RT_NULL (0)
  315. /**
  316. * Double List structure
  317. */
  318. struct rt_list_node
  319. {
  320. struct rt_list_node *next; /**< point to next node. */
  321. struct rt_list_node *prev; /**< point to prev node. */
  322. };
  323. typedef struct rt_list_node rt_list_t; /**< Type for lists. */
  324. /**
  325. * Single List structure
  326. */
  327. struct rt_slist_node
  328. {
  329. struct rt_slist_node *next; /**< point to next node. */
  330. };
  331. typedef struct rt_slist_node rt_slist_t; /**< Type for single list. */
  332. /**
  333. * @addtogroup KernelObject
  334. */
  335. /**@{*/
  336. /*
  337. * kernel object macros
  338. */
  339. #define RT_OBJECT_FLAG_MODULE 0x80 /**< is module object. */
  340. /**
  341. * Base structure of Kernel object
  342. */
  343. struct rt_object
  344. {
  345. char name[RT_NAME_MAX]; /**< name of kernel object */
  346. rt_uint8_t type; /**< type of kernel object */
  347. rt_uint8_t flag; /**< flag of kernel object */
  348. #ifdef RT_USING_MODULE
  349. void *module_id; /**< id of application module */
  350. #endif
  351. rt_list_t list; /**< list node of kernel object */
  352. };
  353. typedef struct rt_object *rt_object_t; /**< Type for kernel objects. */
  354. /**
  355. * The object type can be one of the follows with specific
  356. * macros enabled:
  357. * - Thread
  358. * - Semaphore
  359. * - Mutex
  360. * - Event
  361. * - MailBox
  362. * - MessageQueue
  363. * - MemHeap
  364. * - MemPool
  365. * - Device
  366. * - Timer
  367. * - Module
  368. * - Unknown
  369. * - Static
  370. */
  371. enum rt_object_class_type
  372. {
  373. RT_Object_Class_Null = 0x00, /**< The object is not used. */
  374. RT_Object_Class_Thread = 0x01, /**< The object is a thread. */
  375. RT_Object_Class_Semaphore = 0x02, /**< The object is a semaphore. */
  376. RT_Object_Class_Mutex = 0x03, /**< The object is a mutex. */
  377. RT_Object_Class_Event = 0x04, /**< The object is a event. */
  378. RT_Object_Class_MailBox = 0x05, /**< The object is a mail box. */
  379. RT_Object_Class_MessageQueue = 0x06, /**< The object is a message queue. */
  380. RT_Object_Class_MemHeap = 0x07, /**< The object is a memory heap. */
  381. RT_Object_Class_MemPool = 0x08, /**< The object is a memory pool. */
  382. RT_Object_Class_Device = 0x09, /**< The object is a device. */
  383. RT_Object_Class_Timer = 0x0a, /**< The object is a timer. */
  384. RT_Object_Class_Module = 0x0b, /**< The object is a module. */
  385. RT_Object_Class_Unknown = 0x0c, /**< The object is unknown. */
  386. RT_Object_Class_Static = 0x80 /**< The object is a static object. */
  387. };
  388. /**
  389. * The information of the kernel object
  390. */
  391. struct rt_object_information
  392. {
  393. enum rt_object_class_type type; /**< object class type */
  394. rt_list_t object_list; /**< object list */
  395. rt_size_t object_size; /**< object size */
  396. };
  397. /**
  398. * The hook function call macro
  399. */
  400. #ifdef RT_USING_HOOK
  401. #define RT_OBJECT_HOOK_CALL(func, argv) \
  402. do { if ((func) != RT_NULL) func argv; } while (0)
  403. #else
  404. #define RT_OBJECT_HOOK_CALL(func, argv)
  405. #endif
  406. /**@}*/
  407. /**
  408. * @addtogroup Clock
  409. */
  410. /**@{*/
  411. /**
  412. * clock & timer macros
  413. */
  414. #define RT_TIMER_FLAG_DEACTIVATED 0x0 /**< timer is deactive */
  415. #define RT_TIMER_FLAG_ACTIVATED 0x1 /**< timer is active */
  416. #define RT_TIMER_FLAG_ONE_SHOT 0x0 /**< one shot timer */
  417. #define RT_TIMER_FLAG_PERIODIC 0x2 /**< periodic timer */
  418. #define RT_TIMER_FLAG_HARD_TIMER 0x0 /**< hard timer,the timer's callback function will be called in tick isr. */
  419. #define RT_TIMER_FLAG_SOFT_TIMER 0x4 /**< soft timer,the timer's callback function will be called in timer thread. */
  420. #define RT_TIMER_CTRL_SET_TIME 0x0 /**< set timer control command */
  421. #define RT_TIMER_CTRL_GET_TIME 0x1 /**< get timer control command */
  422. #define RT_TIMER_CTRL_SET_ONESHOT 0x2 /**< change timer to one shot */
  423. #define RT_TIMER_CTRL_SET_PERIODIC 0x3 /**< change timer to periodic */
  424. #define RT_TIMER_CTRL_GET_STATE 0x4 /**< get timer run state active or deactive*/
  425. #ifndef RT_TIMER_SKIP_LIST_LEVEL
  426. #define RT_TIMER_SKIP_LIST_LEVEL 1
  427. #endif
  428. /* 1 or 3 */
  429. #ifndef RT_TIMER_SKIP_LIST_MASK
  430. #define RT_TIMER_SKIP_LIST_MASK 0x3
  431. #endif
  432. /**
  433. * timer structure
  434. */
  435. struct rt_timer
  436. {
  437. struct rt_object parent; /**< inherit from rt_object */
  438. rt_list_t row[RT_TIMER_SKIP_LIST_LEVEL];
  439. void (*timeout_func)(void *parameter); /**< timeout function */
  440. void *parameter; /**< timeout function's parameter */
  441. rt_tick_t init_tick; /**< timer timeout tick */
  442. rt_tick_t timeout_tick; /**< timeout tick */
  443. };
  444. typedef struct rt_timer *rt_timer_t;
  445. /**@}*/
  446. /**
  447. * @addtogroup Signal
  448. */
  449. #ifdef RT_USING_SIGNALS
  450. #include <libc/libc_signal.h>
  451. typedef unsigned long rt_sigset_t;
  452. typedef void (*rt_sighandler_t)(int signo);
  453. typedef siginfo_t rt_siginfo_t;
  454. #define RT_SIG_MAX 32
  455. #endif
  456. /**@}*/
  457. /**
  458. * @addtogroup Thread
  459. */
  460. /**@{*/
  461. /*
  462. * Thread
  463. */
  464. /*
  465. * thread state definitions
  466. */
  467. #define RT_THREAD_INIT 0x00 /**< Initialized status */
  468. #define RT_THREAD_READY 0x01 /**< Ready status */
  469. #define RT_THREAD_SUSPEND 0x02 /**< Suspend status */
  470. #define RT_THREAD_RUNNING 0x03 /**< Running status */
  471. #define RT_THREAD_BLOCK RT_THREAD_SUSPEND /**< Blocked status */
  472. #define RT_THREAD_CLOSE 0x04 /**< Closed status */
  473. #define RT_THREAD_STAT_MASK 0x07
  474. #define RT_THREAD_STAT_YIELD 0x08 /**< indicate whether remaining_tick has been reloaded since last schedule */
  475. #define RT_THREAD_STAT_YIELD_MASK RT_THREAD_STAT_YIELD
  476. #define RT_THREAD_STAT_SIGNAL 0x10 /**< task hold signals */
  477. #define RT_THREAD_STAT_SIGNAL_READY (RT_THREAD_STAT_SIGNAL | RT_THREAD_READY)
  478. #define RT_THREAD_STAT_SIGNAL_WAIT 0x20 /**< task is waiting for signals */
  479. #define RT_THREAD_STAT_SIGNAL_PENDING 0x40 /**< signals is held and it has not been procressed */
  480. #define RT_THREAD_STAT_SIGNAL_MASK 0xf0
  481. /**
  482. * thread control command definitions
  483. */
  484. #define RT_THREAD_CTRL_STARTUP 0x00 /**< Startup thread. */
  485. #define RT_THREAD_CTRL_CLOSE 0x01 /**< Close thread. */
  486. #define RT_THREAD_CTRL_CHANGE_PRIORITY 0x02 /**< Change thread priority. */
  487. #define RT_THREAD_CTRL_INFO 0x03 /**< Get thread information. */
  488. #define RT_THREAD_CTRL_BIND_CPU 0x04 /**< Set thread bind cpu. */
  489. #ifdef RT_USING_SMP
  490. #define RT_CPU_DETACHED RT_CPUS_NR /**< The thread not running on cpu. */
  491. #define RT_CPU_MASK ((1 << RT_CPUS_NR) - 1) /**< All CPUs mask bit. */
  492. #ifndef RT_SCHEDULE_IPI
  493. #define RT_SCHEDULE_IPI 0
  494. #endif
  495. /**
  496. * CPUs definitions
  497. *
  498. */
  499. struct rt_cpu
  500. {
  501. struct rt_thread *current_thread;
  502. rt_uint16_t irq_nest;
  503. rt_uint8_t irq_switch_flag;
  504. rt_uint8_t current_priority;
  505. rt_list_t priority_table[RT_THREAD_PRIORITY_MAX];
  506. #if RT_THREAD_PRIORITY_MAX > 32
  507. rt_uint32_t priority_group;
  508. rt_uint8_t ready_table[32];
  509. #else
  510. rt_uint32_t priority_group;
  511. #endif
  512. rt_tick_t tick;
  513. };
  514. #endif
  515. /**
  516. * Thread structure
  517. */
  518. struct rt_thread
  519. {
  520. /* rt object */
  521. char name[RT_NAME_MAX]; /**< the name of thread */
  522. rt_uint8_t type; /**< type of object */
  523. rt_uint8_t flags; /**< thread's flags */
  524. #ifdef RT_USING_MODULE
  525. void *module_id; /**< id of application module */
  526. #endif
  527. rt_list_t list; /**< the object list */
  528. rt_list_t tlist; /**< the thread list */
  529. /* stack point and entry */
  530. void *sp; /**< stack point */
  531. void *entry; /**< entry */
  532. void *parameter; /**< parameter */
  533. void *stack_addr; /**< stack address */
  534. rt_uint32_t stack_size; /**< stack size */
  535. /* error code */
  536. rt_err_t error; /**< error code */
  537. rt_uint8_t stat; /**< thread status */
  538. #ifdef RT_USING_SMP
  539. rt_uint8_t bind_cpu; /**< thread is bind to cpu */
  540. rt_uint8_t oncpu; /**< process on cpu` */
  541. rt_uint16_t scheduler_lock_nest; /**< scheduler lock count */
  542. rt_uint16_t cpus_lock_nest; /**< cpus lock count */
  543. rt_uint16_t critical_lock_nest; /**< critical lock count */
  544. #endif /*RT_USING_SMP*/
  545. /* priority */
  546. rt_uint8_t current_priority; /**< current priority */
  547. rt_uint8_t init_priority; /**< initialized priority */
  548. #if RT_THREAD_PRIORITY_MAX > 32
  549. rt_uint8_t number;
  550. rt_uint8_t high_mask;
  551. #endif
  552. rt_uint32_t number_mask;
  553. #if defined(RT_USING_EVENT)
  554. /* thread event */
  555. rt_uint32_t event_set;
  556. rt_uint8_t event_info;
  557. #endif
  558. #if defined(RT_USING_SIGNALS)
  559. rt_sigset_t sig_pending; /**< the pending signals */
  560. rt_sigset_t sig_mask; /**< the mask bits of signal */
  561. #ifndef RT_USING_SMP
  562. void *sig_ret; /**< the return stack pointer from signal */
  563. #endif
  564. rt_sighandler_t *sig_vectors; /**< vectors of signal handler */
  565. void *si_list; /**< the signal infor list */
  566. #endif
  567. rt_ubase_t init_tick; /**< thread's initialized tick */
  568. rt_ubase_t remaining_tick; /**< remaining tick */
  569. struct rt_timer thread_timer; /**< built-in thread timer */
  570. void (*cleanup)(struct rt_thread *tid); /**< cleanup function when thread exit */
  571. /* light weight process if present */
  572. #ifdef RT_USING_LWP
  573. void *lwp;
  574. #endif
  575. rt_ubase_t user_data; /**< private user data beyond this thread */
  576. };
  577. typedef struct rt_thread *rt_thread_t;
  578. /**@}*/
  579. /**
  580. * @addtogroup IPC
  581. */
  582. /**@{*/
  583. /**
  584. * IPC flags and control command definitions
  585. */
  586. #define RT_IPC_FLAG_FIFO 0x00 /**< FIFOed IPC. @ref IPC. */
  587. #define RT_IPC_FLAG_PRIO 0x01 /**< PRIOed IPC. @ref IPC. */
  588. #define RT_IPC_CMD_UNKNOWN 0x00 /**< unknown IPC command */
  589. #define RT_IPC_CMD_RESET 0x01 /**< reset IPC object */
  590. #define RT_WAITING_FOREVER -1 /**< Block forever until get resource. */
  591. #define RT_WAITING_NO 0 /**< Non-block. */
  592. /**
  593. * Base structure of IPC object
  594. */
  595. struct rt_ipc_object
  596. {
  597. struct rt_object parent; /**< inherit from rt_object */
  598. rt_list_t suspend_thread; /**< threads pended on this resource */
  599. };
  600. #ifdef RT_USING_SEMAPHORE
  601. /**
  602. * Semaphore structure
  603. */
  604. struct rt_semaphore
  605. {
  606. struct rt_ipc_object parent; /**< inherit from ipc_object */
  607. rt_uint16_t value; /**< value of semaphore. */
  608. rt_uint16_t reserved; /**< reserved field */
  609. };
  610. typedef struct rt_semaphore *rt_sem_t;
  611. #endif
  612. #ifdef RT_USING_MUTEX
  613. /**
  614. * Mutual exclusion (mutex) structure
  615. */
  616. struct rt_mutex
  617. {
  618. struct rt_ipc_object parent; /**< inherit from ipc_object */
  619. rt_uint16_t value; /**< value of mutex */
  620. rt_uint8_t original_priority; /**< priority of last thread hold the mutex */
  621. rt_uint8_t hold; /**< numbers of thread hold the mutex */
  622. struct rt_thread *owner; /**< current owner of mutex */
  623. };
  624. typedef struct rt_mutex *rt_mutex_t;
  625. #endif
  626. #ifdef RT_USING_EVENT
  627. /**
  628. * flag defintions in event
  629. */
  630. #define RT_EVENT_FLAG_AND 0x01 /**< logic and */
  631. #define RT_EVENT_FLAG_OR 0x02 /**< logic or */
  632. #define RT_EVENT_FLAG_CLEAR 0x04 /**< clear flag */
  633. /*
  634. * event structure
  635. */
  636. struct rt_event
  637. {
  638. struct rt_ipc_object parent; /**< inherit from ipc_object */
  639. rt_uint32_t set; /**< event set */
  640. };
  641. typedef struct rt_event *rt_event_t;
  642. #endif
  643. #ifdef RT_USING_MAILBOX
  644. /**
  645. * mailbox structure
  646. */
  647. struct rt_mailbox
  648. {
  649. struct rt_ipc_object parent; /**< inherit from ipc_object */
  650. rt_ubase_t *msg_pool; /**< start address of message buffer */
  651. rt_uint16_t size; /**< size of message pool */
  652. rt_uint16_t entry; /**< index of messages in msg_pool */
  653. rt_uint16_t in_offset; /**< input offset of the message buffer */
  654. rt_uint16_t out_offset; /**< output offset of the message buffer */
  655. rt_list_t suspend_sender_thread; /**< sender thread suspended on this mailbox */
  656. };
  657. typedef struct rt_mailbox *rt_mailbox_t;
  658. #endif
  659. #ifdef RT_USING_MESSAGEQUEUE
  660. /**
  661. * message queue structure
  662. */
  663. struct rt_messagequeue
  664. {
  665. struct rt_ipc_object parent; /**< inherit from ipc_object */
  666. void *msg_pool; /**< start address of message queue */
  667. rt_uint16_t msg_size; /**< message size of each message */
  668. rt_uint16_t max_msgs; /**< max number of messages */
  669. rt_uint16_t entry; /**< index of messages in the queue */
  670. void *msg_queue_head; /**< list head */
  671. void *msg_queue_tail; /**< list tail */
  672. void *msg_queue_free; /**< pointer indicated the free node of queue */
  673. rt_list_t suspend_sender_thread; /**< sender thread suspended on this message queue */
  674. };
  675. typedef struct rt_messagequeue *rt_mq_t;
  676. #endif
  677. /**@}*/
  678. /**
  679. * @addtogroup MM
  680. */
  681. /**@{*/
  682. /*
  683. * memory management
  684. * heap & partition
  685. */
  686. #ifdef RT_USING_MEMHEAP
  687. /**
  688. * memory item on the heap
  689. */
  690. struct rt_memheap_item
  691. {
  692. rt_uint32_t magic; /**< magic number for memheap */
  693. struct rt_memheap *pool_ptr; /**< point of pool */
  694. struct rt_memheap_item *next; /**< next memheap item */
  695. struct rt_memheap_item *prev; /**< prev memheap item */
  696. struct rt_memheap_item *next_free; /**< next free memheap item */
  697. struct rt_memheap_item *prev_free; /**< prev free memheap item */
  698. #ifdef RT_USING_MEMTRACE
  699. rt_uint8_t owner_thread_name[4]; /**< owner thread name */
  700. #endif
  701. };
  702. /**
  703. * Base structure of memory heap object
  704. */
  705. struct rt_memheap
  706. {
  707. struct rt_object parent; /**< inherit from rt_object */
  708. void *start_addr; /**< pool start address and size */
  709. rt_uint32_t pool_size; /**< pool size */
  710. rt_uint32_t available_size; /**< available size */
  711. rt_uint32_t max_used_size; /**< maximum allocated size */
  712. struct rt_memheap_item *block_list; /**< used block list */
  713. struct rt_memheap_item *free_list; /**< free block list */
  714. struct rt_memheap_item free_header; /**< free block list header */
  715. struct rt_semaphore lock; /**< semaphore lock */
  716. };
  717. #endif
  718. #ifdef RT_USING_MEMPOOL
  719. /**
  720. * Base structure of Memory pool object
  721. */
  722. struct rt_mempool
  723. {
  724. struct rt_object parent; /**< inherit from rt_object */
  725. void *start_address; /**< memory pool start */
  726. rt_size_t size; /**< size of memory pool */
  727. rt_size_t block_size; /**< size of memory blocks */
  728. rt_uint8_t *block_list; /**< memory blocks list */
  729. rt_size_t block_total_count; /**< numbers of memory block */
  730. rt_size_t block_free_count; /**< numbers of free memory block */
  731. rt_list_t suspend_thread; /**< threads pended on this resource */
  732. };
  733. typedef struct rt_mempool *rt_mp_t;
  734. #endif
  735. /**@}*/
  736. #ifdef RT_USING_DEVICE
  737. /**
  738. * @addtogroup Device
  739. */
  740. /**@{*/
  741. /**
  742. * device (I/O) class type
  743. */
  744. enum rt_device_class_type
  745. {
  746. RT_Device_Class_Char = 0, /**< character device */
  747. RT_Device_Class_Block, /**< block device */
  748. RT_Device_Class_NetIf, /**< net interface */
  749. RT_Device_Class_MTD, /**< memory device */
  750. RT_Device_Class_CAN, /**< CAN device */
  751. RT_Device_Class_RTC, /**< RTC device */
  752. RT_Device_Class_Sound, /**< Sound device */
  753. RT_Device_Class_Graphic, /**< Graphic device */
  754. RT_Device_Class_I2CBUS, /**< I2C bus device */
  755. RT_Device_Class_USBDevice, /**< USB slave device */
  756. RT_Device_Class_USBHost, /**< USB host bus */
  757. RT_Device_Class_SPIBUS, /**< SPI bus device */
  758. RT_Device_Class_SPIDevice, /**< SPI device */
  759. RT_Device_Class_SDIO, /**< SDIO bus device */
  760. RT_Device_Class_PM, /**< PM pseudo device */
  761. RT_Device_Class_Pipe, /**< Pipe device */
  762. RT_Device_Class_Portal, /**< Portal device */
  763. RT_Device_Class_Timer, /**< Timer device */
  764. RT_Device_Class_Miscellaneous, /**< Miscellaneous device */
  765. RT_Device_Class_Sensor, /**< Sensor device */
  766. RT_Device_Class_Touch, /**< Touch device */
  767. RT_Device_Class_PHY, /**< PHY device */
  768. RT_Device_Class_Unknown /**< unknown device */
  769. };
  770. /**
  771. * device flags defitions
  772. */
  773. #define RT_DEVICE_FLAG_DEACTIVATE 0x000 /**< device is not not initialized */
  774. #define RT_DEVICE_FLAG_RDONLY 0x001 /**< read only */
  775. #define RT_DEVICE_FLAG_WRONLY 0x002 /**< write only */
  776. #define RT_DEVICE_FLAG_RDWR 0x003 /**< read and write */
  777. #define RT_DEVICE_FLAG_REMOVABLE 0x004 /**< removable device */
  778. #define RT_DEVICE_FLAG_STANDALONE 0x008 /**< standalone device */
  779. #define RT_DEVICE_FLAG_ACTIVATED 0x010 /**< device is activated */
  780. #define RT_DEVICE_FLAG_SUSPENDED 0x020 /**< device is suspended */
  781. #define RT_DEVICE_FLAG_STREAM 0x040 /**< stream mode */
  782. #define RT_DEVICE_FLAG_INT_RX 0x100 /**< INT mode on Rx */
  783. #define RT_DEVICE_FLAG_DMA_RX 0x200 /**< DMA mode on Rx */
  784. #define RT_DEVICE_FLAG_INT_TX 0x400 /**< INT mode on Tx */
  785. #define RT_DEVICE_FLAG_DMA_TX 0x800 /**< DMA mode on Tx */
  786. #define RT_DEVICE_OFLAG_CLOSE 0x000 /**< device is closed */
  787. #define RT_DEVICE_OFLAG_RDONLY 0x001 /**< read only access */
  788. #define RT_DEVICE_OFLAG_WRONLY 0x002 /**< write only access */
  789. #define RT_DEVICE_OFLAG_RDWR 0x003 /**< read and write */
  790. #define RT_DEVICE_OFLAG_OPEN 0x008 /**< device is opened */
  791. #define RT_DEVICE_OFLAG_MASK 0xf0f /**< mask of open flag */
  792. /**
  793. * general device commands
  794. */
  795. #define RT_DEVICE_CTRL_RESUME 0x01 /**< resume device */
  796. #define RT_DEVICE_CTRL_SUSPEND 0x02 /**< suspend device */
  797. #define RT_DEVICE_CTRL_CONFIG 0x03 /**< configure device */
  798. #define RT_DEVICE_CTRL_CLOSE 0x04 /**< close device */
  799. #define RT_DEVICE_CTRL_SET_INT 0x10 /**< set interrupt */
  800. #define RT_DEVICE_CTRL_CLR_INT 0x11 /**< clear interrupt */
  801. #define RT_DEVICE_CTRL_GET_INT 0x12 /**< get interrupt status */
  802. /**
  803. * special device commands
  804. */
  805. #define RT_DEVICE_CTRL_CHAR_STREAM 0x10 /**< stream mode on char device */
  806. #define RT_DEVICE_CTRL_BLK_GETGEOME 0x10 /**< get geometry information */
  807. #define RT_DEVICE_CTRL_BLK_SYNC 0x11 /**< flush data to block device */
  808. #define RT_DEVICE_CTRL_BLK_ERASE 0x12 /**< erase block on block device */
  809. #define RT_DEVICE_CTRL_BLK_AUTOREFRESH 0x13 /**< block device : enter/exit auto refresh mode */
  810. #define RT_DEVICE_CTRL_NETIF_GETMAC 0x10 /**< get mac address */
  811. #define RT_DEVICE_CTRL_MTD_FORMAT 0x10 /**< format a MTD device */
  812. #define RT_DEVICE_CTRL_RTC_GET_TIME 0x10 /**< get time */
  813. #define RT_DEVICE_CTRL_RTC_SET_TIME 0x11 /**< set time */
  814. #define RT_DEVICE_CTRL_RTC_GET_ALARM 0x12 /**< get alarm */
  815. #define RT_DEVICE_CTRL_RTC_SET_ALARM 0x13 /**< set alarm */
  816. typedef struct rt_device *rt_device_t;
  817. #ifdef RT_USING_DEVICE_OPS
  818. /**
  819. * operations set for device object
  820. */
  821. struct rt_device_ops
  822. {
  823. /* common device interface */
  824. rt_err_t (*init) (rt_device_t dev);
  825. rt_err_t (*open) (rt_device_t dev, rt_uint16_t oflag);
  826. rt_err_t (*close) (rt_device_t dev);
  827. rt_size_t (*read) (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size);
  828. rt_size_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
  829. rt_err_t (*control)(rt_device_t dev, int cmd, void *args);
  830. };
  831. #endif
  832. /**
  833. * WaitQueue structure
  834. */
  835. struct rt_wqueue
  836. {
  837. rt_uint32_t flag;
  838. rt_list_t waiting_list;
  839. };
  840. typedef struct rt_wqueue rt_wqueue_t;
  841. /**
  842. * Device structure
  843. */
  844. struct rt_device
  845. {
  846. struct rt_object parent; /**< inherit from rt_object */
  847. enum rt_device_class_type type; /**< device type */
  848. rt_uint16_t flag; /**< device flag */
  849. rt_uint16_t open_flag; /**< device open flag */
  850. rt_uint8_t ref_count; /**< reference count */
  851. rt_uint8_t device_id; /**< 0 - 255 */
  852. /* device call back */
  853. rt_err_t (*rx_indicate)(rt_device_t dev, rt_size_t size);
  854. rt_err_t (*tx_complete)(rt_device_t dev, void *buffer);
  855. #ifdef RT_USING_DEVICE_OPS
  856. const struct rt_device_ops *ops;
  857. #else
  858. /* common device interface */
  859. rt_err_t (*init) (rt_device_t dev);
  860. rt_err_t (*open) (rt_device_t dev, rt_uint16_t oflag);
  861. rt_err_t (*close) (rt_device_t dev);
  862. rt_size_t (*read) (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size);
  863. rt_size_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
  864. rt_err_t (*control)(rt_device_t dev, int cmd, void *args);
  865. #endif
  866. #if defined(RT_USING_POSIX)
  867. const struct dfs_file_ops *fops;
  868. struct rt_wqueue wait_queue;
  869. #endif
  870. void *user_data; /**< device private data */
  871. };
  872. /**
  873. * block device geometry structure
  874. */
  875. struct rt_device_blk_geometry
  876. {
  877. rt_uint32_t sector_count; /**< count of sectors */
  878. rt_uint32_t bytes_per_sector; /**< number of bytes per sector */
  879. rt_uint32_t block_size; /**< number of bytes to erase one block */
  880. };
  881. /**
  882. * sector arrange struct on block device
  883. */
  884. struct rt_device_blk_sectors
  885. {
  886. rt_uint32_t sector_begin; /**< begin sector */
  887. rt_uint32_t sector_end; /**< end sector */
  888. };
  889. /**
  890. * cursor control command
  891. */
  892. #define RT_DEVICE_CTRL_CURSOR_SET_POSITION 0x10
  893. #define RT_DEVICE_CTRL_CURSOR_SET_TYPE 0x11
  894. /**
  895. * graphic device control command
  896. */
  897. #define RTGRAPHIC_CTRL_RECT_UPDATE 0
  898. #define RTGRAPHIC_CTRL_POWERON 1
  899. #define RTGRAPHIC_CTRL_POWEROFF 2
  900. #define RTGRAPHIC_CTRL_GET_INFO 3
  901. #define RTGRAPHIC_CTRL_SET_MODE 4
  902. #define RTGRAPHIC_CTRL_GET_EXT 5
  903. #define RTGRAPHIC_CTRL_SET_BRIGHTNESS 6
  904. #define RTGRAPHIC_CTRL_GET_BRIGHTNESS 7
  905. #define RTGRAPHIC_CTRL_GET_MODE 8
  906. #define RTGRAPHIC_CTRL_GET_STATUS 9
  907. /* graphic deice */
  908. enum
  909. {
  910. RTGRAPHIC_PIXEL_FORMAT_MONO = 0,
  911. RTGRAPHIC_PIXEL_FORMAT_GRAY4,
  912. RTGRAPHIC_PIXEL_FORMAT_GRAY16,
  913. RTGRAPHIC_PIXEL_FORMAT_RGB332,
  914. RTGRAPHIC_PIXEL_FORMAT_RGB444,
  915. RTGRAPHIC_PIXEL_FORMAT_RGB565,
  916. RTGRAPHIC_PIXEL_FORMAT_RGB565P,
  917. RTGRAPHIC_PIXEL_FORMAT_BGR565 = RTGRAPHIC_PIXEL_FORMAT_RGB565P,
  918. RTGRAPHIC_PIXEL_FORMAT_RGB666,
  919. RTGRAPHIC_PIXEL_FORMAT_RGB888,
  920. RTGRAPHIC_PIXEL_FORMAT_ARGB888,
  921. RTGRAPHIC_PIXEL_FORMAT_ABGR888,
  922. RTGRAPHIC_PIXEL_FORMAT_RESERVED,
  923. };
  924. /**
  925. * build a pixel position according to (x, y) coordinates.
  926. */
  927. #define RTGRAPHIC_PIXEL_POSITION(x, y) ((x << 16) | y)
  928. /**
  929. * graphic device information structure
  930. */
  931. struct rt_device_graphic_info
  932. {
  933. rt_uint8_t pixel_format; /**< graphic format */
  934. rt_uint8_t bits_per_pixel; /**< bits per pixel */
  935. rt_uint16_t pitch; /**< bytes per line */
  936. rt_uint16_t width; /**< width of graphic device */
  937. rt_uint16_t height; /**< height of graphic device */
  938. rt_uint8_t *framebuffer; /**< frame buffer */
  939. };
  940. /**
  941. * rectangle information structure
  942. */
  943. struct rt_device_rect_info
  944. {
  945. rt_uint16_t x; /**< x coordinate */
  946. rt_uint16_t y; /**< y coordinate */
  947. rt_uint16_t width; /**< width */
  948. rt_uint16_t height; /**< height */
  949. };
  950. /**
  951. * graphic operations
  952. */
  953. struct rt_device_graphic_ops
  954. {
  955. void (*set_pixel) (const char *pixel, int x, int y);
  956. void (*get_pixel) (char *pixel, int x, int y);
  957. void (*draw_hline)(const char *pixel, int x1, int x2, int y);
  958. void (*draw_vline)(const char *pixel, int x, int y1, int y2);
  959. void (*blit_line) (const char *pixel, int x, int y, rt_size_t size);
  960. };
  961. #define rt_graphix_ops(device) ((struct rt_device_graphic_ops *)(device->user_data))
  962. /**@}*/
  963. #endif
  964. /* definitions for libc */
  965. #include "rtlibc.h"
  966. #ifdef __cplusplus
  967. }
  968. #endif
  969. #ifdef __cplusplus
  970. /* RT-Thread definitions for C++ */
  971. namespace rtthread {
  972. enum TICK_WAIT {
  973. WAIT_NONE = 0,
  974. WAIT_FOREVER = -1,
  975. };
  976. }
  977. #endif /* end of __cplusplus */
  978. #endif