This is the mail archive of the ecos-devel@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

REGION TOP and malloc


Hi all,

I am currently working on an AT91-like board for which I have 16MB of
SDRAM. However, not all of the SDRAM can be used, so I added the
support for CYGINT_HAL_ARM_MEM_REAL_REGION_TOP and it seems to work
well in the sense that my hal_arm_mem_real_region_top() function is
called, and the _actual_ TOP is returned.

Though, my problem is that malloc() still continues to return
addresses above my actual heap TOP. I tried to read the code, my
heaps.cxx really seems OK:
 Cyg_Mempool_dlmalloc CYGBLD_ATTRIB_INIT_BEFORE(CYG_INIT_MEMALLOC)
cygmem_pool_heap1 ( (cyg_uint8 *)CYGMEM_SECTION_heap1 ,
    HAL_MEM_REAL_REGION_TOP( (cyg_uint8 *)CYGMEM_SECTION_heap1 +
CYGMEM_SECTION_heap1_SIZE ) - (cyg_uint8 *)CYGMEM_SECTION_heap1 )
        ;
Which really makes the base address and size I have, and according to
the different Malloc implementation (mvarimpl.inl and dlmalloc.cxx),
malloc should either fail or return a valid address (which _is_
possible as I allocate only 800kB out of 8.9MB available).

In order to do the test, I just replaced all my calls to malloc() with:
void* ptr = malloc(size); \
CYG_ASSERT(ptr <= HAL_MEM_REAL_REGION_TOP( (cyg_uint8
*)CYGMEM_SECTION_heap1 + CYGMEM_SECTION_heap1_SIZE ), "malloc returned
an @ out of memory..." )

This assert always fail after a while (but as stated above, mallinfo()
returns 8.9MB free at this point and the size asked for is lower than
800kB). So where did I miss something ?

Thanks in advance,

-- 
damien


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]