Loading...
Searching...
No Matches
Utility Functions

Utilities, generic file. More...

Collaboration diagram for Utility Functions:

## Topics

| CPU related functions
| Timestamp Counter
| Atomic Instructions
| Internal functions
| Bit Manipulation
| ELF binary format
| Functions and types related to ELF binaries.
| Kernel Interface Page API
| Comfortable Command Line Parsing
| Random number support
| Low-Level Thread Functions
| IA32 Port I/O API

## Files

file | rand.h
| Simple Pseudo-Random Number Generator.

## Functions

L4_BEGIN_DECLS long | l4util_splitlog2_hdl (l4_addr_t start, l4_addr_t end, long(*handler)(l4_addr_t s, l4_addr_t e, int log2size))
| Split a range into log2 base and size aligned chunks.
l4_addr_t | l4util_splitlog2_size (l4_addr_t start, l4_addr_t end)
| Return log2 base and size aligned length of a range.
L4_BEGIN_DECLS l4_timeout_s | l4util_micros2l4to (l4_uint64_t us) L4_NOTHROW
| Calculate l4 timeouts.
void | l4_sleep (l4_uint32_t ms) L4_NOTHROW
| Suspend thread for a period of ms milliseconds.
void | l4_usleep (l4_uint64_t us) L4_NOTHROW
| Suspend thread for a period of us microseconds.
void | l4_sleep_forever (void) L4_NOTHROW L4_NORETURN
| Go sleep and never wake up.
void | l4_touch_ro (const void *addr, unsigned size) L4_NOTHROW
| Touch data area to force mapping (read-only).
void | l4_touch_rw (const void *addr, unsigned size) L4_NOTHROW
| Touch data areas to force mapping (read-write).

## Detailed Description

Utilities, generic file.

## Function Documentation

## l4_sleep()

void l4_sleep | ( | l4_uint32_t | ms | ) |

Suspend thread for a period of ms milliseconds.

Parameters

  ms | Time in milliseconds

Examples
  examples/libs/libirq/async_isr.c, examples/sys/aliens/main.c, examples/sys/singlestep/main.c, and examples/sys/start-with-exc/main.c.

References L4_CV, and L4_NOTHROW.

Referenced by L4Re::Namespace::query().

Here is the caller graph for this function:

## l4_touch_ro()

void l4_touch_ro | ( | const void * | addr,
|  | unsigned | size )

inline

Touch data area to force mapping (read-only).

Parameters

  addr | Start of memory area to touch.
  size | Size of area to touch.

Examples
  examples/sys/singlestep/main.c.

Definition at line 92 of file util.h.

References L4_NOTHROW, L4_PAGESIZE, and l4_trunc_page().

Here is the call graph for this function:

## l4_touch_rw()

void l4_touch_rw | ( | const void * | addr,
|  | unsigned | size )

inline

Touch data areas to force mapping (read-write).

Parameters

  addr | Start of memory area to touch.
  size | Size of area to touch.

Examples
  examples/sys/aliens/main.c, and examples/sys/singlestep/main.c.

Definition at line 105 of file util.h.

References L4_NOTHROW, L4_PAGESIZE, and l4_trunc_page().

Here is the call graph for this function:

## l4_usleep()

void l4_usleep | ( | l4_uint64_t | us | ) |

Suspend thread for a period of us microseconds.

Parameters

  us | Time in microseconds

Note
  The timer resolution of L4 kernels is usually 1ms.

References L4_CV, L4_INLINE, L4_NORETURN, and L4_NOTHROW.

## l4util_micros2l4to()

L4_BEGIN_DECLS l4_timeout_s l4util_micros2l4to | ( | l4_uint64_t | us | ) |

Calculate l4 timeouts.

Parameters

  us

  time in microseconds. Special cases:
  - 0 - > timeout 0
  - ~0U -> timeout NEVER

Returns
  the corresponding l4_timeout value

Deprecated
  Use l4_timeout_from_us().

References L4_CV, and L4_NOTHROW.

## l4util_splitlog2_hdl()

L4_END_DECLS long l4util_splitlog2_hdl | ( | l4_addr_t | start,
|  | l4_addr_t | end,
|  | long(* | handler )(l4_addr_t s, l4_addr_t e, int log2size) )

inline

Split a range into log2 base and size aligned chunks.

Parameters

  start | Start of range
  end | End of range (inclusive) (e.g. 2-4 is len 3)
  handler | Handler function that is called with start and end (both inclusive) of the chunk. On success, the handler must return 0, if it returns !=0 the function will immediately return with the return code of the handler.

Returns
  0 on success, != 0 otherwise

Definition at line 51 of file splitlog2.h.

References L4_EINVAL, and l4util_splitlog2_size().

Here is the call graph for this function:

## l4util_splitlog2_size()

l4_addr_t l4util_splitlog2_size | ( | l4_addr_t | start,
|  | l4_addr_t | end )

inline

Return log2 base and size aligned length of a range.

Parameters

  start | Start of range
  end | End of range (inclusive) (e.g. 2-4 is len 3)

Returns
  length of elements in log2size (length is 1 << log2size)

Definition at line 70 of file splitlog2.h.

Referenced by l4util_splitlog2_hdl().

Here is the caller graph for this function: