External functions to implement

You must provide the following external functions.

barman_ext_get_timestamp
extern bm_uint64 barman_ext_get_timestamp(void);
barman_ext_get_timestamp function information
Description Reads the current sample timestamp value, which must be provided for the time at the point of the call. The timer must provide monotonically incrementing values from an implementation defined start point. The counter must not overflow during the period that it is used. The counter is in arbitrary units. The mechanism for converting those units to nanoseconds is described as part of the protocol data header.
Return value The timestamp value in arbitrary units.

The following functions have weak linkage implementations that can be overridden if necessary:

barman_ext_disable_interrupts_local
extern bm_uintptr barman_ext_disable_interrupts_local(void);
barman_ext_disable_interrupts_local function information
Description Disables interrupts on the local processor only. Used to allow atomic accesses to certain resources, for example PMU counters.
Return value The current interrupt enablement status value. This value must be preserved and passed to barman_ext_enable_interrupts_local to restore the previous state.

Note

A weak implementation of this function is provided that modifies DAIF on AArch64, or CPSR on AArch32.

barman_ext_enable_interrupts_local
extern void barman_ext_enable_interrupts_local(bm_uintptr previous_state);
barman_ext_enable_interrupts_local function information
Description Enables interrupts on the local processor only.
Parameter
previous_state

The value that was previously returned from barman_ext_disable_interrupts_local.

Note

A weak implementation of this function is provided that modifies DAIF on AArch64, or CPSR on AArch32.

The following functions must be defined if BM_CONFIG_MAX_CORES > 1:

barman_ext_map_multiprocessor_affinity_to_core_no
extern bm_uint32 barman_ext_map_multiprocessor_affinity_to_core_no(bm_uintptr mpidr);
barman_ext_map_multiprocessor_affinity_to_core_no function information
Description Given the MPIDR register, returns a unique processor number. The implementation must return a value between 0 and N, where N is the maximum number of processors in the system. For any valid permutation of the arguments, a unique value must be returned. This value must not change between successive calls to this function for the same argument values. See the following example.
Parameter
mpidr

The value of the MPIDR register.

Return value The processor number.

Example

//
// Example implementation where processors are arranged as follows:
//
// aff2 | aff1 | aff0 | cpuno
// -----+------+------+------
//   0  |  0   |  0   |  0
//   0  |  0   |  1   |  1
//   0  |  0   |  2   |  2
//   0  |  0   |  3   |  3
//   0  |  1   |  0   |  4
//   0  |  1   |  1   |  5
//
bm_uint32 barman_ext_map_multiprocessor_affinity_to_core_no(bm_uintptr mpidr)
{
  return (mpidr & 0x03) + ((mpidr >> 6) & 0x4);
}

Note

This function only needs defining when BM_CONFIG_MAX_CORES > 1.

barman_ext_map_multiprocessor_affinity_to_cluster_no
extern bm_uint32 barman_ext_map_multiprocessor_affinity_to_cluster_no(bm_uintptr mpidr);
barman_ext_map_multiprocessor_affinity_to_cluster_no function information
Description Given the MPIDR register, return the appropriate cluster number. Cluster IDs should be numbered from 0 to N, where N is the number of clusters in the system. See the following example.
Parameter
mpidr

The value of the MPIDR register.

Return value The cluster number.

Example

//
// Example implementation which is compatible with the example implementation of
// barman_ext_map_multiprocessor_affinity_to_core_no given above.
//
bm_uint32 barman_ext_map_multiprocessor_affinity_to_cluster_no(bm_uintptr mpidr)
{
  return ((mpidr >> 8) & 0x1);
}

Note

This function only needs defining when BM_CONFIG_MAX_CORES > 1.

The following function must be defined if BM_CONFIG_MAX_TASK_INFOS > 0:

barman_ext_get_current_task_id
extern bm_task_id_t barman_ext_get_current_task_id(void);
barman_ext_get_current_task_id function information
Description Returns the current task ID.

The following functions must be defined if BM_CONFIG_ENABLE_LOGGING != 0:

barman_ext_log_info
void barman_ext_log_info(const char * message, ...);
barman_ext_log_info function information
Description Prints an info message.
Parameter message
barman_ext_log_warning
void barman_ext_log_warning(const char * message, ...);
barman_ext_log_warning function information
Description Prints a warning message.
Parameter message
barman_ext_log_error
void barman_ext_log_error(const char * message, ...);
barman_ext_log_error information
Description Prints an error message.
Parameter message

The following function must be defined if BM_CONFIG_ENABLE_DEBUG_LOGGING != 0:

barman_ext_log_debug
void barman_ext_log_debug(const char * message, ...);
barman_ext_log_debug function information
Description Prints a debug message.
Parameter message