axplat/init.rs
1//! Platform initialization.
2
3/// Platform initialization interface.
4#[def_plat_interface]
5pub trait InitIf {
6 /// Initializes the platform at the early stage for the primary core.
7 ///
8 /// This function should be called immediately after the kernel has booted,
9 /// and performed earliest platform configuration and initialization (e.g.,
10 /// early console, clocking).
11 ///
12 /// # Arguments
13 ///
14 /// * `cpu_id` is the logical CPU ID (0, 1, ..., N-1, N is the number of CPU
15 /// cores on the platform).
16 /// * `arg` is passed from the bootloader (typically the device tree blob
17 /// address).
18 ///
19 /// # Before calling this function
20 ///
21 /// * CPU is booted in the kernel mode.
22 /// * Early page table is set up, virtual memory is enabled.
23 /// * CPU-local data is initialized.
24 ///
25 /// # After calling this function
26 ///
27 /// * Exception & interrupt handlers are set up.
28 /// * Early console is initialized.
29 /// * Current monotonic time and wall time can be obtained.
30 fn init_early(cpu_id: usize, arg: usize);
31
32 /// Initializes the platform at the early stage for secondary cores.
33 ///
34 /// See [`init_early`] for details.
35 fn init_early_secondary(cpu_id: usize);
36
37 /// Initializes the platform at the later stage for the primary core.
38 ///
39 /// This function should be called after the kernel has done part of its
40 /// initialization (e.g, logging, memory management), and finalized the rest of
41 /// platform configuration and initialization.
42 ///
43 /// # Arguments
44 ///
45 /// * `cpu_id` is the logical CPU ID (0, 1, ..., N-1, N is the number of CPU
46 /// cores on the platform).
47 /// * `arg` is passed from the bootloader (typically the device tree blob
48 /// address).
49 ///
50 /// # Before calling this function
51 ///
52 /// * Kernel logging is initialized.
53 /// * Fine-grained kernel page table is set up (if applicable).
54 /// * Physical memory allocation is initialized (if applicable).
55 ///
56 /// # After calling this function
57 ///
58 /// * Interrupt controller is initialized (if applicable).
59 /// * Timer interrupts are enabled (if applicable).
60 /// * Other platform devices are initialized.
61 fn init_later(cpu_id: usize, arg: usize);
62
63 /// Initializes the platform at the later stage for secondary cores.
64 ///
65 /// See [`init_later`] for details.
66 fn init_later_secondary(cpu_id: usize);
67}