summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authoryangjie11 <[email protected]>2018-11-28 19:02:11 +0800
committerGitHub <[email protected]>2018-11-28 19:02:11 +0800
commit1a7f95f92b84b0a3acd6243cb2a658b4f9b6f1ac (patch)
tree3b90c3e4b7ced83ce239ae8df020926eaf74d7de /include
parent4a43d3cdae1b731dcf51d3531048c51fd4142516 (diff)
parentd4469fe7d83d08913d096dc6d75a750dd854c0cc (diff)
Merge pull request #1 from RT-Thread/master
test
Diffstat (limited to 'include')
-rw-r--r--include/libc/libc_dirent.h6
-rw-r--r--include/libc/libc_errno.h22
-rw-r--r--include/libc/libc_fcntl.h22
-rw-r--r--include/libc/libc_fdset.h22
-rw-r--r--include/libc/libc_ioctl.h22
-rw-r--r--include/libc/libc_signal.h38
-rw-r--r--include/libc/libc_stat.h6
-rw-r--r--include/rtdbg.h96
-rw-r--r--include/rtdebug.h18
-rw-r--r--include/rtdef.h178
-rw-r--r--include/rthw.h86
-rw-r--r--include/rtlibc.h20
-rw-r--r--include/rtm.h18
-rw-r--r--include/rtservice.h36
-rw-r--r--include/rtthread.h88
15 files changed, 311 insertions, 367 deletions
diff --git a/include/libc/libc_dirent.h b/include/libc/libc_dirent.h
index 5bcbc32478..c3a19878ec 100644
--- a/include/libc/libc_dirent.h
+++ b/include/libc/libc_dirent.h
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
#ifndef LIBC_DIRENT_H__
#define LIBC_DIRENT_H__
diff --git a/include/libc/libc_errno.h b/include/libc/libc_errno.h
index b4f4410595..82ae8cf943 100644
--- a/include/libc/libc_errno.h
+++ b/include/libc/libc_errno.h
@@ -1,21 +1,11 @@
/*
- * File : libc_errno.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2017, RT-Thread Development Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/*
+ * File : libc_errno.h
*
* Change Logs:
* Date Author Notes
diff --git a/include/libc/libc_fcntl.h b/include/libc/libc_fcntl.h
index 7c5a075a97..1b7c69b1f4 100644
--- a/include/libc/libc_fcntl.h
+++ b/include/libc/libc_fcntl.h
@@ -1,21 +1,11 @@
/*
- * File : libc_fcntl.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2017 - 2018, RT-Thread Development Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/*
+ * File : libc_fcntl.h
*
* Change Logs:
* Date Author Notes
diff --git a/include/libc/libc_fdset.h b/include/libc/libc_fdset.h
index 74c4ba1cb2..ecd965cd22 100644
--- a/include/libc/libc_fdset.h
+++ b/include/libc/libc_fdset.h
@@ -1,21 +1,11 @@
/*
- * File : libc_errno.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2017, RT-Thread Development Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/*
+ * File : libc_errno.h
*
* Change Logs:
* Date Author Notes
diff --git a/include/libc/libc_ioctl.h b/include/libc/libc_ioctl.h
index b61866a524..ef5a5257a8 100644
--- a/include/libc/libc_ioctl.h
+++ b/include/libc/libc_ioctl.h
@@ -1,21 +1,11 @@
/*
- * File : libc_ioctl.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2017, RT-Thread Development Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/*
+ * File : libc_ioctl.h
*
* Change Logs:
* Date Author Notes
diff --git a/include/libc/libc_signal.h b/include/libc/libc_signal.h
index d3050bfb54..71f8de125d 100644
--- a/include/libc/libc_signal.h
+++ b/include/libc/libc_signal.h
@@ -1,21 +1,7 @@
/*
- * File : libc_signal.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2017, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -81,25 +67,25 @@ typedef struct siginfo siginfo_t;
#include <sys/signal.h>
#endif
-#ifdef __CC_ARM
+#if defined(__CC_ARM) || defined(__CLANG_ARM)
#include <signal.h>
typedef unsigned long sigset_t;
#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
@@ -109,8 +95,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
@@ -146,7 +132,7 @@ typedef unsigned long sigset_t;
#define SIGQUIT 3
#define SIGILL 4
#define SIGTRAP 5
-// #define SIGABRT 6
+/* #define SIGABRT 6 */
#define SIGEMT 7
#define SIGFPE 8
#define SIGKILL 9
diff --git a/include/libc/libc_stat.h b/include/libc/libc_stat.h
index 26752393db..9079d1ef15 100644
--- a/include/libc/libc_stat.h
+++ b/include/libc/libc_stat.h
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
#ifndef LIBC_STAT_H__
#define LIBC_STAT_H__
diff --git a/include/rtdbg.h b/include/rtdbg.h
index f53aba8de9..9036a0cd66 100644
--- a/include/rtdbg.h
+++ b/include/rtdbg.h
@@ -1,21 +1,7 @@
/*
- * File : rtdbg.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2016, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -37,10 +23,7 @@
* #define DBG_LEVEL DBG_INFO
* #include <rtdbg.h> // must after of DEBUG_ENABLE or some 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!");
*
@@ -53,11 +36,16 @@
#include <rtconfig.h>
+#if defined(RT_USING_ULOG) && defined(DBG_ENABLE)
+/* using ulog compatible with rtdbg */
+#include <ulog.h>
+#else
+
/* DEBUG level */
-#define DBG_LOG 0
-#define DBG_INFO 1
-#define DBG_WARNING 2
-#define DBG_ERROR 3
+#define DBG_ERROR 0
+#define DBG_WARNING 1
+#define DBG_INFO 2
+#define DBG_LOG 3
#ifndef DBG_SECTION_NAME
#define DBG_SECTION_NAME "DBG"
@@ -84,17 +72,23 @@
#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"] ")
+#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"] ")
+#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) \
+ if ((level) <= DBG_LEVEL) \
{ \
switch(level) \
{ \
@@ -109,13 +103,13 @@
}
#define dbg_here \
- if ((DBG_LEVEL) >= DBG_LOG){ \
+ if ((DBG_LEVEL) <= DBG_LOG){ \
rt_kprintf(DBG_SECTION_NAME " Here %s:%d\n", \
__FUNCTION__, __LINE__); \
}
#define dbg_enter \
- if ((DBG_LEVEL) >= DBG_LOG){ \
+ if ((DBG_LEVEL) <= DBG_LOG){ \
_DBG_COLOR(32); \
rt_kprintf(DBG_SECTION_NAME " Enter %s\n", \
__FUNCTION__); \
@@ -123,18 +117,22 @@
}
#define dbg_exit \
- if ((DBG_LEVEL) >= DBG_LOG){ \
+ 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(level, ...) \
- dbg_log(level, __VA_ARGS__); \
- if ((level) >= DBG_LEVEL) { \
- rt_kprintf("\n"); \
- }
+
+#define dbg_log_line(lvl, color_n, fmt, ...) \
+ do \
+ { \
+ _DBG_LOG_HDR(lvl, color_n); \
+ rt_kprintf(fmt, ##__VA_ARGS__); \
+ _DBG_LOG_X_END; \
+ } \
+ while (0)
#define dbg_raw(...) rt_kprintf(__VA_ARGS__);
@@ -143,14 +141,36 @@
#define dbg_here
#define dbg_enter
#define dbg_exit
-#define dbg_log_line(level, ...)
+#define dbg_log_line(lvl, color_n, fmt, ...)
#define dbg_raw(...)
+#endif /* DBG_ENABLE */
+
+#if (DBG_LEVEL >= DBG_LOG)
+#define LOG_D(fmt, ...) dbg_log_line("D", 0, fmt, ##__VA_ARGS__)
+#else
+#define LOG_D(...)
+#endif
+
+#if (DBG_LEVEL >= DBG_INFO)
+#define LOG_I(fmt, ...) dbg_log_line("I", 32, fmt, ##__VA_ARGS__)
+#else
+#define LOG_I(...)
+#endif
+
+#if (DBG_LEVEL >= DBG_WARNING)
+#define LOG_W(fmt, ...) dbg_log_line("W", 33, fmt, ##__VA_ARGS__)
+#else
+#define LOG_W(...)
+#endif
+
+#if (DBG_LEVEL >= DBG_ERROR)
+#define LOG_E(fmt, ...) dbg_log_line("E", 31, fmt, ##__VA_ARGS__)
+#else
+#define LOG_E(...)
#endif
-#define LOG_D(...) dbg_log_line(DBG_LOG , __VA_ARGS__)
-#define LOG_I(...) dbg_log_line(DBG_INFO , __VA_ARGS__)
-#define LOG_W(...) dbg_log_line(DBG_WARNING, __VA_ARGS__)
-#define LOG_E(...) dbg_log_line(DBG_ERROR , __VA_ARGS__)
#define LOG_RAW(...) dbg_raw(__VA_ARGS__)
+#endif /* defined(RT_USING_ULOG) && define(DBG_ENABLE) */
+
#endif /* RT_DBG_H__ */
diff --git a/include/rtdebug.h b/include/rtdebug.h
index e403d51e06..b66cd6fc69 100644
--- a/include/rtdebug.h
+++ b/include/rtdebug.h
@@ -1,21 +1,7 @@
/*
- * File : rtdebug.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*/
#ifndef __RTDEBUG_H__
diff --git a/include/rtdef.h b/include/rtdef.h
index f8d90ceadb..253ec36968 100644
--- a/include/rtdef.h
+++ b/include/rtdef.h
@@ -1,21 +1,7 @@
/*
- * File : rtdef.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -36,6 +22,13 @@
* 2018-02-24 Bernard change version number to v3.0.3
* 2018-04-25 Bernard change version number to v3.0.4
* 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
*/
#ifndef __RT_DEF_H__
@@ -55,8 +48,8 @@ extern "C" {
/*@{*/
/* RT-Thread version information */
-#define RT_VERSION 3L /**< major version number */
-#define RT_SUBVERSION 1L /**< minor version number */
+#define RT_VERSION 4L /**< major version number */
+#define RT_SUBVERSION 0L /**< minor version number */
#define RT_REVISION 0L /**< revise version number */
/* RT-Thread version */
@@ -66,13 +59,20 @@ extern "C" {
/* RT-Thread basic data type definitions */
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
-/* 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 */
@@ -96,14 +96,19 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define RT_UINT32_MAX 0xffffffff /**< Maxium number of UINT32 */
#define RT_TICK_MAX RT_UINT32_MAX /**< Maxium number of tick */
+#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
+#define __CLANG_ARM
+#endif
+
/* Compiler Related Definitions */
-#ifdef __CC_ARM /* ARM Compiler */
+#if defined(__CC_ARM) || defined(__CLANG_ARM) /* ARM Compiler */
#include <stdarg.h>
#define SECTION(x) __attribute__((section(x)))
#define RT_UNUSED __attribute__((unused))
#define RT_USED __attribute__((used))
#define ALIGN(n) __attribute__((aligned(n)))
- #define RT_WEAK __weak
+
+ #define RT_WEAK __attribute__((weak))
#define rt_inline static __inline
/* module compiling */
#ifdef RT_USING_MODULE
@@ -128,11 +133,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)))
@@ -189,13 +194,13 @@ typedef int (*init_fn_t)(void);
const char* fn_name;
const init_fn_t fn;
};
- #define INIT_EXPORT(fn, level) \
- const char __rti_##fn##_name[] = #fn; \
- const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn."level) = \
+ #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) = \
{ __rti_##fn##_name, fn};
#else
- #define INIT_EXPORT(fn, level) \
- const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn
+ #define INIT_EXPORT(fn, level) \
+ RT_USED const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn
#endif
#endif
#else
@@ -495,9 +500,40 @@ 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 0x03 /**< 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_IRQ
+#define RT_SCHEDULE_IPI_IRQ 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;
+};
-#ifdef RT_USING_LWP
-struct rt_lwp;
#endif
/**
@@ -529,6 +565,14 @@ 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 */
+#endif /*RT_USING_SMP*/
+
/* priority */
rt_uint8_t current_priority; /**< current priority */
rt_uint8_t init_priority; /**< initialized priority */
@@ -560,11 +604,12 @@ struct rt_thread
void (*cleanup)(struct rt_thread *tid); /**< cleanup function when thread exit */
- rt_uint32_t user_data; /**< private user data beyond this thread */
-
+ /* light weight process if present */
#ifdef RT_USING_LWP
- struct rt_lwp *lwp; /**< if NULL it's a kernel thread */
+ void *lwp;
#endif
+
+ rt_uint32_t user_data; /**< private user data beyond this thread */
};
typedef struct rt_thread *rt_thread_t;
@@ -657,7 +702,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 */
@@ -1021,59 +1066,6 @@ struct rt_device_graphic_ops
/*@}*/
#endif
-#ifdef RT_USING_MODULE
-/**
- * @addtogroup Module
- */
-
-/*@{*/
-
-/*
- * module system
- */
-
-#define RT_MODULE_FLAG_WITHENTRY 0x00 /**< with entry point */
-#define RT_MODULE_FLAG_WITHOUTENTRY 0x01 /**< without entry point */
-
-/**
- * Application Module structure
- */
-struct rt_module
-{
- struct rt_object parent; /**< inherit from object */
-
- rt_uint32_t vstart_addr; /**< VMA base address for the
- first LOAD segment. */
- rt_uint8_t *module_space; /**< module memory space */
-
- void *module_entry; /**< the entry address of module */
- rt_thread_t module_thread; /**< the main thread of module */
-
- rt_uint8_t *module_cmd_line; /**< module command line */
- rt_uint32_t module_cmd_size; /**< the size of module command line */
-
-#ifdef RT_USING_SLAB
- /* module memory allocator */
- void *mem_list; /**< module's free memory list */
- void *page_array; /**< module's using pages */
- rt_uint32_t page_cnt; /**< module's using pages count */
-#endif
-
- rt_uint16_t nref; /**< reference count */
-
- rt_uint16_t nsym; /**< number of symbol in the module */
- struct rt_module_symtab *symtab; /**< module symbol table */
-
- rt_uint32_t user_data; /**< arch data in the module */
-
- void (*module_init)(void);
- void (*module_cleanup)(void);
-};
-typedef struct rt_module *rt_module_t;
-
-/*@}*/
-#endif
-
/* definitions for libc */
#include "rtlibc.h"
diff --git a/include/rthw.h b/include/rthw.h
index d517228083..3fa0ba301c 100644
--- a/include/rthw.h
+++ b/include/rthw.h
@@ -1,21 +1,7 @@
/*
- * File : rthw.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -24,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__
@@ -106,20 +94,35 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector,
void *param,
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
@@ -131,6 +134,47 @@ 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;
+
+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) \
+ (struct rt_hw_spinlock ) __RT_HW_SPIN_LOCK_INITIALIZER(lockname)
+
+#define RT_DEFINE_SPINLOCK(x) struct rt_hw_spinlock x = __RT_HW_SPIN_LOCK_UNLOCKED(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);
+
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/include/rtlibc.h b/include/rtlibc.h
index db5236edb1..b3a548beb1 100644
--- a/include/rtlibc.h
+++ b/include/rtlibc.h
@@ -1,21 +1,7 @@
/*
- * File : rtlibc.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2017, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -35,7 +21,7 @@
#include "libc/libc_signal.h"
#include "libc/libc_fdset.h"
-#if defined(__CC_ARM) || defined(__IAR_SYSTEMS_ICC__)
+#if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__)
typedef signed long off_t;
typedef int mode_t;
#endif
diff --git a/include/rtm.h b/include/rtm.h
index 05419e4420..7e07a2239c 100644
--- a/include/rtm.h
+++ b/include/rtm.h
@@ -1,21 +1,7 @@
/*
- * File : rtm.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*/
#ifndef __RTM_H__
diff --git a/include/rtservice.h b/include/rtservice.h
index 0bfa424338..3b6fc94c92 100644
--- a/include/rtservice.h
+++ b/include/rtservice.h
@@ -1,21 +1,7 @@
/*
- * File : rtservice.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -253,6 +239,13 @@ rt_inline rt_slist_t *rt_slist_first(rt_slist_t *l)
return l->next;
}
+rt_inline rt_slist_t *rt_slist_tail(rt_slist_t *l)
+{
+ while (l->next) l = l->next;
+
+ return l;
+}
+
rt_inline rt_slist_t *rt_slist_next(rt_slist_t *n)
{
return n->next;
@@ -302,6 +295,17 @@ rt_inline int rt_slist_isempty(rt_slist_t *l)
#define rt_slist_first_entry(ptr, type, member) \
rt_slist_entry((ptr)->next, type, member)
+/**
+ * rt_slist_tail_entry - get the tail element from a slist
+ * @ptr: the slist head to take the element from.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the slist_struct within the struct.
+ *
+ * Note, that slist is expected to be not empty.
+ */
+#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 86a1664f83..d2356b8eda 100644
--- a/include/rtthread.h
+++ b/include/rtthread.h
@@ -1,21 +1,7 @@
/*
- * File : rtthread.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -27,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__
@@ -114,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
/**@}*/
@@ -197,6 +185,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
+
/**@}*/
/**
@@ -270,7 +262,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
@@ -283,9 +275,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
@@ -361,11 +353,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
@@ -442,53 +434,29 @@ rt_err_t rt_device_control(rt_device_t dev, int cmd, void *arg);
/**@}*/
#endif
-#ifdef RT_USING_MODULE
-/**
- * @addtogroup Module
+/*
+ * interrupt service
*/
-/**@{*/
-
/*
- * module interface
+ * rt_interrupt_enter and rt_interrupt_leave only can be called by BSP
*/
-rt_module_t rt_module_load(const char *name, void *module_ptr);
-rt_err_t rt_module_unload(rt_module_t module);
-#ifdef RT_USING_DFS
-rt_module_t rt_module_open(const char *filename);
-rt_module_t rt_module_exec_cmd(const char *path, const char *cmd_line, int size);
-#endif
-void *rt_module_malloc(rt_size_t size);
-void *rt_module_realloc(void *ptr, rt_size_t size);
-void rt_module_free(rt_module_t module, void *addr);
-rt_module_t rt_module_self(void);
-rt_module_t rt_module_find(const char *name);
-
-#ifdef RT_USING_HOOK
-void rt_module_load_sethook(void (*hook)(rt_module_t module));
-void rt_module_unload_sethook(void (*hook)(rt_module_t module));
-#endif
+void rt_interrupt_enter(void);
+void rt_interrupt_leave(void);
-void rt_module_init_object_container(struct rt_module *module);
-rt_err_t rt_module_destroy(rt_module_t module);
+#ifdef RT_USING_SMP
/*
- * application module system initialization
+ * smp cpus lock service
*/
-int rt_system_module_init(void);
-/**@}*/
-#endif
+rt_base_t rt_cpus_lock(void);
+void rt_cpus_unlock(rt_base_t level);
-/*
- * interrupt service
- */
+struct rt_cpu *rt_cpu_self(void);
+struct rt_cpu *rt_cpu_index(int index);
-/*
- * rt_interrupt_enter and rt_interrupt_leave only can be called by BSP
- */
-void rt_interrupt_enter(void);
-void rt_interrupt_leave(void);
+#endif
/*
* the number of nested interrupts.
@@ -549,7 +517,7 @@ 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);
char *rt_strdup(const char *s);
-#ifdef __CC_ARM
+#if defined(__CC_ARM) || defined(__CLANG_ARM)
/* leak strdup interface */
char* strdup(const char* str);
#endif