public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
From: "andrew wiggin" <end3er@gmail.com>
To: ecos-devel@ecos.sourceware.org
Subject: REGION TOP and malloc
Date: Tue, 04 Nov 2008 19:29:00 -0000	[thread overview]
Message-ID: <69b5c5160811041128q74c4a47dwb4d416288a0255b4@mail.gmail.com> (raw)

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

                 reply	other threads:[~2008-11-04 19:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=69b5c5160811041128q74c4a47dwb4d416288a0255b4@mail.gmail.com \
    --to=end3er@gmail.com \
    --cc=ecos-devel@ecos.sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).