Skip to content

Commit 8f6ae7c

Browse files
committed
add IAR placement for LPC1768 and lwip buffers
1 parent d381918 commit 8f6ae7c

File tree

2 files changed

+45
-31
lines changed

2 files changed

+45
-31
lines changed

net/LWIPInterface/lwip/core/mem.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,19 @@ struct mem {
187187
# define ETHMEM_SECTION __attribute__((section("AHBSRAM1"),aligned))
188188
# endif
189189
#elif defined(TARGET_LPC1768)
190-
# define ETHMEM_SECTION __attribute((section("AHBSRAM0")))
191-
#else
192-
# define ETHMEM_SECTION
190+
# if defined (__ICCARM__)
191+
# define ETHMEM_SECTION
192+
# elif defined(TOOLCHAIN_GCC_CR)
193+
# define ETHMEM_SECTION __attribute__((section(".data.$RamPeriph32")))
194+
# else
195+
# define ETHMEM_SECTION __attribute__((section("AHBSRAM0"),aligned))
196+
# endif
193197
#endif
194198

195199
/** the heap. we need one struct mem at the end and some room for alignment */
200+
#if defined (__ICCARM__)
201+
#pragma location = ".ethusbram"
202+
#endif
196203
u8_t ram_heap[MEM_SIZE_ALIGNED + (2*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT] ETHMEM_SECTION;
197204
#define LWIP_RAM_HEAP_POINTER ram_heap
198205
#endif /* LWIP_RAM_HEAP_POINTER */
@@ -483,7 +490,7 @@ mem_trim(void *rmem, mem_size_t newsize)
483490
/* else {
484491
next struct mem is used but size between mem and mem2 is not big enough
485492
to create another struct mem
486-
-> don't do anyhting.
493+
-> don't do anyhting.
487494
-> the remaining space stays unused since it is too small
488495
} */
489496
#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT

net/LWIPInterface/lwip/core/memp.c

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
/*
1010
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
11-
* All rights reserved.
12-
*
13-
* Redistribution and use in source and binary forms, with or without modification,
11+
* All rights reserved.
12+
*
13+
* Redistribution and use in source and binary forms, with or without modification,
1414
* are permitted provided that the following conditions are met:
1515
*
1616
* 1. Redistributions of source code must retain the above copyright notice,
@@ -19,21 +19,21 @@
1919
* this list of conditions and the following disclaimer in the documentation
2020
* and/or other materials provided with the distribution.
2121
* 3. The name of the author may not be used to endorse or promote products
22-
* derived from this software without specific prior written permission.
22+
* derived from this software without specific prior written permission.
2323
*
24-
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
25-
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26-
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
27-
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
29-
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32-
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
24+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
25+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
27+
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
29+
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32+
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
3333
* OF SUCH DAMAGE.
3434
*
3535
* This file is part of the lwIP TCP/IP stack.
36-
*
36+
*
3737
* Author: Adam Dunkels <[email protected]>
3838
*
3939
*/
@@ -155,25 +155,32 @@ static const char *memp_desc[MEMP_MAX] = {
155155
* extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_UDP_PCB_base[];
156156
*/
157157
#define LWIP_MEMPOOL(name,num,size,desc) u8_t memp_memory_ ## name ## _base \
158-
[((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))];
158+
[((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))];
159159
#include "lwip/memp_std.h"
160160

161161
/** This array holds the base of each memory pool. */
162-
static u8_t *const memp_bases[] = {
163-
#define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name ## _base,
162+
static u8_t *const memp_bases[] = {
163+
#define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name ## _base,
164164
#include "lwip/memp_std.h"
165165
};
166166

167167
#else /* MEMP_SEPARATE_POOLS */
168168

169169
#if defined(TARGET_LPC1768)
170-
# define ETHMEM_SECTION __attribute((section("AHBSRAM1")))
171-
#else
172-
# define ETHMEM_SECTION
170+
# if defined (__ICCARM__)
171+
# define ETHMEM_SECTION
172+
# elif defined(TOOLCHAIN_GCC_CR)
173+
# define ETHMEM_SECTION __attribute__((section(".data.$RamPeriph32")))
174+
# else
175+
# define ETHMEM_SECTION __attribute__((section("AHBSRAM1"),aligned))
176+
# endif
173177
#endif
174178

175179
/** This is the actual memory used by the pools (all pools in one big block). */
176-
static u8_t memp_memory[MEM_ALIGNMENT - 1
180+
#if defined (__ICCARM__)
181+
#pragma location = ".ethusbram"
182+
#endif
183+
static u8_t memp_memory[MEM_ALIGNMENT - 1
177184
#define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) )
178185
#include "lwip/memp_std.h"
179186
] ETHMEM_SECTION;
@@ -336,7 +343,7 @@ memp_overflow_init(void)
336343

337344
/**
338345
* Initialize this module.
339-
*
346+
*
340347
* Carves out memp_memory into linked lists for each pool-type.
341348
*/
342349
void
@@ -399,7 +406,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
399406
{
400407
struct memp *memp;
401408
SYS_ARCH_DECL_PROTECT(old_level);
402-
409+
403410
LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;);
404411

405412
SYS_ARCH_PROTECT(old_level);
@@ -408,7 +415,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
408415
#endif /* MEMP_OVERFLOW_CHECK >= 2 */
409416

410417
memp = memp_tab[type];
411-
418+
412419
if (memp != NULL) {
413420
memp_tab[type] = memp->next;
414421
#if MEMP_OVERFLOW_CHECK
@@ -460,9 +467,9 @@ memp_free(memp_t type, void *mem)
460467
#endif /* MEMP_OVERFLOW_CHECK >= 2 */
461468
#endif /* MEMP_OVERFLOW_CHECK */
462469

463-
MEMP_STATS_DEC(used, type);
464-
465-
memp->next = memp_tab[type];
470+
MEMP_STATS_DEC(used, type);
471+
472+
memp->next = memp_tab[type];
466473
memp_tab[type] = memp;
467474

468475
#if MEMP_SANITY_CHECK

0 commit comments

Comments
 (0)