summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorxph <[email protected]>2020-04-09 16:35:28 +0800
committerGitHub <[email protected]>2020-04-09 16:35:28 +0800
commitca7f01d79b3e0a997c771cec298e4ebd65b75809 (patch)
tree3d2c48aae7203b14038ba7b98b500b5343ed7f2a /include
parentf763f8e7284b0492c5a65ad0abf94ee1963d7dcc (diff)
parentbaa3145bfe61b3330b6a160523cc5470fa5db3a7 (diff)
Merge pull request #1 from RT-Thread/master
sync rtt
Diffstat (limited to 'include')
-rw-r--r--include/libc/libc_errno.h321
-rw-r--r--include/libc/libc_signal.h43
-rw-r--r--include/rtdbg.h77
-rw-r--r--include/rtdef.h149
-rw-r--r--include/rthw.h86
-rw-r--r--include/rtservice.h4
-rw-r--r--include/rtthread.h69
7 files changed, 498 insertions, 251 deletions
diff --git a/include/libc/libc_errno.h b/include/libc/libc_errno.h
index 82ae8cf943..0f3bc7635a 100644
--- a/include/libc/libc_errno.h
+++ b/include/libc/libc_errno.h
@@ -2,10 +2,6 @@
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
- */
-
-/*
- * File : libc_errno.h
*
* Change Logs:
* Date Author Notes
@@ -18,144 +14,193 @@
#include <rtconfig.h>
#if defined(RT_USING_NEWLIB) || defined(_WIN32)
-/* use errno.h file in newlib */
+/* use errno.h file in toolchains */
#include <errno.h>
+#endif
+
+#if defined(__CC_ARM)
+/*
+defined in armcc/errno.h
+
+#define EDOM 1
+#define ERANGE 2
+#define EILSEQ 4
+#define ESIGNUM 3
+#define EINVAL 5
+#define ENOMEM 6
+*/
+#define ERROR_BASE_NO 7
+
+#elif defined(__IAR_SYSTEMS_ICC__)
+/* defined in iar/errno.h
+#define EDOM 33
+#define ERANGE 34
+#define EFPOS 35
+#define EILSEQ 36
+*/
+#define ERROR_BASE_NO 36
+
#else
-/* define errno self. */
-#define EPERM 1
-#define ENOENT 2
-#define ESRCH 3
-#define EINTR 4
-#define EIO 5
-#define ENXIO 6
-#define E2BIG 7
-#define ENOEXEC 8
-#define EBADF 9
-#define ECHILD 10
-#define EAGAIN 11
-#define ENOMEM 12
-#define EACCES 13
-#define EFAULT 14
-#define ENOTBLK 15
-#define EBUSY 16
-#define EEXIST 17
-#define EXDEV 18
-#define ENODEV 19
-#define ENOTDIR 20
-#define EISDIR 21
-#define EINVAL 22
-#define ENFILE 23
-#define EMFILE 24
-#define ENOTTY 25
-#define ETXTBSY 26
-#define EFBIG 27
-#define ENOSPC 28
-#define ESPIPE 29
-#define EROFS 30
-#define EMLINK 31
-#define EPIPE 32
-#define EDOM 33
-#define ERANGE 34
-#define EDEADLK 35
-#define ENAMETOOLONG 36
-#define ENOLCK 37
-#define ENOSYS 38
-#define ENOTEMPTY 39
-#define ELOOP 40
+
+#define ERROR_BASE_NO 0
+#endif
+
+#if !defined(RT_USING_NEWLIB) && !defined(_WIN32)
+
+#define EPERM (ERROR_BASE_NO + 1)
+#define ENOENT (ERROR_BASE_NO + 2)
+#define ESRCH (ERROR_BASE_NO + 3)
+#define EINTR (ERROR_BASE_NO + 4)
+#define EIO (ERROR_BASE_NO + 5)
+#define ENXIO (ERROR_BASE_NO + 6)
+#define E2BIG (ERROR_BASE_NO + 7)
+#define ENOEXEC (ERROR_BASE_NO + 8)
+#define EBADF (ERROR_BASE_NO + 9)
+#define ECHILD (ERROR_BASE_NO + 10)
+#define EAGAIN (ERROR_BASE_NO + 11)
+
+#ifndef ENOMEM
+#define ENOMEM (ERROR_BASE_NO + 12)
+#endif
+
+#define EACCES (ERROR_BASE_NO + 13)
+#define EFAULT (ERROR_BASE_NO + 14)
+#define ENOTBLK (ERROR_BASE_NO + 15)
+#define EBUSY (ERROR_BASE_NO + 16)
+#define EEXIST (ERROR_BASE_NO + 17)
+#define EXDEV (ERROR_BASE_NO + 18)
+#define ENODEV (ERROR_BASE_NO + 19)
+#define ENOTDIR (ERROR_BASE_NO + 20)
+#define EISDIR (ERROR_BASE_NO + 21)
+
+#ifndef EINVAL
+#define EINVAL (ERROR_BASE_NO + 22)
+#endif
+
+#define ENFILE (ERROR_BASE_NO + 23)
+#define EMFILE (ERROR_BASE_NO + 24)
+#define ENOTTY (ERROR_BASE_NO + 25)
+#define ETXTBSY (ERROR_BASE_NO + 26)
+#define EFBIG (ERROR_BASE_NO + 27)
+#define ENOSPC (ERROR_BASE_NO + 28)
+#define ESPIPE (ERROR_BASE_NO + 29)
+#define EROFS (ERROR_BASE_NO + 30)
+#define EMLINK (ERROR_BASE_NO + 31)
+#define EPIPE (ERROR_BASE_NO + 32)
+
+#ifndef EDOM
+#define EDOM (ERROR_BASE_NO + 33)
+#endif
+
+#ifndef ERANGE
+#define ERANGE (ERROR_BASE_NO + 34)
+#endif
+
+#define EDEADLK (ERROR_BASE_NO + 35)
+#define ENAMETOOLONG (ERROR_BASE_NO + 36)
+#define ENOLCK (ERROR_BASE_NO + 37)
+#define ENOSYS (ERROR_BASE_NO + 38)
+#define ENOTEMPTY (ERROR_BASE_NO + 39)
+#define ELOOP (ERROR_BASE_NO + 40)
#define EWOULDBLOCK EAGAIN
-#define ENOMSG 42
-#define EIDRM 43
-#define ECHRNG 44
-#define EL2NSYNC 45
-#define EL3HLT 46
-#define EL3RST 47
-#define ELNRNG 48
-#define EUNATCH 49
-#define ENOCSI 50
-#define EL2HLT 51
-#define EBADE 52
-#define EBADR 53
-#define EXFULL 54
-#define ENOANO 55
-#define EBADRQC 56
-#define EBADSLT 57
+#define ENOMSG (ERROR_BASE_NO + 42)
+#define EIDRM (ERROR_BASE_NO + 43)
+#define ECHRNG (ERROR_BASE_NO + 44)
+#define EL2NSYNC (ERROR_BASE_NO + 45)
+#define EL3HLT (ERROR_BASE_NO + 46)
+#define EL3RST (ERROR_BASE_NO + 47)
+#define ELNRNG (ERROR_BASE_NO + 48)
+#define EUNATCH (ERROR_BASE_NO + 49)
+#define ENOCSI (ERROR_BASE_NO + 50)
+#define EL2HLT (ERROR_BASE_NO + 51)
+#define EBADE (ERROR_BASE_NO + 52)
+#define EBADR (ERROR_BASE_NO + 53)
+#define EXFULL (ERROR_BASE_NO + 54)
+#define ENOANO (ERROR_BASE_NO + 55)
+#define EBADRQC (ERROR_BASE_NO + 56)
+#define EBADSLT (ERROR_BASE_NO + 57)
#define EDEADLOCK EDEADLK
-#define EBFONT 59
-#define ENOSTR 60
-#define ENODATA 61
-#define ETIME 62
-#define ENOSR 63
-#define ENONET 64
-#define ENOPKG 65
-#define EREMOTE 66
-#define ENOLINK 67
-#define EADV 68
-#define ESRMNT 69
-#define ECOMM 70
-#define EPROTO 71
-#define EMULTIHOP 72
-#define EDOTDOT 73
-#define EBADMSG 74
-#define EOVERFLOW 75
-#define ENOTUNIQ 76
-#define EBADFD 77
-#define EREMCHG 78
-#define ELIBACC 79
-#define ELIBBAD 80
-#define ELIBSCN 81
-#define ELIBMAX 82
-#define ELIBEXEC 83
-#define EILSEQ 84
-#define ERESTART 85
-#define ESTRPIPE 86
-#define EUSERS 87
-#define ENOTSOCK 88
-#define EDESTADDRREQ 89
-#define EMSGSIZE 90
-#define EPROTOTYPE 91
-#define ENOPROTOOPT 92
-#define EPROTONOSUPPORT 93
-#define ESOCKTNOSUPPORT 94
-#define EOPNOTSUPP 95
-#define ENOTSUP EOPNOTSUPP
-#define EPFNOSUPPORT 96
-#define EAFNOSUPPORT 97
-#define EADDRINUSE 98
-#define EADDRNOTAVAIL 99
-#define ENETDOWN 100
-#define ENETUNREACH 101
-#define ENETRESET 102
-#define ECONNABORTED 103
-#define ECONNRESET 104
-#define ENOBUFS 105
-#define EISCONN 106
-#define ENOTCONN 107
-#define ESHUTDOWN 108
-#define ETOOMANYREFS 109
-#define ETIMEDOUT 110
-#define ECONNREFUSED 111
-#define EHOSTDOWN 112
-#define EHOSTUNREACH 113
-#define EALREADY 114
-#define EINPROGRESS 115
-#define ESTALE 116
-#define EUCLEAN 117
-#define ENOTNAM 118
-#define ENAVAIL 119
-#define EISNAM 120
-#define EREMOTEIO 121
-#define EDQUOT 122
-#define ENOMEDIUM 123
-#define EMEDIUMTYPE 124
-#define ECANCELED 125
-#define ENOKEY 126
-#define EKEYEXPIRED 127
-#define EKEYREVOKED 128
-#define EKEYREJECTED 129
-#define EOWNERDEAD 130
-#define ENOTRECOVERABLE 131
-#define ERFKILL 132
-#define EHWPOISON 133
+#define EBFONT (ERROR_BASE_NO + 59)
+#define ENOSTR (ERROR_BASE_NO + 60)
+#define ENODATA (ERROR_BASE_NO + 61)
+#define ETIME (ERROR_BASE_NO + 62)
+#define ENOSR (ERROR_BASE_NO + 63)
+#define ENONET (ERROR_BASE_NO + 64)
+#define ENOPKG (ERROR_BASE_NO + 65)
+#define EREMOTE (ERROR_BASE_NO + 66)
+#define ENOLINK (ERROR_BASE_NO + 67)
+#define EADV (ERROR_BASE_NO + 68)
+#define ESRMNT (ERROR_BASE_NO + 69)
+#define ECOMM (ERROR_BASE_NO + 70)
+#define EPROTO (ERROR_BASE_NO + 71)
+#define EMULTIHOP (ERROR_BASE_NO + 72)
+#define EDOTDOT (ERROR_BASE_NO + 73)
+#define EBADMSG (ERROR_BASE_NO + 74)
+#define EOVERFLOW (ERROR_BASE_NO + 75)
+#define ENOTUNIQ (ERROR_BASE_NO + 76)
+#define EBADFD (ERROR_BASE_NO + 77)
+#define EREMCHG (ERROR_BASE_NO + 78)
+#define ELIBACC (ERROR_BASE_NO + 79)
+#define ELIBBAD (ERROR_BASE_NO + 80)
+#define ELIBSCN (ERROR_BASE_NO + 81)
+#define ELIBMAX (ERROR_BASE_NO + 82)
+#define ELIBEXEC (ERROR_BASE_NO + 83)
+
+#ifndef EILSEQ
+#define EILSEQ (ERROR_BASE_NO + 84)
+#endif
+
+#define ERESTART (ERROR_BASE_NO + 85)
+#define ESTRPIPE (ERROR_BASE_NO + 86)
+#define EUSERS (ERROR_BASE_NO + 87)
+#define ENOTSOCK (ERROR_BASE_NO + 88)
+#define EDESTADDRREQ (ERROR_BASE_NO + 89)
+#define EMSGSIZE (ERROR_BASE_NO + 90)
+#define EPROTOTYPE (ERROR_BASE_NO + 91)
+#define ENOPROTOOPT (ERROR_BASE_NO + 92)
+#define EPROTONOSUPPORT (ERROR_BASE_NO + 93)
+#define ESOCKTNOSUPPORT (ERROR_BASE_NO + 94)
+#define EOPNOTSUPP (ERROR_BASE_NO + 95)
+#define ENOTSUP EOPNOTSUPP
+#define EPFNOSUPPORT (ERROR_BASE_NO + 96)
+#define EAFNOSUPPORT (ERROR_BASE_NO + 97)
+#define EADDRINUSE (ERROR_BASE_NO + 98)
+#define EADDRNOTAVAIL (ERROR_BASE_NO + 99)
+#define ENETDOWN (ERROR_BASE_NO + 100)
+#define ENETUNREACH (ERROR_BASE_NO + 101)
+#define ENETRESET (ERROR_BASE_NO + 102)
+#define ECONNABORTED (ERROR_BASE_NO + 103)
+#define ECONNRESET (ERROR_BASE_NO + 104)
+#define ENOBUFS (ERROR_BASE_NO + 105)
+#define EISCONN (ERROR_BASE_NO + 106)
+#define ENOTCONN (ERROR_BASE_NO + 107)
+#define ESHUTDOWN (ERROR_BASE_NO + 108)
+#define ETOOMANYREFS (ERROR_BASE_NO + 109)
+#define ETIMEDOUT (ERROR_BASE_NO + 110)
+#define ECONNREFUSED (ERROR_BASE_NO + 111)
+#define EHOSTDOWN (ERROR_BASE_NO + 112)
+#define EHOSTUNREACH (ERROR_BASE_NO + 113)
+#define EALREADY (ERROR_BASE_NO + 114)
+#define EINPROGRESS (ERROR_BASE_NO + 115)
+#define ESTALE (ERROR_BASE_NO + 116)
+#define EUCLEAN (ERROR_BASE_NO + 117)
+#define ENOTNAM (ERROR_BASE_NO + 118)
+#define ENAVAIL (ERROR_BASE_NO + 119)
+#define EISNAM (ERROR_BASE_NO + 120)
+#define EREMOTEIO (ERROR_BASE_NO + 121)
+#define EDQUOT (ERROR_BASE_NO + 122)
+#define ENOMEDIUM (ERROR_BASE_NO + 123)
+#define EMEDIUMTYPE (ERROR_BASE_NO + 124)
+#define ECANCELED (ERROR_BASE_NO + 125)
+#define ENOKEY (ERROR_BASE_NO + 126)
+#define EKEYEXPIRED (ERROR_BASE_NO + 127)
+#define EKEYREVOKED (ERROR_BASE_NO + 128)
+#define EKEYREJECTED (ERROR_BASE_NO + 129)
+#define EOWNERDEAD (ERROR_BASE_NO + 130)
+#define ENOTRECOVERABLE (ERROR_BASE_NO + 131)
+#define ERFKILL (ERROR_BASE_NO + 132)
+#define EHWPOISON (ERROR_BASE_NO + 133)
+
#endif
#endif
diff --git a/include/libc/libc_signal.h b/include/libc/libc_signal.h
index b592b8227e..898fe13f43 100644
--- a/include/libc/libc_signal.h
+++ b/include/libc/libc_signal.h
@@ -2,10 +2,6 @@
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
- */
-
-/*
- * File : libc_signal.h
*
* Change Logs:
* Date Author Notes
@@ -28,7 +24,7 @@ extern "C" {
NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
sigev_notify_attributes to the sigevent structure. */
-union sigval
+union sigval
{
int sival_int; /* Integer signal value */
void *sival_ptr; /* Pointer signal value */
@@ -67,29 +63,30 @@ typedef struct siginfo siginfo_t;
#define SI_MESGQ 0x05 /* Signal generated by arrival of a
message on an empty message queue. */
-#ifdef RT_USING_NEWLIB
-#include <sys/signal.h>
+#if !defined(RT_USING_NEWLIB)
+typedef void (*_sig_func_ptr)(int);
+typedef unsigned long sigset_t;
#endif
-#if defined(__CC_ARM) || defined(__CLANG_ARM)
#include <signal.h>
-typedef unsigned long sigset_t;
+
+#if defined(__CC_ARM) || defined(__CLANG_ARM)
#define SIGHUP 1
-// #define SIGINT 2
+/* #define SIGINT 2 */
#define SIGQUIT 3
-// #define SIGILL 4
+/* #define SIGILL 4 */
#define SIGTRAP 5
-// #define SIGABRT 6
+/* #define SIGABRT 6 */
#define SIGEMT 7
-// #define SIGFPE 8
+/* #define SIGFPE 8 */
#define SIGKILL 9
#define SIGBUS 10
-// #define SIGSEGV 11
+/* #define SIGSEGV 11 */
#define SIGSYS 12
#define SIGPIPE 13
#define SIGALRM 14
-// #define SIGTERM 15
+/* #define SIGTERM 15 */
#define SIGURG 16
#define SIGSTOP 17
#define SIGTSTP 18
@@ -99,8 +96,8 @@ typedef unsigned long sigset_t;
#define SIGTTOU 22
#define SIGPOLL 23
#define SIGWINCH 24
-// #define SIGUSR1 25
-// #define SIGUSR2 26
+/* #define SIGUSR1 25 */
+/* #define SIGUSR2 26 */
#define SIGRTMIN 27
#define SIGRTMAX 31
#define NSIG 32
@@ -109,9 +106,7 @@ typedef unsigned long sigset_t;
#define SIG_BLOCK 1 /* set of signals to block */
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
-typedef void (*_sig_func_ptr)(int);
-
-struct sigaction
+struct sigaction
{
_sig_func_ptr sa_handler;
sigset_t sa_mask;
@@ -128,15 +123,13 @@ int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
#elif defined(__IAR_SYSTEMS_ICC__)
-#include <signal.h>
-typedef unsigned long sigset_t;
#define SIGHUP 1
#define SIGINT 2
#define SIGQUIT 3
#define SIGILL 4
#define SIGTRAP 5
-// #define SIGABRT 6
+/* #define SIGABRT 6 */
#define SIGEMT 7
#define SIGFPE 8
#define SIGKILL 9
@@ -165,9 +158,7 @@ typedef unsigned long sigset_t;
#define SIG_BLOCK 1 /* set of signals to block */
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
-typedef void (*_sig_func_ptr)(int);
-
-struct sigaction
+struct sigaction
{
_sig_func_ptr sa_handler;
sigset_t sa_mask;
diff --git a/include/rtdbg.h b/include/rtdbg.h
index d19a191227..be5a57f312 100644
--- a/include/rtdbg.h
+++ b/include/rtdbg.h
@@ -18,20 +18,13 @@
* In your C/C++ file, enable/disable DEBUG_ENABLE macro, and then include this
* header file.
*
- * #define DBG_SECTION_NAME "MOD"
- * #define DBG_ENABLE // enable debug macro
- * #define DBG_LEVEL DBG_INFO
- * #include <rtdbg.h> // must after of DEBUG_ENABLE or some other options
+ * #define DBG_TAG "MOD_TAG"
+ * #define DBG_LVL DBG_INFO
+ * #include <rtdbg.h> // must after of DBG_LVL, DBG_TAG or other options
*
- * Then in your C/C++ file, you can use dbg_log macro to print out logs:
- * dbg_log(DBG_INFO, "this is a log!\n");
- *
- * Or if you want to using the simple API, you can
+ * Then in your C/C++ file, you can use LOG_X macro to print out logs:
* LOG_D("this is a debug log!");
* LOG_E("this is a error log!");
- *
- * If you want to use different color for different kinds log, you can
- * #define DBG_COLOR
*/
#ifndef RT_DBG_H__
@@ -39,21 +32,54 @@
#include <rtconfig.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* the debug log will force enable when RT_DEBUG macro is defined */
+#if defined(RT_DEBUG) && !defined(DBG_ENABLE)
+#define DBG_ENABLE
+#endif
+
+/* it will force output color log when RT_DEBUG_COLOR macro is defined */
+#if defined(RT_DEBUG_COLOR) && !defined(DBG_COLOR)
+#define DBG_COLOR
+#endif
+
+#if defined(RT_USING_ULOG)
+/* using ulog compatible with rtdbg */
+#include <ulog.h>
+#else
+
/* DEBUG level */
#define DBG_ERROR 0
#define DBG_WARNING 1
#define DBG_INFO 2
#define DBG_LOG 3
+#ifdef DBG_TAG
+#ifndef DBG_SECTION_NAME
+#define DBG_SECTION_NAME DBG_TAG
+#endif
+#else
+/* compatible with old version */
#ifndef DBG_SECTION_NAME
#define DBG_SECTION_NAME "DBG"
#endif
+#endif /* DBG_TAG */
#ifdef DBG_ENABLE
+#ifdef DBG_LVL
+#ifndef DBG_LEVEL
+#define DBG_LEVEL DBG_LVL
+#endif
+#else
+/* compatible with old version */
#ifndef DBG_LEVEL
#define DBG_LEVEL DBG_WARNING
#endif
+#endif /* DBG_LVL */
/*
* The color for terminal (foreground)
@@ -69,19 +95,21 @@
#ifdef DBG_COLOR
#define _DBG_COLOR(n) rt_kprintf("\033["#n"m")
#define _DBG_LOG_HDR(lvl_name, color_n) \
- rt_kprintf("\033["#color_n"m["lvl_name"/"DBG_SECTION_NAME"] ")
+ rt_kprintf("\033["#color_n"m[" lvl_name "/" DBG_SECTION_NAME "] ")
#define _DBG_LOG_X_END \
rt_kprintf("\033[0m\n")
#else
#define _DBG_COLOR(n)
#define _DBG_LOG_HDR(lvl_name, color_n) \
- rt_kprintf("["lvl_name"/"DBG_SECTION_NAME"] ")
+ rt_kprintf("[" lvl_name "/" DBG_SECTION_NAME "] ")
#define _DBG_LOG_X_END \
rt_kprintf("\n")
#endif /* DBG_COLOR */
/*
* static debug routine
+ * NOTE: This is a NOT RECOMMENDED API. Please using LOG_X API.
+ * It will be DISCARDED later. Because it will take up more resources.
*/
#define dbg_log(level, fmt, ...) \
if ((level) <= DBG_LEVEL) \
@@ -104,23 +132,6 @@
__FUNCTION__, __LINE__); \
}
-#define dbg_enter \
- if ((DBG_LEVEL) <= DBG_LOG){ \
- _DBG_COLOR(32); \
- rt_kprintf(DBG_SECTION_NAME " Enter %s\n", \
- __FUNCTION__); \
- _DBG_COLOR(0); \
- }
-
-#define dbg_exit \
- if ((DBG_LEVEL) <= DBG_LOG){ \
- _DBG_COLOR(32); \
- rt_kprintf(DBG_SECTION_NAME " Exit %s:%d\n", \
- __FUNCTION__); \
- _DBG_COLOR(0); \
- }
-
-
#define dbg_log_line(lvl, color_n, fmt, ...) \
do \
{ \
@@ -167,4 +178,10 @@
#define LOG_RAW(...) dbg_raw(__VA_ARGS__)
+#endif /* defined(RT_USING_ULOG) && define(DBG_ENABLE) */
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* RT_DBG_H__ */
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 */
diff --git a/include/rthw.h b/include/rthw.h
index c6af392e62..89877faf90 100644
--- a/include/rthw.h
+++ b/include/rthw.h
@@ -10,6 +10,8 @@
* 2006-09-24 Bernard add rt_hw_context_switch_to declaration
* 2012-12-29 Bernard add rt_hw_exception_install declaration
* 2017-10-17 Hichard add some micros
+ * 2018-11-17 Jesven add rt_hw_spinlock_t
+ * add smp support
*/
#ifndef __RT_HW_H__
@@ -35,7 +37,7 @@ extern "C" {
#endif
#ifndef RT_CPU_CACHE_LINE_SZ
-#define RT_CPU_CACHE_LINE_SZ 32
+#define RT_CPU_CACHE_LINE_SZ 32
#endif
enum RT_HW_CACHE_OPS
@@ -90,22 +92,37 @@ void rt_hw_interrupt_umask(int vector);
rt_isr_handler_t rt_hw_interrupt_install(int vector,
rt_isr_handler_t handler,
void *param,
- char *name);
+ const char *name);
+#ifdef RT_USING_SMP
+rt_base_t rt_hw_local_irq_disable();
+void rt_hw_local_irq_enable(rt_base_t level);
+
+#define rt_hw_interrupt_disable rt_cpus_lock
+#define rt_hw_interrupt_enable rt_cpus_unlock
+
+#else
rt_base_t rt_hw_interrupt_disable(void);
void rt_hw_interrupt_enable(rt_base_t level);
+#endif /*RT_USING_SMP*/
/*
* Context interfaces
*/
-void rt_hw_context_switch(rt_uint32_t from, rt_uint32_t to);
-void rt_hw_context_switch_to(rt_uint32_t to);
-void rt_hw_context_switch_interrupt(rt_uint32_t from, rt_uint32_t to);
+#ifdef RT_USING_SMP
+void rt_hw_context_switch(rt_ubase_t from, rt_ubase_t to, struct rt_thread *to_thread);
+void rt_hw_context_switch_to(rt_ubase_t to, struct rt_thread *to_thread);
+void rt_hw_context_switch_interrupt(void *context, rt_ubase_t from, rt_ubase_t to, struct rt_thread *to_thread);
+#else
+void rt_hw_context_switch(rt_ubase_t from, rt_ubase_t to);
+void rt_hw_context_switch_to(rt_ubase_t to);
+void rt_hw_context_switch_interrupt(rt_ubase_t from, rt_ubase_t to);
+#endif /*RT_USING_SMP*/
void rt_hw_console_output(const char *str);
-void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry);
-void rt_hw_show_memory(rt_uint32_t addr, rt_uint32_t size);
+void rt_hw_backtrace(rt_uint32_t *fp, rt_ubase_t thread_entry);
+void rt_hw_show_memory(rt_uint32_t addr, rt_size_t size);
/*
* Exception interfaces
@@ -117,6 +134,61 @@ void rt_hw_exception_install(rt_err_t (*exception_handle)(void *context));
*/
void rt_hw_us_delay(rt_uint32_t us);
+#ifdef RT_USING_SMP
+typedef union {
+ unsigned long slock;
+ struct __arch_tickets {
+ unsigned short owner;
+ unsigned short next;
+ } tickets;
+} rt_hw_spinlock_t;
+
+struct rt_spinlock
+{
+ rt_hw_spinlock_t lock;
+};
+
+void rt_hw_spin_lock_init(rt_hw_spinlock_t *lock);
+void rt_hw_spin_lock(rt_hw_spinlock_t *lock);
+void rt_hw_spin_unlock(rt_hw_spinlock_t *lock);
+
+int rt_hw_cpu_id(void);
+
+extern rt_hw_spinlock_t _cpus_lock;
+extern rt_hw_spinlock_t _rt_critical_lock;
+
+#define __RT_HW_SPIN_LOCK_INITIALIZER(lockname) {0}
+
+#define __RT_HW_SPIN_LOCK_UNLOCKED(lockname) \
+ (rt_hw_spinlock_t) __RT_HW_SPIN_LOCK_INITIALIZER(lockname)
+
+#define RT_DEFINE_SPINLOCK(x) rt_hw_spinlock_t x = __RT_HW_SPIN_LOCK_UNLOCKED(x)
+#define RT_DECLARE_SPINLOCK(x)
+
+/**
+ * ipi function
+ */
+void rt_hw_ipi_send(int ipi_vector, unsigned int cpu_mask);
+
+/**
+ * boot secondary cpu
+ */
+void rt_hw_secondary_cpu_up(void);
+
+/**
+ * secondary cpu idle function
+ */
+void rt_hw_secondary_cpu_idle_exec(void);
+#else
+
+#define RT_DEFINE_SPINLOCK(x)
+#define RT_DECLARE_SPINLOCK(x) rt_ubase_t x
+
+#define rt_hw_spin_lock(lock) *(lock) = rt_hw_interrupt_disable()
+#define rt_hw_spin_unlock(lock) rt_hw_interrupt_enable(*(lock))
+
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/include/rtservice.h b/include/rtservice.h
index 3b6fc94c92..81d6c71f17 100644
--- a/include/rtservice.h
+++ b/include/rtservice.h
@@ -24,7 +24,7 @@ extern "C" {
* @addtogroup KernelService
*/
-/*@{*/
+/**@{*/
/**
* rt_container_of - return the member address of ptr, if the type of ptr is the
@@ -306,7 +306,7 @@ rt_inline int rt_slist_isempty(rt_slist_t *l)
#define rt_slist_tail_entry(ptr, type, member) \
rt_slist_entry(rt_slist_tail(ptr), type, member)
-/*@}*/
+/**@}*/
#ifdef __cplusplus
}
diff --git a/include/rtthread.h b/include/rtthread.h
index fc5029a220..70d4f38896 100644
--- a/include/rtthread.h
+++ b/include/rtthread.h
@@ -13,6 +13,7 @@
* 2010-04-11 yi.qiu add module feature
* 2013-06-24 Bernard add rt_kprintf re-define when not use RT_USING_CONSOLE.
* 2016-08-09 ArdaFu add new thread and interrupt hook.
+ * 2018-11-22 Jesven add all cpu's lock and ipi handler
*/
#ifndef __RT_THREAD_H__
@@ -74,7 +75,7 @@ void rt_system_tick_init(void);
rt_tick_t rt_tick_get(void);
void rt_tick_set(rt_tick_t tick);
void rt_tick_increase(void);
-int rt_tick_from_millisecond(rt_int32_t ms);
+rt_tick_t rt_tick_from_millisecond(rt_int32_t ms);
void rt_system_timer_init(void);
void rt_system_timer_thread_init(void);
@@ -100,7 +101,8 @@ rt_tick_t rt_timer_next_timeout_tick(void);
void rt_timer_check(void);
#ifdef RT_USING_HOOK
-void rt_timer_timeout_sethook(void (*hook)(struct rt_timer *timer));
+void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer));
+void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer));
#endif
/**@}*/
@@ -136,6 +138,7 @@ rt_err_t rt_thread_delete(rt_thread_t thread);
rt_err_t rt_thread_yield(void);
rt_err_t rt_thread_delay(rt_tick_t tick);
+rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick);
rt_err_t rt_thread_mdelay(rt_int32_t ms);
rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg);
rt_err_t rt_thread_suspend(rt_thread_t thread);
@@ -183,6 +186,10 @@ rt_uint16_t rt_critical_level(void);
void rt_scheduler_sethook(void (*hook)(rt_thread_t from, rt_thread_t to));
#endif
+#ifdef RT_USING_SMP
+void rt_scheduler_ipi_handler(int vector, void *param);
+#endif
+
/**@}*/
/**
@@ -256,7 +263,7 @@ void rt_page_free(void *addr, rt_size_t npages);
#endif
#ifdef RT_USING_HOOK
-void rt_malloc_sethook(void (*hook)(void *ptr, rt_uint32_t size));
+void rt_malloc_sethook(void (*hook)(void *ptr, rt_size_t size));
void rt_free_sethook(void (*hook)(void *ptr));
#endif
@@ -269,9 +276,9 @@ void rt_free_sethook(void (*hook)(void *ptr));
rt_err_t rt_memheap_init(struct rt_memheap *memheap,
const char *name,
void *start_addr,
- rt_uint32_t size);
+ rt_size_t size);
rt_err_t rt_memheap_detach(struct rt_memheap *heap);
-void *rt_memheap_alloc(struct rt_memheap *heap, rt_uint32_t size);
+void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size);
void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize);
void rt_memheap_free(void *ptr);
#endif
@@ -347,11 +354,11 @@ rt_err_t rt_mb_detach(rt_mailbox_t mb);
rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag);
rt_err_t rt_mb_delete(rt_mailbox_t mb);
-rt_err_t rt_mb_send(rt_mailbox_t mb, rt_uint32_t value);
+rt_err_t rt_mb_send(rt_mailbox_t mb, rt_ubase_t value);
rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
- rt_uint32_t value,
+ rt_ubase_t value,
rt_int32_t timeout);
-rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_uint32_t *value, rt_int32_t timeout);
+rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout);
rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg);
#endif
@@ -372,8 +379,12 @@ rt_mq_t rt_mq_create(const char *name,
rt_uint8_t flag);
rt_err_t rt_mq_delete(rt_mq_t mq);
-rt_err_t rt_mq_send(rt_mq_t mq, void *buffer, rt_size_t size);
-rt_err_t rt_mq_urgent(rt_mq_t mq, void *buffer, rt_size_t size);
+rt_err_t rt_mq_send(rt_mq_t mq, const void *buffer, rt_size_t size);
+rt_err_t rt_mq_send_wait(rt_mq_t mq,
+ const void *buffer,
+ rt_size_t size,
+ rt_int32_t timeout);
+rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size);
rt_err_t rt_mq_recv(rt_mq_t mq,
void *buffer,
rt_size_t size,
@@ -381,6 +392,27 @@ rt_err_t rt_mq_recv(rt_mq_t mq,
rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg);
#endif
+/*
+ * spinlock
+ */
+#ifdef RT_USING_SMP
+struct rt_spinlock;
+
+void rt_spin_lock_init(struct rt_spinlock *lock);
+void rt_spin_lock(struct rt_spinlock *lock);
+void rt_spin_unlock(struct rt_spinlock *lock);
+rt_base_t rt_spin_lock_irqsave(struct rt_spinlock *lock);
+void rt_spin_unlock_irqrestore(struct rt_spinlock *lock, rt_base_t level);
+
+#else
+#define rt_spin_lock_init(lock) /* nothing */
+#define rt_spin_lock(lock) rt_enter_critical()
+#define rt_spin_unlock(lock) rt_exit_critical()
+#define rt_spin_lock_irqsave(lock) rt_hw_interrupt_disable()
+#define rt_spin_unlock_irqrestore(lock, level) rt_hw_interrupt_enable(level)
+
+#endif
+
/**@}*/
#ifdef RT_USING_DEVICE
@@ -438,6 +470,20 @@ rt_err_t rt_device_control(rt_device_t dev, int cmd, void *arg);
void rt_interrupt_enter(void);
void rt_interrupt_leave(void);
+#ifdef RT_USING_SMP
+
+/*
+ * smp cpus lock service
+ */
+
+rt_base_t rt_cpus_lock(void);
+void rt_cpus_unlock(rt_base_t level);
+
+struct rt_cpu *rt_cpu_self(void);
+struct rt_cpu *rt_cpu_index(int index);
+
+#endif
+
/*
* the number of nested interrupts.
*/
@@ -496,6 +542,7 @@ void *rt_memcpy(void *dest, const void *src, rt_ubase_t n);
rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count);
rt_int32_t rt_strcmp(const char *cs, const char *ct);
rt_size_t rt_strlen(const char *src);
+rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen);
char *rt_strdup(const char *s);
#if defined(__CC_ARM) || defined(__CLANG_ARM)
/* leak strdup interface */
@@ -507,7 +554,7 @@ rt_int32_t rt_sscanf(const char *buf, const char *fmt, ...);
char *rt_strncpy(char *dest, const char *src, rt_ubase_t n);
void *rt_memmove(void *dest, const void *src, rt_ubase_t n);
rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count);
-rt_uint32_t rt_strcasecmp(const char *a, const char *b);
+rt_int32_t rt_strcasecmp(const char *a, const char *b);
void rt_show_version(void);