From 53c1163c51931ac5c58da03cffeb46ada2486f22 Mon Sep 17 00:00:00 2001 From: Andre Richter Date: Sun, 27 Dec 2020 00:20:24 +0100 Subject: [PATCH] 01: Remove LTO to fix linking bug. For some reason, LTO caused "_start" to start at 0x00080020 instead of 0x00080000. --- 01_wait_forever/Cargo.toml | 3 -- 01_wait_forever/src/_arch/aarch64/cpu.rs | 18 -------- 01_wait_forever/src/panic_wait.rs | 4 +- 02_runtime_init/README.md | 57 ++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 23 deletions(-) diff --git a/01_wait_forever/Cargo.toml b/01_wait_forever/Cargo.toml index 0f798fcb..0595aa57 100644 --- a/01_wait_forever/Cargo.toml +++ b/01_wait_forever/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[profile.release] -lto = true - # The features section is used to select the target board. [features] default = [] diff --git a/01_wait_forever/src/_arch/aarch64/cpu.rs b/01_wait_forever/src/_arch/aarch64/cpu.rs index 1d3e871a..12837a3b 100644 --- a/01_wait_forever/src/_arch/aarch64/cpu.rs +++ b/01_wait_forever/src/_arch/aarch64/cpu.rs @@ -6,21 +6,3 @@ // Assembly counterpart to this file. global_asm!(include_str!("cpu.S")); - -//-------------------------------------------------------------------------------------------------- -// Public Code -//-------------------------------------------------------------------------------------------------- - -/// Pause execution on the core. -#[inline(always)] -pub fn wait_forever() -> ! { - unsafe { - loop { - #[rustfmt::skip] - asm!( - "wfe", - options(nomem, nostack, preserves_flags) - ); - } - } -} diff --git a/01_wait_forever/src/panic_wait.rs b/01_wait_forever/src/panic_wait.rs index 560a1724..0a70c721 100644 --- a/01_wait_forever/src/panic_wait.rs +++ b/01_wait_forever/src/panic_wait.rs @@ -4,10 +4,10 @@ //! A panic handler that infinitely waits. -use crate::cpu; +// use crate::cpu; use core::panic::PanicInfo; #[panic_handler] fn panic(_info: &PanicInfo) -> ! { - cpu::wait_forever() + unimplemented!() } diff --git a/02_runtime_init/README.md b/02_runtime_init/README.md index e54520cd..75a6fa1b 100644 --- a/02_runtime_init/README.md +++ b/02_runtime_init/README.md @@ -23,6 +23,46 @@ ## Diff to previous ```diff +diff -uNr 01_wait_forever/Cargo.toml 02_runtime_init/Cargo.toml +--- 01_wait_forever/Cargo.toml ++++ 02_runtime_init/Cargo.toml +@@ -4,6 +4,9 @@ + authors = ["Andre Richter "] + edition = "2018" + ++[profile.release] ++lto = true ++ + # The features section is used to select the target board. + [features] + default = [] + +diff -uNr 01_wait_forever/src/_arch/aarch64/cpu.rs 02_runtime_init/src/_arch/aarch64/cpu.rs +--- 01_wait_forever/src/_arch/aarch64/cpu.rs ++++ 02_runtime_init/src/_arch/aarch64/cpu.rs +@@ -6,3 +6,21 @@ + + // Assembly counterpart to this file. + global_asm!(include_str!("cpu.S")); ++ ++//-------------------------------------------------------------------------------------------------- ++// Public Code ++//-------------------------------------------------------------------------------------------------- ++ ++/// Pause execution on the core. ++#[inline(always)] ++pub fn wait_forever() -> ! { ++ unsafe { ++ loop { ++ #[rustfmt::skip] ++ asm!( ++ "wfe", ++ options(nomem, nostack, preserves_flags) ++ ); ++ } ++ } ++} + diff -uNr 01_wait_forever/src/_arch/aarch64/cpu.S 02_runtime_init/src/_arch/aarch64/cpu.S --- 01_wait_forever/src/_arch/aarch64/cpu.S +++ 02_runtime_init/src/_arch/aarch64/cpu.S @@ -191,6 +231,23 @@ diff -uNr 01_wait_forever/src/memory.rs 02_runtime_init/src/memory.rs + } +} +diff -uNr 01_wait_forever/src/panic_wait.rs 02_runtime_init/src/panic_wait.rs +--- 01_wait_forever/src/panic_wait.rs ++++ 02_runtime_init/src/panic_wait.rs +@@ -4,10 +4,10 @@ + + //! A panic handler that infinitely waits. + +-// use crate::cpu; ++use crate::cpu; + use core::panic::PanicInfo; + + #[panic_handler] + fn panic(_info: &PanicInfo) -> ! { +- unimplemented!() ++ cpu::wait_forever() + } + diff -uNr 01_wait_forever/src/runtime_init.rs 02_runtime_init/src/runtime_init.rs --- 01_wait_forever/src/runtime_init.rs +++ 02_runtime_init/src/runtime_init.rs