summaryrefslogtreecommitdiff
path: root/include/rtdef.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/rtdef.h')
-rw-r--r--include/rtdef.h149
1 files changed, 112 insertions, 37 deletions
diff --git a/include/rtdef.h b/include/rtdef.h
index deb3295e27..f2b546f75e 100644
--- a/include/rtdef.h
+++ b/include/rtdef.h
@@ -24,6 +24,14 @@
* 2018-05-31 Bernard change version number to v3.1.0
* 2018-09-04 Bernard change version number to v3.1.1
* 2018-09-14 Bernard apply Apache License v2.0 to RT-Thread Kernel
+ * 2018-10-13 Bernard change version number to v4.0.0
+ * 2018-10-02 Bernard add 64bit arch support
+ * 2018-11-22 Jesven add smp member to struct rt_thread
+ * add struct rt_cpu
+ * add smp relevant macros
+ * 2019-01-27 Bernard change version number to v4.0.1
+ * 2019-05-17 Bernard change version number to v4.0.2
+ * 2019-12-20 Bernard change version number to v4.0.3
*/
#ifndef __RT_DEF_H__
@@ -40,27 +48,36 @@ extern "C" {
* @addtogroup BasicDef
*/
-/*@{*/
+/**@{*/
/* RT-Thread version information */
-#define RT_VERSION 3L /**< major version number */
-#define RT_SUBVERSION 1L /**< minor version number */
-#define RT_REVISION 1L /**< revise version number */
+#define RT_VERSION 4L /**< major version number */
+#define RT_SUBVERSION 0L /**< minor version number */
+#define RT_REVISION 3L /**< revise version number */
/* RT-Thread version */
#define RTTHREAD_VERSION ((RT_VERSION * 10000) + \
(RT_SUBVERSION * 100) + RT_REVISION)
/* RT-Thread basic data type definitions */
+#ifndef RT_USING_ARCH_DATA_TYPE
typedef signed char rt_int8_t; /**< 8bit integer type */
typedef signed short rt_int16_t; /**< 16bit integer type */
-typedef signed long rt_int32_t; /**< 32bit integer type */
+typedef signed int rt_int32_t; /**< 32bit integer type */
typedef unsigned char rt_uint8_t; /**< 8bit unsigned integer type */
typedef unsigned short rt_uint16_t; /**< 16bit unsigned integer type */
-typedef unsigned long rt_uint32_t; /**< 32bit unsigned integer type */
-typedef int rt_bool_t; /**< boolean type */
+typedef unsigned int rt_uint32_t; /**< 32bit unsigned integer type */
+
+#ifdef ARCH_CPU_64BIT
+typedef signed long rt_int64_t; /**< 64bit integer type */
+typedef unsigned long rt_uint64_t; /**< 64bit unsigned integer type */
+#else
+typedef signed long long rt_int64_t; /**< 64bit integer type */
+typedef unsigned long long rt_uint64_t; /**< 64bit unsigned integer type */
+#endif
+#endif
-/* 32bit CPU */
+typedef int rt_bool_t; /**< boolean type */
typedef long rt_base_t; /**< Nbit CPU related date type */
typedef unsigned long rt_ubase_t; /**< Nbit unsigned CPU related data type */
@@ -76,7 +93,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define RT_TRUE 1 /**< boolean true */
#define RT_FALSE 0 /**< boolean fails */
-/*@}*/
+/**@}*/
/* maximum value of base type */
#define RT_UINT8_MAX 0xff /**< Maxium number of UINT8 */
@@ -121,11 +138,11 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#include <stdarg.h>
#else
/* the version of GNU GCC must be greater than 4.x */
- typedef __builtin_va_list __gnuc_va_list;
- typedef __gnuc_va_list va_list;
- #define va_start(v,l) __builtin_va_start(v,l)
- #define va_end(v) __builtin_va_end(v)
- #define va_arg(v,l) __builtin_va_arg(v,l)
+ typedef __builtin_va_list __gnuc_va_list;
+ typedef __gnuc_va_list va_list;
+ #define va_start(v,l) __builtin_va_start(v,l)
+ #define va_end(v) __builtin_va_end(v)
+ #define va_arg(v,l) __builtin_va_arg(v,l)
#endif
#define SECTION(x) __attribute__((section(x)))
@@ -184,11 +201,11 @@ typedef int (*init_fn_t)(void);
};
#define INIT_EXPORT(fn, level) \
const char __rti_##fn##_name[] = #fn; \
- RT_USED const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn."level) = \
+ RT_USED const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn." level) = \
{ __rti_##fn##_name, fn};
#else
#define INIT_EXPORT(fn, level) \
- RT_USED const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn
+ RT_USED const init_fn_t __rt_init_##fn SECTION(".rti_fn." level) = fn
#endif
#endif
#else
@@ -247,7 +264,7 @@ typedef int (*init_fn_t)(void);
* @addtogroup Error
*/
-/*@{*/
+/**@{*/
/* RT-Thread error code definitions */
#define RT_EOK 0 /**< There is no error */
@@ -262,7 +279,7 @@ typedef int (*init_fn_t)(void);
#define RT_EINTR 9 /**< Interrupted system call */
#define RT_EINVAL 10 /**< Invalid argument */
-/*@}*/
+/**@}*/
/**
* @ingroup BasicDef
@@ -313,7 +330,7 @@ typedef struct rt_slist_node rt_slist_t; /**< Type for single lis
* @addtogroup KernelObject
*/
-/*@{*/
+/**@{*/
/*
* kernel object macros
@@ -355,7 +372,8 @@ typedef struct rt_object *rt_object_t; /**< Type for kernel obj
*/
enum rt_object_class_type
{
- RT_Object_Class_Thread = 0, /**< The object is a thread. */
+ RT_Object_Class_Null = 0, /**< The object is not used. */
+ RT_Object_Class_Thread, /**< The object is a thread. */
RT_Object_Class_Semaphore, /**< The object is a semaphore. */
RT_Object_Class_Mutex, /**< The object is a mutex. */
RT_Object_Class_Event, /**< The object is a event. */
@@ -390,13 +408,13 @@ struct rt_object_information
#define RT_OBJECT_HOOK_CALL(func, argv)
#endif
-/*@}*/
+/**@}*/
/**
* @addtogroup Clock
*/
-/*@{*/
+/**@{*/
/**
* clock & timer macros
@@ -413,6 +431,7 @@ struct rt_object_information
#define RT_TIMER_CTRL_GET_TIME 0x1 /**< get timer control command */
#define RT_TIMER_CTRL_SET_ONESHOT 0x2 /**< change timer to one shot */
#define RT_TIMER_CTRL_SET_PERIODIC 0x3 /**< change timer to periodic */
+#define RT_TIMER_CTRL_GET_STATE 0x4 /**< get timer run state active or deactive*/
#ifndef RT_TIMER_SKIP_LIST_LEVEL
#define RT_TIMER_SKIP_LIST_LEVEL 1
@@ -440,7 +459,7 @@ struct rt_timer
};
typedef struct rt_timer *rt_timer_t;
-/*@}*/
+/**@}*/
/**
* @addtogroup Signal
@@ -453,13 +472,13 @@ typedef siginfo_t rt_siginfo_t;
#define RT_SIG_MAX 32
#endif
-/*@}*/
+/**@}*/
/**
* @addtogroup Thread
*/
-/*@{*/
+/**@{*/
/*
* Thread
@@ -474,11 +493,15 @@ typedef siginfo_t rt_siginfo_t;
#define RT_THREAD_RUNNING 0x03 /**< Running status */
#define RT_THREAD_BLOCK RT_THREAD_SUSPEND /**< Blocked status */
#define RT_THREAD_CLOSE 0x04 /**< Closed status */
-#define RT_THREAD_STAT_MASK 0x0f
+#define RT_THREAD_STAT_MASK 0x07
-#define RT_THREAD_STAT_SIGNAL 0x10
+#define RT_THREAD_STAT_YIELD 0x08 /**< indicate whether remaining_tick has been reloaded since last schedule */
+#define RT_THREAD_STAT_YIELD_MASK RT_THREAD_STAT_YIELD
+
+#define RT_THREAD_STAT_SIGNAL 0x10 /**< task hold signals */
#define RT_THREAD_STAT_SIGNAL_READY (RT_THREAD_STAT_SIGNAL | RT_THREAD_READY)
-#define RT_THREAD_STAT_SIGNAL_WAIT 0x20
+#define RT_THREAD_STAT_SIGNAL_WAIT 0x20 /**< task is waiting for signals */
+#define RT_THREAD_STAT_SIGNAL_PENDING 0x40 /**< signals is held and it has not been procressed */
#define RT_THREAD_STAT_SIGNAL_MASK 0xf0
/**
@@ -488,6 +511,41 @@ typedef siginfo_t rt_siginfo_t;
#define RT_THREAD_CTRL_CLOSE 0x01 /**< Close thread. */
#define RT_THREAD_CTRL_CHANGE_PRIORITY 0x02 /**< Change thread priority. */
#define RT_THREAD_CTRL_INFO 0x03 /**< Get thread information. */
+#define RT_THREAD_CTRL_BIND_CPU 0x04 /**< Set thread bind cpu. */
+
+#ifdef RT_USING_SMP
+
+#define RT_CPU_DETACHED RT_CPUS_NR /**< The thread not running on cpu. */
+#define RT_CPU_MASK ((1 << RT_CPUS_NR) - 1) /**< All CPUs mask bit. */
+
+#ifndef RT_SCHEDULE_IPI
+#define RT_SCHEDULE_IPI 0
+#endif
+
+/**
+ * CPUs definitions
+ *
+ */
+struct rt_cpu
+{
+ struct rt_thread *current_thread;
+
+ rt_uint16_t irq_nest;
+ rt_uint8_t irq_switch_flag;
+
+ rt_uint8_t current_priority;
+ rt_list_t priority_table[RT_THREAD_PRIORITY_MAX];
+#if RT_THREAD_PRIORITY_MAX > 32
+ rt_uint32_t priority_group;
+ rt_uint8_t ready_table[32];
+#else
+ rt_uint32_t priority_group;
+#endif
+
+ rt_tick_t tick;
+};
+
+#endif
/**
* Thread structure
@@ -518,6 +576,15 @@ struct rt_thread
rt_uint8_t stat; /**< thread status */
+#ifdef RT_USING_SMP
+ rt_uint8_t bind_cpu; /**< thread is bind to cpu */
+ rt_uint8_t oncpu; /**< process on cpu` */
+
+ rt_uint16_t scheduler_lock_nest; /**< scheduler lock count */
+ rt_uint16_t cpus_lock_nest; /**< cpus lock count */
+ rt_uint16_t critical_lock_nest; /**< critical lock count */
+#endif /*RT_USING_SMP*/
+
/* priority */
rt_uint8_t current_priority; /**< current priority */
rt_uint8_t init_priority; /**< initialized priority */
@@ -537,7 +604,9 @@ struct rt_thread
rt_sigset_t sig_pending; /**< the pending signals */
rt_sigset_t sig_mask; /**< the mask bits of signal */
+#ifndef RT_USING_SMP
void *sig_ret; /**< the return stack pointer from signal */
+#endif
rt_sighandler_t *sig_vectors; /**< vectors of signal handler */
void *si_list; /**< the signal infor list */
#endif
@@ -558,13 +627,13 @@ struct rt_thread
};
typedef struct rt_thread *rt_thread_t;
-/*@}*/
+/**@}*/
/**
* @addtogroup IPC
*/
-/*@{*/
+/**@{*/
/**
* IPC flags and control command definitions
@@ -597,6 +666,7 @@ struct rt_semaphore
struct rt_ipc_object parent; /**< inherit from ipc_object */
rt_uint16_t value; /**< value of semaphore. */
+ rt_uint16_t reserved; /**< reserved field */
};
typedef struct rt_semaphore *rt_sem_t;
#endif
@@ -647,7 +717,7 @@ struct rt_mailbox
{
struct rt_ipc_object parent; /**< inherit from ipc_object */
- rt_uint32_t *msg_pool; /**< start address of message buffer */
+ rt_ubase_t *msg_pool; /**< start address of message buffer */
rt_uint16_t size; /**< size of message pool */
@@ -678,17 +748,19 @@ struct rt_messagequeue
void *msg_queue_head; /**< list head */
void *msg_queue_tail; /**< list tail */
void *msg_queue_free; /**< pointer indicated the free node of queue */
+
+ rt_list_t suspend_sender_thread; /**< sender thread suspended on this message queue */
};
typedef struct rt_messagequeue *rt_mq_t;
#endif
-/*@}*/
+/**@}*/
/**
* @addtogroup MM
*/
-/*@{*/
+/**@{*/
/*
* memory management
@@ -751,19 +823,18 @@ struct rt_mempool
rt_size_t block_free_count; /**< numbers of free memory block */
rt_list_t suspend_thread; /**< threads pended on this resource */
- rt_size_t suspend_thread_count; /**< numbers of thread pended on this resource */
};
typedef struct rt_mempool *rt_mp_t;
#endif
-/*@}*/
+/**@}*/
#ifdef RT_USING_DEVICE
/**
* @addtogroup Device
*/
-/*@{*/
+/**@{*/
/**
* device (I/O) class type
@@ -789,6 +860,8 @@ enum rt_device_class_type
RT_Device_Class_Portal, /**< Portal device */
RT_Device_Class_Timer, /**< Timer device */
RT_Device_Class_Miscellaneous, /**< Miscellaneous device */
+ RT_Device_Class_Sensor, /**< Sensor device */
+ RT_Device_Class_Touch, /**< Touch device */
RT_Device_Class_Unknown /**< unknown device */
};
@@ -825,6 +898,7 @@ enum rt_device_class_type
#define RT_DEVICE_CTRL_RESUME 0x01 /**< resume device */
#define RT_DEVICE_CTRL_SUSPEND 0x02 /**< suspend device */
#define RT_DEVICE_CTRL_CONFIG 0x03 /**< configure device */
+#define RT_DEVICE_CTRL_CLOSE 0x04 /**< close device */
#define RT_DEVICE_CTRL_SET_INT 0x10 /**< set interrupt */
#define RT_DEVICE_CTRL_CLR_INT 0x11 /**< clear interrupt */
@@ -960,6 +1034,7 @@ enum
RTGRAPHIC_PIXEL_FORMAT_ABGR888,
RTGRAPHIC_PIXEL_FORMAT_ARGB565,
RTGRAPHIC_PIXEL_FORMAT_ALPHA,
+ RTGRAPHIC_PIXEL_FORMAT_COLOR,
};
/**
@@ -1008,7 +1083,7 @@ struct rt_device_graphic_ops
};
#define rt_graphix_ops(device) ((struct rt_device_graphic_ops *)(device->user_data))
-/*@}*/
+/**@}*/
#endif
/* definitions for libc */