Rahul Dahiya / Mbed OS STM32F7 Ethernet
Committer:
rahul_dahiya
Date:
Wed Jan 15 15:57:15 2020 +0530
Revision:
0:fb8047b156bb
STM32F7 LWIP

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rahul_dahiya 0:fb8047b156bb 1
rahul_dahiya 0:fb8047b156bb 2 /** \addtogroup platform */
rahul_dahiya 0:fb8047b156bb 3 /** @{*/
rahul_dahiya 0:fb8047b156bb 4
rahul_dahiya 0:fb8047b156bb 5 /* mbed Microcontroller Library
rahul_dahiya 0:fb8047b156bb 6 * Copyright (c) 2006-2016 ARM Limited
rahul_dahiya 0:fb8047b156bb 7 *
rahul_dahiya 0:fb8047b156bb 8 * Licensed under the Apache License, Version 2.0 (the "License");
rahul_dahiya 0:fb8047b156bb 9 * you may not use this file except in compliance with the License.
rahul_dahiya 0:fb8047b156bb 10 * You may obtain a copy of the License at
rahul_dahiya 0:fb8047b156bb 11 *
rahul_dahiya 0:fb8047b156bb 12 * http://www.apache.org/licenses/LICENSE-2.0
rahul_dahiya 0:fb8047b156bb 13 *
rahul_dahiya 0:fb8047b156bb 14 * Unless required by applicable law or agreed to in writing, software
rahul_dahiya 0:fb8047b156bb 15 * distributed under the License is distributed on an "AS IS" BASIS,
rahul_dahiya 0:fb8047b156bb 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rahul_dahiya 0:fb8047b156bb 17 * See the License for the specific language governing permissions and
rahul_dahiya 0:fb8047b156bb 18 * limitations under the License.
rahul_dahiya 0:fb8047b156bb 19 */
rahul_dahiya 0:fb8047b156bb 20
rahul_dahiya 0:fb8047b156bb 21 #ifndef __MBED_MEM_TRACE_H__
rahul_dahiya 0:fb8047b156bb 22 #define __MBED_MEM_TRACE_H__
rahul_dahiya 0:fb8047b156bb 23
rahul_dahiya 0:fb8047b156bb 24 #ifdef __cplusplus
rahul_dahiya 0:fb8047b156bb 25 extern "C" {
rahul_dahiya 0:fb8047b156bb 26 #endif
rahul_dahiya 0:fb8047b156bb 27
rahul_dahiya 0:fb8047b156bb 28 #include <stdint.h>
rahul_dahiya 0:fb8047b156bb 29 #include <stddef.h>
rahul_dahiya 0:fb8047b156bb 30
rahul_dahiya 0:fb8047b156bb 31 /* Operation types for tracer */
rahul_dahiya 0:fb8047b156bb 32 enum {
rahul_dahiya 0:fb8047b156bb 33 MBED_MEM_TRACE_MALLOC,
rahul_dahiya 0:fb8047b156bb 34 MBED_MEM_TRACE_REALLOC,
rahul_dahiya 0:fb8047b156bb 35 MBED_MEM_TRACE_CALLOC,
rahul_dahiya 0:fb8047b156bb 36 MBED_MEM_TRACE_FREE
rahul_dahiya 0:fb8047b156bb 37 };
rahul_dahiya 0:fb8047b156bb 38
rahul_dahiya 0:fb8047b156bb 39 /**
rahul_dahiya 0:fb8047b156bb 40 * \defgroup platform_mem_trace mem_trace functions
rahul_dahiya 0:fb8047b156bb 41 * @{
rahul_dahiya 0:fb8047b156bb 42 */
rahul_dahiya 0:fb8047b156bb 43
rahul_dahiya 0:fb8047b156bb 44 /* Prefix for the output of the default tracer */
rahul_dahiya 0:fb8047b156bb 45 #define MBED_MEM_DEFAULT_TRACER_PREFIX "#"
rahul_dahiya 0:fb8047b156bb 46
rahul_dahiya 0:fb8047b156bb 47 /**
rahul_dahiya 0:fb8047b156bb 48 * Type of the callback used by the memory tracer. This callback is called when a memory
rahul_dahiya 0:fb8047b156bb 49 * allocation operation (malloc, realloc, calloc, free) is called and tracing is enabled
rahul_dahiya 0:fb8047b156bb 50 * for that memory allocation function.
rahul_dahiya 0:fb8047b156bb 51 *
rahul_dahiya 0:fb8047b156bb 52 * @param op the ID of the operation (MBED_MEM_TRACE_MALLOC, MBED_MEM_TRACE_REALLOC,
rahul_dahiya 0:fb8047b156bb 53 * MBED_MEM_TRACE_CALLOC or MBED_MEM_TRACE_FREE).
rahul_dahiya 0:fb8047b156bb 54 * @param res the result that the memory operation returned (NULL for 'free').
rahul_dahiya 0:fb8047b156bb 55 * @param caller the caller of the memory operation. Note that the value of 'caller' might be
rahul_dahiya 0:fb8047b156bb 56 * unreliable.
rahul_dahiya 0:fb8047b156bb 57 *
rahul_dahiya 0:fb8047b156bb 58 * The rest of the parameters passed 'mbed_mem_trace_cb_t' are the same as the memory operations
rahul_dahiya 0:fb8047b156bb 59 * that triggered its call (see 'man malloc' for details):
rahul_dahiya 0:fb8047b156bb 60 *
rahul_dahiya 0:fb8047b156bb 61 * - for malloc: cb(MBED_MEM_TRACE_MALLOC, res, caller, size).
rahul_dahiya 0:fb8047b156bb 62 * - for realloc: cb(MBED_MEM_TRACE_REALLOC, res, caller, ptr, size).
rahul_dahiya 0:fb8047b156bb 63 * - for calloc: cb(MBED_MEM_TRACE_CALLOC, res, caller, nmemb, size).
rahul_dahiya 0:fb8047b156bb 64 * - for free: cb(MBED_MEM_TRACE_FREE, NULL, caller, ptr).
rahul_dahiya 0:fb8047b156bb 65 */
rahul_dahiya 0:fb8047b156bb 66 typedef void (*mbed_mem_trace_cb_t)(uint8_t op, void *res, void* caller, ...);
rahul_dahiya 0:fb8047b156bb 67
rahul_dahiya 0:fb8047b156bb 68 /**
rahul_dahiya 0:fb8047b156bb 69 * Set the callback used by the memory tracer (use NULL for disable tracing).
rahul_dahiya 0:fb8047b156bb 70 *
rahul_dahiya 0:fb8047b156bb 71 * @param cb the callback to call on each memory operation.
rahul_dahiya 0:fb8047b156bb 72 */
rahul_dahiya 0:fb8047b156bb 73 void mbed_mem_trace_set_callback(mbed_mem_trace_cb_t cb);
rahul_dahiya 0:fb8047b156bb 74
rahul_dahiya 0:fb8047b156bb 75 /**
rahul_dahiya 0:fb8047b156bb 76 * Trace a call to 'malloc'.
rahul_dahiya 0:fb8047b156bb 77 * @param res the result of running 'malloc'.
rahul_dahiya 0:fb8047b156bb 78 * @param size the 'size' argument given to 'malloc'.
rahul_dahiya 0:fb8047b156bb 79 * @param caller the caller of the memory operation.
rahul_dahiya 0:fb8047b156bb 80 * @return 'res' (the first argument).
rahul_dahiya 0:fb8047b156bb 81 */
rahul_dahiya 0:fb8047b156bb 82 void *mbed_mem_trace_malloc(void *res, size_t size, void *caller);
rahul_dahiya 0:fb8047b156bb 83
rahul_dahiya 0:fb8047b156bb 84 /**
rahul_dahiya 0:fb8047b156bb 85 * Trace a call to 'realloc'.
rahul_dahiya 0:fb8047b156bb 86 * @param res the result of running 'realloc'.
rahul_dahiya 0:fb8047b156bb 87 * @param ptr the 'ptr' argument given to 'realloc'.
rahul_dahiya 0:fb8047b156bb 88 * @param size the 'size' argument given to 'realloc'.
rahul_dahiya 0:fb8047b156bb 89 * @param caller the caller of the memory operation.
rahul_dahiya 0:fb8047b156bb 90 * @return 'res' (the first argument).
rahul_dahiya 0:fb8047b156bb 91 */
rahul_dahiya 0:fb8047b156bb 92 void *mbed_mem_trace_realloc(void *res, void *ptr, size_t size, void *caller);
rahul_dahiya 0:fb8047b156bb 93
rahul_dahiya 0:fb8047b156bb 94 /**
rahul_dahiya 0:fb8047b156bb 95 * Trace a call to 'calloc'.
rahul_dahiya 0:fb8047b156bb 96 * @param res the result of running 'calloc'.
rahul_dahiya 0:fb8047b156bb 97 * @param num the 'nmemb' argument given to 'calloc'.
rahul_dahiya 0:fb8047b156bb 98 * @param size the 'size' argument given to 'calloc'.
rahul_dahiya 0:fb8047b156bb 99 * @param caller the caller of the memory operation.
rahul_dahiya 0:fb8047b156bb 100 * @return 'res' (the first argument).
rahul_dahiya 0:fb8047b156bb 101 */
rahul_dahiya 0:fb8047b156bb 102 void *mbed_mem_trace_calloc(void *res, size_t num, size_t size, void *caller);
rahul_dahiya 0:fb8047b156bb 103
rahul_dahiya 0:fb8047b156bb 104 /**
rahul_dahiya 0:fb8047b156bb 105 * Trace a call to 'free'.
rahul_dahiya 0:fb8047b156bb 106 * @param ptr the 'ptr' argument given to 'free'.
rahul_dahiya 0:fb8047b156bb 107 * @param caller the caller of the memory operation.
rahul_dahiya 0:fb8047b156bb 108 */
rahul_dahiya 0:fb8047b156bb 109 void mbed_mem_trace_free(void *ptr, void *caller);
rahul_dahiya 0:fb8047b156bb 110
rahul_dahiya 0:fb8047b156bb 111 /**
rahul_dahiya 0:fb8047b156bb 112 * Default memory trace callback. DO NOT CALL DIRECTLY. It is meant to be used
rahul_dahiya 0:fb8047b156bb 113 * as the second argument of 'mbed_mem_trace_setup'.
rahul_dahiya 0:fb8047b156bb 114 *
rahul_dahiya 0:fb8047b156bb 115 * The default callback outputs trace data using 'printf', in a format that's
rahul_dahiya 0:fb8047b156bb 116 * easily parsable by an external tool. For each memory operation, the callback
rahul_dahiya 0:fb8047b156bb 117 * outputs a line that begins with "#<op>:<0xresult>;<0xcaller>-":
rahul_dahiya 0:fb8047b156bb 118 *
rahul_dahiya 0:fb8047b156bb 119 * @param op identifies the memory operation ('m' for 'malloc', 'r' for 'realloc',
rahul_dahiya 0:fb8047b156bb 120 * 'c' for 'calloc' and 'f' for 'free').
rahul_dahiya 0:fb8047b156bb 121 * @param res (base 16) is the result of the memor operation. This is always NULL
rahul_dahiya 0:fb8047b156bb 122 * for 'free', since 'free' doesn't return anything.
rahul_dahiya 0:fb8047b156bb 123 * @param caller (base 16) is the caller of the memory operation. Note that the value
rahul_dahiya 0:fb8047b156bb 124 * of 'caller' might be unreliable.
rahul_dahiya 0:fb8047b156bb 125 *
rahul_dahiya 0:fb8047b156bb 126 * The rest of the output depends on the operation being traced:
rahul_dahiya 0:fb8047b156bb 127 *
rahul_dahiya 0:fb8047b156bb 128 * - for 'malloc': 'size', where 'size' is the original argument to 'malloc'.
rahul_dahiya 0:fb8047b156bb 129 * - for 'realloc': '0xptr;size', where 'ptr' (base 16) and 'size' are the original arguments to 'realloc'.
rahul_dahiya 0:fb8047b156bb 130 * - for 'calloc': 'nmemb;size', where 'nmemb' and 'size' are the original arguments to 'calloc'.
rahul_dahiya 0:fb8047b156bb 131 * - for 'free': '0xptr', where 'ptr' (base 16) is the original argument to 'free'.
rahul_dahiya 0:fb8047b156bb 132 *
rahul_dahiya 0:fb8047b156bb 133 * Examples:
rahul_dahiya 0:fb8047b156bb 134 *
rahul_dahiya 0:fb8047b156bb 135 * - "#m:0x20003240;0x600d-50" encodes a 'malloc' that returned 0x20003240, was called
rahul_dahiya 0:fb8047b156bb 136 * by the instruction at 0x600D with a the 'size' argument equal to 50.
rahul_dahiya 0:fb8047b156bb 137 * - "#f:0x0;0x602f-0x20003240" encodes a 'free' that was called by the instruction at
rahul_dahiya 0:fb8047b156bb 138 * 0x602f with the 'ptr' argument equal to 0x20003240.
rahul_dahiya 0:fb8047b156bb 139 */
rahul_dahiya 0:fb8047b156bb 140 void mbed_mem_trace_default_callback(uint8_t op, void *res, void *caller, ...);
rahul_dahiya 0:fb8047b156bb 141
rahul_dahiya 0:fb8047b156bb 142 /** @}*/
rahul_dahiya 0:fb8047b156bb 143
rahul_dahiya 0:fb8047b156bb 144 #ifdef __cplusplus
rahul_dahiya 0:fb8047b156bb 145 }
rahul_dahiya 0:fb8047b156bb 146 #endif
rahul_dahiya 0:fb8047b156bb 147
rahul_dahiya 0:fb8047b156bb 148 #endif// #ifndef __MBED_MEM_TRACE_H__
rahul_dahiya 0:fb8047b156bb 149
rahul_dahiya 0:fb8047b156bb 150
rahul_dahiya 0:fb8047b156bb 151 /** @}*/