Loading...
Searching...
No Matches
Timestamp Counter
Utility Functions
Collaboration diagram for Timestamp Counter:

## Files

file | rdtsc.h
| Timestamp counter related functions.
file | rdtsc.h
| Timestamp counter related functions.

## Functions

l4_cpu_time_t | l4_rdtsc (void)
| Read current value of CPU-internal timestamp counter.
l4_uint32_t | l4_rdtsc_32 (void)
| Read the lest significant 32 bit of the TSC.
l4_uint64_t | l4_rdpmc (int ecx)
| Return current value of CPU-internal performance measurement counter.
l4_uint32_t | l4_rdpmc_32 (int ecx)
| Return the least significant 32 bit of a performance counter.
l4_uint64_t | l4_tsc_to_ns (l4_cpu_time_t tsc)
| Convert timestamp to ns value.
l4_uint64_t | l4_tsc_to_us (l4_cpu_time_t tsc)
| Convert timestamp into micro seconds value.
void | l4_tsc_to_s_and_ns (l4_cpu_time_t tsc, l4_uint32_t *s, l4_uint32_t *ns)
| Convert timestamp to s.ns value.
l4_cpu_time_t | l4_ns_to_tsc (l4_uint64_t ns)
| Convert nano seconds into CPU ticks.
void | l4_busy_wait_ns (l4_uint64_t ns)
| Wait busy for a small amount of time.
void | l4_busy_wait_us (l4_uint64_t us)
| Wait busy for a small amount of time.
l4_uint32_t | l4_calibrate_tsc (l4_kernel_info_t const *kip)
| Determine scalers for timestamp calculations.
l4_uint32_t | l4_tsc_init (l4_kernel_info_t const *kip)
| Initialize scaler for TSC calibrations from the kernel.
l4_uint32_t | l4_get_hz (void)
| Get CPU frequency in Hz.

## Detailed Description

## Function Documentation

## l4_busy_wait_ns()

void l4_busy_wait_ns | ( | l4_uint64_t | ns | ) |

inline

Wait busy for a small amount of time.

Parameters

  ns | nano seconds to wait

Attention
  Not intended for any use!

Definition at line 262 of file rdtsc.h.

References l4_ns_to_tsc(), and l4_rdtsc().

Here is the call graph for this function:

## l4_busy_wait_us()

void l4_busy_wait_us | ( | l4_uint64_t | us | ) |

inline

Wait busy for a small amount of time.

Parameters

  us | micro seconds to wait

Attention
  Not intended for any use!

Definition at line 272 of file rdtsc.h.

References l4_ns_to_tsc(), and l4_rdtsc().

Here is the call graph for this function:

## l4_calibrate_tsc()

l4_uint32_t l4_calibrate_tsc | ( | l4_kernel_info_t const * | kip | ) |

inline

Determine scalers for timestamp calculations.

Determine some scalers to be able to convert between real time and CPU ticks. Just calls l4_tsc_init().

Examples
  examples/sys/aliens/main.c.

Definition at line 159 of file rdtsc.h.

References l4_tsc_init().

Here is the call graph for this function:

## l4_get_hz()

l4_uint32_t l4_get_hz | ( | void |  | ) |

Get CPU frequency in Hz.

Returns
  frequency in Hz

References L4_END_DECLS, and L4_INLINE.

## l4_ns_to_tsc()

l4_cpu_time_t l4_ns_to_tsc | ( | l4_uint64_t | ns | ) |

inline

Convert nano seconds into CPU ticks.

Parameters

  ns | nano seconds

Returns
  CPU ticks

Definition at line 248 of file rdtsc.h.

Referenced by l4_busy_wait_ns(), and l4_busy_wait_us().

Here is the caller graph for this function:

## l4_rdpmc()

l4_uint64_t l4_rdpmc | ( | int | ecx | ) |

inline

Return current value of CPU-internal performance measurement counter.

Parameters

  ecx | ECX value for the rdpmc instruction. For details see the Intel IA-32 Architectures Software Developer's Manual.

Returns
  64-bit PMC

Definition at line 175 of file rdtsc.h.

## l4_rdpmc_32()

l4_uint32_t l4_rdpmc_32 | ( | int | ecx | ) |

inline

Return the least significant 32 bit of a performance counter.

Useful for smaller differences, needs less cycles.

Definition at line 195 of file rdtsc.h.

## l4_rdtsc()

l4_cpu_time_t l4_rdtsc | ( | void |  | ) |

inline

Read current value of CPU-internal timestamp counter.

Returns
  64-bit timestamp

Examples
  examples/sys/aliens/main.c.

Definition at line 165 of file rdtsc.h.

Referenced by l4_busy_wait_ns(), and l4_busy_wait_us().

Here is the caller graph for this function:

## l4_rdtsc_32()

l4_uint32_t l4_rdtsc_32 | ( | void |  | ) |

inline

Read the lest significant 32 bit of the TSC.

Useful for smaller differences, needs less cycles.

Definition at line 185 of file rdtsc.h.

## l4_tsc_init()

l4_uint32_t l4_tsc_init | ( | l4_kernel_info_t const * | kip | ) |

Initialize scaler for TSC calibrations from the kernel.

Initialize the scalers needed by l4_tsc_to_ns()/l4_ns_to_tsc() and so on. Use the kernel-provided frequency.

Parameters

  kip | KIP pointer

Returns
  0 on error (no scalers exported by kernel) otherwise returns (2^32 / (tsc per µsec)). This value has the same semantics as the value returned by the calibrate_delay_loop() function of the Linux kernel.

References L4_CV.

Referenced by l4_calibrate_tsc().

Here is the caller graph for this function:

## l4_tsc_to_ns()

l4_uint64_t l4_tsc_to_ns | ( | l4_cpu_time_t | tsc | ) |

inline

Convert timestamp to ns value.

Parameters

  tsc | time value in CPU ticks

Returns
  time value in ns

Examples
  examples/sys/aliens/main.c.

Definition at line 205 of file rdtsc.h.

## l4_tsc_to_s_and_ns()

void l4_tsc_to_s_and_ns | ( | l4_cpu_time_t | tsc,
|  | l4_uint32_t * | s,
|  | l4_uint32_t * | ns )

inline

Convert timestamp to s.ns value.

Parameters

  | tsc | time value in CPU ticks
  [out] | s | seconds
  [out] | ns | nano seconds

Definition at line 233 of file rdtsc.h.

## l4_tsc_to_us()

l4_uint64_t l4_tsc_to_us | ( | l4_cpu_time_t | tsc | ) |

inline

Convert timestamp into micro seconds value.

Parameters

  tsc | time value in CPU ticks

Returns
  time value in micro seconds

Definition at line 219 of file rdtsc.h.