Boot Flow
Categories:
2 minute read
XWOS Boot Flow
flowchart LR
Pre-initialization --> Initialization --> Post-initialization --> Main
subgraph Pre-initialization
direction TB
exc["Exception Init"]
exc["FPU Init"]
exc["Memory Init"]
end
subgraph Initialization
xwos_init["xwos_init()"]
end
subgraph Post-initialization
direction LR
device["Device Driver Init"]
mm["Dynamic Allocator Init"]
end
subgraph Main
direction LR
skd_init["Init Scheduler: xwos_skd_init_lc()"]
thd["Create Threads"]
skd_start["Start Scheduler: xwos_skd_start_lc()"]
end
XWOS divides the initialization flow into four phases:
- Pre-initialization Phase (user-defined):
xwos_preinit() - Initialization Phase (XWOS-defined):
xwos_init() - Post-initialization Phase (user-defined):
xwos_postinit() - Main Function Phase (user-defined):
xwos_main()
Pre-initialization Phase
In the pre-initialization phase, the user must provide the function definition: void xwos_preinit(void):
- Low-level CPU architecture initialization must be completed, e.g., interrupt initialization, floating-point unit initialization, etc.
- Memory initialization and data section relocation must be completed.
Initialization Phase
The initialization phase function void xwos_init(void) is defined by XWOS and initializes the XWOS kernel. Users must not redefine this function.
xwos_init() accesses global variables, so memory initialization and data section relocation must be completed in the Pre-initialization Phase.
In multi-core systems, xwos_init() is called once in each CPU’s initialization flow.
Post-initialization Phase
In the post-initialization phase, the user must provide the function definition: void xwos_postinit(void):
- The user may choose to complete driver initialization in this phase;
- The user may choose to complete dynamic memory allocator initialization in this phase;
Main Function Phase
- The user may choose to complete driver initialization in this phase;
- The user may choose to complete dynamic memory allocator initialization in this phase;
- The user must create threads in this phase;
- The user must call
xwos_skd_start_lc()in this phase to start the scheduler.
User-defined Boot Flow
If the user uses a custom boot flow, xwos_init() must be called before calling any XWOS API.
This function accesses global variables and must be called only after data section relocation is complete.
In multi-core systems, xwos_init() must be called once in each CPU’s initialization flow.
Custom Boot Flow Example
TODO