Merge pull request #303 from sg-/master

LPC1768 IAR support for lwip
Sam Grove 2016-06-12 13:57:11 +01:00 committed by GitHub
commit a528da04e5
4 changed files with 50 additions and 31 deletions

3
.gitignore vendored
View File

@ -8,6 +8,8 @@ MANIFEST
# Private settings # Private settings
private_settings.py private_settings.py
test_spec.json
projectfiles/
# Default Build Directory # Default Build Directory
build/ build/
@ -74,4 +76,3 @@ cscope.*
# vim swap files # vim swap files
*.swp *.swp
*~ *~

View File

@ -1 +1 @@
https://github.com/mbedmicro/mbed/#52e93aebd083b679a8fe7b0e47039f138fa8c224 https://github.com/mbedmicro/mbed/#df0c855df97688074545693f66bcca5cf9f42111

View File

@ -187,12 +187,21 @@ struct mem {
# define ETHMEM_SECTION __attribute__((section("AHBSRAM1"),aligned)) # define ETHMEM_SECTION __attribute__((section("AHBSRAM1"),aligned))
# endif # endif
#elif defined(TARGET_LPC1768) #elif defined(TARGET_LPC1768)
# define ETHMEM_SECTION __attribute((section("AHBSRAM0"))) # if defined (__ICCARM__)
# define ETHMEM_SECTION
# elif defined(TOOLCHAIN_GCC_CR) || defined(TOOLCHAIN_GCC_ARM)
# define ETHMEM_SECTION __attribute__((section(".data.$RamPeriph32")))
# else
# define ETHMEM_SECTION __attribute__((section("AHBSRAM0"),aligned))
# endif
#else #else
# define ETHMEM_SECTION #define ETHMEM_SECTION
#endif #endif
/** the heap. we need one struct mem at the end and some room for alignment */ /** the heap. we need one struct mem at the end and some room for alignment */
#if defined (__ICCARM__)
#pragma location = ".ethusbram"
#endif
u8_t ram_heap[MEM_SIZE_ALIGNED + (2*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT] ETHMEM_SECTION; u8_t ram_heap[MEM_SIZE_ALIGNED + (2*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT] ETHMEM_SECTION;
#define LWIP_RAM_HEAP_POINTER ram_heap #define LWIP_RAM_HEAP_POINTER ram_heap
#endif /* LWIP_RAM_HEAP_POINTER */ #endif /* LWIP_RAM_HEAP_POINTER */
@ -483,7 +492,7 @@ mem_trim(void *rmem, mem_size_t newsize)
/* else { /* else {
next struct mem is used but size between mem and mem2 is not big enough next struct mem is used but size between mem and mem2 is not big enough
to create another struct mem to create another struct mem
-> don't do anyhting. -> don't do anyhting.
-> the remaining space stays unused since it is too small -> the remaining space stays unused since it is too small
} */ } */
#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT

View File

@ -8,9 +8,9 @@
/* /*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science. * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
@ -19,21 +19,21 @@
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
* *
* This file is part of the lwIP TCP/IP stack. * This file is part of the lwIP TCP/IP stack.
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
*/ */
@ -155,25 +155,34 @@ static const char *memp_desc[MEMP_MAX] = {
* extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_UDP_PCB_base[]; * extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_UDP_PCB_base[];
*/ */
#define LWIP_MEMPOOL(name,num,size,desc) u8_t memp_memory_ ## name ## _base \ #define LWIP_MEMPOOL(name,num,size,desc) u8_t memp_memory_ ## name ## _base \
[((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))];
#include "lwip/memp_std.h" #include "lwip/memp_std.h"
/** This array holds the base of each memory pool. */ /** This array holds the base of each memory pool. */
static u8_t *const memp_bases[] = { static u8_t *const memp_bases[] = {
#define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name ## _base, #define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name ## _base,
#include "lwip/memp_std.h" #include "lwip/memp_std.h"
}; };
#else /* MEMP_SEPARATE_POOLS */ #else /* MEMP_SEPARATE_POOLS */
#if defined(TARGET_LPC1768) #if defined(TARGET_LPC1768)
# define ETHMEM_SECTION __attribute((section("AHBSRAM1"))) # if defined (__ICCARM__)
# define ETHMEM_SECTION
# elif defined(TOOLCHAIN_GCC_CR)
# define ETHMEM_SECTION __attribute__((section(".data.$RamPeriph32")))
# else
# define ETHMEM_SECTION __attribute__((section("AHBSRAM1"),aligned))
# endif
#else #else
# define ETHMEM_SECTION #define ETHMEM_SECTION
#endif #endif
/** This is the actual memory used by the pools (all pools in one big block). */ /** This is the actual memory used by the pools (all pools in one big block). */
static u8_t memp_memory[MEM_ALIGNMENT - 1 #if defined (__ICCARM__)
#pragma location = ".ethusbram"
#endif
static u8_t memp_memory[MEM_ALIGNMENT - 1
#define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) ) #define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) )
#include "lwip/memp_std.h" #include "lwip/memp_std.h"
] ETHMEM_SECTION; ] ETHMEM_SECTION;
@ -336,7 +345,7 @@ memp_overflow_init(void)
/** /**
* Initialize this module. * Initialize this module.
* *
* Carves out memp_memory into linked lists for each pool-type. * Carves out memp_memory into linked lists for each pool-type.
*/ */
void void
@ -399,7 +408,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
{ {
struct memp *memp; struct memp *memp;
SYS_ARCH_DECL_PROTECT(old_level); SYS_ARCH_DECL_PROTECT(old_level);
LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;); LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;);
SYS_ARCH_PROTECT(old_level); SYS_ARCH_PROTECT(old_level);
@ -408,7 +417,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
#endif /* MEMP_OVERFLOW_CHECK >= 2 */ #endif /* MEMP_OVERFLOW_CHECK >= 2 */
memp = memp_tab[type]; memp = memp_tab[type];
if (memp != NULL) { if (memp != NULL) {
memp_tab[type] = memp->next; memp_tab[type] = memp->next;
#if MEMP_OVERFLOW_CHECK #if MEMP_OVERFLOW_CHECK
@ -460,9 +469,9 @@ memp_free(memp_t type, void *mem)
#endif /* MEMP_OVERFLOW_CHECK >= 2 */ #endif /* MEMP_OVERFLOW_CHECK >= 2 */
#endif /* MEMP_OVERFLOW_CHECK */ #endif /* MEMP_OVERFLOW_CHECK */
MEMP_STATS_DEC(used, type); MEMP_STATS_DEC(used, type);
memp->next = memp_tab[type]; memp->next = memp_tab[type];
memp_tab[type] = memp; memp_tab[type] = memp;
#if MEMP_SANITY_CHECK #if MEMP_SANITY_CHECK