1
0

rtdef.h 42 KB

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