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 #[cfg(feature = "smp")]
36 fn init_early_secondary(cpu_id: usize);
37
38 /// Initializes the platform at the later stage for the primary core.
39 ///
40 /// This function should be called after the kernel has done part of its
41 /// initialization (e.g, logging, memory management), and finalized the rest of
42 /// platform configuration and initialization.
43 ///
44 /// # Arguments
45 ///
46 /// * `cpu_id` is the logical CPU ID (0, 1, ..., N-1, N is the number of CPU
47 /// cores on the platform).
48 /// * `arg` is passed from the bootloader (typically the device tree blob
49 /// address).
50 ///
51 /// # Before calling this function
52 ///
53 /// * Kernel logging is initialized.
54 /// * Fine-grained kernel page table is set up (if applicable).
55 /// * Physical memory allocation is initialized (if applicable).
56 ///
57 /// # After calling this function
58 ///
59 /// * Interrupt controller is initialized (if applicable).
60 /// * Timer interrupts are enabled (if applicable).
61 /// * Other essential peripherals are initialized.
62 fn init_later(cpu_id: usize, arg: usize);
63
64 /// Initializes the platform at the later stage for secondary cores.
65 ///
66 /// See [`init_later`] for details.
67 #[cfg(feature = "smp")]
68 fn init_later_secondary(cpu_id: usize);
69}