My Kernel v0.1.0
init.h
1#ifndef KERNEL_INIT_H
2#define KERNEL_INIT_H
3
4#include <kernel/error.h>
5
6#include <utils/compiler.h>
7
8/*
9 * Those functions are called as the very first thing during the startup phase.
10 * They are called with interrupts disabled, paging disabled and no way to
11 * allocate virtual memory.
12 */
13#define INIT_BOOTSTRAP bootstrap
14
15/*
16 * Called after the bootstrap phase. Interrupts and virtual memory management
17 * is already configured at this stage, but interrupts are stil disabled.
18 */
19#define INIT_EARLY early
20
21/*
22 */
23#define INIT_NORMAL normal
24#define INIT_LATE late
25
26#define INIT_STEPS \
27 INIT_BOOTSTRAP, \
28 INIT_EARLY, \
29 INIT_NORMAL, \
30 INIT_LATE
31
32enum init_step {
33 INIT_STEP_BOOTSTRAP,
34 INIT_STEP_EARLY,
35 INIT_STEP_NORMAL,
36 INIT_STEP_LATE
37};
38
39struct initcall {
40 const char *name;
41 error_t (*call)(void);
42};
43
50 struct initcall *start;
51 struct initcall *end;
52};
53
54#define DECLARE_INITCALL(_step, _function) \
55 MAYBE_UNUSED \
56 SECTION(".data.init." stringify(_step)) \
57 static struct initcall __init_##_function = { \
58 .name = stringify(_function), \
59 .call = _function, \
60 }
61
63void initcall_do_level(enum init_step);
64
65#endif /* KERNEL_INIT_H */
Initcalls from the same step are placed in a section together by the linkerscript.
Definition: init.h:49