summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author[email protected] <[email protected]>2010-12-08 23:17:23 +0000
committer[email protected] <[email protected]>2010-12-08 23:17:23 +0000
commitfbe81f8c4c29433859920b2f08f4ff001b891134 (patch)
tree085f649b2b5493445a971ba76d6922689554fd47 /src
parent7cdd2849a717914a90e4b24409d16932518c2f9e (diff)
add IAR compiler version check in weak; add rt_malloc_page/rt_free_page for application module; fix the software timer thread stack issue.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1183 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'src')
-rw-r--r--src/kservice.c5
-rw-r--r--src/slab.c52
-rw-r--r--src/timer.c1
3 files changed, 55 insertions, 3 deletions
diff --git a/src/kservice.c b/src/kservice.c
index c0ff6d2f6c..029302c1ea 100644
--- a/src/kservice.c
+++ b/src/kservice.c
@@ -942,7 +942,10 @@ void rt_hw_console_output(const char* str)
#elif defined(__CC_ARM)
__weak void rt_hw_console_output(const char* str)
#elif defined(__IAR_SYSTEMS_ICC__)
-__weak void rt_hw_console_output(const char* str)
+#if __VER__ > 540
+__weak
+#endif
+void rt_hw_console_output(const char* str)
#endif
{
/* empty console output */
diff --git a/src/slab.c b/src/slab.c
index b8175482c5..927f09f3fa 100644
--- a/src/slab.c
+++ b/src/slab.c
@@ -342,7 +342,8 @@ void rt_system_heap_init(void *begin_addr, void* end_addr)
heap_end = RT_ALIGN_DOWN((rt_uint32_t)end_addr, RT_MM_PAGE_SIZE);
if(heap_start >= heap_end) {
- rt_kprintf("rt_system_heap_init, error begin address 0x%x, and end address 0x%x\n", (rt_uint32_t)begin_addr, (rt_uint32_t)end_addr);
+ rt_kprintf("rt_system_heap_init, wrong address[0x%x - 0x%x]\n",
+ (rt_uint32_t)begin_addr, (rt_uint32_t)end_addr);
return;
}
@@ -353,7 +354,8 @@ void rt_system_heap_init(void *begin_addr, void* end_addr)
rt_sem_init(&heap_sem, "heap", 1, RT_IPC_FLAG_FIFO);
#ifdef RT_SLAB_DEBUG
- rt_kprintf("heap[0x%x - 0x%x], size 0x%x, 0x%x pages\n", heap_start, heap_end, limsize, npages);
+ rt_kprintf("heap[0x%x - 0x%x], size 0x%x, 0x%x pages\n", heap_start, heap_end,
+ limsize, npages);
#endif
/* init pages */
@@ -442,6 +444,52 @@ rt_inline int zoneindex(rt_uint32_t *bytes)
/*@{*/
+/*
+ * This function will allocate the numbers page with specified size
+ * in page memory.
+ *
+ * @param size the size of memory to be allocated.
+ * @note this function is used for RT-Thread Application Module
+ */
+void *rt_malloc_page(rt_size_t npages)
+{
+ void* chunk;
+
+ chunk = rt_page_alloc(npages);
+ if (chunk == RT_NULL) return RT_NULL;
+
+ /* update memory usage */
+#ifdef RT_MEM_STATS
+ rt_sem_take(&heap_sem, RT_WAITING_FOREVER);
+ used_mem += npages * RT_MM_PAGE_SIZE;
+ if (used_mem > max_mem) max_mem = used_mem;
+ rt_sem_release(&heap_sem);
+#endif
+
+ return chunk;
+}
+
+/*
+ * This function will release the previously allocated memory page
+ * by rt_malloc_page.
+ *
+ * @param page_ptr the page address to be released.
+ * @param npages the number of page shall be released.
+ *
+ * @note this function is used for RT-Thread Application Module
+ */
+void rt_free_page(void *page_ptr, rt_size_t npages)
+{
+ rt_page_free(page_ptr, npages);
+
+ /* update memory usage */
+#ifdef RT_MEM_STATS
+ rt_sem_take(&heap_sem, RT_WAITING_FOREVER);
+ used_mem -= npages * RT_MM_PAGE_SIZE;
+ rt_sem_release(&heap_sem);
+#endif
+}
+
/**
* This function will allocate a block from system heap memory.
* - If the nbytes is less than zero,
diff --git a/src/timer.c b/src/timer.c
index b21a3016bd..21fe1f6466 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -416,6 +416,7 @@ void rt_timer_check(void)
#ifdef RT_USING_TIMER_SOFT
static struct rt_thread timer_thread;
+ALIGN(RT_ALIGN_SIZE)
static rt_uint8_t timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE];
static struct rt_semaphore timer_sem;