RTC auf true
platform/mbed_stats.h@0:38ceb79fef03, 2018-11-28 (annotated)
- Committer:
- kevman
- Date:
- Wed Nov 28 15:10:15 2018 +0000
- Revision:
- 0:38ceb79fef03
RTC modified
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kevman | 0:38ceb79fef03 | 1 | |
kevman | 0:38ceb79fef03 | 2 | /** \addtogroup platform */ |
kevman | 0:38ceb79fef03 | 3 | /** @{*/ |
kevman | 0:38ceb79fef03 | 4 | /** |
kevman | 0:38ceb79fef03 | 5 | * \defgroup platform_stats stats functions |
kevman | 0:38ceb79fef03 | 6 | * @{ |
kevman | 0:38ceb79fef03 | 7 | */ |
kevman | 0:38ceb79fef03 | 8 | /* mbed Microcontroller Library |
kevman | 0:38ceb79fef03 | 9 | * Copyright (c) 2016-2018 ARM Limited |
kevman | 0:38ceb79fef03 | 10 | * |
kevman | 0:38ceb79fef03 | 11 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kevman | 0:38ceb79fef03 | 12 | * you may not use this file except in compliance with the License. |
kevman | 0:38ceb79fef03 | 13 | * You may obtain a copy of the License at |
kevman | 0:38ceb79fef03 | 14 | * |
kevman | 0:38ceb79fef03 | 15 | * http://www.apache.org/licenses/LICENSE-2.0 |
kevman | 0:38ceb79fef03 | 16 | * |
kevman | 0:38ceb79fef03 | 17 | * Unless required by applicable law or agreed to in writing, software |
kevman | 0:38ceb79fef03 | 18 | * distributed under the License is distributed on an "AS IS" BASIS, |
kevman | 0:38ceb79fef03 | 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kevman | 0:38ceb79fef03 | 20 | * See the License for the specific language governing permissions and |
kevman | 0:38ceb79fef03 | 21 | * limitations under the License. |
kevman | 0:38ceb79fef03 | 22 | */ |
kevman | 0:38ceb79fef03 | 23 | #ifndef MBED_STATS_H |
kevman | 0:38ceb79fef03 | 24 | #define MBED_STATS_H |
kevman | 0:38ceb79fef03 | 25 | #include <stdint.h> |
kevman | 0:38ceb79fef03 | 26 | #include <stddef.h> |
kevman | 0:38ceb79fef03 | 27 | #include "hal/ticker_api.h" |
kevman | 0:38ceb79fef03 | 28 | |
kevman | 0:38ceb79fef03 | 29 | #ifdef __cplusplus |
kevman | 0:38ceb79fef03 | 30 | extern "C" { |
kevman | 0:38ceb79fef03 | 31 | #endif |
kevman | 0:38ceb79fef03 | 32 | |
kevman | 0:38ceb79fef03 | 33 | #ifdef MBED_ALL_STATS_ENABLED |
kevman | 0:38ceb79fef03 | 34 | #define MBED_SYS_STATS_ENABLED 1 |
kevman | 0:38ceb79fef03 | 35 | #define MBED_STACK_STATS_ENABLED 1 |
kevman | 0:38ceb79fef03 | 36 | #define MBED_CPU_STATS_ENABLED 1 |
kevman | 0:38ceb79fef03 | 37 | #define MBED_HEAP_STATS_ENABLED 1 |
kevman | 0:38ceb79fef03 | 38 | #define MBED_THREAD_STATS_ENABLED 1 |
kevman | 0:38ceb79fef03 | 39 | #endif |
kevman | 0:38ceb79fef03 | 40 | |
kevman | 0:38ceb79fef03 | 41 | /** |
kevman | 0:38ceb79fef03 | 42 | * struct mbed_stats_heap_t definition |
kevman | 0:38ceb79fef03 | 43 | */ |
kevman | 0:38ceb79fef03 | 44 | typedef struct { |
kevman | 0:38ceb79fef03 | 45 | uint32_t current_size; /**< Bytes currently allocated on the heap */ |
kevman | 0:38ceb79fef03 | 46 | uint32_t max_size; /**< Maximum bytes allocated on the heap at one time since reset */ |
kevman | 0:38ceb79fef03 | 47 | uint32_t total_size; /**< Cumulative sum of bytes allocated on the heap that have not been freed */ |
kevman | 0:38ceb79fef03 | 48 | uint32_t reserved_size; /**< Current number of bytes reserved for the heap */ |
kevman | 0:38ceb79fef03 | 49 | uint32_t alloc_cnt; /**< Current number of allocations that have not been freed since reset */ |
kevman | 0:38ceb79fef03 | 50 | uint32_t alloc_fail_cnt; /**< Number of failed allocations since reset */ |
kevman | 0:38ceb79fef03 | 51 | uint32_t overhead_size; /**< Number of bytes used to store heap statistics. This overhead takes up space on the heap, reducing the available heap space */ |
kevman | 0:38ceb79fef03 | 52 | } mbed_stats_heap_t; |
kevman | 0:38ceb79fef03 | 53 | |
kevman | 0:38ceb79fef03 | 54 | /** |
kevman | 0:38ceb79fef03 | 55 | * Fill the passed in heap stat structure with the heap statistics. |
kevman | 0:38ceb79fef03 | 56 | * |
kevman | 0:38ceb79fef03 | 57 | * @param stats A pointer to the mbed_stats_heap_t structure to fill |
kevman | 0:38ceb79fef03 | 58 | */ |
kevman | 0:38ceb79fef03 | 59 | void mbed_stats_heap_get(mbed_stats_heap_t *stats); |
kevman | 0:38ceb79fef03 | 60 | |
kevman | 0:38ceb79fef03 | 61 | /** |
kevman | 0:38ceb79fef03 | 62 | * struct mbed_stats_stack_t definition |
kevman | 0:38ceb79fef03 | 63 | */ |
kevman | 0:38ceb79fef03 | 64 | typedef struct { |
kevman | 0:38ceb79fef03 | 65 | uint32_t thread_id; /**< Identifier for the thread that owns the stack or 0 if representing accumulated statistics */ |
kevman | 0:38ceb79fef03 | 66 | uint32_t max_size; /**< Maximum number of bytes used on the stack since the thread was started */ |
kevman | 0:38ceb79fef03 | 67 | uint32_t reserved_size; /**< Current number of bytes reserved for the stack */ |
kevman | 0:38ceb79fef03 | 68 | uint32_t stack_cnt; /**< The number of stacks represented in the accumulated statistics or 1 if repesenting a single stack */ |
kevman | 0:38ceb79fef03 | 69 | } mbed_stats_stack_t; |
kevman | 0:38ceb79fef03 | 70 | |
kevman | 0:38ceb79fef03 | 71 | /** |
kevman | 0:38ceb79fef03 | 72 | * Fill the passed in structure with stack statistics accumulated for all threads. The thread_id will be 0 |
kevman | 0:38ceb79fef03 | 73 | * and stack_cnt will represent number of threads. |
kevman | 0:38ceb79fef03 | 74 | * |
kevman | 0:38ceb79fef03 | 75 | * @param stats A pointer to the mbed_stats_stack_t structure to fill |
kevman | 0:38ceb79fef03 | 76 | */ |
kevman | 0:38ceb79fef03 | 77 | void mbed_stats_stack_get(mbed_stats_stack_t *stats); |
kevman | 0:38ceb79fef03 | 78 | |
kevman | 0:38ceb79fef03 | 79 | /** |
kevman | 0:38ceb79fef03 | 80 | * Fill the passed array of structures with the stack statistics for each available thread. |
kevman | 0:38ceb79fef03 | 81 | * |
kevman | 0:38ceb79fef03 | 82 | * @param stats A pointer to an array of mbed_stats_stack_t structures to fill |
kevman | 0:38ceb79fef03 | 83 | * @param count The number of mbed_stats_stack_t structures in the provided array |
kevman | 0:38ceb79fef03 | 84 | * @return The number of mbed_stats_stack_t structures that have been filled. |
kevman | 0:38ceb79fef03 | 85 | * If the number of stacks on the system is less than or equal to count, it will equal the number of stacks on the system. |
kevman | 0:38ceb79fef03 | 86 | * If the number of stacks on the system is greater than count, it will equal count. |
kevman | 0:38ceb79fef03 | 87 | */ |
kevman | 0:38ceb79fef03 | 88 | size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count); |
kevman | 0:38ceb79fef03 | 89 | |
kevman | 0:38ceb79fef03 | 90 | /** |
kevman | 0:38ceb79fef03 | 91 | * struct mbed_stats_cpu_t definition |
kevman | 0:38ceb79fef03 | 92 | */ |
kevman | 0:38ceb79fef03 | 93 | typedef struct { |
kevman | 0:38ceb79fef03 | 94 | us_timestamp_t uptime; /**< Time since the system has started */ |
kevman | 0:38ceb79fef03 | 95 | us_timestamp_t idle_time; /**< Time spent in the idle thread since the system has started */ |
kevman | 0:38ceb79fef03 | 96 | us_timestamp_t sleep_time; /**< Time spent in sleep since the system has started */ |
kevman | 0:38ceb79fef03 | 97 | us_timestamp_t deep_sleep_time; /**< Time spent in deep sleep since the system has started */ |
kevman | 0:38ceb79fef03 | 98 | } mbed_stats_cpu_t; |
kevman | 0:38ceb79fef03 | 99 | |
kevman | 0:38ceb79fef03 | 100 | /** |
kevman | 0:38ceb79fef03 | 101 | * Fill the passed in CPU stat structure with CPU statistics. |
kevman | 0:38ceb79fef03 | 102 | * |
kevman | 0:38ceb79fef03 | 103 | * @param stats A pointer to the mbed_stats_cpu_t structure to fill |
kevman | 0:38ceb79fef03 | 104 | */ |
kevman | 0:38ceb79fef03 | 105 | void mbed_stats_cpu_get(mbed_stats_cpu_t *stats); |
kevman | 0:38ceb79fef03 | 106 | |
kevman | 0:38ceb79fef03 | 107 | /** |
kevman | 0:38ceb79fef03 | 108 | * struct mbed_stats_thread_t definition |
kevman | 0:38ceb79fef03 | 109 | */ |
kevman | 0:38ceb79fef03 | 110 | typedef struct { |
kevman | 0:38ceb79fef03 | 111 | uint32_t id; /**< ID of the thread */ |
kevman | 0:38ceb79fef03 | 112 | uint32_t state; /**< State of the thread */ |
kevman | 0:38ceb79fef03 | 113 | uint32_t priority; /**< Priority of the thread (higher number indicates higher priority) */ |
kevman | 0:38ceb79fef03 | 114 | uint32_t stack_size; /**< Current number of bytes reserved for the stack */ |
kevman | 0:38ceb79fef03 | 115 | uint32_t stack_space; /**< Current number of free bytes remaining on the stack */ |
kevman | 0:38ceb79fef03 | 116 | const char *name; /**< Name of the thread */ |
kevman | 0:38ceb79fef03 | 117 | } mbed_stats_thread_t; |
kevman | 0:38ceb79fef03 | 118 | |
kevman | 0:38ceb79fef03 | 119 | /** |
kevman | 0:38ceb79fef03 | 120 | * Fill the passed array of stat structures with the thread statistics for each available thread. |
kevman | 0:38ceb79fef03 | 121 | * |
kevman | 0:38ceb79fef03 | 122 | * @param stats A pointer to an array of mbed_stats_thread_t structures to fill |
kevman | 0:38ceb79fef03 | 123 | * @param count The number of mbed_stats_thread_t structures in the provided array |
kevman | 0:38ceb79fef03 | 124 | * @return The number of mbed_stats_thread_t structures that have been filled. |
kevman | 0:38ceb79fef03 | 125 | * If the number of threads on the system is less than or equal to count, it will equal the number of threads on the system. |
kevman | 0:38ceb79fef03 | 126 | * If the number of threads on the system is greater than count, it will equal count. |
kevman | 0:38ceb79fef03 | 127 | */ |
kevman | 0:38ceb79fef03 | 128 | size_t mbed_stats_thread_get_each(mbed_stats_thread_t *stats, size_t count); |
kevman | 0:38ceb79fef03 | 129 | |
kevman | 0:38ceb79fef03 | 130 | /** |
kevman | 0:38ceb79fef03 | 131 | * enum mbed_compiler_id_t definition |
kevman | 0:38ceb79fef03 | 132 | */ |
kevman | 0:38ceb79fef03 | 133 | typedef enum { |
kevman | 0:38ceb79fef03 | 134 | ARM = 1, /**< ARM */ |
kevman | 0:38ceb79fef03 | 135 | GCC_ARM, /**< GNU ARM */ |
kevman | 0:38ceb79fef03 | 136 | IAR /**< IAR */ |
kevman | 0:38ceb79fef03 | 137 | } mbed_compiler_id_t; |
kevman | 0:38ceb79fef03 | 138 | |
kevman | 0:38ceb79fef03 | 139 | /** |
kevman | 0:38ceb79fef03 | 140 | * struct mbed_stats_sys_t definition |
kevman | 0:38ceb79fef03 | 141 | */ |
kevman | 0:38ceb79fef03 | 142 | typedef struct { |
kevman | 0:38ceb79fef03 | 143 | uint32_t os_version; /**< Mbed OS version (populated only for tagged releases) */ |
kevman | 0:38ceb79fef03 | 144 | uint32_t cpu_id; /**< CPUID register data (Cortex-M only supported) */ |
kevman | 0:38ceb79fef03 | 145 | mbed_compiler_id_t compiler_id; /**< Compiler ID \ref mbed_compiler_id_t */ |
kevman | 0:38ceb79fef03 | 146 | uint32_t compiler_version; /**< Compiler version */ |
kevman | 0:38ceb79fef03 | 147 | } mbed_stats_sys_t; |
kevman | 0:38ceb79fef03 | 148 | |
kevman | 0:38ceb79fef03 | 149 | /** |
kevman | 0:38ceb79fef03 | 150 | * Fill the passed in system stat structure with system statistics. |
kevman | 0:38ceb79fef03 | 151 | * |
kevman | 0:38ceb79fef03 | 152 | * @param stats A pointer to the mbed_stats_sys_t structure to fill |
kevman | 0:38ceb79fef03 | 153 | */ |
kevman | 0:38ceb79fef03 | 154 | void mbed_stats_sys_get(mbed_stats_sys_t *stats); |
kevman | 0:38ceb79fef03 | 155 | |
kevman | 0:38ceb79fef03 | 156 | #ifdef __cplusplus |
kevman | 0:38ceb79fef03 | 157 | } |
kevman | 0:38ceb79fef03 | 158 | #endif |
kevman | 0:38ceb79fef03 | 159 | |
kevman | 0:38ceb79fef03 | 160 | #endif |
kevman | 0:38ceb79fef03 | 161 | |
kevman | 0:38ceb79fef03 | 162 | /** @}*/ |
kevman | 0:38ceb79fef03 | 163 | |
kevman | 0:38ceb79fef03 | 164 | /** @}*/ |