CardSight 0.1.0
C API reference for the CardSight firmware and application
Loading...
Searching...
No Matches
init.h File Reference

Init calls: functions that run in order after the kernel is up. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  initcall
 One entry of the .initcall linker section. More...

Macros

#define INITCALL(_level, _priority, _fn)
 Register a function as an init call.

Typedefs

typedef int(* initcall_fn) (void)
 Signature of an init call.

Functions

void initcalls_run (uint32_t level)
 Run every init call of one level.

Detailed Description

Init calls: functions that run in order after the kernel is up.

Levels 0 and 1 run on the boot stack before the scheduler starts; levels 2 and 3 run from the boot task. Within a level a lower priority number runs first.

Macro Definition Documentation

◆ INITCALL

#define INITCALL ( _level,
_priority,
_fn )
Value:
static const struct initcall __initcall_##_fn __attribute__((used, section(".initcall"))) = { \
.function = (_fn), \
.level = (_level), \
.priority = (_priority), \
}
One entry of the .initcall linker section.
Definition init.h:25

Register a function as an init call.

Places a static struct initcall in the .initcall section, which initcalls_run() walks. The symbol is named after _fn and kept even when nothing references it.

Parameters
_levelInit level (0 to 3).
_priorityOrder within the level; lower runs first.
_fnFunction with the initcall_fn signature.

Typedef Documentation

◆ initcall_fn

typedef int(* initcall_fn) (void)

Signature of an init call.

Returns
0 on success, or a negative errno; the runner ignores the value.

Function Documentation

◆ initcalls_run()

void initcalls_run ( uint32_t level)

Run every init call of one level.

Walks priorities from 0 to 255 and, for each, the whole .initcall section, calling the entries whose level and priority match. Return values are ignored.

Parameters
[in]levelInit level to run.