mbed client on ethernet with LWIP

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by sandbox

Committer:
mbedAustin
Date:
Thu Jun 09 17:08:36 2016 +0000
Revision:
11:cada08fc8a70
Commit for public Consumption

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 11:cada08fc8a70 1 /*
mbedAustin 11:cada08fc8a70 2 * Copyright (c) 2014-2015 ARM Limited. All rights reserved.
mbedAustin 11:cada08fc8a70 3 * SPDX-License-Identifier: Apache-2.0
mbedAustin 11:cada08fc8a70 4 * Licensed under the Apache License, Version 2.0 (the License); you may
mbedAustin 11:cada08fc8a70 5 * not use this file except in compliance with the License.
mbedAustin 11:cada08fc8a70 6 * You may obtain a copy of the License at
mbedAustin 11:cada08fc8a70 7 *
mbedAustin 11:cada08fc8a70 8 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 11:cada08fc8a70 9 *
mbedAustin 11:cada08fc8a70 10 * Unless required by applicable law or agreed to in writing, software
mbedAustin 11:cada08fc8a70 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
mbedAustin 11:cada08fc8a70 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 11:cada08fc8a70 13 * See the License for the specific language governing permissions and
mbedAustin 11:cada08fc8a70 14 * limitations under the License.
mbedAustin 11:cada08fc8a70 15 */
mbedAustin 11:cada08fc8a70 16
mbedAustin 11:cada08fc8a70 17
mbedAustin 11:cada08fc8a70 18 /**
mbedAustin 11:cada08fc8a70 19 * \file nsdynmemLIB.h
mbedAustin 11:cada08fc8a70 20 * \brief Dynamical Memory API for library model
mbedAustin 11:cada08fc8a70 21 *
mbedAustin 11:cada08fc8a70 22 */
mbedAustin 11:cada08fc8a70 23 #ifndef NSDYNMEMLIB_H_
mbedAustin 11:cada08fc8a70 24 #define NSDYNMEMLIB_H_
mbedAustin 11:cada08fc8a70 25 #ifdef __cplusplus
mbedAustin 11:cada08fc8a70 26 extern "C" {
mbedAustin 11:cada08fc8a70 27 #endif
mbedAustin 11:cada08fc8a70 28
mbedAustin 11:cada08fc8a70 29 #include "ns_types.h"
mbedAustin 11:cada08fc8a70 30
mbedAustin 11:cada08fc8a70 31 /*!
mbedAustin 11:cada08fc8a70 32 * \enum heap_fail_t
mbedAustin 11:cada08fc8a70 33 * \brief Dynamically heap system failure call back event types.
mbedAustin 11:cada08fc8a70 34 */
mbedAustin 11:cada08fc8a70 35 typedef enum {
mbedAustin 11:cada08fc8a70 36 NS_DYN_MEM_NULL_FREE, /**< ns_dyn_mem_free(), NULL pointer free [obsolete - no longer faulted] */
mbedAustin 11:cada08fc8a70 37 NS_DYN_MEM_DOUBLE_FREE, /**< ns_dyn_mem_free(), Possible double pointer free */
mbedAustin 11:cada08fc8a70 38 NS_DYN_MEM_ALLOCATE_SIZE_NOT_VALID, /**< Allocate size is 0 or smaller or size is bigger than max heap size */
mbedAustin 11:cada08fc8a70 39 NS_DYN_MEM_POINTER_NOT_VALID, /**< ns_dyn_mem_free(), try to free pointer which not at heap sector */
mbedAustin 11:cada08fc8a70 40 NS_DYN_MEM_HEAP_SECTOR_CORRUPTED, /**< Heap system detect sector corruption */
mbedAustin 11:cada08fc8a70 41 NS_DYN_MEM_HEAP_SECTOR_UNITIALIZED /**< ns_dyn_mem_free(), ns_dyn_mem_temporary_alloc() or ns_dyn_mem_alloc() called before ns_dyn_mem_init() */
mbedAustin 11:cada08fc8a70 42 } heap_fail_t;
mbedAustin 11:cada08fc8a70 43
mbedAustin 11:cada08fc8a70 44 /**
mbedAustin 11:cada08fc8a70 45 * /struct mem_stat_t
mbedAustin 11:cada08fc8a70 46 * /brief Struct for Memory stats Buffer structure
mbedAustin 11:cada08fc8a70 47 */
mbedAustin 11:cada08fc8a70 48 typedef struct mem_stat_t {
mbedAustin 11:cada08fc8a70 49 /*Heap stats*/
mbedAustin 11:cada08fc8a70 50 int16_t heap_sector_size; /**< Heap total Sector len. */
mbedAustin 11:cada08fc8a70 51 int16_t heap_sector_alloc_cnt; /**< Reserved Heap sector cnt. */
mbedAustin 11:cada08fc8a70 52 int16_t heap_sector_allocated_bytes; /**< Reserved Heap data in bytes. */
mbedAustin 11:cada08fc8a70 53 int16_t heap_sector_allocated_bytes_max; /**< Reserved Heap data in bytes max value. */
mbedAustin 11:cada08fc8a70 54 uint32_t heap_alloc_total_bytes; /**< Total Heap allocated bytes. */
mbedAustin 11:cada08fc8a70 55 uint32_t heap_alloc_fail_cnt; /**< Counter for Heap allocation fail. */
mbedAustin 11:cada08fc8a70 56 } mem_stat_t;
mbedAustin 11:cada08fc8a70 57
mbedAustin 11:cada08fc8a70 58 /**
mbedAustin 11:cada08fc8a70 59 * \brief Init and set Dynamical heap pointer and length.
mbedAustin 11:cada08fc8a70 60 *
mbedAustin 11:cada08fc8a70 61 * \param heap_ptr Pointer to dynamically heap buffer
mbedAustin 11:cada08fc8a70 62 * \param heap_size size of the heap buffer
mbedAustin 11:cada08fc8a70 63 * \return None
mbedAustin 11:cada08fc8a70 64 */
mbedAustin 11:cada08fc8a70 65 extern void ns_dyn_mem_init(uint8_t *heap, uint16_t h_size, void (*passed_fptr)(heap_fail_t), mem_stat_t *info_ptr);
mbedAustin 11:cada08fc8a70 66
mbedAustin 11:cada08fc8a70 67
mbedAustin 11:cada08fc8a70 68 /**
mbedAustin 11:cada08fc8a70 69 * \brief Free allocated memory.
mbedAustin 11:cada08fc8a70 70 *
mbedAustin 11:cada08fc8a70 71 * \param heap_ptr Pointer to allocated memory
mbedAustin 11:cada08fc8a70 72 *
mbedAustin 11:cada08fc8a70 73 * \return 0, Free OK
mbedAustin 11:cada08fc8a70 74 * \return <0, Free Fail
mbedAustin 11:cada08fc8a70 75 */
mbedAustin 11:cada08fc8a70 76 extern void ns_dyn_mem_free(void *heap_ptr);
mbedAustin 11:cada08fc8a70 77 /**
mbedAustin 11:cada08fc8a70 78 * \brief Allocate temporary data.
mbedAustin 11:cada08fc8a70 79 *
mbedAustin 11:cada08fc8a70 80 * Space allocate started from beginning of the heap sector
mbedAustin 11:cada08fc8a70 81 *
mbedAustin 11:cada08fc8a70 82 * \param alloc_size Allocated data size
mbedAustin 11:cada08fc8a70 83 *
mbedAustin 11:cada08fc8a70 84 * \return 0, Allocate Fail
mbedAustin 11:cada08fc8a70 85 * \return >0, Pointer to allocated data sector.
mbedAustin 11:cada08fc8a70 86 */
mbedAustin 11:cada08fc8a70 87 extern void *ns_dyn_mem_temporary_alloc(int16_t alloc_size);
mbedAustin 11:cada08fc8a70 88 /**
mbedAustin 11:cada08fc8a70 89 * \brief Allocate long period data.
mbedAustin 11:cada08fc8a70 90 *
mbedAustin 11:cada08fc8a70 91 * Space allocate started from end of the heap sector
mbedAustin 11:cada08fc8a70 92 *
mbedAustin 11:cada08fc8a70 93 * \param alloc_size Allocated data size
mbedAustin 11:cada08fc8a70 94 *
mbedAustin 11:cada08fc8a70 95 * \return 0, Allocate Fail
mbedAustin 11:cada08fc8a70 96 * \return >0, Pointer to allocated data sector.
mbedAustin 11:cada08fc8a70 97 */
mbedAustin 11:cada08fc8a70 98 extern void *ns_dyn_mem_alloc(int16_t alloc_size);
mbedAustin 11:cada08fc8a70 99 #ifdef __cplusplus
mbedAustin 11:cada08fc8a70 100 }
mbedAustin 11:cada08fc8a70 101 #endif
mbedAustin 11:cada08fc8a70 102 #endif /* NSDYNMEMLIB_H_ */
mbedAustin 11:cada08fc8a70 103