patchlwIP - A Lightweight TCP/IP stack - Patches: patch #6966, Moving the heap into a user...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #6966: Moving the heap into a user defined section

Submitter:  Iordan Neshev <iordan_neshev>
Submitted:  Fri 30 Oct 2009 04:20:05 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  goldsimon Open/Closed:  Closed
Planned Release:  None

Wed 13 Jan 2010 01:10:34 PM UTC, comment #4: 

Done by adding the LWIP_RAM_HEAP_POINTER define.

Simon Goldschmidt <goldsimon>
Group administrator
Mon 11 Jan 2010 10:55:07 PM UTC, comment #3: 

This is a great solution and flexible.  The user can point to memory however it's obtained.  Taking care of where the memory is located is now in the user's control too.

I also agree with not having static (same for memp_pools) as exposing it allows that memory to be accessed in a debugger.

Bill Auerbach <billauerbach>
Mon 11 Jan 2010 06:15:26 PM UTC, comment #2: 

Additionally, we could remove the static modifier from 'ram_heap' to allow the same mechanism as for the memp pools (see discussion in bug #26133).

Simon Goldschmidt <goldsimon>
Group administrator
Mon 11 Jan 2010 06:14:28 PM UTC, comment #1: 

There is one other possibility which is much more easy to implement: we could just add a define EXTERNAL_HEAP, that must be a void-pointer to the heap address. Since ram_heap is only used when initializing 'ram'.

See attached patch. Like always, I'll check it in these days if noone objects...

(file #19460)

Simon Goldschmidt <goldsimon>
Group administrator
Fri 30 Oct 2009 04:20:05 PM UTC, original submission:  

This is my suggestion how to move the heap with GCC.
It does not affect the current code if a section is not defined.


This should go in mem.c (above the heap declaration)

/** Defining this allows the heap to be placed in a user-defined
linker section (e.g. EXTERNAL RAM) */

#ifndef HEAP_SECT_PRE
#define HEAP_SECT_PRE
#endif /* HEAP_SECT_PRE */

/** Defining this allows the heap to be placed in a user-defined
linker section (e.g. EXTERNAL RAM) */

#ifndef HEAP_SECT_POST
#define HEAP_SECT_POST
#endif /* HEAP_SECT_POST */

mem.c, line 175: change
static u8_t ram_heap[MEM_SIZE_ALIGNED + (2*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT];
to
static HEAP_SECT_PRE u8_t ram_heap[MEM_SIZE_ALIGNED + (2*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT] HEAP_SECT_POST;

We may add a note how to define the section
/** Place this in cc.h to tell GCC to place the heap in section .externalram:
#define HEAP_SECT_PRE(/POST) attribute ((section (".externalram")))
*/

Alternatively, the two #ifndef-#define-#endifs can be placed in opt.h. Then the atribute would go to lwipopts.h

Unfortunately, this is not easily compatible with #pragma-s

Iordan Neshev <iordan_neshev>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #19460:  mem.c_6966.patch added by goldsimon (1KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by billauerbach (Posted a comment)
  • -email is unavailable- added by goldsimon (Updated the item)
  • -email is unavailable- added by iordan_neshev (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-01-13 goldsimon StatusNone Done
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
    2010-01-11 goldsimon Attached File- Added mem.c_6966.patch, #19460

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code