| 1 | /* @title: Profiling */ |
| 2 | #pragma once |
| 3 | #include <compiler.h> |
| 4 | #include <global.h> |
| 5 | #include <linker/symbols.h> |
| 6 | #include <stdbool.h> |
| 7 | #include <stdint.h> |
| 8 | #include <structures/list.h> |
| 9 | |
| 10 | struct profiling_entry { |
| 11 | const char *name; |
| 12 | void *data; |
| 13 | const char *(*to_str)(void *data); |
| 14 | void (*log)(void *data); |
| 15 | struct list_head list_node; |
| 16 | }; |
| 17 | |
| 18 | /* Current set of profiling flags: |
| 19 | * |
| 20 | * PROFILING_ALL - Enables all profiling |
| 21 | * PROFILING_SCHED - Enables scheduler profiling |
| 22 | * |
| 23 | * TODO: more... |
| 24 | */ |
| 25 | |
| 26 | /* Initialize profiling */ |
| 27 | void profiling_init(void); |
| 28 | void profiling_log_all(void); |
| 29 | |
| 30 | #define PROFILE_SECTION LINKER_SECTION_ATTRIBUTE(profiling_data) |
| 31 | |
| 32 | #define REGISTER_PROFILING_ENTRY(entry) \ |
| 33 | static const struct profiling_entry entry PROFILE_SECTION |
| 34 | |