rtdef.h 42 KB

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