diff options
| author | yangjie11 <[email protected]> | 2018-11-28 19:02:11 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-11-28 19:02:11 +0800 |
| commit | 1a7f95f92b84b0a3acd6243cb2a658b4f9b6f1ac (patch) | |
| tree | 3b90c3e4b7ced83ce239ae8df020926eaf74d7de /include/rtdef.h | |
| parent | 4a43d3cdae1b731dcf51d3531048c51fd4142516 (diff) | |
| parent | d4469fe7d83d08913d096dc6d75a750dd854c0cc (diff) | |
Merge pull request #1 from RT-Thread/master
test
Diffstat (limited to 'include/rtdef.h')
| -rw-r--r-- | include/rtdef.h | 178 |
1 files changed, 85 insertions, 93 deletions
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" |
