public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
* REGION TOP and malloc
@ 2008-11-04 19:29 andrew wiggin
  0 siblings, 0 replies; only message in thread
From: andrew wiggin @ 2008-11-04 19:29 UTC (permalink / raw)
  To: ecos-devel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-04 19:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-04 19:29 REGION TOP and malloc andrew wiggin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).