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/object.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/object.c') 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 -- 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/object.c') 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 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/object.c') 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 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/object.c') 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 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/object.c') 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