10605bf00SDaniel Bristot de Oliveira // SPDX-License-Identifier: GPL-2.0 20605bf00SDaniel Bristot de Oliveira #include "trace.h" 30605bf00SDaniel Bristot de Oliveira 40605bf00SDaniel Bristot de Oliveira /* 50605bf00SDaniel Bristot de Oliveira * osnoise_context - read, store, write, restore osnoise configs. 60605bf00SDaniel Bristot de Oliveira */ 70605bf00SDaniel Bristot de Oliveira struct osnoise_context { 80605bf00SDaniel Bristot de Oliveira int flags; 90605bf00SDaniel Bristot de Oliveira int ref; 100605bf00SDaniel Bristot de Oliveira 110605bf00SDaniel Bristot de Oliveira char *curr_cpus; 120605bf00SDaniel Bristot de Oliveira char *orig_cpus; 130605bf00SDaniel Bristot de Oliveira 140605bf00SDaniel Bristot de Oliveira /* 0 as init value */ 150605bf00SDaniel Bristot de Oliveira unsigned long long orig_runtime_us; 160605bf00SDaniel Bristot de Oliveira unsigned long long runtime_us; 170605bf00SDaniel Bristot de Oliveira 180605bf00SDaniel Bristot de Oliveira /* 0 as init value */ 190605bf00SDaniel Bristot de Oliveira unsigned long long orig_period_us; 200605bf00SDaniel Bristot de Oliveira unsigned long long period_us; 210605bf00SDaniel Bristot de Oliveira 220605bf00SDaniel Bristot de Oliveira /* 0 as init value */ 230605bf00SDaniel Bristot de Oliveira long long orig_timerlat_period_us; 240605bf00SDaniel Bristot de Oliveira long long timerlat_period_us; 250605bf00SDaniel Bristot de Oliveira 2661c57d57SDaniel Bristot de Oliveira /* 0 as init value */ 2761c57d57SDaniel Bristot de Oliveira long long orig_tracing_thresh; 2861c57d57SDaniel Bristot de Oliveira long long tracing_thresh; 2961c57d57SDaniel Bristot de Oliveira 300605bf00SDaniel Bristot de Oliveira /* -1 as init value because 0 is disabled */ 310605bf00SDaniel Bristot de Oliveira long long orig_stop_us; 320605bf00SDaniel Bristot de Oliveira long long stop_us; 330605bf00SDaniel Bristot de Oliveira 340605bf00SDaniel Bristot de Oliveira /* -1 as init value because 0 is disabled */ 350605bf00SDaniel Bristot de Oliveira long long orig_stop_total_us; 360605bf00SDaniel Bristot de Oliveira long long stop_total_us; 370605bf00SDaniel Bristot de Oliveira 380605bf00SDaniel Bristot de Oliveira /* -1 as init value because 0 is disabled */ 390605bf00SDaniel Bristot de Oliveira long long orig_print_stack; 400605bf00SDaniel Bristot de Oliveira long long print_stack; 411f428356SDaniel Bristot de Oliveira 421f428356SDaniel Bristot de Oliveira /* -1 as init value because 0 is off */ 431f428356SDaniel Bristot de Oliveira int orig_opt_irq_disable; 441f428356SDaniel Bristot de Oliveira int opt_irq_disable; 45*cdca4f4eSDaniel Bristot de Oliveira 46*cdca4f4eSDaniel Bristot de Oliveira /* -1 as init value because 0 is off */ 47*cdca4f4eSDaniel Bristot de Oliveira int orig_opt_workload; 48*cdca4f4eSDaniel Bristot de Oliveira int opt_workload; 490605bf00SDaniel Bristot de Oliveira }; 500605bf00SDaniel Bristot de Oliveira 510605bf00SDaniel Bristot de Oliveira /* 520605bf00SDaniel Bristot de Oliveira * *_INIT_VALs are also invalid values, they are used to 530605bf00SDaniel Bristot de Oliveira * communicate errors. 540605bf00SDaniel Bristot de Oliveira */ 550605bf00SDaniel Bristot de Oliveira #define OSNOISE_OPTION_INIT_VAL (-1) 560605bf00SDaniel Bristot de Oliveira #define OSNOISE_TIME_INIT_VAL (0) 570605bf00SDaniel Bristot de Oliveira 580605bf00SDaniel Bristot de Oliveira struct osnoise_context *osnoise_context_alloc(void); 590605bf00SDaniel Bristot de Oliveira int osnoise_get_context(struct osnoise_context *context); 600605bf00SDaniel Bristot de Oliveira void osnoise_put_context(struct osnoise_context *context); 610605bf00SDaniel Bristot de Oliveira 620605bf00SDaniel Bristot de Oliveira int osnoise_set_cpus(struct osnoise_context *context, char *cpus); 630605bf00SDaniel Bristot de Oliveira void osnoise_restore_cpus(struct osnoise_context *context); 640605bf00SDaniel Bristot de Oliveira 650605bf00SDaniel Bristot de Oliveira int osnoise_set_runtime_period(struct osnoise_context *context, 660605bf00SDaniel Bristot de Oliveira unsigned long long runtime, 670605bf00SDaniel Bristot de Oliveira unsigned long long period); 680605bf00SDaniel Bristot de Oliveira void osnoise_restore_runtime_period(struct osnoise_context *context); 690605bf00SDaniel Bristot de Oliveira 700605bf00SDaniel Bristot de Oliveira int osnoise_set_stop_us(struct osnoise_context *context, 710605bf00SDaniel Bristot de Oliveira long long stop_us); 720605bf00SDaniel Bristot de Oliveira void osnoise_restore_stop_us(struct osnoise_context *context); 730605bf00SDaniel Bristot de Oliveira 740605bf00SDaniel Bristot de Oliveira int osnoise_set_stop_total_us(struct osnoise_context *context, 750605bf00SDaniel Bristot de Oliveira long long stop_total_us); 760605bf00SDaniel Bristot de Oliveira void osnoise_restore_stop_total_us(struct osnoise_context *context); 770605bf00SDaniel Bristot de Oliveira 780605bf00SDaniel Bristot de Oliveira int osnoise_set_timerlat_period_us(struct osnoise_context *context, 790605bf00SDaniel Bristot de Oliveira long long timerlat_period_us); 800605bf00SDaniel Bristot de Oliveira void osnoise_restore_timerlat_period_us(struct osnoise_context *context); 810605bf00SDaniel Bristot de Oliveira 8261c57d57SDaniel Bristot de Oliveira int osnoise_set_tracing_thresh(struct osnoise_context *context, 8361c57d57SDaniel Bristot de Oliveira long long tracing_thresh); 8461c57d57SDaniel Bristot de Oliveira void osnoise_restore_tracing_thresh(struct osnoise_context *context); 8561c57d57SDaniel Bristot de Oliveira 860605bf00SDaniel Bristot de Oliveira void osnoise_restore_print_stack(struct osnoise_context *context); 870605bf00SDaniel Bristot de Oliveira int osnoise_set_print_stack(struct osnoise_context *context, 880605bf00SDaniel Bristot de Oliveira long long print_stack); 890605bf00SDaniel Bristot de Oliveira 901f428356SDaniel Bristot de Oliveira int osnoise_set_irq_disable(struct osnoise_context *context, bool onoff); 91*cdca4f4eSDaniel Bristot de Oliveira int osnoise_set_workload(struct osnoise_context *context, bool onoff); 921f428356SDaniel Bristot de Oliveira 930605bf00SDaniel Bristot de Oliveira /* 940605bf00SDaniel Bristot de Oliveira * osnoise_tool - osnoise based tool definition. 950605bf00SDaniel Bristot de Oliveira */ 960605bf00SDaniel Bristot de Oliveira struct osnoise_tool { 970605bf00SDaniel Bristot de Oliveira struct trace_instance trace; 980605bf00SDaniel Bristot de Oliveira struct osnoise_context *context; 990605bf00SDaniel Bristot de Oliveira void *data; 1000605bf00SDaniel Bristot de Oliveira void *params; 1010605bf00SDaniel Bristot de Oliveira time_t start_time; 1020605bf00SDaniel Bristot de Oliveira }; 1030605bf00SDaniel Bristot de Oliveira 1040605bf00SDaniel Bristot de Oliveira void osnoise_destroy_tool(struct osnoise_tool *top); 1050605bf00SDaniel Bristot de Oliveira struct osnoise_tool *osnoise_init_tool(char *tool_name); 1060605bf00SDaniel Bristot de Oliveira struct osnoise_tool *osnoise_init_trace_tool(char *tracer); 1070605bf00SDaniel Bristot de Oliveira 108829a6c0bSDaniel Bristot de Oliveira int osnoise_hist_main(int argc, char *argv[]); 1091eceb2fcSDaniel Bristot de Oliveira int osnoise_top_main(int argc, char **argv); 1100605bf00SDaniel Bristot de Oliveira int osnoise_main(int argc, char **argv); 1111f428356SDaniel Bristot de Oliveira int hwnoise_main(int argc, char **argv); 112