rename init() -> runtime_init()

pull/41/head
Andre Richter 4 years ago
parent be88e5e283
commit 034e1f01d8
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

@ -10,8 +10,8 @@ Check out `make qemu` again to see the additional code run.
- `.bss`
- `_start()`:
- Halt core if core != `core0`.
- `core0` jumps to `init()` Rust function.
- `init()` in `runtime.rs`
- `core0` jumps to `runtime_init()` Rust function.
- `runtime_init()` in `runtime_init.rs`
- Zeros the `.bss` section.
- Calls `kernel_init()`, which calls `panic!()`, which eventually halts
`core0` as well.
@ -47,7 +47,7 @@ diff -uNr 01_wait_forever/src/arch/aarch64/start.S 02_runtime_init/src/arch/aarc
+ ldr x1, =_start // Load address of function "_start()"
+ mov sp, x1 // Set start of stack to before our code, aka first
+ // address before "_start()"
+ bl init // Jump to the "init()" kernel function
+ bl runtime_init // Jump to the "runtime_init()" kernel function
+ b 1b // We should never reach here. But just in case,
+ // park this core aswell
@ -86,7 +86,7 @@ diff -uNr 01_wait_forever/src/main.rs 02_runtime_init/src/main.rs
// the first function to run.
mod arch;
+// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
+// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
+mod runtime_init;
+
// Conditionally includes the selected `BSP` code.
@ -121,7 +121,7 @@ diff -uNr 01_wait_forever/src/runtime_init.rs 02_runtime_init/src/runtime_init.r
+///
+/// - Only a single core must be active and running this function.
+#[no_mangle]
+pub unsafe extern "C" fn init() -> ! {
+pub unsafe extern "C" fn runtime_init() -> ! {
+ extern "C" {
+ // Boundaries of the .bss section, provided by the linker script.
+ static mut __bss_start: u64;

@ -16,6 +16,6 @@ _start:
ldr x1, =_start // Load address of function "_start()"
mov sp, x1 // Set start of stack to before our code, aka first
// address before "_start()"
bl init // Jump to the "init()" kernel function
bl runtime_init // Jump to the "runtime_init()" kernel function
b 1b // We should never reach here. But just in case,
// park this core aswell

@ -16,7 +16,7 @@
// the first function to run.
mod arch;
// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
mod runtime_init;
// Conditionally includes the selected `BSP` code.

@ -11,7 +11,7 @@
///
/// - Only a single core must be active and running this function.
#[no_mangle]
pub unsafe extern "C" fn init() -> ! {
pub unsafe extern "C" fn runtime_init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

@ -16,6 +16,6 @@ _start:
ldr x1, =_start // Load address of function "_start()"
mov sp, x1 // Set start of stack to before our code, aka first
// address before "_start()"
bl init // Jump to the "init()" kernel function
bl runtime_init // Jump to the "runtime_init()" kernel function
b 1b // We should never reach here. But just in case,
// park this core aswell

@ -30,7 +30,7 @@
// the first function to run.
mod arch;
// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
mod runtime_init;
// Conditionally includes the selected `BSP` code.

@ -11,7 +11,7 @@
///
/// - Only a single core must be active and running this function.
#[no_mangle]
pub unsafe extern "C" fn init() -> ! {
pub unsafe extern "C" fn runtime_init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

@ -50,7 +50,7 @@ diff -uNr 03_hacky_hello_world/src/arch/aarch64/start.S 04_zero_overhead_abstrac
- ldr x1, =_start // Load address of function "_start()"
- mov sp, x1 // Set start of stack to before our code, aka first
- // address before "_start()"
- bl init // Jump to the "init()" kernel function
- bl runtime_init // Jump to the "runtime_init()" kernel function
- b 1b // We should never reach here. But just in case,
- // park this core aswell
@ -78,7 +78,7 @@ diff -uNr 03_hacky_hello_world/src/arch/aarch64.rs 04_zero_overhead_abstraction/
+
+ if bsp::BOOT_CORE_ID == MPIDR_EL1.get() & CORE_MASK {
+ SP.set(bsp::BOOT_CORE_STACK_START);
+ crate::runtime_init::init()
+ crate::runtime_init::runtime_init()
+ } else {
+ // If not core0, infinitely wait for events.
+ wait_forever()
@ -150,8 +150,8 @@ diff -uNr 03_hacky_hello_world/src/runtime_init.rs 04_zero_overhead_abstraction/
///
/// - Only a single core must be active and running this function.
-#[no_mangle]
-pub unsafe extern "C" fn init() -> ! {
+pub unsafe fn init() -> ! {
-pub unsafe extern "C" fn runtime_init() -> ! {
+pub unsafe fn runtime_init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

@ -20,7 +20,7 @@ pub unsafe extern "C" fn _start() -> ! {
if bsp::BOOT_CORE_ID == MPIDR_EL1.get() & CORE_MASK {
SP.set(bsp::BOOT_CORE_STACK_START);
crate::runtime_init::init()
crate::runtime_init::runtime_init()
} else {
// If not core0, infinitely wait for events.
wait_forever()

@ -28,7 +28,7 @@
// the first function to run.
mod arch;
// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
mod runtime_init;
// Conditionally includes the selected `BSP` code.

@ -10,7 +10,7 @@
/// # Safety
///
/// - Only a single core must be active and running this function.
pub unsafe fn init() -> ! {
pub unsafe fn runtime_init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

@ -22,7 +22,7 @@ pub unsafe extern "C" fn _start() -> ! {
if bsp::BOOT_CORE_ID == MPIDR_EL1.get() & CORE_MASK {
SP.set(bsp::BOOT_CORE_STACK_START);
crate::runtime_init::init()
crate::runtime_init::runtime_init()
} else {
// If not core0, infinitely wait for events.
wait_forever()

@ -29,7 +29,7 @@
// the first function to run.
mod arch;
// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
mod runtime_init;
// Conditionally includes the selected `BSP` code.

@ -10,7 +10,7 @@
/// # Safety
///
/// - Only a single core must be active and running this function.
pub unsafe fn init() -> ! {
pub unsafe fn runtime_init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

@ -22,7 +22,7 @@ pub unsafe extern "C" fn _start() -> ! {
if bsp::BOOT_CORE_ID == MPIDR_EL1.get() & CORE_MASK {
SP.set(bsp::BOOT_CORE_STACK_START);
crate::runtime_init::init()
crate::runtime_init::runtime_init()
} else {
// If not core0, infinitely wait for events.
wait_forever()

@ -29,7 +29,7 @@
// the first function to run.
mod arch;
// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
mod runtime_init;
// Conditionally includes the selected `BSP` code.

@ -10,7 +10,7 @@
/// # Safety
///
/// - Only a single core must be active and running this function.
pub unsafe fn init() -> ! {
pub unsafe fn runtime_init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

@ -153,7 +153,7 @@ diff -uNr 06_drivers_gpio_uart/src/arch/aarch64.rs 07_uart_chainloader/src/arch/
if bsp::BOOT_CORE_ID == MPIDR_EL1.get() & CORE_MASK {
SP.set(bsp::BOOT_CORE_STACK_START);
- crate::runtime_init::init()
- crate::runtime_init::runtime_init()
+ crate::relocate::relocate_self::<u64>()
} else {
// If not core0, infinitely wait for events.
@ -289,11 +289,11 @@ diff -uNr 06_drivers_gpio_uart/src/main.rs 07_uart_chainloader/src/main.rs
// the first function to run.
mod arch;
-// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
-// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
+// `_start()` then calls `relocate::relocate_self()`.
+mod relocate;
+
+// `relocate::relocate_self()` calls `runtime_init::init()`, which on completion, jumps to
+// `relocate::relocate_self()` calls `runtime_init()`, which on completion, jumps to
+// `kernel_init()`.
mod runtime_init;
@ -412,7 +412,7 @@ diff -uNr 06_drivers_gpio_uart/src/relocate.rs 07_uart_chainloader/src/relocate.
+ // Call `init()` through a trait object, causing the jump to use an absolute address to reach
+ // the relocated binary. An elaborate explanation can be found in the runtime_init.rs source
+ // comments.
+ crate::runtime_init::get().init()
+ crate::runtime_init::get().runtime_init()
+}
diff -uNr 06_drivers_gpio_uart/src/runtime_init.rs 07_uart_chainloader/src/runtime_init.rs
@ -433,7 +433,7 @@ diff -uNr 06_drivers_gpio_uart/src/runtime_init.rs 07_uart_chainloader/src/runti
-/// # Safety
-///
-/// - Only a single core must be active and running this function.
-pub unsafe fn init() -> ! {
-pub unsafe fn runtime_init() -> ! {
- extern "C" {
- // Boundaries of the .bss section, provided by the linker script.
- static mut __bss_start: u64;
@ -447,7 +447,7 @@ diff -uNr 06_drivers_gpio_uart/src/runtime_init.rs 07_uart_chainloader/src/runti
+ /// # Safety
+ ///
+ /// - Only a single core must be active and running this function.
+ unsafe fn init(&self) -> ! {
+ unsafe fn runtime_init(&self) -> ! {
+ extern "C" {
+ // Boundaries of the .bss section, provided by the linker script.
+ static mut __bss_start: u64;

@ -32,7 +32,7 @@ mod arch;
// `_start()` then calls `relocate::relocate_self()`.
mod relocate;
// `relocate::relocate_self()` calls `runtime_init::init()`, which on completion, jumps to
// `relocate::relocate_self()` calls `runtime_init()`, which on completion, jumps to
// `kernel_init()`.
mod runtime_init;

@ -42,5 +42,5 @@ pub unsafe fn relocate_self<T>() -> ! {
// Call `init()` through a trait object, causing the jump to use an absolute address to reach
// the relocated binary. An elaborate explanation can be found in the runtime_init.rs source
// comments.
crate::runtime_init::get().init()
crate::runtime_init::get().runtime_init()
}

@ -19,7 +19,7 @@ pub trait RunTimeInit {
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn init(&self) -> ! {
unsafe fn runtime_init(&self) -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

@ -202,7 +202,7 @@ diff -uNr 07_uart_chainloader/src/arch/aarch64.rs 08_timestamps/src/arch/aarch64
if bsp::BOOT_CORE_ID == MPIDR_EL1.get() & CORE_MASK {
SP.set(bsp::BOOT_CORE_STACK_START);
- crate::relocate::relocate_self::<u64>()
+ crate::runtime_init::init()
+ crate::runtime_init::runtime_init()
} else {
// If not core0, infinitely wait for events.
wait_forever()
@ -340,9 +340,9 @@ diff -uNr 07_uart_chainloader/src/main.rs 08_timestamps/src/main.rs
-// `_start()` then calls `relocate::relocate_self()`.
-mod relocate;
-
-// `relocate::relocate_self()` calls `runtime_init::init()`, which on completion, jumps to
-// `relocate::relocate_self()` calls `runtime_init()`, which on completion, jumps to
-// `kernel_init()`.
+// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
+// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
mod runtime_init;
// Conditionally includes the selected `BSP` code.
@ -539,7 +539,7 @@ diff -uNr 07_uart_chainloader/src/relocate.rs 08_timestamps/src/relocate.rs
- // Call `init()` through a trait object, causing the jump to use an absolute address to reach
- // the relocated binary. An elaborate explanation can be found in the runtime_init.rs source
- // comments.
- crate::runtime_init::get().init()
- crate::runtime_init::get().runtime_init()
-}
diff -uNr 07_uart_chainloader/src/runtime_init.rs 08_timestamps/src/runtime_init.rs
@ -566,7 +566,7 @@ diff -uNr 07_uart_chainloader/src/runtime_init.rs 08_timestamps/src/runtime_init
- /// # Safety
- ///
- /// - Only a single core must be active and running this function.
- unsafe fn init(&self) -> ! {
- unsafe fn runtime_init(&self) -> ! {
- extern "C" {
- // Boundaries of the .bss section, provided by the linker script.
- static mut __bss_start: u64;
@ -580,7 +580,7 @@ diff -uNr 07_uart_chainloader/src/runtime_init.rs 08_timestamps/src/runtime_init
+/// # Safety
+///
+/// - Only a single core must be active and running this function.
+pub unsafe fn init() -> ! {
+pub unsafe fn runtime_init() -> ! {
+ extern "C" {
+ // Boundaries of the .bss section, provided by the linker script.
+ static mut __bss_start: u64;

@ -23,7 +23,7 @@ pub unsafe extern "C" fn _start() -> ! {
if bsp::BOOT_CORE_ID == MPIDR_EL1.get() & CORE_MASK {
SP.set(bsp::BOOT_CORE_STACK_START);
crate::runtime_init::init()
crate::runtime_init::runtime_init()
} else {
// If not core0, infinitely wait for events.
wait_forever()

@ -29,7 +29,7 @@
// the first function to run.
mod arch;
// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
mod runtime_init;
// Conditionally includes the selected `BSP` code.

@ -10,7 +10,7 @@
/// # Safety
///
/// - Only a single core must be active and running this function.
pub unsafe fn init() -> ! {
pub unsafe fn runtime_init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

@ -23,7 +23,7 @@ pub unsafe extern "C" fn _start() -> ! {
if bsp::BOOT_CORE_ID == MPIDR_EL1.get() & CORE_MASK {
SP.set(bsp::BOOT_CORE_STACK_START);
crate::runtime_init::init()
crate::runtime_init::runtime_init()
} else {
// If not core0, infinitely wait for events.
wait_forever()

@ -29,7 +29,7 @@
// the first function to run.
mod arch;
// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
mod runtime_init;
// Conditionally includes the selected `BSP` code.

@ -10,7 +10,7 @@
/// # Safety
///
/// - Only a single core must be active and running this function.
pub unsafe fn init() -> ! {
pub unsafe fn runtime_init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

@ -280,7 +280,7 @@ diff -uNr 09_hw_debug_JTAG/src/arch/aarch64.rs 10_privilege_level/src/arch/aarch
- if bsp::BOOT_CORE_ID == MPIDR_EL1.get() & CORE_MASK {
- SP.set(bsp::BOOT_CORE_STACK_START);
- crate::runtime_init::init()
- crate::runtime_init::runtime_init()
+ // Expect the boot core to start in EL2.
+ if (bsp::BOOT_CORE_ID == MPIDR_EL1.get() & CORE_MASK)
+ && (CurrentEL.get() == CurrentEL::EL::EL2.value)
@ -322,7 +322,7 @@ diff -uNr 09_hw_debug_JTAG/src/arch/aarch64.rs 10_privilege_level/src/arch/aarch
+ );
+
+ // Second, let the link register point to init().
+ ELR_EL2.set(crate::runtime_init::init as *const () as u64);
+ ELR_EL2.set(crate::runtime_init::runtime_init as *const () as u64);
+
+ // Set up SP_EL1 (stack pointer), which will be used by EL1 once we "return" to it.
+ SP_EL1.set(bsp::BOOT_CORE_STACK_START);

@ -63,7 +63,7 @@ unsafe fn el2_to_el1_transition() -> ! {
);
// Second, let the link register point to init().
ELR_EL2.set(crate::runtime_init::init as *const () as u64);
ELR_EL2.set(crate::runtime_init::runtime_init as *const () as u64);
// Set up SP_EL1 (stack pointer), which will be used by EL1 once we "return" to it.
SP_EL1.set(bsp::BOOT_CORE_STACK_START);

@ -29,7 +29,7 @@
// the first function to run.
mod arch;
// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
mod runtime_init;
// Conditionally includes the selected `BSP` code.

@ -10,7 +10,7 @@
/// # Safety
///
/// - Only a single core must be active and running this function.
pub unsafe fn init() -> ! {
pub unsafe fn runtime_init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

@ -64,7 +64,7 @@ unsafe fn el2_to_el1_transition() -> ! {
);
// Second, let the link register point to init().
ELR_EL2.set(crate::runtime_init::init as *const () as u64);
ELR_EL2.set(crate::runtime_init::runtime_init as *const () as u64);
// Set up SP_EL1 (stack pointer), which will be used by EL1 once we "return" to it.
SP_EL1.set(bsp::BOOT_CORE_STACK_START);

@ -31,7 +31,7 @@
// the first function to run.
mod arch;
// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
mod runtime_init;
// Conditionally includes the selected `BSP` code.

@ -10,7 +10,7 @@
/// # Safety
///
/// - Only a single core must be active and running this function.
pub unsafe fn init() -> ! {
pub unsafe fn runtime_init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

@ -64,7 +64,7 @@ unsafe fn el2_to_el1_transition() -> ! {
);
// Second, let the link register point to init().
ELR_EL2.set(crate::runtime_init::init as *const () as u64);
ELR_EL2.set(crate::runtime_init::runtime_init as *const () as u64);
// Set up SP_EL1 (stack pointer), which will be used by EL1 once we "return" to it.
SP_EL1.set(bsp::BOOT_CORE_STACK_START);

@ -32,7 +32,7 @@
// the first function to run.
mod arch;
// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
mod runtime_init;
// Conditionally includes the selected `BSP` code.

@ -10,7 +10,7 @@
/// # Safety
///
/// - Only a single core must be active and running this function.
pub unsafe fn init() -> ! {
pub unsafe fn runtime_init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

@ -23,7 +23,7 @@ pub unsafe extern "C" fn _start() -> ! {
if bsp::BOOT_CORE_ID == MPIDR_EL1.get() & CORE_MASK {
SP.set(bsp::BOOT_CORE_STACK_START);
crate::runtime_init::init()
crate::runtime_init::runtime_init()
} else {
// if not core0, infinitely wait for events
wait_forever()

@ -29,7 +29,7 @@
// the first function to run.
mod arch;
// `_start()` then calls `runtime_init::init()`, which on completion, jumps to `kernel_init()`.
// `_start()` then calls `runtime_init()`, which on completion, jumps to `kernel_init()`.
mod runtime_init;
// Conditionally includes the selected `BSP` code.

@ -10,7 +10,7 @@
/// # Safety
///
/// - Only a single core must be active and running this function.
pub unsafe fn init() -> ! {
pub unsafe fn runtime_init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;

Loading…
Cancel
Save