Skip to content

Commit a528da0

Browse files
authored
Merge pull request #303 from sg-/master
LPC1768 IAR support for lwip
2 parents 963892c + d9ead4d commit a528da0

File tree

4 files changed

+50
-31
lines changed

4 files changed

+50
-31
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ MANIFEST
88

99
# Private settings
1010
private_settings.py
11+
test_spec.json
12+
projectfiles/
1113

1214
# Default Build Directory
1315
build/
@@ -74,4 +76,3 @@ cscope.*
7476
# vim swap files
7577
*.swp
7678
*~
77-

mbed.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/mbedmicro/mbed/#52e93aebd083b679a8fe7b0e47039f138fa8c224
1+
https://github.com/mbedmicro/mbed/#df0c855df97688074545693f66bcca5cf9f42111

net/LWIPInterface/lwip/core/mem.c

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

195201
/** the heap. we need one struct mem at the end and some room for alignment */
202+
#if defined (__ICCARM__)
203+
#pragma location = ".ethusbram"
204+
#endif
196205
u8_t ram_heap[MEM_SIZE_ALIGNED + (2*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT] ETHMEM_SECTION;
197206
#define LWIP_RAM_HEAP_POINTER ram_heap
198207
#endif /* LWIP_RAM_HEAP_POINTER */
@@ -483,7 +492,7 @@ mem_trim(void *rmem, mem_size_t newsize)
483492
/* else {
484493
next struct mem is used but size between mem and mem2 is not big enough
485494
to create another struct mem
486-
-> don't do anyhting.
495+
-> don't do anyhting.
487496
-> the remaining space stays unused since it is too small
488497
} */
489498
#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT

net/LWIPInterface/lwip/core/memp.c

Lines changed: 35 additions & 26 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,34 @@ 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")))
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
171177
#else
172-
# define ETHMEM_SECTION
178+
#define ETHMEM_SECTION
173179
#endif
174180

175181
/** This is the actual memory used by the pools (all pools in one big block). */
176-
static u8_t memp_memory[MEM_ALIGNMENT - 1
182+
#if defined (__ICCARM__)
183+
#pragma location = ".ethusbram"
184+
#endif
185+
static u8_t memp_memory[MEM_ALIGNMENT - 1
177186
#define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) )
178187
#include "lwip/memp_std.h"
179188
] ETHMEM_SECTION;
@@ -336,7 +345,7 @@ memp_overflow_init(void)
336345

337346
/**
338347
* Initialize this module.
339-
*
348+
*
340349
* Carves out memp_memory into linked lists for each pool-type.
341350
*/
342351
void
@@ -399,7 +408,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
399408
{
400409
struct memp *memp;
401410
SYS_ARCH_DECL_PROTECT(old_level);
402-
411+
403412
LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;);
404413

405414
SYS_ARCH_PROTECT(old_level);
@@ -408,7 +417,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
408417
#endif /* MEMP_OVERFLOW_CHECK >= 2 */
409418

410419
memp = memp_tab[type];
411-
420+
412421
if (memp != NULL) {
413422
memp_tab[type] = memp->next;
414423
#if MEMP_OVERFLOW_CHECK
@@ -460,9 +469,9 @@ memp_free(memp_t type, void *mem)
460469
#endif /* MEMP_OVERFLOW_CHECK >= 2 */
461470
#endif /* MEMP_OVERFLOW_CHECK */
462471

463-
MEMP_STATS_DEC(used, type);
464-
465-
memp->next = memp_tab[type];
472+
MEMP_STATS_DEC(used, type);
473+
474+
memp->next = memp_tab[type];
466475
memp_tab[type] = memp;
467476

468477
#if MEMP_SANITY_CHECK

0 commit comments

Comments
 (0)