Use the bare-metal agent by calling the following public API functions.
The prototype of barman_initialize varies depending on the datastore chosen.
When using the linear or circular RAM buffer:
BM_NONNULL((1, 3, 4))
bm_bool barman_initialize(bm_uint8 * buffer, bm_uintptr buffer_length,
When using STM:
BM_NONNULL((2, 3, 4))
bm_bool barman_initialize_with_stm_interface(void * stm_configuration_registers, void * stm_extended_stimulus_ports,
When using ITM on Arm® M-profile architectures:
BM_NONNULL((1, 2))
bm_bool barman_initialize_with_itm_interface(
When using ITM on Arm A- or R-profile architectures:
BM_NONNULL((1, 2, 3))
bm_bool barman_initialize_with_itm_interface(void * itm_registers,
The remaining parameters for each datastore are the same:
const char * target_name,
const struct bm_protocol_clock_info * clock_info,
#if BM_CONFIG_MAX_TASK_INFOS > 0
bm_uint32 num_task_entries,
const struct bm_protocol_task_info * task_entries,
#endif
#if BM_CONFIG_MAX_MMAP_LAYOUTS > 0
bm_uint32 num_mmap_entries,
const struct bm_protocol_mmap_layout * mmap_entries,
#endif
bm_uint32 timer_sample_rate);
| Description | Initialize Barman. |
| Parameters |
|
| Return value |
|
Note
If BM_CONFIG_MAX_TASK_INFOS ≤ 0, num_task_entries and task_entries are not present.
If BM_CONFIG_MAX_MMAP_LAYOUTS ≤ 0, num_mmap_entries and mmap_entries are not present.
void barman_enable_sampling(void);
| Description | Enables sampling. Call when all PMUs are enabled and the data store is configured. |
void barman_disable_sampling(void);
| Description | Disables sampling without reconfiguring the PMU. To resume sampling, call barman_enable_sampling. |
void barman_sample_counters(bm_bool sample_return_address);
| Description | Reads the configured PMU counters for the current processing element and inserts them into the data store. Can also insert a Program Counter record using the return address as the PC sample. |
| Parameter |
|
Note
The Call Paths view displays the PC values. This view is blank if the application does not call barman_sample_counters with sample_return_address == BM_TRUE, or barman_sample_counters_with_program_counter with pc != BM_NULL.
Application code that is not doing periodic sampling typically calls this function with sample_return_address == BM_TRUE.
This function must be run on the processing element for the PMU that it intends to sample from. It must not be migrated to another processing element for the duration of the call. This is necessary as it needs to program the per processing element PMU registers.
void barman_sample_counters_with_program_counter(const void * pc);
| Description | Reads the configured PMU counters for the current processing element and inserts them into the data store. |
| Parameter |
|
Note
The Call Paths view displays the PC values. This view is blank if the application does not call barman_sample_counters_with_program_counter with pc != BM_NULL, or barman_sample_counters with sample_return_address == BM_TRUE.
A periodic interrupt handler typically calls this function, with pc == <the_exception_return_address>.
This function must be run on the processing element for the PMU that it intends to sample from. It must not be migrated to another processing element for the duration of the call. This is necessary as it needs to program the per processing element PMU registers.
The following functions are available if BM_CONFIG_MAX_TASK_INFOS > 0 :
bm_bool barman_add_task_record(bm_uint64 timestamp, const struct bm_protocol_task_info * task_entry);
| Description | Adds a task information record. |
| Parameters |
|
| Return value |
|
void barman_record_task_switch(enum bm_task_switch_reason reason);
| Description | Records that a task switch has occurred. Call this function after the new task is made the current task, so a call to barman_ext_get_current_task_id returns the new task ID. For example, insert it into the scheduler of an RTOS just after the new task is selected to record the task switch. |
| Parameter |
|
Note
Call after the task switch has occurred so that bm_ext_get_current_task returns the task_id of the switched to task.
The following function is available if BM_CONFIG_MAX_MMAP_LAYOUTS > 0:
bm_bool barman_add_mmap_record(bm_uint64 timestamp, const struct bm_protocol_mmap_layout * mmap_entry);
| Description | Adds a mmap information record. |
| Parameters |
|
| Return value |
|
Data types associated with the public API functions:
struct bm_protocol_clock_info
{
bm_uint64 timestamp_base;
bm_uint64 timestamp_multiplier;
bm_uint64 timestamp_divisor;
bm_uint64 unix_base_ns;
};
| Description | Defines information about the monotonic clock used in the trace. Timestamp information is stored in arbitrary units within samples. Arbitrary units reduce the overhead of making the trace by removing the need to transform the timestamp into nanoseconds at the point the sample is recorded. The host expects timestamps to be in nanoseconds. The arbitrary timestamp information is transformed to nanoseconds according to the following formula:
Therefore for a clock that already returns time in nanoseconds, |
| Members |
|
struct bm_protocol_task_info
{
bm_task_id_t task_id;
const char * task_name;
};
| Description | A task information record. Describes information about a unique task within the system. |
| Members |
|
struct bm_protocol_mmap_layout
{
#if BM_CONFIG_MAX_TASK_INFOS > 0
bm_task_id_t task_id;
#endif
bm_uintptr base_address;
bm_uintptr length;
bm_uintptr image_offset;
const char * image_name;
};
| Description | An MMAP layout record. Describes the position of an executable image (or section thereof) in memory, allowing the host to map PC values to the appropriate executable image. |
| Members |
|
enum bm_task_switch_reason
{
BM_TASK_SWITCH_REASON_PREEMPTED = 0,
BM_TASK_SWITCH_REASON_WAIT = 1
};
| Description | Reason for a task switch. |
| Members |
|
WFI and WFE event handling functions:
void barman_wfi(void);
| Description | Wraps WFI instruction and sends events before and after the WFI to log the time in WFI. This function is safe to use in place of the usual WFI asm instruction, as it degenerates to just a WFI instruction when Barman is disabled. |
void barman_wfe(void);
| Description | Wraps WFE instruction and sends events before and after the WFE to log the time in WFE. This function is safe to use in place of the usual WFE asm instruction as it degenerates to just a WFE instruction when Barman is disabled. |
void barman_before_idle(void);
| Description | Call before a WFI or WFE, or other similar halting event, to log entry into the paused state. Can be used in situations where barman_wfi() or barman_wfe() is not suitable. |
Note
You must use barman_before_idle in a pair with barman_after_idle().
Using barman_wfi() or barman_wfe() is usually preferred, as it takes care of calling the before and after functions.
void barman_after_idle(void);
| Description | Call after a WFI or WFE, or other similar halting event, to log exit from the paused state. Can be used in situations where barman_wfi() or barman_wfe() is not suitable. |
Note
You must use barman_after_idle in a pair with barman_before_idle().
Using barman_wfi() or barman_wfe() is usually preferred, as it takes care of calling the before and after functions.
Functions for recording textual annotations:
void barman_annotate_channel(bm_uint32 channel, bm_uint32 color, const char * string)
| Description | Adds a string annotation with a display color, and assigns it to a channel. |
| Parameters |
|
Note
Annotation channels and groups are used to organize annotations within the threads and processes section of the Timeline view. Each annotation channel appears in its own row under the thread. Channels can also be grouped and displayed under a group name, using the barman_annotate_name_group function.
void barman_annotate_name_channel(bm_uint32 channel, bm_uint32 group, const char * name)
| Description | Defines a channel and attaches it to an existing group. |
| Parameters |
|
Note
The channel number must be unique within the task.
void barman_annotate_name_group(bm_uint32 group, const char * name)
| Description | Defines an annotation group. |
| Parameters |
|
Note
The group identifier, group, must be unique within the task.
void barman_annotate_marker(bm_uint32 color, const char * text)
| Description | Adds a bookmark with a string and a color to the Timeline view and Log view. The string is displayed in the Timeline view when you hover over the bookmark, and in the Message column in the Log view. |
| Parameters |
|
| Description | Color macros for annotations. See Annotation #defines . |