BBR 1 Ebene

Committer:
borlanic
Date:
Mon May 14 11:29:06 2018 +0000
Revision:
0:fbdae7e6d805
BBR

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:fbdae7e6d805 1
borlanic 0:fbdae7e6d805 2 /** \addtogroup platform */
borlanic 0:fbdae7e6d805 3 /** @{*/
borlanic 0:fbdae7e6d805 4 /**
borlanic 0:fbdae7e6d805 5 * \defgroup platform_stats stats functions
borlanic 0:fbdae7e6d805 6 * @{
borlanic 0:fbdae7e6d805 7 */
borlanic 0:fbdae7e6d805 8 /* mbed Microcontroller Library
borlanic 0:fbdae7e6d805 9 * Copyright (c) 2016-2016 ARM Limited
borlanic 0:fbdae7e6d805 10 *
borlanic 0:fbdae7e6d805 11 * Licensed under the Apache License, Version 2.0 (the "License");
borlanic 0:fbdae7e6d805 12 * you may not use this file except in compliance with the License.
borlanic 0:fbdae7e6d805 13 * You may obtain a copy of the License at
borlanic 0:fbdae7e6d805 14 *
borlanic 0:fbdae7e6d805 15 * http://www.apache.org/licenses/LICENSE-2.0
borlanic 0:fbdae7e6d805 16 *
borlanic 0:fbdae7e6d805 17 * Unless required by applicable law or agreed to in writing, software
borlanic 0:fbdae7e6d805 18 * distributed under the License is distributed on an "AS IS" BASIS,
borlanic 0:fbdae7e6d805 19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
borlanic 0:fbdae7e6d805 20 * See the License for the specific language governing permissions and
borlanic 0:fbdae7e6d805 21 * limitations under the License.
borlanic 0:fbdae7e6d805 22 */
borlanic 0:fbdae7e6d805 23 #ifndef MBED_STATS_H
borlanic 0:fbdae7e6d805 24 #define MBED_STATS_H
borlanic 0:fbdae7e6d805 25 #include <stdint.h>
borlanic 0:fbdae7e6d805 26 #include <stddef.h>
borlanic 0:fbdae7e6d805 27
borlanic 0:fbdae7e6d805 28 #ifdef __cplusplus
borlanic 0:fbdae7e6d805 29 extern "C" {
borlanic 0:fbdae7e6d805 30 #endif
borlanic 0:fbdae7e6d805 31
borlanic 0:fbdae7e6d805 32 #ifdef MBED_ALL_STATS_ENABLED
borlanic 0:fbdae7e6d805 33 #define MBED_STACK_STATS_ENABLED 1
borlanic 0:fbdae7e6d805 34 #define MBED_HEAP_STATS_ENABLED 1
borlanic 0:fbdae7e6d805 35 #endif
borlanic 0:fbdae7e6d805 36
borlanic 0:fbdae7e6d805 37 /**
borlanic 0:fbdae7e6d805 38 * struct mbed_stats_heap_t definition
borlanic 0:fbdae7e6d805 39 */
borlanic 0:fbdae7e6d805 40 typedef struct {
borlanic 0:fbdae7e6d805 41 uint32_t current_size; /**< Bytes allocated currently. */
borlanic 0:fbdae7e6d805 42 uint32_t max_size; /**< Max bytes allocated at a given time. */
borlanic 0:fbdae7e6d805 43 uint32_t total_size; /**< Cumulative sum of bytes ever allocated. */
borlanic 0:fbdae7e6d805 44 uint32_t reserved_size; /**< Current number of bytes allocated for the heap. */
borlanic 0:fbdae7e6d805 45 uint32_t alloc_cnt; /**< Current number of allocations. */
borlanic 0:fbdae7e6d805 46 uint32_t alloc_fail_cnt; /**< Number of failed allocations. */
borlanic 0:fbdae7e6d805 47 } mbed_stats_heap_t;
borlanic 0:fbdae7e6d805 48
borlanic 0:fbdae7e6d805 49 /**
borlanic 0:fbdae7e6d805 50 * Fill the passed in heap stat structure with heap stats.
borlanic 0:fbdae7e6d805 51 *
borlanic 0:fbdae7e6d805 52 * @param stats A pointer to the mbed_stats_heap_t structure to fill
borlanic 0:fbdae7e6d805 53 */
borlanic 0:fbdae7e6d805 54 void mbed_stats_heap_get(mbed_stats_heap_t *stats);
borlanic 0:fbdae7e6d805 55
borlanic 0:fbdae7e6d805 56 /**
borlanic 0:fbdae7e6d805 57 * struct mbed_stats_stack_t definition
borlanic 0:fbdae7e6d805 58 */
borlanic 0:fbdae7e6d805 59 typedef struct {
borlanic 0:fbdae7e6d805 60 uint32_t thread_id; /**< Identifier for thread that owns the stack or 0 if multiple threads. */
borlanic 0:fbdae7e6d805 61 uint32_t max_size; /**< Maximum number of bytes used on the stack. */
borlanic 0:fbdae7e6d805 62 uint32_t reserved_size; /**< Current number of bytes allocated for the stack. */
borlanic 0:fbdae7e6d805 63 uint32_t stack_cnt; /**< Number of stacks stats accumulated in the structure. */
borlanic 0:fbdae7e6d805 64 } mbed_stats_stack_t;
borlanic 0:fbdae7e6d805 65
borlanic 0:fbdae7e6d805 66 /**
borlanic 0:fbdae7e6d805 67 * Fill the passed in structure with stack stats accumulated for all threads. The thread_id will be 0
borlanic 0:fbdae7e6d805 68 * and stack_cnt will represent number of threads.
borlanic 0:fbdae7e6d805 69 *
borlanic 0:fbdae7e6d805 70 * @param stats A pointer to the mbed_stats_stack_t structure to fill
borlanic 0:fbdae7e6d805 71 */
borlanic 0:fbdae7e6d805 72 void mbed_stats_stack_get(mbed_stats_stack_t *stats);
borlanic 0:fbdae7e6d805 73
borlanic 0:fbdae7e6d805 74 /**
borlanic 0:fbdae7e6d805 75 * Fill the passed array of stat structures with the stack stats for each available thread.
borlanic 0:fbdae7e6d805 76 *
borlanic 0:fbdae7e6d805 77 * @param stats A pointer to an array of mbed_stats_stack_t structures to fill
borlanic 0:fbdae7e6d805 78 * @param count The number of mbed_stats_stack_t structures in the provided array
borlanic 0:fbdae7e6d805 79 * @return The number of mbed_stats_stack_t structures that have been filled,
borlanic 0:fbdae7e6d805 80 * this is equal to the number of stacks on the system.
borlanic 0:fbdae7e6d805 81 */
borlanic 0:fbdae7e6d805 82 size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count);
borlanic 0:fbdae7e6d805 83
borlanic 0:fbdae7e6d805 84 #ifdef __cplusplus
borlanic 0:fbdae7e6d805 85 }
borlanic 0:fbdae7e6d805 86 #endif
borlanic 0:fbdae7e6d805 87
borlanic 0:fbdae7e6d805 88 #endif
borlanic 0:fbdae7e6d805 89
borlanic 0:fbdae7e6d805 90 /** @}*/
borlanic 0:fbdae7e6d805 91
borlanic 0:fbdae7e6d805 92 /** @}*/