From 302f179c851d3a8c953400ca0d2789546c50491c Mon Sep 17 00:00:00 2001 From: liruncong Date: Tue, 9 Feb 2021 23:18:45 +0800 Subject: 修正rt_thread_delay_until时间不准问题,及错误使用无符号比较问题 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/thread.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/thread.c b/src/thread.c index 0db9dd8e4d..627b7e898e 100644 --- a/src/thread.c +++ b/src/thread.c @@ -585,6 +585,7 @@ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick) { register rt_base_t level; struct rt_thread *thread; + rt_tick_t cur_tick; RT_ASSERT(tick != RT_NULL); @@ -596,15 +597,19 @@ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick) /* disable interrupt */ level = rt_hw_interrupt_disable(); - if (rt_tick_get() - *tick < inc_tick) + cur_tick = rt_tick_get(); + if ((rt_int32_t)(cur_tick - *tick) < (rt_int32_t)inc_tick) { - *tick = *tick + inc_tick - rt_tick_get(); + rt_tick_t left_tick; + + *tick += inc_tick; + left_tick = *tick - cur_tick; /* suspend thread */ rt_thread_suspend(thread); /* reset the timeout of thread timer and start it */ - rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, tick); + rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &left_tick); rt_timer_start(&(thread->thread_timer)); /* enable interrupt */ @@ -620,12 +625,10 @@ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick) } else { + *tick = cur_tick; rt_hw_interrupt_enable(level); } - /* get the wakeup tick */ - *tick = rt_tick_get(); - return RT_EOK; } RTM_EXPORT(rt_thread_delay_until); -- cgit v1.3.1 From 114f305f7725309101a4296410d3f95f567aeb1a Mon Sep 17 00:00:00 2001 From: WillianChan Date: Sat, 20 Feb 2021 15:27:37 +0800 Subject: [kernel][memheap]add memory heap track and memory heap check. Signed-off-by: WillianChan --- src/memheap.c | 199 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 186 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/memheap.c b/src/memheap.c index afa06fb9bf..ebd86b87d6 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -35,6 +35,45 @@ #define RT_MEMHEAP_SIZE RT_ALIGN(sizeof(struct rt_memheap_item), RT_ALIGN_SIZE) #define MEMITEM_SIZE(item) ((rt_ubase_t)item->next - (rt_ubase_t)item - RT_MEMHEAP_SIZE) +#define MEMITEM(ptr) (struct rt_memheap_item*)((rt_uint8_t*)ptr - RT_MEMHEAP_SIZE) + +#ifdef RT_USING_MEMTRACE +rt_inline void rt_memheap_setname(struct rt_memheap_item *item, const char *name) +{ + int index; + rt_uint8_t* ptr; + + ptr = (rt_uint8_t*)&(item->next_free); + for (index = 0; index < sizeof(void*); index ++) + { + if (name[index] == '\0') break; + ptr[index] = name[index]; + } + if (name[index] == '\0') ptr[index] = '\0'; + else + { + ptr = (rt_uint8_t*)&(item->prev_free); + for (index = 0; index < sizeof(void*) && (index + sizeof(void*))< RT_NAME_MAX; index ++) + { + if (name[sizeof(void*) + index] == '\0') break; + ptr[index] = name[sizeof(void*) + index]; + } + + if (name[sizeof(void*) + index] == '\0') ptr[index] = '\0'; + } +} + +void rt_mem_set_tag(void* ptr, const char* name) +{ + struct rt_memheap_item* item; + + if (ptr && name) + { + item = MEMITEM(ptr); + rt_memheap_setname(item, name); + } +} +#endif /* * The initialized memory pool will be: @@ -66,7 +105,7 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap, /* initialize the free list header */ item = &(memheap->free_header); - item->magic = RT_MEMHEAP_MAGIC; + item->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_FREED); item->pool_ptr = memheap; item->next = RT_NULL; item->prev = RT_NULL; @@ -78,7 +117,7 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap, /* initialize the first big memory block */ item = (struct rt_memheap_item *)start_addr; - item->magic = RT_MEMHEAP_MAGIC; + item->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_FREED); item->pool_ptr = memheap; item->next = RT_NULL; item->prev = RT_NULL; @@ -103,7 +142,7 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap, */ item = item->next; /* it's a used memory block */ - item->magic = RT_MEMHEAP_MAGIC | RT_MEMHEAP_USED; + item->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_USED); item->pool_ptr = memheap; item->next = (struct rt_memheap_item *)start_addr; item->prev = (struct rt_memheap_item *)start_addr; @@ -201,7 +240,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size) new_ptr)); /* mark the new block as a memory block and freed. */ - new_ptr->magic = RT_MEMHEAP_MAGIC; + new_ptr->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_FREED); /* put the pool pointer into the new block. */ new_ptr->pool_ptr = heap; @@ -255,7 +294,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size) } /* Mark the allocated block as not available. */ - header_ptr->magic |= RT_MEMHEAP_USED; + header_ptr->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_USED); /* release lock */ rt_sem_release(&(heap->lock)); @@ -376,7 +415,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize) next_ptr->prev)); /* mark the new block as a memory block and freed. */ - next_ptr->magic = RT_MEMHEAP_MAGIC; + next_ptr->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_FREED); /* put the pool pointer into the new block. */ next_ptr->pool_ptr = heap; @@ -441,7 +480,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize) new_ptr)); /* mark the new block as a memory block and freed. */ - new_ptr->magic = RT_MEMHEAP_MAGIC; + new_ptr->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_FREED); /* put the pool pointer into the new block. */ new_ptr->pool_ptr = heap; @@ -512,8 +551,11 @@ void rt_memheap_free(void *ptr) ptr, header_ptr)); /* check magic */ - RT_ASSERT((header_ptr->magic & RT_MEMHEAP_MASK) == RT_MEMHEAP_MAGIC); - RT_ASSERT(header_ptr->magic & RT_MEMHEAP_USED); + if (header_ptr->magic != (RT_MEMHEAP_MAGIC | RT_MEMHEAP_USED)) + { + RT_DEBUG_LOG("bad magic:0x%08x @ memheap\n", header_ptr->magic); + } + RT_ASSERT(header_ptr->magic == (RT_MEMHEAP_MAGIC | RT_MEMHEAP_USED)); /* check whether this block of memory has been over-written. */ RT_ASSERT((header_ptr->next->magic & RT_MEMHEAP_MASK) == RT_MEMHEAP_MAGIC); @@ -533,9 +575,9 @@ void rt_memheap_free(void *ptr) } /* Mark the memory as available. */ - header_ptr->magic &= ~RT_MEMHEAP_USED; + header_ptr->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_FREED); /* Adjust the available number of bytes. */ - heap->available_size = heap->available_size + MEMITEM_SIZE(header_ptr); + heap->available_size += MEMITEM_SIZE(header_ptr); /* Determine if the block can be merged with the previous neighbor. */ if (!RT_MEMHEAP_IS_USED(header_ptr->prev)) @@ -544,7 +586,7 @@ void rt_memheap_free(void *ptr) header_ptr->prev)); /* adjust the available number of bytes. */ - heap->available_size = heap->available_size + RT_MEMHEAP_SIZE; + heap->available_size += RT_MEMHEAP_SIZE; /* yes, merge block with previous neighbor. */ (header_ptr->prev)->next = header_ptr->next; @@ -560,7 +602,7 @@ void rt_memheap_free(void *ptr) if (!RT_MEMHEAP_IS_USED(header_ptr->next)) { /* adjust the available number of bytes. */ - heap->available_size = heap->available_size + RT_MEMHEAP_SIZE; + heap->available_size += RT_MEMHEAP_SIZE; /* merge block with next neighbor. */ new_ptr = header_ptr->next; @@ -595,6 +637,91 @@ void rt_memheap_free(void *ptr) } RTM_EXPORT(rt_memheap_free); +#ifdef RT_USING_FINSH +static void _memheap_dump_tag(struct rt_memheap_item* item) +{ + rt_uint8_t name[2 * sizeof(void*)]; + rt_uint8_t* ptr; + + ptr = (rt_uint8_t*)&(item->next_free); + rt_memcpy(name, ptr, sizeof(void*)); + ptr = (rt_uint8_t*)&(item->prev_free); + rt_memcpy(&name[sizeof(void*)], ptr, sizeof(void*)); + + rt_kprintf("%.*s", 2 * sizeof(void*), name); +} + +int rt_memheap_dump(struct rt_memheap *heap) +{ + struct rt_memheap_item *item, *end; + + if (heap == RT_NULL) return 0; + RT_ASSERT(rt_object_get_type(&heap->parent) == RT_Object_Class_MemHeap); + + rt_kprintf("\n[%.*s] [0x%08x - 0x%08x]->\n", RT_NAME_MAX, heap->parent.name, + (rt_ubase_t)heap->start_addr, (rt_ubase_t)heap->start_addr + heap->pool_size); + rt_kprintf("------------------------------\n"); + + /* lock memheap */ + rt_sem_take(&(heap->lock), RT_WAITING_FOREVER); + item = heap->block_list; + + end = (struct rt_memheap_item *) ((rt_uint8_t *)heap->start_addr + heap->pool_size - RT_MEMHEAP_SIZE); + + /* for each memory block */ + while ((rt_ubase_t)item < ((rt_ubase_t)end)) + { + if (RT_MEMHEAP_IS_USED(item) && ((item->magic & RT_MEMHEAP_MASK) != RT_MEMHEAP_MAGIC)) + rt_kprintf("0x%08x", item + 1); + + if (item->magic == (RT_MEMHEAP_MAGIC | RT_MEMHEAP_USED)) + { + rt_kprintf("0x%08x: %-8d ", item + 1, MEMITEM_SIZE(item)); + _memheap_dump_tag(item); + rt_kprintf("\n"); + } + else + { + rt_kprintf("0x%08x: %-8d \n", item + 1, MEMITEM_SIZE(item)); + } + + item = item->next; + } + rt_sem_release(&(heap->lock)); + + return 0; +} + +int memtrace(void) +{ + int count = rt_object_get_length(RT_Object_Class_MemHeap); + struct rt_memheap **heaps; + + if (count > 0) + { + int index; + extern int list_memheap(void); + + heaps = (struct rt_memheap**)rt_malloc(sizeof(struct rt_memheap*) * count); + if (heaps == RT_NULL) return 0; + + list_memheap(); + + rt_kprintf("memheap header size: %d\n", RT_MEMHEAP_SIZE); + count = rt_object_get_pointers(RT_Object_Class_MemHeap, (rt_object_t*)heaps, count); + for (index = 0; index < count; index++) + { + rt_memheap_dump(heaps[index]); + } + + rt_free(heaps); + } + + return 0; +} +MSH_CMD_EXPORT(memtrace, dump memory trace information); +#endif + #ifdef RT_USING_MEMHEAP_AS_HEAP static struct rt_memheap _heap; @@ -643,6 +770,24 @@ void *rt_malloc(rt_size_t size) } } + +#ifdef RT_USING_MEMTRACE + if (ptr == RT_NULL) + { + RT_DEBUG_LOG("malloc[%d] => NULL", size); + } + else + { + struct rt_memheap_item *item = MEMITEM(ptr); + if (rt_thread_self()) + rt_memheap_setname(item, rt_thread_self()->name); + else + rt_memheap_setname(item, ""); + + RT_DEBUG_LOG("malloc => 0x%08x : %d", ptr, size); + } +#endif + return ptr; } RTM_EXPORT(rt_malloc); @@ -691,6 +836,23 @@ void *rt_realloc(void *rmem, rt_size_t newsize) } } +#ifdef RT_USING_MEMTRACE + if (new_ptr == RT_NULL) + { + RT_DEBUG_LOG("realloc[%d] => NULL", newsize); + } + else + { + struct rt_memheap_item *item = MEMITEM(new_ptr); + if (rt_thread_self()) + rt_memheap_setname(item, rt_thread_self()->name); + else + rt_memheap_setname(item, ""); + + RT_DEBUG_LOG("realloc => 0x%08x : %d", new_ptr, newsize); + } +#endif + return new_ptr; } RTM_EXPORT(rt_realloc); @@ -708,6 +870,17 @@ void *rt_calloc(rt_size_t count, rt_size_t size) rt_memset(ptr, 0, total_size); } +#ifdef RT_USING_MEMTRACE + if (ptr == RT_NULL) + { + RT_DEBUG_LOG("calloc[%d x %d] => NULL", count, size); + } + else + { + RT_DEBUG_LOG("calloc => 0x%08x : %d", ptr, count * size); + } +#endif + return ptr; } RTM_EXPORT(rt_calloc); -- cgit v1.3.1 From e94d90705655a1c73d041f685a07693f59b68822 Mon Sep 17 00:00:00 2001 From: WillianChan Date: Sat, 20 Feb 2021 15:51:49 +0800 Subject: [kernel][memheap]fix RT_DEBUG_LOG errors. Signed-off-by: WillianChan --- src/memheap.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/memheap.c b/src/memheap.c index ebd86b87d6..d9c03079ee 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -553,7 +553,8 @@ void rt_memheap_free(void *ptr) /* check magic */ if (header_ptr->magic != (RT_MEMHEAP_MAGIC | RT_MEMHEAP_USED)) { - RT_DEBUG_LOG("bad magic:0x%08x @ memheap\n", header_ptr->magic); + RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("bad magic:0x%08x @ memheap\n", + header_ptr->magic)); } RT_ASSERT(header_ptr->magic == (RT_MEMHEAP_MAGIC | RT_MEMHEAP_USED)); /* check whether this block of memory has been over-written. */ @@ -774,7 +775,7 @@ void *rt_malloc(rt_size_t size) #ifdef RT_USING_MEMTRACE if (ptr == RT_NULL) { - RT_DEBUG_LOG("malloc[%d] => NULL", size); + RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("malloc[%d] => NULL", size)); } else { @@ -784,7 +785,7 @@ void *rt_malloc(rt_size_t size) else rt_memheap_setname(item, ""); - RT_DEBUG_LOG("malloc => 0x%08x : %d", ptr, size); + RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("malloc => 0x%08x : %d", ptr, size)); } #endif @@ -839,7 +840,7 @@ void *rt_realloc(void *rmem, rt_size_t newsize) #ifdef RT_USING_MEMTRACE if (new_ptr == RT_NULL) { - RT_DEBUG_LOG("realloc[%d] => NULL", newsize); + RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("realloc[%d] => NULL", newsize)); } else { @@ -849,7 +850,8 @@ void *rt_realloc(void *rmem, rt_size_t newsize) else rt_memheap_setname(item, ""); - RT_DEBUG_LOG("realloc => 0x%08x : %d", new_ptr, newsize); + RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("realloc => 0x%08x : %d", + new_ptr, newsize)); } #endif @@ -873,11 +875,13 @@ void *rt_calloc(rt_size_t count, rt_size_t size) #ifdef RT_USING_MEMTRACE if (ptr == RT_NULL) { - RT_DEBUG_LOG("calloc[%d x %d] => NULL", count, size); + RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("calloc[%d x %d] => NULL", + count, size)); } else { - RT_DEBUG_LOG("calloc => 0x%08x : %d", ptr, count * size); + RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("calloc => 0x%08x : %d", + ptr, count * size)); } #endif -- cgit v1.3.1 From 4b4ab15602ccb2897917c48c514d38085312ca85 Mon Sep 17 00:00:00 2001 From: WillianChan Date: Sat, 20 Feb 2021 16:18:29 +0800 Subject: [kernel][memheap]rename memtrace to memheaptrace Signed-off-by: WillianChan --- src/memheap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/memheap.c b/src/memheap.c index d9c03079ee..abcba9a50b 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -693,7 +693,7 @@ int rt_memheap_dump(struct rt_memheap *heap) return 0; } -int memtrace(void) +int memheaptrace(void) { int count = rt_object_get_length(RT_Object_Class_MemHeap); struct rt_memheap **heaps; @@ -720,7 +720,7 @@ int memtrace(void) return 0; } -MSH_CMD_EXPORT(memtrace, dump memory trace information); +MSH_CMD_EXPORT(memheaptrace, dump memory trace information); #endif #ifdef RT_USING_MEMHEAP_AS_HEAP -- cgit v1.3.1 From b2d3317c6a7954423167316436c949fbcb1ce61d Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 23 Feb 2021 03:21:16 +0800 Subject: remove minilibc --- bsp/efm32/copy_this_file_shell.c | 8 ------ bsp/lpc2148/rtconfig.h | 4 --- bsp/microblaze/rtconfig.h | 1 - bsp/sam7x/rtconfig.h | 4 --- bsp/wh44b0/rtconfig.h | 4 --- components/dfs/filesystems/nfs/rpc/types.h | 16 ------------ components/libc/compilers/armlibc/sys/types.h | 6 +++++ components/libc/compilers/common/SConscript | 4 +-- components/libc/compilers/dlib/sys/types.h | 6 +++++ components/libc/compilers/newlib/SConscript | 29 ++++++++++++++-------- components/libc/compilers/newlib/minilib.c | 18 ++++++++++++++ .../net/lwip-1.4.1/src/arch/include/arch/cc.h | 2 +- .../net/lwip-2.0.2/src/arch/include/arch/cc.h | 2 +- .../net/lwip-2.1.2/src/arch/include/arch/cc.h | 2 +- src/kservice.c | 22 ---------------- 15 files changed, 54 insertions(+), 74 deletions(-) create mode 100644 components/libc/compilers/newlib/minilib.c (limited to 'src') diff --git a/bsp/efm32/copy_this_file_shell.c b/bsp/efm32/copy_this_file_shell.c index 45ce3cb45a..32b7439e0d 100644 --- a/bsp/efm32/copy_this_file_shell.c +++ b/bsp/efm32/copy_this_file_shell.c @@ -32,14 +32,6 @@ ALIGN(RT_ALIGN_SIZE) static char finsh_thread_stack[FINSH_THREAD_STACK_SIZE]; struct finsh_shell* shell; -#if !defined (RT_USING_NEWLIB) && !defined (RT_USING_MINILIBC) -int strcmp (const char *s1, const char *s2) -{ - while (*s1 && *s1 == *s2) s1++, s2++; - - return (*s1 - *s2); -} - #ifdef RT_USING_HEAP char *strdup(const char *s) { diff --git a/bsp/lpc2148/rtconfig.h b/bsp/lpc2148/rtconfig.h index 70a6ef0325..60887daac1 100644 --- a/bsp/lpc2148/rtconfig.h +++ b/bsp/lpc2148/rtconfig.h @@ -80,10 +80,6 @@ /* Using QEMU or SkyEye*/ /* #define RT_USING_EMULATOR */ -/* SECTION: a mini libc */ -/* Using mini libc library*/ -/* #define RT_USING_MINILIBC */ - /* SECTION: C++ support */ /* Using C++ support*/ /* #define RT_USING_CPLUSPLUS */ diff --git a/bsp/microblaze/rtconfig.h b/bsp/microblaze/rtconfig.h index d054c175b9..bdfe09a4f8 100755 --- a/bsp/microblaze/rtconfig.h +++ b/bsp/microblaze/rtconfig.h @@ -93,7 +93,6 @@ /* SECTION: a runtime libc library */ /* a runtime libc library*/ /* #define RT_USING_NEWLIB */ -#define RT_USING_MINILIBC /* SECTION: C++ support */ /* Using C++ support*/ diff --git a/bsp/sam7x/rtconfig.h b/bsp/sam7x/rtconfig.h index bb3e3546d0..ae74c2535e 100644 --- a/bsp/sam7x/rtconfig.h +++ b/bsp/sam7x/rtconfig.h @@ -72,10 +72,6 @@ #define FINSH_USING_SYMTAB #define FINSH_USING_DESCRIPTION -/* SECTION: a mini libc */ -/* Using mini libc library*/ -/* #define RT_USING_MINILIBC */ - /* SECTION: C++ support */ /* Using C++ support*/ /* #define RT_USING_CPLUSPLUS */ diff --git a/bsp/wh44b0/rtconfig.h b/bsp/wh44b0/rtconfig.h index 32364bbc4a..b5bc28a458 100644 --- a/bsp/wh44b0/rtconfig.h +++ b/bsp/wh44b0/rtconfig.h @@ -65,10 +65,6 @@ /* Using FinSH as Shell*/ /* #define RT_USING_FINSH */ -/* SECTION: a mini libc */ -/* Using mini libc library*/ -/* #define RT_USING_MINILIBC */ - /* SECTION: C++ support */ /* Using C++ support*/ /* #define RT_USING_CPLUSPLUS */ diff --git a/components/dfs/filesystems/nfs/rpc/types.h b/components/dfs/filesystems/nfs/rpc/types.h index 254fcd339c..d76d89146c 100644 --- a/components/dfs/filesystems/nfs/rpc/types.h +++ b/components/dfs/filesystems/nfs/rpc/types.h @@ -47,15 +47,7 @@ #include #include - -#ifndef RT_USING_MINILIBC -typedef unsigned int u_int; -typedef unsigned char u_char; -typedef unsigned long u_long; -#else #include -#include -#endif typedef long long int64_t; typedef unsigned long long uint64_t; @@ -63,14 +55,6 @@ typedef unsigned long long uint64_t; typedef int bool_t; typedef int enum_t; -#ifndef RT_USING_NEWLIB -typedef unsigned long dev_t; -#endif - -#if !defined(RT_USING_NEWLIB) && !defined(RT_USING_MINILIBC) -typedef rt_int32_t ssize_t; -#endif - /* This needs to be changed to uint32_t in the future */ typedef unsigned long rpcprog_t; typedef unsigned long rpcvers_t; diff --git a/components/libc/compilers/armlibc/sys/types.h b/components/libc/compilers/armlibc/sys/types.h index 78fee1bb99..bcca8fae1a 100644 --- a/components/libc/compilers/armlibc/sys/types.h +++ b/components/libc/compilers/armlibc/sys/types.h @@ -23,4 +23,10 @@ typedef long signed int ssize_t; /* Used for a count of bytes or an error #endif typedef unsigned long useconds_t; /* microseconds (unsigned) */ +typedef unsigned long dev_t; + +typedef unsigned int u_int; +typedef unsigned char u_char; +typedef unsigned long u_long; + #endif diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index ecdee2637e..319e1a3555 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -10,7 +10,7 @@ CPPPATH = [cwd] if GetDepend('RT_USING_LIBC'): src += Glob('*.c') else: - if GetDepend('RT_LIBC_USING_TIME') and not GetDepend('RT_USING_MINILIBC'): + if GetDepend('RT_LIBC_USING_TIME'): src += ['time.c'] if GetDepend('RT_USING_POSIX') == False: @@ -21,7 +21,7 @@ if rtconfig.CROSS_TOOL == 'keil': else: CPPDEFINES = [] -if not GetDepend('RT_USING_MINILIBC') and (GetDepend('RT_USING_LIBC') or GetDepend('RT_LIBC_USING_TIME')): +if GetDepend('RT_USING_LIBC') or GetDepend('RT_LIBC_USING_TIME'): group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) Return('group') diff --git a/components/libc/compilers/dlib/sys/types.h b/components/libc/compilers/dlib/sys/types.h index 7dbeddcaa9..9ae7906fb1 100644 --- a/components/libc/compilers/dlib/sys/types.h +++ b/components/libc/compilers/dlib/sys/types.h @@ -22,4 +22,10 @@ typedef long signed int ssize_t; /* Used for a count of bytes or an error #endif typedef unsigned long useconds_t; /* microseconds (unsigned) */ +typedef unsigned long dev_t; + +typedef unsigned int u_int; +typedef unsigned char u_char; +typedef unsigned long u_long; + #endif diff --git a/components/libc/compilers/newlib/SConscript b/components/libc/compilers/newlib/SConscript index d0868bbdea..b1ad6e4784 100644 --- a/components/libc/compilers/newlib/SConscript +++ b/components/libc/compilers/newlib/SConscript @@ -1,21 +1,30 @@ from building import * Import('rtconfig') -src = Glob('*.c') +src = [] cwd = GetCurrentDir() group = [] CPPPATH = [cwd] -CPPDEFINES = ['RT_USING_NEWLIB'] - -# link with libc and libm: -# libm is a frequently used lib. Newlib is compiled with -ffunction-sections in -# recent GCC tool chains. The linker would just link in the functions that have -# been referenced. So setting this won't result in bigger text size. -LIBS = ['c', 'm'] if rtconfig.PLATFORM == 'gcc': - group = DefineGroup('libc', src, depend = ['RT_USING_LIBC'], - CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS) + if GetDepend('RT_USING_LIBC'): + CPPDEFINES = ['RT_USING_NEWLIB'] + # link with libc and libm: + # libm is a frequently used lib. Newlib is compiled with -ffunction-sections in + # recent GCC tool chains. The linker would just link in the functions that have + # been referenced. So setting this won't result in bigger text size. + LIBS = ['c', 'm'] + + src += Glob('*.c') + SrcRemove(src, ['minilib.c']) + if GetDepend('RT_USING_MODULE') == False: + SrcRemove(src, ['libc_syms.c']) + else: + src += ['minilib.c'] + CPPDEFINES = [] + LIBS = [] + + group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS) Return('group') diff --git a/components/libc/compilers/newlib/minilib.c b/components/libc/compilers/newlib/minilib.c new file mode 100644 index 0000000000..2d07eabe5a --- /dev/null +++ b/components/libc/compilers/newlib/minilib.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-02-23 Meco Man first version + */ + +#include +#include + +void * _sbrk_r(struct _reent *ptr, ptrdiff_t incr) +{ + /* no use this routine to get memory */ + return RT_NULL; +} diff --git a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h index 251de66978..ecf22177ac 100644 --- a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h +++ b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h @@ -66,7 +66,7 @@ typedef uintptr_t mem_ptr_t; #endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */ #endif -#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) +#if defined(RT_USING_LIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include #define LWIP_TIMEVAL_PRIVATE 0 #else diff --git a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h index ea6a5ff755..51b06f1a7f 100644 --- a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h +++ b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h @@ -45,7 +45,7 @@ #define S32_F "ld" #define X32_F "lx" -#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) +#if defined(RT_USING_LIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include #define LWIP_TIMEVAL_PRIVATE 0 #else diff --git a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h index 49c7541ed7..2c22d3a873 100644 --- a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h +++ b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h @@ -59,7 +59,7 @@ #endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */ #endif /* RT_USING_LIBC */ -#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) +#if defined(RT_USING_LIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include #define LWIP_TIMEVAL_PRIVATE 0 #else diff --git a/src/kservice.c b/src/kservice.c index 423fe3ddb3..9fc3971c7e 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -1386,26 +1386,4 @@ void rt_assert_handler(const char *ex_string, const char *func, rt_size_t line) RTM_EXPORT(rt_assert_handler); #endif /* RT_DEBUG */ -#if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC) && defined (__GNUC__) -#include -void *memcpy(void *dest, const void *src, size_t n) __attribute__((weak, alias("rt_memcpy"))); -void *memset(void *s, int c, size_t n) __attribute__((weak, alias("rt_memset"))); -void *memmove(void *dest, const void *src, size_t n) __attribute__((weak, alias("rt_memmove"))); -int memcmp(const void *s1, const void *s2, size_t n) __attribute__((weak, alias("rt_memcmp"))); - -size_t strlen(const char *s) __attribute__((weak, alias("rt_strlen"))); -char *strstr(const char *s1, const char *s2) __attribute__((weak, alias("rt_strstr"))); -int strcasecmp(const char *a, const char *b) __attribute__((weak, alias("rt_strcasecmp"))); -char *strncpy(char *dest, const char *src, size_t n) __attribute__((weak, alias("rt_strncpy"))); -int strncmp(const char *cs, const char *ct, size_t count) __attribute__((weak, alias("rt_strncmp"))); -#ifdef RT_USING_HEAP -char *strdup(const char *s) __attribute__((weak, alias("rt_strdup"))); -#endif - -int sprintf(char *buf, const char *format, ...) __attribute__((weak, alias("rt_sprintf"))); -int snprintf(char *buf, rt_size_t size, const char *fmt, ...) __attribute__((weak, alias("rt_snprintf"))); -int vsprintf(char *buf, const char *format, va_list arg_ptr) __attribute__((weak, alias("rt_vsprintf"))); - -#endif - /**@}*/ -- cgit v1.3.1 From 2b98ac215a4e07401464bfcd6ad00957ff03bd72 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 24 Feb 2021 16:29:43 +0800 Subject: [kernel] rearrange rt_thread_control() - schedule the thread when close it --- components/libc/compilers/common/stdlib.c | 10 +-- src/thread.c | 141 ++++++++++++++++-------------- 2 files changed, 77 insertions(+), 74 deletions(-) (limited to 'src') diff --git a/components/libc/compilers/common/stdlib.c b/components/libc/compilers/common/stdlib.c index 9f801ab966..48a86098cd 100644 --- a/components/libc/compilers/common/stdlib.c +++ b/components/libc/compilers/common/stdlib.c @@ -14,18 +14,10 @@ void __rt_libc_exit(int status) { rt_thread_t self = rt_thread_self(); -#ifdef RT_USING_MODULE - if (dlmodule_self()) - { - dlmodule_exit(status); - } -#endif - if (self != RT_NULL) { rt_kprintf("thread:%s exit:%d!\n", self->name, status); - rt_thread_suspend(self); - rt_schedule(); + rt_thread_control(self, RT_THREAD_CTRL_CLOSE, RT_NULL); } } diff --git a/src/thread.c b/src/thread.c index 0db9dd8e4d..2681eca59f 100644 --- a/src/thread.c +++ b/src/thread.c @@ -26,6 +26,7 @@ * bug when thread has not startup. * 2018-11-22 Jesven yield is same to rt_schedule * add support for tasks bound to cpu + * 2021-02-24 Meco Man rearrange rt_thread_control() - schedule the thread when close it */ #include @@ -670,83 +671,93 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg) switch (cmd) { - case RT_THREAD_CTRL_CHANGE_PRIORITY: - /* disable interrupt */ - temp = rt_hw_interrupt_disable(); - - /* for ready thread, change queue */ - if ((thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_READY) + case RT_THREAD_CTRL_CHANGE_PRIORITY: { - /* remove thread from schedule queue first */ - rt_schedule_remove_thread(thread); - - /* change thread priority */ - thread->current_priority = *(rt_uint8_t *)arg; - - /* recalculate priority attribute */ -#if RT_THREAD_PRIORITY_MAX > 32 - thread->number = thread->current_priority >> 3; /* 5bit */ - thread->number_mask = 1 << thread->number; - thread->high_mask = 1 << (thread->current_priority & 0x07); /* 3bit */ -#else - thread->number_mask = 1 << thread->current_priority; -#endif - - /* insert thread to schedule queue again */ - rt_schedule_insert_thread(thread); + /* disable interrupt */ + temp = rt_hw_interrupt_disable(); + + /* for ready thread, change queue */ + if ((thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_READY) + { + /* remove thread from schedule queue first */ + rt_schedule_remove_thread(thread); + + /* change thread priority */ + thread->current_priority = *(rt_uint8_t *)arg; + + /* recalculate priority attribute */ + #if RT_THREAD_PRIORITY_MAX > 32 + thread->number = thread->current_priority >> 3; /* 5bit */ + thread->number_mask = 1 << thread->number; + thread->high_mask = 1 << (thread->current_priority & 0x07); /* 3bit */ + #else + thread->number_mask = 1 << thread->current_priority; + #endif + + /* insert thread to schedule queue again */ + rt_schedule_insert_thread(thread); + } + else + { + thread->current_priority = *(rt_uint8_t *)arg; + + /* recalculate priority attribute */ + #if RT_THREAD_PRIORITY_MAX > 32 + thread->number = thread->current_priority >> 3; /* 5bit */ + thread->number_mask = 1 << thread->number; + thread->high_mask = 1 << (thread->current_priority & 0x07); /* 3bit */ + #else + thread->number_mask = 1 << thread->current_priority; + #endif + } + + /* enable interrupt */ + rt_hw_interrupt_enable(temp); + break; } - else - { - thread->current_priority = *(rt_uint8_t *)arg; - /* recalculate priority attribute */ -#if RT_THREAD_PRIORITY_MAX > 32 - thread->number = thread->current_priority >> 3; /* 5bit */ - thread->number_mask = 1 << thread->number; - thread->high_mask = 1 << (thread->current_priority & 0x07); /* 3bit */ -#else - thread->number_mask = 1 << thread->current_priority; -#endif + case RT_THREAD_CTRL_STARTUP: + { + return rt_thread_startup(thread); } - /* enable interrupt */ - rt_hw_interrupt_enable(temp); - break; - - case RT_THREAD_CTRL_STARTUP: - return rt_thread_startup(thread); - - case RT_THREAD_CTRL_CLOSE: - - if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE) + case RT_THREAD_CTRL_CLOSE: { - return rt_thread_detach(thread); + rt_err_t rt_err; + + if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE) + { + rt_err = rt_thread_detach(thread); + } + #ifdef RT_USING_HEAP + else + { + rt_err = rt_thread_delete(thread); + } + #endif + rt_schedule(); + return rt_err; } -#ifdef RT_USING_HEAP - else + + #ifdef RT_USING_SMP + case RT_THREAD_CTRL_BIND_CPU: { - return rt_thread_delete(thread); - } -#endif + rt_uint8_t cpu; -#ifdef RT_USING_SMP - case RT_THREAD_CTRL_BIND_CPU: - { - rt_uint8_t cpu; + if ((thread->stat & RT_THREAD_STAT_MASK) != RT_THREAD_INIT) + { + /* we only support bind cpu before started phase. */ + return RT_ERROR; + } - if ((thread->stat & RT_THREAD_STAT_MASK) != RT_THREAD_INIT) - { - /* we only support bind cpu before started phase. */ - return RT_ERROR; + cpu = (rt_uint8_t)(size_t)arg; + thread->bind_cpu = cpu > RT_CPUS_NR? RT_CPUS_NR : cpu; + break; } + #endif /*RT_USING_SMP*/ - cpu = (rt_uint8_t)(size_t)arg; - thread->bind_cpu = cpu > RT_CPUS_NR? RT_CPUS_NR : cpu; - break; - } -#endif /*RT_USING_SMP*/ - default: - break; + default: + break; } return RT_EOK; -- cgit v1.3.1 From 62137eec9ab5c689686bb705304964d7451bbcdf Mon Sep 17 00:00:00 2001 From: 张世争 Date: Fri, 26 Feb 2021 10:38:31 +0800 Subject: [update][kernel]规范rt_object_detach的使用 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/thread.c | 15 ++------------- src/timer.c | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/thread.c b/src/thread.c index 2681eca59f..18b5227f5a 100644 --- a/src/thread.c +++ b/src/thread.c @@ -382,19 +382,8 @@ rt_err_t rt_thread_detach(rt_thread_t thread) /* change stat */ thread->stat = RT_THREAD_CLOSE; - if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE) - { - rt_object_detach((rt_object_t)thread); - } - else - { - /* disable interrupt */ - lock = rt_hw_interrupt_disable(); - /* insert to defunct thread list */ - rt_list_insert_after(&rt_thread_defunct, &(thread->tlist)); - /* enable interrupt */ - rt_hw_interrupt_enable(lock); - } + /* detach thread object */ + rt_object_detach((rt_object_t)thread); return RT_EOK; } diff --git a/src/timer.c b/src/timer.c index d882711151..747c28c8bd 100644 --- a/src/timer.c +++ b/src/timer.c @@ -233,7 +233,7 @@ rt_err_t rt_timer_detach(rt_timer_t timer) /* enable interrupt */ rt_hw_interrupt_enable(level); - rt_object_detach((rt_object_t)timer); + rt_object_detach(&(timer->parent)); return RT_EOK; } -- cgit v1.3.1 From 00cebaacace8d3c77655bc7ce751a0aa5abd0784 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 28 Feb 2021 05:07:02 +0800 Subject: add RT_KERVICE_USING_STDLIB --- include/rtthread.h | 33 ++++++++++++++++++++++++--------- src/Kconfig | 4 ++++ src/kservice.c | 5 +++++ 3 files changed, 33 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/include/rtthread.h b/include/rtthread.h index 1e0094e73b..9d537d6e4d 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -14,6 +14,7 @@ * 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 + * 2021-02-28 Meco Man add RT_KERVICE_USING_STDLIB */ #ifndef __RT_THREAD_H__ @@ -516,7 +517,9 @@ void rt_components_board_init(void); #else void rt_kprintf(const char *fmt, ...); void rt_kputs(const char *str); +rt_int32_t rt_sscanf(const char *buf, const char *fmt, ...); #endif + rt_int32_t rt_vsprintf(char *dest, const char *format, va_list arg_ptr); rt_int32_t rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args); rt_int32_t rt_sprintf(char *buf, const char *format, ...); @@ -541,23 +544,35 @@ int __rt_ffs(int value); void *rt_memset(void *src, int c, rt_ubase_t n); void *rt_memcpy(void *dest, const void *src, rt_ubase_t n); +#ifndef RT_KERVICE_USING_STDLIB +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); +char *rt_strstr(const char *str1, const char *str2); +rt_int32_t rt_strcasecmp(const char *a, const char *b); +char *rt_strncpy(char *dest, const char *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); +rt_size_t rt_strlen(const char *src); +#else +#include +#define rt_memmove(dest, src, n) memmove(dest, src, n) +#define rt_memcmp(cs, ct, count) memcmp(cs, ct, count) +#define rt_strstr(str1, str2) strstr(str1, str2) +#define rt_strcasecmp(a, b) strcasecmp(a, b) +#define rt_strncpy(dest, src, n) strncpy(dest, src, n) +#define rt_strncmp(cs, ct, count) strncmp(cs, ct, count) +#define rt_strcmp(cs, ct) strcmp(cs, ct) +#define rt_strnlen(s, maxlen) strnlen(s, maxlen) +#define rt_strlen(src) strlen(src) +#endif /*RT_KERVICE_USING_STDLIB*/ + char *rt_strdup(const char *s); #if defined(__CC_ARM) || defined(__CLANG_ARM) -/* leak strdup interface */ +/* lack strdup interface */ char* strdup(const char* str); #endif -char *rt_strstr(const char *str1, const char *str2); -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_int32_t rt_strcasecmp(const char *a, const char *b); - void rt_show_version(void); #ifdef RT_DEBUG diff --git a/src/Kconfig b/src/Kconfig index 803c827e51..5bc9adda52 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -116,6 +116,10 @@ config RT_TIMER_THREAD_STACK_SIZE endif +config RT_KERVICE_USING_STDLIB + bool "Enable kservice to use standard C library" + default n + menuconfig RT_DEBUG bool "Enable debugging features" default y diff --git a/src/kservice.c b/src/kservice.c index 9fc3971c7e..29097bafac 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -17,6 +17,7 @@ * 2013-06-24 Bernard remove rt_kprintf if RT_USING_CONSOLE is not defined. * 2013-09-24 aozima make sure the device is in STREAM mode when used by rt_kprintf. * 2015-07-06 Bernard Add rt_assert_handler routine. + * 2021-02-28 Meco Man add RT_KERVICE_USING_STDLIB */ #include @@ -280,6 +281,8 @@ RT_WEAK void *rt_memcpy(void *dst, const void *src, rt_ubase_t count) } RTM_EXPORT(rt_memcpy); +#ifndef RT_KERVICE_USING_STDLIB + /** * This function will move memory content from source address to destination * address. @@ -506,6 +509,8 @@ rt_size_t rt_strlen(const char *s) } RTM_EXPORT(rt_strlen); +#endif /*RT_KERVICE_USING_STDLIB*/ + #ifdef RT_USING_HEAP /** * This function will duplicate a string. -- cgit v1.3.1 From 72d7f6c0adf6ef251e7662f09c9dd32579041a19 Mon Sep 17 00:00:00 2001 From: 张世争 Date: Sun, 28 Feb 2021 12:00:44 +0800 Subject: [update][kernel]规范rt_object_t强制转换的使用,消除上次提交的编译警告 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/thread.c | 2 -- src/timer.c | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/thread.c b/src/thread.c index 18b5227f5a..beef93f46a 100644 --- a/src/thread.c +++ b/src/thread.c @@ -358,8 +358,6 @@ RTM_EXPORT(rt_thread_startup); */ rt_err_t rt_thread_detach(rt_thread_t thread) { - rt_base_t lock; - /* thread check */ RT_ASSERT(thread != RT_NULL); RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); diff --git a/src/timer.c b/src/timer.c index 747c28c8bd..2eaca225bc 100644 --- a/src/timer.c +++ b/src/timer.c @@ -201,7 +201,7 @@ void rt_timer_init(rt_timer_t timer, RT_ASSERT(timer != RT_NULL); /* timer object initialization */ - rt_object_init((rt_object_t)timer, RT_Object_Class_Timer, name); + rt_object_init(&(timer->parent), RT_Object_Class_Timer, name); _rt_timer_init(timer, timeout, parameter, time, flag); } @@ -298,7 +298,7 @@ rt_err_t rt_timer_delete(rt_timer_t timer) /* enable interrupt */ rt_hw_interrupt_enable(level); - rt_object_delete((rt_object_t)timer); + rt_object_delete(&(timer->parent)); return RT_EOK; } -- cgit v1.3.1 From 58f000bdce1879154df911069e644f197ca893c7 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 1 Mar 2021 23:58:04 +0800 Subject: 修改拼写错误 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rtthread.h | 6 +++--- src/Kconfig | 2 +- src/kservice.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/include/rtthread.h b/include/rtthread.h index 7e6c9568b0..8efda713e5 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -14,7 +14,7 @@ * 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 - * 2021-02-28 Meco Man add RT_KERVICE_USING_STDLIB + * 2021-02-28 Meco Man add RT_KSERVICE_USING_STDLIB */ #ifndef __RT_THREAD_H__ @@ -544,7 +544,7 @@ int __rt_ffs(int value); void *rt_memset(void *src, int c, rt_ubase_t n); void *rt_memcpy(void *dest, const void *src, rt_ubase_t n); -#ifndef RT_KERVICE_USING_STDLIB +#ifndef RT_KSERVICE_USING_STDLIB 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); char *rt_strstr(const char *str1, const char *str2); @@ -565,7 +565,7 @@ rt_size_t rt_strlen(const char *src); #define rt_strcmp(cs, ct) strcmp(cs, ct) #define rt_strnlen(s, maxlen) strnlen(s, maxlen) #define rt_strlen(src) strlen(src) -#endif /*RT_KERVICE_USING_STDLIB*/ +#endif /*RT_KSERVICE_USING_STDLIB*/ char *rt_strdup(const char *s); #if defined(__CC_ARM) || defined(__CLANG_ARM) diff --git a/src/Kconfig b/src/Kconfig index 5bc9adda52..7659915f57 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -116,7 +116,7 @@ config RT_TIMER_THREAD_STACK_SIZE endif -config RT_KERVICE_USING_STDLIB +config RT_KSERVICE_USING_STDLIB bool "Enable kservice to use standard C library" default n diff --git a/src/kservice.c b/src/kservice.c index 29097bafac..446fec96a1 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -17,7 +17,7 @@ * 2013-06-24 Bernard remove rt_kprintf if RT_USING_CONSOLE is not defined. * 2013-09-24 aozima make sure the device is in STREAM mode when used by rt_kprintf. * 2015-07-06 Bernard Add rt_assert_handler routine. - * 2021-02-28 Meco Man add RT_KERVICE_USING_STDLIB + * 2021-02-28 Meco Man add RT_KSERVICE_USING_STDLIB */ #include @@ -281,7 +281,7 @@ RT_WEAK void *rt_memcpy(void *dst, const void *src, rt_ubase_t count) } RTM_EXPORT(rt_memcpy); -#ifndef RT_KERVICE_USING_STDLIB +#ifndef RT_KSERVICE_USING_STDLIB /** * This function will move memory content from source address to destination @@ -509,7 +509,7 @@ rt_size_t rt_strlen(const char *s) } RTM_EXPORT(rt_strlen); -#endif /*RT_KERVICE_USING_STDLIB*/ +#endif /*RT_KSERVICE_USING_STDLIB*/ #ifdef RT_USING_HEAP /** -- cgit v1.3.1 From 5ce889ea820e1c5bbadc41a0464b2dcdf3e607fc Mon Sep 17 00:00:00 2001 From: liruncong Date: Thu, 4 Mar 2021 19:33:28 +0800 Subject: 撤销有符号比较,仍应使用无符号比较 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/thread.c b/src/thread.c index 627b7e898e..c2a3e2e797 100644 --- a/src/thread.c +++ b/src/thread.c @@ -598,7 +598,7 @@ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick) level = rt_hw_interrupt_disable(); cur_tick = rt_tick_get(); - if ((rt_int32_t)(cur_tick - *tick) < (rt_int32_t)inc_tick) + if (cur_tick - *tick < inc_tick) { rt_tick_t left_tick; -- cgit v1.3.1 From ffe4493982f2f47098f36682e4e6ca964048b903 Mon Sep 17 00:00:00 2001 From: WillianChan Date: Fri, 5 Mar 2021 16:15:51 +0800 Subject: [kernel][Konfig]modify Kconfig file Signed-off-by: WillianChan --- src/Kconfig | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/Kconfig b/src/Kconfig index 803c827e51..aa8e514e5c 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -284,21 +284,19 @@ menu "Memory Management" endchoice - if RT_USING_SMALL_MEM - config RT_USING_MEMTRACE - bool "Enable memory trace" - default n - help - When enable RT_USING_MEMTRACE with shell, developer can call cmd: - 1. memtrace - to dump memory block information. - 2. memcheck - to check memory block to avoid memory overwritten. - - And developer also can call memcheck() in each of scheduling - to check memory block to find which thread has wrongly modified - memory. - endif + config RT_USING_MEMTRACE + bool "Enable memory trace" + default n + help + When enable RT_USING_MEMTRACE with shell, developer can call cmd: + 1. memtrace + to dump memory block information. + 2. memcheck + to check memory block to avoid memory overwritten. + + And developer also can call memcheck() in each of scheduling + to check memory block to find which thread has wrongly modified + memory. config RT_USING_HEAP bool -- cgit v1.3.1 From 678306d300faa44b6cd099464bd978afb2c5c9a6 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 8 Mar 2021 11:25:38 +0800 Subject: [kernel]auto formatted --- src/clock.c | 4 ++-- src/components.c | 2 +- src/cpu.c | 2 +- src/device.c | 2 +- src/idle.c | 4 ++-- src/ipc.c | 20 ++++++++++---------- src/irq.c | 6 +++--- src/kservice.c | 8 ++++---- src/mem.c | 4 ++-- src/memheap.c | 6 +++--- src/mempool.c | 2 +- src/object.c | 10 +++++----- src/scheduler.c | 8 ++++---- src/signal.c | 2 +- src/slab.c | 2 +- src/thread.c | 2 +- src/timer.c | 2 +- 17 files changed, 43 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index 66923e5c00..0880d8d241 100644 --- a/src/clock.c +++ b/src/clock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -111,7 +111,7 @@ rt_tick_t rt_tick_from_millisecond(rt_int32_t ms) tick = RT_TICK_PER_SECOND * (ms / 1000); tick += (RT_TICK_PER_SECOND * (ms % 1000) + 999) / 1000; } - + /* return the calculated tick */ return tick; } diff --git a/src/components.c b/src/components.c index 8ea5654d0c..9709d0aae2 100644 --- a/src/components.c +++ b/src/components.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/src/cpu.c b/src/cpu.c index 96e585713b..48ddb12c46 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/src/device.c b/src/device.c index a4f004fb69..388c2ecf12 100644 --- a/src/device.c +++ b/src/device.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/src/idle.c b/src/idle.c index aa14552a49..24dfffbc6d 100644 --- a/src/idle.c +++ b/src/idle.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -211,7 +211,7 @@ static void rt_thread_idle_entry(void *parameter) #endif rt_thread_idle_excute(); -#ifdef RT_USING_PM +#ifdef RT_USING_PM rt_system_power_manager(); #endif } diff --git a/src/ipc.c b/src/ipc.c index 37b05b9ae3..111d724c23 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -34,7 +34,7 @@ * 2013-09-14 Grissiom add an option check in rt_event_recv * 2018-10-02 Bernard add 64bit support for mailbox * 2019-09-16 tyx add send wait support for message queue - * 2020-07-29 Meco Man fix thread->event_set/event_info when received an + * 2020-07-29 Meco Man fix thread->event_set/event_info when received an * event without pending * 2020-10-11 Meco Man add value overflow-check code * 2021-01-03 Meco Man add rt_mb_urgent() @@ -124,7 +124,7 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list, break; default: - break; + break; } return RT_EOK; @@ -959,7 +959,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) rt_hw_interrupt_enable(temp); /* enable interrupt */ return -RT_EFULL; /* value overflowed */ } - + /* clear owner */ mutex->owner = RT_NULL; mutex->original_priority = 0xff; @@ -1280,11 +1280,11 @@ rt_err_t rt_event_recv(rt_event_t event, /* set received event */ if (recved) *recved = (event->set & set); - - /* fill thread event info */ + + /* fill thread event info */ thread->event_set = (event->set & set); thread->event_info = option; - + /* received event */ if (option & RT_EVENT_FLAG_CLEAR) event->set &= ~set; @@ -1649,7 +1649,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, ++ mb->in_offset; if (mb->in_offset >= mb->size) mb->in_offset = 0; - + if(mb->entry < RT_MB_ENTRY_MAX) { /* increase message entry */ @@ -1660,7 +1660,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, rt_hw_interrupt_enable(temp); /* enable interrupt */ return -RT_EFULL; /* value overflowed */ } - + /* resume suspended thread */ if (!rt_list_isempty(&mb->parent.suspend_thread)) { @@ -2409,7 +2409,7 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size) rt_hw_interrupt_enable(temp); /* enable interrupt */ return -RT_EFULL; /* value overflowed */ } - + /* resume suspended thread */ if (!rt_list_isempty(&mq->parent.suspend_thread)) { diff --git a/src/irq.c b/src/irq.c index 311d297bfe..177c1a9ff5 100644 --- a/src/irq.c +++ b/src/irq.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -21,7 +21,7 @@ static void (*rt_interrupt_leave_hook)(void); /** * @ingroup Hook - * This function set a hook function when the system enter a interrupt + * This function set a hook function when the system enter a interrupt * * @note the hook function must be simple and never be blocked or suspend. */ @@ -31,7 +31,7 @@ void rt_interrupt_enter_sethook(void (*hook)(void)) } /** * @ingroup Hook - * This function set a hook function when the system exit a interrupt. + * This function set a hook function when the system exit a interrupt. * * @note the hook function must be simple and never be blocked or suspend. */ diff --git a/src/kservice.c b/src/kservice.c index 9fc3971c7e..79ee4c2b9d 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -456,7 +456,7 @@ RTM_EXPORT(rt_strncmp); rt_int32_t rt_strcmp(const char *cs, const char *ct) { while (*cs && *cs == *ct) - { + { cs++; ct++; } @@ -1127,10 +1127,10 @@ rt_device_t rt_console_set_device(const char *name) /* find new console device */ new_device = rt_device_find(name); - + /* check whether it's a same device */ if (new_device == old_device) return RT_NULL; - + if (new_device != RT_NULL) { if (_console_device != RT_NULL) diff --git a/src/mem.c b/src/mem.c index c03c8b3452..ac0d27f2c3 100644 --- a/src/mem.c +++ b/src/mem.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -489,7 +489,7 @@ void *rt_realloc(void *rmem, rt_size_t newsize) { ((struct heap_mem *)&heap_ptr[mem2->next])->prev = ptr2; } - + if (mem2 < lfree) { /* the splited struct is now the lowest */ diff --git a/src/memheap.c b/src/memheap.c index 449e66e975..a5d86f6347 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 */ @@ -130,7 +130,7 @@ rt_err_t rt_memheap_detach(struct rt_memheap *heap) RT_ASSERT(heap); RT_ASSERT(rt_object_get_type(&heap->parent) == RT_Object_Class_MemHeap); RT_ASSERT(rt_object_is_systemobject(&heap->parent)); - + rt_sem_detach(&heap->lock); rt_object_detach(&(heap->parent)); @@ -765,7 +765,7 @@ void dump_used_memheap(struct rt_memheap *mh) rt_kprintf("\nmemory heap address:\n"); rt_kprintf("heap_ptr: 0x%08x\n", mh->start_addr); - rt_kprintf("free : 0x%08x\n", mh->available_size); + rt_kprintf("free : 0x%08x\n", mh->available_size); rt_kprintf("max_used: 0x%08x\n", mh->max_used_size); rt_kprintf("size : 0x%08x\n", mh->pool_size); diff --git a/src/mempool.c b/src/mempool.c index db614032aa..1de48940d7 100644 --- a/src/mempool.c +++ b/src/mempool.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/src/object.c b/src/object.c index 56263618b3..013e2d1e33 100644 --- a/src/object.c +++ b/src/object.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -200,7 +200,7 @@ void rt_object_put_sethook(void (*hook)(struct rt_object *object)) /** * This function will return the specified type of object information. * - * @param type the type of object, which can be + * @param type the type of object, which can be * RT_Object_Class_Thread/Semaphore/Mutex... etc * * @return the object type information or RT_NULL @@ -220,7 +220,7 @@ RTM_EXPORT(rt_object_get_information); /** * This function will return the length of object list in object container. * - * @param type the type of object, which can be + * @param type the type of object, which can be * RT_Object_Class_Thread/Semaphore/Mutex... etc * @return the length of object list */ @@ -247,10 +247,10 @@ int rt_object_get_length(enum rt_object_class_type type) RTM_EXPORT(rt_object_get_length); /** - * This function will copy the object pointer of the specified type, + * This function will copy the object pointer of the specified type, * with the maximum size specified by maxlen. * - * @param type the type of object, which can be + * @param type the type of object, which can be * RT_Object_Class_Thread/Semaphore/Mutex... etc * @param pointers the pointers will be saved to * @param maxlen the maximum number of pointers can be saved diff --git a/src/scheduler.c b/src/scheduler.c index 06f305ea0b..c03c20d030 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -270,10 +270,10 @@ void rt_system_scheduler_start(void) #ifdef RT_USING_SMP /** * This function will handle IPI interrupt and do a scheduling in system; - * + * * @param vector, the number of IPI interrupt for system scheduling * @param param, use RT_NULL - * + * * NOTE: this function should be invoke or register as ISR in BSP. */ void rt_scheduler_ipi_handler(int vector, void *param) @@ -283,7 +283,7 @@ void rt_scheduler_ipi_handler(int vector, void *param) /** * This function will perform one scheduling. It will select one thread - * with the highest priority level in global ready queue or local ready queue, + * with the highest priority level in global ready queue or local ready queue, * then switch to it. */ void rt_schedule(void) diff --git a/src/signal.c b/src/signal.c index bb9339ab6c..c2c3e975cb 100644 --- a/src/signal.c +++ b/src/signal.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/src/slab.c b/src/slab.c index 0872ecf092..12ca1a938c 100644 --- a/src/slab.c +++ b/src/slab.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/src/thread.c b/src/thread.c index beef93f46a..402ed66acb 100644 --- a/src/thread.c +++ b/src/thread.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/src/timer.c b/src/timer.c index 2eaca225bc..836df51e06 100644 --- a/src/timer.c +++ b/src/timer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * -- cgit v1.3.1 From 8836cb7895adb51bb361c1492b6b780ebdda78b6 Mon Sep 17 00:00:00 2001 From: 杨澄 <36236188+Eureka1024@users.noreply.github.com> Date: Wed, 17 Mar 2021 23:55:27 +0800 Subject: Fix code comment error for function rt_memset(). --- src/kservice.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/kservice.c b/src/kservice.c index 79ee4c2b9d..c08dc68314 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -146,10 +146,10 @@ RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count) if (!TOO_SMALL(count) && !UNALIGNED(s)) { - /* If we get this far, we know that n is large and m is word-aligned. */ + /* If we get this far, we know that count is large and s is word-aligned. */ aligned_addr = (unsigned long *)s; - /* Store D into each char sized location in BUFFER so that + /* Store d into each char sized location in buffer so that * we can set large blocks quickly. */ if (LBLOCKSIZE == 4) -- cgit v1.3.1 From 846102efa1ba3af5d8431db09adabe38af0e28a7 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Fri, 19 Mar 2021 03:01:07 +0800 Subject: [kernel][device] remove rt_device_init_all() --- bsp/frdm-k64f/applications/startup.c | 3 --- bsp/mb9bf500r/startup.c | 5 ----- include/rtthread.h | 2 -- src/device.c | 14 +------------- 4 files changed, 1 insertion(+), 23 deletions(-) (limited to 'src') diff --git a/bsp/frdm-k64f/applications/startup.c b/bsp/frdm-k64f/applications/startup.c index d16aefddb2..e558cd8cbf 100644 --- a/bsp/frdm-k64f/applications/startup.c +++ b/bsp/frdm-k64f/applications/startup.c @@ -73,9 +73,6 @@ void rtthread_startup(void) /* init scheduler system */ rt_system_scheduler_init(); - /* init all device */ - rt_device_init_all(); - /* init application */ rt_application_init(); diff --git a/bsp/mb9bf500r/startup.c b/bsp/mb9bf500r/startup.c index bc96eb5dca..a8718750fc 100644 --- a/bsp/mb9bf500r/startup.c +++ b/bsp/mb9bf500r/startup.c @@ -61,11 +61,6 @@ void rtthread_startup(void) /* init scheduler system */ rt_system_scheduler_init(); -#ifdef RT_USING_DEVICE - /* init all device */ - rt_device_init_all(); -#endif - /* init application */ rt_application_init(); diff --git a/include/rtthread.h b/include/rtthread.h index 9bcf05820c..e80257a6e5 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -437,8 +437,6 @@ rt_err_t rt_device_unregister(rt_device_t dev); rt_device_t rt_device_create(int type, int attach_size); void rt_device_destroy(rt_device_t device); -rt_err_t rt_device_init_all(void); - rt_err_t rt_device_set_rx_indicate(rt_device_t dev, rt_err_t (*rx_ind)(rt_device_t dev, rt_size_t size)); diff --git a/src/device.c b/src/device.c index 388c2ecf12..50b83c7692 100644 --- a/src/device.c +++ b/src/device.c @@ -12,6 +12,7 @@ * 2012-12-25 Bernard return RT_EOK if the device interface not exist. * 2013-07-09 Grissiom add ref_count support * 2016-04-02 Bernard fix the open_flag initialization issue. + * 2021-03-19 Meco Man remove rt_device_init_all() */ #include @@ -89,19 +90,6 @@ rt_err_t rt_device_unregister(rt_device_t dev) } RTM_EXPORT(rt_device_unregister); -/** - * This function initializes all registered device driver - * - * @return the error code, RT_EOK on successfully. - * - * @deprecated since 1.2.x, this function is not needed because the initialization - * of a device is performed when application opens it. - */ -rt_err_t rt_device_init_all(void) -{ - return RT_EOK; -} - /** * This function finds a device driver by specified name. * -- cgit v1.3.1 From e65b2a1c2e9124848770fb61ee5c2c6d97d91a92 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Fri, 9 Apr 2021 13:37:55 +0800 Subject: add "kservice optimization" option --- src/Kconfig | 8 ++++++++ src/kservice.c | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Kconfig b/src/Kconfig index 0b1735e004..6afb719395 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -116,10 +116,18 @@ config RT_TIMER_THREAD_STACK_SIZE endif +menu "kservice optimization" + config RT_KSERVICE_USING_STDLIB bool "Enable kservice to use standard C library" default n +config RT_KSERVICE_USING_TINY_SIZE + bool "Enable kservice to use tiny size" + default n + +endmenu + menuconfig RT_DEBUG bool "Enable debugging features" default y diff --git a/src/kservice.c b/src/kservice.c index bd0650ac37..e9972dba97 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -126,7 +126,7 @@ RTM_EXPORT(_rt_errno); */ RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count) { -#ifdef RT_USING_TINY_SIZE +#ifdef RT_KSERVICE_USING_TINY_SIZE char *xs = (char *)s; while (count--) @@ -210,7 +210,7 @@ RTM_EXPORT(rt_memset); */ RT_WEAK void *rt_memcpy(void *dst, const void *src, rt_ubase_t count) { -#ifdef RT_USING_TINY_SIZE +#ifdef RT_KSERVICE_USING_TINY_SIZE char *tmp = (char *)dst, *s = (char *)src; rt_ubase_t len; -- cgit v1.3.1 From 0d21f37119ea1620770cc5ed9866d3dc180f4eed Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 12 Apr 2021 23:01:35 +0800 Subject: [kernel][irq] 优化DEBUG打印输出位置,防止造成歧义 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/irq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/irq.c b/src/irq.c index 177c1a9ff5..2d886d3eca 100644 --- a/src/irq.c +++ b/src/irq.c @@ -66,13 +66,13 @@ void rt_interrupt_enter(void) { rt_base_t level; - RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq coming..., irq nest:%d\n", - rt_interrupt_nest)); - level = rt_hw_interrupt_disable(); rt_interrupt_nest ++; RT_OBJECT_HOOK_CALL(rt_interrupt_enter_hook,()); rt_hw_interrupt_enable(level); + + RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq has come..., irq nest:%d\n", + rt_interrupt_nest)); } RTM_EXPORT(rt_interrupt_enter); -- cgit v1.3.1 From 305f9946d844f624fedc20b171685701fe5a2bd3 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 12 Apr 2021 23:08:40 +0800 Subject: clarify the context --- src/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/irq.c b/src/irq.c index 2d886d3eca..65fc2ea5e0 100644 --- a/src/irq.c +++ b/src/irq.c @@ -71,7 +71,7 @@ void rt_interrupt_enter(void) RT_OBJECT_HOOK_CALL(rt_interrupt_enter_hook,()); rt_hw_interrupt_enable(level); - RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq has come..., irq nest:%d\n", + RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq has come..., irq current nest:%d\n", rt_interrupt_nest)); } RTM_EXPORT(rt_interrupt_enter); @@ -87,7 +87,7 @@ void rt_interrupt_leave(void) { rt_base_t level; - RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq leave, irq nest:%d\n", + RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq is going to leave, irq current nest:%d\n", rt_interrupt_nest)); level = rt_hw_interrupt_disable(); -- cgit v1.3.1 From ac2c734583fdaddeebdbb2a168b0f643b2dbaa2b Mon Sep 17 00:00:00 2001 From: geniusgogo Date: Fri, 7 May 2021 14:53:48 +0800 Subject: fixed rt_kprintf %s precision print error. --- src/kservice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/kservice.c b/src/kservice.c index e9972dba97..7ed05b6651 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -922,7 +922,7 @@ rt_int32_t rt_vsnprintf(char *buf, s = va_arg(args, char *); if (!s) s = "(NULL)"; - len = rt_strlen(s); + for (len = 0; (len != field_width) && (s[len] != '\0'); len++); #ifdef RT_PRINTF_PRECISION if (precision > 0 && len > precision) len = precision; #endif -- cgit v1.3.1 From c61419b69bd3895aac2da8a36d9db0b2ff682f26 Mon Sep 17 00:00:00 2001 From: armink Date: Mon, 10 May 2021 09:10:54 +0800 Subject: Update the version number to 4.0.4 --- include/rtdef.h | 3 ++- src/Kconfig | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/include/rtdef.h b/include/rtdef.h index 111ac4a12c..d125c970c9 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -34,6 +34,7 @@ * 2019-12-20 Bernard change version number to v4.0.3 * 2020-08-10 Meco Man add macro for struct rt_device_ops * 2020-10-23 Meco Man define maximum value of ipc type + * 2021-05-10 armink change version number to v4.0.4 */ #ifndef __RT_DEF_H__ @@ -55,7 +56,7 @@ extern "C" { /* RT-Thread version information */ #define RT_VERSION 4L /**< major version number */ #define RT_SUBVERSION 0L /**< minor version number */ -#define RT_REVISION 3L /**< revise version number */ +#define RT_REVISION 4L /**< revise version number */ /* RT-Thread version */ #define RTTHREAD_VERSION ((RT_VERSION * 10000) + \ diff --git a/src/Kconfig b/src/Kconfig index 6afb719395..9a49146dff 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -353,7 +353,7 @@ endmenu config RT_VER_NUM hex - default 0x40003 + default 0x40004 help RT-Thread version number -- cgit v1.3.1 From f7d198463e9bff5554835a4ee86b9e28a0190ede Mon Sep 17 00:00:00 2001 From: Hunter Date: Sat, 15 May 2021 21:57:01 +0800 Subject: 注释错误,此处的场景是zone满了,不是空了 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/slab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slab.c b/src/slab.c index 12ca1a938c..114259002f 100644 --- a/src/slab.c +++ b/src/slab.c @@ -540,7 +540,7 @@ void *rt_malloc(rt_size_t size) { RT_ASSERT(z->z_nfree > 0); - /* Remove us from the zone_array[] when we become empty */ + /* Remove us from the zone_array[] when we become full */ if (--z->z_nfree == 0) { zone_array[zi] = z->z_next; -- cgit v1.3.1 From 02331fd30d1f1ca8c886aac4db6c8c111987913c Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 17 May 2021 21:00:40 +0800 Subject: revert #3647 --- src/ipc.c | 42 ------------------------------------------ 1 file changed, 42 deletions(-) (limited to 'src') diff --git a/src/ipc.c b/src/ipc.c index 111d724c23..27ee92e3fd 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -38,7 +38,6 @@ * event without pending * 2020-10-11 Meco Man add value overflow-check code * 2021-01-03 Meco Man add rt_mb_urgent() - * 2021-01-20 hupu fix priority inversion bug of mutex */ #include @@ -192,31 +191,6 @@ rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list) return RT_EOK; } -/** - * This function will get the highest priority from the specified - * list of threads - * - * @param list of the threads - * - * @return the highest priority - */ -rt_uint8_t rt_ipc_get_highest_priority(rt_list_t *list) -{ - struct rt_list_node *n; - struct rt_thread *sthread; - rt_uint8_t priority = RT_THREAD_PRIORITY_MAX - 1; - - for (n = list->next; n != list; n = n->next) - { - sthread = rt_list_entry(n, struct rt_thread, tlist); - - priority = priority < sthread->current_priority ? - priority : - sthread->current_priority; - } - return priority; -} - #ifdef RT_USING_SEMAPHORE /** * This function will initialize a semaphore and put it under control of @@ -855,7 +829,6 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) register rt_base_t temp; struct rt_thread *thread; rt_bool_t need_schedule; - rt_uint8_t max_priority_in_queue = RT_THREAD_PRIORITY_MAX - 1; /* parameter check */ RT_ASSERT(mutex != RT_NULL); @@ -917,21 +890,6 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) mutex->owner = thread; mutex->original_priority = thread->current_priority; - /* Priority adjustment occurs only when the following conditions - * are met simultaneously: - * 1.The type of mutex is RT_IPC_FLAG_FIFO; - * 2.The priority of the thread to be resumed is not equal to the - * highest priority in the queue; - */ - max_priority_in_queue = rt_ipc_get_highest_priority(&mutex->parent.suspend_thread); - if (mutex->parent.parent.flag == RT_IPC_FLAG_FIFO && - thread->current_priority != max_priority_in_queue) - { - rt_thread_control(thread, - RT_THREAD_CTRL_CHANGE_PRIORITY, - &(max_priority_in_queue)); - } - if(mutex->hold < RT_MUTEX_HOLD_MAX) { mutex->hold ++; -- cgit v1.3.1 From c58d893c1add4e5a2495ff0726132958e3539854 Mon Sep 17 00:00:00 2001 From: Meco Jianting Man <920369182@qq.com> Date: Sat, 22 May 2021 17:21:42 +0800 Subject: [kernel][idle] _has_defunct_thread函数增加条件编译 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _has_defunct_thread函数增加条件编译,防止没有开启heap时报警 --- src/idle.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/idle.c b/src/idle.c index 24dfffbc6d..59868352d8 100644 --- a/src/idle.c +++ b/src/idle.c @@ -127,6 +127,7 @@ rt_err_t rt_thread_idle_delhook(void (*hook)(void)) #endif +#ifdef RT_USING_HEAP /* Return whether there is defunctional thread to be deleted. */ rt_inline int _has_defunct_thread(void) { @@ -140,6 +141,7 @@ rt_inline int _has_defunct_thread(void) return l->next != l; } +#endif /** * @ingroup Thread -- cgit v1.3.1 From cd326d849a745c824c3ff2f0a22b25be4ba04d60 Mon Sep 17 00:00:00 2001 From: yangjie Date: Tue, 25 May 2021 18:28:30 +0800 Subject: [src]移除 C99 依赖 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/timer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/timer.c b/src/timer.c index 836df51e06..9b0db6c6a5 100644 --- a/src/timer.c +++ b/src/timer.c @@ -531,7 +531,9 @@ void rt_timer_check(void) struct rt_timer *t; rt_tick_t current_tick; register rt_base_t level; - rt_list_t list = RT_LIST_OBJECT_INIT(list); + rt_list_t list; + + rt_list_init(&list); RT_DEBUG_LOG(RT_DEBUG_TIMER, ("timer check enter\n")); @@ -613,7 +615,9 @@ void rt_soft_timer_check(void) rt_tick_t current_tick; struct rt_timer *t; register rt_base_t level; - rt_list_t list = RT_LIST_OBJECT_INIT(list); + rt_list_t list; + + rt_list_init(&list); RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check enter\n")); -- cgit v1.3.1 From d9367468061113b31df5e3488dced157e1d0dabf Mon Sep 17 00:00:00 2001 From: tangyuxin Date: Fri, 28 May 2021 10:28:00 +0800 Subject: [kernel] Improve kernel stability --- src/ipc.c | 1 + src/thread.c | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/ipc.c b/src/ipc.c index 111d724c23..22e0f06bc6 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -124,6 +124,7 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list, break; default: + RT_ASSERT(0); break; } diff --git a/src/thread.c b/src/thread.c index 34e96077d1..e03c027eff 100644 --- a/src/thread.c +++ b/src/thread.c @@ -358,6 +358,8 @@ RTM_EXPORT(rt_thread_startup); */ rt_err_t rt_thread_detach(rt_thread_t thread) { + rt_base_t lock; + /* thread check */ RT_ASSERT(thread != RT_NULL); RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); @@ -377,12 +379,18 @@ rt_err_t rt_thread_detach(rt_thread_t thread) /* release thread timer */ rt_timer_detach(&(thread->thread_timer)); + /* disable interrupt */ + lock = rt_hw_interrupt_disable(); + /* change stat */ thread->stat = RT_THREAD_CLOSE; /* detach thread object */ rt_object_detach((rt_object_t)thread); + /* enable interrupt */ + rt_hw_interrupt_enable(lock); + return RT_EOK; } RTM_EXPORT(rt_thread_detach); -- cgit v1.3.1 From 37960723b8fe6c91d14c7c4c1c30a97d17e0033b Mon Sep 17 00:00:00 2001 From: geniusgogo Date: Fri, 28 May 2021 09:43:06 +0800 Subject: fix rt_tick_increase critical code protection --- src/clock.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index 0880d8d241..8746d463c1 100644 --- a/src/clock.c +++ b/src/clock.c @@ -76,10 +76,14 @@ void rt_tick_increase(void) -- thread->remaining_tick; if (thread->remaining_tick == 0) { + rt_base_t level; + /* change to initialized tick */ thread->remaining_tick = thread->init_tick; + level = rt_hw_interrupt_disable(); thread->stat |= RT_THREAD_STAT_YIELD; + rt_hw_interrupt_enable(level); rt_schedule(); } -- cgit v1.3.1 From 039d7979d83666e96d7f6efb84255de0047e3e67 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 29 May 2021 17:30:18 +0800 Subject: [kernel][thread.c] 规范内部函数命名方式 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/thread.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/thread.c b/src/thread.c index e03c027eff..6304a4ebe6 100644 --- a/src/thread.c +++ b/src/thread.c @@ -79,7 +79,7 @@ void rt_thread_inited_sethook(void (*hook)(rt_thread_t thread)) #endif /* must be invoke witch rt_hw_interrupt_disable */ -static void _thread_cleanup_execute(rt_thread_t thread) +static void _rt_thread_cleanup_execute(rt_thread_t thread) { register rt_base_t level; #ifdef RT_USING_MODULE @@ -103,7 +103,7 @@ static void _thread_cleanup_execute(rt_thread_t thread) rt_hw_interrupt_enable(level); } -void rt_thread_exit(void) +static void _rt_thread_exit(void) { struct rt_thread *thread; register rt_base_t level; @@ -114,7 +114,7 @@ void rt_thread_exit(void) /* disable interrupt */ level = rt_hw_interrupt_disable(); - _thread_cleanup_execute(thread); + _rt_thread_cleanup_execute(thread); /* remove from schedule */ rt_schedule_remove_thread(thread); @@ -165,11 +165,11 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread, #ifdef ARCH_CPU_STACK_GROWS_UPWARD thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter, (void *)((char *)thread->stack_addr), - (void *)rt_thread_exit); + (void *)_rt_thread_exit); #else thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter, (rt_uint8_t *)((char *)thread->stack_addr + thread->stack_size - sizeof(rt_ubase_t)), - (void *)rt_thread_exit); + (void *)_rt_thread_exit); #endif /* priority init */ @@ -374,7 +374,7 @@ rt_err_t rt_thread_detach(rt_thread_t thread) rt_schedule_remove_thread(thread); } - _thread_cleanup_execute(thread); + _rt_thread_cleanup_execute(thread); /* release thread timer */ rt_timer_detach(&(thread->thread_timer)); @@ -472,7 +472,7 @@ rt_err_t rt_thread_delete(rt_thread_t thread) rt_schedule_remove_thread(thread); } - _thread_cleanup_execute(thread); + _rt_thread_cleanup_execute(thread); /* release thread timer */ rt_timer_detach(&(thread->thread_timer)); -- cgit v1.3.1 From 2e11562772938ec253bb60123283d476da0bdd2e Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 29 May 2021 19:10:48 +0800 Subject: [kernel][注释] 明确rt_schedule的调度时刻 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scheduler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/scheduler.c b/src/scheduler.c index c03c20d030..ed0f30fc81 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -404,7 +404,7 @@ __exit: #else /** * This function will perform one schedule. It will select one thread - * with the highest priority level, then switch to it. + * with the highest priority level, and switch to it immediately. */ void rt_schedule(void) { -- cgit v1.3.1 From 8b82b834826249dff299353da44188429d18dde2 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 30 May 2021 11:43:44 +0800 Subject: [kernel] 增加rt_mutex_trytake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rtthread.h | 1 + src/ipc.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/include/rtthread.h b/include/rtthread.h index 784b208a76..ccd2d147a8 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -322,6 +322,7 @@ rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag); rt_err_t rt_mutex_delete(rt_mutex_t mutex); rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time); +rt_err_t rt_mutex_trytake(rt_mutex_t mutex); rt_err_t rt_mutex_release(rt_mutex_t mutex); rt_err_t rt_mutex_control(rt_mutex_t mutex, int cmd, void *arg); #endif diff --git a/src/ipc.c b/src/ipc.c index 22e0f06bc6..6cd38b74ab 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -37,7 +37,8 @@ * 2020-07-29 Meco Man fix thread->event_set/event_info when received an * event without pending * 2020-10-11 Meco Man add value overflow-check code - * 2021-01-03 Meco Man add rt_mb_urgent() + * 2021-01-03 Meco Man implement rt_mb_urgent() + * 2021-05-30 Meco Man implement rt_mutex_trytake() * 2021-01-20 hupu fix priority inversion bug of mutex */ @@ -452,7 +453,7 @@ RTM_EXPORT(rt_sem_take); */ rt_err_t rt_sem_trytake(rt_sem_t sem) { - return rt_sem_take(sem, 0); + return rt_sem_take(sem, RT_WAITING_NO); } RTM_EXPORT(rt_sem_trytake); @@ -843,6 +844,19 @@ __again: } RTM_EXPORT(rt_mutex_take); +/** + * This function will try to take a mutex and immediately return + * + * @param mutex the mutex object + * + * @return the error code + */ +rt_err_t rt_mutex_trytake(rt_mutex_t mutex) +{ + return rt_mutex_take(mutex, RT_WAITING_NO); +} +RTM_EXPORT(rt_mutex_trytake); + /** * This function will release a mutex, if there are threads suspended on mutex, * it will be waked up. -- cgit v1.3.1 From f34e9323b430813a6dbb62a609cfb3980aa645b0 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 1 Jun 2021 11:42:47 +0800 Subject: 对rt_tick_increase临界区进行保护 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clock.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index 8746d463c1..045555933d 100644 --- a/src/clock.c +++ b/src/clock.c @@ -62,6 +62,9 @@ void rt_tick_set(rt_tick_t tick) void rt_tick_increase(void) { struct rt_thread *thread; + rt_base_t level; + + level = rt_hw_interrupt_disable(); /* increase the global tick */ #ifdef RT_USING_SMP @@ -76,17 +79,17 @@ void rt_tick_increase(void) -- thread->remaining_tick; if (thread->remaining_tick == 0) { - rt_base_t level; - /* change to initialized tick */ thread->remaining_tick = thread->init_tick; - - level = rt_hw_interrupt_disable(); thread->stat |= RT_THREAD_STAT_YIELD; - rt_hw_interrupt_enable(level); + rt_hw_interrupt_enable(level); rt_schedule(); } + else + { + rt_hw_interrupt_enable(level); + } /* check timer */ rt_timer_check(); -- cgit v1.3.1 From 8e8ae9c95183c4b0c7bf02b9f79a0b0c151cd7c8 Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Thu, 3 Jun 2021 15:02:00 +0800 Subject: [src][memheap] Fix the crash problem after opening Oz optimization on ac6. --- src/memheap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/memheap.c b/src/memheap.c index 63327575cc..2cfdd73ad4 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -17,6 +17,7 @@ * 2013-05-24 Bernard fix the rt_memheap_realloc issue. * 2013-07-11 Grissiom fix the memory block splitting issue. * 2013-07-15 Grissiom optimize rt_memheap_realloc + * 2021-06-03 Flybreak Fix the crash problem after opening Oz optimization on ac6. */ #include @@ -369,7 +370,8 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize) if (newsize > oldsize) { void *new_ptr; - struct rt_memheap_item *next_ptr; + /* Fix the crash problem after opening Oz optimization on ac6 */ + volatile struct rt_memheap_item *next_ptr; /* lock memheap */ result = rt_sem_take(&(heap->lock), RT_WAITING_FOREVER); @@ -441,14 +443,14 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize) next_ptr->prev = header_ptr; next_ptr->next = header_ptr->next; - header_ptr->next->prev = next_ptr; - header_ptr->next = next_ptr; + header_ptr->next->prev = (struct rt_memheap_item *)next_ptr; + header_ptr->next = (struct rt_memheap_item *)next_ptr; /* insert next_ptr to free list */ next_ptr->next_free = heap->free_list->next_free; next_ptr->prev_free = heap->free_list; - heap->free_list->next_free->prev_free = next_ptr; - heap->free_list->next_free = next_ptr; + heap->free_list->next_free->prev_free = (struct rt_memheap_item *)next_ptr; + heap->free_list->next_free = (struct rt_memheap_item *)next_ptr; RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("new ptr: next_free 0x%08x, prev_free 0x%08x", next_ptr->next_free, next_ptr->prev_free)); -- cgit v1.3.1 From 51ec75f71d7a0a74bba0fe979cba79c9732ccad1 Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Thu, 3 Jun 2021 15:13:47 +0800 Subject: [update]format memheap.c --- src/memheap.c | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/memheap.c b/src/memheap.c index 2cfdd73ad4..35a04c14b1 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -42,31 +42,31 @@ rt_inline void rt_memheap_setname(struct rt_memheap_item *item, const char *name) { int index; - rt_uint8_t* ptr; + rt_uint8_t *ptr; - ptr = (rt_uint8_t*)&(item->next_free); - for (index = 0; index < sizeof(void*); index ++) + ptr = (rt_uint8_t *) & (item->next_free); + for (index = 0; index < sizeof(void *); index ++) { if (name[index] == '\0') break; ptr[index] = name[index]; } if (name[index] == '\0') ptr[index] = '\0'; - else + else { - ptr = (rt_uint8_t*)&(item->prev_free); - for (index = 0; index < sizeof(void*) && (index + sizeof(void*))< RT_NAME_MAX; index ++) + ptr = (rt_uint8_t *) & (item->prev_free); + for (index = 0; index < sizeof(void *) && (index + sizeof(void *)) < RT_NAME_MAX; index ++) { - if (name[sizeof(void*) + index] == '\0') break; - ptr[index] = name[sizeof(void*) + index]; + if (name[sizeof(void *) + index] == '\0') break; + ptr[index] = name[sizeof(void *) + index]; } - if (name[sizeof(void*) + index] == '\0') ptr[index] = '\0'; + if (name[sizeof(void *) + index] == '\0') ptr[index] = '\0'; } } -void rt_mem_set_tag(void* ptr, const char* name) +void rt_mem_set_tag(void *ptr, const char *name) { - struct rt_memheap_item* item; + struct rt_memheap_item *item; if (ptr && name) { @@ -668,17 +668,17 @@ void rt_memheap_free(void *ptr) RTM_EXPORT(rt_memheap_free); #ifdef RT_USING_FINSH -static void _memheap_dump_tag(struct rt_memheap_item* item) +static void _memheap_dump_tag(struct rt_memheap_item *item) { - rt_uint8_t name[2 * sizeof(void*)]; - rt_uint8_t* ptr; + rt_uint8_t name[2 * sizeof(void *)]; + rt_uint8_t *ptr; - ptr = (rt_uint8_t*)&(item->next_free); - rt_memcpy(name, ptr, sizeof(void*)); - ptr = (rt_uint8_t*)&(item->prev_free); - rt_memcpy(&name[sizeof(void*)], ptr, sizeof(void*)); + ptr = (rt_uint8_t *) & (item->next_free); + rt_memcpy(name, ptr, sizeof(void *)); + ptr = (rt_uint8_t *) & (item->prev_free); + rt_memcpy(&name[sizeof(void *)], ptr, sizeof(void *)); - rt_kprintf("%.*s", 2 * sizeof(void*), name); + rt_kprintf("%.*s", 2 * sizeof(void *), name); } int rt_memheap_dump(struct rt_memheap *heap) @@ -688,15 +688,15 @@ int rt_memheap_dump(struct rt_memheap *heap) if (heap == RT_NULL) return 0; RT_ASSERT(rt_object_get_type(&heap->parent) == RT_Object_Class_MemHeap); - rt_kprintf("\n[%.*s] [0x%08x - 0x%08x]->\n", RT_NAME_MAX, heap->parent.name, - (rt_ubase_t)heap->start_addr, (rt_ubase_t)heap->start_addr + heap->pool_size); + rt_kprintf("\n[%.*s] [0x%08x - 0x%08x]->\n", RT_NAME_MAX, heap->parent.name, + (rt_ubase_t)heap->start_addr, (rt_ubase_t)heap->start_addr + heap->pool_size); rt_kprintf("------------------------------\n"); /* lock memheap */ rt_sem_take(&(heap->lock), RT_WAITING_FOREVER); item = heap->block_list; - end = (struct rt_memheap_item *) ((rt_uint8_t *)heap->start_addr + heap->pool_size - RT_MEMHEAP_SIZE); + end = (struct rt_memheap_item *)((rt_uint8_t *)heap->start_addr + heap->pool_size - RT_MEMHEAP_SIZE); /* for each memory block */ while ((rt_ubase_t)item < ((rt_ubase_t)end)) @@ -732,13 +732,13 @@ int memheaptrace(void) int index; extern int list_memheap(void); - heaps = (struct rt_memheap**)rt_malloc(sizeof(struct rt_memheap*) * count); + heaps = (struct rt_memheap **)rt_malloc(sizeof(struct rt_memheap *) * count); if (heaps == RT_NULL) return 0; list_memheap(); rt_kprintf("memheap header size: %d\n", RT_MEMHEAP_SIZE); - count = rt_object_get_pointers(RT_Object_Class_MemHeap, (rt_object_t*)heaps, count); + count = rt_object_get_pointers(RT_Object_Class_MemHeap, (rt_object_t *)heaps, count); for (index = 0; index < count; index++) { rt_memheap_dump(heaps[index]); @@ -968,15 +968,15 @@ void dump_used_memheap(struct rt_memheap *mh) { /* dump information */ rt_kprintf("[0x%08x - %d - %c%c%c%c] used\n", header_ptr, block_size, - header_ptr->owner_thread_name[0], header_ptr->owner_thread_name[1], - header_ptr->owner_thread_name[2], header_ptr->owner_thread_name[3]); + header_ptr->owner_thread_name[0], header_ptr->owner_thread_name[1], + header_ptr->owner_thread_name[2], header_ptr->owner_thread_name[3]); } else { /* dump information */ rt_kprintf("[0x%08x - %d - %c%c%c%c] free\n", header_ptr, block_size, - header_ptr->owner_thread_name[0], header_ptr->owner_thread_name[1], - header_ptr->owner_thread_name[2], header_ptr->owner_thread_name[3]); + header_ptr->owner_thread_name[0], header_ptr->owner_thread_name[1], + header_ptr->owner_thread_name[2], header_ptr->owner_thread_name[3]); } /* move to next used memory block */ -- cgit v1.3.1 From 5a6bc9900689ba2d21850cc520c3621c57037025 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 2 Jun 2021 15:30:32 +0800 Subject: [bug][kernel] 保持空闲任务钩子函数调用的原子性 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clock.c | 3 ++- src/idle.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index 045555933d..191525411a 100644 --- a/src/clock.c +++ b/src/clock.c @@ -13,7 +13,8 @@ * 2010-07-13 Bernard fix rt_tick_from_millisecond issue found by kuronca * 2011-06-26 Bernard add rt_tick_set function. * 2018-11-22 Jesven add per cpu tick - * 2020-12-29 Meco Man add function rt_tick_get_millisecond() + * 2020-12-29 Meco Man implement rt_tick_get_millisecond() + * 2021-06-01 Meco Man add critical section projection for rt_tick_increase() */ #include diff --git a/src/idle.c b/src/idle.c index 59868352d8..e73a78be9c 100644 --- a/src/idle.c +++ b/src/idle.c @@ -202,12 +202,14 @@ static void rt_thread_idle_entry(void *parameter) { #ifdef RT_USING_IDLE_HOOK rt_size_t i; + void (*idle_hook)(void); for (i = 0; i < RT_IDLE_HOOK_LIST_SIZE; i++) { - if (idle_hook_list[i] != RT_NULL) + idle_hook = idle_hook_list[i]; + if (idle_hook != RT_NULL) { - idle_hook_list[i](); + idle_hook(); } } #endif -- cgit v1.3.1 From e0b66ccab87bd5142769e0f4fd3f2b5ac14796ba Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Thu, 3 Jun 2021 20:09:26 +0800 Subject: [kernel] 对rt_tick变量增加volatile修饰,防止编译器优化时出现问题 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index 045555933d..f02c524380 100644 --- a/src/clock.c +++ b/src/clock.c @@ -22,7 +22,7 @@ #ifdef RT_USING_SMP #define rt_tick rt_cpu_index(0)->tick #else -static rt_tick_t rt_tick = 0; +static volatile rt_tick_t rt_tick = 0; #endif /** -- cgit v1.3.1 From 076941612a5105acd51a42e5c0d36eb632f5dffa Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Fri, 4 Jun 2021 00:34:27 +0800 Subject: [kernel] 规范内核内部函数命名 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/idle.c | 4 +-- src/ipc.c | 102 ++++++++++++++++++++++++++++---------------------------- src/scheduler.c | 14 ++++---- 3 files changed, 60 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/idle.c b/src/idle.c index 59868352d8..317ee76926 100644 --- a/src/idle.c +++ b/src/idle.c @@ -129,7 +129,7 @@ rt_err_t rt_thread_idle_delhook(void (*hook)(void)) #ifdef RT_USING_HEAP /* Return whether there is defunctional thread to be deleted. */ -rt_inline int _has_defunct_thread(void) +rt_inline int _rt_has_defunct_thread(void) { /* The rt_list_isempty has prototype of "int rt_list_isempty(const rt_list_t *l)". * So the compiler has a good reason that the rt_thread_defunct list does @@ -165,7 +165,7 @@ void rt_thread_idle_excute(void) lock = rt_hw_interrupt_disable(); /* check whether list is empty */ - if (!_has_defunct_thread()) + if (!_rt_has_defunct_thread()) { rt_hw_interrupt_enable(lock); break; diff --git a/src/ipc.c b/src/ipc.c index 6cd38b74ab..311724f0a6 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -64,7 +64,7 @@ extern void (*rt_object_put_hook)(struct rt_object *object); * * @return the operation status, RT_EOK on successful */ -rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc) +rt_inline rt_err_t _rt_ipc_object_init(struct rt_ipc_object *ipc) { /* initialize ipc object */ rt_list_init(&(ipc->suspend_thread)); @@ -83,7 +83,7 @@ rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc) * * @return the operation status, RT_EOK on successful */ -rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list, +rt_inline rt_err_t _rt_ipc_list_suspend(rt_list_t *list, struct rt_thread *thread, rt_uint8_t flag) { @@ -141,7 +141,7 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list, * * @return the operation status, RT_EOK on successful */ -rt_inline rt_err_t rt_ipc_list_resume(rt_list_t *list) +rt_inline rt_err_t _rt_ipc_list_resume(rt_list_t *list) { struct rt_thread *thread; @@ -164,7 +164,7 @@ rt_inline rt_err_t rt_ipc_list_resume(rt_list_t *list) * * @return the operation status, RT_EOK on successful */ -rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list) +rt_inline rt_err_t _rt_ipc_list_resume_all(rt_list_t *list) { struct rt_thread *thread; register rt_ubase_t temp; @@ -202,7 +202,7 @@ rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list) * * @return the highest priority */ -rt_uint8_t rt_ipc_get_highest_priority(rt_list_t *list) +rt_uint8_t _rt_ipc_get_highest_priority(rt_list_t *list) { struct rt_list_node *n; struct rt_thread *sthread; @@ -243,7 +243,7 @@ rt_err_t rt_sem_init(rt_sem_t sem, rt_object_init(&(sem->parent.parent), RT_Object_Class_Semaphore, name); /* initialize ipc object */ - rt_ipc_object_init(&(sem->parent)); + _rt_ipc_object_init(&(sem->parent)); /* set initial value */ sem->value = (rt_uint16_t)value; @@ -272,7 +272,7 @@ rt_err_t rt_sem_detach(rt_sem_t sem) RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent)); /* wakeup all suspended threads */ - rt_ipc_list_resume_all(&(sem->parent.suspend_thread)); + _rt_ipc_list_resume_all(&(sem->parent.suspend_thread)); /* detach semaphore object */ rt_object_detach(&(sem->parent.parent)); @@ -306,7 +306,7 @@ rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag) return sem; /* initialize ipc object */ - rt_ipc_object_init(&(sem->parent)); + _rt_ipc_object_init(&(sem->parent)); /* set initial value */ sem->value = value; @@ -337,7 +337,7 @@ rt_err_t rt_sem_delete(rt_sem_t sem) RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent) == RT_FALSE); /* wakeup all suspended threads */ - rt_ipc_list_resume_all(&(sem->parent.suspend_thread)); + _rt_ipc_list_resume_all(&(sem->parent.suspend_thread)); /* delete semaphore object */ rt_object_delete(&(sem->parent.parent)); @@ -408,7 +408,7 @@ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time) thread->name)); /* suspend thread */ - rt_ipc_list_suspend(&(sem->parent.suspend_thread), + _rt_ipc_list_suspend(&(sem->parent.suspend_thread), thread, sem->parent.parent.flag); @@ -489,7 +489,7 @@ rt_err_t rt_sem_release(rt_sem_t sem) if (!rt_list_isempty(&sem->parent.suspend_thread)) { /* resume the suspended thread */ - rt_ipc_list_resume(&(sem->parent.suspend_thread)); + _rt_ipc_list_resume(&(sem->parent.suspend_thread)); need_schedule = RT_TRUE; } else @@ -543,7 +543,7 @@ rt_err_t rt_sem_control(rt_sem_t sem, int cmd, void *arg) level = rt_hw_interrupt_disable(); /* resume all waiting thread */ - rt_ipc_list_resume_all(&sem->parent.suspend_thread); + _rt_ipc_list_resume_all(&sem->parent.suspend_thread); /* set new value */ sem->value = (rt_uint16_t)value; @@ -581,7 +581,7 @@ rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag) rt_object_init(&(mutex->parent.parent), RT_Object_Class_Mutex, name); /* initialize ipc object */ - rt_ipc_object_init(&(mutex->parent)); + _rt_ipc_object_init(&(mutex->parent)); mutex->value = 1; mutex->owner = RT_NULL; @@ -612,7 +612,7 @@ rt_err_t rt_mutex_detach(rt_mutex_t mutex) RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent)); /* wakeup all suspended threads */ - rt_ipc_list_resume_all(&(mutex->parent.suspend_thread)); + _rt_ipc_list_resume_all(&(mutex->parent.suspend_thread)); /* detach semaphore object */ rt_object_detach(&(mutex->parent.parent)); @@ -644,7 +644,7 @@ rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag) return mutex; /* initialize ipc object */ - rt_ipc_object_init(&(mutex->parent)); + _rt_ipc_object_init(&(mutex->parent)); mutex->value = 1; mutex->owner = RT_NULL; @@ -677,7 +677,7 @@ rt_err_t rt_mutex_delete(rt_mutex_t mutex) RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent) == RT_FALSE); /* wakeup all suspended threads */ - rt_ipc_list_resume_all(&(mutex->parent.suspend_thread)); + _rt_ipc_list_resume_all(&(mutex->parent.suspend_thread)); /* delete mutex object */ rt_object_delete(&(mutex->parent.parent)); @@ -791,7 +791,7 @@ __again: } /* suspend current thread */ - rt_ipc_list_suspend(&(mutex->parent.suspend_thread), + _rt_ipc_list_suspend(&(mutex->parent.suspend_thread), thread, mutex->parent.parent.flag); @@ -938,7 +938,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) * 2.The priority of the thread to be resumed is not equal to the * highest priority in the queue; */ - max_priority_in_queue = rt_ipc_get_highest_priority(&mutex->parent.suspend_thread); + max_priority_in_queue = _rt_ipc_get_highest_priority(&mutex->parent.suspend_thread); if (mutex->parent.parent.flag == RT_IPC_FLAG_FIFO && thread->current_priority != max_priority_in_queue) { @@ -958,7 +958,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) } /* resume thread */ - rt_ipc_list_resume(&(mutex->parent.suspend_thread)); + _rt_ipc_list_resume(&(mutex->parent.suspend_thread)); need_schedule = RT_TRUE; } @@ -1035,7 +1035,7 @@ rt_err_t rt_event_init(rt_event_t event, const char *name, rt_uint8_t flag) event->parent.parent.flag = flag; /* initialize ipc object */ - rt_ipc_object_init(&(event->parent)); + _rt_ipc_object_init(&(event->parent)); /* initialize event */ event->set = 0; @@ -1059,7 +1059,7 @@ rt_err_t rt_event_detach(rt_event_t event) RT_ASSERT(rt_object_is_systemobject(&event->parent.parent)); /* resume all suspended thread */ - rt_ipc_list_resume_all(&(event->parent.suspend_thread)); + _rt_ipc_list_resume_all(&(event->parent.suspend_thread)); /* detach event object */ rt_object_detach(&(event->parent.parent)); @@ -1092,7 +1092,7 @@ rt_event_t rt_event_create(const char *name, rt_uint8_t flag) event->parent.parent.flag = flag; /* initialize ipc object */ - rt_ipc_object_init(&(event->parent)); + _rt_ipc_object_init(&(event->parent)); /* initialize event */ event->set = 0; @@ -1118,7 +1118,7 @@ rt_err_t rt_event_delete(rt_event_t event) RT_DEBUG_NOT_IN_INTERRUPT; /* resume all suspended thread */ - rt_ipc_list_resume_all(&(event->parent.suspend_thread)); + _rt_ipc_list_resume_all(&(event->parent.suspend_thread)); /* delete event object */ rt_object_delete(&(event->parent.parent)); @@ -1321,7 +1321,7 @@ rt_err_t rt_event_recv(rt_event_t event, thread->event_info = option; /* put thread to suspended thread list */ - rt_ipc_list_suspend(&(event->parent.suspend_thread), + _rt_ipc_list_suspend(&(event->parent.suspend_thread), thread, event->parent.parent.flag); @@ -1387,7 +1387,7 @@ rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg) level = rt_hw_interrupt_disable(); /* resume all waiting thread */ - rt_ipc_list_resume_all(&event->parent.suspend_thread); + _rt_ipc_list_resume_all(&event->parent.suspend_thread); /* initialize event set */ event->set = 0; @@ -1433,7 +1433,7 @@ rt_err_t rt_mb_init(rt_mailbox_t mb, mb->parent.parent.flag = flag; /* initialize ipc object */ - rt_ipc_object_init(&(mb->parent)); + _rt_ipc_object_init(&(mb->parent)); /* initialize mailbox */ mb->msg_pool = (rt_ubase_t *)msgpool; @@ -1464,9 +1464,9 @@ rt_err_t rt_mb_detach(rt_mailbox_t mb) RT_ASSERT(rt_object_is_systemobject(&mb->parent.parent)); /* resume all suspended thread */ - rt_ipc_list_resume_all(&(mb->parent.suspend_thread)); + _rt_ipc_list_resume_all(&(mb->parent.suspend_thread)); /* also resume all mailbox private suspended thread */ - rt_ipc_list_resume_all(&(mb->suspend_sender_thread)); + _rt_ipc_list_resume_all(&(mb->suspend_sender_thread)); /* detach mailbox object */ rt_object_detach(&(mb->parent.parent)); @@ -1500,7 +1500,7 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag) mb->parent.parent.flag = flag; /* initialize ipc object */ - rt_ipc_object_init(&(mb->parent)); + _rt_ipc_object_init(&(mb->parent)); /* initialize mailbox */ mb->size = size; @@ -1540,10 +1540,10 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb) RT_ASSERT(rt_object_is_systemobject(&mb->parent.parent) == RT_FALSE); /* resume all suspended thread */ - rt_ipc_list_resume_all(&(mb->parent.suspend_thread)); + _rt_ipc_list_resume_all(&(mb->parent.suspend_thread)); /* also resume all mailbox private suspended thread */ - rt_ipc_list_resume_all(&(mb->suspend_sender_thread)); + _rt_ipc_list_resume_all(&(mb->suspend_sender_thread)); /* free mailbox pool */ RT_KERNEL_FREE(mb->msg_pool); @@ -1612,7 +1612,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, RT_DEBUG_IN_THREAD_CONTEXT; /* suspend current thread */ - rt_ipc_list_suspend(&(mb->suspend_sender_thread), + _rt_ipc_list_suspend(&(mb->suspend_sender_thread), thread, mb->parent.parent.flag); @@ -1679,7 +1679,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, /* resume suspended thread */ if (!rt_list_isempty(&mb->parent.suspend_thread)) { - rt_ipc_list_resume(&(mb->parent.suspend_thread)); + _rt_ipc_list_resume(&(mb->parent.suspend_thread)); /* enable interrupt */ rt_hw_interrupt_enable(temp); @@ -1760,7 +1760,7 @@ rt_err_t rt_mb_urgent(rt_mailbox_t mb, rt_ubase_t value) /* resume suspended thread */ if (!rt_list_isempty(&mb->parent.suspend_thread)) { - rt_ipc_list_resume(&(mb->parent.suspend_thread)); + _rt_ipc_list_resume(&(mb->parent.suspend_thread)); /* enable interrupt */ rt_hw_interrupt_enable(temp); @@ -1834,7 +1834,7 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout) RT_DEBUG_IN_THREAD_CONTEXT; /* suspend current thread */ - rt_ipc_list_suspend(&(mb->parent.suspend_thread), + _rt_ipc_list_suspend(&(mb->parent.suspend_thread), thread, mb->parent.parent.flag); @@ -1897,7 +1897,7 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout) /* resume suspended thread */ if (!rt_list_isempty(&(mb->suspend_sender_thread))) { - rt_ipc_list_resume(&(mb->suspend_sender_thread)); + _rt_ipc_list_resume(&(mb->suspend_sender_thread)); /* enable interrupt */ rt_hw_interrupt_enable(temp); @@ -1941,9 +1941,9 @@ rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg) level = rt_hw_interrupt_disable(); /* resume all waiting thread */ - rt_ipc_list_resume_all(&(mb->parent.suspend_thread)); + _rt_ipc_list_resume_all(&(mb->parent.suspend_thread)); /* also resume all mailbox private suspended thread */ - rt_ipc_list_resume_all(&(mb->suspend_sender_thread)); + _rt_ipc_list_resume_all(&(mb->suspend_sender_thread)); /* re-init mailbox */ mb->entry = 0; @@ -2002,7 +2002,7 @@ rt_err_t rt_mq_init(rt_mq_t mq, mq->parent.parent.flag = flag; /* initialize ipc object */ - rt_ipc_object_init(&(mq->parent)); + _rt_ipc_object_init(&(mq->parent)); /* set message pool */ mq->msg_pool = msgpool; @@ -2050,9 +2050,9 @@ rt_err_t rt_mq_detach(rt_mq_t mq) RT_ASSERT(rt_object_is_systemobject(&mq->parent.parent)); /* resume all suspended thread */ - rt_ipc_list_resume_all(&mq->parent.suspend_thread); + _rt_ipc_list_resume_all(&mq->parent.suspend_thread); /* also resume all message queue private suspended thread */ - rt_ipc_list_resume_all(&(mq->suspend_sender_thread)); + _rt_ipc_list_resume_all(&(mq->suspend_sender_thread)); /* detach message queue object */ rt_object_detach(&(mq->parent.parent)); @@ -2092,7 +2092,7 @@ rt_mq_t rt_mq_create(const char *name, mq->parent.parent.flag = flag; /* initialize ipc object */ - rt_ipc_object_init(&(mq->parent)); + _rt_ipc_object_init(&(mq->parent)); /* initialize message queue */ @@ -2150,9 +2150,9 @@ rt_err_t rt_mq_delete(rt_mq_t mq) RT_ASSERT(rt_object_is_systemobject(&mq->parent.parent) == RT_FALSE); /* resume all suspended thread */ - rt_ipc_list_resume_all(&(mq->parent.suspend_thread)); + _rt_ipc_list_resume_all(&(mq->parent.suspend_thread)); /* also resume all message queue private suspended thread */ - rt_ipc_list_resume_all(&(mq->suspend_sender_thread)); + _rt_ipc_list_resume_all(&(mq->suspend_sender_thread)); /* free message queue pool */ RT_KERNEL_FREE(mq->msg_pool); @@ -2234,7 +2234,7 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq, RT_DEBUG_IN_THREAD_CONTEXT; /* suspend current thread */ - rt_ipc_list_suspend(&(mq->suspend_sender_thread), + _rt_ipc_list_suspend(&(mq->suspend_sender_thread), thread, mq->parent.parent.flag); @@ -2320,7 +2320,7 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq, /* resume suspended thread */ if (!rt_list_isempty(&mq->parent.suspend_thread)) { - rt_ipc_list_resume(&(mq->parent.suspend_thread)); + _rt_ipc_list_resume(&(mq->parent.suspend_thread)); /* enable interrupt */ rt_hw_interrupt_enable(temp); @@ -2428,7 +2428,7 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size) /* resume suspended thread */ if (!rt_list_isempty(&mq->parent.suspend_thread)) { - rt_ipc_list_resume(&(mq->parent.suspend_thread)); + _rt_ipc_list_resume(&(mq->parent.suspend_thread)); /* enable interrupt */ rt_hw_interrupt_enable(temp); @@ -2510,7 +2510,7 @@ rt_err_t rt_mq_recv(rt_mq_t mq, } /* suspend current thread */ - rt_ipc_list_suspend(&(mq->parent.suspend_thread), + _rt_ipc_list_suspend(&(mq->parent.suspend_thread), thread, mq->parent.parent.flag); @@ -2586,7 +2586,7 @@ rt_err_t rt_mq_recv(rt_mq_t mq, /* resume suspended thread */ if (!rt_list_isempty(&(mq->suspend_sender_thread))) { - rt_ipc_list_resume(&(mq->suspend_sender_thread)); + _rt_ipc_list_resume(&(mq->suspend_sender_thread)); /* enable interrupt */ rt_hw_interrupt_enable(temp); @@ -2632,9 +2632,9 @@ rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg) level = rt_hw_interrupt_disable(); /* resume all waiting thread */ - rt_ipc_list_resume_all(&mq->parent.suspend_thread); + _rt_ipc_list_resume_all(&mq->parent.suspend_thread); /* also resume all message queue private suspended thread */ - rt_ipc_list_resume_all(&(mq->suspend_sender_thread)); + _rt_ipc_list_resume_all(&(mq->suspend_sender_thread)); /* release all message in the queue */ while (mq->msg_queue_head != RT_NULL) diff --git a/src/scheduler.c b/src/scheduler.c index ed0f30fc81..179ad85e07 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -23,7 +23,7 @@ * 2013-12-21 Grissiom add rt_critical_level * 2018-11-22 Jesven remove the current task from ready queue * add per cpu ready queue - * add _get_highest_priority_thread to find highest priority task + * add _rt_get_highest_priority_thread to find highest priority task * rt_schedule_insert_thread won't insert current task to ready queue * in smp version, rt_hw_context_switch_interrupt maybe switch to * new task directly @@ -114,7 +114,7 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread) * get the highest priority thread in ready queue */ #ifdef RT_USING_SMP -static struct rt_thread* _get_highest_priority_thread(rt_ubase_t *highest_prio) +static struct rt_thread* _rt_get_highest_priority_thread(rt_ubase_t *highest_prio) { register struct rt_thread *highest_priority_thread; register rt_ubase_t highest_ready_priority, local_highest_ready_priority; @@ -150,7 +150,7 @@ static struct rt_thread* _get_highest_priority_thread(rt_ubase_t *highest_prio) return highest_priority_thread; } #else -static struct rt_thread* _get_highest_priority_thread(rt_ubase_t *highest_prio) +static struct rt_thread* _rt_get_highest_priority_thread(rt_ubase_t *highest_prio) { register struct rt_thread *highest_priority_thread; register rt_ubase_t highest_ready_priority; @@ -239,7 +239,7 @@ void rt_system_scheduler_start(void) register struct rt_thread *to_thread; rt_ubase_t highest_ready_priority; - to_thread = _get_highest_priority_thread(&highest_ready_priority); + to_thread = _rt_get_highest_priority_thread(&highest_ready_priority); #ifdef RT_USING_SMP to_thread->oncpu = rt_hw_cpu_id(); @@ -327,7 +327,7 @@ void rt_schedule(void) if (rt_thread_ready_priority_group != 0 || pcpu->priority_group != 0) { - to_thread = _get_highest_priority_thread(&highest_ready_priority); + to_thread = _rt_get_highest_priority_thread(&highest_ready_priority); current_thread->oncpu = RT_CPU_DETACHED; if ((current_thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_RUNNING) { @@ -425,7 +425,7 @@ void rt_schedule(void) /* need_insert_from_thread: need to insert from_thread to ready queue */ int need_insert_from_thread = 0; - to_thread = _get_highest_priority_thread(&highest_ready_priority); + to_thread = _rt_get_highest_priority_thread(&highest_ready_priority); if ((rt_current_thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_RUNNING) { @@ -576,7 +576,7 @@ void rt_scheduler_do_irq_switch(void *context) if (rt_thread_ready_priority_group != 0 || pcpu->priority_group != 0) { - to_thread = _get_highest_priority_thread(&highest_ready_priority); + to_thread = _rt_get_highest_priority_thread(&highest_ready_priority); current_thread->oncpu = RT_CPU_DETACHED; if ((current_thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_RUNNING) { -- cgit v1.3.1 From 2b6762e85955a10e0150a3f32b869104a106acbd Mon Sep 17 00:00:00 2001 From: Meco Jianting Man <920369182@qq.com> Date: Sat, 5 Jun 2021 13:05:11 +0800 Subject: remove fix priority inversion bug of mutex --- src/ipc.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/ipc.c b/src/ipc.c index 74b47df3b6..bda32dbf26 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -39,7 +39,6 @@ * 2020-10-11 Meco Man add value overflow-check code * 2021-01-03 Meco Man implement rt_mb_urgent() * 2021-05-30 Meco Man implement rt_mutex_trytake() - * 2021-01-20 hupu fix priority inversion bug of mutex */ #include -- cgit v1.3.1 From b2dd3f00f0617abd5757ca75a5579d493dc8bd85 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 7 Jun 2021 16:45:39 +0800 Subject: [bug][kernel][heap] 将内存堆保护机制由FIFO改为PRIO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mem.c | 2 +- src/memheap.c | 2 +- src/slab.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mem.c b/src/mem.c index ac0d27f2c3..2b4d3a03be 100644 --- a/src/mem.c +++ b/src/mem.c @@ -250,7 +250,7 @@ void rt_system_heap_init(void *begin_addr, void *end_addr) rt_mem_setname(heap_end, "INIT"); #endif - rt_sem_init(&heap_sem, "heap", 1, RT_IPC_FLAG_FIFO); + rt_sem_init(&heap_sem, "heap", 1, RT_IPC_FLAG_PRIO); /* initialize the lowest-free pointer to the start of the heap */ lfree = (struct heap_mem *)heap_ptr; diff --git a/src/memheap.c b/src/memheap.c index 35a04c14b1..d3ad6d2c36 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -155,7 +155,7 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap, item->next_free = item->prev_free = RT_NULL; /* initialize semaphore lock */ - rt_sem_init(&(memheap->lock), name, 1, RT_IPC_FLAG_FIFO); + rt_sem_init(&(memheap->lock), name, 1, RT_IPC_FLAG_PRIO); RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("memory heap: start addr 0x%08x, size %d, free list header 0x%08x\n", diff --git a/src/slab.c b/src/slab.c index 114259002f..2769892b68 100644 --- a/src/slab.c +++ b/src/slab.c @@ -363,7 +363,7 @@ void rt_system_heap_init(void *begin_addr, void *end_addr) npages = limsize / RT_MM_PAGE_SIZE; /* initialize heap semaphore */ - rt_sem_init(&heap_sem, "heap", 1, RT_IPC_FLAG_FIFO); + rt_sem_init(&heap_sem, "heap", 1, RT_IPC_FLAG_PRIO); RT_DEBUG_LOG(RT_DEBUG_SLAB, ("heap[0x%x - 0x%x], size 0x%x, 0x%x pages\n", heap_start, heap_end, limsize, npages)); -- cgit v1.3.1 From bb848db2a40fd02ffaf059367a2e21603e47866c Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 8 Jun 2021 10:49:20 +0800 Subject: 解决冲突 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ipc.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'src') diff --git a/src/ipc.c b/src/ipc.c index 311724f0a6..b586a44181 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -194,31 +194,6 @@ rt_inline rt_err_t _rt_ipc_list_resume_all(rt_list_t *list) return RT_EOK; } -/** - * This function will get the highest priority from the specified - * list of threads - * - * @param list of the threads - * - * @return the highest priority - */ -rt_uint8_t _rt_ipc_get_highest_priority(rt_list_t *list) -{ - struct rt_list_node *n; - struct rt_thread *sthread; - rt_uint8_t priority = RT_THREAD_PRIORITY_MAX - 1; - - for (n = list->next; n != list; n = n->next) - { - sthread = rt_list_entry(n, struct rt_thread, tlist); - - priority = priority < sthread->current_priority ? - priority : - sthread->current_priority; - } - return priority; -} - #ifdef RT_USING_SEMAPHORE /** * This function will initialize a semaphore and put it under control of @@ -870,7 +845,6 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) register rt_base_t temp; struct rt_thread *thread; rt_bool_t need_schedule; - rt_uint8_t max_priority_in_queue = RT_THREAD_PRIORITY_MAX - 1; /* parameter check */ RT_ASSERT(mutex != RT_NULL); @@ -932,21 +906,6 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) mutex->owner = thread; mutex->original_priority = thread->current_priority; - /* Priority adjustment occurs only when the following conditions - * are met simultaneously: - * 1.The type of mutex is RT_IPC_FLAG_FIFO; - * 2.The priority of the thread to be resumed is not equal to the - * highest priority in the queue; - */ - max_priority_in_queue = _rt_ipc_get_highest_priority(&mutex->parent.suspend_thread); - if (mutex->parent.parent.flag == RT_IPC_FLAG_FIFO && - thread->current_priority != max_priority_in_queue) - { - rt_thread_control(thread, - RT_THREAD_CTRL_CHANGE_PRIORITY, - &(max_priority_in_queue)); - } - if(mutex->hold < RT_MUTEX_HOLD_MAX) { mutex->hold ++; -- cgit v1.3.1 From 24b4b6cbb9d4b646ed52f1fc996e90f638a7aba6 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 9 Jun 2021 19:50:03 +0800 Subject: [kernel]补充endif后缀注释 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clock.c | 6 +++--- src/components.c | 26 +++++++++++++------------- src/cpu.c | 2 +- src/device.c | 14 +++++++------- src/idle.c | 32 ++++++++++++++++---------------- 5 files changed, 40 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index 7df13775b2..77516b3775 100644 --- a/src/clock.c +++ b/src/clock.c @@ -24,7 +24,7 @@ #define rt_tick rt_cpu_index(0)->tick #else static volatile rt_tick_t rt_tick = 0; -#endif +#endif /* RT_USING_SMP */ /** * @addtogroup Clock @@ -72,7 +72,7 @@ void rt_tick_increase(void) rt_cpu_self()->tick ++; #else ++ rt_tick; -#endif +#endif /* RT_USING_SMP */ /* check time slice */ thread = rt_thread_self(); @@ -138,7 +138,7 @@ RT_WEAK rt_tick_t rt_tick_get_millisecond(void) #warning "rt-thread cannot provide a correct 1ms-based tick any longer,\ please redefine this function in another file by using a high-precision hard-timer." return 0; -#endif +#endif /* 1000 % RT_TICK_PER_SECOND == 0u */ } /**@}*/ diff --git a/src/components.c b/src/components.c index 9709d0aae2..d684d5e6fd 100644 --- a/src/components.c +++ b/src/components.c @@ -23,11 +23,11 @@ #ifdef RT_USING_USER_MAIN #ifndef RT_MAIN_THREAD_STACK_SIZE #define RT_MAIN_THREAD_STACK_SIZE 2048 -#endif +#endif /* RT_MAIN_THREAD_STACK_SIZE */ #ifndef RT_MAIN_THREAD_PRIORITY #define RT_MAIN_THREAD_PRIORITY (RT_THREAD_PRIORITY_MAX / 3) -#endif -#endif +#endif /* RT_MAIN_THREAD_PRIORITY */ +#endif /* RT_USING_USER_MAIN */ #ifdef RT_USING_COMPONENTS_INIT /* @@ -98,7 +98,7 @@ void rt_components_board_init(void) { (*fn_ptr)(); } -#endif +#endif /* RT_DEBUG_INIT */ } /** @@ -124,9 +124,9 @@ void rt_components_init(void) { (*fn_ptr)(); } -#endif +#endif /* RT_DEBUG_INIT */ } -#endif /* RT_USING_COMPONENTS_INIT */ +#endif /* RT_USING_COMPONENTS_INIT */ #ifdef RT_USING_USER_MAIN @@ -167,7 +167,7 @@ int entry(void) ALIGN(8) static rt_uint8_t main_stack[RT_MAIN_THREAD_STACK_SIZE]; struct rt_thread main_thread; -#endif +#endif /* RT_USING_HEAP */ /* the system main thread */ void main_thread_entry(void *parameter) @@ -177,11 +177,11 @@ void main_thread_entry(void *parameter) #ifdef RT_USING_COMPONENTS_INIT /* RT-Thread components initialization */ rt_components_init(); -#endif +#endif /* RT_USING_COMPONENTS_INIT */ #ifdef RT_USING_SMP rt_hw_secondary_cpu_up(); -#endif +#endif /* RT_USING_SMP */ /* invoke system main function */ #if defined(__CC_ARM) || defined(__CLANG_ARM) { @@ -211,7 +211,7 @@ void rt_application_init(void) /* if not define RT_USING_HEAP, using to eliminate the warning */ (void)result; -#endif +#endif /* RT_USING_HEAP */ rt_thread_startup(tid); } @@ -237,7 +237,7 @@ int rtthread_startup(void) #ifdef RT_USING_SIGNALS /* signal system initialization */ rt_system_signal_init(); -#endif +#endif /* RT_USING_SIGNALS */ /* create init_thread */ rt_application_init(); @@ -250,7 +250,7 @@ int rtthread_startup(void) #ifdef RT_USING_SMP rt_hw_spin_lock(&_cpus_lock); -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ /* start scheduler */ rt_system_scheduler_start(); @@ -258,4 +258,4 @@ int rtthread_startup(void) /* never reach here */ return 0; } -#endif +#endif /* RT_USING_USER_MAIN */ diff --git a/src/cpu.c b/src/cpu.c index 48ddb12c46..a7d56ba999 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -185,4 +185,4 @@ void rt_cpus_lock_status_restore(struct rt_thread *thread) } RTM_EXPORT(rt_cpus_lock_status_restore); -#endif +#endif /* RT_USING_SMP */ diff --git a/src/device.c b/src/device.c index 50b83c7692..a9c244d306 100644 --- a/src/device.c +++ b/src/device.c @@ -16,9 +16,9 @@ */ #include -#if defined(RT_USING_POSIX) +#ifdef RT_USING_POSIX #include /* for wqueue_init */ -#endif +#endif /* RT_USING_POSIX */ #ifdef RT_USING_DEVICE @@ -36,7 +36,7 @@ #define device_read (dev->read) #define device_write (dev->write) #define device_control (dev->control) -#endif +#endif /* RT_USING_DEVICE_OPS */ /** * This function registers a device driver with specified name. @@ -62,10 +62,10 @@ rt_err_t rt_device_register(rt_device_t dev, dev->ref_count = 0; dev->open_flag = 0; -#if defined(RT_USING_POSIX) +#ifdef RT_USING_POSIX dev->fops = RT_NULL; rt_wqueue_init(&(dev->wait_queue)); -#endif +#endif /* RT_USING_POSIX */ return RT_EOK; } @@ -150,7 +150,7 @@ void rt_device_destroy(rt_device_t dev) rt_free(dev); } RTM_EXPORT(rt_device_destroy); -#endif +#endif /* RT_USING_HEAP */ /** * This function will initialize the specified device @@ -434,4 +434,4 @@ rt_device_set_tx_complete(rt_device_t dev, } RTM_EXPORT(rt_device_set_tx_complete); -#endif +#endif /* RT_USING_DEVICE */ diff --git a/src/idle.c b/src/idle.c index e73a78be9c..db256a6010 100644 --- a/src/idle.c +++ b/src/idle.c @@ -22,27 +22,27 @@ #ifdef RT_USING_MODULE #include -#endif +#endif /* RT_USING_MODULE */ -#if defined (RT_USING_HOOK) +#ifdef RT_USING_HOOK #ifndef RT_USING_IDLE_HOOK #define RT_USING_IDLE_HOOK -#endif -#endif +#endif /* RT_USING_IDLE_HOOK */ +#endif /* RT_USING_HOOK */ #ifndef IDLE_THREAD_STACK_SIZE #if defined (RT_USING_IDLE_HOOK) || defined(RT_USING_HEAP) #define IDLE_THREAD_STACK_SIZE 256 #else #define IDLE_THREAD_STACK_SIZE 128 -#endif -#endif +#endif /* (RT_USING_IDLE_HOOK) || defined(RT_USING_HEAP) */ +#endif /* IDLE_THREAD_STACK_SIZE */ #ifdef RT_USING_SMP #define _CPUS_NR RT_CPUS_NR #else #define _CPUS_NR 1 -#endif +#endif /* RT_USING_SMP */ extern rt_list_t rt_thread_defunct; @@ -53,7 +53,7 @@ static rt_uint8_t rt_thread_stack[_CPUS_NR][IDLE_THREAD_STACK_SIZE]; #ifdef RT_USING_IDLE_HOOK #ifndef RT_IDLE_HOOK_LIST_SIZE #define RT_IDLE_HOOK_LIST_SIZE 4 -#endif +#endif /* RT_IDLE_HOOK_LIST_SIZE */ static void (*idle_hook_list[RT_IDLE_HOOK_LIST_SIZE])(void); @@ -125,7 +125,7 @@ rt_err_t rt_thread_idle_delhook(void (*hook)(void)) return ret; } -#endif +#endif /* RT_USING_IDLE_HOOK */ #ifdef RT_USING_HEAP /* Return whether there is defunctional thread to be deleted. */ @@ -141,7 +141,7 @@ rt_inline int _has_defunct_thread(void) return l->next != l; } -#endif +#endif /* RT_USING_HEAP */ /** * @ingroup Thread @@ -182,7 +182,7 @@ void rt_thread_idle_excute(void) rt_object_delete((rt_object_t)thread); rt_hw_interrupt_enable(lock); } -#endif +#endif /* RT_USING_HEAP */ } extern void rt_system_power_manager(void); @@ -196,7 +196,7 @@ static void rt_thread_idle_entry(void *parameter) rt_hw_secondary_cpu_idle_exec(); } } -#endif +#endif /* RT_USING_SMP */ while (1) { @@ -212,12 +212,12 @@ static void rt_thread_idle_entry(void *parameter) idle_hook(); } } -#endif +#endif /* RT_USING_IDLE_HOOK */ rt_thread_idle_excute(); #ifdef RT_USING_PM rt_system_power_manager(); -#endif +#endif /* RT_USING_PM */ } } @@ -246,7 +246,7 @@ void rt_thread_idle_init(void) 32); #ifdef RT_USING_SMP rt_thread_control(&idle[i], RT_THREAD_CTRL_BIND_CPU, (void*)i); -#endif +#endif /* RT_USING_SMP */ /* startup */ rt_thread_startup(&idle[i]); } @@ -264,7 +264,7 @@ rt_thread_t rt_thread_idle_gethandler(void) register int id = rt_hw_cpu_id(); #else register int id = 0; -#endif +#endif /* RT_USING_SMP */ return (rt_thread_t)(&idle[id]); } -- cgit v1.3.1 From e019a57ff30b9fda5aa43fdc97eac5cca80bbc3b Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Thu, 10 Jun 2021 17:58:31 +0800 Subject: [kernel] 补充endif后缀注释(2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ipc.c | 30 ++++++++++++++--------------- src/irq.c | 6 ++---- src/kservice.c | 60 +++++++++++++++++++++++++++++----------------------------- 3 files changed, 47 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/ipc.c b/src/ipc.c index bda32dbf26..c981aabe43 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -48,7 +48,7 @@ extern void (*rt_object_trytake_hook)(struct rt_object *object); extern void (*rt_object_take_hook)(struct rt_object *object); extern void (*rt_object_put_hook)(struct rt_object *object); -#endif +#endif /* RT_USING_HOOK */ /** * @addtogroup IPC @@ -93,7 +93,7 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list, { case RT_IPC_FLAG_FIFO: rt_list_insert_before(list, &(thread->tlist)); - break; + break; /* RT_IPC_FLAG_FIFO */ case RT_IPC_FLAG_PRIO: { @@ -121,7 +121,7 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list, if (n == list) rt_list_insert_before(list, &(thread->tlist)); } - break; + break;/* RT_IPC_FLAG_PRIO */ default: RT_ASSERT(0); @@ -319,7 +319,7 @@ rt_err_t rt_sem_delete(rt_sem_t sem) return RT_EOK; } RTM_EXPORT(rt_sem_delete); -#endif +#endif /* RT_USING_HEAP */ /** * This function will take a semaphore, if the semaphore is unavailable, the @@ -533,7 +533,7 @@ rt_err_t rt_sem_control(rt_sem_t sem, int cmd, void *arg) return -RT_ERROR; } RTM_EXPORT(rt_sem_control); -#endif /* end of RT_USING_SEMAPHORE */ +#endif /* RT_USING_SEMAPHORE */ #ifdef RT_USING_MUTEX /** @@ -659,7 +659,7 @@ rt_err_t rt_mutex_delete(rt_mutex_t mutex) return RT_EOK; } RTM_EXPORT(rt_mutex_delete); -#endif +#endif /* RT_USING_HEAP */ /** * This function will take a mutex, if the mutex is unavailable, the @@ -714,7 +714,7 @@ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time) { #ifdef RT_USING_SIGNALS __again: -#endif /* end of RT_USING_SIGNALS */ +#endif /* RT_USING_SIGNALS */ /* The value of mutex is 1 in initial status. Therefore, if the * value is great than 0, it indicates the mutex is avaible. */ @@ -794,7 +794,7 @@ __again: #ifdef RT_USING_SIGNALS /* interrupt by signal, try it again */ if (thread->error == -RT_EINTR) goto __again; -#endif /* end of RT_USING_SIGNALS */ +#endif /* RT_USING_SIGNALS */ /* return error */ return thread->error; @@ -968,7 +968,7 @@ rt_err_t rt_mutex_control(rt_mutex_t mutex, int cmd, void *arg) return -RT_ERROR; } RTM_EXPORT(rt_mutex_control); -#endif /* end of RT_USING_MUTEX */ +#endif /* RT_USING_MUTEX */ #ifdef RT_USING_EVENT /** @@ -1084,7 +1084,7 @@ rt_err_t rt_event_delete(rt_event_t event) return RT_EOK; } RTM_EXPORT(rt_event_delete); -#endif +#endif /* RT_USING_HEAP */ /** * This function will send an event to the event object, if there are threads @@ -1361,7 +1361,7 @@ rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg) return -RT_ERROR; } RTM_EXPORT(rt_event_control); -#endif /* end of RT_USING_EVENT */ +#endif /* RT_USING_EVENT */ #ifdef RT_USING_MAILBOX /** @@ -1512,7 +1512,7 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb) return RT_EOK; } RTM_EXPORT(rt_mb_delete); -#endif +#endif /* RT_USING_HEAP */ /** * This function will send a mail to mailbox object. If the mailbox is full, @@ -1919,7 +1919,7 @@ rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg) return -RT_ERROR; } RTM_EXPORT(rt_mb_control); -#endif /* end of RT_USING_MAILBOX */ +#endif /* RT_USING_MAILBOX */ #ifdef RT_USING_MESSAGEQUEUE struct rt_mq_message @@ -2121,7 +2121,7 @@ rt_err_t rt_mq_delete(rt_mq_t mq) return RT_EOK; } RTM_EXPORT(rt_mq_delete); -#endif +#endif /* RT_USING_HEAP */ /** * This function will send a message to message queue object. If the message queue is full, @@ -2625,6 +2625,6 @@ rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg) return -RT_ERROR; } RTM_EXPORT(rt_mq_control); -#endif /* end of RT_USING_MESSAGEQUEUE */ +#endif /* RT_USING_MESSAGEQUEUE */ /**@}*/ diff --git a/src/irq.c b/src/irq.c index 65fc2ea5e0..e89b8504dc 100644 --- a/src/irq.c +++ b/src/irq.c @@ -39,9 +39,7 @@ void rt_interrupt_leave_sethook(void (*hook)(void)) { rt_interrupt_leave_hook = hook; } -#endif - -/* #define IRQ_DEBUG */ +#endif /* RT_USING_HOOK */ /** * @addtogroup Kernel @@ -53,7 +51,7 @@ void rt_interrupt_leave_sethook(void (*hook)(void)) #define rt_interrupt_nest rt_cpu_self()->irq_nest #else volatile rt_uint8_t rt_interrupt_nest = 0; -#endif +#endif /* RT_USING_SMP */ /** * This function will be invoked by BSP, when enter interrupt service routine diff --git a/src/kservice.c b/src/kservice.c index 7ed05b6651..c4bbdd9151 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -25,7 +25,7 @@ #ifdef RT_USING_MODULE #include -#endif +#endif /* RT_USING_MODULE */ /* use precision */ #define RT_PRINTF_PRECISION @@ -194,7 +194,7 @@ RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count) #undef LBLOCKSIZE #undef UNALIGNED #undef TOO_SMALL -#endif +#endif /* RT_KSERVICE_USING_TINY_SIZE */ } RTM_EXPORT(rt_memset); @@ -277,7 +277,7 @@ RT_WEAK void *rt_memcpy(void *dst, const void *src, rt_ubase_t count) #undef BIGBLOCKSIZE #undef LITTLEBLOCKSIZE #undef TOO_SMALL -#endif +#endif /* RT_KSERVICE_USING_TINY_SIZE */ } RTM_EXPORT(rt_memcpy); @@ -509,7 +509,7 @@ rt_size_t rt_strlen(const char *s) } RTM_EXPORT(rt_strlen); -#endif /*RT_KSERVICE_USING_STDLIB*/ +#endif /* RT_KSERVICE_USING_STDLIB */ #ifdef RT_USING_HEAP /** @@ -535,7 +535,7 @@ RTM_EXPORT(rt_strdup); #if defined(__CC_ARM) || defined(__CLANG_ARM) char *strdup(const char *s) __attribute__((alias("rt_strdup"))); #endif -#endif +#endif /* RT_USING_HEAP */ /** * This function will show the version of rt-thread rtos @@ -591,7 +591,7 @@ rt_inline int divide(long *n, int base) return res; } -#endif +#endif /* RT_PRINTF_LONGLONG */ rt_inline int skip_atoi(const char **s) { @@ -617,7 +617,7 @@ static char *print_number(char *buf, long long num, #else long num, -#endif +#endif /* RT_PRINTF_LONGLONG */ int base, int s, int precision, @@ -629,18 +629,18 @@ static char *print_number(char *buf, long long num, #else long num, -#endif +#endif /* RT_PRINTF_LONGLONG */ int base, int s, int type) -#endif +#endif /* RT_PRINTF_PRECISION */ { char c, sign; #ifdef RT_PRINTF_LONGLONG char tmp[32]; #else char tmp[16]; -#endif +#endif /* RT_PRINTF_LONGLONG */ int precision_bak = precision; const char *digits; static const char small_digits[] = "0123456789abcdef"; @@ -679,7 +679,7 @@ static char *print_number(char *buf, else if (base == 8) size--; } -#endif +#endif /* RT_PRINTF_SPECIAL */ i = 0; if (num == 0) @@ -696,7 +696,7 @@ static char *print_number(char *buf, size -= precision; #else size -= i; -#endif +#endif /* RT_PRINTF_PRECISION */ if (!(type & (ZEROPAD | LEFT))) { @@ -742,7 +742,7 @@ static char *print_number(char *buf, ++ buf; } } -#endif +#endif /* RT_PRINTF_SPECIAL */ /* no align to the left */ if (!(type & LEFT)) @@ -762,7 +762,7 @@ static char *print_number(char *buf, *buf = '0'; ++ buf; } -#endif +#endif /* RT_PRINTF_PRECISION */ /* put number in the temporary buffer */ while (i-- > 0 && (precision_bak != 0)) @@ -791,7 +791,7 @@ rt_int32_t rt_vsnprintf(char *buf, unsigned long long num; #else rt_uint32_t num; -#endif +#endif /* RT_PRINTF_LONGLONG */ int i, len; char *str, *end, c; const char *s; @@ -803,7 +803,7 @@ rt_int32_t rt_vsnprintf(char *buf, #ifdef RT_PRINTF_PRECISION int precision; /* min. # of digits for integers and max for a string */ -#endif +#endif /* RT_PRINTF_PRECISION */ str = buf; end = buf + size; @@ -870,14 +870,14 @@ rt_int32_t rt_vsnprintf(char *buf, } if (precision < 0) precision = 0; } -#endif +#endif /* RT_PRINTF_PRECISION */ /* get the conversion qualifier */ qualifier = 0; #ifdef RT_PRINTF_LONGLONG if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') #else if (*fmt == 'h' || *fmt == 'l') -#endif +#endif /* RT_PRINTF_LONGLONG */ { qualifier = *fmt; ++ fmt; @@ -887,7 +887,7 @@ rt_int32_t rt_vsnprintf(char *buf, qualifier = 'L'; ++ fmt; } -#endif +#endif /* RT_PRINTF_LONGLONG */ } /* the default base */ @@ -925,7 +925,7 @@ rt_int32_t rt_vsnprintf(char *buf, for (len = 0; (len != field_width) && (s[len] != '\0'); len++); #ifdef RT_PRINTF_PRECISION if (precision > 0 && len > precision) len = precision; -#endif +#endif /* RT_PRINTF_PRECISION */ if (!(flags & LEFT)) { @@ -964,7 +964,7 @@ rt_int32_t rt_vsnprintf(char *buf, str = print_number(str, end, (long)va_arg(args, void *), 16, field_width, flags); -#endif +#endif /* RT_PRINTF_PRECISION */ continue; case '%': @@ -1010,7 +1010,7 @@ rt_int32_t rt_vsnprintf(char *buf, else if (qualifier == 'l') #else if (qualifier == 'l') -#endif +#endif /* RT_PRINTF_LONGLONG */ { num = va_arg(args, rt_uint32_t); if (flags & SIGN) num = (rt_int32_t)num; @@ -1029,7 +1029,7 @@ rt_int32_t rt_vsnprintf(char *buf, str = print_number(str, end, num, base, field_width, precision, flags); #else str = print_number(str, end, num, base, field_width, flags); -#endif +#endif /* RT_PRINTF_PRECISION */ } if (size > 0) @@ -1152,7 +1152,7 @@ rt_device_t rt_console_set_device(const char *name) return old_device; } RTM_EXPORT(rt_console_set_device); -#endif +#endif /* RT_USING_DEVICE */ RT_WEAK void rt_hw_console_output(const char *str) { @@ -1184,7 +1184,7 @@ void rt_kputs(const char *str) } #else rt_hw_console_output(str); -#endif +#endif /* RT_USING_DEVICE */ } /** @@ -1222,11 +1222,11 @@ RT_WEAK void rt_kprintf(const char *fmt, ...) } #else rt_hw_console_output(rt_log_buf); -#endif +#endif /* RT_USING_DEVICE */ va_end(args); } RTM_EXPORT(rt_kprintf); -#endif +#endif /* RT_USING_CONSOLE */ #ifdef RT_USING_HEAP /** @@ -1292,7 +1292,7 @@ void rt_free_align(void *ptr) rt_free(real_ptr); } RTM_EXPORT(rt_free_align); -#endif +#endif /* RT_USING_HEAP */ #ifndef RT_USING_CPU_FFS const rt_uint8_t __lowest_bit_bitmap[] = @@ -1340,7 +1340,7 @@ int __rt_ffs(int value) return __lowest_bit_bitmap[(value & 0xff000000) >> 24] + 25; } -#endif +#endif /* RT_USING_CPU_FFS */ #ifdef RT_DEBUG /* RT_ASSERT(EX)'s hook */ @@ -1377,7 +1377,7 @@ void rt_assert_handler(const char *ex_string, const char *func, rt_size_t line) dlmodule_exit(-1); } else -#endif +#endif /*RT_USING_MODULE*/ { rt_kprintf("(%s) assertion failed at function:%s, line number:%d \n", ex_string, func, line); while (dummy == 0); -- cgit v1.3.1 From 8b53609f574209b11f649f946466fd0e0244eb60 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Thu, 10 Jun 2021 18:33:47 +0800 Subject: [kernel] 补充endif后缀注释(3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/memheap.c | 30 +++++++++++------------ src/mempool.c | 7 +++--- src/object.c | 14 +++++------ src/scheduler.c | 76 ++++++++++++++++++++++++++++----------------------------- src/signal.c | 12 ++++----- src/slab.c | 22 ++++++++--------- src/thread.c | 34 +++++++++++++------------- src/timer.c | 20 +++++++-------- 8 files changed, 107 insertions(+), 108 deletions(-) (limited to 'src') diff --git a/src/memheap.c b/src/memheap.c index 35a04c14b1..feac8bb4aa 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -74,7 +74,7 @@ void rt_mem_set_tag(void *ptr, const char *name) rt_memheap_setname(item, name); } } -#endif +#endif /* RT_USING_MEMTRACE */ /* * The initialized memory pool will be: @@ -127,7 +127,7 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap, #ifdef RT_USING_MEMTRACE rt_memset(item->owner_thread_name, ' ', sizeof(item->owner_thread_name)); -#endif +#endif /* RT_USING_MEMTRACE */ item->next = (struct rt_memheap_item *) ((rt_uint8_t *)item + memheap->available_size + RT_MEMHEAP_SIZE); @@ -252,7 +252,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size) #ifdef RT_USING_MEMTRACE rt_memset(new_ptr->owner_thread_name, ' ', sizeof(new_ptr->owner_thread_name)); -#endif +#endif /* RT_USING_MEMTRACE */ /* break down the block list */ new_ptr->prev = header_ptr; @@ -310,7 +310,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size) rt_memcpy(header_ptr->owner_thread_name, rt_thread_self()->name, sizeof(header_ptr->owner_thread_name)); else rt_memcpy(header_ptr->owner_thread_name, "NONE", sizeof(header_ptr->owner_thread_name)); -#endif +#endif /* RT_USING_MEMTRACE */ /* release lock */ rt_sem_release(&(heap->lock)); @@ -439,7 +439,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize) #ifdef RT_USING_MEMTRACE rt_memset(next_ptr->owner_thread_name, ' ', sizeof(next_ptr->owner_thread_name)); -#endif +#endif /* RT_USING_MEMTRACE */ next_ptr->prev = header_ptr; next_ptr->next = header_ptr->next; @@ -507,7 +507,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize) #ifdef RT_USING_MEMTRACE rt_memset(new_ptr->owner_thread_name, ' ', sizeof(new_ptr->owner_thread_name)); -#endif +#endif /* RT_USING_MEMTRACE */ /* break down the block list */ new_ptr->prev = header_ptr; @@ -660,7 +660,7 @@ void rt_memheap_free(void *ptr) #ifdef RT_USING_MEMTRACE rt_memset(header_ptr->owner_thread_name, ' ', sizeof(header_ptr->owner_thread_name)); -#endif +#endif /* RT_USING_MEMTRACE */ /* release lock */ rt_sem_release(&(heap->lock)); @@ -750,7 +750,7 @@ int memheaptrace(void) return 0; } MSH_CMD_EXPORT(memheaptrace, dump memory trace information); -#endif +#endif /* RT_USING_FINSH */ #ifdef RT_USING_MEMHEAP_AS_HEAP static struct rt_memheap _heap; @@ -816,7 +816,7 @@ void *rt_malloc(rt_size_t size) RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("malloc => 0x%08x : %d", ptr, size)); } -#endif +#endif /* RT_USING_MEMTRACE */ return ptr; } @@ -882,7 +882,7 @@ void *rt_realloc(void *rmem, rt_size_t newsize) RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("realloc => 0x%08x : %d", new_ptr, newsize)); } -#endif +#endif /* RT_USING_MEMTRACE */ return new_ptr; } @@ -912,7 +912,7 @@ void *rt_calloc(rt_size_t count, rt_size_t size) RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("calloc => 0x%08x : %d", ptr, count * size)); } -#endif +#endif /* RT_USING_MEMTRACE */ return ptr; } @@ -932,7 +932,7 @@ void rt_memory_info(rt_uint32_t *total, *max_used = _heap.max_used_size; } -#endif +#endif /* RT_USING_MEMHEAP_AS_HEAP */ #ifdef RT_USING_MEMTRACE @@ -1004,8 +1004,8 @@ void memtrace_heap() #ifdef RT_USING_FINSH #include MSH_CMD_EXPORT(memtrace_heap, dump memory trace for heap); -#endif /* end of RT_USING_FINSH */ +#endif /* RT_USING_FINSH */ -#endif /* end of RT_USING_MEMTRACE */ +#endif /* RT_USING_MEMTRACE */ -#endif /* end of RT_USING_MEMHEAP */ +#endif /* RT_USING_MEMHEAP */ diff --git a/src/mempool.c b/src/mempool.c index 1de48940d7..5ac87d2bc8 100644 --- a/src/mempool.c +++ b/src/mempool.c @@ -54,7 +54,7 @@ void rt_mp_free_sethook(void (*hook)(struct rt_mempool *mp, void *block)) } /**@}*/ -#endif +#endif /* RT_USING_HOOK */ /** * @addtogroup MM @@ -290,7 +290,7 @@ rt_err_t rt_mp_delete(rt_mp_t mp) return RT_EOK; } RTM_EXPORT(rt_mp_delete); -#endif +#endif /* RT_USING_HEAP */ /** * This function will allocate a block from memory pool @@ -451,5 +451,4 @@ RTM_EXPORT(rt_mp_free); /**@}*/ -#endif - +#endif /* RT_USING_MEMPOOL */ diff --git a/src/object.c b/src/object.c index 013e2d1e33..ff96037c52 100644 --- a/src/object.c +++ b/src/object.c @@ -20,7 +20,7 @@ #ifdef RT_USING_MODULE #include -#endif +#endif /* RT_USING_MODULE */ /* * define object_info for the number of rt_object_container items. @@ -189,7 +189,7 @@ void rt_object_put_sethook(void (*hook)(struct rt_object *object)) } /**@}*/ -#endif +#endif /* RT_USING_HOOK */ /** * @addtogroup KernelObject @@ -305,7 +305,7 @@ void rt_object_init(struct rt_object *object, struct rt_object_information *information; #ifdef RT_USING_MODULE struct rt_dlmodule *module = dlmodule_self(); -#endif +#endif /* RT_USING_MODULE */ /* get object information */ information = rt_object_get_information(type); @@ -349,7 +349,7 @@ void rt_object_init(struct rt_object *object, object->module_id = (void *)module; } else -#endif +#endif /* RT_USING_MODULE */ { /* insert object into information object list */ rt_list_insert_after(&(information->object_list), &(object->list)); @@ -403,7 +403,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name) struct rt_object_information *information; #ifdef RT_USING_MODULE struct rt_dlmodule *module = dlmodule_self(); -#endif +#endif /* RT_USING_MODULE */ RT_DEBUG_NOT_IN_INTERRUPT; @@ -444,7 +444,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name) object->module_id = (void *)module; } else -#endif +#endif /* RT_USING_MODULE */ { /* insert object into information object list */ rt_list_insert_after(&(information->object_list), &(object->list)); @@ -487,7 +487,7 @@ void rt_object_delete(rt_object_t object) /* free the memory of object */ RT_KERNEL_FREE(object); } -#endif +#endif /* RT_USING_HEAP */ /** * This function will judge the object is system object or not. diff --git a/src/scheduler.c b/src/scheduler.c index ed0f30fc81..eec660a8aa 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -38,14 +38,14 @@ rt_uint32_t rt_thread_ready_priority_group; #if RT_THREAD_PRIORITY_MAX > 32 /* Maximum priority level, 256 */ rt_uint8_t rt_thread_ready_table[32]; -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ #ifndef RT_USING_SMP extern volatile rt_uint8_t rt_interrupt_nest; static rt_int16_t rt_scheduler_lock_nest; struct rt_thread *rt_current_thread = RT_NULL; rt_uint8_t rt_current_priority; -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ rt_list_t rt_thread_defunct; @@ -71,18 +71,18 @@ rt_scheduler_sethook(void (*hook)(struct rt_thread *from, struct rt_thread *to)) } /**@}*/ -#endif +#endif /* RT_USING_HOOK */ #ifdef RT_USING_OVERFLOW_CHECK static void _rt_scheduler_stack_check(struct rt_thread *thread) { RT_ASSERT(thread != RT_NULL); -#if defined(ARCH_CPU_STACK_GROWS_UPWARD) +#ifdef ARCH_CPU_STACK_GROWS_UPWARD if (*((rt_uint8_t *)((rt_ubase_t)thread->stack_addr + thread->stack_size - 1)) != '#' || #else if (*((rt_uint8_t *)thread->stack_addr) != '#' || -#endif +#endif /* ARCH_CPU_STACK_GROWS_UPWARD */ (rt_ubase_t)thread->sp <= (rt_ubase_t)thread->stack_addr || (rt_ubase_t)thread->sp > (rt_ubase_t)thread->stack_addr + (rt_ubase_t)thread->stack_size) @@ -94,7 +94,7 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread) level = rt_hw_interrupt_disable(); while (level); } -#if defined(ARCH_CPU_STACK_GROWS_UPWARD) +#ifdef ARCH_CPU_STACK_GROWS_UPWARD else if ((rt_ubase_t)thread->sp > ((rt_ubase_t)thread->stack_addr + thread->stack_size)) { rt_kprintf("warning: %s stack is close to the top of stack address.\n", @@ -106,9 +106,9 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread) rt_kprintf("warning: %s stack is close to end of stack address.\n", thread->name); } -#endif +#endif /* ARCH_CPU_STACK_GROWS_UPWARD */ } -#endif +#endif /* RT_USING_OVERFLOW_CHECK */ /* * get the highest priority thread in ready queue @@ -129,7 +129,7 @@ static struct rt_thread* _get_highest_priority_thread(rt_ubase_t *highest_prio) #else highest_ready_priority = __rt_ffs(rt_thread_ready_priority_group) - 1; local_highest_ready_priority = __rt_ffs(pcpu->priority_group) - 1; -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ /* get highest ready priority thread */ if (highest_ready_priority < local_highest_ready_priority) @@ -162,7 +162,7 @@ static struct rt_thread* _get_highest_priority_thread(rt_ubase_t *highest_prio) highest_ready_priority = (number << 3) + __rt_ffs(rt_thread_ready_table[number]) - 1; #else highest_ready_priority = __rt_ffs(rt_thread_ready_priority_group) - 1; -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ /* get highest ready priority thread */ highest_priority_thread = rt_list_entry(rt_thread_priority_table[highest_ready_priority].next, @@ -173,7 +173,7 @@ static struct rt_thread* _get_highest_priority_thread(rt_ubase_t *highest_prio) return highest_priority_thread; } -#endif +#endif /* RT_USING_SMP */ /** * @ingroup SystemInit @@ -183,12 +183,12 @@ void rt_system_scheduler_init(void) { #ifdef RT_USING_SMP int cpu; -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ register rt_base_t offset; #ifndef RT_USING_SMP rt_scheduler_lock_nest = 0; -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("start scheduler: max priority 0x%02x\n", RT_THREAD_PRIORITY_MAX)); @@ -213,9 +213,9 @@ void rt_system_scheduler_init(void) #if RT_THREAD_PRIORITY_MAX > 32 rt_memset(pcpu->ready_table, 0, sizeof(pcpu->ready_table)); -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ } -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ /* initialize ready priority group */ rt_thread_ready_priority_group = 0; @@ -223,7 +223,7 @@ void rt_system_scheduler_init(void) #if RT_THREAD_PRIORITY_MAX > 32 /* initialize ready table */ rt_memset(rt_thread_ready_table, 0, sizeof(rt_thread_ready_table)); -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ /* initialize thread defunct */ rt_list_init(&rt_thread_defunct); @@ -245,7 +245,7 @@ void rt_system_scheduler_start(void) to_thread->oncpu = rt_hw_cpu_id(); #else rt_current_thread = to_thread; -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ rt_schedule_remove_thread(to_thread); to_thread->stat = RT_THREAD_RUNNING; @@ -255,7 +255,7 @@ void rt_system_scheduler_start(void) rt_hw_context_switch_to((rt_ubase_t)&to_thread->sp, to_thread); #else rt_hw_context_switch_to((rt_ubase_t)&to_thread->sp); -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ /* never come back */ } @@ -319,7 +319,7 @@ void rt_schedule(void) rt_thread_resume(current_thread); } } -#endif +#endif /* RT_USING_SIGNALS */ if (current_thread->scheduler_lock_nest == 1) /* whether lock scheduler */ { @@ -367,7 +367,7 @@ void rt_schedule(void) #ifdef RT_USING_OVERFLOW_CHECK _rt_scheduler_stack_check(to_thread); -#endif +#endif /* RT_USING_OVERFLOW_CHECK */ rt_hw_context_switch((rt_ubase_t)¤t_thread->sp, (rt_ubase_t)&to_thread->sp, to_thread); @@ -396,7 +396,7 @@ void rt_schedule(void) { rt_hw_interrupt_enable(level); } -#endif +#endif /* RT_USING_SIGNALS */ __exit: return ; @@ -472,7 +472,7 @@ void rt_schedule(void) #ifdef RT_USING_OVERFLOW_CHECK _rt_scheduler_stack_check(to_thread); -#endif +#endif /* RT_USING_OVERFLOW_CHECK */ if (rt_interrupt_nest == 0) { @@ -502,7 +502,7 @@ void rt_schedule(void) { rt_hw_interrupt_enable(level); } -#endif +#endif /* RT_USING_SIGNALS */ goto __exit; } else @@ -527,7 +527,7 @@ void rt_schedule(void) __exit: return; } -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ /** * This function checks if a scheduling is needed after IRQ context. If yes, @@ -559,7 +559,7 @@ void rt_scheduler_do_irq_switch(void *context) rt_thread_resume(current_thread); } } -#endif +#endif /* RT_USING_SIGNALS */ if (pcpu->irq_switch_flag == 0) { @@ -608,7 +608,7 @@ void rt_scheduler_do_irq_switch(void *context) #ifdef RT_USING_OVERFLOW_CHECK _rt_scheduler_stack_check(to_thread); -#endif +#endif /* RT_USING_OVERFLOW_CHECK */ RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("switch in interrupt\n")); current_thread->cpus_lock_nest--; @@ -621,7 +621,7 @@ void rt_scheduler_do_irq_switch(void *context) } rt_hw_interrupt_enable(level); } -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ /* * This function will insert a thread to system ready queue. The state of @@ -661,7 +661,7 @@ void rt_schedule_insert_thread(struct rt_thread *thread) { #if RT_THREAD_PRIORITY_MAX > 32 rt_thread_ready_table[thread->number] |= thread->high_mask; -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ rt_thread_ready_priority_group |= thread->number_mask; rt_list_insert_before(&(rt_thread_priority_table[thread->current_priority]), @@ -675,7 +675,7 @@ void rt_schedule_insert_thread(struct rt_thread *thread) #if RT_THREAD_PRIORITY_MAX > 32 pcpu->ready_table[thread->number] |= thread->high_mask; -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ pcpu->priority_group |= thread->number_mask; rt_list_insert_before(&(rt_cpu_index(bind_cpu)->priority_table[thread->current_priority]), @@ -724,14 +724,14 @@ void rt_schedule_insert_thread(struct rt_thread *thread) /* set priority mask */ #if RT_THREAD_PRIORITY_MAX > 32 rt_thread_ready_table[thread->number] |= thread->high_mask; -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ rt_thread_ready_priority_group |= thread->number_mask; __exit: /* enable interrupt */ rt_hw_interrupt_enable(temp); } -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ /* * This function will remove a thread from system ready queue. @@ -768,7 +768,7 @@ void rt_schedule_remove_thread(struct rt_thread *thread) } #else rt_thread_ready_priority_group &= ~thread->number_mask; -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ } } else @@ -785,7 +785,7 @@ void rt_schedule_remove_thread(struct rt_thread *thread) } #else pcpu->priority_group &= ~thread->number_mask; -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ } } @@ -818,13 +818,13 @@ void rt_schedule_remove_thread(struct rt_thread *thread) } #else rt_thread_ready_priority_group &= ~thread->number_mask; -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ } /* enable interrupt */ rt_hw_interrupt_enable(level); } -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ /** * This function will lock the thread scheduler. @@ -885,7 +885,7 @@ void rt_enter_critical(void) /* enable interrupt */ rt_hw_interrupt_enable(level); } -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ RTM_EXPORT(rt_enter_critical); /** @@ -959,7 +959,7 @@ void rt_exit_critical(void) rt_hw_interrupt_enable(level); } } -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ RTM_EXPORT(rt_exit_critical); /** @@ -975,7 +975,7 @@ rt_uint16_t rt_critical_level(void) return current_thread->critical_lock_nest; #else return rt_scheduler_lock_nest; -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ } RTM_EXPORT(rt_critical_level); diff --git a/src/signal.c b/src/signal.c index c2c3e975cb..bb7706d9ef 100644 --- a/src/signal.c +++ b/src/signal.c @@ -20,7 +20,7 @@ #ifndef RT_SIG_INFO_MAX #define RT_SIG_INFO_MAX 32 -#endif +#endif /* RT_SIG_INFO_MAX */ #define DBG_TAG "SIGN" #define DBG_LVL DBG_WARNING @@ -67,7 +67,7 @@ static void _signal_entry(void *parameter) /* return to thread */ tid->sp = tid->sig_ret; tid->sig_ret = RT_NULL; -#endif +#endif /* RT_USING_SMP */ LOG_D("switch back to: 0x%08x\n", tid->sp); tid->stat &= ~RT_THREAD_STAT_SIGNAL; @@ -76,7 +76,7 @@ static void _signal_entry(void *parameter) rt_hw_context_switch_to((rt_base_t)¶meter, tid); #else rt_hw_context_switch_to((rt_ubase_t)&(tid->sp)); -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ } /* @@ -153,7 +153,7 @@ static void _signal_deliver(rt_thread_t tid) tid->sig_ret = tid->sp; tid->sp = rt_hw_stack_init((void *)_signal_entry, RT_NULL, (void *)((char *)tid->sig_ret - 32), RT_NULL); -#endif +#endif /* RT_USING_SMP */ rt_hw_interrupt_enable(level); LOG_D("signal stack pointer @ 0x%08x", tid->sp); @@ -204,7 +204,7 @@ void *rt_signal_check(void* context) rt_hw_interrupt_enable(level); return context; } -#endif +#endif /* RT_USING_SMP */ rt_sighandler_t rt_signal_install(int signo, rt_sighandler_t handler) { @@ -586,4 +586,4 @@ int rt_system_signal_init(void) return 0; } -#endif +#endif /* RT_USING_SIGNALS */ diff --git a/src/slab.c b/src/slab.c index 114259002f..bec826ef18 100644 --- a/src/slab.c +++ b/src/slab.c @@ -61,7 +61,7 @@ /* some statistical variable */ #ifdef RT_MEM_STATS static rt_size_t used_mem, max_mem; -#endif +#endif /* RT_MEM_STATS */ #ifdef RT_USING_HOOK static void (*rt_malloc_hook)(void *ptr, rt_size_t size); @@ -99,7 +99,7 @@ RTM_EXPORT(rt_free_sethook); /**@}*/ -#endif +#endif /* RT_USING_HOOK */ /* * slab allocator implementation @@ -516,7 +516,7 @@ void *rt_malloc(rt_size_t size) used_mem += size; if (used_mem > max_mem) max_mem = used_mem; -#endif +#endif /* RT_MEM_STATS */ goto done; } @@ -571,7 +571,7 @@ void *rt_malloc(rt_size_t size) used_mem += z->z_chunksize; if (used_mem > max_mem) max_mem = used_mem; -#endif +#endif /* RT_MEM_STATS */ goto done; } @@ -655,7 +655,7 @@ void *rt_malloc(rt_size_t size) used_mem += z->z_chunksize; if (used_mem > max_mem) max_mem = used_mem; -#endif +#endif /* RT_MEM_STATS */ } done: @@ -790,7 +790,7 @@ void rt_free(void *ptr) (rt_ubase_t)addr, ((rt_ubase_t)(addr) - heap_start) >> RT_MM_PAGE_BITS)); } -#endif +#endif /* RT_DEBUG_SLAB */ kup = btokup((rt_ubase_t)ptr & ~RT_MM_PAGE_MASK); /* release large allocation */ @@ -806,7 +806,7 @@ void rt_free(void *ptr) #ifdef RT_MEM_STATS used_mem -= size * RT_MM_PAGE_SIZE; -#endif +#endif /* RT_MEM_STATS */ rt_sem_release(&heap_sem); RT_DEBUG_LOG(RT_DEBUG_SLAB, @@ -833,7 +833,7 @@ void rt_free(void *ptr) #ifdef RT_MEM_STATS used_mem -= z->z_chunksize; -#endif +#endif /* RT_MEM_STATS */ /* * Bump the number of free chunks. If it becomes non-zero the zone @@ -929,9 +929,9 @@ void list_mem(void) rt_kprintf("maximum allocated memory: %d\n", max_mem); } FINSH_FUNCTION_EXPORT(list_mem, list memory usage information) -#endif -#endif +#endif /* RT_USING_FINSH */ +#endif /* RT_MEM_STATS */ /**@}*/ -#endif +#endif /* defined (RT_USING_HEAP) && defined (RT_USING_SLAB) */ diff --git a/src/thread.c b/src/thread.c index 6304a4ebe6..c0a8f0ee74 100644 --- a/src/thread.c +++ b/src/thread.c @@ -76,7 +76,7 @@ void rt_thread_inited_sethook(void (*hook)(rt_thread_t thread)) rt_thread_inited_hook = hook; } -#endif +#endif /* RT_USING_HOOK */ /* must be invoke witch rt_hw_interrupt_disable */ static void _rt_thread_cleanup_execute(rt_thread_t thread) @@ -84,7 +84,7 @@ static void _rt_thread_cleanup_execute(rt_thread_t thread) register rt_base_t level; #ifdef RT_USING_MODULE struct rt_dlmodule *module = RT_NULL; -#endif +#endif /* RT_USING_MODULE */ level = rt_hw_interrupt_disable(); #ifdef RT_USING_MODULE module = (struct rt_dlmodule*)thread->module_id; @@ -92,14 +92,14 @@ static void _rt_thread_cleanup_execute(rt_thread_t thread) { dlmodule_destroy(module); } -#endif +#endif /* RT_USING_MODULE */ /* invoke thread cleanup */ if (thread->cleanup != RT_NULL) thread->cleanup(thread); #ifdef RT_USING_SIGNALS rt_thread_free_sig(thread); -#endif +#endif /* RT_USING_SIGNALS */ rt_hw_interrupt_enable(level); } @@ -170,7 +170,7 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread, thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter, (rt_uint8_t *)((char *)thread->stack_addr + thread->stack_size - sizeof(rt_ubase_t)), (void *)_rt_thread_exit); -#endif +#endif /* ARCH_CPU_STACK_GROWS_UPWARD */ /* priority init */ RT_ASSERT(priority < RT_THREAD_PRIORITY_MAX); @@ -181,7 +181,7 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread, #if RT_THREAD_PRIORITY_MAX > 32 thread->number = 0; thread->high_mask = 0; -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ /* tick init */ thread->init_tick = tick; @@ -200,7 +200,7 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread, thread->scheduler_lock_nest = 0; thread->cpus_lock_nest = 0; thread->critical_lock_nest = 0; -#endif /*RT_USING_SMP*/ +#endif /* RT_USING_SMP */ /* initialize cleanup function and user data */ thread->cleanup = 0; @@ -221,14 +221,14 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread, #ifndef RT_USING_SMP thread->sig_ret = RT_NULL; -#endif +#endif /* RT_USING_SMP */ thread->sig_vectors = RT_NULL; thread->si_list = RT_NULL; -#endif +#endif /* RT_USING_SIGNALS */ #ifdef RT_USING_LWP thread->lwp = RT_NULL; -#endif +#endif /* RT_USING_LWP */ RT_OBJECT_HOOK_CALL(rt_thread_inited_hook, (thread)); @@ -302,7 +302,7 @@ rt_thread_t rt_thread_self(void) extern rt_thread_t rt_current_thread; return rt_current_thread; -#endif +#endif /* RT_USING_SMP */ } RTM_EXPORT(rt_thread_self); @@ -330,7 +330,7 @@ rt_err_t rt_thread_startup(rt_thread_t thread) thread->high_mask = 1L << (thread->current_priority & 0x07); /* 3bit */ #else thread->number_mask = 1L << thread->current_priority; -#endif +#endif /* RT_THREAD_PRIORITY_MAX > 32 */ RT_DEBUG_LOG(RT_DEBUG_THREAD, ("startup a thread:%s with priority:%d\n", thread->name, thread->init_priority)); @@ -492,7 +492,7 @@ rt_err_t rt_thread_delete(rt_thread_t thread) return RT_EOK; } RTM_EXPORT(rt_thread_delete); -#endif +#endif /* RT_USING_HEAP */ /** * This function will let current thread yield processor, and scheduler will @@ -690,7 +690,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg) thread->high_mask = 1 << (thread->current_priority & 0x07); /* 3bit */ #else thread->number_mask = 1 << thread->current_priority; - #endif + #endif /* RT_THREAD_PRIORITY_MAX > 32 */ /* insert thread to schedule queue again */ rt_schedule_insert_thread(thread); @@ -706,7 +706,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg) thread->high_mask = 1 << (thread->current_priority & 0x07); /* 3bit */ #else thread->number_mask = 1 << thread->current_priority; - #endif + #endif /* RT_THREAD_PRIORITY_MAX > 32 */ } /* enable interrupt */ @@ -732,7 +732,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg) { rt_err = rt_thread_delete(thread); } - #endif + #endif /* RT_USING_HEAP */ rt_schedule(); return rt_err; } @@ -752,7 +752,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg) thread->bind_cpu = cpu > RT_CPUS_NR? RT_CPUS_NR : cpu; break; } - #endif /*RT_USING_SMP*/ + #endif /* RT_USING_SMP */ default: break; diff --git a/src/timer.c b/src/timer.c index 9b0db6c6a5..1c8e70fccc 100644 --- a/src/timer.c +++ b/src/timer.c @@ -31,11 +31,11 @@ static rt_list_t rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL]; #ifndef RT_TIMER_THREAD_STACK_SIZE #define RT_TIMER_THREAD_STACK_SIZE 512 -#endif +#endif /* RT_TIMER_THREAD_STACK_SIZE */ #ifndef RT_TIMER_THREAD_PRIO #define RT_TIMER_THREAD_PRIO 0 -#endif +#endif /* RT_TIMER_THREAD_PRIO */ /* soft timer status */ static rt_uint8_t soft_timer_status = RT_SOFT_TIMER_IDLE; @@ -44,7 +44,7 @@ static rt_list_t rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL]; static struct rt_thread timer_thread; ALIGN(RT_ALIGN_SIZE) static rt_uint8_t timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE]; -#endif +#endif /* RT_USING_TIMER_SOFT */ #ifdef RT_USING_HOOK extern void (*rt_object_take_hook)(struct rt_object *object); @@ -81,7 +81,7 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) } /**@}*/ -#endif +#endif /* RT_USING_HOOK */ static void _rt_timer_init(rt_timer_t timer, void (*timeout)(void *parameter), @@ -171,7 +171,7 @@ void rt_timer_dump(rt_list_t timer_heads[]) } rt_kprintf("\n"); } -#endif +#endif /* RT_DEBUG_TIMER */ /** * @addtogroup Clock @@ -303,7 +303,7 @@ rt_err_t rt_timer_delete(rt_timer_t timer) return RT_EOK; } RTM_EXPORT(rt_timer_delete); -#endif +#endif /* RT_USING_HEAP */ /** * This function will start the timer @@ -348,7 +348,7 @@ rt_err_t rt_timer_start(rt_timer_t timer) timer_list = rt_soft_timer_list; } else -#endif +#endif /* RT_USING_TIMER_SOFT */ { /* insert timer to system timer list */ timer_list = rt_timer_list; @@ -422,7 +422,7 @@ rt_err_t rt_timer_start(rt_timer_t timer) rt_schedule(); } } -#endif +#endif /* RT_USING_TIMER_SOFT */ return RT_EOK; } @@ -718,7 +718,7 @@ static void rt_thread_timer_entry(void *parameter) rt_soft_timer_check(); } } -#endif +#endif /* RT_USING_TIMER_SOFT */ /** * @ingroup SystemInit @@ -764,7 +764,7 @@ void rt_system_timer_thread_init(void) /* startup */ rt_thread_startup(&timer_thread); -#endif +#endif /* RT_USING_TIMER_SOFT */ } /**@}*/ -- cgit v1.3.1 From fa1f1ef485734d990f9a5aecb001d3a0aa0eb59a Mon Sep 17 00:00:00 2001 From: yangjie Date: Fri, 11 Jun 2021 10:00:23 +0800 Subject: [src] add RT_WEAK for rt_malloc_align,rt_free_align --- src/kservice.c | 4 ++-- src/memheap.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/kservice.c b/src/kservice.c index 7ed05b6651..40040f7885 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -1238,7 +1238,7 @@ RTM_EXPORT(rt_kprintf); * * @return the allocated memory block on successful, otherwise returns RT_NULL */ -void *rt_malloc_align(rt_size_t size, rt_size_t align) +RT_WEAK void *rt_malloc_align(rt_size_t size, rt_size_t align) { void *ptr; void *align_ptr; @@ -1284,7 +1284,7 @@ RTM_EXPORT(rt_malloc_align); * * @param ptr the memory block pointer */ -void rt_free_align(void *ptr) +RT_WEAK void rt_free_align(void *ptr) { void *real_ptr; diff --git a/src/memheap.c b/src/memheap.c index 35a04c14b1..80f27a461f 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -757,6 +757,8 @@ static struct rt_memheap _heap; void rt_system_heap_init(void *begin_addr, void *end_addr) { + RT_ASSERT((rt_uint32_t)end_addr > (rt_uint32_t)begin_addr); + /* initialize a default heap in the system */ rt_memheap_init(&_heap, "heap", -- cgit v1.3.1 From 4fa92ae3f6766863035238da9ae2b46622abb8a9 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Fri, 11 Jun 2021 13:07:29 +0800 Subject: [kernel] 补充endif后缀注释(4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mem.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/mem.c b/src/mem.c index ac0d27f2c3..e2328cc234 100644 --- a/src/mem.c +++ b/src/mem.c @@ -52,7 +52,6 @@ #ifndef RT_USING_MEMHEAP_AS_HEAP -/* #define RT_MEM_DEBUG */ #define RT_MEM_STATS #if defined (RT_USING_HEAP) && defined (RT_USING_SMALL_MEM) @@ -90,7 +89,7 @@ void rt_free_sethook(void (*hook)(void *ptr)) /**@}*/ -#endif +#endif /* RT_USING_HOOK */ #define HEAP_MAGIC 0x1ea0 struct heap_mem @@ -100,7 +99,7 @@ struct heap_mem rt_uint16_t used; #ifdef ARCH_CPU_64BIT rt_uint32_t resv; -#endif +#endif /* ARCH_CPU_64BIT */ rt_size_t next, prev; @@ -109,8 +108,8 @@ struct heap_mem rt_uint8_t thread[8]; #else rt_uint8_t thread[4]; /* thread name */ -#endif -#endif +#endif /* ARCH_CPU_64BIT */ +#endif /* RT_USING_MEMTRACE */ }; /** pointer to the heap: for alignment, heap_ptr is now a pointer instead of an array */ @@ -123,7 +122,7 @@ static struct heap_mem *heap_end; #define MIN_SIZE 24 #else #define MIN_SIZE 12 -#endif +#endif /* ARCH_CPU_64BIT */ #define MIN_SIZE_ALIGNED RT_ALIGN(MIN_SIZE, RT_ALIGN_SIZE) #define SIZEOF_STRUCT_MEM RT_ALIGN(sizeof(struct heap_mem), RT_ALIGN_SIZE) @@ -135,7 +134,8 @@ static rt_size_t mem_size_aligned; #ifdef RT_MEM_STATS static rt_size_t used_mem, max_mem; -#endif +#endif /* RT_MEM_STATS */ + #ifdef RT_USING_MEMTRACE rt_inline void rt_mem_setname(struct heap_mem *mem, const char *name) { @@ -151,7 +151,7 @@ rt_inline void rt_mem_setname(struct heap_mem *mem, const char *name) mem->thread[index] = ' '; } } -#endif +#endif /* RT_USING_MEMTRACE */ static void plug_holes(struct heap_mem *mem) { @@ -238,7 +238,7 @@ void rt_system_heap_init(void *begin_addr, void *end_addr) mem->used = 0; #ifdef RT_USING_MEMTRACE rt_mem_setname(mem, "INIT"); -#endif +#endif /* RT_USING_MEMTRACE */ /* initialize the end of the heap */ heap_end = (struct heap_mem *)&heap_ptr[mem->next]; @@ -248,7 +248,7 @@ void rt_system_heap_init(void *begin_addr, void *end_addr) heap_end->prev = mem_size_aligned + SIZEOF_STRUCT_MEM; #ifdef RT_USING_MEMTRACE rt_mem_setname(heap_end, "INIT"); -#endif +#endif /* RT_USING_MEMTRACE */ rt_sem_init(&heap_sem, "heap", 1, RT_IPC_FLAG_FIFO); @@ -336,7 +336,7 @@ void *rt_malloc(rt_size_t size) mem2->prev = ptr; #ifdef RT_USING_MEMTRACE rt_mem_setname(mem2, " "); -#endif +#endif /* RT_USING_MEMTRACE */ /* and insert it between mem and mem->next */ mem->next = ptr2; @@ -350,7 +350,7 @@ void *rt_malloc(rt_size_t size) used_mem += (size + SIZEOF_STRUCT_MEM); if (max_mem < used_mem) max_mem = used_mem; -#endif +#endif /* RT_MEM_STATS */ } else { @@ -366,7 +366,7 @@ void *rt_malloc(rt_size_t size) used_mem += mem->next - ((rt_uint8_t *)mem - heap_ptr); if (max_mem < used_mem) max_mem = used_mem; -#endif +#endif /* RT_MEM_STATS */ } /* set memory block magic */ mem->magic = HEAP_MAGIC; @@ -375,7 +375,7 @@ void *rt_malloc(rt_size_t size) rt_mem_setname(mem, rt_thread_self()->name); else rt_mem_setname(mem, "NONE"); -#endif +#endif /* RT_USING_MEMTRACE */ if (mem == lfree) { @@ -473,7 +473,7 @@ void *rt_realloc(void *rmem, rt_size_t newsize) /* split memory block */ #ifdef RT_MEM_STATS used_mem -= (size - newsize); -#endif +#endif /* RT_MEM_STATS */ ptr2 = ptr + SIZEOF_STRUCT_MEM + newsize; mem2 = (struct heap_mem *)&heap_ptr[ptr2]; @@ -483,7 +483,7 @@ void *rt_realloc(void *rmem, rt_size_t newsize) mem2->prev = ptr; #ifdef RT_USING_MEMTRACE rt_mem_setname(mem2, " "); -#endif +#endif /* RT_USING_MEMTRACE */ mem->next = ptr2; if (mem2->next != mem_size_aligned + SIZEOF_STRUCT_MEM) { @@ -597,7 +597,7 @@ void rt_free(void *rmem) mem->magic = HEAP_MAGIC; #ifdef RT_USING_MEMTRACE rt_mem_setname(mem, " "); -#endif +#endif /* RT_USING_MEMTRACE */ if (mem < lfree) { @@ -607,7 +607,7 @@ void rt_free(void *rmem) #ifdef RT_MEM_STATS used_mem -= (mem->next - ((rt_uint8_t *)mem - heap_ptr)); -#endif +#endif /* RT_MEM_STATS */ /* finally, see if prev or next are free also */ plug_holes(mem); @@ -706,12 +706,12 @@ int memtrace(int argc, char **argv) return 0; } MSH_CMD_EXPORT(memtrace, dump memory trace information); -#endif /* end of RT_USING_MEMTRACE */ -#endif /* end of RT_USING_FINSH */ +#endif /* RT_USING_MEMTRACE */ +#endif /* RT_USING_FINSH */ -#endif +#endif /* defined (RT_USING_HEAP) && defined (RT_USING_SMALL_MEM) */ /**@}*/ -#endif /* end of RT_USING_HEAP */ -#endif /* end of RT_USING_MEMHEAP_AS_HEAP */ +#endif /* RT_MEM_STATS */ +#endif /* RT_USING_MEMHEAP_AS_HEAP */ -- cgit v1.3.1 From 921e6064260f7afa80f3d10424bd49526241a3ee Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 13 Jun 2021 17:36:42 +0800 Subject: 将defined(__CC_ARM) || defined(__CLANG_ARM) 改为 ifdef __ARMCC_VERSION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/finsh/shell.c | 2 +- include/libc/libc_signal.h | 2 +- include/rtlibc.h | 2 +- include/rtthread.h | 2 +- src/components.c | 4 ++-- src/kservice.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/components/finsh/shell.c b/components/finsh/shell.c index a749660629..c89139c0ed 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -817,7 +817,7 @@ int finsh_system_init(void) rt_thread_t tid; #ifdef FINSH_USING_SYMTAB -#if defined(__CC_ARM) || defined(__CLANG_ARM) /* ARM C Compiler */ +#ifdef __ARMCC_VERSION /* ARM C Compiler */ extern const int FSymTab$$Base; extern const int FSymTab$$Limit; extern const int VSymTab$$Base; diff --git a/include/libc/libc_signal.h b/include/libc/libc_signal.h index 8a4cc0d738..1fb8194643 100644 --- a/include/libc/libc_signal.h +++ b/include/libc/libc_signal.h @@ -71,7 +71,7 @@ typedef unsigned long sigset_t; #include -#if defined(__CC_ARM) || defined(__CLANG_ARM) +#ifdef __ARMCC_VERSION #define SIGHUP 1 /* #define SIGINT 2 */ diff --git a/include/rtlibc.h b/include/rtlibc.h index a62051e157..4e7caa81fc 100644 --- a/include/rtlibc.h +++ b/include/rtlibc.h @@ -22,7 +22,7 @@ #include "libc/libc_stdio.h" #ifndef RT_USING_LIBC -#if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__) +#if defined(__ARMCC_VERSION) || defined(__IAR_SYSTEMS_ICC__) typedef signed long off_t; typedef int mode_t; #endif diff --git a/include/rtthread.h b/include/rtthread.h index ccd2d147a8..cf897b0e5e 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -567,7 +567,7 @@ rt_size_t rt_strlen(const char *src); #endif /*RT_KSERVICE_USING_STDLIB*/ char *rt_strdup(const char *s); -#if defined(__CC_ARM) || defined(__CLANG_ARM) +#ifdef __ARMCC_VERSION /* lack strdup interface */ char* strdup(const char* str); #endif diff --git a/src/components.c b/src/components.c index d684d5e6fd..e156b783e4 100644 --- a/src/components.c +++ b/src/components.c @@ -134,7 +134,7 @@ void rt_application_init(void); void rt_hw_board_init(void); int rtthread_startup(void); -#if defined(__CC_ARM) || defined(__CLANG_ARM) +#ifdef __ARMCC_VERSION extern int $Super$$main(void); /* re-define main function */ int $Sub$$main(void) @@ -183,7 +183,7 @@ void main_thread_entry(void *parameter) rt_hw_secondary_cpu_up(); #endif /* RT_USING_SMP */ /* invoke system main function */ -#if defined(__CC_ARM) || defined(__CLANG_ARM) +#ifdef __ARMCC_VERSION { extern int $Super$$main(void); $Super$$main(); /* for ARMCC. */ diff --git a/src/kservice.c b/src/kservice.c index 448b2d717d..49e1486078 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -532,7 +532,7 @@ char *rt_strdup(const char *s) return tmp; } RTM_EXPORT(rt_strdup); -#if defined(__CC_ARM) || defined(__CLANG_ARM) +#ifdef __ARMCC_VERSION char *strdup(const char *s) __attribute__((alias("rt_strdup"))); #endif #endif /* RT_USING_HEAP */ -- cgit v1.3.1 From ec3c1d4d0085c57d996a5c6acc21e7dbde85b30f Mon Sep 17 00:00:00 2001 From: 杨澄 <36236188+Eureka1024@users.noreply.github.com> Date: Wed, 23 Jun 2021 21:23:07 +0800 Subject: [kernel] Fix comment error for rt_mutex_detach(). --- src/ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ipc.c b/src/ipc.c index c981aabe43..959f0fb522 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -588,7 +588,7 @@ rt_err_t rt_mutex_detach(rt_mutex_t mutex) /* wakeup all suspended threads */ rt_ipc_list_resume_all(&(mutex->parent.suspend_thread)); - /* detach semaphore object */ + /* detach mutex object */ rt_object_detach(&(mutex->parent.parent)); return RT_EOK; -- cgit v1.3.1 From 05bb1a50b0d26b7c60c82ccb4ff8a66a501feac3 Mon Sep 17 00:00:00 2001 From: fenghuijie Date: Sat, 3 Jul 2021 17:54:58 +0800 Subject: 添加idle回收资源的修改 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rtthread.h | 6 ++- src/Kconfig | 5 ++ src/idle.c | 154 +++++++++++++++++++++++++++++++++++++++++++++-------- src/scheduler.c | 5 -- src/thread.c | 40 ++++++++------ 5 files changed, 168 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/include/rtthread.h b/include/rtthread.h index 0583ce6434..f9d0b45e86 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -168,7 +168,6 @@ void rt_thread_idle_init(void); rt_err_t rt_thread_idle_sethook(void (*hook)(void)); rt_err_t rt_thread_idle_delhook(void (*hook)(void)); #endif -void rt_thread_idle_excute(void); rt_thread_t rt_thread_idle_gethandler(void); /* @@ -187,6 +186,7 @@ rt_uint16_t rt_critical_level(void); #ifdef RT_USING_HOOK void rt_scheduler_sethook(void (*hook)(rt_thread_t from, rt_thread_t to)); +void rt_scheduler_switchto_sethook(void (*hook)(struct rt_thread *tid)); #endif #ifdef RT_USING_SMP @@ -396,6 +396,10 @@ 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 +/* defunct */ +void rt_thread_defunct_enqueue(rt_thread_t thread); +rt_thread_t rt_thread_defunct_dequeue(void); + /* * spinlock */ diff --git a/src/Kconfig b/src/Kconfig index 9a49146dff..e0582f5663 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -98,6 +98,11 @@ config IDLE_THREAD_STACK_SIZE int "The stack size of idle thread" default 256 +config SYSTEM_THREAD_STACK_SIZE + int "The stack size of system thread (for defunct etc.)" + depends on RT_USING_SMP + default IDLE_THREAD_STACK_SIZE + config RT_USING_TIMER_SOFT bool "Enable software timer with a timer thread" default y diff --git a/src/idle.c b/src/idle.c index db256a6010..a571e487cf 100644 --- a/src/idle.c +++ b/src/idle.c @@ -44,12 +44,22 @@ #define _CPUS_NR 1 #endif /* RT_USING_SMP */ -extern rt_list_t rt_thread_defunct; +static rt_list_t _rt_thread_defunct = RT_LIST_OBJECT_INIT(_rt_thread_defunct);; static struct rt_thread idle[_CPUS_NR]; ALIGN(RT_ALIGN_SIZE) static rt_uint8_t rt_thread_stack[_CPUS_NR][IDLE_THREAD_STACK_SIZE]; +#ifdef RT_USING_SMP +#ifndef SYSTEM_THREAD_STACK_SIZE +#define SYSTEM_THREAD_STACK_SIZE IDLE_THREAD_STACK_SIZE +#endif +static struct rt_thread rt_system_thread; +ALIGN(RT_ALIGN_SIZE) +static rt_uint8_t rt_system_stack[SYSTEM_THREAD_STACK_SIZE]; +static struct rt_semaphore system_sem; +#endif + #ifdef RT_USING_IDLE_HOOK #ifndef RT_IDLE_HOOK_LIST_SIZE #define RT_IDLE_HOOK_LIST_SIZE 4 @@ -127,43 +137,75 @@ rt_err_t rt_thread_idle_delhook(void (*hook)(void)) #endif /* RT_USING_IDLE_HOOK */ -#ifdef RT_USING_HEAP +#ifdef RT_USING_MODULE /* Return whether there is defunctional thread to be deleted. */ rt_inline int _has_defunct_thread(void) { /* The rt_list_isempty has prototype of "int rt_list_isempty(const rt_list_t *l)". - * So the compiler has a good reason that the rt_thread_defunct list does - * not change within rt_thread_idle_excute thus optimize the "while" loop + * So the compiler has a good reason that the _rt_thread_defunct list does + * not change within rt_thread_defunct_exceute thus optimize the "while" loop * into a "if". * * So add the volatile qualifier here. */ - const volatile rt_list_t *l = (const volatile rt_list_t *)&rt_thread_defunct; + const volatile rt_list_t *l = (const volatile rt_list_t *)&_rt_thread_defunct; return l->next != l; } -#endif /* RT_USING_HEAP */ +#endif /* RT_USING_MODULE */ + +/* enqueue a thread to defunct queue + * it must be called between rt_hw_interrupt_disable and rt_hw_interrupt_enable + */ +void rt_thread_defunct_enqueue(rt_thread_t thread) +{ + rt_list_insert_after(&_rt_thread_defunct, &thread->tlist); +#ifdef RT_USING_SMP + rt_sem_release(&system_sem); +#endif +} + +/* dequeue a thread from defunct queue + * it must be called between rt_hw_interrupt_disable and rt_hw_interrupt_enable + */ +rt_thread_t rt_thread_defunct_dequeue(void) +{ + rt_thread_t thread = RT_NULL; + rt_list_t *l = &_rt_thread_defunct; + + if (l->next != l) + { + thread = rt_list_entry(l->next, + struct rt_thread, + tlist); + rt_list_remove(&(thread->tlist)); + } + return thread; +} /** * @ingroup Thread * * This function will perform system background job when system idle. */ -void rt_thread_idle_excute(void) +static void rt_defunct_execute(void) { - /* Loop until there is no dead thread. So one call to rt_thread_idle_excute + /* Loop until there is no dead thread. So one call to rt_defunct_execute * will do all the cleanups. */ - /* disable interrupt */ - - RT_DEBUG_NOT_IN_INTERRUPT; - -#ifdef RT_USING_HEAP while (1) { rt_base_t lock; rt_thread_t thread; + void (*cleanup)(struct rt_thread *tid); +#ifdef RT_USING_MODULE + struct rt_dlmodule *module = RT_NULL; +#endif + RT_DEBUG_NOT_IN_INTERRUPT; + + /* disable interrupt */ lock = rt_hw_interrupt_disable(); +#ifdef RT_USING_MODULE /* check whether list is empty */ if (!_has_defunct_thread()) { @@ -171,18 +213,56 @@ void rt_thread_idle_excute(void) break; } /* get defunct thread */ - thread = rt_list_entry(rt_thread_defunct.next, + thread = rt_list_entry(_rt_thread_defunct.next, struct rt_thread, tlist); + module = (struct rt_dlmodule*)thread->module_id; + if (module) + { + dlmodule_destroy(module); + } /* remove defunct thread */ rt_list_remove(&(thread->tlist)); - /* release thread's stack */ - RT_KERNEL_FREE(thread->stack_addr); - /* delete thread object */ - rt_object_delete((rt_object_t)thread); - rt_hw_interrupt_enable(lock); +#else + thread = rt_thread_defunct_dequeue(); + if (!thread) + { + rt_hw_interrupt_enable(lock); + break; + } +#endif + /* invoke thread cleanup */ + cleanup = thread->cleanup; + if (cleanup != RT_NULL) + { + rt_hw_interrupt_enable(lock); + cleanup(thread); + lock = rt_hw_interrupt_disable(); + } + +#ifdef RT_USING_SIGNALS + rt_thread_free_sig(thread); +#endif + + /* if it's a system object, not delete it */ + if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE) + { + /* detach this object */ + rt_object_detach((rt_object_t)thread); + /* enable interrupt */ + rt_hw_interrupt_enable(lock); + } + else + { + rt_hw_interrupt_enable(lock); +#ifdef RT_USING_HEAP + /* release thread's stack */ + RT_KERNEL_FREE(thread->stack_addr); + /* delete thread object */ + rt_object_delete((rt_object_t)thread); +#endif + } } -#endif /* RT_USING_HEAP */ } extern void rt_system_power_manager(void); @@ -214,13 +294,27 @@ static void rt_thread_idle_entry(void *parameter) } #endif /* RT_USING_IDLE_HOOK */ - rt_thread_idle_excute(); +#ifndef RT_USING_SMP + rt_defunct_execute(); +#endif /* RT_USING_SMP */ + #ifdef RT_USING_PM rt_system_power_manager(); #endif /* RT_USING_PM */ } } +#ifdef RT_USING_SMP +static void rt_thread_system_entry(void *parameter) +{ + while (1) + { + rt_sem_take(&system_sem, RT_WAITING_FOREVER); + rt_defunct_execute(); + } +} +#endif + /** * @ingroup SystemInit * @@ -250,6 +344,24 @@ void rt_thread_idle_init(void) /* startup */ rt_thread_startup(&idle[i]); } + +#ifdef RT_USING_SMP + RT_ASSERT(RT_THREAD_PRIORITY_MAX > 2); + + rt_sem_init(&system_sem, "defunct", 1, RT_IPC_FLAG_FIFO); + + /* create defunct thread */ + rt_thread_init(&rt_system_thread, + "tsystem", + rt_thread_system_entry, + RT_NULL, + rt_system_stack, + sizeof(rt_system_stack), + RT_THREAD_PRIORITY_MAX - 2, + 32); + /* startup */ + rt_thread_startup(&rt_system_thread); +#endif } /** diff --git a/src/scheduler.c b/src/scheduler.c index eec660a8aa..956d95d7cc 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -47,8 +47,6 @@ struct rt_thread *rt_current_thread = RT_NULL; rt_uint8_t rt_current_priority; #endif /* RT_USING_SMP */ -rt_list_t rt_thread_defunct; - #ifdef RT_USING_HOOK static void (*rt_scheduler_hook)(struct rt_thread *from, struct rt_thread *to); @@ -224,9 +222,6 @@ void rt_system_scheduler_init(void) /* initialize ready table */ rt_memset(rt_thread_ready_table, 0, sizeof(rt_thread_ready_table)); #endif /* RT_THREAD_PRIORITY_MAX > 32 */ - - /* initialize thread defunct */ - rt_list_init(&rt_thread_defunct); } /** diff --git a/src/thread.c b/src/thread.c index c0a8f0ee74..88cc7b61ba 100644 --- a/src/thread.c +++ b/src/thread.c @@ -32,8 +32,6 @@ #include #include -extern rt_list_t rt_thread_defunct; - #ifdef RT_USING_HOOK static void (*rt_thread_suspend_hook)(rt_thread_t thread); static void (*rt_thread_resume_hook) (rt_thread_t thread); @@ -131,7 +129,7 @@ static void _rt_thread_exit(void) else { /* insert to defunct thread list */ - rt_list_insert_after(&rt_thread_defunct, &(thread->tlist)); + rt_thread_defunct_enqueue(thread); } /* switch to next task */ @@ -379,17 +377,22 @@ rt_err_t rt_thread_detach(rt_thread_t thread) /* release thread timer */ rt_timer_detach(&(thread->thread_timer)); - /* disable interrupt */ - lock = rt_hw_interrupt_disable(); - /* change stat */ thread->stat = RT_THREAD_CLOSE; - /* detach thread object */ - rt_object_detach((rt_object_t)thread); - - /* enable interrupt */ - rt_hw_interrupt_enable(lock); + if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE) + { + rt_object_detach((rt_object_t)thread); + } + else + { + /* disable interrupt */ + lock = rt_hw_interrupt_disable(); + /* insert to defunct thread list */ + rt_thread_defunct_enqueue(thread); + /* enable interrupt */ + rt_hw_interrupt_enable(lock); + } return RT_EOK; } @@ -484,7 +487,7 @@ rt_err_t rt_thread_delete(rt_thread_t thread) thread->stat = RT_THREAD_CLOSE; /* insert to defunct thread list */ - rt_list_insert_after(&rt_thread_defunct, &(thread->tlist)); + rt_thread_defunct_enqueue(thread); /* enable interrupt */ rt_hw_interrupt_enable(lock); @@ -847,12 +850,12 @@ rt_err_t rt_thread_resume(rt_thread_t thread) rt_timer_stop(&thread->thread_timer); - /* enable interrupt */ - rt_hw_interrupt_enable(temp); - /* insert to schedule ready list */ rt_schedule_insert_thread(thread); + /* enable interrupt */ + rt_hw_interrupt_enable(temp); + RT_OBJECT_HOOK_CALL(rt_thread_resume_hook, (thread)); return RT_EOK; } @@ -867,6 +870,7 @@ RTM_EXPORT(rt_thread_resume); void rt_thread_timeout(void *parameter) { struct rt_thread *thread; + register rt_base_t temp; thread = (struct rt_thread *)parameter; @@ -875,6 +879,9 @@ void rt_thread_timeout(void *parameter) RT_ASSERT((thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_SUSPEND); RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); + /* disable interrupt */ + temp = rt_hw_interrupt_disable(); + /* set error number */ thread->error = -RT_ETIMEOUT; @@ -884,6 +891,9 @@ void rt_thread_timeout(void *parameter) /* insert to schedule ready list */ rt_schedule_insert_thread(thread); + /* enable interrupt */ + rt_hw_interrupt_enable(temp); + /* do schedule */ rt_schedule(); } -- cgit v1.3.1 From 0015af02e4f08ab47f2d2fefcb7c1aca1682bfda Mon Sep 17 00:00:00 2001 From: fenghuijie Date: Mon, 5 Jul 2021 18:33:22 +0800 Subject: 调整代码,以支持cpu usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rtdef.h | 4 ++++ include/rtthread.h | 1 + libcpu/arm/cortex-a/interrupt.c | 14 ++++++++++++++ libcpu/arm/cortex-a/start_gcc.S | 2 ++ src/irq.c | 2 +- src/scheduler.c | 13 +++++++++++++ src/thread.c | 4 ++++ 7 files changed, 39 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/include/rtdef.h b/include/rtdef.h index 2eb2cc1963..e1a64a433a 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -663,6 +663,10 @@ struct rt_thread rt_ubase_t init_tick; /**< thread's initialized tick */ rt_ubase_t remaining_tick; /**< remaining tick */ +#ifdef RT_USING_CPU_USAGE + rt_uint64_t duration_tick; /**< cpu usage tick */ +#endif + struct rt_timer thread_timer; /**< built-in thread timer */ void (*cleanup)(struct rt_thread *tid); /**< cleanup function when thread exit */ diff --git a/include/rtthread.h b/include/rtthread.h index f2f4091b8a..cf47a48efe 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -186,6 +186,7 @@ rt_uint16_t rt_critical_level(void); #ifdef RT_USING_HOOK void rt_scheduler_sethook(void (*hook)(rt_thread_t from, rt_thread_t to)); +void rt_scheduler_switch_sethook(void (*hook)(struct rt_thread *tid)); #endif #ifdef RT_USING_SMP diff --git a/libcpu/arm/cortex-a/interrupt.c b/libcpu/arm/cortex-a/interrupt.c index 474a23fee1..f90f1c0094 100644 --- a/libcpu/arm/cortex-a/interrupt.c +++ b/libcpu/arm/cortex-a/interrupt.c @@ -27,6 +27,20 @@ struct rt_irq_desc isr_table[MAX_HANDLERS]; rt_uint32_t rt_interrupt_from_thread = 0; rt_uint32_t rt_interrupt_to_thread = 0; rt_uint32_t rt_thread_switch_interrupt_flag = 0; + +#ifdef RT_USING_HOOK +static void (*rt_interrupt_switch_hook)(void); + +void rt_interrupt_switch_sethook(void (*hook)(void)) +{ + rt_interrupt_switch_hook = hook; +} +#endif + +void rt_interrupt_hook(void) +{ + RT_OBJECT_HOOK_CALL(rt_interrupt_switch_hook, ()); +} #endif const unsigned int VECTOR_BASE = 0x00; diff --git a/libcpu/arm/cortex-a/start_gcc.S b/libcpu/arm/cortex-a/start_gcc.S index 6c5dd81785..908468476e 100644 --- a/libcpu/arm/cortex-a/start_gcc.S +++ b/libcpu/arm/cortex-a/start_gcc.S @@ -341,6 +341,8 @@ rt_hw_context_switch_interrupt_do: ldr r6, [r6] ldr sp, [r6] @ get new task's stack pointer + bl rt_interrupt_hook + #ifdef RT_USING_FPU /* fpu context */ ldmfd sp!, {r6} diff --git a/src/irq.c b/src/irq.c index e89b8504dc..6ddcb3dd4a 100644 --- a/src/irq.c +++ b/src/irq.c @@ -89,8 +89,8 @@ void rt_interrupt_leave(void) rt_interrupt_nest)); level = rt_hw_interrupt_disable(); - rt_interrupt_nest --; RT_OBJECT_HOOK_CALL(rt_interrupt_leave_hook,()); + rt_interrupt_nest --; rt_hw_interrupt_enable(level); } RTM_EXPORT(rt_interrupt_leave); diff --git a/src/scheduler.c b/src/scheduler.c index 956d95d7cc..353fdad5cb 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -49,6 +49,7 @@ rt_uint8_t rt_current_priority; #ifdef RT_USING_HOOK static void (*rt_scheduler_hook)(struct rt_thread *from, struct rt_thread *to); +static void (*rt_scheduler_switch_hook)(struct rt_thread *tid); /** * @addtogroup Hook @@ -68,6 +69,12 @@ rt_scheduler_sethook(void (*hook)(struct rt_thread *from, struct rt_thread *to)) rt_scheduler_hook = hook; } +void +rt_scheduler_switch_sethook(void (*hook)(struct rt_thread *tid)) +{ + rt_scheduler_switch_hook = hook; +} + /**@}*/ #endif /* RT_USING_HOOK */ @@ -364,6 +371,8 @@ void rt_schedule(void) _rt_scheduler_stack_check(to_thread); #endif /* RT_USING_OVERFLOW_CHECK */ + RT_OBJECT_HOOK_CALL(rt_scheduler_switch_hook, (current_thread)); + rt_hw_context_switch((rt_ubase_t)¤t_thread->sp, (rt_ubase_t)&to_thread->sp, to_thread); } @@ -473,6 +482,8 @@ void rt_schedule(void) { extern void rt_thread_handle_sig(rt_bool_t clean_state); + RT_OBJECT_HOOK_CALL(rt_scheduler_switch_hook, (from_thread)); + rt_hw_context_switch((rt_ubase_t)&from_thread->sp, (rt_ubase_t)&to_thread->sp); @@ -609,6 +620,8 @@ void rt_scheduler_do_irq_switch(void *context) current_thread->cpus_lock_nest--; current_thread->scheduler_lock_nest--; + RT_OBJECT_HOOK_CALL(rt_scheduler_switch_hook, (current_thread)); + rt_hw_context_switch_interrupt(context, (rt_ubase_t)¤t_thread->sp, (rt_ubase_t)&to_thread->sp, to_thread); } diff --git a/src/thread.c b/src/thread.c index 88cc7b61ba..60e6ab91d1 100644 --- a/src/thread.c +++ b/src/thread.c @@ -228,6 +228,10 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread, thread->lwp = RT_NULL; #endif /* RT_USING_LWP */ +#ifdef RT_USING_CPU_USAGE + thread->duration_tick = 0; +#endif + RT_OBJECT_HOOK_CALL(rt_thread_inited_hook, (thread)); return RT_EOK; -- cgit v1.3.1 From edcdd126edf86b9990e15449ab69c8554da9e274 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 7 Jul 2021 03:30:01 +0800 Subject: [kernel][ipc] 移除mutex RT_IPC_FLAG_FIFO 功能 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ipc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ipc.c b/src/ipc.c index 959f0fb522..6a038cd2b6 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -548,6 +548,8 @@ RTM_EXPORT(rt_sem_control); */ rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag) { + (void)flag; + /* parameter check */ RT_ASSERT(mutex != RT_NULL); @@ -562,8 +564,8 @@ rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag) mutex->original_priority = 0xFF; mutex->hold = 0; - /* set flag */ - mutex->parent.parent.flag = flag; + /* set flag and it can only be RT_IPC_FLAG_PRIO */ + mutex->parent.parent.flag = RT_IPC_FLAG_PRIO; return RT_EOK; } @@ -609,6 +611,7 @@ RTM_EXPORT(rt_mutex_detach); rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag) { struct rt_mutex *mutex; + (void)flag; RT_DEBUG_NOT_IN_INTERRUPT; @@ -625,8 +628,8 @@ rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag) mutex->original_priority = 0xFF; mutex->hold = 0; - /* set flag */ - mutex->parent.parent.flag = flag; + /* set flag and it can only be RT_IPC_FLAG_PRIO */ + mutex->parent.parent.flag = RT_IPC_FLAG_PRIO; return mutex; } -- cgit v1.3.1 From 6e334416e3c855ef17a2a59eba816408ac296a75 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 7 Jul 2021 10:16:49 +0800 Subject: [ipc][mutex] 补充注释 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ipc.c b/src/ipc.c index 6a038cd2b6..6bc9c079b9 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -564,7 +564,7 @@ rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag) mutex->original_priority = 0xFF; mutex->hold = 0; - /* set flag and it can only be RT_IPC_FLAG_PRIO */ + /* flag can only be RT_IPC_FLAG_PRIO. RT_IPC_FLAG_FIFO cannot solve the unbounded priority inversion problem */ mutex->parent.parent.flag = RT_IPC_FLAG_PRIO; return RT_EOK; @@ -628,7 +628,7 @@ rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag) mutex->original_priority = 0xFF; mutex->hold = 0; - /* set flag and it can only be RT_IPC_FLAG_PRIO */ + /* flag can only be RT_IPC_FLAG_PRIO. RT_IPC_FLAG_FIFO cannot solve the unbounded priority inversion problem */ mutex->parent.parent.flag = RT_IPC_FLAG_PRIO; return mutex; -- cgit v1.3.1 From 9f3e349f69c66fb27496492d0f0c3cefa0bb891b Mon Sep 17 00:00:00 2001 From: chenjh Date: Fri, 9 Jul 2021 10:54:51 +0800 Subject: [comment] Optimize the comment for ipc --- src/ipc.c | 1079 ++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 848 insertions(+), 231 deletions(-) (limited to 'src') diff --git a/src/ipc.c b/src/ipc.c index 6bc9c079b9..8acfd831d7 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -57,11 +57,16 @@ extern void (*rt_object_put_hook)(struct rt_object *object); /**@{*/ /** - * This function will initialize an IPC object + * @brief This function will initialize an IPC object, such as semaphore, mutex, messagequeue and mailbox. * - * @param ipc the IPC object + * @note Executing this function will complete an initialization of the suspend thread list of the ipc object. * - * @return the operation status, RT_EOK on successful + * @param ipc is a pointer to the IPC object. + * + * @return Return the operation status. When the return value is RT_EOK, the initialization is successful. + * When the return value is any other values, it means the initialization failed. + * + * @warning This function can be called from all IPC initialization and creation. */ rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc) { @@ -71,16 +76,35 @@ rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc) return RT_EOK; } + /** - * This function will suspend a thread to a specified list. IPC object or some - * double-queue object (mailbox etc.) contains this kind of list. + * @brief This function will suspend a thread to a IPC object list. + * + * @param list is a pointer to a suspended thread list of the IPC object. + * + * @param thread is a pointer to the thread object to be suspended. + * + * @param flag is a flag for the thread object to be suspended. It determines how the thread is suspended. + * The flag can be ONE of the following values: + * + * RT_IPC_FLAG_PRIO The pending threads will queue in order of priority. + * + * RT_IPC_FLAG_FIFO The pending threads will queue in the first-in-first-out method + * (also known as first-come-first-served (FCFS) scheduling strategy). + * + * NOTE: RT_IPC_FLAG_FIFO is a non-real-time scheduling mode. It is strongly recommended to use + * RT_IPC_FLAG_PRIO to ensure the thread is real-time UNLESS your applications concern about + * the first-in-first-out principle, and you clearly understand that all threads involved in + * this semaphore will become non-real-time threads. * - * @param list the IPC suspended thread list - * @param thread the thread object to be suspended - * @param flag the IPC object flag, - * which shall be RT_IPC_FLAG_FIFO/RT_IPC_FLAG_PRIO. + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means the initialization failed. * - * @return the operation status, RT_EOK on successful + * @warning This function can ONLY be called in the thread context, you can use RT_DEBUG_IN_THREAD_CONTEXT to + * check the context. + * In addition, this function is generally called by the following functions: + * rt_sem_take(), rt_mutex_take(), rt_event_recv(), rt_mb_send_wait(), + * rt_mb_recv(), rt_mq_recv(), rt_mq_send_wait() */ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list, struct rt_thread *thread, @@ -131,14 +155,25 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list, return RT_EOK; } + /** - * This function will resume the first thread in the list of a IPC object: - * - remove the thread from suspend queue of IPC object - * - put the thread into system ready queue + * @brief This function will resume a thread. + * + * @note This function will resume the first thread in the list of a IPC object. + * 1. remove the thread from suspend queue of a IPC object. + * 2. put the thread into system ready queue. + * + * By contrast, the rt_ipc_list_resume_all() function will resume all suspended threads + * in the list of a IPC object. + * + * @param list is a pointer to a suspended thread list of the IPC object. * - * @param list the thread list + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. * - * @return the operation status, RT_EOK on successful + * @warning This function is generally called by the following functions: + * rt_sem_release(), rt_mutex_release(), rt_mb_send_wait(), rt_mq_send_wait(), + * rt_mb_urgent(), rt_mb_recv(), rt_mq_urgent(), rt_mq_recv(), */ rt_inline rt_err_t rt_ipc_list_resume(rt_list_t *list) { @@ -155,13 +190,19 @@ rt_inline rt_err_t rt_ipc_list_resume(rt_list_t *list) return RT_EOK; } + /** - * This function will resume all suspended threads in a list, including - * suspend list of IPC object and private list of mailbox etc. + * @brief This function will resume all suspended threads in the IPC object list, + * including the suspended list of IPC object, and private list of mailbox etc. + * + * @note This function will resume all threads in the IPC object list. + * By contrast, the rt_ipc_list_resume() function will resume a suspended thread in the list of a IPC object. * - * @param list of the threads to resume + * @param list is a pointer to a suspended thread list of the IPC object. + * + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. * - * @return the operation status, RT_EOK on successful */ rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list) { @@ -193,17 +234,51 @@ rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list) return RT_EOK; } +/**@}*/ + #ifdef RT_USING_SEMAPHORE /** - * This function will initialize a semaphore and put it under control of - * resource management. + * @addtogroup semaphore + */ + +/**@{*/ +/** + * @brief This function will initialize a static semaphore object. + * + * @note For the static semaphore object, its memory space is allocated by the compiler during compiling, + * and shall placed on the read-write data segment or on the uninitialized data segment. + * By contrast, the rt_sem_create() function will allocate memory space automatically and initialize + * the semaphore. + * + * @see rt_sem_create() + * + * @param sem is a pointer to the semaphore to initialize. It is assumed that storage for the semaphore will be + * allocated in your application. * - * @param sem the semaphore object - * @param name the name of semaphore - * @param value the initial value of semaphore - * @param flag the flag of semaphore + * @param name is a pointer to the name you would like to give the semaphore. * - * @return the operation status, RT_EOK on successful + * @param value is the initial value for the semaphore. + * If used to share resources, you should initialize the value as the number of available resources. + * If used to signal the occurrence of an event, you should initialize the value as 0. + * + * @param flag is the semaphore flag, which determines the queuing way of how multiple threads wait + * when the semaphore is not available. + * The semaphore flag can be ONE of the following values: + * + * RT_IPC_FLAG_PRIO The pending threads will queue in order of priority. + * + * RT_IPC_FLAG_FIFO The pending threads will queue in the first-in-first-out method + * (also known as first-come-first-served (FCFS) scheduling strategy). + * + * NOTE: RT_IPC_FLAG_FIFO is a non-real-time scheduling mode. It is strongly recommended to + * use RT_IPC_FLAG_PRIO to ensure the thread is real-time UNLESS your applications concern about + * the first-in-first-out principle, and you clearly understand that all threads involved in + * this semaphore will become non-real-time threads. + * + * @return Return the operation status. When the return value is RT_EOK, the initialization is successful. + * If the return value is any other values, it represents the initialization failed. + * + * @warning This function can ONLY be called from threads. */ rt_err_t rt_sem_init(rt_sem_t sem, const char *name, @@ -229,14 +304,24 @@ rt_err_t rt_sem_init(rt_sem_t sem, } RTM_EXPORT(rt_sem_init); + /** - * This function will detach a semaphore from resource management + * @brief This function will detach a static semaphore object. + * + * @note This function is used to detach a static semaphore object which is initialized by rt_sem_init() function. + * By contrast, the rt_sem_delete() function will delete a semaphore object. + * When the semaphore is successfully detached, it will resume all suspended threads in the semaphore list. * - * @param sem the semaphore object + * @see rt_sem_delete() * - * @return the operation status, RT_EOK on successful + * @param sem is a pointer to a semaphore object to be detached. * - * @see rt_sem_delete + * @return Return the operation status. When the return value is RT_EOK, the initialization is successful. + * If the return value is any other values, it means that the semaphore detach failed. + * + * @warning This function can ONLY detach a static semaphore initialized by the rt_sem_init() function. + * If the semaphore is created by the rt_sem_create() function, you MUST NOT USE this function to detach it, + * ONLY USE the rt_sem_delete() function to complete the deletion. */ rt_err_t rt_sem_detach(rt_sem_t sem) { @@ -257,15 +342,36 @@ RTM_EXPORT(rt_sem_detach); #ifdef RT_USING_HEAP /** - * This function will create a semaphore from system resource + * @brief Creating a semaphore object. + * + * @note For the semaphore object, its memory space is allocated automatically. + * By contrast, the rt_sem_init() function will initialize a static semaphore object. + * + * @see rt_sem_init() + * + * @param name is a pointer to the name you would like to give the semaphore. + * + * @param value is the initial value for the semaphore. + * If used to share resources, you should initialize the value as the number of available resources. + * If used to signal the occurrence of an event, you should initialize the value as 0. * - * @param name the name of semaphore - * @param value the initial value of semaphore - * @param flag the flag of semaphore + * @param flag is the semaphore flag, which determines the queuing way of how multiple threads wait + * when the semaphore is not available. + * The semaphore flag can be ONE of the following values: * - * @return the created semaphore, RT_NULL on error happen + * RT_IPC_FLAG_PRIO The pending threads will queue in order of priority. * - * @see rt_sem_init + * RT_IPC_FLAG_FIFO The pending threads will queue in the first-in-first-out method + * (also known as first-come-first-served (FCFS) scheduling strategy). + * + * NOTE: RT_IPC_FLAG_FIFO is a non-real-time scheduling mode. It is strongly recommended to + * use RT_IPC_FLAG_PRIO to ensure the thread is real-time UNLESS your applications concern about + * the first-in-first-out principle, and you clearly understand that all threads involved in + * this semaphore will become non-real-time threads. + * + * @return Return a pointer to the semaphore object. When the return value is RT_NULL, it means the creation failed. + * + * @warning This function can NOT be called in interrupt context. You can use macor RT_DEBUG_NOT_IN_INTERRUPT to check it. */ rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag) { @@ -292,14 +398,24 @@ rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag) } RTM_EXPORT(rt_sem_create); + /** - * This function will delete a semaphore object and release the memory + * @brief This function will delete a semaphore object and release the memory space. * - * @param sem the semaphore object + * @note This function is used to delete a semaphore object which is created by the rt_sem_create() function. + * By contrast, the rt_sem_detach() function will detach a static semaphore object. + * When the semaphore is successfully deleted, it will resume all suspended threads in the semaphore list. * - * @return the error code + * @see rt_sem_detach() * - * @see rt_sem_detach + * @param sem is a pointer to a semaphore object to be deleted. + * + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the semaphore detach failed. + * + * @warning This function can ONLY delete a semaphore initialized by the rt_sem_create() function. + * If the semaphore is initialized by the rt_sem_init() function, you MUST NOT USE this function to delete it, + * ONLY USE the rt_sem_detach() function to complete the detachment. */ rt_err_t rt_sem_delete(rt_sem_t sem) { @@ -321,14 +437,29 @@ rt_err_t rt_sem_delete(rt_sem_t sem) RTM_EXPORT(rt_sem_delete); #endif /* RT_USING_HEAP */ + /** - * This function will take a semaphore, if the semaphore is unavailable, the - * thread shall wait for a specified time. + * @brief This function will take a semaphore, if the semaphore is unavailable, the thread shall wait for + * the semaphore up to a specified time. + * + * @note When this function is called, the count value of the sem->value will decrease 1 until it is equal to 0. + * When the sem->value is 0, it means that the semaphore is unavailable. At this time, it will suspend the + * thread preparing to take the semaphore. + * On the contrary, the rt_sem_release() function will increase the count value of sem->value by 1 each time. * - * @param sem the semaphore object - * @param time the waiting time + * @see rt_sem_trytake() * - * @return the error code + * @param sem is a pointer to a semaphore object. + * + * @param time is a timeout period (unit: an OS tick). If the semaphore is unavailable, the thread will wait for + * the semaphore up to the amount of time specified by the argument. + * NOTE: Generally, we use the macro RT_WAITING_FOREVER to set this parameter, which means that when the + * semaphore is unavailable, the thread will be waitting forever. + * + * @return Return the operation status. ONLY When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the semaphore take failed. + * + * @warning This function can ONLY be called in the thread context. It MUST NOT BE called in interrupt context. */ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time) { @@ -418,12 +549,20 @@ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time) } RTM_EXPORT(rt_sem_take); + /** - * This function will try to take a semaphore and immediately return + * @brief This function will try to take a semaphore, if the semaphore is unavailable, the thread returns immediately. * - * @param sem the semaphore object + * @note This function is very similar to the rt_sem_take() function, when the semaphore is not available, + * the rt_sem_trytake() function will return immediately without waiting for a timeout. + * In other words, rt_sem_trytake(sem) has the same effect as rt_sem_take(sem, 0). * - * @return the error code + * @see rt_sem_take() + * + * @param sem is a pointer to a semaphore object. + * + * @return Return the operation status. ONLY When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the semaphore take failed. */ rt_err_t rt_sem_trytake(rt_sem_t sem) { @@ -431,13 +570,18 @@ rt_err_t rt_sem_trytake(rt_sem_t sem) } RTM_EXPORT(rt_sem_trytake); + /** - * This function will release a semaphore, if there are threads suspended on - * semaphore, it will be waked up. + * @brief This function will release a semaphore. If there is thread suspended on the semaphore, it will get resumed. + * + * @note If there are threads suspended on this semaphore, the first thread in the list of this semaphore object + * will be resumed, and a thread scheduling (rt_schedule) will be executed. + * If no threads are suspended on this semaphore, the count value sem->value of this semaphore will increase by 1. * - * @param sem the semaphore object + * @param sem is a pointer to a semaphore object. * - * @return the error code + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the semaphore release failed. */ rt_err_t rt_sem_release(rt_sem_t sem) { @@ -490,14 +634,20 @@ rt_err_t rt_sem_release(rt_sem_t sem) } RTM_EXPORT(rt_sem_release); + /** - * This function can get or set some extra attributions of a semaphore object. + * @brief This function will set some extra attributions of a semaphore object. + * + * @note Currently this function only supports the RT_IPC_CMD_RESET command to reset the semaphore. + * + * @param sem is a pointer to a semaphore object. + * + * @param cmd is a command word used to configure some attributions of the semaphore. * - * @param sem the semaphore object - * @param cmd the execution command - * @param arg the execution argument + * @param arg is the argument of the function to execute the command. * - * @return the error code + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that this function failed to execute. */ rt_err_t rt_sem_control(rt_sem_t sem, int cmd, void *arg) { @@ -533,18 +683,41 @@ rt_err_t rt_sem_control(rt_sem_t sem, int cmd, void *arg) return -RT_ERROR; } RTM_EXPORT(rt_sem_control); + +/**@}*/ #endif /* RT_USING_SEMAPHORE */ #ifdef RT_USING_MUTEX /** - * This function will initialize a mutex and put it under control of resource - * management. + * @addtogroup mutex + */ + +/**@{*/ + +/** + * @brief Initialize a static mutex object. + * + * @note For the static mutex object, its memory space is allocated by the compiler during compiling, + * and shall placed on the read-write data segment or on the uninitialized data segment. + * By contrast, the rt_mutex_create() function will automatically allocate memory space + * and initialize the mutex. * - * @param mutex the mutex object - * @param name the name of mutex - * @param flag the flag of mutex + * @see rt_mutex_create() * - * @return the operation status, RT_EOK on successful + * @param mutex is a pointer to the mutex to initialize. It is assumed that storage for the mutex will be + * allocated in your application. + * + * @param name is a pointer to the name that given to the mutex. + * + * @param flag is the mutex flag, which determines the queuing way of how multiple threads wait + * when the mutex is not available. + * NOTE: The mutex flag can ONLY be RT_IPC_FLAG_PRIO. Using RT_IPC_FLAG_FIFO will seriously affect + * the real-time performance of the system. + * + * @return Return the operation status. When the return value is RT_EOK, the initialization is successful. + * If the return value is any other values, it represents the initialization failed. + * + * @warning This function can ONLY be called from threads. */ rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag) { @@ -571,14 +744,24 @@ rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag) } RTM_EXPORT(rt_mutex_init); + /** - * This function will detach a mutex from resource management + * @brief This function will detach a static mutex object. * - * @param mutex the mutex object + * @note This function is used to detach a static mutex object which is initialized by rt_mutex_init() function. + * By contrast, the rt_mutex_delete() function will delete a mutex object. + * When the mutex is successfully detached, it will resume all suspended threads in the mutex list. * - * @return the operation status, RT_EOK on successful + * @see rt_mutex_delete() * - * @see rt_mutex_delete + * @param mutex is a pointer to a mutex object to be detached. + * + * @return Return the operation status. When the return value is RT_EOK, the initialization is successful. + * If the return value is any other values, it means that the mutex detach failed. + * + * @warning This function can ONLY detach a static mutex initialized by the rt_mutex_init() function. + * If the mutex is created by the rt_mutex_create() function, you MUST NOT USE this function to detach it, + * ONLY USE the rt_mutex_delete() function to complete the deletion. */ rt_err_t rt_mutex_detach(rt_mutex_t mutex) { @@ -599,14 +782,23 @@ RTM_EXPORT(rt_mutex_detach); #ifdef RT_USING_HEAP /** - * This function will create a mutex from system resource + * @brief This function will create a mutex object. + * + * @note For the mutex object, its memory space is automatically allocated. + * By contrast, the rt_mutex_init() function will initialize a static mutex object. + * + * @see rt_mutex_init() * - * @param name the name of mutex - * @param flag the flag of mutex + * @param name is a pointer to the name that given to the mutex. * - * @return the created mutex, RT_NULL on error happen + * @param flag is the mutex flag, which determines the queuing way of how multiple threads wait + * when the mutex is not available. + * NOTE: The mutex flag can ONLY be RT_IPC_FLAG_PRIO. Using RT_IPC_FLAG_FIFO will seriously affect + * the real-time performance of the system. * - * @see rt_mutex_init + * @return Return a pointer to the mutex object. When the return value is RT_NULL, it means the creation failed. + * + * @warning This function can ONLY be called from threads. */ rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag) { @@ -635,14 +827,24 @@ rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag) } RTM_EXPORT(rt_mutex_create); + /** - * This function will delete a mutex object and release the memory + * @brief This function will delete a mutex object and release this memory space. + * + * @note This function is used to delete a mutex object which is created by the rt_mutex_create() function. + * By contrast, the rt_mutex_detach() function will detach a static mutex object. + * When the mutex is successfully deleted, it will resume all suspended threads in the mutex list. + * + * @see rt_mutex_detach() * - * @param mutex the mutex object + * @param mutex is a pointer to a mutex object to be deleted. * - * @return the error code + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the mutex detach failed. * - * @see rt_mutex_detach + * @warning This function can ONLY delete a mutex initialized by the rt_mutex_create() function. + * If the mutex is initialized by the rt_mutex_init() function, you MUST NOT USE this function to delete it, + * ONLY USE the rt_mutex_detach() function to complete the detachment. */ rt_err_t rt_mutex_delete(rt_mutex_t mutex) { @@ -664,14 +866,29 @@ rt_err_t rt_mutex_delete(rt_mutex_t mutex) RTM_EXPORT(rt_mutex_delete); #endif /* RT_USING_HEAP */ + /** - * This function will take a mutex, if the mutex is unavailable, the - * thread shall wait for a specified time. + * @brief This function will take a mutex, if the mutex is unavailable, the thread shall wait for + * the mutex up to a specified time. + * + * @note When this function is called, the count value of the sem->value will decrease 1 until it is equal to 0. + * When the sem->value is 0, it means that the mutex is unavailable. At this time, it will suspend the + * thread preparing to take the mutex. + * On the contrary, the rt_sem_release() function will increase the count value of sem->value by 1 each time. + * + * @see rt_mutex_trytake() + * + * @param mutex is a pointer to a mutex object. * - * @param mutex the mutex object - * @param time the waiting time + * @param time is a timeout period (unit: an OS tick). If the mutex is unavailable, the thread will wait for + * the mutex up to the amount of time specified by the argument. + * NOTE: Generally, we set this parameter to RT_WAITING_FOREVER, which means that when the mutex is unavailable, + * the thread will be waitting forever. * - * @return the error code + * @return Return the operation status. ONLY When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the mutex take failed. + * + * @warning This function can ONLY be called in the thread context. It MUST NOT BE called in interrupt context. */ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time) { @@ -821,12 +1038,21 @@ __again: } RTM_EXPORT(rt_mutex_take); + /** - * This function will try to take a mutex and immediately return + * @brief This function will try to take a mutex, if the mutex is unavailable, the thread returns immediately. + * + * @note This function is very similar to the rt_mutex_take() function, when the mutex is not available, + * except that rt_mutex_trytake() will return immediately without waiting for a timeout + * when the mutex is not available. + * In other words, rt_mutex_trytake(mutex) has the same effect as rt_mutex_take(mutex, 0). + * + * @see rt_mutex_take() * - * @param mutex the mutex object + * @param mutex is a pointer to a mutex object. * - * @return the error code + * @return Return the operation status. ONLY When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the mutex take failed. */ rt_err_t rt_mutex_trytake(rt_mutex_t mutex) { @@ -834,13 +1060,18 @@ rt_err_t rt_mutex_trytake(rt_mutex_t mutex) } RTM_EXPORT(rt_mutex_trytake); + /** - * This function will release a mutex, if there are threads suspended on mutex, - * it will be waked up. + * @brief This function will release a mutex. If there is thread suspended on the mutex, the thread will be resumed. + * + * @note If there are threads suspended on this mutex, the first thread in the list of this mutex object + * will be resumed, and a thread scheduling (rt_schedule) will be executed. + * If no threads are suspended on this mutex, the count value mutex->value of this mutex will increase by 1. * - * @param mutex the mutex object + * @param mutex is a pointer to a mutex object. * - * @return the error code + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the mutex release failed. */ rt_err_t rt_mutex_release(rt_mutex_t mutex) { @@ -953,14 +1184,20 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) } RTM_EXPORT(rt_mutex_release); + /** - * This function can get or set some extra attributions of a mutex object. + * @brief This function will set some extra attributions of a mutex object. + * + * @note Currently this function does not implement the control function. * - * @param mutex the mutex object - * @param cmd the execution command - * @param arg the execution argument + * @param mutex is a pointer to a mutex object. * - * @return the error code + * @param cmd is a command word used to configure some attributions of the mutex. + * + * @param arg is the argument of the function to execute the command. + * + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that this function failed to execute. */ rt_err_t rt_mutex_control(rt_mutex_t mutex, int cmd, void *arg) { @@ -971,18 +1208,54 @@ rt_err_t rt_mutex_control(rt_mutex_t mutex, int cmd, void *arg) return -RT_ERROR; } RTM_EXPORT(rt_mutex_control); + +/**@}*/ #endif /* RT_USING_MUTEX */ #ifdef RT_USING_EVENT /** - * This function will initialize an event and put it under control of resource - * management. + * @addtogroup event + */ + +/**@{*/ + +/** + * @brief The function will initialize a static event object. + * + * @note For the static event object, its memory space is allocated by the compiler during compiling, + * and shall placed on the read-write data segment or on the uninitialized data segment. + * By contrast, the rt_event_create() function will allocate memory space automatically + * and initialize the event. + * + * @see rt_event_create() + * + * @param event is a pointer to the event to initialize. It is assumed that storage for the event + * will be allocated in your application. + * + * @param name is a pointer to the name that given to the event. + * + * @param value is the initial value for the event. + * If want to share resources, you should initialize the value as the number of available resources. + * If want to signal the occurrence of an event, you should initialize the value as 0. + * + * @param flag is the event flag, which determines the queuing way of how multiple threads wait + * when the event is not available. + * The event flag can be ONE of the following values: + * + * RT_IPC_FLAG_PRIO The pending threads will queue in order of priority. * - * @param event the event object - * @param name the name of event - * @param flag the flag of event + * RT_IPC_FLAG_FIFO The pending threads will queue in the first-in-first-out method + * (also known as first-come-first-served (FCFS) scheduling strategy). * - * @return the operation status, RT_EOK on successful + * NOTE: RT_IPC_FLAG_FIFO is a non-real-time scheduling mode. It is strongly recommended to + * use RT_IPC_FLAG_PRIO to ensure the thread is real-time UNLESS your applications concern about + * the first-in-first-out principle, and you clearly understand that all threads involved in + * this event will become non-real-time threads. + * + * @return Return the operation status. When the return value is RT_EOK, the initialization is successful. + * If the return value is any other values, it represents the initialization failed. + * + * @warning This function can ONLY be called from threads. */ rt_err_t rt_event_init(rt_event_t event, const char *name, rt_uint8_t flag) { @@ -1005,12 +1278,24 @@ rt_err_t rt_event_init(rt_event_t event, const char *name, rt_uint8_t flag) } RTM_EXPORT(rt_event_init); + /** - * This function will detach an event object from resource management + * @brief This function will detach a static event object. + * + * @note This function is used to detach a static event object which is initialized by rt_event_init() function. + * By contrast, the rt_event_delete() function will delete an event object. + * When the event is successfully detached, it will resume all suspended threads in the event list. * - * @param event the event object + * @see rt_event_delete() * - * @return the operation status, RT_EOK on successful + * @param event is a pointer to an event object to be detached. + * + * @return Return the operation status. When the return value is RT_EOK, the initialization is successful. + * If the return value is any other values, it means that the event detach failed. + * + * @warning This function can ONLY detach a static event initialized by the rt_event_init() function. + * If the event is created by the rt_event_create() function, you MUST NOT USE this function to detach it, + * ONLY USE the rt_event_delete() function to complete the deletion. */ rt_err_t rt_event_detach(rt_event_t event) { @@ -1031,12 +1316,32 @@ RTM_EXPORT(rt_event_detach); #ifdef RT_USING_HEAP /** - * This function will create an event object from system resource + * @brief Creating an event object. + * + * @note For the event object, its memory space is allocated automatically. + * By contrast, the rt_event_init() function will initialize a static event object. + * + * @see rt_event_init() * - * @param name the name of event - * @param flag the flag of event + * @param name is a pointer to the name that given to the event. * - * @return the created event, RT_NULL on error happen + * @param flag is the event flag, which determines the queuing way of how multiple threads wait when the event + * is not available. + * The event flag can be ONE of the following values: + * + * RT_IPC_FLAG_PRIO The pending threads will queue in order of priority. + * + * RT_IPC_FLAG_FIFO The pending threads will queue in the first-in-first-out method + * (also known as first-come-first-served (FCFS) scheduling strategy). + * + * NOTE: RT_IPC_FLAG_FIFO is a non-real-time scheduling mode. It is strongly recommended to + * use RT_IPC_FLAG_PRIO to ensure the thread is real-time UNLESS your applications concern about + * the first-in-first-out principle, and you clearly understand that all threads involved in + * this event will become non-real-time threads. + * + * @return Return a pointer to the event object. When the return value is RT_NULL, it means the creation failed. + * + * @warning This function can ONLY be called from threads. */ rt_event_t rt_event_create(const char *name, rt_uint8_t flag) { @@ -1062,12 +1367,24 @@ rt_event_t rt_event_create(const char *name, rt_uint8_t flag) } RTM_EXPORT(rt_event_create); + /** - * This function will delete an event object and release the memory + * @brief This function will delete an event object and release the memory space. + * + * @note This function is used to delete an event object which is created by the rt_event_create() function. + * By contrast, the rt_event_detach() function will detach a static event object. + * When the event is successfully deleted, it will resume all suspended threads in the event list. + * + * @see rt_event_detach() * - * @param event the event object + * @param event is a pointer to an event object to be deleted. * - * @return the error code + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the event detach failed. + * + * @warning This function can ONLY delete an event initialized by the rt_event_create() function. + * If the event is initialized by the rt_event_init() function, you MUST NOT USE this function to delete it, + * ONLY USE the rt_event_detach() function to complete the detachment. */ rt_err_t rt_event_delete(rt_event_t event) { @@ -1089,14 +1406,23 @@ rt_err_t rt_event_delete(rt_event_t event) RTM_EXPORT(rt_event_delete); #endif /* RT_USING_HEAP */ + /** - * This function will send an event to the event object, if there are threads - * suspended on event object, it will be waked up. + * @brief This function will send an event to the event object. + * If there is a thread suspended on the event, the thread will be resumed. + * + * @note When using this function, you need to use the parameter (set) to specify the event flag of the event object, + * then the function will traverse the list of suspended threads waiting on the event object. + * If there is a thread suspended on the event, and the thread's event_info and the event flag of + * the current event object matches, the thread will be resumed. + * + * @param event is a pointer to the event object to be sent. * - * @param event the event object - * @param set the event set + * @param set is a flag that you will set for this event's flag. + * You can set an event flag, or you can set multiple flags through OR logic operation. * - * @return the error code + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the event detach failed. */ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set) { @@ -1190,18 +1516,38 @@ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set) } RTM_EXPORT(rt_event_send); + /** - * This function will receive an event from event object, if the event is - * unavailable, the thread shall wait for a specified time. + * @brief This function will receive an event from event object. if the event is unavailable, the thread shall wait for + * the event up to a specified time. + * + * @note If there are threads suspended on this semaphore, the first thread in the list of this semaphore object + * will be resumed, and a thread scheduling (rt_schedule) will be executed. + * If no threads are suspended on this semaphore, the count value sem->value of this semaphore will increase by 1. + * + * @param event is a pointer to the event object to be received. + * + * @param set is a flag that you will set for this event's flag. + * You can set an event flag, or you can set multiple flags through OR logic operation. * - * @param event the fast event object - * @param set the interested event set - * @param option the receive option, either RT_EVENT_FLAG_AND or - * RT_EVENT_FLAG_OR should be set. - * @param timeout the waiting time - * @param recved the received event, if you don't care, RT_NULL can be set. + * @param option is the option of this receiving event, it indicates how the receiving event is operated. + * The option can be one or more of the following values, When selecting multiple values,use logical OR to operate. + * (NOTE: RT_EVENT_FLAG_OR and RT_EVENT_FLAG_AND can only select one): * - * @return the error code + * + * RT_EVENT_FLAG_OR The thread select to use logical OR to receive the event. + * + * RT_EVENT_FLAG_AND The thread select to use logical OR to receive the event. + * + * RT_EVENT_FLAG_CLEAR When the thread receives the corresponding event, the function + * determines whether to clear the event flag. + * + * @param timeout is a timeout period (unit: an OS tick). + * + * @param recved is a pointer to the received event. If you don't care about this value, you can use RT_NULL to set. + * + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the semaphore release failed. */ rt_err_t rt_event_recv(rt_event_t event, rt_uint32_t set, @@ -1325,14 +1671,20 @@ rt_err_t rt_event_recv(rt_event_t event, } RTM_EXPORT(rt_event_recv); + /** - * This function can get or set some extra attributions of an event object. + * @brief This function will set some extra attributions of an event object. + * + * @note Currently this function only supports the RT_IPC_CMD_RESET command to reset the event. + * + * @param event is a pointer to an event object. * - * @param event the event object - * @param cmd the execution command - * @param arg the execution argument + * @param cmd is a command word used to configure some attributions of the event. * - * @return the error code + * @param arg is the argument of the function to execute the command. + * + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that this function failed to execute. */ rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg) { @@ -1364,20 +1716,55 @@ rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg) return -RT_ERROR; } RTM_EXPORT(rt_event_control); + +/**@}*/ #endif /* RT_USING_EVENT */ #ifdef RT_USING_MAILBOX /** - * This function will initialize a mailbox and put it under control of resource - * management. + * @addtogroup mailbox + */ + +/**@{*/ + +/** + * @brief Initialize a static mailbox object. * - * @param mb the mailbox object - * @param name the name of mailbox - * @param msgpool the begin address of buffer to save received mail - * @param size the size of mailbox - * @param flag the flag of mailbox + * @note For the static mailbox object, its memory space is allocated by the compiler during compiling, + * and shall placed on the read-write data segment or on the uninitialized data segment. + * By contrast, the rt_mb_create() function will allocate memory space automatically and initialize the mailbox. * - * @return the operation status, RT_EOK on successful + * @see rt_mb_create() + * + * @param mb is a pointer to the mailbox to initialize. + * It is assumed that storage for the mailbox will be allocated in your application. + * + * @param name is a pointer to the name that given to the mailbox. + * + * @param msgpoll is a pointer to the starting address of the memory space you allocated for the mailbox in advance. + * In other words, msgpoll is a pointer to the mailbox buffer of the starting address. + * + * @param size is the maximum number of mails in the mailbox. + * For example, when the mailbox buffer capacity is N, size is N/4. + * + * @param flag is the mailbox flag, which determines the queuing way of how multiple threads wait + * when the mailbox is not available. + * The mailbox flag can be ONE of the following values: + * + * RT_IPC_FLAG_PRIO The pending threads will queue in order of priority. + * + * RT_IPC_FLAG_FIFO The pending threads will queue in the first-in-first-out method + * (also known as first-come-first-served (FCFS) scheduling strategy). + * + * NOTE: RT_IPC_FLAG_FIFO is a non-real-time scheduling mode. It is strongly recommended to + * use RT_IPC_FLAG_PRIO to ensure the thread is real-time UNLESS your applications concern about + * the first-in-first-out principle, and you clearly understand that all threads involved in + * this mailbox will become non-real-time threads. + * + * @return Return the operation status. When the return value is RT_EOK, the initialization is successful. + * If the return value is any other values, it represents the initialization failed. + * + * @warning This function can ONLY be called from threads. */ rt_err_t rt_mb_init(rt_mailbox_t mb, const char *name, @@ -1410,12 +1797,24 @@ rt_err_t rt_mb_init(rt_mailbox_t mb, } RTM_EXPORT(rt_mb_init); + /** - * This function will detach a mailbox from resource management + * @brief This function will detach a static mailbox object. + * + * @note This function is used to detach a static mailbox object which is initialized by rt_mb_init() function. + * By contrast, the rt_mb_delete() function will delete a mailbox object. + * When the mailbox is successfully detached, it will resume all suspended threads in the mailbox list. * - * @param mb the mailbox object + * @see rt_mb_delete() * - * @return the operation status, RT_EOK on successful + * @param mb is a pointer to a mailbox object to be detached. + * + * @return Return the operation status. When the return value is RT_EOK, the initialization is successful. + * If the return value is any other values, it means that the mailbox detach failed. + * + * @warning This function can ONLY detach a static mailbox initialized by the rt_mb_init() function. + * If the mailbox is created by the rt_mb_create() function, you MUST NOT USE this function to detach it, + * ONLY USE the rt_mb_delete() function to complete the deletion. */ rt_err_t rt_mb_detach(rt_mailbox_t mb) { @@ -1438,13 +1837,35 @@ RTM_EXPORT(rt_mb_detach); #ifdef RT_USING_HEAP /** - * This function will create a mailbox object from system resource + * @brief Creating a mailbox object. + * + * @note For the mailbox object, its memory space is allocated automatically. + * By contrast, the rt_mb_init() function will initialize a static mailbox object. + * + * @see rt_mb_init() * - * @param name the name of mailbox - * @param size the size of mailbox - * @param flag the flag of mailbox + * @param name is a pointer that given to the mailbox. * - * @return the created mailbox, RT_NULL on error happen + * @param size is the maximum number of mails in the mailbox. + * For example, when mailbox buffer capacity is N, size is N/4. + * + * @param flag is the mailbox flag, which determines the queuing way of how multiple threads wait + * when the mailbox is not available. + * The mailbox flag can be ONE of the following values: + * + * RT_IPC_FLAG_PRIO The pending threads will queue in order of priority. + * + * RT_IPC_FLAG_FIFO The pending threads will queue in the first-in-first-out method + * (also known as first-come-first-served (FCFS) scheduling strategy). + * + * NOTE: RT_IPC_FLAG_FIFO is a non-real-time scheduling mode. It is strongly recommended to + * use RT_IPC_FLAG_PRIO to ensure the thread is real-time UNLESS your applications concern about + * the first-in-first-out principle, and you clearly understand that all threads involved in + * this mailbox will become non-real-time threads. + * + * @return Return a pointer to the mailbox object. When the return value is RT_NULL, it means the creation failed. + * + * @warning This function can ONLY be called from threads. */ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag) { @@ -1484,12 +1905,24 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag) } RTM_EXPORT(rt_mb_create); + /** - * This function will delete a mailbox object and release the memory + * @brief This function will delete a mailbox object and release the memory space. + * + * @note This function is used to delete a mailbox object which is created by the rt_mb_create() function. + * By contrast, the rt_mb_detach() function will detach a static mailbox object. + * When the mailbox is successfully deleted, it will resume all suspended threads in the mailbox list. * - * @param mb the mailbox object + * @see rt_mb_detach() * - * @return the error code + * @param mb is a pointer to a mailbox object to be deleted. + * + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the mailbox detach failed. + * + * @warning This function can only delete mailbox created by the rt_mb_create() function. + * If the mailbox is initialized by the rt_mb_init() function, you MUST NOT USE this function to delete it, + * ONLY USE the rt_mb_detach() function to complete the detachment. */ rt_err_t rt_mb_delete(rt_mailbox_t mb) { @@ -1517,15 +1950,29 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb) RTM_EXPORT(rt_mb_delete); #endif /* RT_USING_HEAP */ + /** - * This function will send a mail to mailbox object. If the mailbox is full, - * current thread will be suspended until timeout. + * @brief This function will send an mail to the mailbox object. If there is a thread suspended on the mailbox, + * the thread will be resumed. + * + * @note When using this function to send a mail, if the mailbox if fully used, the current thread will + * wait for a timeout. If the set timeout time is reached and there is still no space available, + * the sending thread will be resumed and an error code will be returned. + * By contrast, the rt_mb_send() function will return an error code immediately without waiting time + * when the mailbox if fully used. + * + * @see rt_mb_send() + * + * @param mb is a pointer to the mailbox object to be sent. + * + * @param value is a value to the content of the mail you want to send. + * + * @param timeout is a timeout period (unit: an OS tick). * - * @param mb the mailbox object - * @param value the mail - * @param timeout the waiting time + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the mailbox detach failed. * - * @return the error code + * @warning This function can be called in interrupt context and thread context. */ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, rt_ubase_t value, @@ -1657,15 +2104,23 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, } RTM_EXPORT(rt_mb_send_wait); + /** - * This function will send a mail to mailbox object, if there are threads - * suspended on mailbox object, it will be waked up. This function will return - * immediately, if you want blocking send, use rt_mb_send_wait instead. + * @brief This function will send an mail to the mailbox object. If there is a thread suspended on the mailbox, + * the thread will be resumed. + * + * @note When using this function to send a mail, if the mailbox is fully used, this function will return an error + * code immediately without waiting time. + * By contrast, the rt_mb_send_wait() function is set a timeout to wait for the mail to be sent. + * + * @see rt_mb_send_wait() + * + * @param mb is a pointer to the mailbox object to be sent. * - * @param mb the mailbox object - * @param value the mail + * @param value is a value to the content of the mail you want to send. * - * @return the error code + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the mailbox detach failed. */ rt_err_t rt_mb_send(rt_mailbox_t mb, rt_ubase_t value) { @@ -1673,15 +2128,22 @@ rt_err_t rt_mb_send(rt_mailbox_t mb, rt_ubase_t value) } RTM_EXPORT(rt_mb_send); + /** - * This function will send an urgent mail to mailbox object, if there are threads - * suspended on mailbox object, it will be waked up. This function will return - * immediately. + * @brief This function will send an urgent mail to the mailbox object. + * + * @note This function is almost the same as the rt_mb_send() function. The only difference is that + * when sending an urgent mail, the mail will be placed at the head of the mail queue so that + * the recipient can receive the urgent mail first. + * + * @see rt_mb_send() + * + * @param mb is a pointer to the mailbox object to be sent. * - * @param mb the mailbox object - * @param value the mail + * @param value is the content of the mail you want to send. * - * @return the error code + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the mailbox detach failed. */ rt_err_t rt_mb_urgent(rt_mailbox_t mb, rt_ubase_t value) { @@ -1738,15 +2200,24 @@ rt_err_t rt_mb_urgent(rt_mailbox_t mb, rt_ubase_t value) } RTM_EXPORT(rt_mb_urgent); + /** - * This function will receive a mail from mailbox object, if there is no mail - * in mailbox object, the thread shall wait for a specified time. + * @brief This function will receive a mail from mailbox object, if there is no mail in mailbox object, + * the thread shall wait for a specified time. + * + * @note Only when there is mail in the mailbox, the receiving thread can get the mail immediately and + * return RT_EOK, otherwise the receiving thread will be suspended until the set timeout. If the mail + * is still not received within the specified time, it will return-RT_ETIMEOUT. + * + * @param mb is a pointer to the mailbox object to be received. + * + * @param value is a flag that you will set for this mailbox's flag. + * You can set an mailbox flag, or you can set multiple flags through OR logic operations. * - * @param mb the mailbox object - * @param value the received mail will be saved in - * @param timeout the waiting time + * @param timeout is a timeout period (unit: an OS tick). * - * @return the error code + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the mailbox release failed. */ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout) { @@ -1879,14 +2350,20 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout) } RTM_EXPORT(rt_mb_recv); + /** - * This function can get or set some extra attributions of a mailbox object. + * @brief This function will set some extra attributions of a mailbox object. + * + * @note Currently this function only supports the RT_IPC_CMD_RESET command to reset the mailbox. + * + * @param mb is a pointer to a mailbox object. + * + * @param cmd is a command used to configure some attributions of the mailbox. * - * @param mb the mailbox object - * @param cmd the execution command - * @param arg the execution argument + * @param arg is the argument of the function to execute the command. * - * @return the error code + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that this function failed to execute. */ rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg) { @@ -1922,26 +2399,64 @@ rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg) return -RT_ERROR; } RTM_EXPORT(rt_mb_control); + +/**@}*/ #endif /* RT_USING_MAILBOX */ #ifdef RT_USING_MESSAGEQUEUE +/** + * @addtogroup messagequeue + */ + +/**@{*/ + struct rt_mq_message { struct rt_mq_message *next; }; + /** - * This function will initialize a message queue and put it under control of - * resource management. + * @brief Initialize a static messagequeue object. + * + * @note For the static messagequeue object, its memory space is allocated by the compiler during compiling, + * and shall placed on the read-write data segment or on the uninitialized data segment. + * By contrast, the rt_mq_create() function will allocate memory space automatically + * and initialize the messagequeue. + * + * @see rt_mq_create() + * + * @param mq is a pointer to the messagequeue to initialize. It is assumed that storage for + * the messagequeue will be allocated in your application. + * + * @param name is a pointer to the name that given to the messagequeue. + * + * @param msgpool is a pointer to the starting address of the memory space you allocated for + * the messagequeue in advance. + * In other words, msgpool is a pointer to the messagequeue buffer of the starting address. + * + * @param msg_size is the maximum length of a message in the messagequeue (Unit: Byte). + * + * @param pool_size is the size of the memory space allocated for the messagequeue in advance. + * + * @param flag is the messagequeue flag, which determines the queuing way of how multiple threads wait + * when the messagequeue is not available. + * The messagequeue flag can be ONE of the following values: + * + * RT_IPC_FLAG_PRIO The pending threads will queue in order of priority. * - * @param mq the message object - * @param name the name of message queue - * @param msgpool the beginning address of buffer to save messages - * @param msg_size the maximum size of message - * @param pool_size the size of buffer to save messages - * @param flag the flag of message queue + * RT_IPC_FLAG_FIFO The pending threads will queue in the first-in-first-out method + * (also known as first-come-first-served (FCFS) scheduling strategy). * - * @return the operation status, RT_EOK on successful + * NOTE: RT_IPC_FLAG_FIFO is a non-real-time scheduling mode. It is strongly recommended to + * use RT_IPC_FLAG_PRIO to ensure the thread is real-time UNLESS your applications concern about + * the first-in-first-out principle, and you clearly understand that all threads involved in + * this messagequeue will become non-real-time threads. + * + * @return Return the operation status. When the return value is RT_EOK, the initialization is successful. + * If the return value is any other values, it represents the initialization failed. + * + * @warning This function can ONLY be called from threads. */ rt_err_t rt_mq_init(rt_mq_t mq, const char *name, @@ -1996,12 +2511,24 @@ rt_err_t rt_mq_init(rt_mq_t mq, } RTM_EXPORT(rt_mq_init); + /** - * This function will detach a message queue object from resource management + * @brief This function will detach a static messagequeue object. + * + * @note This function is used to detach a static messagequeue object which is initialized by rt_mq_init() function. + * By contrast, the rt_mq_delete() function will delete a messagequeue object. + * When the messagequeue is successfully detached, it will resume all suspended threads in the messagequeue list. * - * @param mq the message queue object + * @see rt_mq_delete() * - * @return the operation status, RT_EOK on successful + * @param mq is a pointer to a messagequeue object to be detached. + * + * @return Return the operation status. When the return value is RT_EOK, the initialization is successful. + * If the return value is any other values, it means that the messagequeue detach failed. + * + * @warning This function can ONLY detach a static messagequeue initialized by the rt_mq_init() function. + * If the messagequeue is created by the rt_mq_create() function, you MUST NOT USE this function to detach it, + * and ONLY USE the rt_mq_delete() function to complete the deletion. */ rt_err_t rt_mq_detach(rt_mq_t mq) { @@ -2024,14 +2551,36 @@ RTM_EXPORT(rt_mq_detach); #ifdef RT_USING_HEAP /** - * This function will create a message queue object from system resource + * @brief Creating a messagequeue object. + * + * @note For the messagequeue object, its memory space is allocated automatically. + * By contrast, the rt_mq_init() function will initialize a static messagequeue object. + * + * @see rt_mq_init() * - * @param name the name of message queue - * @param msg_size the size of message - * @param max_msgs the maximum number of message in queue - * @param flag the flag of message queue + * @param name is a pointer that given to the messagequeue. * - * @return the created message queue, RT_NULL on error happen + * @param msg_size is the maximum length of a message in the messagequeue (Unit: Byte). + * + * @param max_msgs is the maximum number of messages in the messagequeue. + * + * @param flag is the messagequeue flag, which determines the queuing way of how multiple threads wait + * when the messagequeue is not available. + * The messagequeue flag can be ONE of the following values: + * + * RT_IPC_FLAG_PRIO The pending threads will queue in order of priority. + * + * RT_IPC_FLAG_FIFO The pending threads will queue in the first-in-first-out method + * (also known as first-come-first-served (FCFS) scheduling strategy). + * + * NOTE: RT_IPC_FLAG_FIFO is a non-real-time scheduling mode. It is strongly recommended to + * use RT_IPC_FLAG_PRIO to ensure the thread is real-time UNLESS your applications concern about + * the first-in-first-out principle, and you clearly understand that all threads involved in + * this messagequeue will become non-real-time threads. + * + * @return Return a pointer to the messagequeue object. When the return value is RT_NULL, it means the creation failed. + * + * @warning This function can NOT be called in interrupt context. You can use macor RT_DEBUG_NOT_IN_INTERRUPT to check it. */ rt_mq_t rt_mq_create(const char *name, rt_size_t msg_size, @@ -2094,12 +2643,25 @@ rt_mq_t rt_mq_create(const char *name, } RTM_EXPORT(rt_mq_create); + /** - * This function will delete a message queue object and release the memory + * @brief This function will delete a messagequeue object and release the memory. * - * @param mq the message queue object + * @note This function is used to delete a messagequeue object which is created by the rt_mq_create() function. + * By contrast, the rt_mq_detach() function will detach a static messagequeue object. + * When the messagequeue is successfully deleted, it will resume all suspended threads in the messagequeue list. * - * @return the error code + * @see rt_mq_detach() + * + * @param mq is a pointer to a messagequeue object to be deleted. + * + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the messagequeue detach failed. + * + * @warning This function can ONLY delete a messagequeue initialized by the rt_mq_create() function. + * If the messagequeue is initialized by the rt_mq_init() function, you MUST NOT USE this function to delete it, + * ONLY USE the rt_mq_detach() function to complete the detachment. + * for example,the rt_mq_create() function, it cannot be called in interrupt context. */ rt_err_t rt_mq_delete(rt_mq_t mq) { @@ -2126,16 +2688,35 @@ rt_err_t rt_mq_delete(rt_mq_t mq) RTM_EXPORT(rt_mq_delete); #endif /* RT_USING_HEAP */ + /** - * This function will send a message to message queue object. If the message queue is full, - * current thread will be suspended until timeout. + * @brief This function will send a message to the messagequeue object. If + * there is a thread suspended on the messagequeue, the thread will be + * resumed. + * + * @note When using this function to send a message, if the messagequeue is + * fully used, the current thread will wait for a timeout. If reaching + * the timeout and there is still no space available, the sending + * thread will be resumed and an error code will be returned. By + * contrast, the rt_mq_send() function will return an error code + * immediately without waiting when the messagequeue if fully used. + * + * @see rt_mq_send() + * + * @param mq is a pointer to the messagequeue object to be sent. + * + * @param buffer is the content of the message. * - * @param mq the message queue object - * @param buffer the message - * @param size the size of buffer - * @param timeout the waiting time + * @param size is the length of the message(Unit: Byte). * - * @return the error code + * @param timeout is a timeout period (unit: an OS tick). + * + * @return Return the operation status. When the return value is RT_EOK, the + * operation is successful. If the return value is any other values, + * it means that the messagequeue detach failed. + * + * @warning This function can be called in interrupt context and thread + * context. */ rt_err_t rt_mq_send_wait(rt_mq_t mq, const void *buffer, @@ -2298,15 +2879,28 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq, } RTM_EXPORT(rt_mq_send_wait) + /** - * This function will send a message to message queue object, if there are - * threads suspended on message queue object, it will be waked up. + * @brief This function will send a message to the messagequeue object. + * If there is a thread suspended on the messagequeue, the thread will be resumed. + * + * @note When using this function to send a message, if the messagequeue is fully used, + * the current thread will wait for a timeout. + * By contrast, when the messagequeue is fully used, the rt_mq_send_wait() function will + * return an error code immediately without waiting. + * + * @see rt_mq_send_wait() + * + * @param mq is a pointer to the messagequeue object to be sent. + * + * @param buffer is the content of the message. + * + * @param size is the length of the message(Unit: Byte). * - * @param mq the message queue object - * @param buffer the message - * @param size the size of buffer + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the messagequeue detach failed. * - * @return the error code + * @warning This function can be called in interrupt context and thread context. */ rt_err_t rt_mq_send(rt_mq_t mq, const void *buffer, rt_size_t size) { @@ -2314,16 +2908,24 @@ rt_err_t rt_mq_send(rt_mq_t mq, const void *buffer, rt_size_t size) } RTM_EXPORT(rt_mq_send); + /** - * This function will send an urgent message to message queue object, which - * means the message will be inserted to the head of message queue. If there - * are threads suspended on message queue object, it will be waked up. + * @brief This function will send an urgent message to the messagequeue object. + * + * @note This function is almost the same as the rt_mq_send() function. The only difference is that + * when sending an urgent message, the message is placed at the head of the messagequeue so that + * the recipient can receive the urgent message first. + * + * @see rt_mq_send() + * + * @param mq is a pointer to the messagequeue object to be sent. * - * @param mq the message queue object - * @param buffer the message - * @param size the size of buffer + * @param buffer is the content of the message. * - * @return the error code + * @param size is the length of the message(Unit: Byte). + * + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the mailbox detach failed. */ rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size) { @@ -2406,17 +3008,25 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size) } RTM_EXPORT(rt_mq_urgent); + /** - * This function will receive a message from message queue object, if there is - * no message in message queue object, the thread shall wait for a specified - * time. + * @brief This function will receive a message from message queue object, + * if there is no message in messagequeue object, the thread shall wait for a specified time. + * + * @note Only when there is mail in the mailbox, the receiving thread can get the mail immediately and return RT_EOK, + * otherwise the receiving thread will be suspended until timeout. + * If the mail is not received within the specified time, it will return -RT_ETIMEOUT. + * + * @param mq is a pointer to the messagequeue object to be received. * - * @param mq the message queue object - * @param buffer the received message will be saved in - * @param size the size of buffer - * @param timeout the waiting time + * @param buffer is the content of the message. * - * @return the error code + * @param size is the length of the message(Unit: Byte). + * + * @param timeout is a timeout period (unit: an OS tick). + * + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the mailbox release failed. */ rt_err_t rt_mq_recv(rt_mq_t mq, void *buffer, @@ -2568,15 +3178,20 @@ rt_err_t rt_mq_recv(rt_mq_t mq, } RTM_EXPORT(rt_mq_recv); + /** - * This function can get or set some extra attributions of a message queue - * object. + * @brief This function will set some extra attributions of a messagequeue object. + * + * @note Currently this function only supports the RT_IPC_CMD_RESET command to reset the messagequeue. * - * @param mq the message queue object - * @param cmd the execution command - * @param arg the execution argument + * @param mq is a pointer to a messagequeue object. * - * @return the error code + * @param cmd is a command used to configure some attributions of the messagequeue. + * + * @param arg is the argument of the function to execute the command. + * + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that this function failed to execute. */ rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg) { @@ -2628,6 +3243,8 @@ rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg) return -RT_ERROR; } RTM_EXPORT(rt_mq_control); + +/**@}*/ #endif /* RT_USING_MESSAGEQUEUE */ /**@}*/ -- cgit v1.3.1 From c0e48f0417e21c5300d0ac8b7a696f989145a7e1 Mon Sep 17 00:00:00 2001 From: xukai Date: Fri, 9 Jul 2021 17:37:46 +0800 Subject: [components][kernel] 解决多核下 finsh 不能响应串口输入问题 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kservice.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src') diff --git a/src/kservice.c b/src/kservice.c index 49e1486078..128a9f4f54 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -1176,11 +1176,7 @@ void rt_kputs(const char *str) } else { - rt_uint16_t old_flag = _console_device->open_flag; - - _console_device->open_flag |= RT_DEVICE_FLAG_STREAM; rt_device_write(_console_device, 0, str, rt_strlen(str)); - _console_device->open_flag = old_flag; } #else rt_hw_console_output(str); @@ -1214,11 +1210,7 @@ RT_WEAK void rt_kprintf(const char *fmt, ...) } else { - rt_uint16_t old_flag = _console_device->open_flag; - - _console_device->open_flag |= RT_DEVICE_FLAG_STREAM; rt_device_write(_console_device, 0, rt_log_buf, length); - _console_device->open_flag = old_flag; } #else rt_hw_console_output(rt_log_buf); -- cgit v1.3.1 From f33c89ce5aed94bf143f7f4d0bd7e1e743176f06 Mon Sep 17 00:00:00 2001 From: liuduanfei <939763442@qq.com> Date: Wed, 14 Jul 2021 07:02:56 +0000 Subject: 64位模式下 默认支持 RT_PRINTF_LONGLONG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kservice.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/kservice.c b/src/kservice.c index e9972dba97..dfb37dd888 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -30,6 +30,10 @@ /* use precision */ #define RT_PRINTF_PRECISION +#ifdef ARCH_CPU_64BIT + #define RT_PRINTF_LONGLONG +#endif + /** * @addtogroup KernelService */ -- cgit v1.3.1 From 1d276ac4b32f53899a60aff8d0406143177fe17e Mon Sep 17 00:00:00 2001 From: liuduanfei <939763442@qq.com> Date: Thu, 15 Jul 2021 08:28:30 +0000 Subject: 清除 kservice.c 中对 RT_PRINTF_LONGLONG 的支持 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kservice.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/kservice.c b/src/kservice.c index dfb37dd888..e9972dba97 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -30,10 +30,6 @@ /* use precision */ #define RT_PRINTF_PRECISION -#ifdef ARCH_CPU_64BIT - #define RT_PRINTF_LONGLONG -#endif - /** * @addtogroup KernelService */ -- cgit v1.3.1 From 4e40129e57f8c507514fc981fa742820a1a08e8a Mon Sep 17 00:00:00 2001 From: liuduanfei <939763442@qq.com> Date: Thu, 15 Jul 2021 08:30:17 +0000 Subject: Kconfig 中添加 RT_PRINTF_LONGLONG 的选择,默认不选择 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/Kconfig b/src/Kconfig index 6afb719395..a1b0ff9a17 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -347,6 +347,10 @@ menu "Kernel Device Object" config RT_CONSOLE_DEVICE_NAME string "the device name for console" default "uart" + + config RT_PRINTF_LONGLONG + bool "rt_kprintf support long long" + default n endif endmenu -- cgit v1.3.1 From b339b5cf330cb4ca880a204389b851a7d23f99a6 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 3 Aug 2021 10:55:16 +0800 Subject: [src][Kconfig] 增加隐性RT_USING_ASM_MEMCPY定义 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Kconfig | 4 ++++ src/kservice.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Kconfig b/src/Kconfig index a987daab46..71abd9cf4f 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -131,6 +131,10 @@ config RT_KSERVICE_USING_TINY_SIZE bool "Enable kservice to use tiny size" default n +config RT_USING_ASM_MEMCPY + bool + default n + endmenu menuconfig RT_DEBUG diff --git a/src/kservice.c b/src/kservice.c index 128a9f4f54..91872492fb 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -198,6 +198,7 @@ RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count) } RTM_EXPORT(rt_memset); +#ifndef RT_USING_ASM_MEMCPY /** * This function will copy memory content from source address to destination * address. @@ -208,7 +209,7 @@ RTM_EXPORT(rt_memset); * * @return the address of destination memory */ -RT_WEAK void *rt_memcpy(void *dst, const void *src, rt_ubase_t count) +void *rt_memcpy(void *dst, const void *src, rt_ubase_t count) { #ifdef RT_KSERVICE_USING_TINY_SIZE char *tmp = (char *)dst, *s = (char *)src; @@ -280,6 +281,7 @@ RT_WEAK void *rt_memcpy(void *dst, const void *src, rt_ubase_t count) #endif /* RT_KSERVICE_USING_TINY_SIZE */ } RTM_EXPORT(rt_memcpy); +#endif /* RT_USING_ASM_MEMCPY */ #ifndef RT_KSERVICE_USING_STDLIB -- cgit v1.3.1 From c10678c1f0968a1ce9f5af1eb051b39f3bb2c1d6 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 13 Jul 2021 13:20:36 +0800 Subject: 内部函数以_开头 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/idle.c | 4 +-- src/ipc.c | 102 ++++++++++++++++++++++++++++---------------------------- src/scheduler.c | 14 ++++---- 3 files changed, 60 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/idle.c b/src/idle.c index a6efad5628..81ac7e30dd 100644 --- a/src/idle.c +++ b/src/idle.c @@ -129,7 +129,7 @@ rt_err_t rt_thread_idle_delhook(void (*hook)(void)) #ifdef RT_USING_HEAP /* Return whether there is defunctional thread to be deleted. */ -rt_inline int _rt_has_defunct_thread(void) +rt_inline int _idle_has_defunct_thread(void) { /* The rt_list_isempty has prototype of "int rt_list_isempty(const rt_list_t *l)". * So the compiler has a good reason that the rt_thread_defunct list does @@ -165,7 +165,7 @@ void rt_thread_idle_excute(void) lock = rt_hw_interrupt_disable(); /* check whether list is empty */ - if (!_rt_has_defunct_thread()) + if (!_idle_has_defunct_thread()) { rt_hw_interrupt_enable(lock); break; diff --git a/src/ipc.c b/src/ipc.c index d57aa64d59..30ed44de56 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -63,7 +63,7 @@ extern void (*rt_object_put_hook)(struct rt_object *object); * * @return the operation status, RT_EOK on successful */ -rt_inline rt_err_t _rt_ipc_object_init(struct rt_ipc_object *ipc) +rt_inline rt_err_t _ipc_object_init(struct rt_ipc_object *ipc) { /* initialize ipc object */ rt_list_init(&(ipc->suspend_thread)); @@ -82,9 +82,9 @@ rt_inline rt_err_t _rt_ipc_object_init(struct rt_ipc_object *ipc) * * @return the operation status, RT_EOK on successful */ -rt_inline rt_err_t _rt_ipc_list_suspend(rt_list_t *list, - struct rt_thread *thread, - rt_uint8_t flag) +rt_inline rt_err_t _ipc_list_suspend(rt_list_t *list, + struct rt_thread *thread, + rt_uint8_t flag) { /* suspend thread */ rt_thread_suspend(thread); @@ -140,7 +140,7 @@ rt_inline rt_err_t _rt_ipc_list_suspend(rt_list_t *list, * * @return the operation status, RT_EOK on successful */ -rt_inline rt_err_t _rt_ipc_list_resume(rt_list_t *list) +rt_inline rt_err_t _ipc_list_resume(rt_list_t *list) { struct rt_thread *thread; @@ -163,7 +163,7 @@ rt_inline rt_err_t _rt_ipc_list_resume(rt_list_t *list) * * @return the operation status, RT_EOK on successful */ -rt_inline rt_err_t _rt_ipc_list_resume_all(rt_list_t *list) +rt_inline rt_err_t _ipc_list_resume_all(rt_list_t *list) { struct rt_thread *thread; register rt_ubase_t temp; @@ -217,7 +217,7 @@ rt_err_t rt_sem_init(rt_sem_t sem, rt_object_init(&(sem->parent.parent), RT_Object_Class_Semaphore, name); /* initialize ipc object */ - _rt_ipc_object_init(&(sem->parent)); + _ipc_object_init(&(sem->parent)); /* set initial value */ sem->value = (rt_uint16_t)value; @@ -246,7 +246,7 @@ rt_err_t rt_sem_detach(rt_sem_t sem) RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent)); /* wakeup all suspended threads */ - _rt_ipc_list_resume_all(&(sem->parent.suspend_thread)); + _ipc_list_resume_all(&(sem->parent.suspend_thread)); /* detach semaphore object */ rt_object_detach(&(sem->parent.parent)); @@ -280,7 +280,7 @@ rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag) return sem; /* initialize ipc object */ - _rt_ipc_object_init(&(sem->parent)); + _ipc_object_init(&(sem->parent)); /* set initial value */ sem->value = value; @@ -311,7 +311,7 @@ rt_err_t rt_sem_delete(rt_sem_t sem) RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent) == RT_FALSE); /* wakeup all suspended threads */ - _rt_ipc_list_resume_all(&(sem->parent.suspend_thread)); + _ipc_list_resume_all(&(sem->parent.suspend_thread)); /* delete semaphore object */ rt_object_delete(&(sem->parent.parent)); @@ -382,7 +382,7 @@ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time) thread->name)); /* suspend thread */ - _rt_ipc_list_suspend(&(sem->parent.suspend_thread), + _ipc_list_suspend(&(sem->parent.suspend_thread), thread, sem->parent.parent.flag); @@ -463,7 +463,7 @@ rt_err_t rt_sem_release(rt_sem_t sem) if (!rt_list_isempty(&sem->parent.suspend_thread)) { /* resume the suspended thread */ - _rt_ipc_list_resume(&(sem->parent.suspend_thread)); + _ipc_list_resume(&(sem->parent.suspend_thread)); need_schedule = RT_TRUE; } else @@ -517,7 +517,7 @@ rt_err_t rt_sem_control(rt_sem_t sem, int cmd, void *arg) level = rt_hw_interrupt_disable(); /* resume all waiting thread */ - _rt_ipc_list_resume_all(&sem->parent.suspend_thread); + _ipc_list_resume_all(&sem->parent.suspend_thread); /* set new value */ sem->value = (rt_uint16_t)value; @@ -555,7 +555,7 @@ rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag) rt_object_init(&(mutex->parent.parent), RT_Object_Class_Mutex, name); /* initialize ipc object */ - _rt_ipc_object_init(&(mutex->parent)); + _ipc_object_init(&(mutex->parent)); mutex->value = 1; mutex->owner = RT_NULL; @@ -586,7 +586,7 @@ rt_err_t rt_mutex_detach(rt_mutex_t mutex) RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent)); /* wakeup all suspended threads */ - _rt_ipc_list_resume_all(&(mutex->parent.suspend_thread)); + _ipc_list_resume_all(&(mutex->parent.suspend_thread)); /* detach semaphore object */ rt_object_detach(&(mutex->parent.parent)); @@ -618,7 +618,7 @@ rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag) return mutex; /* initialize ipc object */ - _rt_ipc_object_init(&(mutex->parent)); + _ipc_object_init(&(mutex->parent)); mutex->value = 1; mutex->owner = RT_NULL; @@ -651,7 +651,7 @@ rt_err_t rt_mutex_delete(rt_mutex_t mutex) RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent) == RT_FALSE); /* wakeup all suspended threads */ - _rt_ipc_list_resume_all(&(mutex->parent.suspend_thread)); + _ipc_list_resume_all(&(mutex->parent.suspend_thread)); /* delete mutex object */ rt_object_delete(&(mutex->parent.parent)); @@ -765,7 +765,7 @@ __again: } /* suspend current thread */ - _rt_ipc_list_suspend(&(mutex->parent.suspend_thread), + _ipc_list_suspend(&(mutex->parent.suspend_thread), thread, mutex->parent.parent.flag); @@ -916,7 +916,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) } /* resume thread */ - _rt_ipc_list_resume(&(mutex->parent.suspend_thread)); + _ipc_list_resume(&(mutex->parent.suspend_thread)); need_schedule = RT_TRUE; } @@ -993,7 +993,7 @@ rt_err_t rt_event_init(rt_event_t event, const char *name, rt_uint8_t flag) event->parent.parent.flag = flag; /* initialize ipc object */ - _rt_ipc_object_init(&(event->parent)); + _ipc_object_init(&(event->parent)); /* initialize event */ event->set = 0; @@ -1017,7 +1017,7 @@ rt_err_t rt_event_detach(rt_event_t event) RT_ASSERT(rt_object_is_systemobject(&event->parent.parent)); /* resume all suspended thread */ - _rt_ipc_list_resume_all(&(event->parent.suspend_thread)); + _ipc_list_resume_all(&(event->parent.suspend_thread)); /* detach event object */ rt_object_detach(&(event->parent.parent)); @@ -1050,7 +1050,7 @@ rt_event_t rt_event_create(const char *name, rt_uint8_t flag) event->parent.parent.flag = flag; /* initialize ipc object */ - _rt_ipc_object_init(&(event->parent)); + _ipc_object_init(&(event->parent)); /* initialize event */ event->set = 0; @@ -1076,7 +1076,7 @@ rt_err_t rt_event_delete(rt_event_t event) RT_DEBUG_NOT_IN_INTERRUPT; /* resume all suspended thread */ - _rt_ipc_list_resume_all(&(event->parent.suspend_thread)); + _ipc_list_resume_all(&(event->parent.suspend_thread)); /* delete event object */ rt_object_delete(&(event->parent.parent)); @@ -1279,7 +1279,7 @@ rt_err_t rt_event_recv(rt_event_t event, thread->event_info = option; /* put thread to suspended thread list */ - _rt_ipc_list_suspend(&(event->parent.suspend_thread), + _ipc_list_suspend(&(event->parent.suspend_thread), thread, event->parent.parent.flag); @@ -1345,7 +1345,7 @@ rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg) level = rt_hw_interrupt_disable(); /* resume all waiting thread */ - _rt_ipc_list_resume_all(&event->parent.suspend_thread); + _ipc_list_resume_all(&event->parent.suspend_thread); /* initialize event set */ event->set = 0; @@ -1391,7 +1391,7 @@ rt_err_t rt_mb_init(rt_mailbox_t mb, mb->parent.parent.flag = flag; /* initialize ipc object */ - _rt_ipc_object_init(&(mb->parent)); + _ipc_object_init(&(mb->parent)); /* initialize mailbox */ mb->msg_pool = (rt_ubase_t *)msgpool; @@ -1422,9 +1422,9 @@ rt_err_t rt_mb_detach(rt_mailbox_t mb) RT_ASSERT(rt_object_is_systemobject(&mb->parent.parent)); /* resume all suspended thread */ - _rt_ipc_list_resume_all(&(mb->parent.suspend_thread)); + _ipc_list_resume_all(&(mb->parent.suspend_thread)); /* also resume all mailbox private suspended thread */ - _rt_ipc_list_resume_all(&(mb->suspend_sender_thread)); + _ipc_list_resume_all(&(mb->suspend_sender_thread)); /* detach mailbox object */ rt_object_detach(&(mb->parent.parent)); @@ -1458,7 +1458,7 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag) mb->parent.parent.flag = flag; /* initialize ipc object */ - _rt_ipc_object_init(&(mb->parent)); + _ipc_object_init(&(mb->parent)); /* initialize mailbox */ mb->size = size; @@ -1498,10 +1498,10 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb) RT_ASSERT(rt_object_is_systemobject(&mb->parent.parent) == RT_FALSE); /* resume all suspended thread */ - _rt_ipc_list_resume_all(&(mb->parent.suspend_thread)); + _ipc_list_resume_all(&(mb->parent.suspend_thread)); /* also resume all mailbox private suspended thread */ - _rt_ipc_list_resume_all(&(mb->suspend_sender_thread)); + _ipc_list_resume_all(&(mb->suspend_sender_thread)); /* free mailbox pool */ RT_KERNEL_FREE(mb->msg_pool); @@ -1570,7 +1570,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, RT_DEBUG_IN_THREAD_CONTEXT; /* suspend current thread */ - _rt_ipc_list_suspend(&(mb->suspend_sender_thread), + _ipc_list_suspend(&(mb->suspend_sender_thread), thread, mb->parent.parent.flag); @@ -1637,7 +1637,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, /* resume suspended thread */ if (!rt_list_isempty(&mb->parent.suspend_thread)) { - _rt_ipc_list_resume(&(mb->parent.suspend_thread)); + _ipc_list_resume(&(mb->parent.suspend_thread)); /* enable interrupt */ rt_hw_interrupt_enable(temp); @@ -1718,7 +1718,7 @@ rt_err_t rt_mb_urgent(rt_mailbox_t mb, rt_ubase_t value) /* resume suspended thread */ if (!rt_list_isempty(&mb->parent.suspend_thread)) { - _rt_ipc_list_resume(&(mb->parent.suspend_thread)); + _ipc_list_resume(&(mb->parent.suspend_thread)); /* enable interrupt */ rt_hw_interrupt_enable(temp); @@ -1792,7 +1792,7 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout) RT_DEBUG_IN_THREAD_CONTEXT; /* suspend current thread */ - _rt_ipc_list_suspend(&(mb->parent.suspend_thread), + _ipc_list_suspend(&(mb->parent.suspend_thread), thread, mb->parent.parent.flag); @@ -1855,7 +1855,7 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout) /* resume suspended thread */ if (!rt_list_isempty(&(mb->suspend_sender_thread))) { - _rt_ipc_list_resume(&(mb->suspend_sender_thread)); + _ipc_list_resume(&(mb->suspend_sender_thread)); /* enable interrupt */ rt_hw_interrupt_enable(temp); @@ -1899,9 +1899,9 @@ rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg) level = rt_hw_interrupt_disable(); /* resume all waiting thread */ - _rt_ipc_list_resume_all(&(mb->parent.suspend_thread)); + _ipc_list_resume_all(&(mb->parent.suspend_thread)); /* also resume all mailbox private suspended thread */ - _rt_ipc_list_resume_all(&(mb->suspend_sender_thread)); + _ipc_list_resume_all(&(mb->suspend_sender_thread)); /* re-init mailbox */ mb->entry = 0; @@ -1960,7 +1960,7 @@ rt_err_t rt_mq_init(rt_mq_t mq, mq->parent.parent.flag = flag; /* initialize ipc object */ - _rt_ipc_object_init(&(mq->parent)); + _ipc_object_init(&(mq->parent)); /* set message pool */ mq->msg_pool = msgpool; @@ -2008,9 +2008,9 @@ rt_err_t rt_mq_detach(rt_mq_t mq) RT_ASSERT(rt_object_is_systemobject(&mq->parent.parent)); /* resume all suspended thread */ - _rt_ipc_list_resume_all(&mq->parent.suspend_thread); + _ipc_list_resume_all(&mq->parent.suspend_thread); /* also resume all message queue private suspended thread */ - _rt_ipc_list_resume_all(&(mq->suspend_sender_thread)); + _ipc_list_resume_all(&(mq->suspend_sender_thread)); /* detach message queue object */ rt_object_detach(&(mq->parent.parent)); @@ -2050,7 +2050,7 @@ rt_mq_t rt_mq_create(const char *name, mq->parent.parent.flag = flag; /* initialize ipc object */ - _rt_ipc_object_init(&(mq->parent)); + _ipc_object_init(&(mq->parent)); /* initialize message queue */ @@ -2108,9 +2108,9 @@ rt_err_t rt_mq_delete(rt_mq_t mq) RT_ASSERT(rt_object_is_systemobject(&mq->parent.parent) == RT_FALSE); /* resume all suspended thread */ - _rt_ipc_list_resume_all(&(mq->parent.suspend_thread)); + _ipc_list_resume_all(&(mq->parent.suspend_thread)); /* also resume all message queue private suspended thread */ - _rt_ipc_list_resume_all(&(mq->suspend_sender_thread)); + _ipc_list_resume_all(&(mq->suspend_sender_thread)); /* free message queue pool */ RT_KERNEL_FREE(mq->msg_pool); @@ -2192,7 +2192,7 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq, RT_DEBUG_IN_THREAD_CONTEXT; /* suspend current thread */ - _rt_ipc_list_suspend(&(mq->suspend_sender_thread), + _ipc_list_suspend(&(mq->suspend_sender_thread), thread, mq->parent.parent.flag); @@ -2278,7 +2278,7 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq, /* resume suspended thread */ if (!rt_list_isempty(&mq->parent.suspend_thread)) { - _rt_ipc_list_resume(&(mq->parent.suspend_thread)); + _ipc_list_resume(&(mq->parent.suspend_thread)); /* enable interrupt */ rt_hw_interrupt_enable(temp); @@ -2386,7 +2386,7 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size) /* resume suspended thread */ if (!rt_list_isempty(&mq->parent.suspend_thread)) { - _rt_ipc_list_resume(&(mq->parent.suspend_thread)); + _ipc_list_resume(&(mq->parent.suspend_thread)); /* enable interrupt */ rt_hw_interrupt_enable(temp); @@ -2468,7 +2468,7 @@ rt_err_t rt_mq_recv(rt_mq_t mq, } /* suspend current thread */ - _rt_ipc_list_suspend(&(mq->parent.suspend_thread), + _ipc_list_suspend(&(mq->parent.suspend_thread), thread, mq->parent.parent.flag); @@ -2544,7 +2544,7 @@ rt_err_t rt_mq_recv(rt_mq_t mq, /* resume suspended thread */ if (!rt_list_isempty(&(mq->suspend_sender_thread))) { - _rt_ipc_list_resume(&(mq->suspend_sender_thread)); + _ipc_list_resume(&(mq->suspend_sender_thread)); /* enable interrupt */ rt_hw_interrupt_enable(temp); @@ -2590,9 +2590,9 @@ rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg) level = rt_hw_interrupt_disable(); /* resume all waiting thread */ - _rt_ipc_list_resume_all(&mq->parent.suspend_thread); + _ipc_list_resume_all(&mq->parent.suspend_thread); /* also resume all message queue private suspended thread */ - _rt_ipc_list_resume_all(&(mq->suspend_sender_thread)); + _ipc_list_resume_all(&(mq->suspend_sender_thread)); /* release all message in the queue */ while (mq->msg_queue_head != RT_NULL) diff --git a/src/scheduler.c b/src/scheduler.c index 179ad85e07..8849d7f3ec 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -23,7 +23,7 @@ * 2013-12-21 Grissiom add rt_critical_level * 2018-11-22 Jesven remove the current task from ready queue * add per cpu ready queue - * add _rt_get_highest_priority_thread to find highest priority task + * add _scheduler_get_highest_priority_thread to find highest priority task * rt_schedule_insert_thread won't insert current task to ready queue * in smp version, rt_hw_context_switch_interrupt maybe switch to * new task directly @@ -114,7 +114,7 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread) * get the highest priority thread in ready queue */ #ifdef RT_USING_SMP -static struct rt_thread* _rt_get_highest_priority_thread(rt_ubase_t *highest_prio) +static struct rt_thread* _scheduler_get_highest_priority_thread(rt_ubase_t *highest_prio) { register struct rt_thread *highest_priority_thread; register rt_ubase_t highest_ready_priority, local_highest_ready_priority; @@ -150,7 +150,7 @@ static struct rt_thread* _rt_get_highest_priority_thread(rt_ubase_t *highest_pri return highest_priority_thread; } #else -static struct rt_thread* _rt_get_highest_priority_thread(rt_ubase_t *highest_prio) +static struct rt_thread* _scheduler_get_highest_priority_thread(rt_ubase_t *highest_prio) { register struct rt_thread *highest_priority_thread; register rt_ubase_t highest_ready_priority; @@ -239,7 +239,7 @@ void rt_system_scheduler_start(void) register struct rt_thread *to_thread; rt_ubase_t highest_ready_priority; - to_thread = _rt_get_highest_priority_thread(&highest_ready_priority); + to_thread = _scheduler_get_highest_priority_thread(&highest_ready_priority); #ifdef RT_USING_SMP to_thread->oncpu = rt_hw_cpu_id(); @@ -327,7 +327,7 @@ void rt_schedule(void) if (rt_thread_ready_priority_group != 0 || pcpu->priority_group != 0) { - to_thread = _rt_get_highest_priority_thread(&highest_ready_priority); + to_thread = _scheduler_get_highest_priority_thread(&highest_ready_priority); current_thread->oncpu = RT_CPU_DETACHED; if ((current_thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_RUNNING) { @@ -425,7 +425,7 @@ void rt_schedule(void) /* need_insert_from_thread: need to insert from_thread to ready queue */ int need_insert_from_thread = 0; - to_thread = _rt_get_highest_priority_thread(&highest_ready_priority); + to_thread = _scheduler_get_highest_priority_thread(&highest_ready_priority); if ((rt_current_thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_RUNNING) { @@ -576,7 +576,7 @@ void rt_scheduler_do_irq_switch(void *context) if (rt_thread_ready_priority_group != 0 || pcpu->priority_group != 0) { - to_thread = _rt_get_highest_priority_thread(&highest_ready_priority); + to_thread = _scheduler_get_highest_priority_thread(&highest_ready_priority); current_thread->oncpu = RT_CPU_DETACHED; if ((current_thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_RUNNING) { -- cgit v1.3.1 From 67f2f323a2d7bfa7ba8efbd291691c12269088a2 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Fri, 6 Aug 2021 02:56:42 +0800 Subject: [kernel] 规范内部函数命名 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cpu.c | 18 +++++++++--------- src/object.c | 9 +++++---- src/signal.c | 8 ++++---- src/thread.c | 48 ++++++++++++++++++++++++------------------------ 4 files changed, 42 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/cpu.c b/src/cpu.c index a7d56ba999..fc1fed5a06 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -11,13 +11,13 @@ #include #ifdef RT_USING_SMP -static struct rt_cpu rt_cpus[RT_CPUS_NR]; +static struct rt_cpu _cpus[RT_CPUS_NR]; rt_hw_spinlock_t _cpus_lock; /* * disable scheduler */ -static void rt_preempt_disable(void) +static void _cpu_preempt_disable(void) { register rt_base_t level; struct rt_thread *current_thread; @@ -42,7 +42,7 @@ static void rt_preempt_disable(void) /* * enable scheduler */ -static void rt_preempt_enable(void) +static void _cpu_preempt_enable(void) { register rt_base_t level; struct rt_thread *current_thread; @@ -73,7 +73,7 @@ RTM_EXPORT(rt_spin_lock_init) void rt_spin_lock(struct rt_spinlock *lock) { - rt_preempt_disable(); + _cpu_preempt_disable(); rt_hw_spin_lock(&lock->lock); } RTM_EXPORT(rt_spin_lock) @@ -81,7 +81,7 @@ RTM_EXPORT(rt_spin_lock) void rt_spin_unlock(struct rt_spinlock *lock) { rt_hw_spin_unlock(&lock->lock); - rt_preempt_enable(); + _cpu_preempt_enable(); } RTM_EXPORT(rt_spin_unlock) @@ -89,7 +89,7 @@ rt_base_t rt_spin_lock_irqsave(struct rt_spinlock *lock) { unsigned long level; - rt_preempt_disable(); + _cpu_preempt_disable(); level = rt_hw_local_irq_disable(); rt_hw_spin_lock(&lock->lock); @@ -103,7 +103,7 @@ void rt_spin_unlock_irqrestore(struct rt_spinlock *lock, rt_base_t level) rt_hw_spin_unlock(&lock->lock); rt_hw_local_irq_enable(level); - rt_preempt_enable(); + _cpu_preempt_enable(); } RTM_EXPORT(rt_spin_unlock_irqrestore) @@ -112,12 +112,12 @@ RTM_EXPORT(rt_spin_unlock_irqrestore) */ struct rt_cpu *rt_cpu_self(void) { - return &rt_cpus[rt_hw_cpu_id()]; + return &_cpus[rt_hw_cpu_id()]; } struct rt_cpu *rt_cpu_index(int index) { - return &rt_cpus[index]; + return &_cpus[index]; } /** diff --git a/src/object.c b/src/object.c index ff96037c52..718b0aa5b2 100644 --- a/src/object.c +++ b/src/object.c @@ -23,7 +23,7 @@ #endif /* RT_USING_MODULE */ /* - * define object_info for the number of rt_object_container items. + * define object_info for the number of _object_container items. */ enum rt_object_info_type { @@ -60,8 +60,9 @@ enum rt_object_info_type }; #define _OBJ_CONTAINER_LIST_INIT(c) \ - {&(rt_object_container[c].object_list), &(rt_object_container[c].object_list)} -static struct rt_object_information rt_object_container[RT_Object_Info_Unknown] = + {&(_object_container[c].object_list), &(_object_container[c].object_list)} + +static struct rt_object_information _object_container[RT_Object_Info_Unknown] = { /* initialize object container - thread */ {RT_Object_Class_Thread, _OBJ_CONTAINER_LIST_INIT(RT_Object_Info_Thread), sizeof(struct rt_thread)}, @@ -211,7 +212,7 @@ rt_object_get_information(enum rt_object_class_type type) int index; for (index = 0; index < RT_Object_Info_Unknown; index ++) - if (rt_object_container[index].type == type) return &rt_object_container[index]; + if (_object_container[index].type == type) return &_object_container[index]; return RT_NULL; } diff --git a/src/signal.c b/src/signal.c index bb7706d9ef..c5ae2a709a 100644 --- a/src/signal.c +++ b/src/signal.c @@ -35,7 +35,7 @@ struct siginfo_node struct rt_slist_node list; }; -static struct rt_mempool *_rt_siginfo_pool; +static struct rt_mempool *_siginfo_pool; static void _signal_deliver(rt_thread_t tid); void rt_thread_handle_sig(rt_bool_t clean_state); @@ -538,7 +538,7 @@ int rt_thread_kill(rt_thread_t tid, int sig) } rt_hw_interrupt_enable(level); - si_node = (struct siginfo_node *) rt_mp_alloc(_rt_siginfo_pool, 0); + si_node = (struct siginfo_node *) rt_mp_alloc(_siginfo_pool, 0); if (si_node) { rt_slist_init(&(si_node->list)); @@ -576,8 +576,8 @@ int rt_thread_kill(rt_thread_t tid, int sig) int rt_system_signal_init(void) { - _rt_siginfo_pool = rt_mp_create("signal", RT_SIG_INFO_MAX, sizeof(struct siginfo_node)); - if (_rt_siginfo_pool == RT_NULL) + _siginfo_pool = rt_mp_create("signal", RT_SIG_INFO_MAX, sizeof(struct siginfo_node)); + if (_siginfo_pool == RT_NULL) { LOG_E("create memory pool for signal info failed."); RT_ASSERT(0); diff --git a/src/thread.c b/src/thread.c index 60e6ab91d1..7e0c10bfef 100644 --- a/src/thread.c +++ b/src/thread.c @@ -77,7 +77,7 @@ void rt_thread_inited_sethook(void (*hook)(rt_thread_t thread)) #endif /* RT_USING_HOOK */ /* must be invoke witch rt_hw_interrupt_disable */ -static void _rt_thread_cleanup_execute(rt_thread_t thread) +static void _thread_cleanup_execute(rt_thread_t thread) { register rt_base_t level; #ifdef RT_USING_MODULE @@ -101,7 +101,7 @@ static void _rt_thread_cleanup_execute(rt_thread_t thread) rt_hw_interrupt_enable(level); } -static void _rt_thread_exit(void) +static void _thread_exit(void) { struct rt_thread *thread; register rt_base_t level; @@ -112,7 +112,7 @@ static void _rt_thread_exit(void) /* disable interrupt */ level = rt_hw_interrupt_disable(); - _rt_thread_cleanup_execute(thread); + _thread_cleanup_execute(thread); /* remove from schedule */ rt_schedule_remove_thread(thread); @@ -139,14 +139,14 @@ static void _rt_thread_exit(void) rt_hw_interrupt_enable(level); } -static rt_err_t _rt_thread_init(struct rt_thread *thread, - const char *name, - void (*entry)(void *parameter), - void *parameter, - void *stack_start, - rt_uint32_t stack_size, - rt_uint8_t priority, - rt_uint32_t tick) +static rt_err_t _thread_init(struct rt_thread *thread, + const char *name, + void (*entry)(void *parameter), + void *parameter, + void *stack_start, + rt_uint32_t stack_size, + rt_uint8_t priority, + rt_uint32_t tick) { /* init thread list */ rt_list_init(&(thread->tlist)); @@ -163,11 +163,11 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread, #ifdef ARCH_CPU_STACK_GROWS_UPWARD thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter, (void *)((char *)thread->stack_addr), - (void *)_rt_thread_exit); + (void *)_thread_exit); #else thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter, (rt_uint8_t *)((char *)thread->stack_addr + thread->stack_size - sizeof(rt_ubase_t)), - (void *)_rt_thread_exit); + (void *)_thread_exit); #endif /* ARCH_CPU_STACK_GROWS_UPWARD */ /* priority init */ @@ -274,14 +274,14 @@ rt_err_t rt_thread_init(struct rt_thread *thread, /* initialize thread object */ rt_object_init((rt_object_t)thread, RT_Object_Class_Thread, name); - return _rt_thread_init(thread, - name, - entry, - parameter, - stack_start, - stack_size, - priority, - tick); + return _thread_init(thread, + name, + entry, + parameter, + stack_start, + stack_size, + priority, + tick); } RTM_EXPORT(rt_thread_init); @@ -376,7 +376,7 @@ rt_err_t rt_thread_detach(rt_thread_t thread) rt_schedule_remove_thread(thread); } - _rt_thread_cleanup_execute(thread); + _thread_cleanup_execute(thread); /* release thread timer */ rt_timer_detach(&(thread->thread_timer)); @@ -440,7 +440,7 @@ rt_thread_t rt_thread_create(const char *name, return RT_NULL; } - _rt_thread_init(thread, + _thread_init(thread, name, entry, parameter, @@ -479,7 +479,7 @@ rt_err_t rt_thread_delete(rt_thread_t thread) rt_schedule_remove_thread(thread); } - _rt_thread_cleanup_execute(thread); + _thread_cleanup_execute(thread); /* release thread timer */ rt_timer_detach(&(thread->thread_timer)); -- cgit v1.3.1 From b7dd004de07056d7cf83ccdcc778a9f3d42a9c54 Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Fri, 6 Aug 2021 18:35:58 +0800 Subject: [bsp/virt64/aarch64] Add 'qemu-virt64-aarch64' bsp --- bsp/qemu-virt64-aarch64/.config | 599 ++++++++++++++++++++++++ bsp/qemu-virt64-aarch64/Kconfig | 30 ++ bsp/qemu-virt64-aarch64/README.md | 52 ++ bsp/qemu-virt64-aarch64/README_zh.md | 53 +++ bsp/qemu-virt64-aarch64/SConscript | 14 + bsp/qemu-virt64-aarch64/SConstruct | 28 ++ bsp/qemu-virt64-aarch64/applications/SConscript | 9 + bsp/qemu-virt64-aarch64/applications/main.c | 18 + bsp/qemu-virt64-aarch64/driver/Kconfig | 122 +++++ bsp/qemu-virt64-aarch64/driver/SConscript | 14 + bsp/qemu-virt64-aarch64/driver/board.c | 106 +++++ bsp/qemu-virt64-aarch64/driver/board.h | 47 ++ bsp/qemu-virt64-aarch64/driver/drv_uart.c | 143 ++++++ bsp/qemu-virt64-aarch64/driver/drv_uart.h | 16 + bsp/qemu-virt64-aarch64/link.lds | 151 ++++++ bsp/qemu-virt64-aarch64/qemu.bat | 1 + bsp/qemu-virt64-aarch64/qemu.sh | 1 + bsp/qemu-virt64-aarch64/rtconfig.h | 196 ++++++++ bsp/qemu-virt64-aarch64/rtconfig.py | 57 +++ bsp/raspberry-pi/raspi3-64/driver/board.h | 1 + libcpu/aarch64/common/gic/SConscript | 6 + libcpu/aarch64/common/gic/gic_pl390.c | 273 +++++++++++ libcpu/aarch64/common/gic/gic_pl390.h | 27 ++ libcpu/aarch64/cortex-a53/entry_point.S | 7 +- libcpu/aarch64/cortex-a53/interrupt.c | 19 + libcpu/aarch64/cortex-a53/interrupt.h | 2 - libcpu/aarch64/cortex-a53/trap.c | 25 +- src/memheap.c | 2 +- 28 files changed, 2014 insertions(+), 5 deletions(-) create mode 100644 bsp/qemu-virt64-aarch64/.config create mode 100644 bsp/qemu-virt64-aarch64/Kconfig create mode 100644 bsp/qemu-virt64-aarch64/README.md create mode 100644 bsp/qemu-virt64-aarch64/README_zh.md create mode 100644 bsp/qemu-virt64-aarch64/SConscript create mode 100644 bsp/qemu-virt64-aarch64/SConstruct create mode 100644 bsp/qemu-virt64-aarch64/applications/SConscript create mode 100644 bsp/qemu-virt64-aarch64/applications/main.c create mode 100644 bsp/qemu-virt64-aarch64/driver/Kconfig create mode 100644 bsp/qemu-virt64-aarch64/driver/SConscript create mode 100644 bsp/qemu-virt64-aarch64/driver/board.c create mode 100644 bsp/qemu-virt64-aarch64/driver/board.h create mode 100644 bsp/qemu-virt64-aarch64/driver/drv_uart.c create mode 100644 bsp/qemu-virt64-aarch64/driver/drv_uart.h create mode 100644 bsp/qemu-virt64-aarch64/link.lds create mode 100644 bsp/qemu-virt64-aarch64/qemu.bat create mode 100644 bsp/qemu-virt64-aarch64/qemu.sh create mode 100644 bsp/qemu-virt64-aarch64/rtconfig.h create mode 100644 bsp/qemu-virt64-aarch64/rtconfig.py create mode 100644 libcpu/aarch64/common/gic/gic_pl390.c create mode 100644 libcpu/aarch64/common/gic/gic_pl390.h (limited to 'src') diff --git a/bsp/qemu-virt64-aarch64/.config b/bsp/qemu-virt64-aarch64/.config new file mode 100644 index 0000000000..7f589d2d6c --- /dev/null +++ b/bsp/qemu-virt64-aarch64/.config @@ -0,0 +1,599 @@ +# +# Automatically generated file; DO NOT EDIT. +# RT-Thread Project Configuration +# + +# +# RT-Thread Kernel +# +CONFIG_RT_NAME_MAX=8 +# CONFIG_RT_USING_ARCH_DATA_TYPE is not set +# CONFIG_RT_USING_SMP is not set +CONFIG_RT_ALIGN_SIZE=4 +# CONFIG_RT_THREAD_PRIORITY_8 is not set +CONFIG_RT_THREAD_PRIORITY_32=y +# CONFIG_RT_THREAD_PRIORITY_256 is not set +CONFIG_RT_THREAD_PRIORITY_MAX=32 +CONFIG_RT_TICK_PER_SECOND=1000 +CONFIG_RT_USING_OVERFLOW_CHECK=y +CONFIG_RT_USING_HOOK=y +CONFIG_RT_USING_IDLE_HOOK=y +CONFIG_RT_IDLE_HOOK_LIST_SIZE=4 +CONFIG_IDLE_THREAD_STACK_SIZE=2048 +CONFIG_RT_USING_TIMER_SOFT=y +CONFIG_RT_TIMER_THREAD_PRIO=4 +CONFIG_RT_TIMER_THREAD_STACK_SIZE=2048 + +# +# kservice optimization +# +# CONFIG_RT_KSERVICE_USING_STDLIB is not set +# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set +CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y +# CONFIG_RT_DEBUG_INIT_CONFIG is not set +# CONFIG_RT_DEBUG_THREAD_CONFIG is not set +# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set +# CONFIG_RT_DEBUG_IPC_CONFIG is not set +# CONFIG_RT_DEBUG_TIMER_CONFIG is not set +# CONFIG_RT_DEBUG_IRQ_CONFIG is not set +# CONFIG_RT_DEBUG_MEM_CONFIG is not set +# CONFIG_RT_DEBUG_SLAB_CONFIG is not set +# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set +# CONFIG_RT_DEBUG_MODULE_CONFIG is not set + +# +# Inter-Thread communication +# +CONFIG_RT_USING_SEMAPHORE=y +CONFIG_RT_USING_MUTEX=y +CONFIG_RT_USING_EVENT=y +CONFIG_RT_USING_MAILBOX=y +CONFIG_RT_USING_MESSAGEQUEUE=y +# CONFIG_RT_USING_SIGNALS is not set + +# +# Memory Management +# +CONFIG_RT_USING_MEMPOOL=y +CONFIG_RT_USING_MEMHEAP=y +# CONFIG_RT_USING_NOHEAP is not set +CONFIG_RT_USING_SMALL_MEM=y +# CONFIG_RT_USING_SLAB is not set +# CONFIG_RT_USING_MEMHEAP_AS_HEAP is not set +# CONFIG_RT_USING_USERHEAP is not set +CONFIG_RT_USING_MEMTRACE=y +CONFIG_RT_USING_HEAP=y + +# +# Kernel Device Object +# +CONFIG_RT_USING_DEVICE=y +CONFIG_RT_USING_DEVICE_OPS=y +# CONFIG_RT_USING_INTERRUPT_INFO is not set +CONFIG_RT_USING_CONSOLE=y +CONFIG_RT_CONSOLEBUF_SIZE=128 +CONFIG_RT_CONSOLE_DEVICE_NAME="uart0" +# CONFIG_RT_PRINTF_LONGLONG is not set +CONFIG_RT_VER_NUM=0x40004 +CONFIG_ARCH_CPU_64BIT=y +# CONFIG_RT_USING_CPU_FFS is not set +# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set + +# +# RT-Thread Components +# +CONFIG_RT_USING_COMPONENTS_INIT=y +CONFIG_RT_USING_USER_MAIN=y +CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048 +CONFIG_RT_MAIN_THREAD_PRIORITY=10 + +# +# C++ features +# +# CONFIG_RT_USING_CPLUSPLUS is not set + +# +# Command shell +# +CONFIG_RT_USING_FINSH=y +CONFIG_FINSH_THREAD_NAME="tshell" +CONFIG_FINSH_USING_HISTORY=y +CONFIG_FINSH_HISTORY_LINES=5 +CONFIG_FINSH_USING_SYMTAB=y +CONFIG_FINSH_USING_DESCRIPTION=y +# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set +CONFIG_FINSH_THREAD_PRIORITY=20 +CONFIG_FINSH_THREAD_STACK_SIZE=4096 +CONFIG_FINSH_CMD_SIZE=80 +# CONFIG_FINSH_USING_AUTH is not set +CONFIG_FINSH_USING_MSH=y +CONFIG_FINSH_USING_MSH_DEFAULT=y +CONFIG_FINSH_USING_MSH_ONLY=y +CONFIG_FINSH_ARG_MAX=10 + +# +# Device virtual file system +# +CONFIG_RT_USING_DFS=y +CONFIG_DFS_USING_WORKDIR=y +CONFIG_DFS_FILESYSTEMS_MAX=2 +CONFIG_DFS_FILESYSTEM_TYPES_MAX=2 +CONFIG_DFS_FD_MAX=16 +# CONFIG_RT_USING_DFS_MNTTABLE is not set +# CONFIG_RT_USING_DFS_ELMFAT is not set +CONFIG_RT_USING_DFS_DEVFS=y +# CONFIG_RT_USING_DFS_ROMFS is not set +# CONFIG_RT_USING_DFS_RAMFS is not set + +# +# Device Drivers +# +CONFIG_RT_USING_DEVICE_IPC=y +CONFIG_RT_PIPE_BUFSZ=512 +# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set +CONFIG_RT_USING_SERIAL=y +CONFIG_RT_USING_SERIAL_V1=y +# CONFIG_RT_USING_SERIAL_V2 is not set +# CONFIG_RT_SERIAL_USING_DMA is not set +CONFIG_RT_SERIAL_RB_BUFSZ=64 +# CONFIG_RT_USING_CAN is not set +# CONFIG_RT_USING_HWTIMER is not set +# CONFIG_RT_USING_CPUTIME is not set +# CONFIG_RT_USING_I2C is not set +# CONFIG_RT_USING_PHY is not set +CONFIG_RT_USING_PIN=y +# CONFIG_RT_USING_ADC is not set +# CONFIG_RT_USING_DAC is not set +# CONFIG_RT_USING_PWM is not set +# CONFIG_RT_USING_MTD_NOR is not set +# CONFIG_RT_USING_MTD_NAND is not set +# CONFIG_RT_USING_PM is not set +CONFIG_RT_USING_RTC=y +# CONFIG_RT_USING_ALARM is not set +# CONFIG_RT_USING_SOFT_RTC is not set +# CONFIG_RT_USING_SDIO is not set +# CONFIG_RT_USING_SPI is not set +# CONFIG_RT_USING_WDT is not set +# CONFIG_RT_USING_AUDIO is not set +# CONFIG_RT_USING_SENSOR is not set +# CONFIG_RT_USING_TOUCH is not set +# CONFIG_RT_USING_HWCRYPTO is not set +# CONFIG_RT_USING_PULSE_ENCODER is not set +# CONFIG_RT_USING_INPUT_CAPTURE is not set +# CONFIG_RT_USING_WIFI is not set + +# +# Using USB +# +# CONFIG_RT_USING_USB_HOST is not set +# CONFIG_RT_USING_USB_DEVICE is not set + +# +# POSIX layer and C standard library +# +CONFIG_RT_USING_LIBC=y +# CONFIG_RT_USING_PTHREADS is not set +CONFIG_RT_USING_POSIX=y +# CONFIG_RT_USING_POSIX_MMAP is not set +# CONFIG_RT_USING_POSIX_TERMIOS is not set +# CONFIG_RT_USING_POSIX_GETLINE is not set +# CONFIG_RT_USING_POSIX_AIO is not set +# CONFIG_RT_USING_MODULE is not set +CONFIG_RT_LIBC_FIXED_TIMEZONE=8 + +# +# Network +# + +# +# Socket abstraction layer +# +# CONFIG_RT_USING_SAL is not set + +# +# Network interface device +# +# CONFIG_RT_USING_NETDEV is not set + +# +# light weight TCP/IP stack +# +# CONFIG_RT_USING_LWIP is not set + +# +# AT commands +# +# CONFIG_RT_USING_AT is not set + +# +# VBUS(Virtual Software BUS) +# +# CONFIG_RT_USING_VBUS is not set + +# +# Utilities +# +# CONFIG_RT_USING_RYM is not set +# CONFIG_RT_USING_ULOG is not set +# CONFIG_RT_USING_UTEST is not set +# CONFIG_RT_USING_RT_LINK is not set + +# +# RT-Thread Utestcases +# +# CONFIG_RT_USING_UTESTCASES is not set + +# +# RT-Thread online packages +# + +# +# IoT - internet of things +# +# CONFIG_PKG_USING_LORAWAN_DRIVER is not set +# CONFIG_PKG_USING_PAHOMQTT is not set +# CONFIG_PKG_USING_UMQTT is not set +# CONFIG_PKG_USING_WEBCLIENT is not set +# CONFIG_PKG_USING_WEBNET is not set +# CONFIG_PKG_USING_MONGOOSE is not set +# CONFIG_PKG_USING_MYMQTT is not set +# CONFIG_PKG_USING_KAWAII_MQTT is not set +# CONFIG_PKG_USING_BC28_MQTT is not set +# CONFIG_PKG_USING_WEBTERMINAL is not set +# CONFIG_PKG_USING_CJSON is not set +# CONFIG_PKG_USING_JSMN is not set +# CONFIG_PKG_USING_LIBMODBUS is not set +# CONFIG_PKG_USING_FREEMODBUS is not set +# CONFIG_PKG_USING_LJSON is not set +# CONFIG_PKG_USING_EZXML is not set +# CONFIG_PKG_USING_NANOPB is not set + +# +# Wi-Fi +# + +# +# Marvell WiFi +# +# CONFIG_PKG_USING_WLANMARVELL is not set + +# +# Wiced WiFi +# +# CONFIG_PKG_USING_WLAN_WICED is not set +# CONFIG_PKG_USING_RW007 is not set +# CONFIG_PKG_USING_COAP is not set +# CONFIG_PKG_USING_NOPOLL is not set +# CONFIG_PKG_USING_NETUTILS is not set +# CONFIG_PKG_USING_CMUX is not set +# CONFIG_PKG_USING_PPP_DEVICE is not set +# CONFIG_PKG_USING_AT_DEVICE is not set +# CONFIG_PKG_USING_ATSRV_SOCKET is not set +# CONFIG_PKG_USING_WIZNET is not set + +# +# IoT Cloud +# +# CONFIG_PKG_USING_ONENET is not set +# CONFIG_PKG_USING_GAGENT_CLOUD is not set +# CONFIG_PKG_USING_ALI_IOTKIT is not set +# CONFIG_PKG_USING_AZURE is not set +# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set +# CONFIG_PKG_USING_JIOT-C-SDK is not set +# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set +# CONFIG_PKG_USING_JOYLINK is not set +# CONFIG_PKG_USING_NIMBLE is not set +# CONFIG_PKG_USING_OTA_DOWNLOADER is not set +# CONFIG_PKG_USING_IPMSG is not set +# CONFIG_PKG_USING_LSSDP is not set +# CONFIG_PKG_USING_AIRKISS_OPEN is not set +# CONFIG_PKG_USING_LIBRWS is not set +# CONFIG_PKG_USING_TCPSERVER is not set +# CONFIG_PKG_USING_PROTOBUF_C is not set +# CONFIG_PKG_USING_DLT645 is not set +# CONFIG_PKG_USING_QXWZ is not set +# CONFIG_PKG_USING_SMTP_CLIENT is not set +# CONFIG_PKG_USING_ABUP_FOTA is not set +# CONFIG_PKG_USING_LIBCURL2RTT is not set +# CONFIG_PKG_USING_CAPNP is not set +# CONFIG_PKG_USING_RT_CJSON_TOOLS is not set +# CONFIG_PKG_USING_AGILE_TELNET is not set +# CONFIG_PKG_USING_NMEALIB is not set +# CONFIG_PKG_USING_AGILE_JSMN is not set +# CONFIG_PKG_USING_PDULIB is not set +# CONFIG_PKG_USING_BTSTACK is not set +# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set +# CONFIG_PKG_USING_WAYZ_IOTKIT is not set +# CONFIG_PKG_USING_MAVLINK is not set +# CONFIG_PKG_USING_RAPIDJSON is not set +# CONFIG_PKG_USING_BSAL is not set +# CONFIG_PKG_USING_AGILE_MODBUS is not set +# CONFIG_PKG_USING_AGILE_FTP is not set +# CONFIG_PKG_USING_EMBEDDEDPROTO is not set + +# +# security packages +# +# CONFIG_PKG_USING_MBEDTLS is not set +# CONFIG_PKG_USING_libsodium is not set +# CONFIG_PKG_USING_TINYCRYPT is not set +# CONFIG_PKG_USING_TFM is not set +# CONFIG_PKG_USING_YD_CRYPTO is not set + +# +# language packages +# +# CONFIG_PKG_USING_LUA is not set +# CONFIG_PKG_USING_JERRYSCRIPT is not set +# CONFIG_PKG_USING_MICROPYTHON is not set + +# +# multimedia packages +# +# CONFIG_PKG_USING_OPENMV is not set +# CONFIG_PKG_USING_MUPDF is not set +# CONFIG_PKG_USING_STEMWIN is not set +# CONFIG_PKG_USING_WAVPLAYER is not set +# CONFIG_PKG_USING_TJPGD is not set +# CONFIG_PKG_USING_PDFGEN is not set +# CONFIG_PKG_USING_HELIX is not set +# CONFIG_PKG_USING_AZUREGUIX is not set +# CONFIG_PKG_USING_TOUCHGFX2RTT is not set +# CONFIG_PKG_USING_NUEMWIN is not set +# CONFIG_PKG_USING_MP3PLAYER is not set +# CONFIG_PKG_USING_TINYJPEG is not set + +# +# tools packages +# +# CONFIG_PKG_USING_CMBACKTRACE is not set +# CONFIG_PKG_USING_EASYFLASH is not set +# CONFIG_PKG_USING_EASYLOGGER is not set +# CONFIG_PKG_USING_SYSTEMVIEW is not set +# CONFIG_PKG_USING_SEGGER_RTT is not set +# CONFIG_PKG_USING_RDB is not set +# CONFIG_PKG_USING_QRCODE is not set +# CONFIG_PKG_USING_ULOG_EASYFLASH is not set +# CONFIG_PKG_USING_ULOG_FILE is not set +# CONFIG_PKG_USING_LOGMGR is not set +# CONFIG_PKG_USING_ADBD is not set +# CONFIG_PKG_USING_COREMARK is not set +# CONFIG_PKG_USING_DHRYSTONE is not set +# CONFIG_PKG_USING_MEMORYPERF is not set +# CONFIG_PKG_USING_NR_MICRO_SHELL is not set +# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set +# CONFIG_PKG_USING_LUNAR_CALENDAR is not set +# CONFIG_PKG_USING_BS8116A is not set +# CONFIG_PKG_USING_GPS_RMC is not set +# CONFIG_PKG_USING_URLENCODE is not set +# CONFIG_PKG_USING_UMCN is not set +# CONFIG_PKG_USING_LWRB2RTT is not set +# CONFIG_PKG_USING_CPU_USAGE is not set +# CONFIG_PKG_USING_GBK2UTF8 is not set +# CONFIG_PKG_USING_VCONSOLE is not set +# CONFIG_PKG_USING_KDB is not set +# CONFIG_PKG_USING_WAMR is not set +# CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set +# CONFIG_PKG_USING_LWLOG is not set +# CONFIG_PKG_USING_ANV_TRACE is not set +# CONFIG_PKG_USING_ANV_MEMLEAK is not set +# CONFIG_PKG_USING_ANV_TESTSUIT is not set +# CONFIG_PKG_USING_ANV_BENCH is not set +# CONFIG_PKG_USING_DEVMEM is not set +# CONFIG_PKG_USING_REGEX is not set +# CONFIG_PKG_USING_MEM_SANDBOX is not set +# CONFIG_PKG_USING_SOLAR_TERMS is not set +# CONFIG_PKG_USING_GAN_ZHI is not set + +# +# system packages +# + +# +# acceleration: Assembly language or algorithmic acceleration packages +# +# CONFIG_PKG_USING_RT_MEMCPY_CM is not set +# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set +# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set +# CONFIG_PKG_USING_QFPLIB_M3 is not set + +# +# Micrium: Micrium software products porting for RT-Thread +# +# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set +# CONFIG_PKG_USING_UCOSII_WRAPPER is not set +# CONFIG_PKG_USING_UC_CRC is not set +# CONFIG_PKG_USING_UC_CLK is not set +# CONFIG_PKG_USING_UC_COMMON is not set +# CONFIG_PKG_USING_UC_MODBUS is not set +# CONFIG_PKG_USING_GUIENGINE is not set +# CONFIG_PKG_USING_CAIRO is not set +# CONFIG_PKG_USING_PIXMAN is not set +# CONFIG_PKG_USING_PARTITION is not set +# CONFIG_PKG_USING_FAL is not set +# CONFIG_PKG_USING_FLASHDB is not set +# CONFIG_PKG_USING_SQLITE is not set +# CONFIG_PKG_USING_RTI is not set +# CONFIG_PKG_USING_LITTLEVGL2RTT is not set +# CONFIG_PKG_USING_CMSIS is not set +# CONFIG_PKG_USING_DFS_YAFFS is not set +# CONFIG_PKG_USING_LITTLEFS is not set +# CONFIG_PKG_USING_DFS_JFFS2 is not set +# CONFIG_PKG_USING_DFS_UFFS is not set +# CONFIG_PKG_USING_LWEXT4 is not set +# CONFIG_PKG_USING_THREAD_POOL is not set +# CONFIG_PKG_USING_ROBOTS is not set +# CONFIG_PKG_USING_EV is not set +# CONFIG_PKG_USING_SYSWATCH is not set +# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set +# CONFIG_PKG_USING_PLCCORE is not set +# CONFIG_PKG_USING_RAMDISK is not set +# CONFIG_PKG_USING_MININI is not set +# CONFIG_PKG_USING_QBOOT is not set +# CONFIG_PKG_USING_PPOOL is not set +# CONFIG_PKG_USING_OPENAMP is not set +# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set +# CONFIG_PKG_USING_LPM is not set +# CONFIG_PKG_USING_TLSF is not set +# CONFIG_PKG_USING_EVENT_RECORDER is not set + +# +# peripheral libraries and drivers +# +# CONFIG_PKG_USING_SENSORS_DRIVERS is not set +# CONFIG_PKG_USING_REALTEK_AMEBA is not set +# CONFIG_PKG_USING_SHT2X is not set +# CONFIG_PKG_USING_SHT3X is not set +# CONFIG_PKG_USING_AS7341 is not set +# CONFIG_PKG_USING_STM32_SDIO is not set +# CONFIG_PKG_USING_ICM20608 is not set +# CONFIG_PKG_USING_U8G2 is not set +# CONFIG_PKG_USING_BUTTON is not set +# CONFIG_PKG_USING_PCF8574 is not set +# CONFIG_PKG_USING_SX12XX is not set +# CONFIG_PKG_USING_SIGNAL_LED is not set +# CONFIG_PKG_USING_LEDBLINK is not set +# CONFIG_PKG_USING_LITTLED is not set +# CONFIG_PKG_USING_LKDGUI is not set +# CONFIG_PKG_USING_NRF5X_SDK is not set +# CONFIG_PKG_USING_NRFX is not set +# CONFIG_PKG_USING_WM_LIBRARIES is not set +# CONFIG_PKG_USING_KENDRYTE_SDK is not set +# CONFIG_PKG_USING_INFRARED is not set +# CONFIG_PKG_USING_AGILE_BUTTON is not set +# CONFIG_PKG_USING_AGILE_LED is not set +# CONFIG_PKG_USING_AT24CXX is not set +# CONFIG_PKG_USING_MOTIONDRIVER2RTT is not set +# CONFIG_PKG_USING_AD7746 is not set +# CONFIG_PKG_USING_PCA9685 is not set +# CONFIG_PKG_USING_I2C_TOOLS is not set +# CONFIG_PKG_USING_NRF24L01 is not set +# CONFIG_PKG_USING_TOUCH_DRIVERS is not set +# CONFIG_PKG_USING_MAX17048 is not set +# CONFIG_PKG_USING_RPLIDAR is not set +# CONFIG_PKG_USING_AS608 is not set +# CONFIG_PKG_USING_RC522 is not set +# CONFIG_PKG_USING_WS2812B is not set +# CONFIG_PKG_USING_EMBARC_BSP is not set +# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set +# CONFIG_PKG_USING_MULTI_RTIMER is not set +# CONFIG_PKG_USING_MAX7219 is not set +# CONFIG_PKG_USING_BEEP is not set +# CONFIG_PKG_USING_EASYBLINK is not set +# CONFIG_PKG_USING_PMS_SERIES is not set +# CONFIG_PKG_USING_CAN_YMODEM is not set +# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set +# CONFIG_PKG_USING_QLED is not set +# CONFIG_PKG_USING_PAJ7620 is not set +# CONFIG_PKG_USING_AGILE_CONSOLE is not set +# CONFIG_PKG_USING_LD3320 is not set +# CONFIG_PKG_USING_WK2124 is not set +# CONFIG_PKG_USING_LY68L6400 is not set +# CONFIG_PKG_USING_DM9051 is not set +# CONFIG_PKG_USING_SSD1306 is not set +# CONFIG_PKG_USING_QKEY is not set +# CONFIG_PKG_USING_RS485 is not set +# CONFIG_PKG_USING_NES is not set +# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set +# CONFIG_PKG_USING_VDEVICE is not set +# CONFIG_PKG_USING_SGM706 is not set +# CONFIG_PKG_USING_STM32WB55_SDK is not set +# CONFIG_PKG_USING_RDA58XX is not set +# CONFIG_PKG_USING_LIBNFC is not set +# CONFIG_PKG_USING_MFOC is not set +# CONFIG_PKG_USING_TMC51XX is not set +# CONFIG_PKG_USING_TCA9534 is not set +# CONFIG_PKG_USING_KOBUKI is not set +# CONFIG_PKG_USING_ROSSERIAL is not set +# CONFIG_PKG_USING_MICRO_ROS is not set + +# +# AI packages +# +# CONFIG_PKG_USING_LIBANN is not set +# CONFIG_PKG_USING_NNOM is not set +# CONFIG_PKG_USING_ONNX_BACKEND is not set +# CONFIG_PKG_USING_ONNX_PARSER is not set +# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set +# CONFIG_PKG_USING_ELAPACK is not set +# CONFIG_PKG_USING_ULAPACK is not set +# CONFIG_PKG_USING_QUEST is not set +# CONFIG_PKG_USING_NAXOS is not set + +# +# miscellaneous packages +# +# CONFIG_PKG_USING_LIBCSV is not set +# CONFIG_PKG_USING_OPTPARSE is not set +# CONFIG_PKG_USING_FASTLZ is not set +# CONFIG_PKG_USING_MINILZO is not set +# CONFIG_PKG_USING_QUICKLZ is not set +# CONFIG_PKG_USING_LZMA is not set +# CONFIG_PKG_USING_MULTIBUTTON is not set +# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set +# CONFIG_PKG_USING_CANFESTIVAL is not set +# CONFIG_PKG_USING_ZLIB is not set +# CONFIG_PKG_USING_MINIZIP is not set +# CONFIG_PKG_USING_DSTR is not set +# CONFIG_PKG_USING_TINYFRAME is not set +# CONFIG_PKG_USING_KENDRYTE_DEMO is not set +# CONFIG_PKG_USING_DIGITALCTRL is not set +# CONFIG_PKG_USING_UPACKER is not set +# CONFIG_PKG_USING_UPARAM is not set + +# +# samples: kernel and components samples +# +# CONFIG_PKG_USING_KERNEL_SAMPLES is not set +# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set +# CONFIG_PKG_USING_NETWORK_SAMPLES is not set +# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set +# CONFIG_PKG_USING_HELLO is not set +# CONFIG_PKG_USING_VI is not set +# CONFIG_PKG_USING_KI is not set +# CONFIG_PKG_USING_ARMv7M_DWT is not set +# CONFIG_PKG_USING_VT100 is not set +# CONFIG_PKG_USING_UKAL is not set +# CONFIG_PKG_USING_CRCLIB is not set + +# +# entertainment: terminal games and other interesting software packages +# +# CONFIG_PKG_USING_THREES is not set +# CONFIG_PKG_USING_2048 is not set +# CONFIG_PKG_USING_SNAKE is not set +# CONFIG_PKG_USING_TETRIS is not set +# CONFIG_PKG_USING_DONUT is not set +# CONFIG_PKG_USING_ACLOCK is not set +# CONFIG_PKG_USING_LWGPS is not set +# CONFIG_PKG_USING_STATE_MACHINE is not set +# CONFIG_PKG_USING_MCURSES is not set +# CONFIG_PKG_USING_COWSAY is not set +CONFIG_OPPO_A55_SOC=y +# CONFIG_BSP_SUPPORT_FPU is not set + +# +# Hardware Drivers Config +# + +# +# BCM Peripheral Drivers +# +CONFIG_BSP_USING_UART=y +CONFIG_RT_USING_UART0=y +# CONFIG_RT_USING_UART1 is not set +CONFIG_BSP_USING_GIC=y +CONFIG_BSP_USING_GIC390=y +CONFIG_BSP_USING_PIN=y +# CONFIG_BSP_USING_SYSTIMER is not set +# CONFIG_BSP_USING_I2C is not set +# CONFIG_BSP_USING_SPI is not set +# CONFIG_BSP_USING_WDT is not set +# CONFIG_BSP_USING_RTC is not set +# CONFIG_BSP_USING_SDIO is not set + +# +# Board Peripheral Drivers +# +# CONFIG_BSP_USING_HDMI is not set diff --git a/bsp/qemu-virt64-aarch64/Kconfig b/bsp/qemu-virt64-aarch64/Kconfig new file mode 100644 index 0000000000..b511ccfba7 --- /dev/null +++ b/bsp/qemu-virt64-aarch64/Kconfig @@ -0,0 +1,30 @@ +mainmenu "RT-Thread Project Configuration" + +config BSP_DIR + string + option env="BSP_ROOT" + default "." + +config RTT_DIR + string + option env="RTT_ROOT" + default "../../" + +config PKGS_DIR + string + option env="PKGS_ROOT" + default "packages" + +source "$RTT_DIR/Kconfig" +source "$PKGS_DIR/Kconfig" + +config OPPO_A55_SOC + bool + select ARCH_ARM_CORTEX_A53 + select ARCH_CPU_64BIT + select RT_USING_COMPONENTS_INIT + select RT_USING_USER_MAIN + select RT_USING_RTC + default y + +source "$BSP_DIR/driver/Kconfig" diff --git a/bsp/qemu-virt64-aarch64/README.md b/bsp/qemu-virt64-aarch64/README.md new file mode 100644 index 0000000000..c1a90ca46f --- /dev/null +++ b/bsp/qemu-virt64-aarch64/README.md @@ -0,0 +1,52 @@ +# QEMU/AArch64 VIRT BSP Introduction + +[中文页](README_ZH.md) | English + +## 1. Introduction + +The AArch64 execution state was introduced with the ARMv8 ISA for machines executing A64 instructions. This project ported RT-Thread on QEMU AArch64 VIRT machine. + +## 2. Compiling + +Usage ARM Developer GNU ToolChain, it support Linux and Windows: +``` +https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads/ +``` +Download the `xxx-aarch64-none-elf` of x86_64 hosted platform,set the `RTT_EXEC_PATH` is system environment after decompress the binary. + +Enter directory `rt-thread/bsp/qemu-virt64-aarch64` and input: +``` +scons +``` + +## 2. Execution + +The project execution tool is `qemu-system-aarch64` + +Download Windows platform from website: +``` +https://www.qemu.org/download/ +``` +On Linux platform (Ubuntu, Deepin and so on), install QEMU by apt. +``` +sudo apt update +sudo apt install qemu-system-arm +``` + +Run qemu.bat or qemu.sh in terminal: +``` +heap: [0x40042aa0 - 0x40142aa0] + + \ | / +- RT - Thread Operating System + / | \ 4.0.4 build Aug 6 2021 + 2006 - 2021 Copyright by rt-thread team +Hi, this is RT-Thread!! +msh /> +``` + +## 3. Condition + +| Driver | Condition | Remark | +| ------ | --------- | ------ | +| UART | Support | UART0 | \ No newline at end of file diff --git a/bsp/qemu-virt64-aarch64/README_zh.md b/bsp/qemu-virt64-aarch64/README_zh.md new file mode 100644 index 0000000000..248cc9d812 --- /dev/null +++ b/bsp/qemu-virt64-aarch64/README_zh.md @@ -0,0 +1,53 @@ +# QEMU/AArch64 VIRT板级支持包说明 + +中文页 | [English](README.md) + +## 1. 简介 + +AArch64是一种采用ARMv8 ISA,用于执行A64指令的机器的64位执行模式。本工程是在QEMU的AArch64 VIRT版本上进行的一份移植。 + +## 2. 编译说明 + +建议使用ARM Developer GNU交叉编译工具链,目前支持Linux/Windows平台: +``` +https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads/ +``` +下载x86_64 Hosted平台下载对应的`xxx-aarch64-none-elf`二进制包,解压后设置`RTT_EXEC_PATH`环境变量为该编译器的bin目录下即可。 + +进入到`rt-thread/bsp/qemu-virt64-aarch64`目录进行输入: +``` +scons +``` +可以看到正常生成`rtthread.elf`与`rtthread.bin`文件。 + +## 3. 执行 + +本工程执行环境为`qemu-system-aarch64`模拟器 + +Windows平台下,可以在此获取到QEMU: +``` +https://www.qemu.org/download/ +``` +Linux平台下,以Ubuntu、Deepin系列发行版为例,可通过该命令安装QEMU: +``` +sudo apt update +sudo apt install qemu-system-arm +``` + +在终端执行qemu.bat或qemu.sh可以看到程序运行: +``` +heap: [0x40042aa0 - 0x40142aa0] + + \ | / +- RT - Thread Operating System + / | \ 4.0.4 build Aug 6 2021 + 2006 - 2021 Copyright by rt-thread team +Hi, this is RT-Thread!! +msh /> +``` + +## 4.支持情况 + +| 驱动 | 支持情况 | 备注 | +| ------ | ---- | :------: | +| UART | 支持 | UART0 | \ No newline at end of file diff --git a/bsp/qemu-virt64-aarch64/SConscript b/bsp/qemu-virt64-aarch64/SConscript new file mode 100644 index 0000000000..c7ef7659ec --- /dev/null +++ b/bsp/qemu-virt64-aarch64/SConscript @@ -0,0 +1,14 @@ +# for module compiling +import os +from building import * + +cwd = GetCurrentDir() +objs = [] +list = os.listdir(cwd) + +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + objs = objs + SConscript(os.path.join(d, 'SConscript')) + +Return('objs') diff --git a/bsp/qemu-virt64-aarch64/SConstruct b/bsp/qemu-virt64-aarch64/SConstruct new file mode 100644 index 0000000000..2d83f7ada6 --- /dev/null +++ b/bsp/qemu-virt64-aarch64/SConstruct @@ -0,0 +1,28 @@ +import os +import sys +import rtconfig + +from rtconfig import RTT_ROOT + +sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] +from building import * + +TARGET = 'rtthread.' + rtconfig.TARGET_EXT + +DefaultEnvironment(tools=[]) +env = Environment(tools = ['mingw'], + AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, + CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, + CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, + AR = rtconfig.AR, ARFLAGS = '-rc', + LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) +env.PrependENVPath('PATH', rtconfig.EXEC_PATH) + +Export('RTT_ROOT') +Export('rtconfig') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT) + +# make a building +DoBuilding(TARGET, objs) diff --git a/bsp/qemu-virt64-aarch64/applications/SConscript b/bsp/qemu-virt64-aarch64/applications/SConscript new file mode 100644 index 0000000000..c583d3016e --- /dev/null +++ b/bsp/qemu-virt64-aarch64/applications/SConscript @@ -0,0 +1,9 @@ +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') + Glob('*.cpp') +CPPPATH = [cwd] + +group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/qemu-virt64-aarch64/applications/main.c b/bsp/qemu-virt64-aarch64/applications/main.c new file mode 100644 index 0000000000..18499f42df --- /dev/null +++ b/bsp/qemu-virt64-aarch64/applications/main.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2017-5-30 Bernard the first version + */ + +#include + +int main(int argc, char** argv) +{ + rt_kprintf("Hi, this is RT-Thread!!\n"); + + return 0; +} diff --git a/bsp/qemu-virt64-aarch64/driver/Kconfig b/bsp/qemu-virt64-aarch64/driver/Kconfig new file mode 100644 index 0000000000..872fa32fe0 --- /dev/null +++ b/bsp/qemu-virt64-aarch64/driver/Kconfig @@ -0,0 +1,122 @@ + +config BSP_SUPPORT_FPU + bool "Using Float" + default n + +menu "Hardware Drivers Config" + menu "BCM Peripheral Drivers" + menuconfig BSP_USING_UART + bool "Using UART" + select RT_USING_SERIAL + default y + + if BSP_USING_UART + config RT_USING_UART0 + bool "Enabel UART 0" + default y + + config RT_USING_UART1 + bool "Enabel UART 1" + default n + endif + + menuconfig BSP_USING_GIC + bool "Enable GIC" + select RT_USING_GIC + default y + if BSP_USING_GIC + config BSP_USING_GIC390 + bool "Enable GIC390" + default y + endif + + config BSP_USING_PIN + bool "Using PIN" + select RT_USING_PIN + default y + + menuconfig BSP_USING_SYSTIMER + bool "Enable SYSTIMER" + select RT_USING_SYSTIMER + default n + + if BSP_USING_SYSTIMER + config RT_USING_SYSTIMER1 + bool "Enable sys timer1" + default n + config RT_USING_SYSTIMER3 + bool "Enable sys timer3" + default n + endif + + menuconfig BSP_USING_I2C + bool "Enable I2C" + select RT_USING_I2C + default n + + if BSP_USING_I2C + config BSP_USING_I2C0 + bool "Enable I2C0" + default n + config BSP_USING_I2C1 + bool "Enable I2C1" + default n + endif + + menuconfig BSP_USING_SPI + bool "Enable SPI" + select RT_USING_SPI + default n + + if BSP_USING_SPI + config BSP_USING_SPI0 + bool "Enable SPI0" + default n + config BSP_USING_SPI1 + bool "Enable SPI1" + default n + endif + + config BSP_USING_WDT + bool "Enable WDT" + select RT_USING_WDT + default n + + menuconfig BSP_USING_RTC + bool "Enable RTC" + select RT_USING_RTC + default n + + if BSP_USING_RTC + config BSP_USING_ALARM + bool "Enable Alarm" + select RT_USING_ALARM + default n + endif + + menuconfig BSP_USING_SDIO + bool "Enable SDIO" + select RT_USING_SDIO + default n + + if BSP_USING_SDIO + config BSP_USING_SDIO0 + bool "Enable SDIO0" + select RT_USING_SDIO + default n + endif + endmenu + + menu "Board Peripheral Drivers" + menuconfig BSP_USING_HDMI + bool "Enable HDMI" + select BSP_USING_SPI + default n + + if BSP_USING_HDMI + config BSP_USING_HDMI_DISPLAY + bool "HDMI DISPLAY" + default n + endif + endmenu +endmenu diff --git a/bsp/qemu-virt64-aarch64/driver/SConscript b/bsp/qemu-virt64-aarch64/driver/SConscript new file mode 100644 index 0000000000..4de25c676a --- /dev/null +++ b/bsp/qemu-virt64-aarch64/driver/SConscript @@ -0,0 +1,14 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Split(''' +board.c +drv_uart.c +''') +CPPPATH = [cwd] + +group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/qemu-virt64-aarch64/driver/board.c b/bsp/qemu-virt64-aarch64/driver/board.c new file mode 100644 index 0000000000..1378b4f2be --- /dev/null +++ b/bsp/qemu-virt64-aarch64/driver/board.c @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2019-07-29 zdzn first version + * 2021-07-31 GuEe-GUI config the memory/io address map + */ + +#include +#include + +#include "board.h" +#include +#include "drv_uart.h" + +void rt_hw_vector_init(void); + +static uint64_t tickval = 0; + +void rt_hw_timer_isr(int vector, void *parameter) +{ + uint64_t cntvct_el0; + + do + { + tickval += 0xF424; + __asm__ volatile ("msr CNTV_CVAL_EL0, %0"::"r"(tickval)); + __asm__ volatile ("mrs %0, CNTVCT_EL0":"=r"(cntvct_el0)); + } + while (cntvct_el0 >= tickval); + + rt_tick_increase(); +} + +int rt_hw_timer_init() +{ + uint64_t val; + + rt_hw_interrupt_install(27, rt_hw_timer_isr, RT_NULL, "tick"); + rt_hw_interrupt_umask(27); + + val = 0; + __asm__ volatile ("msr CNTV_CTL_EL0, %0"::"r"(val)); + val = 0x03B9ACA0; + __asm__ volatile ("msr CNTFRQ_EL0, %0"::"r"(val)); + tickval += 0xF424; + __asm__ volatile ("msr CNTV_CVAL_EL0, %0"::"r"(tickval)); + val = 1; + __asm__ volatile ("msr CNTV_CTL_EL0, %0"::"r"(val)); + return 0; +} + +void idle_wfi(void) +{ + asm volatile ("wfi"); +} + +/** + * Initialize the Hardware related stuffs. Called from rtthread_startup() + * after interrupt disabled. + */ +void rt_hw_board_init(void) +{ + uint64_t cont; + + mmu_init(); + cont = (uint64_t)RT_HW_HEAP_END + 0x1fffff; + cont &= ~0x1fffff; + cont -= 0x40000000; + cont >>= 21; + /* memory location */ + armv8_map_2M(0x40000000, 0x40000000, cont, MEM_ATTR_MEMORY); + /* uart location*/ + armv8_map_2M(PL011_UART0_BASE, PL011_UART0_BASE, 0x1, MEM_ATTR_IO); + /* gic location*/ + armv8_map_2M(GIC_PL390_DISTRIBUTOR_PPTR, GIC_PL390_DISTRIBUTOR_PPTR, 0x1, MEM_ATTR_IO); + mmu_enable(); + + /* initialize hardware interrupt */ + rt_hw_interrupt_init(); // in libcpu/interrupt.c. Set some data structures, no operation on device + rt_hw_vector_init(); // in libcpu/interrupt.c. == rt_cpu_vector_set_base((rt_ubase_t)&system_vectors); + + /* initialize uart */ + rt_hw_uart_init(); // driver/drv_uart.c + /* initialize timer for os tick */ + rt_hw_timer_init(); + rt_thread_idle_sethook(idle_wfi); + +#ifdef RT_USING_CONSOLE + /* set console device */ + rt_console_set_device(RT_CONSOLE_DEVICE_NAME); +#endif /* RT_USING_CONSOLE */ + +#ifdef RT_USING_HEAP + /* initialize memory system */ + rt_kprintf("heap: [0x%08x - 0x%08x]\n", RT_HW_HEAP_BEGIN, RT_HW_HEAP_END); + rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END); +#endif + +#ifdef RT_USING_COMPONENTS_INIT + rt_components_board_init(); +#endif +} diff --git a/bsp/qemu-virt64-aarch64/driver/board.h b/bsp/qemu-virt64-aarch64/driver/board.h new file mode 100644 index 0000000000..87da1852ab --- /dev/null +++ b/bsp/qemu-virt64-aarch64/driver/board.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2017-5-30 Bernard the first version + * 2021-07-31 GuEe-GUI add ARM GIC definitions + */ + +#ifndef BOARD_H__ +#define BOARD_H__ + +#include + +extern unsigned char __bss_start; +extern unsigned char __bss_end; + +#define RT_HW_HEAP_BEGIN (void*)&__bss_end +#define RT_HW_HEAP_END (void*)(RT_HW_HEAP_BEGIN + 1 * 1024 * 1024) + +/* UART */ +#define PL011_UARTDR 0x000 +#define PL011_UARTFR 0x018 +#define PL011_UARTFR_TXFF_BIT 5 +#define PL011_UART0_BASE 0x09000000 +#define PL011_UART0_SIZE 0x00001000 + +/* DIST and CPU */ +#define GIC_PL390_DISTRIBUTOR_PPTR 0x08000000 +#define GIC_PL390_CONTROLLER_PPTR 0x08010000 + +/* the basic constants and interfaces needed by gic */ +rt_inline rt_uint32_t platform_get_gic_dist_base(void) +{ + return GIC_PL390_DISTRIBUTOR_PPTR; +} + +rt_inline rt_uint32_t platform_get_gic_cpu_base(void) +{ + return GIC_PL390_CONTROLLER_PPTR; +} + +void rt_hw_board_init(void); + +#endif diff --git a/bsp/qemu-virt64-aarch64/driver/drv_uart.c b/bsp/qemu-virt64-aarch64/driver/drv_uart.c new file mode 100644 index 0000000000..94df82c9b5 --- /dev/null +++ b/bsp/qemu-virt64-aarch64/driver/drv_uart.c @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/5/5 Bernard The first version + */ + +#include +#include +#include + +#include "board.h" + +unsigned int readl(volatile void *addr) +{ + return *(volatile unsigned int *)addr; +} + +void writel(unsigned int v, volatile void *addr) +{ + *(volatile unsigned int *)addr = v; +} + +struct hw_uart_device +{ + rt_ubase_t hw_base; + rt_uint32_t irqno; +}; + +static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg) +{ + return RT_EOK; +} + +static rt_err_t uart_control(struct rt_serial_device *serial, int cmd, void *arg) +{ + struct hw_uart_device *uart; + uint32_t val; + + RT_ASSERT(serial != RT_NULL); + uart = (struct hw_uart_device *)serial->parent.user_data; + + switch (cmd) + { + case RT_DEVICE_CTRL_CLR_INT: + /* disable rx irq */ + val = readl((volatile void *)(uart->hw_base + 0x38)); + val &= ~0x10; + writel(val, (volatile void *)(uart->hw_base + 0x38)); + rt_hw_interrupt_mask(uart->irqno); + break; + + case RT_DEVICE_CTRL_SET_INT: + /* enable rx irq */ + val = readl((volatile void *)(uart->hw_base + 0x38)); + val |= 0x10; + writel(val, (volatile void *)(uart->hw_base + 0x38)); + rt_hw_interrupt_umask(uart->irqno); + break; + } + + return RT_EOK; +} + +static int uart_putc(struct rt_serial_device *serial, char c) +{ + struct hw_uart_device *uart; + + RT_ASSERT(serial != RT_NULL); + uart = (struct hw_uart_device *)serial->parent.user_data; + + while (readl((volatile void *)(uart->hw_base + PL011_UARTFR)) & (1 << PL011_UARTFR_TXFF_BIT)) + { + } + + writel(c, (volatile void *)( uart->hw_base + PL011_UARTDR)); + + return 1; +} + +static int uart_getc(struct rt_serial_device *serial) +{ + int ch = -1; + struct hw_uart_device *uart; + + RT_ASSERT(serial != RT_NULL); + uart = (struct hw_uart_device *)serial->parent.user_data; + + if (!(readl((volatile void *)(uart->hw_base + 0x18)) & (1 << 4))) + { + ch = readl((volatile void *)(uart->hw_base)); + } + + return ch; +} + +static const struct rt_uart_ops _uart_ops = +{ + uart_configure, + uart_control, + uart_putc, + uart_getc, +}; + +static void rt_hw_uart_isr(int irqno, void *param) +{ + struct rt_serial_device *serial = (struct rt_serial_device*)param; + rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND); +} + +#ifdef RT_USING_UART0 +/* UART device driver structure */ +static struct hw_uart_device _uart0_device = +{ + PL011_UART0_BASE, + 33, +}; +static struct rt_serial_device _serial0; +#endif + +int rt_hw_uart_init(void) +{ + struct hw_uart_device *uart; + struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; + +#ifdef RT_USING_UART0 + uart = &_uart0_device; + + _serial0.ops = &_uart_ops; + _serial0.config = config; + + /* register UART1 device */ + rt_hw_serial_register(&_serial0, "uart0", + RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, + uart); + rt_hw_interrupt_install(uart->irqno, rt_hw_uart_isr, &_serial0, "uart0"); +#endif + + return 0; +} diff --git a/bsp/qemu-virt64-aarch64/driver/drv_uart.h b/bsp/qemu-virt64-aarch64/driver/drv_uart.h new file mode 100644 index 0000000000..686d5b7a09 --- /dev/null +++ b/bsp/qemu-virt64-aarch64/driver/drv_uart.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2017-5-30 Bernard the first version + */ + +#ifndef DRV_UART_H__ +#define DRV_UART_H__ + +int rt_hw_uart_init(void); + +#endif /* DRV_UART_H__ */ diff --git a/bsp/qemu-virt64-aarch64/link.lds b/bsp/qemu-virt64-aarch64/link.lds new file mode 100644 index 0000000000..169f206b68 --- /dev/null +++ b/bsp/qemu-virt64-aarch64/link.lds @@ -0,0 +1,151 @@ +/* + * File : link.lds + * 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. + * + * 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. + * + * Change Logs: + * 2017-5-30 bernard first version + */ + +/* _EL1_STACK_SIZE = DEFINED(_EL1_STACK_SIZE) ? _EL1_STACK_SIZE : 0x20000; */ + +SECTIONS +{ + . = 0x40000000; + . = ALIGN(4096); + .text : + { + KEEP(*(.text.entrypoint)) /* The entry point */ + *(.vectors) + *(.text) /* remaining code */ + *(.text.*) /* remaining code */ + + *(.rodata) /* read-only data (constants) */ + *(.rodata*) + *(.glue_7) + *(.glue_7t) + *(.gnu.linkonce.t*) + + /* section information for finsh shell */ + . = ALIGN(16); + __fsymtab_start = .; + KEEP(*(FSymTab)) + __fsymtab_end = .; + . = ALIGN(16); + __vsymtab_start = .; + KEEP(*(VSymTab)) + __vsymtab_end = .; + . = ALIGN(16); + + /* section information for initial. */ + . = ALIGN(16); + __rt_init_start = .; + KEEP(*(SORT(.rti_fn*))) + __rt_init_end = .; + . = ALIGN(16); + + . = ALIGN(16); + _etext = .; + } + + .eh_frame_hdr : + { + *(.eh_frame_hdr) + *(.eh_frame_entry) + } + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } + + . = ALIGN(16); + .data : + { + *(.data) + *(.data.*) + + *(.data1) + *(.data1.*) + + . = ALIGN(16); + _gp = ABSOLUTE(.); /* Base of small data */ + + *(.sdata) + *(.sdata.*) + } + + . = ALIGN(16); + .ctors : + { + PROVIDE(__ctors_start__ = .); + KEEP(*(SORT(.ctors.*))) + KEEP(*(.ctors)) + PROVIDE(__ctors_end__ = .); + } + + .dtors : + { + PROVIDE(__dtors_start__ = .); + KEEP(*(SORT(.dtors.*))) + KEEP(*(.dtors)) + PROVIDE(__dtors_end__ = .); + } + + . = ALIGN(16); + .bss : + { + PROVIDE(__bss_start = .); + *(.bss) + *(.bss.*) + *(.dynbss) + *(COMMON) + PROVIDE(__bss_end = .); + } + _end = .; + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + * Symbols in the DWARF debugging sections are relative to the beginning + * of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } +} + +__bss_size = (__bss_end - __bss_start)>>3; diff --git a/bsp/qemu-virt64-aarch64/qemu.bat b/bsp/qemu-virt64-aarch64/qemu.bat new file mode 100644 index 0000000000..f8896a3472 --- /dev/null +++ b/bsp/qemu-virt64-aarch64/qemu.bat @@ -0,0 +1 @@ +qemu-system-aarch64 -M virt -cpu cortex-a53 -smp 1 -kernel rtthread.elf -nographic diff --git a/bsp/qemu-virt64-aarch64/qemu.sh b/bsp/qemu-virt64-aarch64/qemu.sh new file mode 100644 index 0000000000..d05fdafd14 --- /dev/null +++ b/bsp/qemu-virt64-aarch64/qemu.sh @@ -0,0 +1 @@ +qemu-system-aarch64 -M virt -cpu cortex-a53 -smp 1 -kernel rtthread.elf -nographic -monitor pty diff --git a/bsp/qemu-virt64-aarch64/rtconfig.h b/bsp/qemu-virt64-aarch64/rtconfig.h new file mode 100644 index 0000000000..23054ac45d --- /dev/null +++ b/bsp/qemu-virt64-aarch64/rtconfig.h @@ -0,0 +1,196 @@ +#ifndef RT_CONFIG_H__ +#define RT_CONFIG_H__ + +/* Automatically generated file; DO NOT EDIT. */ +/* RT-Thread Project Configuration */ + +/* RT-Thread Kernel */ + +#define RT_NAME_MAX 8 +#define RT_ALIGN_SIZE 4 +#define RT_THREAD_PRIORITY_32 +#define RT_THREAD_PRIORITY_MAX 32 +#define RT_TICK_PER_SECOND 1000 +#define RT_USING_OVERFLOW_CHECK +#define RT_USING_HOOK +#define RT_USING_IDLE_HOOK +#define RT_IDLE_HOOK_LIST_SIZE 4 +#define IDLE_THREAD_STACK_SIZE 2048 +#define RT_USING_TIMER_SOFT +#define RT_TIMER_THREAD_PRIO 4 +#define RT_TIMER_THREAD_STACK_SIZE 2048 + +/* kservice optimization */ + +#define RT_DEBUG +#define RT_DEBUG_COLOR + +/* Inter-Thread communication */ + +#define RT_USING_SEMAPHORE +#define RT_USING_MUTEX +#define RT_USING_EVENT +#define RT_USING_MAILBOX +#define RT_USING_MESSAGEQUEUE + +/* Memory Management */ + +#define RT_USING_MEMPOOL +#define RT_USING_MEMHEAP +#define RT_USING_SMALL_MEM +#define RT_USING_MEMTRACE +#define RT_USING_HEAP + +/* Kernel Device Object */ + +#define RT_USING_DEVICE +#define RT_USING_DEVICE_OPS +#define RT_USING_CONSOLE +#define RT_CONSOLEBUF_SIZE 128 +#define RT_CONSOLE_DEVICE_NAME "uart0" +#define RT_VER_NUM 0x40004 +#define ARCH_CPU_64BIT + +/* RT-Thread Components */ + +#define RT_USING_COMPONENTS_INIT +#define RT_USING_USER_MAIN +#define RT_MAIN_THREAD_STACK_SIZE 2048 +#define RT_MAIN_THREAD_PRIORITY 10 + +/* C++ features */ + + +/* Command shell */ + +#define RT_USING_FINSH +#define FINSH_THREAD_NAME "tshell" +#define FINSH_USING_HISTORY +#define FINSH_HISTORY_LINES 5 +#define FINSH_USING_SYMTAB +#define FINSH_USING_DESCRIPTION +#define FINSH_THREAD_PRIORITY 20 +#define FINSH_THREAD_STACK_SIZE 4096 +#define FINSH_CMD_SIZE 80 +#define FINSH_USING_MSH +#define FINSH_USING_MSH_DEFAULT +#define FINSH_USING_MSH_ONLY +#define FINSH_ARG_MAX 10 + +/* Device virtual file system */ + +#define RT_USING_DFS +#define DFS_USING_WORKDIR +#define DFS_FILESYSTEMS_MAX 2 +#define DFS_FILESYSTEM_TYPES_MAX 2 +#define DFS_FD_MAX 16 +#define RT_USING_DFS_DEVFS + +/* Device Drivers */ + +#define RT_USING_DEVICE_IPC +#define RT_PIPE_BUFSZ 512 +#define RT_USING_SERIAL +#define RT_USING_SERIAL_V1 +#define RT_SERIAL_RB_BUFSZ 64 +#define RT_USING_PIN +#define RT_USING_RTC + +/* Using USB */ + + +/* POSIX layer and C standard library */ + +#define RT_USING_LIBC +#define RT_USING_POSIX +#define RT_LIBC_FIXED_TIMEZONE 8 + +/* Network */ + +/* Socket abstraction layer */ + + +/* Network interface device */ + + +/* light weight TCP/IP stack */ + + +/* AT commands */ + + +/* VBUS(Virtual Software BUS) */ + + +/* Utilities */ + + +/* RT-Thread Utestcases */ + + +/* RT-Thread online packages */ + +/* IoT - internet of things */ + + +/* Wi-Fi */ + +/* Marvell WiFi */ + + +/* Wiced WiFi */ + + +/* IoT Cloud */ + + +/* security packages */ + + +/* language packages */ + + +/* multimedia packages */ + + +/* tools packages */ + + +/* system packages */ + +/* acceleration: Assembly language or algorithmic acceleration packages */ + + +/* Micrium: Micrium software products porting for RT-Thread */ + + +/* peripheral libraries and drivers */ + + +/* AI packages */ + + +/* miscellaneous packages */ + + +/* samples: kernel and components samples */ + + +/* entertainment: terminal games and other interesting software packages */ + +#define OPPO_A55_SOC + +/* Hardware Drivers Config */ + +/* BCM Peripheral Drivers */ + +#define BSP_USING_UART +#define RT_USING_UART0 +#define BSP_USING_GIC +#define BSP_USING_GIC390 +#define BSP_USING_PIN + +/* Board Peripheral Drivers */ + + +#endif diff --git a/bsp/qemu-virt64-aarch64/rtconfig.py b/bsp/qemu-virt64-aarch64/rtconfig.py new file mode 100644 index 0000000000..5c97f83ed9 --- /dev/null +++ b/bsp/qemu-virt64-aarch64/rtconfig.py @@ -0,0 +1,57 @@ +import os + +# toolchains options +ARCH ='aarch64' +CPU ='cortex-a53' +CROSS_TOOL ='gcc' + +if os.getenv('RTT_ROOT'): + RTT_ROOT = os.getenv('RTT_ROOT') +else: + RTT_ROOT = os.path.join(os.getcwd(), '..', '..') + +if os.getenv('RTT_CC'): + CROSS_TOOL = os.getenv('RTT_CC') + +# cross_tool provides the cross compiler +# EXEC_PATH is the compiler execute path, for example, CodeSourcery, + +if CROSS_TOOL == 'gcc': + PLATFORM = 'gcc' + EXEC_PATH = r'C:/Program Files/gcc-arm-8.3-2019.03-i686-mingw32-aarch64-elf/bin' + +if os.getenv('RTT_EXEC_PATH'): + EXEC_PATH = os.getenv('RTT_EXEC_PATH') + +BUILD = 'debug' + +if PLATFORM == 'gcc': + # toolchains + PREFIX = 'aarch64-elf-' + CC = PREFIX + 'gcc' + CXX = PREFIX + 'g++' + AS = PREFIX + 'gcc' + AR = PREFIX + 'ar' + LINK = PREFIX + 'gcc' + TARGET_EXT = 'elf' + SIZE = PREFIX + 'size' + OBJDUMP = PREFIX + 'objdump' + OBJCPY = PREFIX + 'objcopy' + + DEVICE = ' -g -march=armv8-a -mtune=cortex-a53' + CFLAGS = DEVICE + ' -Wall' + AFLAGS = ' -c' + ' -x assembler-with-cpp -D__ASSEMBLY__' + LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,system_vectors -T link.lds' + CPATH = '' + LPATH = '' + + if BUILD == 'debug': + CFLAGS += ' -O0 -gdwarf-2' + AFLAGS += ' -gdwarf-2' + else: + CFLAGS += ' -O2' + + CXXFLAGS = CFLAGS + +DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n' +POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' diff --git a/bsp/raspberry-pi/raspi3-64/driver/board.h b/bsp/raspberry-pi/raspi3-64/driver/board.h index 6b51f0408e..a279319619 100644 --- a/bsp/raspberry-pi/raspi3-64/driver/board.h +++ b/bsp/raspberry-pi/raspi3-64/driver/board.h @@ -12,6 +12,7 @@ #define BOARD_H__ #include +#include "raspi.h" extern unsigned char __bss_start; extern unsigned char __bss_end; diff --git a/libcpu/aarch64/common/gic/SConscript b/libcpu/aarch64/common/gic/SConscript index b114ba7678..28daac87ff 100644 --- a/libcpu/aarch64/common/gic/SConscript +++ b/libcpu/aarch64/common/gic/SConscript @@ -5,6 +5,10 @@ from building import * cwd = GetCurrentDir() CPPPATH = [cwd] +gic390_group = Split(''' +gic_pl390.c +''') + gic400_group = Split(''' gic_pl400.c ''') @@ -14,6 +18,8 @@ gic_pl500.c ''') src = () +if GetDepend('BSP_USING_GIC390'): + src = gic390_group if GetDepend('BSP_USING_GIC400'): src = gic400_group if GetDepend('BSP_USING_GIC500'): diff --git a/libcpu/aarch64/common/gic/gic_pl390.c b/libcpu/aarch64/common/gic/gic_pl390.c new file mode 100644 index 0000000000..a8e3b10d94 --- /dev/null +++ b/libcpu/aarch64/common/gic/gic_pl390.c @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-07-31 GuEe-GUI the first version + */ +#include + +#include "gic_pl390.h" + +#define BIT(n) (1ul<<(n)) +#define MASK(n) (BIT(n)-1ul) + +#define IRQ_REG(IRQ) ((IRQ) / 32) +#define IRQ_BIT(IRQ) BIT((IRQ) % 32) +#define IRQ_MASK MASK(10) +#define IRQ_SET_ALL 0xffffffff +#define IS_IRQ_VALID(X) (((X)&IRQ_MASK) < GIC390_SPECIAL_IRQ_START) + +#define TARGET_CPU_ALLINT(CPU) \ +( \ + (((CPU) & 0xff) << 0 ) | \ + (((CPU) & 0xff) << 8 ) | \ + (((CPU) & 0xff) << 16) | \ + (((CPU) & 0xff) << 24) \ +) +#define CPU(X) (1<<(X)) +#define TARGET_CPU0_ALLINT TARGET_CPU_ALLINT(CPU(0)) + +/* memory map for GIC distributor */ +struct gic_dist_map +{ + rt_uint32_t enable; /* 0x000 */ + rt_uint32_t ic_type; /* 0x004 */ + rt_uint32_t dist_ident; /* 0x008 */ + rt_uint32_t res1[29]; /* [0x00C, 0x080) */ + + rt_uint32_t security[32]; /* [0x080, 0x100) */ + + rt_uint32_t enable_set[32]; /* [0x100, 0x180) */ + rt_uint32_t enable_clr[32]; /* [0x180, 0x200) */ + rt_uint32_t pending_set[32]; /* [0x200, 0x280) */ + rt_uint32_t pending_clr[32]; /* [0x280, 0x300) */ + rt_uint32_t active[32]; /* [0x300, 0x380) */ + rt_uint32_t res2[32]; /* [0x380, 0x400) */ + + rt_uint32_t priority[255]; /* [0x400, 0x7FC) */ + rt_uint32_t res3; /* 0x7FC */ + + rt_uint32_t targets[255]; /* [0x800, 0xBFC) */ + rt_uint32_t res4; /* 0xBFC */ + + rt_uint32_t config[64]; /* [0xC00, 0xD00) */ + + rt_uint32_t spi[32]; /* [0xD00, 0xD80) */ + rt_uint32_t res5[20]; /* [0xD80, 0xDD0) */ + rt_uint32_t res6; /* 0xDD0 */ + rt_uint32_t legacy_int; /* 0xDD4 */ + rt_uint32_t res7[2]; /* [0xDD8, 0xDE0) */ + rt_uint32_t match_d; /* 0xDE0 */ + rt_uint32_t enable_d; /* 0xDE4 */ + rt_uint32_t res8[70]; /* [0xDE8, 0xF00) */ + + rt_uint32_t sgi_control; /* 0xF00 */ + rt_uint32_t res9[3]; /* [0xF04, 0xF10) */ + rt_uint32_t sgi_pending_clr[4]; /* [0xF10, 0xF20) */ + rt_uint32_t res10[40]; /* [0xF20, 0xFC0) */ + + rt_uint32_t periph_id[12]; /* [0xFC0, 0xFF0) */ + rt_uint32_t component_id[4]; /* [0xFF0, 0xFFF] */ +}; + +/* memory map for GIC CPU interface */ +struct gic_cpu_iface_map +{ + rt_uint32_t icontrol; /* 0x000 */ + rt_uint32_t pri_msk_c; /* 0x004 */ + rt_uint32_t pb_c; /* 0x008 */ + rt_uint32_t int_ack; /* 0x00C */ + rt_uint32_t eoi; /* 0x010 */ + rt_uint32_t run_priority; /* 0x014 */ + rt_uint32_t hi_pend; /* 0x018 */ + rt_uint32_t ns_alias_bp_c; /* 0x01C */ + rt_uint32_t ns_alias_ack; /* 0x020 GIC400 only */ + rt_uint32_t ns_alias_eoi; /* 0x024 GIC400 only */ + rt_uint32_t ns_alias_hi_pend; /* 0x028 GIC400 only */ + + rt_uint32_t res1[5]; /* [0x02C, 0x040) */ + + rt_uint32_t integ_en_c; /* 0x040 PL390 only */ + rt_uint32_t interrupt_out; /* 0x044 PL390 only */ + rt_uint32_t res2[2]; /* [0x048, 0x050) */ + + rt_uint32_t match_c; /* 0x050 PL390 only */ + rt_uint32_t enable_c; /* 0x054 PL390 only */ + + rt_uint32_t res3[30]; /* [0x058, 0x0FC) */ + rt_uint32_t active_priority[4]; /* [0x0D0, 0xDC] GIC400 only */ + rt_uint32_t ns_active_priority[4]; /* [0xE0,0xEC] GIC400 only */ + rt_uint32_t res4[3]; + + rt_uint32_t cpu_if_ident; /* 0x0FC */ + rt_uint32_t res5[948]; /* [0x100. 0xFC0) */ + + rt_uint32_t periph_id[8]; /* [0xFC0, 9xFF0) PL390 only */ + rt_uint32_t component_id[4]; /* [0xFF0, 0xFFF] PL390 only */ +}; + +volatile struct gic_dist_map *gic_dist = + (volatile struct gic_dist_map*)(GIC_PL390_DISTRIBUTOR_PPTR); + +volatile struct gic_cpu_iface_map *gic_cpuiface = + (volatile struct gic_cpu_iface_map*)(GIC_PL390_CONTROLLER_PPTR); + +/* + * The only sane way to get an GIC IRQ number that can be properly + * ACKED later is through the int_ack register. Unfortunately, reading + * this register changes the interrupt state to pending so future + * reads will not return the same value For this reason, we have a + * global variable to store the IRQ number. + */ +static rt_uint32_t active_irq = GIC390_IRQ_NONE; + +rt_inline int is_irq_edge_triggered(int irq) +{ + int word = irq / 16; + int bit = ((irq & 0xf) * 2); + + return !!(gic_dist->config[word] & BIT(bit + 1)); +} + +rt_inline void dist_pending_clr(int irq) +{ + int word = irq / 32; + int bit = irq & 0x1f; + gic_dist->pending_clr[word] = BIT(bit); +} + +rt_inline void dist_init(void) +{ + int i; + int nirqs = 32 * ((gic_dist->ic_type & 0x1f) + 1); + gic_dist->enable = 0; + + for (i = 0; i < nirqs; i += 32) + { + /* disable */ + gic_dist->enable_clr[i / 32] = IRQ_SET_ALL; + /* clear pending */ + gic_dist->pending_clr[i / 32] = IRQ_SET_ALL; + } + + /* reset interrupts priority */ + for (i = 32; i < nirqs; i += 4) + { + gic_dist->priority[i / 4] = 0x0; + } + + /* + * reset int target to cpu 0 + * (Should really query which processor we're running on and use that) + */ + for (i = 0; i < nirqs; i += 4) + { + gic_dist->targets[i / 4] = TARGET_CPU0_ALLINT; + } + + /* level-triggered, 1-N */ + for (i = 64; i < nirqs; i += 32) + { + gic_dist->config[i / 32] = 0; + } + /* enable the int controller */ + gic_dist->enable = 1; +} + +rt_inline void cpu_iface_init(void) +{ + rt_uint32_t i; + + /* For non-Exynos4, the registers are banked per CPU, need to clear them */ + gic_dist->enable_clr[0] = IRQ_SET_ALL; + gic_dist->pending_clr[0] = IRQ_SET_ALL; + gic_dist->priority[0] = 0x00; + /* put everything in group 0 */ + + /* clear any software generated interrupts */ + for (i = 0; i < 16; i += 4) + { + gic_dist->sgi_pending_clr[i / 4] = IRQ_SET_ALL; + } + + gic_cpuiface->icontrol = 0; + gic_cpuiface->pri_msk_c = 0x000000f0; + gic_cpuiface->pb_c = 0x00000003; + + while (((i = gic_cpuiface->int_ack) & IRQ_MASK) != GIC390_IRQ_NONE) + { + gic_cpuiface->eoi = i; + } + gic_cpuiface->icontrol = 0x1; +} + + +void arm_gic_irq_init(void) +{ + dist_init(); + cpu_iface_init(); +} + +int arm_gic_get_active_irq(void) +{ + int irq; + if (!IS_IRQ_VALID(active_irq)) + { + active_irq = gic_cpuiface->int_ack; + } + + if (IS_IRQ_VALID(active_irq)) + { + irq = active_irq & IRQ_MASK; + } + else + { + irq = GIC390_IRQ_NONE; + } + + return irq; +} + +void arm_gic_mask(int irq) +{ + int word = irq / 32; + int bit = irq & 0x1f; + + gic_dist->enable_clr[word] = BIT(bit); +} + +void arm_gic_umask(int irq) +{ + int word = irq / 32; + int bit = irq & 0x1f; + gic_dist->enable_set[word] = BIT(bit); +} + +void arm_gic_ack(int irq) +{ + if (!(IS_IRQ_VALID(active_irq) && (active_irq & IRQ_MASK) == irq)) + { + return; + } + if (is_irq_edge_triggered(irq)) + { + dist_pending_clr(irq); + } + + gic_cpuiface->eoi = active_irq; + active_irq = GIC390_IRQ_NONE; +} + +int rt_hw_interrupt_get_irq(void) +{ + return arm_gic_get_active_irq(); +} + +void rt_hw_interrupt_ack(int fiq_irq) +{ + return arm_gic_ack(fiq_irq); +} + diff --git a/libcpu/aarch64/common/gic/gic_pl390.h b/libcpu/aarch64/common/gic/gic_pl390.h new file mode 100644 index 0000000000..7ea574967d --- /dev/null +++ b/libcpu/aarch64/common/gic/gic_pl390.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-07-31 GuEe-GUI the first version + */ + +#ifndef GIC_PL390_H__ +#define GIC_PL390_H__ + +#include + +#define GIC390_SPECIAL_IRQ_START 1020 +#define GIC390_IRQ_NONE 1023 + +void arm_gic_irq_init(void); + +int arm_gic_get_active_irq(void); +void arm_gic_ack(int irq); + +void arm_gic_mask(int irq); +void arm_gic_umask(int irq); + +#endif diff --git a/libcpu/aarch64/cortex-a53/entry_point.S b/libcpu/aarch64/cortex-a53/entry_point.S index 6d2c69226b..552e5916ce 100644 --- a/libcpu/aarch64/cortex-a53/entry_point.S +++ b/libcpu/aarch64/cortex-a53/entry_point.S @@ -35,7 +35,7 @@ _start: // ldr x2, =EL1_stack // mov sp, x2 - ldr x1, =_start + ldr x1, =init_el1_stack_limit // set up EL1 mrs x0, CurrentEL // CurrentEL Register. bit 2, 3. Others reserved @@ -109,3 +109,8 @@ _start: bl entry // for failsafe, halt this core too b .L__current_cpu_idle +.bss +.align 3 +init_el1_stack: + .space 4096 +init_el1_stack_limit: diff --git a/libcpu/aarch64/cortex-a53/interrupt.c b/libcpu/aarch64/cortex-a53/interrupt.c index 4a5d502a3c..ba49be5132 100644 --- a/libcpu/aarch64/cortex-a53/interrupt.c +++ b/libcpu/aarch64/cortex-a53/interrupt.c @@ -9,6 +9,7 @@ * 2019-07-28 zdzn add smp support * 2019-08-09 zhangjun fixup the problem of smp startup and scheduling issues, * write addr to mailbox3 to startup smp, and we use mailbox0 for ipi + * 2021-07-31 GuEe-GUI Add gic pl390 branch */ #include @@ -19,6 +20,10 @@ #include "armv8.h" #include "interrupt.h" +#ifdef BSP_USING_GIC390 +#include +#endif + #define MAX_HANDLERS 72 #ifdef RT_USING_SMP @@ -41,6 +46,7 @@ void rt_hw_vector_init(void) rt_hw_set_current_vbar((rt_ubase_t)&system_vectors); // cpu_gcc.S } +#ifndef BSP_USING_GIC static void default_isr_handler(int vector, void *param) { #ifdef RT_USING_SMP @@ -49,12 +55,16 @@ static void default_isr_handler(int vector, void *param) rt_kprintf("unhandled irq: %d\n",vector); #endif } +#endif /** * This function will initialize hardware interrupt */ void rt_hw_interrupt_init(void) { +#ifdef BSP_USING_GIC390 + arm_gic_irq_init(); +#else rt_uint32_t index; /* mask all of interrupts */ @@ -76,6 +86,7 @@ void rt_hw_interrupt_init(void) rt_interrupt_from_thread = 0; rt_interrupt_to_thread = 0; rt_thread_switch_interrupt_flag = 0; +#endif } /** @@ -84,6 +95,9 @@ void rt_hw_interrupt_init(void) */ void rt_hw_interrupt_mask(int vector) { +#ifdef BSP_USING_GIC390 + arm_gic_mask(vector); +#else if (vector < 32) { IRQ_DISABLE1 = (1 << vector); @@ -98,6 +112,7 @@ void rt_hw_interrupt_mask(int vector) vector = vector - 64; IRQ_DISABLE_BASIC = (1 << vector); } +#endif } /** @@ -106,6 +121,9 @@ void rt_hw_interrupt_mask(int vector) */ void rt_hw_interrupt_umask(int vector) { +#ifdef BSP_USING_GIC390 + arm_gic_umask(vector); +#else if (vector < 32) { IRQ_ENABLE1 = (1 << vector); @@ -120,6 +138,7 @@ void rt_hw_interrupt_umask(int vector) vector = vector - 64; IRQ_ENABLE_BASIC = (1 << vector); } +#endif } /** diff --git a/libcpu/aarch64/cortex-a53/interrupt.h b/libcpu/aarch64/cortex-a53/interrupt.h index 94a455550d..72e69bd808 100644 --- a/libcpu/aarch64/cortex-a53/interrupt.h +++ b/libcpu/aarch64/cortex-a53/interrupt.h @@ -14,8 +14,6 @@ #include #include -#include "raspi.h" - #define INT_IRQ 0x00 #define INT_FIQ 0x01 diff --git a/libcpu/aarch64/cortex-a53/trap.c b/libcpu/aarch64/cortex-a53/trap.c index d43e0e4d6a..ca5b6ecd44 100644 --- a/libcpu/aarch64/cortex-a53/trap.c +++ b/libcpu/aarch64/cortex-a53/trap.c @@ -4,7 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 * * Date Author Notes - * 2018-10-06 ZhaoXiaowei the first version + * 2018-10-06 ZhaoXiaowei the first version + * 2021-07-31 GuEe-GUI Add gic_pl390 branch */ #include @@ -13,6 +14,10 @@ #include "interrupt.h" #include "armv8.h" +#ifdef BSP_USING_GIC390 +#include +#endif + extern struct rt_thread *rt_current_thread; #ifdef RT_USING_FINSH extern long list_thread(void); @@ -65,6 +70,8 @@ void rt_hw_trap_irq(void) uint32_t irq; rt_isr_handler_t isr_func; extern struct rt_irq_desc isr_table[]; + +#ifndef BSP_USING_GIC390 uint32_t value = 0; value = IRQ_PEND_BASIC & 0x3ff; #ifdef BSP_USING_CORETIMER @@ -100,6 +107,15 @@ void rt_hw_trap_irq(void) value &= 0x0f; irq = __rt_ffs(value) + 63; } +#else + irq = arm_gic_get_active_irq(); + + if (irq == GIC390_IRQ_NONE) + { + /* Spurious interrupt */ + return; + } +#endif /* get interrupt service routine */ isr_func = isr_table[irq].handler; @@ -113,11 +129,17 @@ void rt_hw_trap_irq(void) /* turn to interrupt service routine */ isr_func(irq, param); } +#ifndef BSP_USING_GIC390 } +#else + /* end of interrupt */ + arm_gic_ack(irq); +#endif } void rt_hw_trap_fiq(void) { +#ifndef BSP_USING_GIC390 void *param; uint32_t irq; rt_isr_handler_t isr_func; @@ -199,4 +221,5 @@ void rt_hw_trap_fiq(void) isr_func(irq, param); } } +#endif } diff --git a/src/memheap.c b/src/memheap.c index d77c95601e..d0801d721b 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -438,7 +438,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize) next_ptr->pool_ptr = heap; #ifdef RT_USING_MEMTRACE - rt_memset(next_ptr->owner_thread_name, ' ', sizeof(next_ptr->owner_thread_name)); + rt_memset((void *)next_ptr->owner_thread_name, ' ', sizeof(next_ptr->owner_thread_name)); #endif /* RT_USING_MEMTRACE */ next_ptr->prev = header_ptr; -- cgit v1.3.1 From 33a6700f160ce8c451b08287d12c94c9691556fc Mon Sep 17 00:00:00 2001 From: supperthomas <78900636@qq.com> Date: Sun, 15 Aug 2021 23:04:22 +0800 Subject: add the comment of irq.c --- src/irq.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/irq.c b/src/irq.c index 6ddcb3dd4a..ac43c45573 100644 --- a/src/irq.c +++ b/src/irq.c @@ -9,6 +9,7 @@ * 2006-05-03 Bernard add IRQ_DEBUG * 2016-08-09 ArdaFu add interrupt enter and leave hook. * 2018-11-22 Jesven rt_interrupt_get_nest function add disable irq + * 2021-08-15 Supperthomas fix the comment */ #include @@ -21,19 +22,26 @@ static void (*rt_interrupt_leave_hook)(void); /** * @ingroup Hook - * This function set a hook function when the system enter a interrupt - * + * + * @brief This function set a hook function when the system enter a interrupt + * * @note the hook function must be simple and never be blocked or suspend. + * + * @param hook The function point to be called */ void rt_interrupt_enter_sethook(void (*hook)(void)) { rt_interrupt_enter_hook = hook; } + /** * @ingroup Hook - * This function set a hook function when the system exit a interrupt. - * + * + * @brief This function set a hook function when the system exit a interrupt. + * * @note the hook function must be simple and never be blocked or suspend. + * + * @param hook The function point to be called */ void rt_interrupt_leave_sethook(void (*hook)(void)) { @@ -53,11 +61,12 @@ void rt_interrupt_leave_sethook(void (*hook)(void)) volatile rt_uint8_t rt_interrupt_nest = 0; #endif /* RT_USING_SMP */ + /** - * This function will be invoked by BSP, when enter interrupt service routine - * + * @brief This function will be invoked by BSP, when enter interrupt service routine + * * @note please don't invoke this routine in application - * + * * @see rt_interrupt_leave */ void rt_interrupt_enter(void) @@ -74,11 +83,12 @@ void rt_interrupt_enter(void) } RTM_EXPORT(rt_interrupt_enter); + /** - * This function will be invoked by BSP, when leave interrupt service routine - * + * @brief This function will be invoked by BSP, when leave interrupt service routine + * * @note please don't invoke this routine in application - * + * * @see rt_interrupt_enter */ void rt_interrupt_leave(void) @@ -95,13 +105,14 @@ void rt_interrupt_leave(void) } RTM_EXPORT(rt_interrupt_leave); + /** - * This function will return the nest of interrupt. - * + * @brief This function will return the nest of interrupt. + * * User application can invoke this function to get whether current * context is interrupt context. - * - * @return the number of nested interrupts. + * + * @return rt_uint8_t the number of nested interrupts. */ RT_WEAK rt_uint8_t rt_interrupt_get_nest(void) { -- cgit v1.3.1 From 30fd28a89a1a73428f9cd8086add95c4066d2857 Mon Sep 17 00:00:00 2001 From: supperthomas <78900636@qq.com> Date: Sun, 15 Aug 2021 23:04:35 +0800 Subject: add the comment of timer.c --- src/timer.c | 98 ++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/timer.c b/src/timer.c index 1c8e70fccc..18b7ac4d58 100644 --- a/src/timer.c +++ b/src/timer.c @@ -16,6 +16,7 @@ * 2012-12-15 Bernard fix the next timeout issue in soft timer * 2014-07-12 Bernard does not lock scheduler when invoking soft-timer * timeout function. + * 2021-08-15 supperthomas add the comment */ #include @@ -59,10 +60,10 @@ static void (*rt_timer_exit_hook)(struct rt_timer *timer); /**@{*/ /** - * This function will set a hook function, which will be invoked when enter - * timer timeout callback function. - * - * @param hook the hook function + * @brief This function will set a hook function on timer, + * which will be invoked when enter timer timeout callback function. + * + * @param hook the function point of timer */ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer)) { @@ -70,10 +71,10 @@ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer)) } /** - * This function will set a hook function, which will be invoked when exit - * timer timeout callback function. - * - * @param hook the hook function + * @brief This function will set a hook function, which will be + * invoked when exit * timer timeout callback function. + * + * @param hook the function point of timer */ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) { @@ -83,6 +84,20 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) /**@}*/ #endif /* RT_USING_HOOK */ + +/** + * @brief [internal] the init funtion of timer + * + * the internal called function of rt_timer_init + * + * @see rt_timer_init + * + * @param timer the static timer object + * @param timeout the timeout function + * @param parameter the parameter of timeout function + * @param time the tick of timer + * @param flag the flag of timer + */ static void _rt_timer_init(rt_timer_t timer, void (*timeout)(void *parameter), void *parameter, @@ -110,7 +125,13 @@ static void _rt_timer_init(rt_timer_t timer, } } -/* the fist timer always in the last row */ +/** + * @brief find the next emtpy timer + * + * @param timer_list the timer of the next timeout + * + * @return rt_tick_t the point of timer + */ static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[]) { struct rt_timer *timer; @@ -133,6 +154,11 @@ static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[]) return timeout_tick; } +/** + * @brief remove the timer + * + * @param timer the point of timer + */ rt_inline void _rt_timer_remove(rt_timer_t timer) { int i; @@ -144,6 +170,12 @@ rt_inline void _rt_timer_remove(rt_timer_t timer) } #if RT_DEBUG_TIMER +/** + * @brief the number of timer + * + * @param timer + * @return int the count + */ static int rt_timer_count_height(struct rt_timer *timer) { int i, cnt = 0; @@ -155,7 +187,11 @@ static int rt_timer_count_height(struct rt_timer *timer) } return cnt; } - +/** + * @brief dump the all timer information + * + * @param timer_heads the head of timer + */ void rt_timer_dump(rt_list_t timer_heads[]) { rt_list_t *list; @@ -180,9 +216,8 @@ void rt_timer_dump(rt_list_t timer_heads[]) /**@{*/ /** - * This function will initialize a timer, normally this function is used to - * initialize a static timer object. - * + * @brief This function will initialize a timer + * normally this function is used to initialize a static timer object. * @param timer the static timer object * @param name the name of timer * @param timeout the timeout function @@ -208,11 +243,10 @@ void rt_timer_init(rt_timer_t timer, RTM_EXPORT(rt_timer_init); /** - * This function will detach a timer from timer management. - * - * @param timer the static timer object - * - * @return the operation status, RT_EOK on OK; RT_ERROR on error + * @brief This function will detach a timer from timer management. + * + * @param timer the timer to be detached + * @return rt_err_t RT_EOK */ rt_err_t rt_timer_detach(rt_timer_t timer) { @@ -241,7 +275,7 @@ RTM_EXPORT(rt_timer_detach); #ifdef RT_USING_HEAP /** - * This function will create a timer + * @brief This function will create a timer * * @param name the name of timer * @param timeout the timeout function @@ -273,7 +307,7 @@ rt_timer_t rt_timer_create(const char *name, RTM_EXPORT(rt_timer_create); /** - * This function will delete a timer and release timer memory + * @brief This function will delete a timer and release timer memory * * @param timer the timer to be deleted * @@ -306,7 +340,7 @@ RTM_EXPORT(rt_timer_delete); #endif /* RT_USING_HEAP */ /** - * This function will start the timer + * @brief This function will start the timer * * @param timer the timer to be started * @@ -429,7 +463,7 @@ rt_err_t rt_timer_start(rt_timer_t timer) RTM_EXPORT(rt_timer_start); /** - * This function will stop the timer + * @brief This function will stop the timer * * @param timer the timer to be stopped * @@ -463,7 +497,7 @@ rt_err_t rt_timer_stop(rt_timer_t timer) RTM_EXPORT(rt_timer_stop); /** - * This function will get or set some options of the timer + * @brief This function will get or set some options of the timer * * @param timer the timer to be get or set * @param cmd the control command @@ -521,8 +555,8 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg) RTM_EXPORT(rt_timer_control); /** - * This function will check timer list, if a timeout event happens, the - * corresponding timeout function will be invoked. + * @brief This function will check timer list, if a timeout event happens, + * the corresponding timeout function will be invoked. * * @note this function shall be invoked in operating system timer interrupt. */ @@ -596,7 +630,7 @@ void rt_timer_check(void) } /** - * This function will return the next timeout tick in the system. + * @brief This function will return the next timeout tick in the system. * * @return the next timeout tick in the system */ @@ -607,7 +641,7 @@ rt_tick_t rt_timer_next_timeout_tick(void) #ifdef RT_USING_TIMER_SOFT /** - * This function will check software-timer list, if a timeout event happens, the + * @brief This function will check software-timer list, if a timeout event happens, the * corresponding timeout function will be invoked. */ void rt_soft_timer_check(void) @@ -684,7 +718,11 @@ void rt_soft_timer_check(void) RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check leave\n")); } -/* system timer thread entry */ +/** + * @brief system timer thread entry + * + * @param parameter + */ static void rt_thread_timer_entry(void *parameter) { rt_tick_t next_timeout; @@ -723,7 +761,7 @@ static void rt_thread_timer_entry(void *parameter) /** * @ingroup SystemInit * - * This function will initialize system timer + * @brief This function will initialize system timer */ void rt_system_timer_init(void) { @@ -738,7 +776,7 @@ void rt_system_timer_init(void) /** * @ingroup SystemInit * - * This function will initialize system timer thread + * @brief This function will initialize system timer thread */ void rt_system_timer_thread_init(void) { -- cgit v1.3.1 From 19bcf9ae32682697dc2beac7cc605f7338d44c2f Mon Sep 17 00:00:00 2001 From: supperthomas <78900636@qq.com> Date: Mon, 16 Aug 2021 22:07:46 +0800 Subject: add the formatted file --- src/irq.c | 24 ++++++++++++------------ src/timer.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/irq.c b/src/irq.c index ac43c45573..40c2aa5305 100644 --- a/src/irq.c +++ b/src/irq.c @@ -22,11 +22,11 @@ static void (*rt_interrupt_leave_hook)(void); /** * @ingroup Hook - * + * * @brief This function set a hook function when the system enter a interrupt - * + * * @note the hook function must be simple and never be blocked or suspend. - * + * * @param hook The function point to be called */ void rt_interrupt_enter_sethook(void (*hook)(void)) @@ -36,11 +36,11 @@ void rt_interrupt_enter_sethook(void (*hook)(void)) /** * @ingroup Hook - * + * * @brief This function set a hook function when the system exit a interrupt. - * + * * @note the hook function must be simple and never be blocked or suspend. - * + * * @param hook The function point to be called */ void rt_interrupt_leave_sethook(void (*hook)(void)) @@ -64,9 +64,9 @@ volatile rt_uint8_t rt_interrupt_nest = 0; /** * @brief This function will be invoked by BSP, when enter interrupt service routine - * + * * @note please don't invoke this routine in application - * + * * @see rt_interrupt_leave */ void rt_interrupt_enter(void) @@ -86,9 +86,9 @@ RTM_EXPORT(rt_interrupt_enter); /** * @brief This function will be invoked by BSP, when leave interrupt service routine - * + * * @note please don't invoke this routine in application - * + * * @see rt_interrupt_enter */ void rt_interrupt_leave(void) @@ -108,10 +108,10 @@ RTM_EXPORT(rt_interrupt_leave); /** * @brief This function will return the nest of interrupt. - * + * * User application can invoke this function to get whether current * context is interrupt context. - * + * * @return rt_uint8_t the number of nested interrupts. */ RT_WEAK rt_uint8_t rt_interrupt_get_nest(void) diff --git a/src/timer.c b/src/timer.c index 18b7ac4d58..44d0d4a7cc 100644 --- a/src/timer.c +++ b/src/timer.c @@ -16,7 +16,7 @@ * 2012-12-15 Bernard fix the next timeout issue in soft timer * 2014-07-12 Bernard does not lock scheduler when invoking soft-timer * timeout function. - * 2021-08-15 supperthomas add the comment + * 2021-08-15 supperthomas add the comment */ #include @@ -60,9 +60,9 @@ static void (*rt_timer_exit_hook)(struct rt_timer *timer); /**@{*/ /** - * @brief This function will set a hook function on timer, + * @brief This function will set a hook function on timer, * which will be invoked when enter timer timeout callback function. - * + * * @param hook the function point of timer */ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer)) @@ -71,9 +71,9 @@ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer)) } /** - * @brief This function will set a hook function, which will be + * @brief This function will set a hook function, which will be * invoked when exit * timer timeout callback function. - * + * * @param hook the function point of timer */ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) @@ -87,11 +87,11 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) /** * @brief [internal] the init funtion of timer - * + * * the internal called function of rt_timer_init - * + * * @see rt_timer_init - * + * * @param timer the static timer object * @param timeout the timeout function * @param parameter the parameter of timeout function @@ -127,9 +127,9 @@ static void _rt_timer_init(rt_timer_t timer, /** * @brief find the next emtpy timer - * + * * @param timer_list the timer of the next timeout - * + * * @return rt_tick_t the point of timer */ static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[]) @@ -155,8 +155,8 @@ static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[]) } /** - * @brief remove the timer - * + * @brief remove the timer + * * @param timer the point of timer */ rt_inline void _rt_timer_remove(rt_timer_t timer) @@ -172,8 +172,8 @@ rt_inline void _rt_timer_remove(rt_timer_t timer) #if RT_DEBUG_TIMER /** * @brief the number of timer - * - * @param timer + * + * @param timer * @return int the count */ static int rt_timer_count_height(struct rt_timer *timer) @@ -189,7 +189,7 @@ static int rt_timer_count_height(struct rt_timer *timer) } /** * @brief dump the all timer information - * + * * @param timer_heads the head of timer */ void rt_timer_dump(rt_list_t timer_heads[]) @@ -244,7 +244,7 @@ RTM_EXPORT(rt_timer_init); /** * @brief This function will detach a timer from timer management. - * + * * @param timer the timer to be detached * @return rt_err_t RT_EOK */ @@ -555,7 +555,7 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg) RTM_EXPORT(rt_timer_control); /** - * @brief This function will check timer list, if a timeout event happens, + * @brief This function will check timer list, if a timeout event happens, * the corresponding timeout function will be invoked. * * @note this function shall be invoked in operating system timer interrupt. @@ -719,9 +719,9 @@ void rt_soft_timer_check(void) } /** - * @brief system timer thread entry - * - * @param parameter + * @brief system timer thread entry + * + * @param parameter */ static void rt_thread_timer_entry(void *parameter) { -- cgit v1.3.1 From 247f21f998ccb61f3bdebfa3239c1714c81905f3 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 17 Aug 2021 05:56:39 -0400 Subject: [kernel][timer] 规范内部函数和变量命名 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/timer.c | 82 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/timer.c b/src/timer.c index 44d0d4a7cc..07647a55f9 100644 --- a/src/timer.c +++ b/src/timer.c @@ -23,7 +23,7 @@ #include /* hard timer list */ -static rt_list_t rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL]; +static rt_list_t _timer_list[RT_TIMER_SKIP_LIST_LEVEL]; #ifdef RT_USING_TIMER_SOFT @@ -39,12 +39,12 @@ static rt_list_t rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL]; #endif /* RT_TIMER_THREAD_PRIO */ /* soft timer status */ -static rt_uint8_t soft_timer_status = RT_SOFT_TIMER_IDLE; +static rt_uint8_t _soft_timer_status = RT_SOFT_TIMER_IDLE; /* soft timer list */ -static rt_list_t rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL]; -static struct rt_thread timer_thread; +static rt_list_t _soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL]; +static struct rt_thread _timer_thread; ALIGN(RT_ALIGN_SIZE) -static rt_uint8_t timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE]; +static rt_uint8_t _timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE]; #endif /* RT_USING_TIMER_SOFT */ #ifdef RT_USING_HOOK @@ -98,7 +98,7 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) * @param time the tick of timer * @param flag the flag of timer */ -static void _rt_timer_init(rt_timer_t timer, +static void _timer_init(rt_timer_t timer, void (*timeout)(void *parameter), void *parameter, rt_tick_t time, @@ -132,7 +132,7 @@ static void _rt_timer_init(rt_timer_t timer, * * @return rt_tick_t the point of timer */ -static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[]) +static rt_tick_t _timer_list_next_timeout(rt_list_t timer_list[]) { struct rt_timer *timer; register rt_base_t level; @@ -159,7 +159,7 @@ static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[]) * * @param timer the point of timer */ -rt_inline void _rt_timer_remove(rt_timer_t timer) +rt_inline void _timer_remove(rt_timer_t timer) { int i; @@ -176,7 +176,7 @@ rt_inline void _rt_timer_remove(rt_timer_t timer) * @param timer * @return int the count */ -static int rt_timer_count_height(struct rt_timer *timer) +static int _timer_count_height(struct rt_timer *timer) { int i, cnt = 0; @@ -203,7 +203,7 @@ void rt_timer_dump(rt_list_t timer_heads[]) struct rt_timer *timer = rt_list_entry(list, struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]); - rt_kprintf("%d", rt_timer_count_height(timer)); + rt_kprintf("%d", _timer_count_height(timer)); } rt_kprintf("\n"); } @@ -238,7 +238,7 @@ void rt_timer_init(rt_timer_t timer, /* timer object initialization */ rt_object_init(&(timer->parent), RT_Object_Class_Timer, name); - _rt_timer_init(timer, timeout, parameter, time, flag); + _timer_init(timer, timeout, parameter, time, flag); } RTM_EXPORT(rt_timer_init); @@ -260,7 +260,7 @@ rt_err_t rt_timer_detach(rt_timer_t timer) /* disable interrupt */ level = rt_hw_interrupt_disable(); - _rt_timer_remove(timer); + _timer_remove(timer); /* stop timer */ timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED; @@ -300,7 +300,7 @@ rt_timer_t rt_timer_create(const char *name, return RT_NULL; } - _rt_timer_init(timer, timeout, parameter, time, flag); + _timer_init(timer, timeout, parameter, time, flag); return timer; } @@ -325,7 +325,7 @@ rt_err_t rt_timer_delete(rt_timer_t timer) /* disable interrupt */ level = rt_hw_interrupt_disable(); - _rt_timer_remove(timer); + _timer_remove(timer); /* stop timer */ timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED; @@ -362,7 +362,7 @@ rt_err_t rt_timer_start(rt_timer_t timer) /* stop timer firstly */ level = rt_hw_interrupt_disable(); /* remove timer from list */ - _rt_timer_remove(timer); + _timer_remove(timer); /* change status of timer */ timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED; @@ -379,13 +379,13 @@ rt_err_t rt_timer_start(rt_timer_t timer) if (timer->parent.flag & RT_TIMER_FLAG_SOFT_TIMER) { /* insert timer to soft timer list */ - timer_list = rt_soft_timer_list; + timer_list = _soft_timer_list; } else #endif /* RT_USING_TIMER_SOFT */ { /* insert timer to system timer list */ - timer_list = rt_timer_list; + timer_list = _timer_list; } row_head[0] = &timer_list[0]; @@ -448,11 +448,11 @@ rt_err_t rt_timer_start(rt_timer_t timer) if (timer->parent.flag & RT_TIMER_FLAG_SOFT_TIMER) { /* check whether timer thread is ready */ - if ((soft_timer_status == RT_SOFT_TIMER_IDLE) && - ((timer_thread.stat & RT_THREAD_STAT_MASK) == RT_THREAD_SUSPEND)) + if ((_soft_timer_status == RT_SOFT_TIMER_IDLE) && + ((_timer_thread.stat & RT_THREAD_STAT_MASK) == RT_THREAD_SUSPEND)) { /* resume timer thread to check soft timer */ - rt_thread_resume(&timer_thread); + rt_thread_resume(&_timer_thread); rt_schedule(); } } @@ -485,7 +485,7 @@ rt_err_t rt_timer_stop(rt_timer_t timer) /* disable interrupt */ level = rt_hw_interrupt_disable(); - _rt_timer_remove(timer); + _timer_remove(timer); /* change status */ timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED; @@ -576,9 +576,9 @@ void rt_timer_check(void) /* disable interrupt */ level = rt_hw_interrupt_disable(); - while (!rt_list_isempty(&rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1])) + while (!rt_list_isempty(&_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1])) { - t = rt_list_entry(rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next, + t = rt_list_entry(_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next, struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]); /* @@ -590,7 +590,7 @@ void rt_timer_check(void) RT_OBJECT_HOOK_CALL(rt_timer_enter_hook, (t)); /* remove timer from timer list firstly */ - _rt_timer_remove(t); + _timer_remove(t); if (!(t->parent.flag & RT_TIMER_FLAG_PERIODIC)) { t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED; @@ -636,7 +636,7 @@ void rt_timer_check(void) */ rt_tick_t rt_timer_next_timeout_tick(void) { - return rt_timer_list_next_timeout(rt_timer_list); + return _timer_list_next_timeout(_timer_list); } #ifdef RT_USING_TIMER_SOFT @@ -658,9 +658,9 @@ void rt_soft_timer_check(void) /* disable interrupt */ level = rt_hw_interrupt_disable(); - while (!rt_list_isempty(&rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1])) + while (!rt_list_isempty(&_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1])) { - t = rt_list_entry(rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next, + t = rt_list_entry(_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next, struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]); current_tick = rt_tick_get(); @@ -674,7 +674,7 @@ void rt_soft_timer_check(void) RT_OBJECT_HOOK_CALL(rt_timer_enter_hook, (t)); /* remove timer from timer list firstly */ - _rt_timer_remove(t); + _timer_remove(t); if (!(t->parent.flag & RT_TIMER_FLAG_PERIODIC)) { t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED; @@ -682,7 +682,7 @@ void rt_soft_timer_check(void) /* add timer to temporary list */ rt_list_insert_after(&list, &(t->row[RT_TIMER_SKIP_LIST_LEVEL - 1])); - soft_timer_status = RT_SOFT_TIMER_BUSY; + _soft_timer_status = RT_SOFT_TIMER_BUSY; /* enable interrupt */ rt_hw_interrupt_enable(level); @@ -695,7 +695,7 @@ void rt_soft_timer_check(void) /* disable interrupt */ level = rt_hw_interrupt_disable(); - soft_timer_status = RT_SOFT_TIMER_IDLE; + _soft_timer_status = RT_SOFT_TIMER_IDLE; /* Check whether the timer object is detached or started again */ if (rt_list_isempty(&list)) { @@ -723,14 +723,14 @@ void rt_soft_timer_check(void) * * @param parameter */ -static void rt_thread_timer_entry(void *parameter) +static void _timer_thread_entry(void *parameter) { rt_tick_t next_timeout; while (1) { /* get the next timeout tick */ - next_timeout = rt_timer_list_next_timeout(rt_soft_timer_list); + next_timeout = _timer_list_next_timeout(_soft_timer_list); if (next_timeout == RT_TICK_MAX) { /* no software timer exist, suspend self. */ @@ -767,9 +767,9 @@ void rt_system_timer_init(void) { int i; - for (i = 0; i < sizeof(rt_timer_list) / sizeof(rt_timer_list[0]); i++) + for (i = 0; i < sizeof(_timer_list) / sizeof(_timer_list[0]); i++) { - rt_list_init(rt_timer_list + i); + rt_list_init(_timer_list + i); } } @@ -784,24 +784,24 @@ void rt_system_timer_thread_init(void) int i; for (i = 0; - i < sizeof(rt_soft_timer_list) / sizeof(rt_soft_timer_list[0]); + i < sizeof(_soft_timer_list) / sizeof(_soft_timer_list[0]); i++) { - rt_list_init(rt_soft_timer_list + i); + rt_list_init(_soft_timer_list + i); } /* start software timer thread */ - rt_thread_init(&timer_thread, + rt_thread_init(&_timer_thread, "timer", - rt_thread_timer_entry, + _timer_thread_entry, RT_NULL, - &timer_thread_stack[0], - sizeof(timer_thread_stack), + &_timer_thread_stack[0], + sizeof(_timer_thread_stack), RT_TIMER_THREAD_PRIO, 10); /* startup */ - rt_thread_startup(&timer_thread); + rt_thread_startup(&_timer_thread); #endif /* RT_USING_TIMER_SOFT */ } -- cgit v1.3.1 From 29828dc94fb55b1224dd0b7a31b388a11fe51870 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 25 Aug 2021 19:10:01 -0400 Subject: [finsh] finsh组件可以选择是否包含内置命令 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/allwinner_tina/libcpu/trap.c | 8 ++++---- bsp/bluetrum/ab32vg1-ab-prougen/board/board.c | 2 ++ bsp/dm365/platform/trap.c | 8 ++++---- bsp/imx6sx/cortex-a9/cpu/trap.c | 12 ++++++------ bsp/qemu-vexpress-gemini/cpu/trap.c | 12 ++++++------ bsp/raspberry-pi/raspi2/cpu/trap.c | 12 ++++++------ bsp/raspberry-pi/raspi3-32/cpu/trap.c | 12 ++++++------ components/finsh/Kconfig | 4 ++++ components/finsh/SConscript | 4 +++- components/finsh/msh.c | 22 ++++++++++++---------- libcpu/aarch64/cortex-a53/trap.c | 4 ++-- libcpu/aarch64/cortex-a72/trap.c | 4 ++-- libcpu/arm/am335x/trap.c | 8 ++++---- libcpu/arm/arm926/trap.c | 8 ++++---- libcpu/arm/cortex-a/trap.c | 12 ++++++------ libcpu/arm/cortex-m0/cpuport.c | 4 +++- libcpu/arm/cortex-m23/cpuport.c | 4 +++- libcpu/arm/cortex-m3/cpuport.c | 6 ++++-- libcpu/arm/cortex-m33/cpuport.c | 4 +++- libcpu/arm/cortex-m4/cpuport.c | 4 +++- libcpu/arm/cortex-m7/cpuport.c | 4 +++- libcpu/arm/cortex-r4/trap.c | 8 ++++---- libcpu/arm/realview-a8-vmm/trap.c | 12 ++++++------ libcpu/arm/s3c24x0/trap.c | 8 ++++---- libcpu/arm/zynqmp-r5/trap.c | 12 ++++++------ libcpu/risc-v/k210/interrupt.c | 4 +++- libcpu/risc-v/virt64/interrupt.c | 5 +++-- libcpu/rx/cpuport.c | 4 ++-- src/memheap.c | 6 ++++-- 29 files changed, 122 insertions(+), 95 deletions(-) (limited to 'src') diff --git a/bsp/allwinner_tina/libcpu/trap.c b/bsp/allwinner_tina/libcpu/trap.c index daf3501c68..66f3e2ecb6 100644 --- a/bsp/allwinner_tina/libcpu/trap.c +++ b/bsp/allwinner_tina/libcpu/trap.c @@ -15,7 +15,7 @@ #define INT_FIQ 0x01 extern struct rt_thread *rt_current_thread; -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -89,7 +89,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_kprintf("undefined instruction\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -141,7 +141,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_kprintf("prefetch abort\n"); rt_kprintf("thread - %s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -169,7 +169,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_kprintf("data abort\n"); rt_kprintf("thread - %s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c b/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c index f68ec1bba8..92753a361c 100644 --- a/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c +++ b/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c @@ -209,7 +209,9 @@ void rt_hw_console_output(const char *str) RT_SECTION(".irq.err") void exception_isr(void) { +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); +#endif sys_error_hook(1); #ifdef RT_USING_CONSOLE diff --git a/bsp/dm365/platform/trap.c b/bsp/dm365/platform/trap.c index 5c5f0272b3..c1636a5ab0 100644 --- a/bsp/dm365/platform/trap.c +++ b/bsp/dm365/platform/trap.c @@ -20,7 +20,7 @@ /*@{*/ extern struct rt_thread *rt_current_thread; -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -56,7 +56,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_kprintf("undefined instruction\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -94,7 +94,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_kprintf("prefetch abort\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -130,7 +130,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_kprintf("data abort\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/bsp/imx6sx/cortex-a9/cpu/trap.c b/bsp/imx6sx/cortex-a9/cpu/trap.c index f3b2c26e6d..451a2f40db 100644 --- a/bsp/imx6sx/cortex-a9/cpu/trap.c +++ b/bsp/imx6sx/cortex-a9/cpu/trap.c @@ -17,7 +17,7 @@ #include "gic.h" extern struct rt_thread *rt_current_thread; -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -49,7 +49,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -68,7 +68,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -86,7 +86,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -104,7 +104,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -121,7 +121,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/bsp/qemu-vexpress-gemini/cpu/trap.c b/bsp/qemu-vexpress-gemini/cpu/trap.c index c6ca45aee7..319dba851c 100644 --- a/bsp/qemu-vexpress-gemini/cpu/trap.c +++ b/bsp/qemu-vexpress-gemini/cpu/trap.c @@ -21,7 +21,7 @@ #include "gic.h" extern struct rt_thread *rt_current_thread; -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -53,7 +53,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -72,7 +72,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -90,7 +90,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -108,7 +108,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -125,7 +125,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/bsp/raspberry-pi/raspi2/cpu/trap.c b/bsp/raspberry-pi/raspi2/cpu/trap.c index 8a1eb33c65..a8c3d5be0e 100644 --- a/bsp/raspberry-pi/raspi2/cpu/trap.c +++ b/bsp/raspberry-pi/raspi2/cpu/trap.c @@ -15,7 +15,7 @@ #include "armv7.h" extern struct rt_thread *rt_current_thread; -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -47,7 +47,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -66,7 +66,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -84,7 +84,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -102,7 +102,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -119,7 +119,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/bsp/raspberry-pi/raspi3-32/cpu/trap.c b/bsp/raspberry-pi/raspi3-32/cpu/trap.c index b9fa6bb1c5..8a9cf9b133 100644 --- a/bsp/raspberry-pi/raspi3-32/cpu/trap.c +++ b/bsp/raspberry-pi/raspi3-32/cpu/trap.c @@ -18,7 +18,7 @@ #include "armv7.h" extern struct rt_thread *rt_current_thread; -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -52,7 +52,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -71,7 +71,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -89,7 +89,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -107,7 +107,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -124,7 +124,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/components/finsh/Kconfig b/components/finsh/Kconfig index 637b1a30c1..4c5740929e 100644 --- a/components/finsh/Kconfig +++ b/components/finsh/Kconfig @@ -31,6 +31,10 @@ config FINSH_USING_DESCRIPTION bool "Keeping description in symbol table" default y +config FINSH_USING_BUILT_IN_COMMANDS + bool "Enable built-in commands, such as list_thread" + default y + config FINSH_ECHO_DISABLE_DEFAULT bool "Disable the echo mode in default" default n diff --git a/components/finsh/SConscript b/components/finsh/SConscript index 1a6d7c8fc7..bacd25ea12 100644 --- a/components/finsh/SConscript +++ b/components/finsh/SConscript @@ -3,10 +3,12 @@ from building import * cwd = GetCurrentDir() src = Split(''' shell.c -cmd.c msh.c ''') +if GetDepend('FINSH_USING_BUILT_IN_COMMANDS'): + src += ['cmd.c'] + if GetDepend('RT_USING_DFS'): src += ['msh_file.c'] diff --git a/components/finsh/msh.c b/components/finsh/msh.c index 899a6567b1..a0680e2ce9 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -54,6 +54,7 @@ int msh_help(int argc, char **argv) } MSH_CMD_EXPORT_ALIAS(msh_help, help, RT - Thread shell help.); +#ifdef FINSH_USING_BUILT_IN_COMMANDS int cmd_ps(int argc, char **argv) { extern long list_thread(void); @@ -77,13 +78,14 @@ int cmd_free(int argc, char **argv) #ifdef RT_USING_MEMHEAP_AS_HEAP list_memheap(); -#else +#else /* RT_USING_MEMHEAP_AS_HEAP */ list_mem(); #endif return 0; } MSH_CMD_EXPORT_ALIAS(cmd_free, free, Show the memory usage in the system.); -#endif +#endif /* RT_USING_HEAP */ +#endif /* FINSH_USING_BUILT_IN_COMMANDS */ static int msh_split(char *cmd, rt_size_t length, char *argv[FINSH_ARG_MAX]) { @@ -270,7 +272,7 @@ int system(const char *command) return ret; } RTM_EXPORT(system); -#endif +#endif /* defined(RT_USING_MODULE) && defined(RT_USING_DFS) */ static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp) { @@ -339,7 +341,7 @@ static int _msh_exec_lwp(char *cmd, rt_size_t length) return 0; } -#endif +#endif /* defined(RT_USING_LWP) && defined(RT_USING_DFS) */ int msh_exec(char *cmd, rt_size_t length) { @@ -376,15 +378,15 @@ int msh_exec(char *cmd, rt_size_t length) { return 0; } -#endif +#endif /* RT_USING_MODULE */ #ifdef RT_USING_LWP if (_msh_exec_lwp(cmd, length) == 0) { return 0; } -#endif -#endif +#endif /* RT_USING_LWP */ +#endif /* RT_USING_DFS */ /* truncate the cmd at the first space. */ { @@ -534,7 +536,7 @@ void msh_auto_complete_path(char *path) closedir(dir); rt_free(full_path); } -#endif +#endif /* RT_USING_DFS */ void msh_auto_complete(char *prefix) { @@ -575,9 +577,9 @@ void msh_auto_complete(char *prefix) { msh_auto_complete_path(ptr); } -#endif +#endif /* RT_USING_MODULE */ } -#endif +#endif /* RT_USING_DFS */ /* checks in internal command */ { diff --git a/libcpu/aarch64/cortex-a53/trap.c b/libcpu/aarch64/cortex-a53/trap.c index ca5b6ecd44..4837d445d4 100644 --- a/libcpu/aarch64/cortex-a53/trap.c +++ b/libcpu/aarch64/cortex-a53/trap.c @@ -19,7 +19,7 @@ #endif extern struct rt_thread *rt_current_thread; -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -55,7 +55,7 @@ void rt_hw_trap_error(struct rt_hw_exp_stack *regs) { rt_kprintf("error exception:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/aarch64/cortex-a72/trap.c b/libcpu/aarch64/cortex-a72/trap.c index bd76f7717b..b89a2cca70 100644 --- a/libcpu/aarch64/cortex-a72/trap.c +++ b/libcpu/aarch64/cortex-a72/trap.c @@ -14,7 +14,7 @@ #include "armv8.h" extern struct rt_thread *rt_current_thread; -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -50,7 +50,7 @@ void rt_hw_trap_error(struct rt_hw_exp_stack *regs) { rt_kprintf("error exception:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/am335x/trap.c b/libcpu/arm/am335x/trap.c index 7c73ce93d3..94da0063d0 100644 --- a/libcpu/arm/am335x/trap.c +++ b/libcpu/arm/am335x/trap.c @@ -24,7 +24,7 @@ /*@{*/ extern struct rt_thread *rt_current_thread; -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -67,7 +67,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_kprintf("undefined instruction\n"); rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -105,7 +105,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_kprintf("prefetch abort\n"); rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -133,7 +133,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_kprintf("data abort\n"); rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/arm926/trap.c b/libcpu/arm/arm926/trap.c index c364b2addd..5751636259 100644 --- a/libcpu/arm/arm926/trap.c +++ b/libcpu/arm/arm926/trap.c @@ -16,7 +16,7 @@ #define INT_FIQ 0x01 extern struct rt_thread *rt_current_thread; -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -90,7 +90,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_kprintf("undefined instruction\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -142,7 +142,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_kprintf("prefetch abort\n"); rt_kprintf("thread - %s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -170,7 +170,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_kprintf("data abort\n"); rt_kprintf("thread - %s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/cortex-a/trap.c b/libcpu/arm/cortex-a/trap.c index b3efe31a64..a215374348 100644 --- a/libcpu/arm/cortex-a/trap.c +++ b/libcpu/arm/cortex-a/trap.c @@ -15,7 +15,7 @@ #include "armv7.h" #include "interrupt.h" -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -89,7 +89,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -115,7 +115,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -140,7 +140,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -165,7 +165,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -189,7 +189,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/cortex-m0/cpuport.c b/libcpu/arm/cortex-m0/cpuport.c index 49e15bf339..d6c9be11cf 100644 --- a/libcpu/arm/cortex-m0/cpuport.c +++ b/libcpu/arm/cortex-m0/cpuport.c @@ -90,7 +90,9 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, return stk; } +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); +#endif extern rt_thread_t rt_current_thread; /** * fault exception handling @@ -108,7 +110,7 @@ void rt_hw_hard_fault_exception(struct exception_stack_frame *contex) rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif diff --git a/libcpu/arm/cortex-m23/cpuport.c b/libcpu/arm/cortex-m23/cpuport.c index d8f9b12c2c..4619534c05 100644 --- a/libcpu/arm/cortex-m23/cpuport.c +++ b/libcpu/arm/cortex-m23/cpuport.c @@ -91,7 +91,9 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, return stk; } +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); +#endif extern rt_thread_t rt_current_thread; /** * fault exception handling @@ -109,7 +111,7 @@ void rt_hw_hard_fault_exception(struct exception_stack_frame *contex) rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif diff --git a/libcpu/arm/cortex-m3/cpuport.c b/libcpu/arm/cortex-m3/cpuport.c index 19c33bd7c9..02f84564d5 100644 --- a/libcpu/arm/cortex-m3/cpuport.c +++ b/libcpu/arm/cortex-m3/cpuport.c @@ -291,7 +291,9 @@ struct exception_info */ void rt_hw_hard_fault_exception(struct exception_info * exception_info) { +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); +#endif struct stack_frame* context = &exception_info->stack_frame; if (rt_exception_hook != RT_NULL) @@ -325,9 +327,9 @@ void rt_hw_hard_fault_exception(struct exception_info * exception_info) { rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); -#endif /* RT_USING_FINSH */ +#endif } else { diff --git a/libcpu/arm/cortex-m33/cpuport.c b/libcpu/arm/cortex-m33/cpuport.c index 928689d9c8..8f73985f87 100644 --- a/libcpu/arm/cortex-m33/cpuport.c +++ b/libcpu/arm/cortex-m33/cpuport.c @@ -373,7 +373,9 @@ struct exception_info void rt_hw_hard_fault_exception(struct exception_info *exception_info) { +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); +#endif struct exception_stack_frame *exception_stack = &exception_info->stack_frame.exception_stack_frame; struct stack_frame *context = &exception_info->stack_frame; @@ -407,7 +409,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) { rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif } diff --git a/libcpu/arm/cortex-m4/cpuport.c b/libcpu/arm/cortex-m4/cpuport.c index dbc42d21cf..8dfcbe9cc4 100644 --- a/libcpu/arm/cortex-m4/cpuport.c +++ b/libcpu/arm/cortex-m4/cpuport.c @@ -370,7 +370,9 @@ struct exception_info void rt_hw_hard_fault_exception(struct exception_info *exception_info) { +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); +#endif struct exception_stack_frame *exception_stack = &exception_info->stack_frame.exception_stack_frame; struct stack_frame *context = &exception_info->stack_frame; @@ -404,7 +406,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) { rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif } diff --git a/libcpu/arm/cortex-m7/cpuport.c b/libcpu/arm/cortex-m7/cpuport.c index dbc42d21cf..8dfcbe9cc4 100644 --- a/libcpu/arm/cortex-m7/cpuport.c +++ b/libcpu/arm/cortex-m7/cpuport.c @@ -370,7 +370,9 @@ struct exception_info void rt_hw_hard_fault_exception(struct exception_info *exception_info) { +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); +#endif struct exception_stack_frame *exception_stack = &exception_info->stack_frame.exception_stack_frame; struct stack_frame *context = &exception_info->stack_frame; @@ -404,7 +406,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) { rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif } diff --git a/libcpu/arm/cortex-r4/trap.c b/libcpu/arm/cortex-r4/trap.c index e6c62390c1..9cb24026f0 100644 --- a/libcpu/arm/cortex-r4/trap.c +++ b/libcpu/arm/cortex-r4/trap.c @@ -67,7 +67,7 @@ void rt_hw_trap_svc(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -85,7 +85,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -103,7 +103,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("Data Abort "); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -120,7 +120,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("Reserved trap\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/realview-a8-vmm/trap.c b/libcpu/arm/realview-a8-vmm/trap.c index c6ca45aee7..319dba851c 100644 --- a/libcpu/arm/realview-a8-vmm/trap.c +++ b/libcpu/arm/realview-a8-vmm/trap.c @@ -21,7 +21,7 @@ #include "gic.h" extern struct rt_thread *rt_current_thread; -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -53,7 +53,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -72,7 +72,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -90,7 +90,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -108,7 +108,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -125,7 +125,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/s3c24x0/trap.c b/libcpu/arm/s3c24x0/trap.c index f0e8a7097a..29190dce4e 100644 --- a/libcpu/arm/s3c24x0/trap.c +++ b/libcpu/arm/s3c24x0/trap.c @@ -22,7 +22,7 @@ /*@{*/ extern struct rt_thread *rt_current_thread; -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -58,7 +58,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_kprintf("undefined instruction\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -96,7 +96,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_kprintf("prefetch abort\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -117,7 +117,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_kprintf("data abort\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/zynqmp-r5/trap.c b/libcpu/arm/zynqmp-r5/trap.c index 64d4cbf5e8..9ec5d1a568 100644 --- a/libcpu/arm/zynqmp-r5/trap.c +++ b/libcpu/arm/zynqmp-r5/trap.c @@ -16,7 +16,7 @@ #include "armv7.h" #include "interrupt.h" -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -48,7 +48,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -67,7 +67,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -85,7 +85,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -103,7 +103,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -120,7 +120,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/risc-v/k210/interrupt.c b/libcpu/risc-v/k210/interrupt.c index 934acbdbf8..98cbef5401 100644 --- a/libcpu/risc-v/k210/interrupt.c +++ b/libcpu/risc-v/k210/interrupt.c @@ -335,7 +335,9 @@ uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc, uintptr_t * sp) else { rt_thread_t tid; +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(); +#endif rt_hw_interrupt_disable(); @@ -387,7 +389,7 @@ uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc, uintptr_t * sp) print_stack_frame(sp); rt_kprintf("exception pc => 0x%08x\n", epc); rt_kprintf("current thread: %.*s\n", RT_NAME_MAX, tid->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif while(1); diff --git a/libcpu/risc-v/virt64/interrupt.c b/libcpu/risc-v/virt64/interrupt.c index 7916be8f6f..4b109d71ad 100644 --- a/libcpu/risc-v/virt64/interrupt.c +++ b/libcpu/risc-v/virt64/interrupt.c @@ -212,8 +212,9 @@ void handle_trap(rt_size_t xcause,rt_size_t xtval,rt_size_t xepc,struct rt_hw_st else { rt_thread_t tid; +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern long list_thread(); - +#endif rt_hw_interrupt_disable(); rt_kprintf("xcause = %08x,xtval = %08x,xepc = %08x\n", xcause, xtval, xepc); @@ -265,7 +266,7 @@ void handle_trap(rt_size_t xcause,rt_size_t xtval,rt_size_t xepc,struct rt_hw_st dump_regs(sp); rt_kprintf("exception pc => 0x%08x\n", xepc); rt_kprintf("current thread: %.*s\n", RT_NAME_MAX, tid->name); -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif while(1); diff --git a/libcpu/rx/cpuport.c b/libcpu/rx/cpuport.c index 00f9e26ba9..9f737a50e7 100644 --- a/libcpu/rx/cpuport.c +++ b/libcpu/rx/cpuport.c @@ -94,7 +94,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter, return(rt_uint8_t *)stack_frame; } -#ifdef RT_USING_FINSH +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern void list_thread(void); #endif extern rt_thread_t rt_current_thread; @@ -130,7 +130,7 @@ void rt_hw_hard_fault_exception(struct stack_frame* exception_contex) rt_kprintf("acclo: 0x%08x\n", exception_contex->ACCLO); } rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name); - #ifdef RT_USING_FINSH + #if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif while (1); diff --git a/src/memheap.c b/src/memheap.c index d0801d721b..1f62c3afb0 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -730,13 +730,15 @@ int memheaptrace(void) if (count > 0) { int index; +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) extern int list_memheap(void); +#endif heaps = (struct rt_memheap **)rt_malloc(sizeof(struct rt_memheap *) * count); if (heaps == RT_NULL) return 0; - +#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) list_memheap(); - +#endif rt_kprintf("memheap header size: %d\n", RT_MEMHEAP_SIZE); count = rt_object_get_pointers(RT_Object_Class_MemHeap, (rt_object_t *)heaps, count); for (index = 0; index < count; index++) -- cgit v1.3.1 From 320c44adf81c7405a6b791fc890d7c21a7dbd756 Mon Sep 17 00:00:00 2001 From: supperthomas <78900636@qq.com> Date: Sat, 28 Aug 2021 23:31:35 +0800 Subject: add the fixed comment --- src/irq.c | 8 ++--- src/timer.c | 112 ++++++++++++++++++++++++++++++++++-------------------------- 2 files changed, 68 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/irq.c b/src/irq.c index 40c2aa5305..81c972c955 100644 --- a/src/irq.c +++ b/src/irq.c @@ -25,7 +25,7 @@ static void (*rt_interrupt_leave_hook)(void); * * @brief This function set a hook function when the system enter a interrupt * - * @note the hook function must be simple and never be blocked or suspend. + * @note The hook function must be simple and never be blocked or suspend. * * @param hook The function point to be called */ @@ -39,7 +39,7 @@ void rt_interrupt_enter_sethook(void (*hook)(void)) * * @brief This function set a hook function when the system exit a interrupt. * - * @note the hook function must be simple and never be blocked or suspend. + * @note The hook function must be simple and never be blocked or suspend. * * @param hook The function point to be called */ @@ -65,7 +65,7 @@ volatile rt_uint8_t rt_interrupt_nest = 0; /** * @brief This function will be invoked by BSP, when enter interrupt service routine * - * @note please don't invoke this routine in application + * @note Please don't invoke this routine in application * * @see rt_interrupt_leave */ @@ -87,7 +87,7 @@ RTM_EXPORT(rt_interrupt_enter); /** * @brief This function will be invoked by BSP, when leave interrupt service routine * - * @note please don't invoke this routine in application + * @note Please don't invoke this routine in application * * @see rt_interrupt_enter */ diff --git a/src/timer.c b/src/timer.c index 07647a55f9..5c90d34675 100644 --- a/src/timer.c +++ b/src/timer.c @@ -61,9 +61,9 @@ static void (*rt_timer_exit_hook)(struct rt_timer *timer); /** * @brief This function will set a hook function on timer, - * which will be invoked when enter timer timeout callback function. + * which will be invoked when enter timer timeout callback function. * - * @param hook the function point of timer + * @param hook The function point of timer */ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer)) { @@ -72,9 +72,9 @@ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer)) /** * @brief This function will set a hook function, which will be - * invoked when exit * timer timeout callback function. + * invoked when exit timer timeout callback function. * - * @param hook the function point of timer + * @param hook The function point of timer */ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) { @@ -86,17 +86,21 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) /** - * @brief [internal] the init funtion of timer + * @brief [internal] The init funtion of timer * - * the internal called function of rt_timer_init + * The internal called function of rt_timer_init * * @see rt_timer_init * - * @param timer the static timer object - * @param timeout the timeout function - * @param parameter the parameter of timeout function - * @param time the tick of timer - * @param flag the flag of timer + * @param timer The static timer object + * + * @param timeout The timeout function + * + * @param parameter The parameter of timeout function + * + * @param time The tick of timer + * + * @param flag The flag of timer */ static void _timer_init(rt_timer_t timer, void (*timeout)(void *parameter), @@ -126,11 +130,11 @@ static void _timer_init(rt_timer_t timer, } /** - * @brief find the next emtpy timer + * @brief Find the next emtpy timer ticks * - * @param timer_list the timer of the next timeout + * @param timer_list The timer of the next timeout * - * @return rt_tick_t the point of timer + * @return rt_tick_t The next timer's ticks */ static rt_tick_t _timer_list_next_timeout(rt_list_t timer_list[]) { @@ -155,9 +159,9 @@ static rt_tick_t _timer_list_next_timeout(rt_list_t timer_list[]) } /** - * @brief remove the timer + * @brief Remove the timer * - * @param timer the point of timer + * @param timer The point of the timer */ rt_inline void _timer_remove(rt_timer_t timer) { @@ -171,10 +175,11 @@ rt_inline void _timer_remove(rt_timer_t timer) #if RT_DEBUG_TIMER /** - * @brief the number of timer + * @brief The number of timer * - * @param timer - * @return int the count + * @param timer the head of timer + * + * @return int the count of timer */ static int _timer_count_height(struct rt_timer *timer) { @@ -218,12 +223,18 @@ void rt_timer_dump(rt_list_t timer_heads[]) /** * @brief This function will initialize a timer * normally this function is used to initialize a static timer object. - * @param timer the static timer object - * @param name the name of timer - * @param timeout the timeout function - * @param parameter the parameter of timeout function - * @param time the tick of timer - * @param flag the flag of timer + * + * @param timer The static timer object + * + * @param name The name of timer + * + * @param timeout The timeout function + * + * @param parameter The parameter of timeout function + * + * @param time The tick of timer + * + * @param flag The flag of timer */ void rt_timer_init(rt_timer_t timer, const char *name, @@ -245,8 +256,9 @@ RTM_EXPORT(rt_timer_init); /** * @brief This function will detach a timer from timer management. * - * @param timer the timer to be detached - * @return rt_err_t RT_EOK + * @param timer The timer to be detached + * + * @return rt_err_t The status of detach */ rt_err_t rt_timer_detach(rt_timer_t timer) { @@ -277,13 +289,17 @@ RTM_EXPORT(rt_timer_detach); /** * @brief This function will create a timer * - * @param name the name of timer - * @param timeout the timeout function - * @param parameter the parameter of timeout function - * @param time the tick of timer - * @param flag the flag of timer + * @param name The name of timer + * + * @param timeout The timeout function + * + * @param parameter The parameter of timeout function + * + * @param time The tick of timer + * + * @param flag The flag of timer * - * @return the created timer object + * @return The created timer object */ rt_timer_t rt_timer_create(const char *name, void (*timeout)(void *parameter), @@ -309,9 +325,9 @@ RTM_EXPORT(rt_timer_create); /** * @brief This function will delete a timer and release timer memory * - * @param timer the timer to be deleted + * @param timer The timer to be deleted * - * @return the operation status, RT_EOK on OK; RT_ERROR on error + * @return rt_err_t The operation status, RT_EOK on OK; RT_ERROR on error */ rt_err_t rt_timer_delete(rt_timer_t timer) { @@ -342,9 +358,9 @@ RTM_EXPORT(rt_timer_delete); /** * @brief This function will start the timer * - * @param timer the timer to be started + * @param timer The timer to be started * - * @return the operation status, RT_EOK on OK, -RT_ERROR on error + * @return The operation status, RT_EOK on OK, -RT_ERROR on error */ rt_err_t rt_timer_start(rt_timer_t timer) { @@ -465,9 +481,9 @@ RTM_EXPORT(rt_timer_start); /** * @brief This function will stop the timer * - * @param timer the timer to be stopped + * @param timer The timer to be stopped * - * @return the operation status, RT_EOK on OK, -RT_ERROR on error + * @return The operation status, RT_EOK on OK, -RT_ERROR on error */ rt_err_t rt_timer_stop(rt_timer_t timer) { @@ -499,11 +515,11 @@ RTM_EXPORT(rt_timer_stop); /** * @brief This function will get or set some options of the timer * - * @param timer the timer to be get or set - * @param cmd the control command - * @param arg the argument + * @param timer The timer to be get or set + * @param cmd The control command + * @param arg The argument * - * @return RT_EOK + * @return rt_err_t the statu of control */ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg) { @@ -558,7 +574,7 @@ RTM_EXPORT(rt_timer_control); * @brief This function will check timer list, if a timeout event happens, * the corresponding timeout function will be invoked. * - * @note this function shall be invoked in operating system timer interrupt. + * @note This function shall be invoked in operating system timer interrupt. */ void rt_timer_check(void) { @@ -632,7 +648,7 @@ void rt_timer_check(void) /** * @brief This function will return the next timeout tick in the system. * - * @return the next timeout tick in the system + * @return The next timeout tick in the system */ rt_tick_t rt_timer_next_timeout_tick(void) { @@ -642,7 +658,7 @@ rt_tick_t rt_timer_next_timeout_tick(void) #ifdef RT_USING_TIMER_SOFT /** * @brief This function will check software-timer list, if a timeout event happens, the - * corresponding timeout function will be invoked. + * corresponding timeout function will be invoked. */ void rt_soft_timer_check(void) { @@ -719,9 +735,9 @@ void rt_soft_timer_check(void) } /** - * @brief system timer thread entry + * @brief System timer thread entry * - * @param parameter + * @param parameter The arg of the thread */ static void _timer_thread_entry(void *parameter) { -- cgit v1.3.1 From 1997113fbca8894dcaad75a6fa4e7b42396a4031 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 28 Aug 2021 16:48:08 -0400 Subject: FINSH_USING_BUILT_IN_COMMANDS改MSH_USING_BUILT_IN_COMMANDS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/allwinner_tina/libcpu/trap.c | 8 ++++---- bsp/bluetrum/ab32vg1-ab-prougen/board/board.c | 2 +- bsp/dm365/platform/trap.c | 8 ++++---- bsp/imx6sx/cortex-a9/cpu/trap.c | 12 ++++++------ bsp/qemu-vexpress-gemini/cpu/trap.c | 12 ++++++------ bsp/raspberry-pi/raspi2/cpu/trap.c | 12 ++++++------ bsp/raspberry-pi/raspi3-32/cpu/trap.c | 12 ++++++------ components/finsh/Kconfig | 2 +- components/finsh/SConscript | 2 +- components/finsh/msh.c | 4 ++-- libcpu/aarch64/cortex-a53/trap.c | 4 ++-- libcpu/aarch64/cortex-a72/trap.c | 4 ++-- libcpu/arm/am335x/trap.c | 8 ++++---- libcpu/arm/arm926/trap.c | 8 ++++---- libcpu/arm/cortex-a/trap.c | 12 ++++++------ libcpu/arm/cortex-m0/cpuport.c | 4 ++-- libcpu/arm/cortex-m23/cpuport.c | 4 ++-- libcpu/arm/cortex-m3/cpuport.c | 4 ++-- libcpu/arm/cortex-m33/cpuport.c | 4 ++-- libcpu/arm/cortex-m4/cpuport.c | 4 ++-- libcpu/arm/cortex-m7/cpuport.c | 4 ++-- libcpu/arm/cortex-r4/trap.c | 8 ++++---- libcpu/arm/realview-a8-vmm/trap.c | 12 ++++++------ libcpu/arm/s3c24x0/trap.c | 8 ++++---- libcpu/arm/zynqmp-r5/trap.c | 12 ++++++------ libcpu/risc-v/k210/interrupt.c | 4 ++-- libcpu/risc-v/virt64/interrupt.c | 4 ++-- libcpu/rx/cpuport.c | 4 ++-- src/memheap.c | 4 ++-- 29 files changed, 95 insertions(+), 95 deletions(-) (limited to 'src') diff --git a/bsp/allwinner_tina/libcpu/trap.c b/bsp/allwinner_tina/libcpu/trap.c index 66f3e2ecb6..2017f33759 100644 --- a/bsp/allwinner_tina/libcpu/trap.c +++ b/bsp/allwinner_tina/libcpu/trap.c @@ -15,7 +15,7 @@ #define INT_FIQ 0x01 extern struct rt_thread *rt_current_thread; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -89,7 +89,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_kprintf("undefined instruction\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -141,7 +141,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_kprintf("prefetch abort\n"); rt_kprintf("thread - %s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -169,7 +169,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_kprintf("data abort\n"); rt_kprintf("thread - %s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c b/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c index 92753a361c..32714f6a4d 100644 --- a/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c +++ b/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c @@ -209,7 +209,7 @@ void rt_hw_console_output(const char *str) RT_SECTION(".irq.err") void exception_isr(void) { -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif sys_error_hook(1); diff --git a/bsp/dm365/platform/trap.c b/bsp/dm365/platform/trap.c index c1636a5ab0..68b834b9d8 100644 --- a/bsp/dm365/platform/trap.c +++ b/bsp/dm365/platform/trap.c @@ -20,7 +20,7 @@ /*@{*/ extern struct rt_thread *rt_current_thread; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -56,7 +56,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_kprintf("undefined instruction\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -94,7 +94,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_kprintf("prefetch abort\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -130,7 +130,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_kprintf("data abort\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/bsp/imx6sx/cortex-a9/cpu/trap.c b/bsp/imx6sx/cortex-a9/cpu/trap.c index 451a2f40db..4625d1accf 100644 --- a/bsp/imx6sx/cortex-a9/cpu/trap.c +++ b/bsp/imx6sx/cortex-a9/cpu/trap.c @@ -17,7 +17,7 @@ #include "gic.h" extern struct rt_thread *rt_current_thread; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -49,7 +49,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -68,7 +68,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -86,7 +86,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -104,7 +104,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -121,7 +121,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/bsp/qemu-vexpress-gemini/cpu/trap.c b/bsp/qemu-vexpress-gemini/cpu/trap.c index 319dba851c..86eceb39cf 100644 --- a/bsp/qemu-vexpress-gemini/cpu/trap.c +++ b/bsp/qemu-vexpress-gemini/cpu/trap.c @@ -21,7 +21,7 @@ #include "gic.h" extern struct rt_thread *rt_current_thread; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -53,7 +53,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -72,7 +72,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -90,7 +90,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -108,7 +108,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -125,7 +125,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/bsp/raspberry-pi/raspi2/cpu/trap.c b/bsp/raspberry-pi/raspi2/cpu/trap.c index a8c3d5be0e..ef2f141546 100644 --- a/bsp/raspberry-pi/raspi2/cpu/trap.c +++ b/bsp/raspberry-pi/raspi2/cpu/trap.c @@ -15,7 +15,7 @@ #include "armv7.h" extern struct rt_thread *rt_current_thread; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -47,7 +47,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -66,7 +66,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -84,7 +84,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -102,7 +102,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -119,7 +119,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/bsp/raspberry-pi/raspi3-32/cpu/trap.c b/bsp/raspberry-pi/raspi3-32/cpu/trap.c index 8a9cf9b133..3fcd16481e 100644 --- a/bsp/raspberry-pi/raspi3-32/cpu/trap.c +++ b/bsp/raspberry-pi/raspi3-32/cpu/trap.c @@ -18,7 +18,7 @@ #include "armv7.h" extern struct rt_thread *rt_current_thread; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -52,7 +52,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -71,7 +71,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -89,7 +89,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -107,7 +107,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -124,7 +124,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/components/finsh/Kconfig b/components/finsh/Kconfig index 1a980b06aa..cf4e673c75 100644 --- a/components/finsh/Kconfig +++ b/components/finsh/Kconfig @@ -41,7 +41,7 @@ if RT_USING_MSH int "The command line size for shell" default 80 - config FINSH_USING_BUILT_IN_COMMANDS + config MSH_USING_BUILT_IN_COMMANDS bool "Enable built-in commands, such as list_thread" default y diff --git a/components/finsh/SConscript b/components/finsh/SConscript index 65395f346b..28fe02bac5 100644 --- a/components/finsh/SConscript +++ b/components/finsh/SConscript @@ -6,7 +6,7 @@ shell.c msh.c ''') -if GetDepend('FINSH_USING_BUILT_IN_COMMANDS'): +if GetDepend('MSH_USING_BUILT_IN_COMMANDS'): src += ['cmd.c'] if GetDepend('RT_USING_DFS'): diff --git a/components/finsh/msh.c b/components/finsh/msh.c index a0680e2ce9..86985c561c 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -54,7 +54,7 @@ int msh_help(int argc, char **argv) } MSH_CMD_EXPORT_ALIAS(msh_help, help, RT - Thread shell help.); -#ifdef FINSH_USING_BUILT_IN_COMMANDS +#ifdef MSH_USING_BUILT_IN_COMMANDS int cmd_ps(int argc, char **argv) { extern long list_thread(void); @@ -85,7 +85,7 @@ int cmd_free(int argc, char **argv) } MSH_CMD_EXPORT_ALIAS(cmd_free, free, Show the memory usage in the system.); #endif /* RT_USING_HEAP */ -#endif /* FINSH_USING_BUILT_IN_COMMANDS */ +#endif /* MSH_USING_BUILT_IN_COMMANDS */ static int msh_split(char *cmd, rt_size_t length, char *argv[FINSH_ARG_MAX]) { diff --git a/libcpu/aarch64/cortex-a53/trap.c b/libcpu/aarch64/cortex-a53/trap.c index 4837d445d4..6002713543 100644 --- a/libcpu/aarch64/cortex-a53/trap.c +++ b/libcpu/aarch64/cortex-a53/trap.c @@ -19,7 +19,7 @@ #endif extern struct rt_thread *rt_current_thread; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -55,7 +55,7 @@ void rt_hw_trap_error(struct rt_hw_exp_stack *regs) { rt_kprintf("error exception:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/aarch64/cortex-a72/trap.c b/libcpu/aarch64/cortex-a72/trap.c index b89a2cca70..ba96f03a69 100644 --- a/libcpu/aarch64/cortex-a72/trap.c +++ b/libcpu/aarch64/cortex-a72/trap.c @@ -14,7 +14,7 @@ #include "armv8.h" extern struct rt_thread *rt_current_thread; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -50,7 +50,7 @@ void rt_hw_trap_error(struct rt_hw_exp_stack *regs) { rt_kprintf("error exception:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/am335x/trap.c b/libcpu/arm/am335x/trap.c index 94da0063d0..19cb31ad67 100644 --- a/libcpu/arm/am335x/trap.c +++ b/libcpu/arm/am335x/trap.c @@ -24,7 +24,7 @@ /*@{*/ extern struct rt_thread *rt_current_thread; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -67,7 +67,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_kprintf("undefined instruction\n"); rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -105,7 +105,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_kprintf("prefetch abort\n"); rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -133,7 +133,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_kprintf("data abort\n"); rt_kprintf("thread %.*s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/arm926/trap.c b/libcpu/arm/arm926/trap.c index 5751636259..c1b1ffe912 100644 --- a/libcpu/arm/arm926/trap.c +++ b/libcpu/arm/arm926/trap.c @@ -16,7 +16,7 @@ #define INT_FIQ 0x01 extern struct rt_thread *rt_current_thread; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -90,7 +90,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_kprintf("undefined instruction\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -142,7 +142,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_kprintf("prefetch abort\n"); rt_kprintf("thread - %s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -170,7 +170,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_kprintf("data abort\n"); rt_kprintf("thread - %s stack:\n", RT_NAME_MAX, rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/cortex-a/trap.c b/libcpu/arm/cortex-a/trap.c index a215374348..814db418cd 100644 --- a/libcpu/arm/cortex-a/trap.c +++ b/libcpu/arm/cortex-a/trap.c @@ -15,7 +15,7 @@ #include "armv7.h" #include "interrupt.h" -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -89,7 +89,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -115,7 +115,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -140,7 +140,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -165,7 +165,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -189,7 +189,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/cortex-m0/cpuport.c b/libcpu/arm/cortex-m0/cpuport.c index d6c9be11cf..af343aa8b2 100644 --- a/libcpu/arm/cortex-m0/cpuport.c +++ b/libcpu/arm/cortex-m0/cpuport.c @@ -90,7 +90,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, return stk; } -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif extern rt_thread_t rt_current_thread; @@ -110,7 +110,7 @@ void rt_hw_hard_fault_exception(struct exception_stack_frame *contex) rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif diff --git a/libcpu/arm/cortex-m23/cpuport.c b/libcpu/arm/cortex-m23/cpuport.c index 4619534c05..a3b18f5f35 100644 --- a/libcpu/arm/cortex-m23/cpuport.c +++ b/libcpu/arm/cortex-m23/cpuport.c @@ -91,7 +91,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, return stk; } -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif extern rt_thread_t rt_current_thread; @@ -111,7 +111,7 @@ void rt_hw_hard_fault_exception(struct exception_stack_frame *contex) rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif diff --git a/libcpu/arm/cortex-m3/cpuport.c b/libcpu/arm/cortex-m3/cpuport.c index 02f84564d5..d376f00424 100644 --- a/libcpu/arm/cortex-m3/cpuport.c +++ b/libcpu/arm/cortex-m3/cpuport.c @@ -291,7 +291,7 @@ struct exception_info */ void rt_hw_hard_fault_exception(struct exception_info * exception_info) { -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif struct stack_frame* context = &exception_info->stack_frame; @@ -327,7 +327,7 @@ void rt_hw_hard_fault_exception(struct exception_info * exception_info) { rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif } diff --git a/libcpu/arm/cortex-m33/cpuport.c b/libcpu/arm/cortex-m33/cpuport.c index 8f73985f87..aa2325012c 100644 --- a/libcpu/arm/cortex-m33/cpuport.c +++ b/libcpu/arm/cortex-m33/cpuport.c @@ -373,7 +373,7 @@ struct exception_info void rt_hw_hard_fault_exception(struct exception_info *exception_info) { -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif struct exception_stack_frame *exception_stack = &exception_info->stack_frame.exception_stack_frame; @@ -409,7 +409,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) { rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif } diff --git a/libcpu/arm/cortex-m4/cpuport.c b/libcpu/arm/cortex-m4/cpuport.c index 8dfcbe9cc4..f24c33cf4d 100644 --- a/libcpu/arm/cortex-m4/cpuport.c +++ b/libcpu/arm/cortex-m4/cpuport.c @@ -370,7 +370,7 @@ struct exception_info void rt_hw_hard_fault_exception(struct exception_info *exception_info) { -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif struct exception_stack_frame *exception_stack = &exception_info->stack_frame.exception_stack_frame; @@ -406,7 +406,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) { rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif } diff --git a/libcpu/arm/cortex-m7/cpuport.c b/libcpu/arm/cortex-m7/cpuport.c index 8dfcbe9cc4..f24c33cf4d 100644 --- a/libcpu/arm/cortex-m7/cpuport.c +++ b/libcpu/arm/cortex-m7/cpuport.c @@ -370,7 +370,7 @@ struct exception_info void rt_hw_hard_fault_exception(struct exception_info *exception_info) { -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif struct exception_stack_frame *exception_stack = &exception_info->stack_frame.exception_stack_frame; @@ -406,7 +406,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) { rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif } diff --git a/libcpu/arm/cortex-r4/trap.c b/libcpu/arm/cortex-r4/trap.c index 9cb24026f0..3ff3d297c0 100644 --- a/libcpu/arm/cortex-r4/trap.c +++ b/libcpu/arm/cortex-r4/trap.c @@ -67,7 +67,7 @@ void rt_hw_trap_svc(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -85,7 +85,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -103,7 +103,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("Data Abort "); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -120,7 +120,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("Reserved trap\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/realview-a8-vmm/trap.c b/libcpu/arm/realview-a8-vmm/trap.c index 319dba851c..86eceb39cf 100644 --- a/libcpu/arm/realview-a8-vmm/trap.c +++ b/libcpu/arm/realview-a8-vmm/trap.c @@ -21,7 +21,7 @@ #include "gic.h" extern struct rt_thread *rt_current_thread; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -53,7 +53,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -72,7 +72,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -90,7 +90,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -108,7 +108,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -125,7 +125,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/s3c24x0/trap.c b/libcpu/arm/s3c24x0/trap.c index 29190dce4e..c4be806dc6 100644 --- a/libcpu/arm/s3c24x0/trap.c +++ b/libcpu/arm/s3c24x0/trap.c @@ -22,7 +22,7 @@ /*@{*/ extern struct rt_thread *rt_current_thread; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -58,7 +58,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) rt_kprintf("undefined instruction\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -96,7 +96,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) rt_kprintf("prefetch abort\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -117,7 +117,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) rt_kprintf("data abort\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/arm/zynqmp-r5/trap.c b/libcpu/arm/zynqmp-r5/trap.c index 9ec5d1a568..5db5a0c01b 100644 --- a/libcpu/arm/zynqmp-r5/trap.c +++ b/libcpu/arm/zynqmp-r5/trap.c @@ -16,7 +16,7 @@ #include "armv7.h" #include "interrupt.h" -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(void); #endif @@ -48,7 +48,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs) { rt_kprintf("undefined instruction:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -67,7 +67,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs) { rt_kprintf("software interrupt:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -85,7 +85,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs) { rt_kprintf("prefetch abort:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -103,7 +103,7 @@ void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs) { rt_kprintf("data abort:"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); @@ -120,7 +120,7 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs) { rt_kprintf("reserved trap:\n"); rt_hw_show_register(regs); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif rt_hw_cpu_shutdown(); diff --git a/libcpu/risc-v/k210/interrupt.c b/libcpu/risc-v/k210/interrupt.c index 98cbef5401..b5384b01ee 100644 --- a/libcpu/risc-v/k210/interrupt.c +++ b/libcpu/risc-v/k210/interrupt.c @@ -335,7 +335,7 @@ uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc, uintptr_t * sp) else { rt_thread_t tid; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(); #endif @@ -389,7 +389,7 @@ uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc, uintptr_t * sp) print_stack_frame(sp); rt_kprintf("exception pc => 0x%08x\n", epc); rt_kprintf("current thread: %.*s\n", RT_NAME_MAX, tid->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif while(1); diff --git a/libcpu/risc-v/virt64/interrupt.c b/libcpu/risc-v/virt64/interrupt.c index 4b109d71ad..eae0a55c96 100644 --- a/libcpu/risc-v/virt64/interrupt.c +++ b/libcpu/risc-v/virt64/interrupt.c @@ -212,7 +212,7 @@ void handle_trap(rt_size_t xcause,rt_size_t xtval,rt_size_t xepc,struct rt_hw_st else { rt_thread_t tid; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern long list_thread(); #endif rt_hw_interrupt_disable(); @@ -266,7 +266,7 @@ void handle_trap(rt_size_t xcause,rt_size_t xtval,rt_size_t xepc,struct rt_hw_st dump_regs(sp); rt_kprintf("exception pc => 0x%08x\n", xepc); rt_kprintf("current thread: %.*s\n", RT_NAME_MAX, tid->name); -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif while(1); diff --git a/libcpu/rx/cpuport.c b/libcpu/rx/cpuport.c index 9f737a50e7..366569f63d 100644 --- a/libcpu/rx/cpuport.c +++ b/libcpu/rx/cpuport.c @@ -94,7 +94,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter, return(rt_uint8_t *)stack_frame; } -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern void list_thread(void); #endif extern rt_thread_t rt_current_thread; @@ -130,7 +130,7 @@ void rt_hw_hard_fault_exception(struct stack_frame* exception_contex) rt_kprintf("acclo: 0x%08x\n", exception_contex->ACCLO); } rt_kprintf("hard fault on thread: %s\n", rt_current_thread->name); - #if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) + #if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_thread(); #endif while (1); diff --git a/src/memheap.c b/src/memheap.c index 1f62c3afb0..e09f5c4bce 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -730,13 +730,13 @@ int memheaptrace(void) if (count > 0) { int index; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) extern int list_memheap(void); #endif heaps = (struct rt_memheap **)rt_malloc(sizeof(struct rt_memheap *) * count); if (heaps == RT_NULL) return 0; -#if defined(RT_USING_FINSH) && defined(FINSH_USING_BUILT_IN_COMMANDS) +#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS) list_memheap(); #endif rt_kprintf("memheap header size: %d\n", RT_MEMHEAP_SIZE); -- cgit v1.3.1 From a35520f841ebb7fb2152e7f9a7893d3a95f8615f Mon Sep 17 00:00:00 2001 From: supperthomas <78900636@qq.com> Date: Mon, 30 Aug 2021 07:28:36 +0800 Subject: fix the return --- src/irq.c | 6 ++--- src/timer.c | 74 ++++++++++++++++++++++++++++++------------------------------- 2 files changed, 40 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/irq.c b/src/irq.c index 81c972c955..3889a2a2c8 100644 --- a/src/irq.c +++ b/src/irq.c @@ -27,7 +27,7 @@ static void (*rt_interrupt_leave_hook)(void); * * @note The hook function must be simple and never be blocked or suspend. * - * @param hook The function point to be called + * @param hook the function point to be called */ void rt_interrupt_enter_sethook(void (*hook)(void)) { @@ -41,7 +41,7 @@ void rt_interrupt_enter_sethook(void (*hook)(void)) * * @note The hook function must be simple and never be blocked or suspend. * - * @param hook The function point to be called + * @param hook the function point to be called */ void rt_interrupt_leave_sethook(void (*hook)(void)) { @@ -112,7 +112,7 @@ RTM_EXPORT(rt_interrupt_leave); * User application can invoke this function to get whether current * context is interrupt context. * - * @return rt_uint8_t the number of nested interrupts. + * @return the number of nested interrupts. */ RT_WEAK rt_uint8_t rt_interrupt_get_nest(void) { diff --git a/src/timer.c b/src/timer.c index 5c90d34675..da52a02fc8 100644 --- a/src/timer.c +++ b/src/timer.c @@ -63,7 +63,7 @@ static void (*rt_timer_exit_hook)(struct rt_timer *timer); * @brief This function will set a hook function on timer, * which will be invoked when enter timer timeout callback function. * - * @param hook The function point of timer + * @param hook is the function point of timer */ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer)) { @@ -74,7 +74,7 @@ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer)) * @brief This function will set a hook function, which will be * invoked when exit timer timeout callback function. * - * @param hook The function point of timer + * @param hook is the function point of timer */ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) { @@ -92,15 +92,15 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) * * @see rt_timer_init * - * @param timer The static timer object + * @param timer is timer object * - * @param timeout The timeout function + * @param timeout is the timeout function * - * @param parameter The parameter of timeout function + * @param parameter is the parameter of timeout function * - * @param time The tick of timer + * @param time is the tick of timer * - * @param flag The flag of timer + * @param flag the flag of timer */ static void _timer_init(rt_timer_t timer, void (*timeout)(void *parameter), @@ -132,9 +132,9 @@ static void _timer_init(rt_timer_t timer, /** * @brief Find the next emtpy timer ticks * - * @param timer_list The timer of the next timeout + * @param timer_list is the array of time list * - * @return rt_tick_t The next timer's ticks + * @return the next timer's ticks */ static rt_tick_t _timer_list_next_timeout(rt_list_t timer_list[]) { @@ -161,7 +161,7 @@ static rt_tick_t _timer_list_next_timeout(rt_list_t timer_list[]) /** * @brief Remove the timer * - * @param timer The point of the timer + * @param timer the point of the timer */ rt_inline void _timer_remove(rt_timer_t timer) { @@ -179,7 +179,7 @@ rt_inline void _timer_remove(rt_timer_t timer) * * @param timer the head of timer * - * @return int the count of timer + * @return count of timer */ static int _timer_count_height(struct rt_timer *timer) { @@ -224,17 +224,17 @@ void rt_timer_dump(rt_list_t timer_heads[]) * @brief This function will initialize a timer * normally this function is used to initialize a static timer object. * - * @param timer The static timer object + * @param timer is the point of timer * - * @param name The name of timer + * @param name is a pointer to the name of the timer * - * @param timeout The timeout function + * @param timeout is the callback of timer * - * @param parameter The parameter of timeout function + * @param parameter is the param of the callback * - * @param time The tick of timer + * @param time is the ticks of timer * - * @param flag The flag of timer + * @param flag is the flag of timer */ void rt_timer_init(rt_timer_t timer, const char *name, @@ -256,9 +256,9 @@ RTM_EXPORT(rt_timer_init); /** * @brief This function will detach a timer from timer management. * - * @param timer The timer to be detached + * @param timer is the timer to be detached * - * @return rt_err_t The status of detach + * @return the status of detach */ rt_err_t rt_timer_detach(rt_timer_t timer) { @@ -289,17 +289,17 @@ RTM_EXPORT(rt_timer_detach); /** * @brief This function will create a timer * - * @param name The name of timer + * @param name the name of timer * - * @param timeout The timeout function + * @param timeout the timeout function * - * @param parameter The parameter of timeout function + * @param parameter the parameter of timeout function * - * @param time The tick of timer + * @param time the tick of timer * - * @param flag The flag of timer + * @param flag the flag of timer * - * @return The created timer object + * @return the created timer object */ rt_timer_t rt_timer_create(const char *name, void (*timeout)(void *parameter), @@ -325,9 +325,9 @@ RTM_EXPORT(rt_timer_create); /** * @brief This function will delete a timer and release timer memory * - * @param timer The timer to be deleted + * @param timer the timer to be deleted * - * @return rt_err_t The operation status, RT_EOK on OK; RT_ERROR on error + * @return the operation status, RT_EOK on OK; RT_ERROR on error */ rt_err_t rt_timer_delete(rt_timer_t timer) { @@ -358,9 +358,9 @@ RTM_EXPORT(rt_timer_delete); /** * @brief This function will start the timer * - * @param timer The timer to be started + * @param timer the timer to be started * - * @return The operation status, RT_EOK on OK, -RT_ERROR on error + * @return the operation status, RT_EOK on OK, -RT_ERROR on error */ rt_err_t rt_timer_start(rt_timer_t timer) { @@ -481,9 +481,9 @@ RTM_EXPORT(rt_timer_start); /** * @brief This function will stop the timer * - * @param timer The timer to be stopped + * @param timer the timer to be stopped * - * @return The operation status, RT_EOK on OK, -RT_ERROR on error + * @return the operation status, RT_EOK on OK, -RT_ERROR on error */ rt_err_t rt_timer_stop(rt_timer_t timer) { @@ -515,11 +515,11 @@ RTM_EXPORT(rt_timer_stop); /** * @brief This function will get or set some options of the timer * - * @param timer The timer to be get or set - * @param cmd The control command - * @param arg The argument + * @param timer the timer to be get or set + * @param cmd the control command + * @param arg the argument * - * @return rt_err_t the statu of control + * @return the statu of control */ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg) { @@ -648,7 +648,7 @@ void rt_timer_check(void) /** * @brief This function will return the next timeout tick in the system. * - * @return The next timeout tick in the system + * @return the next timeout tick in the system */ rt_tick_t rt_timer_next_timeout_tick(void) { @@ -737,7 +737,7 @@ void rt_soft_timer_check(void) /** * @brief System timer thread entry * - * @param parameter The arg of the thread + * @param parameter is the arg of the thread */ static void _timer_thread_entry(void *parameter) { -- cgit v1.3.1 From 75b65ebcf2d2261bcd5cf762cc8aa8452e78b8d1 Mon Sep 17 00:00:00 2001 From: WillianChan Date: Tue, 31 Aug 2021 10:39:44 +0800 Subject: [fix][kernel][timer]fixed timer ASSERT exception due to multithreaded scheduling Signed-off-by: WillianChan --- src/timer.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/timer.c b/src/timer.c index da52a02fc8..25ba175306 100644 --- a/src/timer.c +++ b/src/timer.c @@ -367,6 +367,7 @@ rt_err_t rt_timer_start(rt_timer_t timer) unsigned int row_lvl; rt_list_t *timer_list; register rt_base_t level; + register rt_bool_t need_schedule; rt_list_t *row_head[RT_TIMER_SKIP_LIST_LEVEL]; unsigned int tst_nr; static unsigned int random_nr; @@ -375,6 +376,8 @@ rt_err_t rt_timer_start(rt_timer_t timer) RT_ASSERT(timer != RT_NULL); RT_ASSERT(rt_object_get_type(&timer->parent) == RT_Object_Class_Timer); + need_schedule = RT_FALSE; + /* stop timer firstly */ level = rt_hw_interrupt_disable(); /* remove timer from list */ @@ -457,9 +460,6 @@ rt_err_t rt_timer_start(rt_timer_t timer) timer->parent.flag |= RT_TIMER_FLAG_ACTIVATED; - /* enable interrupt */ - rt_hw_interrupt_enable(level); - #ifdef RT_USING_TIMER_SOFT if (timer->parent.flag & RT_TIMER_FLAG_SOFT_TIMER) { @@ -469,11 +469,19 @@ rt_err_t rt_timer_start(rt_timer_t timer) { /* resume timer thread to check soft timer */ rt_thread_resume(&_timer_thread); - rt_schedule(); + need_schedule = RT_TRUE; } } #endif /* RT_USING_TIMER_SOFT */ + /* enable interrupt */ + rt_hw_interrupt_enable(level); + + if (need_schedule) + { + rt_schedule(); + } + return RT_EOK; } RTM_EXPORT(rt_timer_start); -- cgit v1.3.1 From 4e4f381feca709f4979115dd5517573f3d5b561b Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Sat, 4 Sep 2021 17:45:33 +0800 Subject: [add] a comment for the signal --- src/signal.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'src') diff --git a/src/signal.c b/src/signal.c index c5ae2a709a..e630c0dd97 100644 --- a/src/signal.c +++ b/src/signal.c @@ -206,6 +206,20 @@ void *rt_signal_check(void* context) } #endif /* RT_USING_SMP */ +/** + * @brief This function will install a processing function to a specific + * signal and return the old processing function of this signal. + * + * @note This function needs to be used in conjunction with the + * rt_signal_unmask() function to make the signal effective. + * + * @see rt_signal_unmask() + * + * @param signo is a specific signal value (range: 0 ~ RT_SIG_MAX). + * + * @return Return the old processing function of this signal. ONLY When the + * return value is SIG_ERR, the operation is failed. + */ rt_sighandler_t rt_signal_install(int signo, rt_sighandler_t handler) { rt_base_t level; @@ -233,6 +247,17 @@ rt_sighandler_t rt_signal_install(int signo, rt_sighandler_t handler) return old; } +/** + * @brief This function will block the specified signal. + * + * @note This function will block the specified signal, even if the + * rt_thread_kill() function is called to send this signal to + * the current thread, it will no longer take effect. + * + * @see rt_thread_kill() + * + * @param signo is a specific signal value (range: 0 ~ RT_SIG_MAX). + */ void rt_signal_mask(int signo) { rt_base_t level; @@ -245,6 +270,17 @@ void rt_signal_mask(int signo) rt_hw_interrupt_enable(level); } +/** + * @brief This function will unblock the specified signal. + * + * @note This function will unblock the specified signal. After calling + * the rt_thread_kill() function to send this signal to the current + * thread, it will take effect. + * + * @see rt_thread_kill() + * + * @param signo is a specific signal value (range: 0 ~ RT_SIG_MAX). + */ void rt_signal_unmask(int signo) { rt_base_t level; @@ -266,6 +302,20 @@ void rt_signal_unmask(int signo) } } +/** + * @brief This function will wait for the arrival of the set signal. If it does not wait for this signal, the thread will be + * suspended until it waits for this signal or the waiting time exceeds the specified timeout: timeout. + * + * @param set is the set of signal values to be waited for. Use the function + * sigaddset() to add the signal. + * + * @param si is a pointer to the received signal info. If you don't care about this value, you can use RT_NULL to set. + * + * @param timeout is a timeout period (unit: an OS tick). + * + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the signal wait failed. + */ int rt_signal_wait(const rt_sigset_t *set, rt_siginfo_t *si, rt_int32_t timeout) { int ret = RT_EOK; @@ -497,6 +547,16 @@ void rt_thread_free_sig(rt_thread_t tid) } } +/** + * @brief This function can be used to send any signal to any thread. + * + * @param tid is a pointer to the thread that receives the signal. + * + * @param sig is a specific signal value (range: 0 ~ RT_SIG_MAX). + * + * @return Return the operation status. When the return value is RT_EOK, the operation is successful. + * If the return value is any other values, it means that the signal send failed. + */ int rt_thread_kill(rt_thread_t tid, int sig) { siginfo_t si; -- cgit v1.3.1 From 921e6057aa11e52eafcbcdabbb5765359ba2f286 Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Fri, 10 Sep 2021 15:50:15 +0800 Subject: [clock] Improve the code comment of the clock.c --- src/clock.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index 77516b3775..3b35e98d34 100644 --- a/src/clock.c +++ b/src/clock.c @@ -33,9 +33,9 @@ static volatile rt_tick_t rt_tick = 0; /**@{*/ /** - * This function will return current tick from operating system startup + * @brief This function will return current tick from operating system startup * - * @return current tick + * @return Return current tick */ rt_tick_t rt_tick_get(void) { @@ -45,7 +45,9 @@ rt_tick_t rt_tick_get(void) RTM_EXPORT(rt_tick_get); /** - * This function will set current tick + * @brief This function will set current tick + * + * @param tick is the value that you will set. */ void rt_tick_set(rt_tick_t tick) { @@ -57,8 +59,8 @@ void rt_tick_set(rt_tick_t tick) } /** - * This function will notify kernel there is one tick passed. Normally, - * this function is invoked by clock ISR. + * @brief This function will notify kernel there is one tick passed. + * Normally, this function is invoked by clock ISR. */ void rt_tick_increase(void) { @@ -97,14 +99,14 @@ void rt_tick_increase(void) } /** - * This function will calculate the tick from millisecond. + * @brief This function will calculate the tick from millisecond. * - * @param ms the specified millisecond - * - Negative Number wait forever - * - Zero not wait - * - Max 0x7fffffff + * @param ms is the specified millisecond + * - Negative Number wait forever + * - Zero not wait + * - Max 0x7fffffff * - * @return the calculated tick + * @return Return the calculated tick */ rt_tick_t rt_tick_from_millisecond(rt_int32_t ms) { @@ -126,9 +128,13 @@ rt_tick_t rt_tick_from_millisecond(rt_int32_t ms) RTM_EXPORT(rt_tick_from_millisecond); /** - * This function will provide the passed millisecond from boot. - * - * @return passed millisecond from boot + * @brief This function will return the passed millisecond from boot. + * + * @note When the value of RT_TICK_PER_SECOND is lower than 1000 or + * is not an integral multiple of 1000, this function will not + * provide the correct 1ms-based tick. + * + * @return Return passed millisecond from boot */ RT_WEAK rt_tick_t rt_tick_get_millisecond(void) { -- cgit v1.3.1 From ce1402f773314f5c9b1465bb6f8838b0d68188a9 Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Fri, 10 Sep 2021 15:52:37 +0800 Subject: [kernel] Improve the code comment of the components.c --- src/components.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/components.c b/src/components.c index e156b783e4..2a4affdefb 100644 --- a/src/components.c +++ b/src/components.c @@ -78,7 +78,7 @@ static int rti_end(void) INIT_EXPORT(rti_end, "6.end"); /** - * RT-Thread Components Initialization for board + * @brief RT-Thread Components Initialization for board. */ void rt_components_board_init(void) { @@ -102,7 +102,7 @@ void rt_components_board_init(void) } /** - * RT-Thread Components Initialization + * @brief RT-Thread Components Initialization. */ void rt_components_init(void) { @@ -169,7 +169,11 @@ static rt_uint8_t main_stack[RT_MAIN_THREAD_STACK_SIZE]; struct rt_thread main_thread; #endif /* RT_USING_HEAP */ -/* the system main thread */ +/** + * @brief The system main thread. In this thread will call the rt_components_init() + * for initialization of RT-Thread Components and call the user's programming + * entry main(). + */ void main_thread_entry(void *parameter) { extern int main(void); @@ -193,6 +197,10 @@ void main_thread_entry(void *parameter) #endif } +/** + * @brief This function will create and start the main thread, but this thread + * will not run until the scheduler starts. + */ void rt_application_init(void) { rt_thread_t tid; @@ -216,6 +224,11 @@ void rt_application_init(void) rt_thread_startup(tid); } +/** + * @brief RT-Thread startup function. This function will call all levels of initialization + * functions to complete the initialization of the system, and finally start the + * scheduler. + */ int rtthread_startup(void) { rt_hw_interrupt_disable(); -- cgit v1.3.1 From e562c6f24bf3f857f11aa0bd82d46a6b4767464a Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Fri, 10 Sep 2021 16:31:29 +0800 Subject: [kernel] 裁剪尾随空格 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clock.c | 6 +++--- src/components.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index 3b35e98d34..e49df94aae 100644 --- a/src/clock.c +++ b/src/clock.c @@ -46,7 +46,7 @@ RTM_EXPORT(rt_tick_get); /** * @brief This function will set current tick - * + * * @param tick is the value that you will set. */ void rt_tick_set(rt_tick_t tick) @@ -129,11 +129,11 @@ RTM_EXPORT(rt_tick_from_millisecond); /** * @brief This function will return the passed millisecond from boot. - * + * * @note When the value of RT_TICK_PER_SECOND is lower than 1000 or * is not an integral multiple of 1000, this function will not * provide the correct 1ms-based tick. - * + * * @return Return passed millisecond from boot */ RT_WEAK rt_tick_t rt_tick_get_millisecond(void) diff --git a/src/components.c b/src/components.c index 2a4affdefb..87e76091f2 100644 --- a/src/components.c +++ b/src/components.c @@ -199,7 +199,7 @@ void main_thread_entry(void *parameter) /** * @brief This function will create and start the main thread, but this thread - * will not run until the scheduler starts. + * will not run until the scheduler starts. */ void rt_application_init(void) { -- cgit v1.3.1 From a912a2f88f6b765885a6139be3ce42c388e8b767 Mon Sep 17 00:00:00 2001 From: yangjie Date: Fri, 10 Sep 2021 15:55:08 +0800 Subject: [kernel]Normalized kernel API annotation --- src/device.c | 110 +++++++++++++++++++++++++++++++------------------------- src/idle.c | 44 +++++++++++------------ src/mem.c | 55 ++++++++++++++++------------ src/mempool.c | 41 ++++++++++++--------- src/object.c | 94 ++++++++++++++++++++++++++---------------------- src/scheduler.c | 59 ++++++++++++++++-------------- src/slab.c | 82 +++++++++++++++++++++++++++--------------- 7 files changed, 275 insertions(+), 210 deletions(-) (limited to 'src') diff --git a/src/device.c b/src/device.c index a9c244d306..2c1d31f23e 100644 --- a/src/device.c +++ b/src/device.c @@ -39,11 +39,13 @@ #endif /* RT_USING_DEVICE_OPS */ /** - * This function registers a device driver with specified name. + * @brief This function registers a device driver with specified name. * - * @param dev the pointer of device driver structure - * @param name the device driver's name - * @param flags the capabilities flag of device + * @param dev the pointer of device driver structure. + * + * @param name the device driver's name. + * + * @param flags the capabilities flag of device. * * @return the error code, RT_EOK on initialization successfully. */ @@ -72,9 +74,9 @@ rt_err_t rt_device_register(rt_device_t dev, RTM_EXPORT(rt_device_register); /** - * This function removes a previously registered device driver + * @brief This function removes a previously registered device driver. * - * @param dev the pointer of device driver structure + * @param dev the pointer of device driver structure. * * @return the error code, RT_EOK on successfully. */ @@ -91,9 +93,9 @@ rt_err_t rt_device_unregister(rt_device_t dev) RTM_EXPORT(rt_device_unregister); /** - * This function finds a device driver by specified name. + * @brief This function finds a device driver by specified name. * - * @param name the device driver's name + * @param name the device driver's name. * * @return the registered device driver on successful, or RT_NULL on failure. */ @@ -105,10 +107,11 @@ RTM_EXPORT(rt_device_find); #ifdef RT_USING_HEAP /** - * This function creates a device object with user data size. + * @brief This function creates a device object with user data size. * - * @param type, the kind type of this device object. - * @param attach_size, the size of user data. + * @param type the kind type of this device object. + * + * @param attach_size the size of user data. * * @return the allocated device object, or RT_NULL when failed. */ @@ -134,9 +137,9 @@ rt_device_t rt_device_create(int type, int attach_size) RTM_EXPORT(rt_device_create); /** - * This function destroy the specific device object. + * @brief This function destroy the specific device object. * - * @param dev, the specific device object. + * @param dev the specific device object. */ void rt_device_destroy(rt_device_t dev) { @@ -153,11 +156,11 @@ RTM_EXPORT(rt_device_destroy); #endif /* RT_USING_HEAP */ /** - * This function will initialize the specified device + * @brief This function will initialize the specified device. * - * @param dev the pointer of device driver structure + * @param dev the pointer of device driver structure. * - * @return the result + * @return the result, RT_EOK on successfully. */ rt_err_t rt_device_init(rt_device_t dev) { @@ -187,12 +190,13 @@ rt_err_t rt_device_init(rt_device_t dev) } /** - * This function will open a device + * @brief This function will open a device. + * + * @param dev the pointer of device driver structure. * - * @param dev the pointer of device driver structure - * @param oflag the flags for device open + * @param oflag the flags for device open. * - * @return the result + * @return the result, RT_EOK on successfully. */ rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag) { @@ -253,11 +257,11 @@ rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag) RTM_EXPORT(rt_device_open); /** - * This function will close a device + * @brief This function will close a device. * - * @param dev the pointer of device driver structure + * @param dev the pointer of device driver structure. * - * @return the result + * @return the result, RT_EOK on successfully. */ rt_err_t rt_device_close(rt_device_t dev) { @@ -289,12 +293,15 @@ rt_err_t rt_device_close(rt_device_t dev) RTM_EXPORT(rt_device_close); /** - * This function will read some data from a device. + * @brief This function will read some data from a device. + * + * @param dev the pointer of device driver structure. + * + * @param pos the position of reading. + * + * @param buffer the data buffer to save read data. * - * @param dev the pointer of device driver structure - * @param pos the position of reading - * @param buffer the data buffer to save read data - * @param size the size of buffer + * @param size the size of buffer. * * @return the actually read size on successful, otherwise negative returned. * @@ -328,12 +335,15 @@ rt_size_t rt_device_read(rt_device_t dev, RTM_EXPORT(rt_device_read); /** - * This function will write some data to a device. + * @brief This function will write some data to a device. * - * @param dev the pointer of device driver structure - * @param pos the position of written - * @param buffer the data buffer to be written to device - * @param size the size of buffer + * @param dev the pointer of device driver structure. + * + * @param pos the position of written. + * + * @param buffer the data buffer to be written to device. + * + * @param size the size of buffer. * * @return the actually written size on successful, otherwise negative returned. * @@ -367,13 +377,15 @@ rt_size_t rt_device_write(rt_device_t dev, RTM_EXPORT(rt_device_write); /** - * This function will perform a variety of control functions on devices. + * @brief This function will perform a variety of control functions on devices. + * + * @param dev the pointer of device driver structure. * - * @param dev the pointer of device driver structure - * @param cmd the command sent to device - * @param arg the argument of command + * @param cmd the command sent to device. * - * @return the result + * @param arg the argument of command. + * + * @return the result, -RT_ENOSYS for failed. */ rt_err_t rt_device_control(rt_device_t dev, int cmd, void *arg) { @@ -391,13 +403,14 @@ rt_err_t rt_device_control(rt_device_t dev, int cmd, void *arg) RTM_EXPORT(rt_device_control); /** - * This function will set the reception indication callback function. This callback function - * is invoked when this device receives data. + * @brief This function will set the reception indication callback function. This callback function + * is invoked when this device receives data. + * + * @param dev the pointer of device driver structure. * - * @param dev the pointer of device driver structure - * @param rx_ind the indication callback function + * @param rx_ind the indication callback function. * - * @return RT_EOK + * @return RT_EOK. */ rt_err_t rt_device_set_rx_indicate(rt_device_t dev, @@ -413,13 +426,14 @@ rt_device_set_rx_indicate(rt_device_t dev, RTM_EXPORT(rt_device_set_rx_indicate); /** - * This function will set the indication callback function when device has - * written data to physical hardware. + * @brief This function will set the indication callback function when device has + * written data to physical hardware. + * + * @param dev the pointer of device driver structure. * - * @param dev the pointer of device driver structure - * @param tx_done the indication callback function + * @param tx_done the indication callback function. * - * @return RT_EOK + * @return RT_EOK. */ rt_err_t rt_device_set_tx_complete(rt_device_t dev, diff --git a/src/idle.c b/src/idle.c index ec625cb4a1..4bf89c38e0 100644 --- a/src/idle.c +++ b/src/idle.c @@ -68,14 +68,13 @@ static struct rt_semaphore system_sem; static void (*idle_hook_list[RT_IDLE_HOOK_LIST_SIZE])(void); /** - * @ingroup Hook - * This function sets a hook function to idle thread loop. When the system performs - * idle loop, this hook function should be invoked. + * @brief This function sets a hook function to idle thread loop. When the system performs + * idle loop, this hook function should be invoked. * - * @param hook the specified hook function + * @param hook the specified hook function. * - * @return RT_EOK: set OK - * -RT_EFULL: hook list is full + * @return RT_EOK: set OK. + * -RT_EFULL: hook list is full. * * @note the hook function must be simple and never be blocked or suspend. */ @@ -104,12 +103,12 @@ rt_err_t rt_thread_idle_sethook(void (*hook)(void)) } /** - * delete the idle hook on hook list + * @brief delete the idle hook on hook list. * - * @param hook the specified hook function + * @param hook the specified hook function. * - * @return RT_EOK: delete OK - * -RT_ENOSYS: hook was not found + * @return RT_EOK: delete OK. + * -RT_ENOSYS: hook was not found. */ rt_err_t rt_thread_idle_delhook(void (*hook)(void)) { @@ -153,8 +152,10 @@ rt_inline int _idle_has_defunct_thread(void) } #endif /* RT_USING_MODULE */ -/* enqueue a thread to defunct queue - * it must be called between rt_hw_interrupt_disable and rt_hw_interrupt_enable +/** + * @brief Enqueue a thread to defunct queue. + * + * @note It must be called between rt_hw_interrupt_disable and rt_hw_interrupt_enable */ void rt_thread_defunct_enqueue(rt_thread_t thread) { @@ -164,8 +165,10 @@ void rt_thread_defunct_enqueue(rt_thread_t thread) #endif } -/* dequeue a thread from defunct queue - * it must be called between rt_hw_interrupt_disable and rt_hw_interrupt_enable +/** + * @brief Dequeue a thread from defunct queue. + * + * @note It must be called between rt_hw_interrupt_disable and rt_hw_interrupt_enable. */ rt_thread_t rt_thread_defunct_dequeue(void) { @@ -183,9 +186,7 @@ rt_thread_t rt_thread_defunct_dequeue(void) } /** - * @ingroup Thread - * - * This function will perform system background job when system idle. + * @brief This function will perform system background job when system idle. */ static void rt_defunct_execute(void) { @@ -316,9 +317,7 @@ static void rt_thread_system_entry(void *parameter) #endif /** - * @ingroup SystemInit - * - * This function will initialize idle thread, then start it. + * @brief This function will initialize idle thread, then start it. * * @note this function must be invoked when system init. */ @@ -365,10 +364,7 @@ void rt_thread_idle_init(void) } /** - * @ingroup Thread - * - * This function will get the handler of the idle thread. - * + * @brief This function will get the handler of the idle thread. */ rt_thread_t rt_thread_idle_gethandler(void) { diff --git a/src/mem.c b/src/mem.c index 20ac0e588c..0fefb86f89 100644 --- a/src/mem.c +++ b/src/mem.c @@ -66,10 +66,10 @@ static void (*rt_free_hook)(void *ptr); /**@{*/ /** - * This function will set a hook function, which will be invoked when a memory - * block is allocated from heap memory. + * @brief This function will set a hook function, which will be invoked when a memory + * block is allocated from heap memory. * - * @param hook the hook function + * @param hook the hook function. */ void rt_malloc_sethook(void (*hook)(void *ptr, rt_size_t size)) { @@ -77,8 +77,8 @@ void rt_malloc_sethook(void (*hook)(void *ptr, rt_size_t size)) } /** - * This function will set a hook function, which will be invoked when a memory - * block is released to heap memory. + * @brief This function will set a hook function, which will be invoked when a memory + * block is released to heap memory. * * @param hook the hook function */ @@ -194,11 +194,10 @@ static void plug_holes(struct heap_mem *mem) } /** - * @ingroup SystemInit - * - * This function will initialize system heap memory. + * @brief This function will initialize system heap memory. * * @param begin_addr the beginning address of system heap memory. + * * @param end_addr the end address of system heap memory. */ void rt_system_heap_init(void *begin_addr, void *end_addr) @@ -263,7 +262,7 @@ void rt_system_heap_init(void *begin_addr, void *end_addr) /**@{*/ /** - * Allocate a block of memory with a minimum of 'size' bytes. + * @brief Allocate a block of memory with a minimum of 'size' bytes. * * @param size is the minimum size of the requested block in bytes. * @@ -411,12 +410,13 @@ void *rt_malloc(rt_size_t size) RTM_EXPORT(rt_malloc); /** - * This function will change the previously allocated memory block. + * @brief This function will change the previously allocated memory block. * - * @param rmem pointer to memory allocated by rt_malloc - * @param newsize the required new size + * @param rmem pointer to memory allocated by rt_malloc. * - * @return the changed memory block address + * @param newsize the required new size. + * + * @return the changed memory block address. */ void *rt_realloc(void *rmem, rt_size_t newsize) { @@ -517,16 +517,17 @@ void *rt_realloc(void *rmem, rt_size_t newsize) RTM_EXPORT(rt_realloc); /** - * This function will contiguously allocate enough space for count objects - * that are size bytes of memory each and returns a pointer to the allocated - * memory. + * @brief This function will contiguously allocate enough space for count objects + * that are size bytes of memory each and returns a pointer to the allocated + * memory. + * + * @note The allocated memory is filled with bytes of value zero. * - * The allocated memory is filled with bytes of value zero. + * @param count number of objects to allocate. * - * @param count number of objects to allocate - * @param size size of the objects to allocate + * @param size size of the objects to allocate. * - * @return pointer to allocated memory / NULL pointer if there is an error + * @return pointer to allocated memory / NULL pointer if there is an error. */ void *rt_calloc(rt_size_t count, rt_size_t size) { @@ -544,8 +545,8 @@ void *rt_calloc(rt_size_t count, rt_size_t size) RTM_EXPORT(rt_calloc); /** - * This function will release the previously allocated memory block by - * rt_malloc. The released memory block is taken back to system heap. + * @brief This function will release the previously allocated memory block by + * rt_malloc. The released memory block is taken back to system heap. * * @param rmem the address of memory which will be released */ @@ -616,6 +617,16 @@ void rt_free(void *rmem) RTM_EXPORT(rt_free); #ifdef RT_MEM_STATS +/** +* @brief This function will caculate the total memory, the used memory, and +* the max used memory. +* +* @param total is a pointer to get the total size of the memory. +* +* @param used is a pointer to get the size of memory used. +* +* @param max_used is a pointer to get the maximum memory used. +*/ void rt_memory_info(rt_uint32_t *total, rt_uint32_t *used, rt_uint32_t *max_used) diff --git a/src/mempool.c b/src/mempool.c index 5ac87d2bc8..9b201c5f89 100644 --- a/src/mempool.c +++ b/src/mempool.c @@ -32,8 +32,8 @@ static void (*rt_mp_free_hook)(struct rt_mempool *mp, void *block); /**@{*/ /** - * This function will set a hook function, which will be invoked when a memory - * block is allocated from memory pool. + * @brief This function will set a hook function, which will be invoked when a memory + * block is allocated from memory pool. * * @param hook the hook function */ @@ -43,8 +43,8 @@ void rt_mp_alloc_sethook(void (*hook)(struct rt_mempool *mp, void *block)) } /** - * This function will set a hook function, which will be invoked when a memory - * block is released to memory pool. + * @brief This function will set a hook function, which will be invoked when a memory + * block is released to memory pool. * * @param hook the hook function */ @@ -63,13 +63,17 @@ void rt_mp_free_sethook(void (*hook)(struct rt_mempool *mp, void *block)) /**@{*/ /** - * This function will initialize a memory pool object, normally which is used - * for static object. + * @brief This function will initialize a memory pool object, normally which is used + * for static object. * * @param mp the memory pool object + * * @param name the name of memory pool + * * @param start the star address of memory pool + * * @param size the total size of memory pool + * * @param block_size the size for each block * * @return RT_EOK @@ -125,9 +129,9 @@ rt_err_t rt_mp_init(struct rt_mempool *mp, RTM_EXPORT(rt_mp_init); /** - * This function will detach a memory pool from system object management. + * @brief This function will detach a memory pool from system object management. * - * @param mp the memory pool object + * @param mp the memory pool object. * * @return RT_EOK */ @@ -172,11 +176,13 @@ RTM_EXPORT(rt_mp_detach); #ifdef RT_USING_HEAP /** - * This function will create a mempool object and allocate the memory pool from - * heap. + * @brief This function will create a mempool object and allocate the memory pool from + * heap. * * @param name the name of memory pool + * * @param block_count the count of blocks in memory pool + * * @param block_size the size for each block * * @return the created mempool object @@ -241,9 +247,9 @@ rt_mp_t rt_mp_create(const char *name, RTM_EXPORT(rt_mp_create); /** - * This function will delete a memory pool and release the object memory. + * @brief This function will delete a memory pool and release the object memory. * - * @param mp the memory pool object + * @param mp the memory pool object. * * @return RT_EOK */ @@ -293,12 +299,13 @@ RTM_EXPORT(rt_mp_delete); #endif /* RT_USING_HEAP */ /** - * This function will allocate a block from memory pool + * @brief This function will allocate a block from memory pool. * - * @param mp the memory pool object - * @param time the waiting time + * @param mp the memory pool object. + * + * @param time the waiting time. * - * @return the allocated memory block or RT_NULL on allocated failed + * @return the allocated memory block or RT_NULL on allocated failed. */ void *rt_mp_alloc(rt_mp_t mp, rt_int32_t time) { @@ -392,7 +399,7 @@ void *rt_mp_alloc(rt_mp_t mp, rt_int32_t time) RTM_EXPORT(rt_mp_alloc); /** - * This function will release a memory block + * @brief This function will release a memory block * * @param block the address of memory block to be released */ diff --git a/src/object.c b/src/object.c index 718b0aa5b2..de0140ebfa 100644 --- a/src/object.c +++ b/src/object.c @@ -120,10 +120,10 @@ void (*rt_object_put_hook)(struct rt_object *object); /**@{*/ /** - * This function will set a hook function, which will be invoked when object - * attaches to kernel object system. + * @brief This function will set a hook function, which will be invoked when object + * attaches to kernel object system. * - * @param hook the hook function + * @param hook the hook function. */ void rt_object_attach_sethook(void (*hook)(struct rt_object *object)) { @@ -131,8 +131,8 @@ void rt_object_attach_sethook(void (*hook)(struct rt_object *object)) } /** - * This function will set a hook function, which will be invoked when object - * detaches from kernel object system. + * @brief This function will set a hook function, which will be invoked when object + * detaches from kernel object system. * * @param hook the hook function */ @@ -142,17 +142,17 @@ void rt_object_detach_sethook(void (*hook)(struct rt_object *object)) } /** - * This function will set a hook function, which will be invoked when object - * is taken from kernel object system. + * @brief This function will set a hook function, which will be invoked when object + * is taken from kernel object system. * - * The object is taken means: - * semaphore - semaphore is taken by thread - * mutex - mutex is taken by thread - * event - event is received by thread - * mailbox - mail is received by thread - * message queue - message is received by thread + * The object is taken means: + * semaphore - semaphore is taken by thread + * mutex - mutex is taken by thread + * event - event is received by thread + * mailbox - mail is received by thread + * message queue - message is received by thread * - * @param hook the hook function + * @param hook the hook function. */ void rt_object_trytake_sethook(void (*hook)(struct rt_object *object)) { @@ -160,18 +160,18 @@ void rt_object_trytake_sethook(void (*hook)(struct rt_object *object)) } /** - * This function will set a hook function, which will be invoked when object - * have been taken from kernel object system. + * @brief This function will set a hook function, which will be invoked when object + * have been taken from kernel object system. * - * The object have been taken means: - * semaphore - semaphore have been taken by thread - * mutex - mutex have been taken by thread - * event - event have been received by thread - * mailbox - mail have been received by thread - * message queue - message have been received by thread - * timer - timer is started + * The object have been taken means: + * semaphore - semaphore have been taken by thread + * mutex - mutex have been taken by thread + * event - event have been received by thread + * mailbox - mail have been received by thread + * message queue - message have been received by thread + * timer - timer is started * - * @param hook the hook function + * @param hook the hook function. */ void rt_object_take_sethook(void (*hook)(struct rt_object *object)) { @@ -179,8 +179,8 @@ void rt_object_take_sethook(void (*hook)(struct rt_object *object)) } /** - * This function will set a hook function, which will be invoked when object - * is put to kernel object system. + * @brief This function will set a hook function, which will be invoked when object + * is put to kernel object system. * * @param hook the hook function */ @@ -199,7 +199,7 @@ void rt_object_put_sethook(void (*hook)(struct rt_object *object)) /**@{*/ /** - * This function will return the specified type of object information. + * @brief This function will return the specified type of object information. * * @param type the type of object, which can be * RT_Object_Class_Thread/Semaphore/Mutex... etc @@ -219,10 +219,11 @@ rt_object_get_information(enum rt_object_class_type type) RTM_EXPORT(rt_object_get_information); /** - * This function will return the length of object list in object container. + * @brief This function will return the length of object list in object container. * * @param type the type of object, which can be * RT_Object_Class_Thread/Semaphore/Mutex... etc + * * @return the length of object list */ int rt_object_get_length(enum rt_object_class_type type) @@ -248,12 +249,14 @@ int rt_object_get_length(enum rt_object_class_type type) RTM_EXPORT(rt_object_get_length); /** - * This function will copy the object pointer of the specified type, - * with the maximum size specified by maxlen. + * @brief This function will copy the object pointer of the specified type, + * with the maximum size specified by maxlen. * * @param type the type of object, which can be * RT_Object_Class_Thread/Semaphore/Mutex... etc + * * @param pointers the pointers will be saved to + * * @param maxlen the maximum number of pointers can be saved * * @return the copied number of object pointers @@ -290,11 +293,13 @@ int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers RTM_EXPORT(rt_object_get_pointers); /** - * This function will initialize an object and add it to object system - * management. + * @brief This function will initialize an object and add it to object system + * management. * * @param object the specified object to be initialized. + * * @param type the object type. + * * @param name the object name. In system, the object's name must be unique. */ void rt_object_init(struct rt_object *object, @@ -361,8 +366,8 @@ void rt_object_init(struct rt_object *object, } /** - * This function will detach a static object from object system, - * and the memory of static object is not freed. + * @brief This function will detach a static object from object system, + * and the memory of static object is not freed. * * @param object the specified object to be detached. */ @@ -390,9 +395,10 @@ void rt_object_detach(rt_object_t object) #ifdef RT_USING_HEAP /** - * This function will allocate an object from object system + * @brief This function will allocate an object from object system. * * @param type the type of object + * * @param name the object name. In system, the object's name must be unique. * * @return object @@ -459,7 +465,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name) } /** - * This function will delete an object and release object memory. + * @brief This function will delete an object and release object memory. * * @param object the specified object to be deleted. */ @@ -491,9 +497,10 @@ void rt_object_delete(rt_object_t object) #endif /* RT_USING_HEAP */ /** - * This function will judge the object is system object or not. - * Normally, the system object is a static object and the type - * of object set to RT_Object_Class_Static. + * @brief This function will judge the object is system object or not. + * + * @note Normally, the system object is a static object and the type + * of object set to RT_Object_Class_Static. * * @param object the specified object to be judged. * @@ -511,8 +518,8 @@ rt_bool_t rt_object_is_systemobject(rt_object_t object) } /** - * This function will return the type of object without - * RT_Object_Class_Static flag. + * @brief This function will return the type of object without + * RT_Object_Class_Static flag. * * @param object the specified object to be get type. * @@ -527,10 +534,11 @@ rt_uint8_t rt_object_get_type(rt_object_t object) } /** - * This function will find specified name object from object - * container. + * @brief This function will find specified name object from object + * container. * * @param name the specified name of object. + * * @param type the type of object * * @return the found object or RT_NULL if there is no this object diff --git a/src/scheduler.c b/src/scheduler.c index bb431e2efe..dc0073d097 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -58,19 +58,23 @@ static void (*rt_scheduler_switch_hook)(struct rt_thread *tid); /**@{*/ /** - * This function will set a hook function, which will be invoked when thread - * switch happens. + * @brief This function will set a hook function, which will be invoked when thread + * switch happens. * - * @param hook the hook function + * @param hook the hook function. */ -void -rt_scheduler_sethook(void (*hook)(struct rt_thread *from, struct rt_thread *to)) +void rt_scheduler_sethook(void (*hook)(struct rt_thread *from, struct rt_thread *to)) { rt_scheduler_hook = hook; } -void -rt_scheduler_switch_sethook(void (*hook)(struct rt_thread *tid)) +/** + * @brief This function will set a hook function, which will be invoked when context + * switch happens. + * + * @param hook the hook function. + */ +void rt_scheduler_switch_sethook(void (*hook)(struct rt_thread *tid)) { rt_scheduler_switch_hook = hook; } @@ -181,8 +185,7 @@ static struct rt_thread* _scheduler_get_highest_priority_thread(rt_ubase_t *high #endif /* RT_USING_SMP */ /** - * @ingroup SystemInit - * This function will initialize the system scheduler + * @brief This function will initialize the system scheduler. */ void rt_system_scheduler_init(void) { @@ -271,12 +274,13 @@ void rt_system_scheduler_start(void) #ifdef RT_USING_SMP /** - * This function will handle IPI interrupt and do a scheduling in system; + * @brief This function will handle IPI interrupt and do a scheduling in system. * - * @param vector, the number of IPI interrupt for system scheduling - * @param param, use RT_NULL + * @param vector the number of IPI interrupt for system scheduling. * - * NOTE: this function should be invoke or register as ISR in BSP. + * @param param use RT_NULL. + * + * @note this function should be invoke or register as ISR in BSP. */ void rt_scheduler_ipi_handler(int vector, void *param) { @@ -284,9 +288,9 @@ void rt_scheduler_ipi_handler(int vector, void *param) } /** - * This function will perform one scheduling. It will select one thread - * with the highest priority level in global ready queue or local ready queue, - * then switch to it. + * @brief This function will perform one scheduling. It will select one thread + * with the highest priority level in global ready queue or local ready queue, + * then switch to it. */ void rt_schedule(void) { @@ -407,8 +411,8 @@ __exit: } #else /** - * This function will perform one schedule. It will select one thread - * with the highest priority level, and switch to it immediately. + * @brief This function will perform one schedule. It will select one thread + * with the highest priority level, and switch to it immediately. */ void rt_schedule(void) { @@ -536,9 +540,9 @@ __exit: #endif /* RT_USING_SMP */ /** - * This function checks if a scheduling is needed after IRQ context. If yes, - * it will select one thread with the highest priority level, and then switch - * to it. + * @brief This function checks if a scheduling is needed after IRQ context. If yes, + * it will select one thread with the highest priority level, and then switch + * to it. */ #ifdef RT_USING_SMP void rt_scheduler_do_irq_switch(void *context) @@ -631,11 +635,12 @@ void rt_scheduler_do_irq_switch(void *context) } #endif /* RT_USING_SMP */ -/* - * This function will insert a thread to system ready queue. The state of - * thread will be set as READY and remove from suspend queue. +/** + * @brief This function will insert a thread to system ready queue. The state of + * thread will be set as READY and remove from suspend queue. * * @param thread the thread to be inserted + * * @note Please do not invoke this function in user application. */ #ifdef RT_USING_SMP @@ -835,7 +840,7 @@ void rt_schedule_remove_thread(struct rt_thread *thread) #endif /* RT_USING_SMP */ /** - * This function will lock the thread scheduler. + * @brief This function will lock the thread scheduler. */ #ifdef RT_USING_SMP void rt_enter_critical(void) @@ -897,7 +902,7 @@ void rt_enter_critical(void) RTM_EXPORT(rt_enter_critical); /** - * This function will unlock the thread scheduler. + * @brief This function will unlock the thread scheduler. */ #ifdef RT_USING_SMP void rt_exit_critical(void) @@ -971,7 +976,7 @@ void rt_exit_critical(void) RTM_EXPORT(rt_exit_critical); /** - * Get the scheduler lock level + * @brief Get the scheduler lock level. * * @return the level of the scheduler lock. 0 means unlocked. */ diff --git a/src/slab.c b/src/slab.c index ad1dc71811..4225a4d797 100644 --- a/src/slab.c +++ b/src/slab.c @@ -74,10 +74,10 @@ static void (*rt_free_hook)(void *ptr); /**@{*/ /** - * This function will set a hook function, which will be invoked when a memory - * block is allocated from heap memory. + * @brief This function will set a hook function, which will be invoked when a memory + * block is allocated from heap memory. * - * @param hook the hook function + * @param hook the hook function. */ void rt_malloc_sethook(void (*hook)(void *ptr, rt_size_t size)) { @@ -86,8 +86,8 @@ void rt_malloc_sethook(void (*hook)(void *ptr, rt_size_t size)) RTM_EXPORT(rt_malloc_sethook); /** - * This function will set a hook function, which will be invoked when a memory - * block is released to heap memory. + * @brief This function will set a hook function, which will be invoked when a memory + * block is released to heap memory. * * @param hook the hook function */ @@ -233,6 +233,11 @@ struct rt_page_head static struct rt_page_head *rt_page_list; static struct rt_semaphore heap_sem; +/** + * @brief Alloc memory size by page. + * + * @param npages the number of pages. + */ void *rt_page_alloc(rt_size_t npages) { struct rt_page_head *b, *n; @@ -269,6 +274,13 @@ void *rt_page_alloc(rt_size_t npages) return b; } +/** + * @brief Free memory by page. + * + * @param addr the head address of first page. + * + * @param npages the number of pages. + */ void rt_page_free(void *addr, rt_size_t npages) { struct rt_page_head *b, *n; @@ -334,12 +346,11 @@ static void rt_page_init(void *addr, rt_size_t npages) } /** - * @ingroup SystemInit + * @brief This function will init system heap. * - * This function will init system heap + * @param begin_addr the beginning address of system page. * - * @param begin_addr the beginning address of system page - * @param end_addr the end address of system page + * @param end_addr the end address of system page. */ void rt_system_heap_init(void *begin_addr, void *end_addr) { @@ -465,15 +476,15 @@ rt_inline int zoneindex(rt_size_t *bytes) /**@{*/ /** - * This function will allocate a block from system heap memory. - * - If the nbytes is less than zero, - * or - * - If there is no nbytes sized memory valid in system, - * the RT_NULL is returned. + * @brief This function will allocate a block from system heap memory. + * + * @note the RT_NULL is returned if + * - the nbytes is less than zero. + * - there is no nbytes sized memory valid in system. * - * @param size the size of memory to be allocated + * @param size the size of memory to be allocated. * - * @return the allocated memory + * @return the allocated memory. */ void *rt_malloc(rt_size_t size) { @@ -668,12 +679,13 @@ __exit: RTM_EXPORT(rt_malloc); /** - * This function will change the size of previously allocated memory block. + * @brief This function will change the size of previously allocated memory block. + * + * @param ptr the previously allocated memory block. * - * @param ptr the previously allocated memory block - * @param size the new size of memory block + * @param size the new size of memory block. * - * @return the allocated memory + * @return the allocated memory. */ void *rt_realloc(void *ptr, rt_size_t size) { @@ -736,16 +748,17 @@ void *rt_realloc(void *ptr, rt_size_t size) RTM_EXPORT(rt_realloc); /** - * This function will contiguously allocate enough space for count objects - * that are size bytes of memory each and returns a pointer to the allocated - * memory. + * @brief This function will contiguously allocate enough space for count objects + * that are size bytes of memory each and returns a pointer to the allocated + * memory. * - * The allocated memory is filled with bytes of value zero. + * @note The allocated memory is filled with bytes of value zero. * - * @param count number of objects to allocate - * @param size size of the objects to allocate + * @param count number of objects to allocate. * - * @return pointer to allocated memory / NULL pointer if there is an error + * @param size size of the objects to allocate. + * + * @return pointer to allocated memory / NULL pointer if there is an error. */ void *rt_calloc(rt_size_t count, rt_size_t size) { @@ -763,8 +776,9 @@ void *rt_calloc(rt_size_t count, rt_size_t size) RTM_EXPORT(rt_calloc); /** - * This function will release the previous allocated memory block by rt_malloc. - * The released memory block is taken back to system heap. + * @brief This function will release the previous allocated memory block by rt_malloc. + * + * @note The released memory block is taken back to system heap. * * @param ptr the address of memory which will be released */ @@ -905,6 +919,16 @@ void rt_free(void *ptr) RTM_EXPORT(rt_free); #ifdef RT_MEM_STATS +/** +* @brief This function will caculate the total memory, the used memory, and +* the max used memory. +* +* @param total is a pointer to get the total size of the memory. +* +* @param used is a pointer to get the size of memory used. +* +* @param max_used is a pointer to get the maximum memory used. +*/ void rt_memory_info(rt_uint32_t *total, rt_uint32_t *used, rt_uint32_t *max_used) -- cgit v1.3.1 From 5de69966704067ade411d1c4aa11bea327f69793 Mon Sep 17 00:00:00 2001 From: yangjie Date: Fri, 10 Sep 2021 17:51:52 +0800 Subject: [kernel]update format --- src/idle.c | 2 +- src/mem.c | 4 ++-- src/slab.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/idle.c b/src/idle.c index 4bf89c38e0..61f6a5b383 100644 --- a/src/idle.c +++ b/src/idle.c @@ -167,7 +167,7 @@ void rt_thread_defunct_enqueue(rt_thread_t thread) /** * @brief Dequeue a thread from defunct queue. - * + * * @note It must be called between rt_hw_interrupt_disable and rt_hw_interrupt_enable. */ rt_thread_t rt_thread_defunct_dequeue(void) diff --git a/src/mem.c b/src/mem.c index 0fefb86f89..f661d49118 100644 --- a/src/mem.c +++ b/src/mem.c @@ -618,11 +618,11 @@ RTM_EXPORT(rt_free); #ifdef RT_MEM_STATS /** -* @brief This function will caculate the total memory, the used memory, and +* @brief This function will caculate the total memory, the used memory, and * the max used memory. * * @param total is a pointer to get the total size of the memory. -* +* * @param used is a pointer to get the size of memory used. * * @param max_used is a pointer to get the maximum memory used. diff --git a/src/slab.c b/src/slab.c index 4225a4d797..87acb17da8 100644 --- a/src/slab.c +++ b/src/slab.c @@ -920,11 +920,11 @@ RTM_EXPORT(rt_free); #ifdef RT_MEM_STATS /** -* @brief This function will caculate the total memory, the used memory, and +* @brief This function will caculate the total memory, the used memory, and * the max used memory. * * @param total is a pointer to get the total size of the memory. -* +* * @param used is a pointer to get the size of memory used. * * @param max_used is a pointer to get the maximum memory used. -- cgit v1.3.1 From e6f5282f6e547c2924c8921dcfacfb13de4f9e60 Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Fri, 10 Sep 2021 18:08:30 +0800 Subject: [kernel] Improve the code comment of the cpu.c --- src/cpu.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cpu.c b/src/cpu.c index fc1fed5a06..5466a350ae 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -65,12 +65,26 @@ static void _cpu_preempt_enable(void) rt_hw_local_irq_enable(level); } +/** + * @brief Initialize a static spinlock object. + * + * @param lock is a pointer to the spinlock to initialize. + * It is assumed that storage for the spinlock will be allocated in your application. + */ void rt_spin_lock_init(struct rt_spinlock *lock) { rt_hw_spin_lock_init(&lock->lock); } RTM_EXPORT(rt_spin_lock_init) +/** + * @brief This function will lock the spinlock. + * + * @note If the spinlock is locked, the current CPU will keep polling the spinlock state + * until the spinlock is unlocked. + * + * @param lock is a pointer to the spinlock. + */ void rt_spin_lock(struct rt_spinlock *lock) { _cpu_preempt_disable(); @@ -78,6 +92,11 @@ void rt_spin_lock(struct rt_spinlock *lock) } RTM_EXPORT(rt_spin_lock) +/** + * @brief This function will unlock the spinlock. + * + * @param lock is a pointer to the spinlock. + */ void rt_spin_unlock(struct rt_spinlock *lock) { rt_hw_spin_unlock(&lock->lock); @@ -85,6 +104,16 @@ void rt_spin_unlock(struct rt_spinlock *lock) } RTM_EXPORT(rt_spin_unlock) +/** + * @brief This function will disable the local interrupt and then lock the spinlock. + * + * @note If the spinlock is locked, the current CPU will keep polling the spinlock state + * until the spinlock is unlocked. + * + * @param lock is a pointer to the spinlock. + * + * @return Return current cpu interrupt status. + */ rt_base_t rt_spin_lock_irqsave(struct rt_spinlock *lock) { unsigned long level; @@ -98,6 +127,13 @@ rt_base_t rt_spin_lock_irqsave(struct rt_spinlock *lock) } RTM_EXPORT(rt_spin_lock_irqsave) +/** + * @brief This function will unlock the spinlock and then restore current cpu interrupt status. + * + * @param lock is a pointer to the spinlock. + * + * @param level is interrupt status returned by rt_spin_lock_irqsave(). + */ void rt_spin_unlock_irqrestore(struct rt_spinlock *lock, rt_base_t level) { rt_hw_spin_unlock(&lock->lock); @@ -108,20 +144,29 @@ void rt_spin_unlock_irqrestore(struct rt_spinlock *lock, rt_base_t level) RTM_EXPORT(rt_spin_unlock_irqrestore) /** - * This fucntion will return current cpu. + * @brief This fucntion will return current cpu object. + * + * @return Return a pointer to the current cpu object. */ struct rt_cpu *rt_cpu_self(void) { return &_cpus[rt_hw_cpu_id()]; } +/** + * @brief This fucntion will return the cpu object corresponding to index. + * + * @return Return a pointer to the cpu object corresponding to index. + */ struct rt_cpu *rt_cpu_index(int index) { return &_cpus[index]; } /** - * This function will lock all cpus's scheduler and disable local irq. + * @brief This function will lock all cpus's scheduler and disable local irq. + * + * @return Return current cpu interrupt status. */ rt_base_t rt_cpus_lock(void) { @@ -148,7 +193,9 @@ rt_base_t rt_cpus_lock(void) RTM_EXPORT(rt_cpus_lock); /** - * This function will restore all cpus's scheduler and restore local irq. + * @brief This function will restore all cpus's scheduler and restore local irq. + * + * @param level is interrupt status returned by rt_cpus_lock(). */ void rt_cpus_unlock(rt_base_t level) { -- cgit v1.3.1 From 48c7a455e69c007cd166f3732bd5aa5971e31702 Mon Sep 17 00:00:00 2001 From: liukangcc Date: Fri, 10 Sep 2021 15:32:06 +0800 Subject: [update] src/thread.c function description. --- src/thread.c | 205 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 117 insertions(+), 88 deletions(-) (limited to 'src') diff --git a/src/thread.c b/src/thread.c index 7e0c10bfef..3cf9e015cb 100644 --- a/src/thread.c +++ b/src/thread.c @@ -38,12 +38,11 @@ static void (*rt_thread_resume_hook) (rt_thread_t thread); static void (*rt_thread_inited_hook) (rt_thread_t thread); /** - * @ingroup Hook - * This function sets a hook function when the system suspend a thread. + * @brief This function sets a hook function when the system suspend a thread. * - * @param hook the specified hook function + * @note the hook function must be simple and never be blocked or suspend. * - * @note the hook function must be simple and never be blocked or suspend. + * @param hook the specified hook function. */ void rt_thread_suspend_sethook(void (*hook)(rt_thread_t thread)) { @@ -51,12 +50,11 @@ void rt_thread_suspend_sethook(void (*hook)(rt_thread_t thread)) } /** - * @ingroup Hook - * This function sets a hook function when the system resume a thread. + * @brief This function sets a hook function when the system resume a thread. * - * @param hook the specified hook function + * @note the hook function must be simple and never be blocked or suspend. * - * @note the hook function must be simple and never be blocked or suspend. + * @param hook the specified hook function. */ void rt_thread_resume_sethook(void (*hook)(rt_thread_t thread)) { @@ -64,10 +62,9 @@ void rt_thread_resume_sethook(void (*hook)(rt_thread_t thread)) } /** - * @ingroup Hook - * This function sets a hook function when a thread is initialized. + * @brief This function sets a hook function when a thread is initialized. * - * @param hook the specified hook function + * @param hook the specified hook function. */ void rt_thread_inited_sethook(void (*hook)(rt_thread_t thread)) { @@ -76,7 +73,6 @@ void rt_thread_inited_sethook(void (*hook)(rt_thread_t thread)) #endif /* RT_USING_HOOK */ -/* must be invoke witch rt_hw_interrupt_disable */ static void _thread_cleanup_execute(rt_thread_t thread) { register rt_base_t level; @@ -244,19 +240,27 @@ static rt_err_t _thread_init(struct rt_thread *thread, /**@{*/ /** - * This function will initialize a thread, normally it's used to initialize a - * static thread object. - * - * @param thread the static thread object - * @param name the name of thread, which shall be unique - * @param entry the entry function of thread - * @param parameter the parameter of thread enter function - * @param stack_start the start address of thread stack - * @param stack_size the size of thread stack - * @param priority the priority of thread - * @param tick the time slice if there are same priority thread - * - * @return the operation status, RT_EOK on OK, -RT_ERROR on error + * @brief This function will initialize a thread, normally it's used to initialize a + * static thread object. + * + * @param thread the static thread object. + * + * @param name the name of thread, which shall be unique. + * + * @param entry the entry function of thread. + * + * @param parameter the parameter of thread enter function. + * + * @param stack_start the start address of thread stack. + * + * @param stack_size the size of thread stack. + * + * @param priority the priority of thread. + * + * @param tick the time slice if there are same priority thread. + * + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_init(struct rt_thread *thread, const char *name, @@ -286,9 +290,9 @@ rt_err_t rt_thread_init(struct rt_thread *thread, RTM_EXPORT(rt_thread_init); /** - * This function will return self thread object + * @brief This function will return self thread object. * - * @return the self thread object + * @return the self thread object. */ rt_thread_t rt_thread_self(void) { @@ -309,11 +313,12 @@ rt_thread_t rt_thread_self(void) RTM_EXPORT(rt_thread_self); /** - * This function will start a thread and put it to system ready queue + * @brief This function will start a thread and put it to system ready queue. * - * @param thread the thread to be started + * @param thread the thread to be started. * - * @return the operation status, RT_EOK on OK, -RT_ERROR on error + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_startup(rt_thread_t thread) { @@ -351,12 +356,13 @@ rt_err_t rt_thread_startup(rt_thread_t thread) RTM_EXPORT(rt_thread_startup); /** - * This function will detach a thread. The thread object will be removed from - * thread queue and detached/deleted from system object management. + * @brief This function will detach a thread. The thread object will be removed from + * thread queue and detached/deleted from system object management. * - * @param thread the thread to be deleted + * @param thread the thread to be deleted. * - * @return the operation status, RT_EOK on OK, -RT_ERROR on error + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_detach(rt_thread_t thread) { @@ -404,17 +410,22 @@ RTM_EXPORT(rt_thread_detach); #ifdef RT_USING_HEAP /** - * This function will create a thread object and allocate thread object memory - * and stack. + * @brief This function will create a thread object and allocate thread object memory. + * and stack. + * + * @param name the name of thread, which shall be unique. + * + * @param entry the entry function of thread. * - * @param name the name of thread, which shall be unique - * @param entry the entry function of thread - * @param parameter the parameter of thread enter function - * @param stack_size the size of thread stack - * @param priority the priority of thread - * @param tick the time slice if there are same priority thread + * @param parameter the parameter of thread enter function. * - * @return the created thread object + * @param stack_size the size of thread stack. + * + * @param priority the priority of thread. + * + * @param tick the time slice if there are same priority thread. + * + * @return the created thread object. */ rt_thread_t rt_thread_create(const char *name, void (*entry)(void *parameter), @@ -454,12 +465,13 @@ rt_thread_t rt_thread_create(const char *name, RTM_EXPORT(rt_thread_create); /** - * This function will delete a thread. The thread object will be removed from - * thread queue and deleted from system object management in the idle thread. + * @brief This function will delete a thread. The thread object will be removed from + * thread queue and deleted from system object management in the idle thread. * - * @param thread the thread to be deleted + * @param thread the thread to be deleted. * - * @return the operation status, RT_EOK on OK, -RT_ERROR on error + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_delete(rt_thread_t thread) { @@ -502,11 +514,12 @@ RTM_EXPORT(rt_thread_delete); #endif /* RT_USING_HEAP */ /** - * This function will let current thread yield processor, and scheduler will - * choose a highest thread to run. After yield processor, the current thread - * is still in READY state. + * @brief This function will let current thread yield processor, and scheduler will + * choose a highest thread to run. After yield processor, the current thread + * is still in READY state. * - * @return RT_EOK + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_yield(void) { @@ -525,11 +538,13 @@ rt_err_t rt_thread_yield(void) RTM_EXPORT(rt_thread_yield); /** - * This function will let current thread sleep for some ticks. + * @brief This function will let current thread sleep for some ticks. Change current thread state to suspend, + * when the thread timer reaches the tick value, scheduler will awaken this thread. * - * @param tick the sleep ticks + * @param tick the sleep ticks. * - * @return RT_EOK + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_sleep(rt_tick_t tick) { @@ -564,11 +579,12 @@ rt_err_t rt_thread_sleep(rt_tick_t tick) } /** - * This function will let current thread delay for some ticks. + * @brief This function will let current thread delay for some ticks. * - * @param tick the delay ticks + * @param tick the delay ticks. * - * @return RT_EOK + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_delay(rt_tick_t tick) { @@ -577,12 +593,14 @@ rt_err_t rt_thread_delay(rt_tick_t tick) RTM_EXPORT(rt_thread_delay); /** - * This function will let current thread delay until (*tick + inc_tick). + * @brief This function will let current thread delay until (*tick + inc_tick). * - * @param tick the tick of last wakeup. - * @param inc_tick the increment tick + * @param tick the tick of last wakeup. * - * @return RT_EOK + * @param inc_tick the increment tick. + * + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick) { @@ -637,11 +655,12 @@ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick) RTM_EXPORT(rt_thread_delay_until); /** - * This function will let current thread delay for some milliseconds. + * @brief This function will let current thread delay for some milliseconds. * - * @param ms the delay ms time + * @param ms the delay ms time. * - * @return RT_EOK + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_mdelay(rt_int32_t ms) { @@ -654,17 +673,24 @@ rt_err_t rt_thread_mdelay(rt_int32_t ms) RTM_EXPORT(rt_thread_mdelay); /** - * This function will control thread behaviors according to control command. + * @brief This function will control thread behaviors according to control command. + * + * @param thread the specified thread to be controlled. + * + * @param cmd the control command, which includes. * - * @param thread the specified thread to be controlled - * @param cmd the control command, which includes - * RT_THREAD_CTRL_CHANGE_PRIORITY for changing priority level of thread; - * RT_THREAD_CTRL_STARTUP for starting a thread; - * RT_THREAD_CTRL_CLOSE for delete a thread; - * RT_THREAD_CTRL_BIND_CPU for bind the thread to a CPU. - * @param arg the argument of control command + * RT_THREAD_CTRL_CHANGE_PRIORITY for changing priority level of thread. * - * @return RT_EOK + * RT_THREAD_CTRL_STARTUP for starting a thread. + * + * RT_THREAD_CTRL_CLOSE for delete a thread. + * + * RT_THREAD_CTRL_BIND_CPU for bind the thread to a CPU. + * + * @param arg the argument of control command. + * + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg) { @@ -770,14 +796,15 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg) RTM_EXPORT(rt_thread_control); /** - * This function will suspend the specified thread. + * @brief This function will suspend the specified thread and change it to suspend state. * - * @param thread the thread to be suspended + * @note if suspend self thread, after this function call, the + * rt_schedule() must be invoked. * - * @return the operation status, RT_EOK on OK, -RT_ERROR on error + * @param thread the thread to be suspended. * - * @note if suspend self thread, after this function call, the - * rt_schedule() must be invoked. + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_suspend(rt_thread_t thread) { @@ -822,11 +849,12 @@ rt_err_t rt_thread_suspend(rt_thread_t thread) RTM_EXPORT(rt_thread_suspend); /** - * This function will resume a thread and put it to system ready queue. + * @brief This function will resume a thread and put it to system ready queue. * - * @param thread the thread to be resumed + * @param thread the thread to be resumed. * - * @return the operation status, RT_EOK on OK, -RT_ERROR on error + * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. + * When the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_resume(rt_thread_t thread) { @@ -866,10 +894,10 @@ rt_err_t rt_thread_resume(rt_thread_t thread) RTM_EXPORT(rt_thread_resume); /** - * This function is the timeout function for thread, normally which is invoked - * when thread is timeout to wait some resource. + * @brief This function is the timeout function for thread, normally which is invoked + * when thread is timeout to wait some resource. * - * @param parameter the parameter of thread timeout function + * @param parameter the parameter of thread timeout function */ void rt_thread_timeout(void *parameter) { @@ -904,18 +932,19 @@ void rt_thread_timeout(void *parameter) RTM_EXPORT(rt_thread_timeout); /** - * This function will find the specified thread. + * @brief This function will find the specified thread. * - * @param name the name of thread finding + * @note please don't invoke this function in interrupt status. * - * @return the found thread + * @param name the name of thread finding. * - * @note please don't invoke this function in interrupt status. + * @return the found thread. */ rt_thread_t rt_thread_find(char *name) { return (rt_thread_t)rt_object_find(name, RT_Object_Class_Thread); } + RTM_EXPORT(rt_thread_find); /**@}*/ -- cgit v1.3.1 From 464d0c5a97a23f3ec89778945da650b251eddebc Mon Sep 17 00:00:00 2001 From: yangjie Date: Sat, 11 Sep 2021 16:40:56 +0800 Subject: [kernel] update comments --- src/device.c | 64 ++++++++++++++++++++++++++++----------------------------- src/mem.c | 22 ++++++++++---------- src/mempool.c | 39 ++++++++++++++++++----------------- src/object.c | 40 ++++++++++++++++++------------------ src/scheduler.c | 35 +++++++++++++++---------------- src/slab.c | 16 +++++++-------- 6 files changed, 108 insertions(+), 108 deletions(-) (limited to 'src') diff --git a/src/device.c b/src/device.c index 2c1d31f23e..6e22c2b692 100644 --- a/src/device.c +++ b/src/device.c @@ -39,13 +39,13 @@ #endif /* RT_USING_DEVICE_OPS */ /** - * @brief This function registers a device driver with specified name. + * @brief This function registers a device driver with a specified name. * - * @param dev the pointer of device driver structure. + * @param dev is the pointer of device driver structure. * - * @param name the device driver's name. + * @param name is the device driver's name. * - * @param flags the capabilities flag of device. + * @param flags is the capabilities flag of device. * * @return the error code, RT_EOK on initialization successfully. */ @@ -76,7 +76,7 @@ RTM_EXPORT(rt_device_register); /** * @brief This function removes a previously registered device driver. * - * @param dev the pointer of device driver structure. + * @param dev is the pointer of device driver structure. * * @return the error code, RT_EOK on successfully. */ @@ -95,7 +95,7 @@ RTM_EXPORT(rt_device_unregister); /** * @brief This function finds a device driver by specified name. * - * @param name the device driver's name. + * @param name is the device driver's name. * * @return the registered device driver on successful, or RT_NULL on failure. */ @@ -109,9 +109,9 @@ RTM_EXPORT(rt_device_find); /** * @brief This function creates a device object with user data size. * - * @param type the kind type of this device object. + * @param type is the type of the device object. * - * @param attach_size the size of user data. + * @param attach_size is the size of user data. * * @return the allocated device object, or RT_NULL when failed. */ @@ -139,7 +139,7 @@ RTM_EXPORT(rt_device_create); /** * @brief This function destroy the specific device object. * - * @param dev the specific device object. + * @param dev is a specific device object. */ void rt_device_destroy(rt_device_t dev) { @@ -158,7 +158,7 @@ RTM_EXPORT(rt_device_destroy); /** * @brief This function will initialize the specified device. * - * @param dev the pointer of device driver structure. + * @param dev is the pointer of device driver structure. * * @return the result, RT_EOK on successfully. */ @@ -192,9 +192,9 @@ rt_err_t rt_device_init(rt_device_t dev) /** * @brief This function will open a device. * - * @param dev the pointer of device driver structure. + * @param dev is the pointer of device driver structure. * - * @param oflag the flags for device open. + * @param oflag is the flags for device open. * * @return the result, RT_EOK on successfully. */ @@ -259,7 +259,7 @@ RTM_EXPORT(rt_device_open); /** * @brief This function will close a device. * - * @param dev the pointer of device driver structure. + * @param dev is the pointer of device driver structure. * * @return the result, RT_EOK on successfully. */ @@ -295,13 +295,13 @@ RTM_EXPORT(rt_device_close); /** * @brief This function will read some data from a device. * - * @param dev the pointer of device driver structure. + * @param dev is the pointer of device driver structure. * - * @param pos the position of reading. + * @param pos is the position when reading. * - * @param buffer the data buffer to save read data. + * @param buffer is a data buffer to save the read data. * - * @param size the size of buffer. + * @param size is the size of buffer. * * @return the actually read size on successful, otherwise negative returned. * @@ -337,13 +337,13 @@ RTM_EXPORT(rt_device_read); /** * @brief This function will write some data to a device. * - * @param dev the pointer of device driver structure. + * @param dev is the pointer of device driver structure. * - * @param pos the position of written. + * @param pos is the position when writing. * - * @param buffer the data buffer to be written to device. + * @param buffer is the data buffer to be written to device. * - * @param size the size of buffer. + * @param size is the size of buffer. * * @return the actually written size on successful, otherwise negative returned. * @@ -379,11 +379,11 @@ RTM_EXPORT(rt_device_write); /** * @brief This function will perform a variety of control functions on devices. * - * @param dev the pointer of device driver structure. + * @param dev is the pointer of device driver structure. * - * @param cmd the command sent to device. + * @param cmd is the command sent to device. * - * @param arg the argument of command. + * @param arg is the argument of command. * * @return the result, -RT_ENOSYS for failed. */ @@ -406,11 +406,11 @@ RTM_EXPORT(rt_device_control); * @brief This function will set the reception indication callback function. This callback function * is invoked when this device receives data. * - * @param dev the pointer of device driver structure. + * @param dev is the pointer of device driver structure. * - * @param rx_ind the indication callback function. + * @param rx_ind is the indication callback function. * - * @return RT_EOK. + * @return RT_EOK */ rt_err_t rt_device_set_rx_indicate(rt_device_t dev, @@ -426,14 +426,14 @@ rt_device_set_rx_indicate(rt_device_t dev, RTM_EXPORT(rt_device_set_rx_indicate); /** - * @brief This function will set the indication callback function when device has - * written data to physical hardware. + * @brief This function will set a callback function. The callback function + * will be called when device has written data to physical hardware. * - * @param dev the pointer of device driver structure. + * @param dev is the pointer of device driver structure. * - * @param tx_done the indication callback function. + * @param tx_done is the indication callback function. * - * @return RT_EOK. + * @return RT_EOK */ rt_err_t rt_device_set_tx_complete(rt_device_t dev, diff --git a/src/mem.c b/src/mem.c index f661d49118..3c0816748e 100644 --- a/src/mem.c +++ b/src/mem.c @@ -266,7 +266,7 @@ void rt_system_heap_init(void *begin_addr, void *end_addr) * * @param size is the minimum size of the requested block in bytes. * - * @return pointer to allocated memory or NULL if no free memory was found. + * @return the pointer to allocated memory or NULL if no free memory was found. */ void *rt_malloc(rt_size_t size) { @@ -410,11 +410,11 @@ void *rt_malloc(rt_size_t size) RTM_EXPORT(rt_malloc); /** - * @brief This function will change the previously allocated memory block. + * @brief This function will change the size of previously allocated memory block. * - * @param rmem pointer to memory allocated by rt_malloc. + * @param rmem is the pointer to memory allocated by rt_malloc. * - * @param newsize the required new size. + * @param newsize is the required new size. * * @return the changed memory block address. */ @@ -517,15 +517,15 @@ void *rt_realloc(void *rmem, rt_size_t newsize) RTM_EXPORT(rt_realloc); /** - * @brief This function will contiguously allocate enough space for count objects - * that are size bytes of memory each and returns a pointer to the allocated - * memory. + * @brief This function will contiguously allocate enough space for count objects + * that are size bytes of memory each and returns a pointer to the allocated + * memory. * - * @note The allocated memory is filled with bytes of value zero. + * @note The allocated memory is filled with bytes of value zero. * - * @param count number of objects to allocate. + * @param count is the number of objects to allocate. * - * @param size size of the objects to allocate. + * @param size is the size of one object to allocate. * * @return pointer to allocated memory / NULL pointer if there is an error. */ @@ -548,7 +548,7 @@ RTM_EXPORT(rt_calloc); * @brief This function will release the previously allocated memory block by * rt_malloc. The released memory block is taken back to system heap. * - * @param rmem the address of memory which will be released + * @param rmem the address of memory which will be released. */ void rt_free(void *rmem) { diff --git a/src/mempool.c b/src/mempool.c index 9b201c5f89..09a4955eee 100644 --- a/src/mempool.c +++ b/src/mempool.c @@ -33,7 +33,7 @@ static void (*rt_mp_free_hook)(struct rt_mempool *mp, void *block); /** * @brief This function will set a hook function, which will be invoked when a memory - * block is allocated from memory pool. + * block is allocated from the memory pool. * * @param hook the hook function */ @@ -44,7 +44,7 @@ void rt_mp_alloc_sethook(void (*hook)(struct rt_mempool *mp, void *block)) /** * @brief This function will set a hook function, which will be invoked when a memory - * block is released to memory pool. + * block is released to the memory pool. * * @param hook the hook function */ @@ -63,18 +63,18 @@ void rt_mp_free_sethook(void (*hook)(struct rt_mempool *mp, void *block)) /**@{*/ /** - * @brief This function will initialize a memory pool object, normally which is used - * for static object. + * @brief This function will initialize a memory pool object, normally which is used + * for static object. * - * @param mp the memory pool object + * @param mp is the memory pool object. * - * @param name the name of memory pool + * @param name is the name of the memory pool. * - * @param start the star address of memory pool + * @param start is the start address of the memory pool. * - * @param size the total size of memory pool + * @param size is the total size of the memory pool. * - * @param block_size the size for each block + * @param block_size is the size for each block.. * * @return RT_EOK */ @@ -129,9 +129,9 @@ rt_err_t rt_mp_init(struct rt_mempool *mp, RTM_EXPORT(rt_mp_init); /** - * @brief This function will detach a memory pool from system object management. + * @brief This function will detach a memory pool from system object management. * - * @param mp the memory pool object. + * @param mp is the memory pool object. * * @return RT_EOK */ @@ -179,11 +179,11 @@ RTM_EXPORT(rt_mp_detach); * @brief This function will create a mempool object and allocate the memory pool from * heap. * - * @param name the name of memory pool + * @param name is the name of memory pool. * - * @param block_count the count of blocks in memory pool + * @param block_count is the count of blocks in memory pool. * - * @param block_size the size for each block + * @param block_size is the size for each block. * * @return the created mempool object */ @@ -249,7 +249,7 @@ RTM_EXPORT(rt_mp_create); /** * @brief This function will delete a memory pool and release the object memory. * - * @param mp the memory pool object. + * @param mp is the memory pool object. * * @return RT_EOK */ @@ -301,9 +301,10 @@ RTM_EXPORT(rt_mp_delete); /** * @brief This function will allocate a block from memory pool. * - * @param mp the memory pool object. + * @param mp is the memory pool object. * - * @param time the waiting time. + * @param time is the maximum waiting time for allocating memory. + * - 0 for not waiting, allocating memory immediately. * * @return the allocated memory block or RT_NULL on allocated failed. */ @@ -399,9 +400,9 @@ void *rt_mp_alloc(rt_mp_t mp, rt_int32_t time) RTM_EXPORT(rt_mp_alloc); /** - * @brief This function will release a memory block + * @brief This function will release a memory block. * - * @param block the address of memory block to be released + * @param block the address of memory block to be released. */ void rt_mp_free(void *block) { diff --git a/src/object.c b/src/object.c index de0140ebfa..66d5775bd7 100644 --- a/src/object.c +++ b/src/object.c @@ -123,7 +123,7 @@ void (*rt_object_put_hook)(struct rt_object *object); * @brief This function will set a hook function, which will be invoked when object * attaches to kernel object system. * - * @param hook the hook function. + * @param hook is the hook function. */ void rt_object_attach_sethook(void (*hook)(struct rt_object *object)) { @@ -134,7 +134,7 @@ void rt_object_attach_sethook(void (*hook)(struct rt_object *object)) * @brief This function will set a hook function, which will be invoked when object * detaches from kernel object system. * - * @param hook the hook function + * @param hook is the hook function */ void rt_object_detach_sethook(void (*hook)(struct rt_object *object)) { @@ -152,7 +152,7 @@ void rt_object_detach_sethook(void (*hook)(struct rt_object *object)) * mailbox - mail is received by thread * message queue - message is received by thread * - * @param hook the hook function. + * @param hook is the hook function. */ void rt_object_trytake_sethook(void (*hook)(struct rt_object *object)) { @@ -182,7 +182,7 @@ void rt_object_take_sethook(void (*hook)(struct rt_object *object)) * @brief This function will set a hook function, which will be invoked when object * is put to kernel object system. * - * @param hook the hook function + * @param hook is the hook function */ void rt_object_put_sethook(void (*hook)(struct rt_object *object)) { @@ -201,7 +201,7 @@ void rt_object_put_sethook(void (*hook)(struct rt_object *object)) /** * @brief This function will return the specified type of object information. * - * @param type the type of object, which can be + * @param type is the type of object, which can be * RT_Object_Class_Thread/Semaphore/Mutex... etc * * @return the object type information or RT_NULL @@ -221,7 +221,7 @@ RTM_EXPORT(rt_object_get_information); /** * @brief This function will return the length of object list in object container. * - * @param type the type of object, which can be + * @param type is the type of object, which can be * RT_Object_Class_Thread/Semaphore/Mutex... etc * * @return the length of object list @@ -252,14 +252,14 @@ RTM_EXPORT(rt_object_get_length); * @brief This function will copy the object pointer of the specified type, * with the maximum size specified by maxlen. * - * @param type the type of object, which can be + * @param type is the type of object, which can be * RT_Object_Class_Thread/Semaphore/Mutex... etc * - * @param pointers the pointers will be saved to + * @param pointers is the pointer will be saved to. * - * @param maxlen the maximum number of pointers can be saved + * @param maxlen is the maximum number of pointers can be saved. * - * @return the copied number of object pointers + * @return the copied number of object pointers. */ int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers, int maxlen) { @@ -296,11 +296,11 @@ RTM_EXPORT(rt_object_get_pointers); * @brief This function will initialize an object and add it to object system * management. * - * @param object the specified object to be initialized. + * @param object is the specified object to be initialized. * - * @param type the object type. + * @param type is the object type. * - * @param name the object name. In system, the object's name must be unique. + * @param name is the object name. In system, the object's name must be unique. */ void rt_object_init(struct rt_object *object, enum rt_object_class_type type, @@ -397,9 +397,9 @@ void rt_object_detach(rt_object_t object) /** * @brief This function will allocate an object from object system. * - * @param type the type of object + * @param type is the type of object. * - * @param name the object name. In system, the object's name must be unique. + * @param name is the object name. In system, the object's name must be unique. * * @return object */ @@ -467,7 +467,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name) /** * @brief This function will delete an object and release object memory. * - * @param object the specified object to be deleted. + * @param object is the specified object to be deleted. */ void rt_object_delete(rt_object_t object) { @@ -502,7 +502,7 @@ void rt_object_delete(rt_object_t object) * @note Normally, the system object is a static object and the type * of object set to RT_Object_Class_Static. * - * @param object the specified object to be judged. + * @param object is the specified object to be judged. * * @return RT_TRUE if a system object, RT_FALSE for others. */ @@ -521,7 +521,7 @@ rt_bool_t rt_object_is_systemobject(rt_object_t object) * @brief This function will return the type of object without * RT_Object_Class_Static flag. * - * @param object the specified object to be get type. + * @param object is the specified object to be get type. * * @return the type of object. */ @@ -537,9 +537,9 @@ rt_uint8_t rt_object_get_type(rt_object_t object) * @brief This function will find specified name object from object * container. * - * @param name the specified name of object. + * @param name is the specified name of object. * - * @param type the type of object + * @param type is the type of object * * @return the found object or RT_NULL if there is no this object * in object container. diff --git a/src/scheduler.c b/src/scheduler.c index dc0073d097..6ef02f3d3c 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -61,7 +61,7 @@ static void (*rt_scheduler_switch_hook)(struct rt_thread *tid); * @brief This function will set a hook function, which will be invoked when thread * switch happens. * - * @param hook the hook function. + * @param hook is the hook function. */ void rt_scheduler_sethook(void (*hook)(struct rt_thread *from, struct rt_thread *to)) { @@ -72,7 +72,7 @@ void rt_scheduler_sethook(void (*hook)(struct rt_thread *from, struct rt_thread * @brief This function will set a hook function, which will be invoked when context * switch happens. * - * @param hook the hook function. + * @param hook is the hook function. */ void rt_scheduler_switch_sethook(void (*hook)(struct rt_thread *tid)) { @@ -235,9 +235,8 @@ void rt_system_scheduler_init(void) } /** - * @ingroup SystemInit - * This function will startup scheduler. It will select one thread - * with the highest priority level, then switch to it. + * @brief This function will startup the scheduler. It will select one thread + * with the highest priority level, then switch to it. */ void rt_system_scheduler_start(void) { @@ -276,9 +275,9 @@ void rt_system_scheduler_start(void) /** * @brief This function will handle IPI interrupt and do a scheduling in system. * - * @param vector the number of IPI interrupt for system scheduling. + * @param vector is the number of IPI interrupt for system scheduling. * - * @param param use RT_NULL. + * @param param is not used, and can be set to RT_NULL. * * @note this function should be invoke or register as ISR in BSP. */ @@ -411,8 +410,8 @@ __exit: } #else /** - * @brief This function will perform one schedule. It will select one thread - * with the highest priority level, and switch to it immediately. + * @brief This function will perform scheduling once. It will select one thread + * with the highest priority, and switch to it immediately. */ void rt_schedule(void) { @@ -540,7 +539,7 @@ __exit: #endif /* RT_USING_SMP */ /** - * @brief This function checks if a scheduling is needed after IRQ context. If yes, + * @brief This function checks whether a scheduling is needed after an IRQ context switching. If yes, * it will select one thread with the highest priority level, and then switch * to it. */ @@ -636,12 +635,12 @@ void rt_scheduler_do_irq_switch(void *context) #endif /* RT_USING_SMP */ /** - * @brief This function will insert a thread to system ready queue. The state of - * thread will be set as READY and remove from suspend queue. + * @brief This function will insert a thread to the system ready queue. The state of + * thread will be set as READY and the thread will be removed from suspend queue. * - * @param thread the thread to be inserted + * @param thread is the thread to be inserted. * - * @note Please do not invoke this function in user application. + * @note Please do not invoke this function in user application. */ #ifdef RT_USING_SMP void rt_schedule_insert_thread(struct rt_thread *thread) @@ -746,12 +745,12 @@ __exit: } #endif /* RT_USING_SMP */ -/* - * This function will remove a thread from system ready queue. +/** + * @brief This function will remove a thread from system ready queue. * - * @param thread the thread to be removed + * @param thread is the thread to be removed. * - * @note Please do not invoke this function in user application. + * @note Please do not invoke this function in user application. */ #ifdef RT_USING_SMP void rt_schedule_remove_thread(struct rt_thread *thread) diff --git a/src/slab.c b/src/slab.c index 87acb17da8..8e0ce7bc83 100644 --- a/src/slab.c +++ b/src/slab.c @@ -277,9 +277,9 @@ void *rt_page_alloc(rt_size_t npages) /** * @brief Free memory by page. * - * @param addr the head address of first page. + * @param addr is the head address of first page. * - * @param npages the number of pages. + * @param npages is the number of pages. */ void rt_page_free(void *addr, rt_size_t npages) { @@ -482,7 +482,7 @@ rt_inline int zoneindex(rt_size_t *bytes) * - the nbytes is less than zero. * - there is no nbytes sized memory valid in system. * - * @param size the size of memory to be allocated. + * @param size is the size of memory to be allocated. * * @return the allocated memory. */ @@ -681,9 +681,9 @@ RTM_EXPORT(rt_malloc); /** * @brief This function will change the size of previously allocated memory block. * - * @param ptr the previously allocated memory block. + * @param ptr is the previously allocated memory block. * - * @param size the new size of memory block. + * @param size is the new size of memory block. * * @return the allocated memory. */ @@ -754,9 +754,9 @@ RTM_EXPORT(rt_realloc); * * @note The allocated memory is filled with bytes of value zero. * - * @param count number of objects to allocate. + * @param count is the number of objects to allocate. * - * @param size size of the objects to allocate. + * @param size is the size of the objects to allocate. * * @return pointer to allocated memory / NULL pointer if there is an error. */ @@ -780,7 +780,7 @@ RTM_EXPORT(rt_calloc); * * @note The released memory block is taken back to system heap. * - * @param ptr the address of memory which will be released + * @param ptr is the address of memory which will be released */ void rt_free(void *ptr) { -- cgit v1.3.1 From 202b23371d6ea028648fa820c4977c7d12217f35 Mon Sep 17 00:00:00 2001 From: liukangcc Date: Sat, 11 Sep 2021 13:37:37 +0800 Subject: [update] thread.c api annotation. --- src/thread.c | 138 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 70 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/thread.c b/src/thread.c index 3cf9e015cb..0c7ae4beaa 100644 --- a/src/thread.c +++ b/src/thread.c @@ -40,9 +40,9 @@ static void (*rt_thread_inited_hook) (rt_thread_t thread); /** * @brief This function sets a hook function when the system suspend a thread. * - * @note the hook function must be simple and never be blocked or suspend. + * @note The hook function must be simple and never be blocked or suspend. * - * @param hook the specified hook function. + * @param hook is the specified hook function. */ void rt_thread_suspend_sethook(void (*hook)(rt_thread_t thread)) { @@ -52,9 +52,9 @@ void rt_thread_suspend_sethook(void (*hook)(rt_thread_t thread)) /** * @brief This function sets a hook function when the system resume a thread. * - * @note the hook function must be simple and never be blocked or suspend. + * @note The hook function must be simple and never be blocked or suspend. * - * @param hook the specified hook function. + * @param hook is the specified hook function. */ void rt_thread_resume_sethook(void (*hook)(rt_thread_t thread)) { @@ -64,7 +64,7 @@ void rt_thread_resume_sethook(void (*hook)(rt_thread_t thread)) /** * @brief This function sets a hook function when a thread is initialized. * - * @param hook the specified hook function. + * @param hook is the specified hook function. */ void rt_thread_inited_sethook(void (*hook)(rt_thread_t thread)) { @@ -240,27 +240,27 @@ static rt_err_t _thread_init(struct rt_thread *thread, /**@{*/ /** - * @brief This function will initialize a thread, normally it's used to initialize a + * @brief This function will initialize a thread. It's used to initialize a * static thread object. * - * @param thread the static thread object. + * @param thread is the static thread object. * - * @param name the name of thread, which shall be unique. + * @param name is the name of thread, which shall be unique. * - * @param entry the entry function of thread. + * @param entry is the entry function of thread. * - * @param parameter the parameter of thread enter function. + * @param parameter is the parameter of thread enter function. * - * @param stack_start the start address of thread stack. + * @param stack_start is the start address of thread stack. * - * @param stack_size the size of thread stack. + * @param stack_size is the size of thread stack. * - * @param priority the priority of thread. + * @param priority is the priority of thread. * - * @param tick the time slice if there are same priority thread. + * @param tick is the time slice if there are same priority thread. * - * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. - * When the return value is any other values, it means this operation failed. + * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. + * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_init(struct rt_thread *thread, const char *name, @@ -292,7 +292,7 @@ RTM_EXPORT(rt_thread_init); /** * @brief This function will return self thread object. * - * @return the self thread object. + * @return The self thread object. */ rt_thread_t rt_thread_self(void) { @@ -315,10 +315,10 @@ RTM_EXPORT(rt_thread_self); /** * @brief This function will start a thread and put it to system ready queue. * - * @param thread the thread to be started. + * @param thread is the thread to be started. * - * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. - * When the return value is any other values, it means this operation failed. + * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. + * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_startup(rt_thread_t thread) { @@ -357,12 +357,12 @@ RTM_EXPORT(rt_thread_startup); /** * @brief This function will detach a thread. The thread object will be removed from - * thread queue and detached/deleted from system object management. + * thread queue and detached/deleted from the system object management. * - * @param thread the thread to be deleted. + * @param thread is the thread to be deleted. * - * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. - * When the return value is any other values, it means this operation failed. + * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. + * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_detach(rt_thread_t thread) { @@ -413,19 +413,20 @@ RTM_EXPORT(rt_thread_detach); * @brief This function will create a thread object and allocate thread object memory. * and stack. * - * @param name the name of thread, which shall be unique. + * @param name is the name of thread, which shall be unique. * - * @param entry the entry function of thread. + * @param entry is the entry function of thread. * - * @param parameter the parameter of thread enter function. + * @param parameter is the parameter of thread enter function. * - * @param stack_size the size of thread stack. + * @param stack_size is the size of thread stack. * - * @param priority the priority of thread. + * @param priority is the priority of thread. * - * @param tick the time slice if there are same priority thread. + * @param tick is the time slice if there are same priority thread. * - * @return the created thread object. + * @return If the return value is a rt_thread structure pointer, the function is successfully executed. + * If the return value is RT_NULL, it means this operation failed. */ rt_thread_t rt_thread_create(const char *name, void (*entry)(void *parameter), @@ -468,10 +469,10 @@ RTM_EXPORT(rt_thread_create); * @brief This function will delete a thread. The thread object will be removed from * thread queue and deleted from system object management in the idle thread. * - * @param thread the thread to be deleted. + * @param thread is the thread to be deleted. * - * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. - * When the return value is any other values, it means this operation failed. + * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. + * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_delete(rt_thread_t thread) { @@ -514,12 +515,12 @@ RTM_EXPORT(rt_thread_delete); #endif /* RT_USING_HEAP */ /** - * @brief This function will let current thread yield processor, and scheduler will - * choose a highest thread to run. After yield processor, the current thread - * is still in READY state. + * @brief This function will let current thread yield processor, and scheduler will + * choose the highest thread to run. After yield processor, the current thread + * is still in READY state. * - * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. - * When the return value is any other values, it means this operation failed. + * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. + * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_yield(void) { @@ -541,10 +542,10 @@ RTM_EXPORT(rt_thread_yield); * @brief This function will let current thread sleep for some ticks. Change current thread state to suspend, * when the thread timer reaches the tick value, scheduler will awaken this thread. * - * @param tick the sleep ticks. + * @param tick is the sleep ticks. * - * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. - * When the return value is any other values, it means this operation failed. + * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. + * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_sleep(rt_tick_t tick) { @@ -581,10 +582,10 @@ rt_err_t rt_thread_sleep(rt_tick_t tick) /** * @brief This function will let current thread delay for some ticks. * - * @param tick the delay ticks. + * @param tick is the delay ticks. * - * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. - * When the return value is any other values, it means this operation failed. + * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. + * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_delay(rt_tick_t tick) { @@ -595,12 +596,12 @@ RTM_EXPORT(rt_thread_delay); /** * @brief This function will let current thread delay until (*tick + inc_tick). * - * @param tick the tick of last wakeup. + * @param tick is the tick of last wakeup. * - * @param inc_tick the increment tick. + * @param inc_tick is the increment tick. * - * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. - * When the return value is any other values, it means this operation failed. + * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. + * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick) { @@ -657,10 +658,10 @@ RTM_EXPORT(rt_thread_delay_until); /** * @brief This function will let current thread delay for some milliseconds. * - * @param ms the delay ms time. + * @param ms is the delay ms time. * - * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. - * When the return value is any other values, it means this operation failed. + * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. + * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_mdelay(rt_int32_t ms) { @@ -675,9 +676,9 @@ RTM_EXPORT(rt_thread_mdelay); /** * @brief This function will control thread behaviors according to control command. * - * @param thread the specified thread to be controlled. + * @param thread is the specified thread to be controlled. * - * @param cmd the control command, which includes. + * @param cmd is the control command, which includes. * * RT_THREAD_CTRL_CHANGE_PRIORITY for changing priority level of thread. * @@ -687,10 +688,10 @@ RTM_EXPORT(rt_thread_mdelay); * * RT_THREAD_CTRL_BIND_CPU for bind the thread to a CPU. * - * @param arg the argument of control command. + * @param arg is the argument of control command. * - * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. - * When the return value is any other values, it means this operation failed. + * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. + * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg) { @@ -798,13 +799,13 @@ RTM_EXPORT(rt_thread_control); /** * @brief This function will suspend the specified thread and change it to suspend state. * - * @note if suspend self thread, after this function call, the + * @note If suspend self thread, after this function call, the * rt_schedule() must be invoked. * - * @param thread the thread to be suspended. + * @param thread is the thread to be suspended. * - * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. - * When the return value is any other values, it means this operation failed. + * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. + * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_suspend(rt_thread_t thread) { @@ -851,10 +852,10 @@ RTM_EXPORT(rt_thread_suspend); /** * @brief This function will resume a thread and put it to system ready queue. * - * @param thread the thread to be resumed. + * @param thread is the thread to be resumed. * - * @return Return the operation status. When the return value is RT_EOK, the function is successfully executed. - * When the return value is any other values, it means this operation failed. + * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. + * If the return value is any other values, it means this operation failed. */ rt_err_t rt_thread_resume(rt_thread_t thread) { @@ -897,7 +898,7 @@ RTM_EXPORT(rt_thread_resume); * @brief This function is the timeout function for thread, normally which is invoked * when thread is timeout to wait some resource. * - * @param parameter the parameter of thread timeout function + * @param parameter is the parameter of thread timeout function */ void rt_thread_timeout(void *parameter) { @@ -934,11 +935,12 @@ RTM_EXPORT(rt_thread_timeout); /** * @brief This function will find the specified thread. * - * @note please don't invoke this function in interrupt status. + * @note Please don't invoke this function in interrupt status. * - * @param name the name of thread finding. + * @param name is the name of thread finding. * - * @return the found thread. + * @return If the return value is a rt_thread structure pointer, the function is successfully executed. + * If the return value is RT_NULL, it means this operation failed. */ rt_thread_t rt_thread_find(char *name) { -- cgit v1.3.1 From fe5d506ef25ac7dc4b4516c9cb3ed38d0e38d619 Mon Sep 17 00:00:00 2001 From: yangjie Date: Mon, 13 Sep 2021 16:10:44 +0800 Subject: 【增加】memheap.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/memheap.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 130 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/memheap.c b/src/memheap.c index e09f5c4bce..8422b1d802 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -39,6 +39,13 @@ #define MEMITEM(ptr) (struct rt_memheap_item*)((rt_uint8_t*)ptr - RT_MEMHEAP_SIZE) #ifdef RT_USING_MEMTRACE +/** + * @brief This function will set a new name for memheap. + * + * @param item is a pointer point to a memheap object. + * + * @param name is the new name to be set. + */ rt_inline void rt_memheap_setname(struct rt_memheap_item *item, const char *name) { int index; @@ -64,6 +71,13 @@ rt_inline void rt_memheap_setname(struct rt_memheap_item *item, const char *name } } +/** + * @brief This function will set a new name for memheap. + * + * @param ptr is a pointer point to a memheap object. + * + * @param name is the new name to be set. + */ void rt_mem_set_tag(void *ptr, const char *name) { struct rt_memheap_item *item; @@ -76,16 +90,28 @@ void rt_mem_set_tag(void *ptr, const char *name) } #endif /* RT_USING_MEMTRACE */ -/* - * The initialized memory pool will be: - * +-----------------------------------+--------------------------+ - * | whole freed memory block | Used Memory Block Tailer | - * +-----------------------------------+--------------------------+ +/** + * @brief This function initializes a piece of memory called memheap. + * + * @note The initialized memory pool will be: + * +-----------------------------------+--------------------------+ + * | whole freed memory block | Used Memory Block Tailer | + * +-----------------------------------+--------------------------+ + * + * block_list --> whole freed memory block + * + * The length of Used Memory Block Tailer is 0, + * which is prevents block merging across list + * + * @param memheap is a pointer of the memheap object. + * + * @param name is the name of the memheap. + * + * @param start_addr is the start address of the memheap. * - * block_list --> whole freed memory block + * @param size is the size of the memheap. * - * The length of Used Memory Block Tailer is 0, - * which is prevents block merging across list + * @return RT_EOK */ rt_err_t rt_memheap_init(struct rt_memheap *memheap, const char *name, @@ -165,6 +191,13 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap, } RTM_EXPORT(rt_memheap_init); +/** + * @brief This function will remove a memheap from the system. + * + * @param heap is a pointer of memheap object. + * + * @return RT_EOK + */ rt_err_t rt_memheap_detach(struct rt_memheap *heap) { RT_ASSERT(heap); @@ -179,6 +212,15 @@ rt_err_t rt_memheap_detach(struct rt_memheap *heap) } RTM_EXPORT(rt_memheap_detach); +/** + * @brief Allocate a block of memory with a minimum of 'size' bytes on memheap. + * + * @param heap is a pointer for memheap object. + * + * @param size is the minimum size of the requested block in bytes. + * + * @return the pointer to allocated memory or NULL if no free memory was found. + */ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size) { rt_err_t result; @@ -336,6 +378,18 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size) } RTM_EXPORT(rt_memheap_alloc); +/** + * @brief This function will change the size of previously allocated memory block. + * + * @param heap is a pointer to the memheap object, which will reallocate + * memory from the block + * + * @param ptr is a pointer to start address of memory. + * + * @param newsize is the required new size. + * + * @return the changed memory block address. + */ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize) { rt_err_t result; @@ -556,6 +610,12 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize) } RTM_EXPORT(rt_memheap_realloc); +/** + * @brief This function will release the allocated memory block by + * rt_malloc. The released memory block is taken back to system heap. + * + * @param ptr the address of memory which will be released. + */ void rt_memheap_free(void *ptr) { rt_err_t result; @@ -680,7 +740,13 @@ static void _memheap_dump_tag(struct rt_memheap_item *item) rt_kprintf("%.*s", 2 * sizeof(void *), name); } - +/** + * @brief This function will print the memheap infomation. + * + * @param heap is the pointer to the memheap to get information. + * + * @return 0 + */ int rt_memheap_dump(struct rt_memheap *heap) { struct rt_memheap_item *item, *end; @@ -757,6 +823,13 @@ MSH_CMD_EXPORT(memheaptrace, dump memory trace information); #ifdef RT_USING_MEMHEAP_AS_HEAP static struct rt_memheap _heap; +/** + * @brief This function initializes a heap for system. + * + * @param begin_addr is the start address of the memory. + * + * @param end_addr is the end address of the memory. + */ void rt_system_heap_init(void *begin_addr, void *end_addr) { RT_ASSERT((rt_uint32_t)end_addr > (rt_uint32_t)begin_addr); @@ -768,6 +841,11 @@ void rt_system_heap_init(void *begin_addr, void *end_addr) (rt_uint32_t)end_addr - (rt_uint32_t)begin_addr); } +/** + * @brief Allocate a block of memory with a minimum of 'size' bytes. + * + * @param size is the minimum size of the requested block in bytes. + */ void *rt_malloc(rt_size_t size) { void *ptr; @@ -804,7 +882,6 @@ void *rt_malloc(rt_size_t size) } } - #ifdef RT_USING_MEMTRACE if (ptr == RT_NULL) { @@ -826,12 +903,27 @@ void *rt_malloc(rt_size_t size) } RTM_EXPORT(rt_malloc); +/** + * @brief This function will release the previously allocated memory block by + * rt_malloc. The released memory block is taken back to system heap. + * + * @param rmem the address of memory which will be released. + */ void rt_free(void *rmem) { rt_memheap_free(rmem); } RTM_EXPORT(rt_free); +/** + * @brief This function will change the size of previously allocated memory block. + * + * @param rmem is the pointer to memory allocated by rt_malloc. + * + * @param newsize is the required new size. + * + * @return the changed memory block address. + */ void *rt_realloc(void *rmem, rt_size_t newsize) { void *new_ptr; @@ -892,6 +984,19 @@ void *rt_realloc(void *rmem, rt_size_t newsize) } RTM_EXPORT(rt_realloc); +/** + * @brief This function will contiguously allocate enough space for count objects + * that are size bytes of memory each and returns a pointer to the allocated + * memory. + * + * @note The allocated memory is filled with bytes of value zero. + * + * @param count is the number of objects to allocate. + * + * @param size is the size of one object to allocate. + * + * @return pointer to allocated memory pointer. + */ void *rt_calloc(rt_size_t count, rt_size_t size) { void *ptr; @@ -922,6 +1027,16 @@ void *rt_calloc(rt_size_t count, rt_size_t size) } RTM_EXPORT(rt_calloc); +/** +* @brief This function will caculate the total memory, the used memory, and +* the max used memory. +* +* @param total is a pointer to get the total size of the memory. +* +* @param used is a pointer to get the size of memory used. +* +* @param max_used is a pointer to get the maximum memory used. +*/ void rt_memory_info(rt_uint32_t *total, rt_uint32_t *used, rt_uint32_t *max_used) @@ -940,12 +1055,16 @@ void rt_memory_info(rt_uint32_t *total, #ifdef RT_USING_MEMTRACE +/** + * @brief This function will print the used memheap infomation. + * + * @param memheap is a pointer of the memheap object. + */ void dump_used_memheap(struct rt_memheap *mh) { struct rt_memheap_item *header_ptr; rt_uint32_t block_size; - rt_kprintf("\nmemory heap address:\n"); rt_kprintf("heap_ptr: 0x%08x\n", mh->start_addr); rt_kprintf("free : 0x%08x\n", mh->available_size); -- cgit v1.3.1 From d586417bb7d4c01f089f262f611f825c8a144fd5 Mon Sep 17 00:00:00 2001 From: Sherman Date: Fri, 10 Sep 2021 18:34:14 +0800 Subject: [kservice] 完善 API 注释 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kservice.c | 226 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 146 insertions(+), 80 deletions(-) (limited to 'src') diff --git a/src/kservice.c b/src/kservice.c index 91872492fb..25d34dfc47 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -43,8 +43,8 @@ static volatile int __rt_errno; static rt_device_t _console_device = RT_NULL; #endif -/* - * This function will get errno +/** + * This function gets the global errno for the current thread. * * @return errno */ @@ -66,10 +66,10 @@ rt_err_t rt_get_errno(void) } RTM_EXPORT(rt_get_errno); -/* - * This function will set errno +/** + * This function sets the global errno for the current thread. * - * @param error the errno shall be set + * @param error is the errno shall be set. */ void rt_set_errno(rt_err_t error) { @@ -96,9 +96,9 @@ void rt_set_errno(rt_err_t error) RTM_EXPORT(rt_set_errno); /** - * This function returns errno. + * This function returns the address of the current thread errno. * - * @return the errno in the system + * @return The errno address. */ int *_rt_errno(void) { @@ -116,13 +116,16 @@ int *_rt_errno(void) RTM_EXPORT(_rt_errno); /** - * This function will set the content of memory to specified value + * This function will set the content of memory to specified value. + * + * @param s is the address of source memory, point to the memory block to be filled. + * + * @param c is the value to be set. The value is passed in int form, but the function + * uses the unsigned character form of the value when filling the memory block. * - * @param s the address of source memory - * @param c the value shall be set in content - * @param count the copied length + * @param count number of bytes to be set. * - * @return the address of source memory + * @return The address of source memory. */ RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count) { @@ -200,14 +203,15 @@ RTM_EXPORT(rt_memset); #ifndef RT_USING_ASM_MEMCPY /** - * This function will copy memory content from source address to destination - * address. + * This function will copy memory content from source address to destination address. * - * @param dst the address of destination memory - * @param src the address of source memory - * @param count the copied length + * @param dst is the address of destination memory, points to the copied content. * - * @return the address of destination memory + * @param src is the address of source memory, pointing to the data source to be copied. + * + * @param count is the copied length. + * + * @return The address of destination memory */ void *rt_memcpy(void *dst, const void *src, rt_ubase_t count) { @@ -287,13 +291,16 @@ RTM_EXPORT(rt_memcpy); /** * This function will move memory content from source address to destination - * address. + * address. If the destination memory does not overlap with the source memory, + * the function is the same as memcpy(). + * + * @param dst is the address of destination memory, points to the copied content. * - * @param dest the address of destination memory - * @param src the address of source memory - * @param n the copied length + * @param src is the address of source memory, point to the data source to be copied. * - * @return the address of destination memory + * @param count is the copied length. + * + * @return The address of destination memory. */ void *rt_memmove(void *dest, const void *src, rt_ubase_t n) { @@ -318,13 +325,18 @@ void *rt_memmove(void *dest, const void *src, rt_ubase_t n) RTM_EXPORT(rt_memmove); /** - * This function will compare two areas of memory + * This function will compare two areas of memory. + * + * @param cs is a block of memory. + * + * @param ct is another block of memory. * - * @param cs one area of memory - * @param ct another area of memory - * @param count the size of the area + * @param count is the size of the area. * - * @return the result + * @return Compare the results: + * If the result < 0, cs is smaller than ct. + * If the result > 0, cs is greater than ct. + * If the result = 0, cs is equal to ct. */ RT_WEAK rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count) { @@ -340,12 +352,14 @@ RT_WEAK rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count) RTM_EXPORT(rt_memcmp); /** - * This function will return the first occurrence of a string. + * This function will return the first occurrence of a string, without the + * terminator '\0'. * - * @param s1 the source string - * @param s2 the find string + * @param s1 is the source string. * - * @return the first occurrence of a s2 in s1, or RT_NULL if no found. + * @param s2 is the find string. + * + * @return The first occurrence of a s2 in s1, or RT_NULL if no found. */ char *rt_strstr(const char *s1, const char *s2) { @@ -370,10 +384,14 @@ RTM_EXPORT(rt_strstr); /** * This function will compare two strings while ignoring differences in case * - * @param a the string to be compared - * @param b the string to be compared + * @param a is the string to be compared. + * + * @param b is the string to be compared. * - * @return the result + * @return Compare the results: + * If the result < 0, a is smaller than a. + * If the result > 0, a is greater than a. + * If the result = 0, a is equal to a. */ rt_int32_t rt_strcasecmp(const char *a, const char *b) { @@ -397,11 +415,13 @@ RTM_EXPORT(rt_strcasecmp); /** * This function will copy string no more than n bytes. * - * @param dst the string to copy - * @param src the string to be copied - * @param n the maximum copied length + * @param dst points to the address used to store the copied content. + * + * @param src is the string to be copied. * - * @return the result + * @param n is the maximum copied length. + * + * @return The address where the copied content is stored. */ char *rt_strncpy(char *dst, const char *src, rt_ubase_t n) { @@ -427,13 +447,18 @@ char *rt_strncpy(char *dst, const char *src, rt_ubase_t n) RTM_EXPORT(rt_strncpy); /** - * This function will compare two strings with specified maximum length + * This function will compare two strings with specified maximum length. + * + * @param cs is the string to be compared. + * + * @param ct is the string to be compared. * - * @param cs the string to be compared - * @param ct the string to be compared - * @param count the maximum compare length + * @param count is the maximum compare length. * - * @return the result + * @return Compare the results: + * If the result < 0, cs is smaller than ct. + * If the result > 0, cs is greater than ct. + * If the result = 0, cs is equal to ct. */ rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count) { @@ -451,12 +476,16 @@ rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count) RTM_EXPORT(rt_strncmp); /** - * This function will compare two strings without specified length + * This function will compare two strings without specified length. * - * @param cs the string to be compared - * @param ct the string to be compared + * @param cs is the string to be compared. * - * @return the result + * @param ct is the string to be compared. + * + * @return Compare the results: + * If the result < 0, cs is smaller than ct. + * If the result > 0, cs is greater than ct. + * If the result = 0, cs is equal to ct. */ rt_int32_t rt_strcmp(const char *cs, const char *ct) { @@ -477,9 +506,11 @@ RTM_EXPORT(rt_strcmp); * first maxlen characters in the string pointed to by s and never * beyond s+maxlen. * - * @param s the string - * @param maxlen the max size - * @return the length of string + * @param s is the string. + * + * @param maxlen is the max size. + * + * @return The length of string. */ rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen) { @@ -496,9 +527,9 @@ RTM_EXPORT(rt_strnlen); * This function will return the length of a string, which terminate will * null character. * - * @param s the string + * @param s is the string * - * @return the length of string + * @return The length of string. */ rt_size_t rt_strlen(const char *s) { @@ -517,9 +548,9 @@ RTM_EXPORT(rt_strlen); /** * This function will duplicate a string. * - * @param s the string to be duplicated + * @param s is the string to be duplicated. * - * @return the duplicated string pointer + * @return The string address of the copy. */ char *rt_strdup(const char *s) { @@ -556,6 +587,13 @@ RTM_EXPORT(rt_show_version); #define _ISDIGIT(c) ((unsigned)((c) - '0') < 10) #ifdef RT_PRINTF_LONGLONG +/** + * This function will duplicate a string. + * + * @param s the string to be duplicated + * + * @return the duplicated string pointer + */ rt_inline int divide(long long *n, int base) { int res; @@ -784,6 +822,19 @@ static char *print_number(char *buf, return buf; } +/** + * This function will fill a formatted string to buffer. + * + * @param buf is the buffer to save formatted string. + * + * @param size is the size of buffer. + * + * @param fmt is the format parameters. + * + * @param args is a list of variable parameters. + * + * @return The number of characters actually written to buffer. + */ rt_int32_t rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, @@ -1051,11 +1102,15 @@ rt_int32_t rt_vsnprintf(char *buf, RTM_EXPORT(rt_vsnprintf); /** - * This function will fill a formatted string to buffer + * This function will fill a formatted string to buffer. * - * @param buf the buffer to save formatted string - * @param size the size of buffer - * @param fmt the format + * @param buf is the buffer to save formatted string. + * + * @param size is the size of buffer. + * + * @param fmt is the format parameters. + * + * @return The number of characters actually written to buffer. */ rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...) { @@ -1071,11 +1126,15 @@ rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...) RTM_EXPORT(rt_snprintf); /** - * This function will fill a formatted string to buffer + * This function will fill a formatted string to buffer. + * + * @param buf is the buffer to save formatted string. + * + * @param format is the format parameters. * - * @param buf the buffer to save formatted string - * @param arg_ptr the arg_ptr - * @param format the format + * @param arg_ptr is a list of variable parameters. + * + * @return The number of characters actually written to buffer. */ rt_int32_t rt_vsprintf(char *buf, const char *format, va_list arg_ptr) { @@ -1086,8 +1145,11 @@ RTM_EXPORT(rt_vsprintf); /** * This function will fill a formatted string to buffer * - * @param buf the buffer to save formatted string - * @param format the format + * @param buf the buffer to save formatted string. + * + * @param format is the format parameters. + * + * @return The number of characters actually written to buffer. */ rt_int32_t rt_sprintf(char *buf, const char *format, ...) { @@ -1108,7 +1170,7 @@ RTM_EXPORT(rt_sprintf); /** * This function returns the device using in console. * - * @return the device using in console or RT_NULL + * @return Returns the console device pointer or RT_NULL. */ rt_device_t rt_console_get_device(void) { @@ -1121,7 +1183,7 @@ RTM_EXPORT(rt_console_get_device); * After set a device to console, all output of rt_kprintf will be * redirected to this new device. * - * @param name the name of new console device + * @param name is the name of new console device. * * @return the old console device handler on successful, or RT_NULL on failure. */ @@ -1165,7 +1227,7 @@ RTM_EXPORT(rt_hw_console_output); /** * This function will put string to the console. * - * @param str the string output to the console. + * @param str is the string output to the console. */ void rt_kputs(const char *str) { @@ -1186,9 +1248,9 @@ void rt_kputs(const char *str) } /** - * This function will print a formatted string on system console + * This function will print a formatted string on system console. * - * @param fmt the format + * @param fmt is the format parameters. */ RT_WEAK void rt_kprintf(const char *fmt, ...) { @@ -1227,10 +1289,12 @@ RTM_EXPORT(rt_kprintf); * This function allocates a memory block, which address is aligned to the * specified alignment size. * - * @param size the allocated memory block size - * @param align the alignment size + * @param size is the allocated memory block size. * - * @return the allocated memory block on successful, otherwise returns RT_NULL + * @param align is the alignment size. + * + * @return The memory block address was returned successfully, otherwise it was + * returned empty RT_NULL. */ RT_WEAK void *rt_malloc_align(rt_size_t size, rt_size_t align) { @@ -1276,7 +1340,7 @@ RTM_EXPORT(rt_malloc_align); * This function release the memory block, which is allocated by * rt_malloc_align function and address is aligned. * - * @param ptr the memory block pointer + * @param ptr is the memory block pointer. */ RT_WEAK void rt_free_align(void *ptr) { @@ -1316,8 +1380,8 @@ const rt_uint8_t __lowest_bit_bitmap[] = * Bits are numbered starting at 1 (the least significant bit). A return value of * zero from any of these functions means that the argument was zero. * - * @return return the index of the first bit set. If value is 0, then this function - * shall return 0. + * @return Return the index of the first bit set. If value is 0, then this function + * shall return 0. */ int __rt_ffs(int value) { @@ -1344,7 +1408,7 @@ void (*rt_assert_hook)(const char *ex, const char *func, rt_size_t line); /** * This function will set a hook function to RT_ASSERT(EX). It will run when the expression is false. * - * @param hook the hook function + * @param hook is the hook function. */ void rt_assert_set_hook(void (*hook)(const char *ex, const char *func, rt_size_t line)) { @@ -1354,9 +1418,11 @@ void rt_assert_set_hook(void (*hook)(const char *ex, const char *func, rt_size_t /** * The RT_ASSERT function. * - * @param ex the assertion condition string - * @param func the function name when assertion. - * @param line the file line number when assertion. + * @param ex is the assertion condition string. + * + * @param func is the function name when assertion. + * + * @param line is the file line number when assertion. */ void rt_assert_handler(const char *ex_string, const char *func, rt_size_t line) { -- cgit v1.3.1 From 6cb093aa272a0b1ef908cbd8e103cbd94120b3c6 Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Sat, 11 Sep 2021 18:29:37 +0800 Subject: [kernel] Improve code comments. --- src/clock.c | 2 +- src/components.c | 9 +++++---- src/cpu.c | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index e49df94aae..fb7ee447d2 100644 --- a/src/clock.c +++ b/src/clock.c @@ -130,7 +130,7 @@ RTM_EXPORT(rt_tick_from_millisecond); /** * @brief This function will return the passed millisecond from boot. * - * @note When the value of RT_TICK_PER_SECOND is lower than 1000 or + * @note if the value of RT_TICK_PER_SECOND is lower than 1000 or * is not an integral multiple of 1000, this function will not * provide the correct 1ms-based tick. * diff --git a/src/components.c b/src/components.c index 87e76091f2..9433b7457c 100644 --- a/src/components.c +++ b/src/components.c @@ -78,7 +78,9 @@ static int rti_end(void) INIT_EXPORT(rti_end, "6.end"); /** - * @brief RT-Thread Components Initialization for board. + * @brief Onboard components initialization. In this function, the board-level + * initialization function will be called to complete the initialization + * of the on-board peripherals. */ void rt_components_board_init(void) { @@ -225,9 +227,8 @@ void rt_application_init(void) } /** - * @brief RT-Thread startup function. This function will call all levels of initialization - * functions to complete the initialization of the system, and finally start the - * scheduler. + * @brief This function will call all levels of initialization functions to complete + * the initialization of the system, and finally start the scheduler. */ int rtthread_startup(void) { diff --git a/src/cpu.c b/src/cpu.c index 5466a350ae..b689ecf2d7 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -69,7 +69,6 @@ static void _cpu_preempt_enable(void) * @brief Initialize a static spinlock object. * * @param lock is a pointer to the spinlock to initialize. - * It is assumed that storage for the spinlock will be allocated in your application. */ void rt_spin_lock_init(struct rt_spinlock *lock) { -- cgit v1.3.1 From 2e5b4736fe86e852c218d9ed0e492ba9ea6a3d56 Mon Sep 17 00:00:00 2001 From: aozima Date: Wed, 14 Jul 2021 22:08:30 +0800 Subject: [kernel] update memheap auto binding policy. --- src/Kconfig | 15 +++++++++++---- src/memheap.c | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Kconfig b/src/Kconfig index 71abd9cf4f..fc7fcd54f4 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -268,11 +268,18 @@ menu "Memory Management" help Using static memory fixed partition - config RT_USING_MEMHEAP + menuconfig RT_USING_MEMHEAP bool "Using memory heap object" default n - help - Using memory heap object to manage dynamic memory heap. + + if RT_USING_MEMHEAP + + if RT_USING_MEMHEAP_AS_HEAP + config RT_USING_MEMHEAP_AUTO_BINDING + bool "Use all of memheap objects as heap" + default y + endif + endif choice prompt "Dynamic Memory Management" @@ -289,7 +296,7 @@ menu "Memory Management" if RT_USING_MEMHEAP config RT_USING_MEMHEAP_AS_HEAP - bool "Use all of memheap objects as heap" + bool "Use memheap objects as heap" endif config RT_USING_USERHEAP diff --git a/src/memheap.c b/src/memheap.c index 8422b1d802..d1c2822922 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -852,6 +852,7 @@ void *rt_malloc(rt_size_t size) /* try to allocate in system heap */ ptr = rt_memheap_alloc(&_heap, size); +#ifdef RT_USING_MEMHEAP_AUTO_BINDING if (ptr == RT_NULL) { struct rt_object *object; @@ -881,6 +882,7 @@ void *rt_malloc(rt_size_t size) break; } } +#endif /* RT_USING_MEMHEAP_AUTO_BINDING */ #ifdef RT_USING_MEMTRACE if (ptr == RT_NULL) -- cgit v1.3.1 From d99737d8a99844bbf8056656b0e61b93c2343ade Mon Sep 17 00:00:00 2001 From: liukangcc Date: Sat, 18 Sep 2021 16:23:50 +0800 Subject: [update] functions annotation. --- src/clock.c | 12 ++++++------ src/ipc.c | 7 ------- src/kservice.c | 12 +++++++----- src/memheap.c | 2 +- src/signal.c | 2 ++ 5 files changed, 16 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index fb7ee447d2..21be3a4203 100644 --- a/src/clock.c +++ b/src/clock.c @@ -33,9 +33,9 @@ static volatile rt_tick_t rt_tick = 0; /**@{*/ /** - * @brief This function will return current tick from operating system startup + * @brief This function will return current tick from operating system startup. * - * @return Return current tick + * @return Return current tick. */ rt_tick_t rt_tick_get(void) { @@ -45,7 +45,7 @@ rt_tick_t rt_tick_get(void) RTM_EXPORT(rt_tick_get); /** - * @brief This function will set current tick + * @brief This function will set current tick. * * @param tick is the value that you will set. */ @@ -101,12 +101,12 @@ void rt_tick_increase(void) /** * @brief This function will calculate the tick from millisecond. * - * @param ms is the specified millisecond + * @param ms is the specified millisecond. * - Negative Number wait forever * - Zero not wait * - Max 0x7fffffff * - * @return Return the calculated tick + * @return Return the calculated tick. */ rt_tick_t rt_tick_from_millisecond(rt_int32_t ms) { @@ -134,7 +134,7 @@ RTM_EXPORT(rt_tick_from_millisecond); * is not an integral multiple of 1000, this function will not * provide the correct 1ms-based tick. * - * @return Return passed millisecond from boot + * @return Return passed millisecond from boot. */ RT_WEAK rt_tick_t rt_tick_get_millisecond(void) { diff --git a/src/ipc.c b/src/ipc.c index 57ac453a68..a467c14151 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -1234,10 +1234,6 @@ RTM_EXPORT(rt_mutex_control); * * @param name is a pointer to the name that given to the event. * - * @param value is the initial value for the event. - * If want to share resources, you should initialize the value as the number of available resources. - * If want to signal the occurrence of an event, you should initialize the value as 0. - * * @param flag is the event flag, which determines the queuing way of how multiple threads wait * when the event is not available. * The event flag can be ONE of the following values: @@ -1741,9 +1737,6 @@ RTM_EXPORT(rt_event_control); * * @param name is a pointer to the name that given to the mailbox. * - * @param msgpoll is a pointer to the starting address of the memory space you allocated for the mailbox in advance. - * In other words, msgpoll is a pointer to the mailbox buffer of the starting address. - * * @param size is the maximum number of mails in the mailbox. * For example, when the mailbox buffer capacity is N, size is N/4. * diff --git a/src/kservice.c b/src/kservice.c index 25d34dfc47..41d81d8677 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -294,11 +294,11 @@ RTM_EXPORT(rt_memcpy); * address. If the destination memory does not overlap with the source memory, * the function is the same as memcpy(). * - * @param dst is the address of destination memory, points to the copied content. + * @param dest is the address of destination memory, points to the copied content. * * @param src is the address of source memory, point to the data source to be copied. * - * @param count is the copied length. + * @param n is the copied length. * * @return The address of destination memory. */ @@ -590,9 +590,11 @@ RTM_EXPORT(rt_show_version); /** * This function will duplicate a string. * - * @param s the string to be duplicated + * @param n is the string to be duplicated. + * + * @param base is support divide instructions value. * - * @return the duplicated string pointer + * @return the duplicated string pointer. */ rt_inline int divide(long long *n, int base) { @@ -1418,7 +1420,7 @@ void rt_assert_set_hook(void (*hook)(const char *ex, const char *func, rt_size_t /** * The RT_ASSERT function. * - * @param ex is the assertion condition string. + * @param ex_string is the assertion condition string. * * @param func is the function name when assertion. * diff --git a/src/memheap.c b/src/memheap.c index 8422b1d802..f9da3ac015 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -1058,7 +1058,7 @@ void rt_memory_info(rt_uint32_t *total, /** * @brief This function will print the used memheap infomation. * - * @param memheap is a pointer of the memheap object. + * @param mh is a pointer of the memheap object. */ void dump_used_memheap(struct rt_memheap *mh) { diff --git a/src/signal.c b/src/signal.c index e630c0dd97..14201ee948 100644 --- a/src/signal.c +++ b/src/signal.c @@ -217,6 +217,8 @@ void *rt_signal_check(void* context) * * @param signo is a specific signal value (range: 0 ~ RT_SIG_MAX). * + * @param handler is sets the processing of signal value. + * * @return Return the old processing function of this signal. ONLY When the * return value is SIG_ERR, the operation is failed. */ -- cgit v1.3.1