rtos_trace/lib.rs
1#![doc = include_str!("../README.md")]
2#![no_std]
3
4mod macros;
5pub mod trace;
6
7/// Task info block.
8pub struct TaskInfo {
9 /// Names as static string.
10 pub name: &'static str,
11 /// Task priority number.
12 pub priority: u32,
13 /// Start address of the stack.
14 pub stack_base: usize,
15 /// Size of the stack in bytes.
16 pub stack_size: usize,
17}
18
19/// Collection of tracing functions which are called by the RTOS.
20pub trait RtosTrace {
21 /// Start tracing.
22 fn start();
23 /// Stop tracing.
24 fn stop();
25
26 /// A new task with `id` was created.
27 fn task_new(id: u32);
28 /// The task with `id` has `info` attributes.
29 fn task_send_info(id: u32, info: TaskInfo);
30 /// Convenience function to create a new task with a name only.
31 fn task_new_stackless(id: u32, name: &'static str, priority: u32);
32 /// The task with `id` has been terminated.
33 fn task_terminate(id: u32);
34 /// The task with `id` will start to run on the CPU now.
35 fn task_exec_begin(id: u32);
36 /// Execution of the current task has ended.
37 fn task_exec_end();
38 /// The task with `id` is ready to run.
39 fn task_ready_begin(id: u32);
40 /// The task with `id` is being blocked/suspended.
41 fn task_ready_end(id: u32);
42
43 /// The RTOS enters idle mode.
44 fn system_idle();
45
46 /// Enter an ISR.
47 fn isr_enter();
48 /// Exit an ISR.
49 fn isr_exit();
50 /// Exit an ISR to the scheduler.
51 fn isr_exit_to_scheduler();
52
53 /// Create a new marker with `id`.
54 fn name_marker(id: u32, name: &'static str);
55 /// Create a new marker with `id`.
56 fn marker(id: u32);
57 /// Begin event of marker with `id`.
58 fn marker_begin(id: u32);
59 /// End event of marker with `id`.
60 fn marker_end(id: u32);
61}
62
63/// Callbacks to the OS invoked by the tracing system.
64/// This trait can be implemented in the RTOS.
65pub trait RtosTraceOSCallbacks {
66 /// Send a list of all tasks to the tracing system.
67 fn task_list();
68 /// Get system time in microseconds.
69 fn time() -> u64;
70}
71
72/// Callbacks to the application invoked by the tracing system.
73/// This trait can be implemented by user.
74pub trait RtosTraceApplicationCallbacks {
75 /// Send a system and application description to the tracing system.
76 fn system_description();
77 /// Get system clock in Hertz.
78 fn sysclock() -> u32;
79}