summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShicheng Chu <[email protected]>2023-06-29 23:24:25 +0800
committerGitHub <[email protected]>2023-06-29 11:24:25 -0400
commite2c031643c8dec7c9ea1581216e19bf19c8f73f0 (patch)
tree926536732e7472c5e86ac5198b239d82f9f55da4 /src
parent148ae53cf8d3abc2c2e11c94c171b123b950b2fc (diff)
[include][dbg]update: no longer use RT_DEBUG_LOG in rtdebug.h (#7750)
Diffstat (limited to 'src')
-rw-r--r--src/Kconfig60
-rw-r--r--src/components.c4
-rw-r--r--src/ipc.c77
-rw-r--r--src/irq.c16
-rw-r--r--src/kservice.c12
-rw-r--r--src/mem.c37
-rw-r--r--src/memheap.c122
-rw-r--r--src/scheduler_mp.c31
-rw-r--r--src/scheduler_up.c31
-rw-r--r--src/slab.c56
-rw-r--r--src/thread.c22
-rw-r--r--src/timer.c22
12 files changed, 255 insertions, 235 deletions
diff --git a/src/Kconfig b/src/Kconfig
index f88f806f74..bcb58f1dee 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -207,92 +207,52 @@ if RT_DEBUG
bool "Enable color debugging log"
default n
- config RT_DEBUG_INIT_CONFIG
+ config RT_DEBUG_INIT
bool "Enable debugging of components initialization"
default n
- config RT_DEBUG_INIT
- int
- default 1 if RT_DEBUG_INIT_CONFIG
-
- config RT_DEBUG_THREAD_CONFIG
+ config RT_DEBUG_THREAD
bool "Enable debugging of Thread State Changes"
default n
- config RT_DEBUG_THREAD
- int
- default 1 if RT_DEBUG_THREAD_CONFIG
-
- config RT_DEBUG_SCHEDULER_CONFIG
+ config RT_DEBUG_SCHEDULER
bool "Enable debugging of Scheduler"
default n
- config RT_DEBUG_SCHEDULER
- int
- default 1 if RT_DEBUG_SCHEDULER_CONFIG
-
- config RT_DEBUG_IPC_CONFIG
+ config RT_DEBUG_IPC
bool "Enable debugging of IPC"
default n
- config RT_DEBUG_IPC
- int
- default 1 if RT_DEBUG_IPC_CONFIG
-
- config RT_DEBUG_TIMER_CONFIG
+ config RT_DEBUG_TIMER
bool "Enable debugging of Timer"
default n
- config RT_DEBUG_TIMER
- int
- default 1 if RT_DEBUG_TIMER_CONFIG
-
- config RT_DEBUG_IRQ_CONFIG
+ config RT_DEBUG_IRQ
bool "Enable debugging of IRQ(Interrupt Request)"
default n
- config RT_DEBUG_IRQ
- int
- default 1 if RT_DEBUG_IRQ_CONFIG
-
- config RT_DEBUG_MEM_CONFIG
+ config RT_DEBUG_MEM
bool "Enable debugging of Small Memory Algorithm"
default n
- config RT_DEBUG_MEM
- int
- default 1 if RT_DEBUG_MEM_CONFIG
-
- config RT_DEBUG_SLAB_CONFIG
+ config RT_DEBUG_SLAB
bool "Enable debugging of SLAB Memory Algorithm"
default n
- config RT_DEBUG_SLAB
- int
- default 1 if RT_DEBUG_SLAB_CONFIG
-
- config RT_DEBUG_MEMHEAP_CONFIG
+ config RT_DEBUG_MEMHEAP
bool "Enable debugging of Memory Heap Algorithm"
default n
- config RT_DEBUG_MEMHEAP
- int
- default 1 if RT_DEBUG_MEMHEAP_CONFIG
-
if ARCH_MM_MMU
config RT_DEBUG_PAGE_LEAK
bool "Enable page leaking tracer"
default n
endif
- config RT_DEBUG_MODULE_CONFIG
+ config RT_DEBUG_MODULE
bool "Enable debugging of Application Module"
default n
- config RT_DEBUG_MODULE
- int
- default 1 if RT_DEBUG_MODULE_CONFIG
-
endif
menu "Inter-Thread communication"
diff --git a/src/components.c b/src/components.c
index 97ace80990..af74954d76 100644
--- a/src/components.c
+++ b/src/components.c
@@ -84,7 +84,7 @@ INIT_EXPORT(rti_end, "6.end");
*/
void rt_components_board_init(void)
{
-#if RT_DEBUG_INIT
+#ifdef RT_DEBUG_INIT
int result;
const struct rt_init_desc *desc;
for (desc = &__rt_init_desc_rti_board_start; desc < &__rt_init_desc_rti_board_end; desc ++)
@@ -108,7 +108,7 @@ void rt_components_board_init(void)
*/
void rt_components_init(void)
{
-#if RT_DEBUG_INIT
+#ifdef RT_DEBUG_INIT
int result;
const struct rt_init_desc *desc;
diff --git a/src/ipc.c b/src/ipc.c
index 806400fa12..d97fa1d35a 100644
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -50,6 +50,14 @@
#include <rtthread.h>
#include <rthw.h>
+#define DBG_TAG "kernel.ipc"
+#ifdef RT_DEBUG_IPC
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif /* defined (RT_DEBUG_IPC) */
+#include <rtdbg.h>
+
#ifndef __on_rt_object_trytake_hook
#define __on_rt_object_trytake_hook(parent) __ON_HOOK_ARGS(rt_object_trytake_hook, (parent))
#endif
@@ -211,7 +219,7 @@ rt_inline rt_err_t _ipc_list_resume(rt_list_t *list)
thread->error = RT_EOK;
- RT_DEBUG_LOG(RT_DEBUG_IPC, ("resume thread:%s\n", thread->parent.name));
+ LOG_D("resume thread:%s\n", thread->parent.name);
/* resume it */
rt_thread_resume(thread);
@@ -513,10 +521,10 @@ static rt_err_t _rt_sem_take(rt_sem_t sem, rt_int32_t timeout, int suspend_flag)
/* disable interrupt */
level = rt_hw_interrupt_disable();
- RT_DEBUG_LOG(RT_DEBUG_IPC, ("thread %s take sem:%s, which value is: %d\n",
- rt_thread_self()->parent.name,
- sem->parent.parent.name,
- sem->value));
+ LOG_D("thread %s take sem:%s, which value is: %d",
+ rt_thread_self()->parent.name,
+ sem->parent.parent.name,
+ sem->value);
if (sem->value > 0)
{
@@ -544,7 +552,7 @@ static rt_err_t _rt_sem_take(rt_sem_t sem, rt_int32_t timeout, int suspend_flag)
/* reset thread error number */
thread->error = -RT_EINTR;
- RT_DEBUG_LOG(RT_DEBUG_IPC, ("sem take: suspend thread - %s\n", thread->parent.name));
+ LOG_D("sem take: suspend thread - %s", thread->parent.name);
/* suspend thread */
ret = _ipc_list_suspend(&(sem->parent.suspend_thread),
@@ -560,7 +568,7 @@ static rt_err_t _rt_sem_take(rt_sem_t sem, rt_int32_t timeout, int suspend_flag)
/* has waiting time, start thread timer */
if (timeout > 0)
{
- RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n", thread->parent.name));
+ LOG_D("set thread:%s to timer list", thread->parent.name);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
@@ -654,10 +662,10 @@ rt_err_t rt_sem_release(rt_sem_t sem)
/* disable interrupt */
level = rt_hw_interrupt_disable();
- RT_DEBUG_LOG(RT_DEBUG_IPC, ("thread %s releases sem:%s, which value is: %d\n",
- rt_thread_self()->parent.name,
- sem->parent.parent.name,
- sem->value));
+ LOG_D("thread %s releases sem:%s, which value is: %d",
+ rt_thread_self()->parent.name,
+ sem->parent.parent.name,
+ sem->value);
if (!rt_list_isempty(&sem->parent.suspend_thread))
{
@@ -788,8 +796,7 @@ rt_inline rt_uint8_t _thread_get_mutex_priority(struct rt_thread* thread)
rt_inline void _thread_update_priority(struct rt_thread *thread, rt_uint8_t priority, int suspend_flag)
{
rt_err_t ret;
- RT_DEBUG_LOG(RT_DEBUG_IPC,
- ("thread:%s priority -> %d\n", thread->parent.name, priority));
+ LOG_D("thread:%s priority -> %d", thread->parent.name, priority);
/* change priority of the thread */
rt_thread_control(thread,
@@ -822,9 +829,8 @@ rt_inline void _thread_update_priority(struct rt_thread *thread, rt_uint8_t prio
/* update priority */
_mutex_update_priority(pending_mutex);
/* change the priority of mutex owner thread */
- RT_DEBUG_LOG(RT_DEBUG_IPC,
- ("mutex: %s priority -> %d\n", pending_mutex->parent.parent.name,
- pending_mutex->priority));
+ LOG_D("mutex: %s priority -> %d", pending_mutex->parent.parent.name,
+ pending_mutex->priority);
mutex_priority = _thread_get_mutex_priority(pending_mutex->owner);
if (mutex_priority != pending_mutex->owner->current_priority)
@@ -1180,9 +1186,8 @@ static rt_err_t _rt_mutex_take(rt_mutex_t mutex, rt_int32_t timeout, int suspend
RT_OBJECT_HOOK_CALL(rt_object_trytake_hook, (&(mutex->parent.parent)));
- RT_DEBUG_LOG(RT_DEBUG_IPC,
- ("mutex_take: current thread %s, hold: %d\n",
- thread->parent.name, mutex->hold));
+ LOG_D("mutex_take: current thread %s, hold: %d",
+ thread->parent.name, mutex->hold);
/* reset thread error */
thread->error = RT_EOK;
@@ -1238,8 +1243,8 @@ static rt_err_t _rt_mutex_take(rt_mutex_t mutex, rt_int32_t timeout, int suspend
rt_uint8_t priority = thread->current_priority;
/* mutex is unavailable, push to suspend list */
- RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_take: suspend thread: %s\n",
- thread->parent.name));
+ LOG_D("mutex_take: suspend thread: %s",
+ thread->parent.name);
/* suspend current thread */
ret = _ipc_list_suspend(&(mutex->parent.suspend_thread),
@@ -1268,9 +1273,8 @@ static rt_err_t _rt_mutex_take(rt_mutex_t mutex, rt_int32_t timeout, int suspend
/* has waiting time, start thread timer */
if (timeout > 0)
{
- RT_DEBUG_LOG(RT_DEBUG_IPC,
- ("mutex_take: start the timer of thread:%s\n",
- thread->parent.name));
+ LOG_D("mutex_take: start the timer of thread:%s",
+ thread->parent.name);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
@@ -1422,9 +1426,8 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
/* disable interrupt */
level = rt_hw_interrupt_disable();
- RT_DEBUG_LOG(RT_DEBUG_IPC,
- ("mutex_release:current thread %s, hold: %d\n",
- thread->parent.name, mutex->hold));
+ LOG_D("mutex_release:current thread %s, hold: %d",
+ thread->parent.name, mutex->hold);
RT_OBJECT_HOOK_CALL(rt_object_put_hook, (&(mutex->parent.parent)));
@@ -1470,8 +1473,8 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
struct rt_thread,
tlist);
- RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_release: resume thread: %s\n",
- next_thread->parent.name));
+ LOG_D("mutex_release: resume thread: %s",
+ next_thread->parent.name);
/* remove the thread from the suspended list of mutex */
rt_list_remove(&(next_thread->tlist));
@@ -2417,8 +2420,8 @@ static rt_err_t _rt_mb_send_wait(rt_mailbox_t mb,
/* get the start tick of timer */
tick_delta = rt_tick_get();
- RT_DEBUG_LOG(RT_DEBUG_IPC, ("mb_send_wait: start timer of thread:%s\n",
- thread->parent.name));
+ LOG_D("mb_send_wait: start timer of thread:%s",
+ thread->parent.name);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
@@ -2711,8 +2714,8 @@ static rt_err_t _rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeo
/* get the start tick of timer */
tick_delta = rt_tick_get();
- RT_DEBUG_LOG(RT_DEBUG_IPC, ("mb_recv: start timer of thread:%s\n",
- thread->parent.name));
+ LOG_D("mb_recv: start timer of thread:%s",
+ thread->parent.name);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
@@ -3256,8 +3259,8 @@ static rt_err_t _rt_mq_send_wait(rt_mq_t mq,
/* get the start tick of timer */
tick_delta = rt_tick_get();
- RT_DEBUG_LOG(RT_DEBUG_IPC, ("mq_send_wait: start timer of thread:%s\n",
- thread->parent.name));
+ LOG_D("mq_send_wait: start timer of thread:%s",
+ thread->parent.name);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
@@ -3649,8 +3652,8 @@ static rt_ssize_t _rt_mq_recv(rt_mq_t mq,
/* get the start tick of timer */
tick_delta = rt_tick_get();
- RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n",
- thread->parent.name));
+ LOG_D("set thread:%s to timer list",
+ thread->parent.name);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
diff --git a/src/irq.c b/src/irq.c
index 4d431b2194..b0b0c7a182 100644
--- a/src/irq.c
+++ b/src/irq.c
@@ -17,6 +17,14 @@
#include <rthw.h>
#include <rtthread.h>
+#define DBG_TAG "kernel.irq"
+#ifdef RT_DEBUG_IRQ
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif /* defined (RT_DEBUG_IRQ) */
+#include <rtdbg.h>
+
#ifndef __on_rt_interrupt_enter_hook
#define __on_rt_interrupt_enter_hook() __ON_HOOK_ARGS(rt_interrupt_enter_hook, ())
#endif
@@ -87,8 +95,8 @@ rt_weak void rt_interrupt_enter(void)
RT_OBJECT_HOOK_CALL(rt_interrupt_enter_hook,());
rt_hw_interrupt_enable(level);
- RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq has come..., irq current nest:%d\n",
- (rt_int32_t)rt_interrupt_nest));
+ LOG_D("irq has come..., irq current nest:%d",
+ (rt_int32_t)rt_interrupt_nest);
}
RTM_EXPORT(rt_interrupt_enter);
@@ -104,8 +112,8 @@ rt_weak void rt_interrupt_leave(void)
{
rt_base_t level;
- RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq is going to leave, irq current nest:%d\n",
- (rt_int32_t)rt_interrupt_nest));
+ LOG_D("irq is going to leave, irq current nest:%d",
+ (rt_int32_t)rt_interrupt_nest);
level = rt_hw_interrupt_disable();
RT_OBJECT_HOOK_CALL(rt_interrupt_leave_hook,());
diff --git a/src/kservice.c b/src/kservice.c
index dddcdf6df3..7e750b52e1 100644
--- a/src/kservice.c
+++ b/src/kservice.c
@@ -29,6 +29,14 @@
#include <rtthread.h>
#include <rthw.h>
+#define DBG_TAG "kernel.device"
+#ifdef RT_DEBUG_DEVICE
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif /* defined (RT_DEBUG_DEVICE) */
+#include <rtdbg.h>
+
#ifdef RT_USING_MODULE
#include <dlmodule.h>
#endif /* RT_USING_MODULE */
@@ -58,8 +66,8 @@ static rt_device_t _console_device = RT_NULL;
rt_weak void rt_hw_us_delay(rt_uint32_t us)
{
(void) us;
- RT_DEBUG_LOG(RT_DEBUG_DEVICE, ("rt_hw_us_delay() doesn't support for this board."
- "Please consider implementing rt_hw_us_delay() in another file.\n"));
+ LOG_D("rt_hw_us_delay() doesn't support for this board."
+ "Please consider implementing rt_hw_us_delay() in another file.");
}
rt_weak const char *rt_hw_cpu_arch(void)
diff --git a/src/mem.c b/src/mem.c
index 6beede9f6e..8160d9ea58 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -54,6 +54,15 @@
/**
* memory item on the small mem
*/
+
+#define DBG_TAG "kernel.mem"
+#ifdef RT_DEBUG_MEM
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif /* defined (RT_DEBUG_MEM) */
+#include <rtdbg.h>
+
struct rt_small_mem_item
{
rt_ubase_t pool_ptr; /**< small memory object addr */
@@ -213,8 +222,8 @@ rt_smem_t rt_smem_init(const char *name,
/* point to begin address of heap */
small_mem->heap_ptr = (rt_uint8_t *)begin_align;
- RT_DEBUG_LOG(RT_DEBUG_MEM, ("mem init, heap begin address 0x%x, size %d\n",
- (rt_ubase_t)small_mem->heap_ptr, small_mem->mem_size_aligned));
+ LOG_D("mem init, heap begin address 0x%x, size %d",
+ (rt_ubase_t)small_mem->heap_ptr, small_mem->mem_size_aligned);
/* initialize the start of the heap */
mem = (struct rt_small_mem_item *)small_mem->heap_ptr;
@@ -290,12 +299,12 @@ void *rt_smem_alloc(rt_smem_t m, rt_size_t size)
if (size != RT_ALIGN(size, RT_ALIGN_SIZE))
{
- RT_DEBUG_LOG(RT_DEBUG_MEM, ("malloc size %d, but align to %d\n",
- size, RT_ALIGN(size, RT_ALIGN_SIZE)));
+ LOG_D("malloc size %d, but align to %d",
+ size, RT_ALIGN(size, RT_ALIGN_SIZE));
}
else
{
- RT_DEBUG_LOG(RT_DEBUG_MEM, ("malloc size %d\n", size));
+ LOG_D("malloc size %d", size);
}
small_mem = (struct rt_small_mem *)m;
@@ -308,7 +317,7 @@ void *rt_smem_alloc(rt_smem_t m, rt_size_t size)
if (size > small_mem->mem_size_aligned)
{
- RT_DEBUG_LOG(RT_DEBUG_MEM, ("no memory\n"));
+ LOG_D("no memory");
return RT_NULL;
}
@@ -393,10 +402,9 @@ void *rt_smem_alloc(rt_smem_t m, rt_size_t size)
RT_ASSERT((rt_ubase_t)((rt_uint8_t *)mem + SIZEOF_STRUCT_MEM) % RT_ALIGN_SIZE == 0);
RT_ASSERT((((rt_ubase_t)mem) & (RT_ALIGN_SIZE - 1)) == 0);
- RT_DEBUG_LOG(RT_DEBUG_MEM,
- ("allocate memory at 0x%x, size: %d\n",
- (rt_ubase_t)((rt_uint8_t *)mem + SIZEOF_STRUCT_MEM),
- (rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr))));
+ LOG_D("allocate memory at 0x%x, size: %d",
+ (rt_ubase_t)((rt_uint8_t *)mem + SIZEOF_STRUCT_MEM),
+ (rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr)));
/* return the memory data except mem struct */
return (rt_uint8_t *)mem + SIZEOF_STRUCT_MEM;
@@ -435,7 +443,7 @@ void *rt_smem_realloc(rt_smem_t m, void *rmem, rt_size_t newsize)
newsize = RT_ALIGN(newsize, RT_ALIGN_SIZE);
if (newsize > small_mem->mem_size_aligned)
{
- RT_DEBUG_LOG(RT_DEBUG_MEM, ("realloc: out of memory\n"));
+ LOG_D("realloc: out of memory");
return RT_NULL;
}
@@ -534,10 +542,9 @@ void rt_smem_free(void *rmem)
(rt_uint8_t *)rmem < (rt_uint8_t *)small_mem->heap_end);
RT_ASSERT(MEM_POOL(&small_mem->heap_ptr[mem->next]) == small_mem);
- RT_DEBUG_LOG(RT_DEBUG_MEM,
- ("release memory 0x%x, size: %d\n",
- (rt_ubase_t)rmem,
- (rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr))));
+ LOG_D("release memory 0x%x, size: %d",
+ (rt_ubase_t)rmem,
+ (rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr)));
/* ... and is now unused. */
mem->pool_ptr = MEM_FREED();
diff --git a/src/memheap.c b/src/memheap.c
index 0df9ed41ed..067523bb93 100644
--- a/src/memheap.c
+++ b/src/memheap.c
@@ -26,6 +26,14 @@
#ifdef RT_USING_MEMHEAP
+#define DBG_TAG "kernel.memheap"
+#ifdef RT_DEBUG_MEMHEAP
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif /* defined (RT_DEBUG_MEM) */
+#include <rtdbg.h>
+
/* dynamic pool magic and mask */
#define RT_MEMHEAP_MAGIC 0x1ea01ea0
#define RT_MEMHEAP_MASK 0xFFFFFFFE
@@ -143,9 +151,8 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap,
rt_sem_init(&(memheap->lock), name, 1, RT_IPC_FLAG_PRIO);
memheap->locked = RT_FALSE;
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
- ("memory heap: start addr 0x%08x, size %d, free list header 0x%08x\n",
- start_addr, size, &(memheap->free_header)));
+ LOG_D("memory heap: start addr 0x%08x, size %d, free list header 0x%08x",
+ start_addr, size, &(memheap->free_header));
return RT_EOK;
}
@@ -195,8 +202,8 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
if (size < RT_MEMHEAP_MINIALLOC)
size = RT_MEMHEAP_MINIALLOC;
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("allocate %d on heap:%8.*s",
- size, RT_NAME_MAX, heap->parent.name));
+ LOG_D("allocate %d on heap:%8.*s",
+ size, RT_NAME_MAX, heap->parent.name);
if (size < heap->available_size)
{
@@ -242,12 +249,11 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
new_ptr = (struct rt_memheap_item *)
(((rt_uint8_t *)header_ptr) + size + RT_MEMHEAP_SIZE);
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
- ("split: block[0x%08x] nextm[0x%08x] prevm[0x%08x] to new[0x%08x]\n",
- header_ptr,
- header_ptr->next,
- header_ptr->prev,
- new_ptr));
+ LOG_D("split: block[0x%08x] nextm[0x%08x] prevm[0x%08x] to new[0x%08x]",
+ header_ptr,
+ header_ptr->next,
+ header_ptr->prev,
+ new_ptr);
/* mark the new block as a memory block and freed. */
new_ptr->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_FREED);
@@ -276,9 +282,9 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
new_ptr->prev_free = heap->free_list;
heap->free_list->next_free->prev_free = new_ptr;
heap->free_list->next_free = new_ptr;
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("new ptr: next_free 0x%08x, prev_free 0x%08x\n",
- new_ptr->next_free,
- new_ptr->prev_free));
+ LOG_D("new ptr: next_free 0x%08x, prev_free 0x%08x",
+ new_ptr->next_free,
+ new_ptr->prev_free);
/* decrement the available byte count. */
heap->available_size = heap->available_size -
@@ -295,11 +301,10 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
heap->max_used_size = heap->pool_size - heap->available_size;
/* remove header_ptr from free list */
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
- ("one block: block[0x%08x], next_free 0x%08x, prev_free 0x%08x\n",
- header_ptr,
- header_ptr->next_free,
- header_ptr->prev_free));
+ LOG_D("one block: block[0x%08x], next_free 0x%08x, prev_free 0x%08x",
+ header_ptr,
+ header_ptr->next_free,
+ header_ptr->prev_free);
header_ptr->next_free->prev_free = header_ptr->prev_free;
header_ptr->prev_free->next_free = header_ptr->next_free;
@@ -324,11 +329,10 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
}
/* Return a memory address to the caller. */
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
- ("alloc mem: memory[0x%08x], heap[0x%08x], size: %d\n",
- (void *)((rt_uint8_t *)header_ptr + RT_MEMHEAP_SIZE),
- header_ptr,
- size));
+ LOG_D("alloc mem: memory[0x%08x], heap[0x%08x], size: %d",
+ (void *)((rt_uint8_t *)header_ptr + RT_MEMHEAP_SIZE),
+ header_ptr,
+ size);
return (void *)((rt_uint8_t *)header_ptr + RT_MEMHEAP_SIZE);
}
@@ -340,7 +344,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
}
}
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("allocate memory: failed\n"));
+ LOG_D("allocate memory: failed");
/* Return the completion status. */
return RT_NULL;
@@ -436,22 +440,20 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
heap->max_used_size = heap->pool_size - heap->available_size;
/* remove next_ptr from free list */
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
- ("remove block: block[0x%08x], next_free 0x%08x, prev_free 0x%08x",
- next_ptr,
- next_ptr->next_free,
- next_ptr->prev_free));
+ LOG_D("remove block: block[0x%08x], next_free 0x%08x, prev_free 0x%08x",
+ next_ptr,
+ next_ptr->next_free,
+ next_ptr->prev_free);
_remove_next_ptr(next_ptr);
/* build a new one on the right place */
next_ptr = (struct rt_memheap_item *)((char *)ptr + newsize);
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
- ("new free block: block[0x%08x] nextm[0x%08x] prevm[0x%08x]",
- next_ptr,
- next_ptr->next,
- next_ptr->prev));
+ LOG_D("new free block: block[0x%08x] nextm[0x%08x] prevm[0x%08x]",
+ next_ptr,
+ next_ptr->next,
+ next_ptr->prev);
/* mark the new block as a memory block and freed. */
next_ptr->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_FREED);
@@ -473,9 +475,9 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
next_ptr->prev_free = heap->free_list;
heap->free_list->next_free->prev_free = (struct rt_memheap_item *)next_ptr;
heap->free_list->next_free = (struct rt_memheap_item *)next_ptr;
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("new ptr: next_free 0x%08x, prev_free 0x%08x",
- next_ptr->next_free,
- next_ptr->prev_free));
+ LOG_D("new ptr: next_free 0x%08x, prev_free 0x%08x",
+ next_ptr->next_free,
+ next_ptr->prev_free);
if (heap->locked == RT_FALSE)
{
/* release lock */
@@ -523,12 +525,11 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
new_ptr = (struct rt_memheap_item *)
(((rt_uint8_t *)header_ptr) + newsize + RT_MEMHEAP_SIZE);
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
- ("split: block[0x%08x] nextm[0x%08x] prevm[0x%08x] to new[0x%08x]\n",
- header_ptr,
- header_ptr->next,
- header_ptr->prev,
- new_ptr));
+ LOG_D("split: block[0x%08x] nextm[0x%08x] prevm[0x%08x] to new[0x%08x]",
+ header_ptr,
+ header_ptr->next,
+ header_ptr->prev,
+ new_ptr);
/* mark the new block as a memory block and freed. */
new_ptr->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_FREED);
@@ -554,9 +555,8 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
free_ptr = new_ptr->next;
heap->available_size = heap->available_size - MEMITEM_SIZE(free_ptr);
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
- ("merge: right node 0x%08x, next_free 0x%08x, prev_free 0x%08x\n",
- header_ptr, header_ptr->next_free, header_ptr->prev_free));
+ LOG_D("merge: right node 0x%08x, next_free 0x%08x, prev_free 0x%08x",
+ header_ptr, header_ptr->next_free, header_ptr->prev_free);
free_ptr->next->prev = new_ptr;
new_ptr->next = free_ptr->next;
@@ -571,9 +571,9 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
new_ptr->prev_free = heap->free_list;
heap->free_list->next_free->prev_free = new_ptr;
heap->free_list->next_free = new_ptr;
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("new free ptr: next_free 0x%08x, prev_free 0x%08x\n",
- new_ptr->next_free,
- new_ptr->prev_free));
+ LOG_D("new free ptr: next_free 0x%08x, prev_free 0x%08x",
+ new_ptr->next_free,
+ new_ptr->prev_free);
/* increment the available byte count. */
heap->available_size = heap->available_size + MEMITEM_SIZE(new_ptr);
@@ -611,15 +611,15 @@ void rt_memheap_free(void *ptr)
header_ptr = (struct rt_memheap_item *)
((rt_uint8_t *)ptr - RT_MEMHEAP_SIZE);
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("free memory: memory[0x%08x], block[0x%08x]\n",
- ptr, header_ptr));
+ LOG_D("free memory: memory[0x%08x], block[0x%08x]",
+ ptr, header_ptr);
/* check magic */
if (header_ptr->magic != (RT_MEMHEAP_MAGIC | RT_MEMHEAP_USED) ||
(header_ptr->next->magic & RT_MEMHEAP_MASK) != RT_MEMHEAP_MAGIC)
{
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("bad magic:0x%08x @ memheap\n",
- header_ptr->magic));
+ LOG_D("bad magic:0x%08x @ memheap",
+ header_ptr->magic);
RT_ASSERT(header_ptr->magic == (RT_MEMHEAP_MAGIC | RT_MEMHEAP_USED));
/* check whether this block of memory has been over-written. */
RT_ASSERT((header_ptr->next->magic & RT_MEMHEAP_MASK) == RT_MEMHEAP_MAGIC);
@@ -651,8 +651,8 @@ void rt_memheap_free(void *ptr)
/* Determine if the block can be merged with the previous neighbor. */
if (!RT_MEMHEAP_IS_USED(header_ptr->prev))
{
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("merge: left node 0x%08x\n",
- header_ptr->prev));
+ LOG_D("merge: left node 0x%08x",
+ header_ptr->prev);
/* adjust the available number of bytes. */
heap->available_size += RT_MEMHEAP_SIZE;
@@ -676,9 +676,8 @@ void rt_memheap_free(void *ptr)
/* merge block with next neighbor. */
new_ptr = header_ptr->next;
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
- ("merge: right node 0x%08x, next_free 0x%08x, prev_free 0x%08x\n",
- new_ptr, new_ptr->next_free, new_ptr->prev_free));
+ LOG_D("merge: right node 0x%08x, next_free 0x%08x, prev_free 0x%08x",
+ new_ptr, new_ptr->next_free, new_ptr->prev_free);
new_ptr->next->prev = header_ptr;
header_ptr->next = new_ptr->next;
@@ -708,9 +707,8 @@ void rt_memheap_free(void *ptr)
n->prev_free->next_free = header_ptr;
n->prev_free = header_ptr;
- RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
- ("insert to free list: next_free 0x%08x, prev_free 0x%08x\n",
- header_ptr->next_free, header_ptr->prev_free));
+ LOG_D("insert to free list: next_free 0x%08x, prev_free 0x%08x",
+ header_ptr->next_free, header_ptr->prev_free);
}
#ifdef RT_USING_MEMTRACE
diff --git a/src/scheduler_mp.c b/src/scheduler_mp.c
index 243cfd8dbe..a1f9912193 100644
--- a/src/scheduler_mp.c
+++ b/src/scheduler_mp.c
@@ -34,6 +34,14 @@
#include <rtthread.h>
#include <rthw.h>
+#define DBG_TAG "kernel.scheduler"
+#ifdef RT_DEBUG_SCHEDULER
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif /* defined (RT_DEBUG_SCHEDULER) */
+#include <rtdbg.h>
+
rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX];
rt_uint32_t rt_thread_ready_priority_group;
#if RT_THREAD_PRIORITY_MAX > 32
@@ -180,8 +188,8 @@ void rt_system_scheduler_init(void)
int cpu;
rt_base_t offset;
- RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("start scheduler: max priority 0x%02x\n",
- RT_THREAD_PRIORITY_MAX));
+ LOG_D("start scheduler: max priority 0x%02x",
+ RT_THREAD_PRIORITY_MAX);
for (offset = 0; offset < RT_THREAD_PRIORITY_MAX; offset ++)
{
@@ -345,13 +353,12 @@ void rt_schedule(void)
to_thread->stat = RT_THREAD_RUNNING | (to_thread->stat & ~RT_THREAD_STAT_MASK);
/* switch to new thread */
- RT_DEBUG_LOG(RT_DEBUG_SCHEDULER,
- ("[%d]switch to priority#%d "
+ LOG_D("[%d]switch to priority#%d "
"thread:%.*s(sp:0x%08x), "
- "from thread:%.*s(sp: 0x%08x)\n",
+ "from thread:%.*s(sp: 0x%08x)",
pcpu->irq_nest, highest_ready_priority,
RT_NAME_MAX, to_thread->parent.name, to_thread->sp,
- RT_NAME_MAX, current_thread->parent.name, current_thread->sp));
+ RT_NAME_MAX, current_thread->parent.name, current_thread->sp);
#ifdef RT_USING_OVERFLOW_CHECK
_scheduler_stack_check(to_thread);
@@ -482,7 +489,7 @@ void rt_scheduler_do_irq_switch(void *context)
#ifdef RT_USING_OVERFLOW_CHECK
_scheduler_stack_check(to_thread);
#endif /* RT_USING_OVERFLOW_CHECK */
- RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("switch in interrupt\n"));
+ LOG_D("switch in interrupt");
RT_ASSERT(current_thread->cpus_lock_nest > 0);
current_thread->cpus_lock_nest--;
@@ -584,8 +591,8 @@ void rt_schedule_insert_thread(struct rt_thread *thread)
}
}
- RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("insert thread[%.*s], the priority: %d\n",
- RT_NAME_MAX, thread->parent.name, thread->current_priority));
+ LOG_D("insert thread[%.*s], the priority: %d",
+ RT_NAME_MAX, thread->parent.name, thread->current_priority);
__exit:
/* enable interrupt */
@@ -608,9 +615,9 @@ void rt_schedule_remove_thread(struct rt_thread *thread)
/* disable interrupt */
level = rt_hw_interrupt_disable();
- RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("remove thread[%.*s], the priority: %d\n",
- RT_NAME_MAX, thread->parent.name,
- thread->current_priority));
+ LOG_D("remove thread[%.*s], the priority: %d",
+ RT_NAME_MAX, thread->parent.name,
+ thread->current_priority);
/* remove thread from ready list */
rt_list_remove(&(thread->tlist));
diff --git a/src/scheduler_up.c b/src/scheduler_up.c
index 4c96089e34..ab4c0e977a 100644
--- a/src/scheduler_up.c
+++ b/src/scheduler_up.c
@@ -34,6 +34,14 @@
#include <rtthread.h>
#include <rthw.h>
+#define DBG_TAG "kernel.scheduler"
+#ifdef RT_DEBUG_SCHEDULER
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif /* defined (RT_DEBUG_SCHEDULER) */
+#include <rtdbg.h>
+
rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX];
rt_uint32_t rt_thread_ready_priority_group;
#if RT_THREAD_PRIORITY_MAX > 32
@@ -170,8 +178,8 @@ void rt_system_scheduler_init(void)
rt_base_t offset;
rt_scheduler_lock_nest = 0;
- RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("start scheduler: max priority 0x%02x\n",
- RT_THREAD_PRIORITY_MAX));
+ LOG_D("start scheduler: max priority 0x%02x",
+ RT_THREAD_PRIORITY_MAX);
for (offset = 0; offset < RT_THREAD_PRIORITY_MAX; offset ++)
{
@@ -277,13 +285,12 @@ void rt_schedule(void)
to_thread->stat = RT_THREAD_RUNNING | (to_thread->stat & ~RT_THREAD_STAT_MASK);
/* switch to new thread */
- RT_DEBUG_LOG(RT_DEBUG_SCHEDULER,
- ("[%d]switch to priority#%d "
+ LOG_D("[%d]switch to priority#%d "
"thread:%.*s(sp:0x%08x), "
- "from thread:%.*s(sp: 0x%08x)\n",
+ "from thread:%.*s(sp: 0x%08x)",
rt_interrupt_nest, highest_ready_priority,
RT_NAME_MAX, to_thread->parent.name, to_thread->sp,
- RT_NAME_MAX, from_thread->parent.name, from_thread->sp));
+ RT_NAME_MAX, from_thread->parent.name, from_thread->sp);
#ifdef RT_USING_OVERFLOW_CHECK
_scheduler_stack_check(to_thread);
@@ -324,7 +331,7 @@ void rt_schedule(void)
}
else
{
- RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("switch in interrupt\n"));
+ LOG_D("switch in interrupt");
rt_hw_context_switch_interrupt((rt_ubase_t)&from_thread->sp,
(rt_ubase_t)&to_thread->sp, from_thread, to_thread);
@@ -384,8 +391,8 @@ void rt_schedule_insert_thread(struct rt_thread *thread)
&(thread->tlist));
}
- RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("insert thread[%.*s], the priority: %d\n",
- RT_NAME_MAX, thread->parent.name, thread->current_priority));
+ LOG_D("insert thread[%.*s], the priority: %d",
+ RT_NAME_MAX, thread->parent.name, thread->current_priority);
/* set priority mask */
#if RT_THREAD_PRIORITY_MAX > 32
@@ -414,9 +421,9 @@ void rt_schedule_remove_thread(struct rt_thread *thread)
/* disable interrupt */
level = rt_hw_interrupt_disable();
- RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("remove thread[%.*s], the priority: %d\n",
- RT_NAME_MAX, thread->parent.name,
- thread->current_priority));
+ LOG_D("remove thread[%.*s], the priority: %d",
+ RT_NAME_MAX, thread->parent.name,
+ thread->current_priority);
/* remove thread from ready list */
rt_list_remove(&(thread->tlist));
diff --git a/src/slab.c b/src/slab.c
index e883a9de9b..c026dde982 100644
--- a/src/slab.c
+++ b/src/slab.c
@@ -56,6 +56,15 @@
#include <rtthread.h>
#if defined (RT_USING_SLAB)
+
+#define DBG_TAG "kernel.slab"
+#ifdef RT_DEBUG_SLAB
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif /* defined (RT_DEBUG_SLAB) */
+#include <rtdbg.h>
+
/*
* slab allocator implementation
*
@@ -336,8 +345,8 @@ rt_slab_t rt_slab_init(const char *name, void *begin_addr, rt_size_t size)
limsize = end_align - begin_align;
npages = limsize / RT_MM_PAGE_SIZE;
- RT_DEBUG_LOG(RT_DEBUG_SLAB, ("heap[0x%x - 0x%x], size 0x%x, 0x%x pages\n",
- begin_align, end_align, limsize, npages));
+ LOG_D("heap[0x%x - 0x%x], size 0x%x, 0x%x pages",
+ begin_align, end_align, limsize, npages);
rt_memset(slab, 0, sizeof(*slab));
/* initialize slab memory object */
@@ -364,16 +373,16 @@ rt_slab_t rt_slab_init(const char *name, void *begin_addr, rt_size_t size)
slab->zone_page_cnt = slab->zone_size / RT_MM_PAGE_SIZE;
- RT_DEBUG_LOG(RT_DEBUG_SLAB, ("zone size 0x%x, zone page count 0x%x\n",
- slab->zone_size, slab->zone_page_cnt));
+ LOG_D("zone size 0x%x, zone page count 0x%x",
+ slab->zone_size, slab->zone_page_cnt);
/* allocate slab->memusage array */
limsize = npages * sizeof(struct rt_slab_memusage);
limsize = RT_ALIGN(limsize, RT_MM_PAGE_SIZE);
slab->memusage = rt_slab_page_alloc((rt_slab_t)(&slab->parent), limsize / RT_MM_PAGE_SIZE);
- RT_DEBUG_LOG(RT_DEBUG_SLAB, ("slab->memusage 0x%x, size 0x%x\n",
- (rt_ubase_t)slab->memusage, limsize));
+ LOG_D("slab->memusage 0x%x, size 0x%x",
+ (rt_ubase_t)slab->memusage, limsize);
return &slab->parent;
}
RTM_EXPORT(rt_slab_init);
@@ -511,11 +520,10 @@ void *rt_slab_alloc(rt_slab_t m, rt_size_t size)
kup->type = PAGE_TYPE_LARGE;
kup->size = size >> RT_MM_PAGE_BITS;
- RT_DEBUG_LOG(RT_DEBUG_SLAB,
- ("alloc a large memory 0x%x, page cnt %d, kup %d\n",
- size,
- size >> RT_MM_PAGE_BITS,
- ((rt_ubase_t)chunk - slab->heap_start) >> RT_MM_PAGE_BITS));
+ LOG_D("alloc a large memory 0x%x, page cnt %d, kup %d",
+ size,
+ size >> RT_MM_PAGE_BITS,
+ ((rt_ubase_t)chunk - slab->heap_start) >> RT_MM_PAGE_BITS);
/* mem stat */
slab->parent.used += size;
if (slab->parent.used > slab->parent.max)
@@ -534,7 +542,7 @@ void *rt_slab_alloc(rt_slab_t m, rt_size_t size)
zi = zoneindex(&size);
RT_ASSERT(zi < RT_SLAB_NZONES);
- RT_DEBUG_LOG(RT_DEBUG_SLAB, ("try to alloc 0x%x on zone: %d\n", size, zi));
+ LOG_D("try to alloc 0x%x on zone: %d", size, zi);
if ((z = slab->zone_array[zi]) != RT_NULL)
{
@@ -600,8 +608,8 @@ void *rt_slab_alloc(rt_slab_t m, rt_size_t size)
return RT_NULL;
}
- RT_DEBUG_LOG(RT_DEBUG_SLAB, ("alloc a new zone: 0x%x\n",
- (rt_ubase_t)z));
+ LOG_D("alloc a new zone: 0x%x",
+ (rt_ubase_t)z);
/* set message usage */
for (off = 0, kup = btokup(z); off < slab->zone_page_cnt; off ++)
@@ -743,14 +751,13 @@ void rt_slab_free(rt_slab_t m, void *ptr)
return ;
/* get memory usage */
-#if RT_DEBUG_SLAB
+#ifdef RT_DEBUG_SLAB
{
rt_ubase_t addr = ((rt_ubase_t)ptr & ~RT_MM_PAGE_MASK);
- RT_DEBUG_LOG(RT_DEBUG_SLAB,
- ("free a memory 0x%x and align to 0x%x, kup index %d\n",
- (rt_ubase_t)ptr,
- (rt_ubase_t)addr,
- ((rt_ubase_t)(addr) - slab->heap_start) >> RT_MM_PAGE_BITS));
+ LOG_D("free a memory 0x%x and align to 0x%x, kup index %d",
+ (rt_ubase_t)ptr,
+ (rt_ubase_t)addr,
+ ((rt_ubase_t)(addr) - slab->heap_start) >> RT_MM_PAGE_BITS);
}
#endif /* RT_DEBUG_SLAB */
@@ -766,9 +773,8 @@ void rt_slab_free(rt_slab_t m, void *ptr)
/* mem stats */
slab->parent.used -= size * RT_MM_PAGE_SIZE;
- RT_DEBUG_LOG(RT_DEBUG_SLAB,
- ("free large memory block 0x%x, page count %d\n",
- (rt_ubase_t)ptr, size));
+ LOG_D("free large memory block 0x%x, page count %d",
+ (rt_ubase_t)ptr, size);
/* free this page */
rt_slab_page_free(m, ptr, size);
@@ -808,8 +814,8 @@ void rt_slab_free(rt_slab_t m, void *ptr)
{
struct rt_slab_zone **pz;
- RT_DEBUG_LOG(RT_DEBUG_SLAB, ("free zone 0x%x\n",
- (rt_ubase_t)z, z->z_zoneindex));
+ LOG_D("free zone 0x%x",
+ (rt_ubase_t)z, z->z_zoneindex);
/* remove zone from zone array list */
for (pz = &slab->zone_array[z->z_zoneindex]; z != *pz; pz = &(*pz)->z_next)
diff --git a/src/thread.c b/src/thread.c
index ad82a13550..57b922894b 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -38,6 +38,14 @@
#include <rtthread.h>
#include <stddef.h>
+#define DBG_TAG "kernel.thread"
+#ifdef RT_DEBUG_THREAD
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif /* defined (RT_DEBUG_THREAD) */
+#include <rtdbg.h>
+
#ifndef __on_rt_thread_inited_hook
#define __on_rt_thread_inited_hook(thread) __ON_HOOK_ARGS(rt_thread_inited_hook, (thread))
#endif
@@ -385,8 +393,8 @@ rt_err_t rt_thread_startup(rt_thread_t thread)
thread->number_mask = 1L << thread->current_priority;
#endif /* RT_THREAD_PRIORITY_MAX > 32 */
- RT_DEBUG_LOG(RT_DEBUG_THREAD, ("startup a thread:%s with priority:%d\n",
- thread->parent.name, thread->current_priority));
+ LOG_D("startup a thread:%s with priority:%d",
+ thread->parent.name, thread->current_priority);
/* change thread stat */
thread->stat = RT_THREAD_SUSPEND;
/* then resume it */
@@ -983,12 +991,12 @@ rt_err_t rt_thread_suspend_with_flag(rt_thread_t thread, int suspend_flag)
RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
RT_ASSERT(thread == rt_thread_self());
- RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: %s\n", thread->parent.name));
+ LOG_D("thread suspend: %s", thread->parent.name);
stat = thread->stat & RT_THREAD_STAT_MASK;
if ((stat != RT_THREAD_READY) && (stat != RT_THREAD_RUNNING))
{
- RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: thread disorder, 0x%2x\n", thread->stat));
+ LOG_D("thread suspend: thread disorder, 0x%2x", thread->stat);
return -RT_ERROR;
}
@@ -1046,12 +1054,12 @@ rt_err_t rt_thread_resume(rt_thread_t thread)
RT_ASSERT(thread != RT_NULL);
RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
- RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread resume: %s\n", thread->parent.name));
+ LOG_D("thread resume: %s", thread->parent.name);
if ((thread->stat & RT_THREAD_SUSPEND_MASK) != RT_THREAD_SUSPEND_MASK)
{
- RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread resume: thread disorder, %d\n",
- thread->stat));
+ LOG_D("thread resume: thread disorder, %d",
+ thread->stat);
return -RT_ERROR;
}
diff --git a/src/timer.c b/src/timer.c
index 037b97b134..04e4a91b13 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -24,6 +24,14 @@
#include <rtthread.h>
#include <rthw.h>
+#define DBG_TAG "kernel.timer"
+#ifdef RT_DEBUG_TIMER
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif /* defined (RT_DEBUG_TIMER) */
+#include <rtdbg.h>
+
/* hard timer list */
static rt_list_t _timer_list[RT_TIMER_SKIP_LIST_LEVEL];
@@ -195,7 +203,7 @@ rt_inline void _timer_remove(rt_timer_t timer)
}
}
-#if RT_DEBUG_TIMER
+#ifdef RT_DEBUG_TIMER
/**
* @brief The number of timer
*
@@ -653,7 +661,7 @@ void rt_timer_check(void)
rt_list_init(&list);
- RT_DEBUG_LOG(RT_DEBUG_TIMER, ("timer check enter\n"));
+ LOG_D("timer check enter");
current_tick = rt_tick_get();
@@ -688,7 +696,7 @@ void rt_timer_check(void)
current_tick = rt_tick_get();
RT_OBJECT_HOOK_CALL(rt_timer_exit_hook, (t));
- RT_DEBUG_LOG(RT_DEBUG_TIMER, ("current tick: %d\n", current_tick));
+ LOG_D("current tick: %d", current_tick);
/* Check whether the timer object is detached or started again */
if (rt_list_isempty(&list))
@@ -710,7 +718,7 @@ void rt_timer_check(void)
/* enable interrupt */
rt_hw_interrupt_enable(level);
- RT_DEBUG_LOG(RT_DEBUG_TIMER, ("timer check leave\n"));
+ LOG_D("timer check leave");
}
/**
@@ -739,7 +747,7 @@ void rt_soft_timer_check(void)
rt_list_init(&list);
- RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check enter\n"));
+ LOG_D("software timer check enter");
/* disable interrupt */
level = rt_hw_interrupt_disable();
@@ -776,7 +784,7 @@ void rt_soft_timer_check(void)
t->timeout_func(t->parameter);
RT_OBJECT_HOOK_CALL(rt_timer_exit_hook, (t));
- RT_DEBUG_LOG(RT_DEBUG_TIMER, ("current tick: %d\n", current_tick));
+ LOG_D("current tick: %d", current_tick);
/* disable interrupt */
level = rt_hw_interrupt_disable();
@@ -801,7 +809,7 @@ void rt_soft_timer_check(void)
/* enable interrupt */
rt_hw_interrupt_enable(level);
- RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check leave\n"));
+ LOG_D("software timer check leave");
}
/**