apply kuronca patch for heap initialization check.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@811 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
f834265044
commit
0a64bac9d9
|
@ -96,7 +96,7 @@ void rt_tick_increase()
|
|||
rt_tick_t rt_tick_from_millisecond(rt_uint32_t ms)
|
||||
{
|
||||
/* return the calculated tick */
|
||||
return (RT_TICK_PER_SECOND * ms) / 1000 + (RT_TICK_PER_SECOND * ms) % 1000 ? 1:0;
|
||||
return (RT_TICK_PER_SECOND * ms+999) / 1000;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
|
15
src/mem.c
15
src/mem.c
|
@ -166,15 +166,22 @@ static void plug_holes(struct heap_mem *mem)
|
|||
void rt_system_heap_init(void* begin_addr, void* end_addr)
|
||||
{
|
||||
struct heap_mem *mem;
|
||||
rt_uint32_t begin_align = RT_ALIGN((rt_uint32_t)begin_addr, RT_ALIGN_SIZE);
|
||||
rt_uint32_t end_align = RT_ALIGN_DOWN((rt_uint32_t)end_addr, RT_ALIGN_SIZE);
|
||||
|
||||
/* alignment addr */
|
||||
begin_addr = (void*)RT_ALIGN((rt_uint32_t)begin_addr, RT_ALIGN_SIZE);
|
||||
|
||||
if((end_align > (2 * SIZEOF_STRUCT_MEM) ) &&
|
||||
((end_align - 2 * SIZEOF_STRUCT_MEM) >= begin_align )) {
|
||||
/* calculate the aligned memory size */
|
||||
mem_size_aligned = RT_ALIGN_DOWN((rt_uint32_t)end_addr - (rt_uint32_t)begin_addr, RT_ALIGN_SIZE) - 2 * SIZEOF_STRUCT_MEM;
|
||||
mem_size_aligned = end_align - begin_align - 2 * SIZEOF_STRUCT_MEM;
|
||||
}
|
||||
else {
|
||||
rt_kprintf("mem init, error begin address 0x%x, and end address 0x%x\n", (rt_uint32_t)begin_addr, (rt_uint32_t)end_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
/* point to begin address of heap */
|
||||
heap_ptr = begin_addr;
|
||||
heap_ptr = (rt_uint8_t *)begin_align;
|
||||
|
||||
#ifdef RT_MEM_DEBUG
|
||||
rt_kprintf("mem init, heap begin address 0x%x, size %d\n", (rt_uint32_t)heap_ptr, mem_size_aligned);
|
||||
|
|
|
@ -329,6 +329,11 @@ void rt_system_heap_init(void *begin_addr, void* end_addr)
|
|||
heap_start = RT_ALIGN((rt_uint32_t)begin_addr, RT_MM_PAGE_SIZE);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
limsize = heap_end - heap_start;
|
||||
npages = limsize / RT_MM_PAGE_SIZE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue