This is the mail archive of the
ecos-devel@sourceware.org
mailing list for the eCos project.
REGION TOP and malloc
- From: "andrew wiggin" <end3er at gmail dot com>
- To: ecos-devel at ecos dot sourceware dot org
- Date: Tue, 4 Nov 2008 20:28:23 +0100
- Subject: REGION TOP and malloc
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=Q5FOm4RmzT+txmTc2cvKOr2HpCHlyprXTP8ypW9zj44=; b=AX8sbkp8urdVJqOGl2b9kkc3f4Jq9KRfpapKKg44dEYhLdARTGevzNYacqRsGbO9Pj qXu3xXdcjV7H87pGrerCfyo3fKCq4Hl62Iuyx7x7DI/N8itLO2E/H/aU4lRUAMXbNIEi M10fxM3cFxTwWPKtLOn/teV58PwohxDYET3f4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=bXg2obb6thxLyiteiT1SXoxS+yJUsPZkwo8jH69I5mQcCU5wfL8rGyQi1sDc52O9nL ODiOrNIvesT3DzSocWqIuZBcusPUUlHRHlirWXl2OUQMZrjweRroERN6mqJmLruZNbvg 6uDkrNiHN3mGQVvEPHsM0QLhMe0muudUyy0OI=
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