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