From 098e19ecc44b04d0a142c16742edf7cf00b5dd82 Mon Sep 17 00:00:00 2001 From: Andre Richter Date: Sun, 1 Nov 2020 21:32:53 +0100 Subject: [PATCH] Fix zero-sized bss handling --- 02_runtime_init/README.md | 23 +++++++++++------- 02_runtime_init/src/bsp/raspberrypi/link.ld | 3 +++ 02_runtime_init/src/bsp/raspberrypi/memory.rs | 8 +++++- 02_runtime_init/src/memory.rs | 6 +---- .../src/bsp/raspberrypi/link.ld | 3 +++ .../src/bsp/raspberrypi/memory.rs | 8 +++++- 03_hacky_hello_world/src/memory.rs | 6 +---- .../src/bsp/raspberrypi/link.ld | 3 +++ .../src/bsp/raspberrypi/memory.rs | 8 +++++- 04_zero_overhead_abstraction/src/memory.rs | 6 +---- 05_safe_globals/src/bsp/raspberrypi/link.ld | 3 +++ 05_safe_globals/src/bsp/raspberrypi/memory.rs | 8 +++++- 05_safe_globals/src/memory.rs | 6 +---- .../src/bsp/raspberrypi/link.ld | 3 +++ .../src/bsp/raspberrypi/memory.rs | 8 +++++- 06_drivers_gpio_uart/src/memory.rs | 6 +---- 07_uart_chainloader/README.md | 17 ++++++------- .../src/bsp/raspberrypi/link.ld | 3 +++ .../src/bsp/raspberrypi/memory.rs | 8 +++++- 07_uart_chainloader/src/memory.rs | 6 +---- 07_uart_chainloader/src/relocate.rs | 6 +---- 08_timestamps/README.md | 17 ++++++------- 08_timestamps/src/bsp/raspberrypi/link.ld | 3 +++ 08_timestamps/src/bsp/raspberrypi/memory.rs | 8 +++++- 08_timestamps/src/memory.rs | 6 +---- 09_hw_debug_JTAG/src/bsp/raspberrypi/link.ld | 3 +++ .../src/bsp/raspberrypi/memory.rs | 8 +++++- 09_hw_debug_JTAG/src/memory.rs | 6 +---- .../src/bsp/raspberrypi/link.ld | 3 +++ .../src/bsp/raspberrypi/memory.rs | 8 +++++- 10_privilege_level/src/memory.rs | 6 +---- .../src/bsp/raspberrypi/link.ld | 3 +++ .../src/bsp/raspberrypi/memory.rs | 8 +++++- .../src/memory.rs | 6 +---- .../src/bsp/raspberrypi/link.ld | 3 +++ .../src/bsp/raspberrypi/memory.rs | 8 +++++- 12_exceptions_part1_groundwork/src/memory.rs | 6 +---- 13_integrated_testing/README.md | 4 +-- .../src/bsp/raspberrypi/link.ld | 3 +++ .../src/bsp/raspberrypi/memory.rs | 8 +++++- 13_integrated_testing/src/memory.rs | 6 +---- .../src/bsp/raspberrypi/link.ld | 3 +++ .../src/bsp/raspberrypi/memory.rs | 8 +++++- .../src/memory.rs | 6 +---- 15_virtual_mem_part2_mmio_remap/README.md | 4 +-- .../src/bsp/raspberrypi/link.ld | 3 +++ .../src/bsp/raspberrypi/memory.rs | 8 +++++- 15_virtual_mem_part2_mmio_remap/src/memory.rs | 6 +---- X1_JTAG_boot/jtag_boot_rpi3.img | Bin 7392 -> 7512 bytes X1_JTAG_boot/jtag_boot_rpi4.img | Bin 7360 -> 7496 bytes X1_JTAG_boot/src/bsp/raspberrypi/link.ld | 3 +++ X1_JTAG_boot/src/bsp/raspberrypi/memory.rs | 8 +++++- X1_JTAG_boot/src/memory.rs | 6 +---- 53 files changed, 198 insertions(+), 128 deletions(-) diff --git a/02_runtime_init/README.md b/02_runtime_init/README.md index 72e5f84b..e54520cd 100644 --- a/02_runtime_init/README.md +++ b/02_runtime_init/README.md @@ -48,7 +48,7 @@ diff -uNr 01_wait_forever/src/_arch/aarch64/cpu.S 02_runtime_init/src/_arch/aarc diff -uNr 01_wait_forever/src/bsp/raspberrypi/link.ld 02_runtime_init/src/bsp/raspberrypi/link.ld --- 01_wait_forever/src/bsp/raspberrypi/link.ld +++ 02_runtime_init/src/bsp/raspberrypi/link.ld -@@ -13,5 +13,24 @@ +@@ -13,5 +13,27 @@ *(.text._start) *(.text*) } @@ -68,6 +68,9 @@ diff -uNr 01_wait_forever/src/bsp/raspberrypi/link.ld 02_runtime_init/src/bsp/ra + __bss_start = .; + *(.bss*); + . = ALIGN(8); ++ ++ /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ ++ . += 8; + __bss_end_inclusive = . - 8; + } + @@ -77,7 +80,7 @@ diff -uNr 01_wait_forever/src/bsp/raspberrypi/link.ld 02_runtime_init/src/bsp/ra diff -uNr 01_wait_forever/src/bsp/raspberrypi/memory.rs 02_runtime_init/src/bsp/raspberrypi/memory.rs --- 01_wait_forever/src/bsp/raspberrypi/memory.rs +++ 02_runtime_init/src/bsp/raspberrypi/memory.rs -@@ -0,0 +1,31 @@ +@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// +// Copyright (c) 2018-2020 Andre Richter @@ -107,7 +110,13 @@ diff -uNr 01_wait_forever/src/bsp/raspberrypi/memory.rs 02_runtime_init/src/bsp/ +/// - Values are provided by the linker script and must be trusted as-is. +/// - The linker-provided addresses must be u64 aligned. +pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { -+ unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } ++ let range; ++ unsafe { ++ range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); ++ } ++ assert!(!range.is_empty()); ++ ++ range +} diff -uNr 01_wait_forever/src/bsp/raspberrypi.rs 02_runtime_init/src/bsp/raspberrypi.rs @@ -150,7 +159,7 @@ diff -uNr 01_wait_forever/src/main.rs 02_runtime_init/src/main.rs diff -uNr 01_wait_forever/src/memory.rs 02_runtime_init/src/memory.rs --- 01_wait_forever/src/memory.rs +++ 02_runtime_init/src/memory.rs -@@ -0,0 +1,34 @@ +@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// +// Copyright (c) 2018-2020 Andre Richter @@ -176,13 +185,9 @@ diff -uNr 01_wait_forever/src/memory.rs 02_runtime_init/src/memory.rs + let mut ptr = *range.start(); + let end_inclusive = *range.end(); + -+ loop { ++ while ptr <= end_inclusive { + core::ptr::write_volatile(ptr, T::from(0)); + ptr = ptr.offset(1); -+ -+ if ptr > end_inclusive { -+ break; -+ } + } +} diff --git a/02_runtime_init/src/bsp/raspberrypi/link.ld b/02_runtime_init/src/bsp/raspberrypi/link.ld index 6354a501..c03bb5e5 100644 --- a/02_runtime_init/src/bsp/raspberrypi/link.ld +++ b/02_runtime_init/src/bsp/raspberrypi/link.ld @@ -29,6 +29,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/02_runtime_init/src/bsp/raspberrypi/memory.rs b/02_runtime_init/src/bsp/raspberrypi/memory.rs index 1cac6d21..25ba9f15 100644 --- a/02_runtime_init/src/bsp/raspberrypi/memory.rs +++ b/02_runtime_init/src/bsp/raspberrypi/memory.rs @@ -27,5 +27,11 @@ extern "Rust" { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/02_runtime_init/src/memory.rs b/02_runtime_init/src/memory.rs index 77e21c0c..827b8b85 100644 --- a/02_runtime_init/src/memory.rs +++ b/02_runtime_init/src/memory.rs @@ -23,12 +23,8 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/03_hacky_hello_world/src/bsp/raspberrypi/link.ld b/03_hacky_hello_world/src/bsp/raspberrypi/link.ld index 6354a501..c03bb5e5 100644 --- a/03_hacky_hello_world/src/bsp/raspberrypi/link.ld +++ b/03_hacky_hello_world/src/bsp/raspberrypi/link.ld @@ -29,6 +29,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/03_hacky_hello_world/src/bsp/raspberrypi/memory.rs b/03_hacky_hello_world/src/bsp/raspberrypi/memory.rs index 1cac6d21..25ba9f15 100644 --- a/03_hacky_hello_world/src/bsp/raspberrypi/memory.rs +++ b/03_hacky_hello_world/src/bsp/raspberrypi/memory.rs @@ -27,5 +27,11 @@ extern "Rust" { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/03_hacky_hello_world/src/memory.rs b/03_hacky_hello_world/src/memory.rs index 77e21c0c..827b8b85 100644 --- a/03_hacky_hello_world/src/memory.rs +++ b/03_hacky_hello_world/src/memory.rs @@ -23,12 +23,8 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/04_zero_overhead_abstraction/src/bsp/raspberrypi/link.ld b/04_zero_overhead_abstraction/src/bsp/raspberrypi/link.ld index 6354a501..c03bb5e5 100644 --- a/04_zero_overhead_abstraction/src/bsp/raspberrypi/link.ld +++ b/04_zero_overhead_abstraction/src/bsp/raspberrypi/link.ld @@ -29,6 +29,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/04_zero_overhead_abstraction/src/bsp/raspberrypi/memory.rs b/04_zero_overhead_abstraction/src/bsp/raspberrypi/memory.rs index 9e1a819d..51cc958a 100644 --- a/04_zero_overhead_abstraction/src/bsp/raspberrypi/memory.rs +++ b/04_zero_overhead_abstraction/src/bsp/raspberrypi/memory.rs @@ -43,5 +43,11 @@ pub fn boot_core_stack_end() -> usize { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/04_zero_overhead_abstraction/src/memory.rs b/04_zero_overhead_abstraction/src/memory.rs index 77e21c0c..827b8b85 100644 --- a/04_zero_overhead_abstraction/src/memory.rs +++ b/04_zero_overhead_abstraction/src/memory.rs @@ -23,12 +23,8 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/05_safe_globals/src/bsp/raspberrypi/link.ld b/05_safe_globals/src/bsp/raspberrypi/link.ld index 6354a501..c03bb5e5 100644 --- a/05_safe_globals/src/bsp/raspberrypi/link.ld +++ b/05_safe_globals/src/bsp/raspberrypi/link.ld @@ -29,6 +29,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/05_safe_globals/src/bsp/raspberrypi/memory.rs b/05_safe_globals/src/bsp/raspberrypi/memory.rs index 9e1a819d..51cc958a 100644 --- a/05_safe_globals/src/bsp/raspberrypi/memory.rs +++ b/05_safe_globals/src/bsp/raspberrypi/memory.rs @@ -43,5 +43,11 @@ pub fn boot_core_stack_end() -> usize { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/05_safe_globals/src/memory.rs b/05_safe_globals/src/memory.rs index 77e21c0c..827b8b85 100644 --- a/05_safe_globals/src/memory.rs +++ b/05_safe_globals/src/memory.rs @@ -23,12 +23,8 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/06_drivers_gpio_uart/src/bsp/raspberrypi/link.ld b/06_drivers_gpio_uart/src/bsp/raspberrypi/link.ld index 6354a501..c03bb5e5 100644 --- a/06_drivers_gpio_uart/src/bsp/raspberrypi/link.ld +++ b/06_drivers_gpio_uart/src/bsp/raspberrypi/link.ld @@ -29,6 +29,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/06_drivers_gpio_uart/src/bsp/raspberrypi/memory.rs b/06_drivers_gpio_uart/src/bsp/raspberrypi/memory.rs index e23fc1d6..fae05125 100644 --- a/06_drivers_gpio_uart/src/bsp/raspberrypi/memory.rs +++ b/06_drivers_gpio_uart/src/bsp/raspberrypi/memory.rs @@ -66,5 +66,11 @@ pub fn boot_core_stack_end() -> usize { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/06_drivers_gpio_uart/src/memory.rs b/06_drivers_gpio_uart/src/memory.rs index 77e21c0c..827b8b85 100644 --- a/06_drivers_gpio_uart/src/memory.rs +++ b/06_drivers_gpio_uart/src/memory.rs @@ -23,12 +23,8 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/07_uart_chainloader/README.md b/07_uart_chainloader/README.md index 4cc07973..907b6770 100644 --- a/07_uart_chainloader/README.md +++ b/07_uart_chainloader/README.md @@ -310,7 +310,7 @@ diff -uNr 06_drivers_gpio_uart/src/bsp/raspberrypi/link.ld 07_uart_chainloader/s } .rodata : -@@ -32,5 +35,16 @@ +@@ -35,5 +38,16 @@ __bss_end_inclusive = . - 8; } @@ -357,7 +357,7 @@ diff -uNr 06_drivers_gpio_uart/src/bsp/raspberrypi/memory.rs 07_uart_chainloader /// Physical devices. #[cfg(feature = "bsp_rpi3")] -@@ -59,12 +64,34 @@ +@@ -59,13 +64,35 @@ map::BOOT_CORE_STACK_END } @@ -392,8 +392,9 @@ diff -uNr 06_drivers_gpio_uart/src/bsp/raspberrypi/memory.rs 07_uart_chainloader /// - The linker-provided addresses must be u64 aligned. -pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { +pub fn relocated_bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } - } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); diff -uNr 06_drivers_gpio_uart/src/console.rs 07_uart_chainloader/src/console.rs --- 06_drivers_gpio_uart/src/console.rs @@ -531,7 +532,7 @@ diff -uNr 06_drivers_gpio_uart/src/main.rs 07_uart_chainloader/src/main.rs diff -uNr 06_drivers_gpio_uart/src/relocate.rs 07_uart_chainloader/src/relocate.rs --- 06_drivers_gpio_uart/src/relocate.rs +++ 07_uart_chainloader/src/relocate.rs -@@ -0,0 +1,55 @@ +@@ -0,0 +1,51 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// +// Copyright (c) 2018-2020 Andre Richter @@ -561,17 +562,13 @@ diff -uNr 06_drivers_gpio_uart/src/relocate.rs 07_uart_chainloader/src/relocate. + let mut current_binary_start_addr = bsp::memory::board_default_load_addr(); + + // Copy the whole binary. -+ loop { ++ while relocated_binary_start_addr <= relocated_binary_end_addr_inclusive { + core::ptr::write_volatile( + relocated_binary_start_addr, + core::ptr::read_volatile(current_binary_start_addr), + ); + relocated_binary_start_addr = relocated_binary_start_addr.offset(1); + current_binary_start_addr = current_binary_start_addr.offset(1); -+ -+ if relocated_binary_start_addr > relocated_binary_end_addr_inclusive { -+ break; -+ } + } + + // The following function calls form a hack to achieve an "absolute jump" to diff --git a/07_uart_chainloader/src/bsp/raspberrypi/link.ld b/07_uart_chainloader/src/bsp/raspberrypi/link.ld index 1dd2403e..a6dc653a 100644 --- a/07_uart_chainloader/src/bsp/raspberrypi/link.ld +++ b/07_uart_chainloader/src/bsp/raspberrypi/link.ld @@ -32,6 +32,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/07_uart_chainloader/src/bsp/raspberrypi/memory.rs b/07_uart_chainloader/src/bsp/raspberrypi/memory.rs index 989f51b0..0af09903 100644 --- a/07_uart_chainloader/src/bsp/raspberrypi/memory.rs +++ b/07_uart_chainloader/src/bsp/raspberrypi/memory.rs @@ -93,5 +93,11 @@ pub fn relocated_runtime_init_addr() -> *const u64 { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn relocated_bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/07_uart_chainloader/src/memory.rs b/07_uart_chainloader/src/memory.rs index 77e21c0c..827b8b85 100644 --- a/07_uart_chainloader/src/memory.rs +++ b/07_uart_chainloader/src/memory.rs @@ -23,12 +23,8 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/07_uart_chainloader/src/relocate.rs b/07_uart_chainloader/src/relocate.rs index 184235de..bbedfa47 100644 --- a/07_uart_chainloader/src/relocate.rs +++ b/07_uart_chainloader/src/relocate.rs @@ -27,17 +27,13 @@ pub unsafe fn relocate_self() -> ! { let mut current_binary_start_addr = bsp::memory::board_default_load_addr(); // Copy the whole binary. - loop { + while relocated_binary_start_addr <= relocated_binary_end_addr_inclusive { core::ptr::write_volatile( relocated_binary_start_addr, core::ptr::read_volatile(current_binary_start_addr), ); relocated_binary_start_addr = relocated_binary_start_addr.offset(1); current_binary_start_addr = current_binary_start_addr.offset(1); - - if relocated_binary_start_addr > relocated_binary_end_addr_inclusive { - break; - } } // The following function calls form a hack to achieve an "absolute jump" to diff --git a/08_timestamps/README.md b/08_timestamps/README.md index b1008b50..e812e05b 100644 --- a/08_timestamps/README.md +++ b/08_timestamps/README.md @@ -301,7 +301,7 @@ diff -uNr 07_uart_chainloader/src/bsp/raspberrypi/link.ld 08_timestamps/src/bsp/ } .rodata : -@@ -35,16 +32,5 @@ +@@ -38,16 +35,5 @@ __bss_end_inclusive = . - 8; } @@ -348,7 +348,7 @@ diff -uNr 07_uart_chainloader/src/bsp/raspberrypi/memory.rs 08_timestamps/src/bs /// Physical devices. #[cfg(feature = "bsp_rpi3")] -@@ -64,34 +59,12 @@ +@@ -64,35 +59,13 @@ map::BOOT_CORE_STACK_END } @@ -383,8 +383,9 @@ diff -uNr 07_uart_chainloader/src/bsp/raspberrypi/memory.rs 08_timestamps/src/bs /// - The linker-provided addresses must be u64 aligned. -pub fn relocated_bss_range_inclusive() -> RangeInclusive<*mut u64> { +pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } - } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); diff -uNr 07_uart_chainloader/src/main.rs 08_timestamps/src/main.rs --- 07_uart_chainloader/src/main.rs @@ -586,7 +587,7 @@ diff -uNr 07_uart_chainloader/src/print.rs 08_timestamps/src/print.rs diff -uNr 07_uart_chainloader/src/relocate.rs 08_timestamps/src/relocate.rs --- 07_uart_chainloader/src/relocate.rs +++ 08_timestamps/src/relocate.rs -@@ -1,55 +0,0 @@ +@@ -1,51 +0,0 @@ -// SPDX-License-Identifier: MIT OR Apache-2.0 -// -// Copyright (c) 2018-2020 Andre Richter @@ -616,17 +617,13 @@ diff -uNr 07_uart_chainloader/src/relocate.rs 08_timestamps/src/relocate.rs - let mut current_binary_start_addr = bsp::memory::board_default_load_addr(); - - // Copy the whole binary. -- loop { +- while relocated_binary_start_addr <= relocated_binary_end_addr_inclusive { - core::ptr::write_volatile( - relocated_binary_start_addr, - core::ptr::read_volatile(current_binary_start_addr), - ); - relocated_binary_start_addr = relocated_binary_start_addr.offset(1); - current_binary_start_addr = current_binary_start_addr.offset(1); -- -- if relocated_binary_start_addr > relocated_binary_end_addr_inclusive { -- break; -- } - } - - // The following function calls form a hack to achieve an "absolute jump" to diff --git a/08_timestamps/src/bsp/raspberrypi/link.ld b/08_timestamps/src/bsp/raspberrypi/link.ld index 6354a501..c03bb5e5 100644 --- a/08_timestamps/src/bsp/raspberrypi/link.ld +++ b/08_timestamps/src/bsp/raspberrypi/link.ld @@ -29,6 +29,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/08_timestamps/src/bsp/raspberrypi/memory.rs b/08_timestamps/src/bsp/raspberrypi/memory.rs index e23fc1d6..fae05125 100644 --- a/08_timestamps/src/bsp/raspberrypi/memory.rs +++ b/08_timestamps/src/bsp/raspberrypi/memory.rs @@ -66,5 +66,11 @@ pub fn boot_core_stack_end() -> usize { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/08_timestamps/src/memory.rs b/08_timestamps/src/memory.rs index 77e21c0c..827b8b85 100644 --- a/08_timestamps/src/memory.rs +++ b/08_timestamps/src/memory.rs @@ -23,12 +23,8 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/09_hw_debug_JTAG/src/bsp/raspberrypi/link.ld b/09_hw_debug_JTAG/src/bsp/raspberrypi/link.ld index 6354a501..c03bb5e5 100644 --- a/09_hw_debug_JTAG/src/bsp/raspberrypi/link.ld +++ b/09_hw_debug_JTAG/src/bsp/raspberrypi/link.ld @@ -29,6 +29,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/09_hw_debug_JTAG/src/bsp/raspberrypi/memory.rs b/09_hw_debug_JTAG/src/bsp/raspberrypi/memory.rs index e23fc1d6..fae05125 100644 --- a/09_hw_debug_JTAG/src/bsp/raspberrypi/memory.rs +++ b/09_hw_debug_JTAG/src/bsp/raspberrypi/memory.rs @@ -66,5 +66,11 @@ pub fn boot_core_stack_end() -> usize { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/09_hw_debug_JTAG/src/memory.rs b/09_hw_debug_JTAG/src/memory.rs index 77e21c0c..827b8b85 100644 --- a/09_hw_debug_JTAG/src/memory.rs +++ b/09_hw_debug_JTAG/src/memory.rs @@ -23,12 +23,8 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/10_privilege_level/src/bsp/raspberrypi/link.ld b/10_privilege_level/src/bsp/raspberrypi/link.ld index 6354a501..c03bb5e5 100644 --- a/10_privilege_level/src/bsp/raspberrypi/link.ld +++ b/10_privilege_level/src/bsp/raspberrypi/link.ld @@ -29,6 +29,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/10_privilege_level/src/bsp/raspberrypi/memory.rs b/10_privilege_level/src/bsp/raspberrypi/memory.rs index e23fc1d6..fae05125 100644 --- a/10_privilege_level/src/bsp/raspberrypi/memory.rs +++ b/10_privilege_level/src/bsp/raspberrypi/memory.rs @@ -66,5 +66,11 @@ pub fn boot_core_stack_end() -> usize { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/10_privilege_level/src/memory.rs b/10_privilege_level/src/memory.rs index 77e21c0c..827b8b85 100644 --- a/10_privilege_level/src/memory.rs +++ b/10_privilege_level/src/memory.rs @@ -23,12 +23,8 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/11_virtual_mem_part1_identity_mapping/src/bsp/raspberrypi/link.ld b/11_virtual_mem_part1_identity_mapping/src/bsp/raspberrypi/link.ld index 2a1e27a6..5b5adbaa 100644 --- a/11_virtual_mem_part1_identity_mapping/src/bsp/raspberrypi/link.ld +++ b/11_virtual_mem_part1_identity_mapping/src/bsp/raspberrypi/link.ld @@ -32,6 +32,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/11_virtual_mem_part1_identity_mapping/src/bsp/raspberrypi/memory.rs b/11_virtual_mem_part1_identity_mapping/src/bsp/raspberrypi/memory.rs index 1eb2300d..810acd8a 100644 --- a/11_virtual_mem_part1_identity_mapping/src/bsp/raspberrypi/memory.rs +++ b/11_virtual_mem_part1_identity_mapping/src/bsp/raspberrypi/memory.rs @@ -98,5 +98,11 @@ pub fn boot_core_stack_end() -> usize { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/11_virtual_mem_part1_identity_mapping/src/memory.rs b/11_virtual_mem_part1_identity_mapping/src/memory.rs index 64c81f25..59236a12 100644 --- a/11_virtual_mem_part1_identity_mapping/src/memory.rs +++ b/11_virtual_mem_part1_identity_mapping/src/memory.rs @@ -25,12 +25,8 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/12_exceptions_part1_groundwork/src/bsp/raspberrypi/link.ld b/12_exceptions_part1_groundwork/src/bsp/raspberrypi/link.ld index 5c923a77..90d096ff 100644 --- a/12_exceptions_part1_groundwork/src/bsp/raspberrypi/link.ld +++ b/12_exceptions_part1_groundwork/src/bsp/raspberrypi/link.ld @@ -37,6 +37,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/12_exceptions_part1_groundwork/src/bsp/raspberrypi/memory.rs b/12_exceptions_part1_groundwork/src/bsp/raspberrypi/memory.rs index 1eb2300d..810acd8a 100644 --- a/12_exceptions_part1_groundwork/src/bsp/raspberrypi/memory.rs +++ b/12_exceptions_part1_groundwork/src/bsp/raspberrypi/memory.rs @@ -98,5 +98,11 @@ pub fn boot_core_stack_end() -> usize { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/12_exceptions_part1_groundwork/src/memory.rs b/12_exceptions_part1_groundwork/src/memory.rs index 64c81f25..59236a12 100644 --- a/12_exceptions_part1_groundwork/src/memory.rs +++ b/12_exceptions_part1_groundwork/src/memory.rs @@ -25,12 +25,8 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/13_integrated_testing/README.md b/13_integrated_testing/README.md index 35578a29..68460d7b 100644 --- a/13_integrated_testing/README.md +++ b/13_integrated_testing/README.md @@ -1512,8 +1512,8 @@ diff -uNr 12_exceptions_part1_groundwork/src/memory/mmu.rs 13_integrated_testing diff -uNr 12_exceptions_part1_groundwork/src/memory.rs 13_integrated_testing/src/memory.rs --- 12_exceptions_part1_groundwork/src/memory.rs +++ 13_integrated_testing/src/memory.rs -@@ -34,3 +34,40 @@ - } +@@ -30,3 +30,40 @@ + ptr = ptr.offset(1); } } + diff --git a/13_integrated_testing/src/bsp/raspberrypi/link.ld b/13_integrated_testing/src/bsp/raspberrypi/link.ld index 5c923a77..90d096ff 100644 --- a/13_integrated_testing/src/bsp/raspberrypi/link.ld +++ b/13_integrated_testing/src/bsp/raspberrypi/link.ld @@ -37,6 +37,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/13_integrated_testing/src/bsp/raspberrypi/memory.rs b/13_integrated_testing/src/bsp/raspberrypi/memory.rs index 1eb2300d..810acd8a 100644 --- a/13_integrated_testing/src/bsp/raspberrypi/memory.rs +++ b/13_integrated_testing/src/bsp/raspberrypi/memory.rs @@ -98,5 +98,11 @@ pub fn boot_core_stack_end() -> usize { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/13_integrated_testing/src/memory.rs b/13_integrated_testing/src/memory.rs index 76041890..32353d4f 100644 --- a/13_integrated_testing/src/memory.rs +++ b/13_integrated_testing/src/memory.rs @@ -25,13 +25,9 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/14_exceptions_part2_peripheral_IRQs/src/bsp/raspberrypi/link.ld b/14_exceptions_part2_peripheral_IRQs/src/bsp/raspberrypi/link.ld index 5c923a77..90d096ff 100644 --- a/14_exceptions_part2_peripheral_IRQs/src/bsp/raspberrypi/link.ld +++ b/14_exceptions_part2_peripheral_IRQs/src/bsp/raspberrypi/link.ld @@ -37,6 +37,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } diff --git a/14_exceptions_part2_peripheral_IRQs/src/bsp/raspberrypi/memory.rs b/14_exceptions_part2_peripheral_IRQs/src/bsp/raspberrypi/memory.rs index 2cf1a297..8cb07905 100644 --- a/14_exceptions_part2_peripheral_IRQs/src/bsp/raspberrypi/memory.rs +++ b/14_exceptions_part2_peripheral_IRQs/src/bsp/raspberrypi/memory.rs @@ -102,5 +102,11 @@ pub fn boot_core_stack_end() -> usize { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/14_exceptions_part2_peripheral_IRQs/src/memory.rs b/14_exceptions_part2_peripheral_IRQs/src/memory.rs index 76041890..32353d4f 100644 --- a/14_exceptions_part2_peripheral_IRQs/src/memory.rs +++ b/14_exceptions_part2_peripheral_IRQs/src/memory.rs @@ -25,13 +25,9 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/15_virtual_mem_part2_mmio_remap/README.md b/15_virtual_mem_part2_mmio_remap/README.md index 7421cc9b..0b60f8c5 100644 --- a/15_virtual_mem_part2_mmio_remap/README.md +++ b/15_virtual_mem_part2_mmio_remap/README.md @@ -1453,8 +1453,8 @@ diff -uNr 14_exceptions_part2_peripheral_IRQs/src/bsp/raspberrypi/driver.rs 15_v diff -uNr 14_exceptions_part2_peripheral_IRQs/src/bsp/raspberrypi/link.ld 15_virtual_mem_part2_mmio_remap/src/bsp/raspberrypi/link.ld --- 14_exceptions_part2_peripheral_IRQs/src/bsp/raspberrypi/link.ld +++ 15_virtual_mem_part2_mmio_remap/src/bsp/raspberrypi/link.ld -@@ -39,6 +39,11 @@ - . = ALIGN(8); +@@ -42,6 +42,11 @@ + . += 8; __bss_end_inclusive = . - 8; } + . = ALIGN(65536); diff --git a/15_virtual_mem_part2_mmio_remap/src/bsp/raspberrypi/link.ld b/15_virtual_mem_part2_mmio_remap/src/bsp/raspberrypi/link.ld index c78ef8ef..ae5c2819 100644 --- a/15_virtual_mem_part2_mmio_remap/src/bsp/raspberrypi/link.ld +++ b/15_virtual_mem_part2_mmio_remap/src/bsp/raspberrypi/link.ld @@ -37,6 +37,9 @@ SECTIONS __bss_start = .; *(.bss*); . = ALIGN(8); + + /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ + . += 8; __bss_end_inclusive = . - 8; } . = ALIGN(65536); diff --git a/15_virtual_mem_part2_mmio_remap/src/bsp/raspberrypi/memory.rs b/15_virtual_mem_part2_mmio_remap/src/bsp/raspberrypi/memory.rs index 7376e229..5c05e208 100644 --- a/15_virtual_mem_part2_mmio_remap/src/bsp/raspberrypi/memory.rs +++ b/15_virtual_mem_part2_mmio_remap/src/bsp/raspberrypi/memory.rs @@ -184,5 +184,11 @@ pub fn phys_boot_core_stack_end() -> Address { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/15_virtual_mem_part2_mmio_remap/src/memory.rs b/15_virtual_mem_part2_mmio_remap/src/memory.rs index 76041890..32353d4f 100644 --- a/15_virtual_mem_part2_mmio_remap/src/memory.rs +++ b/15_virtual_mem_part2_mmio_remap/src/memory.rs @@ -25,13 +25,9 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } } diff --git a/X1_JTAG_boot/jtag_boot_rpi3.img b/X1_JTAG_boot/jtag_boot_rpi3.img index 1357692a32fa9a84ff20b4302ef0e3b888a0d39f..086b01aeab0f5ed1e855dda06b628d2d5fe8b165 100755 GIT binary patch delta 1273 zcmZ`&TWB0r7(QoaCp+83)P%jwUa~W!$zIakH8e@vRLLa8yI9x;EJR4A=~mX5&2}~q zi3nMt;)8wg@V68d!F>>%r9$FTB`STfm&)4s_1n?-ibQ8XEWjRHLKV4(pG^gi2?Fx5N(t@JE zQ9)S?P(>A^(OH@Q(Xy-nQ|9PKjUl4&mE4p%MDC*hqVg1TF}yNB=G8%>36_m#dwFBKpSFKUFz(SVR$-NA+n`{inq+;`iw?IGS^ zHHpn6*MzL5865_DGCqmee*hF_vBC^m7lS?=QOX7=MGYvPyR5zVDW3Y>~(9FV~ zIOc7pN%GAMy+>afrW+e3g-*bvr@_rDb^gHTxEqZSIzBHO@6_B#{dVUV<~Gt`b$!oO z*%7TjctjAmn`zkV-Q~2$V8(X^R=gi`W*TC?aq6kh_{K3aulfhM#t7W-KM9Wp&h!)m zv^RA5TTg^8!fGIfKY{lGr-r|EFdDkGesFAhRao6=m zElvO5S3sl~mk7aU(ja#x1V2lCy(=MG>7Y}`+aWj*8pG=_89Mf|RxaoD<-$@?KCcyC z%by#U6 zmYxFq9ts~{aS#VUZJW-zwdS05wefcS=U_5C(bI6gmL1px65f-{h#f8LcweIbeGh#% Ip&FU^7uIP_kpKVy delta 1149 zcmZ`%OKcNY6us|_#~zcPLML{|pUk)pb{v}|j%f&~Dn>zVqauOib^)uzNz z@*uSp5-j?3L2c>Ei%K1sj__KWw|z0H1+mx6*t@dD(u*TfK?J(8pZ%Lnv)jxGdz!T6xJ9iIrNGwW^-< zGkhFUtHvHS=j`#T%`g#T@AIzA?b86NGGN-gi@GBz^>ry+e?~zS(;&nu!|WgvT{)7@ zIlV5v+g)A`Smki#?d>7iY@X>;OG7d=Z|}Cs3di(o(A4>4aZMh?W6Iu0CCa`|{_BJzzumLnPJjNw+~Enedb!_nxm-Xl>yTy7B`{{X*=>f{nOqeqL2KF90W zv4-#S3%O%AeBXEB1|E3zXPnhWi{Hs!)Hd_{kBEn#Uzi&?w{ZIGN5c!}g~q^J+B@34 z|N9G5F`a&?;Z!U`S2R2m>)+kdyhuHMil-W0kBt)pS7Q@JA6pA~nszPi^A{h#7%g5Pomh>#RwWHjV$*e_5B{#Ev#;l^>c25kvVc2->u$AS%MP7-~vVXB|=H z6j#8daNseCick->5CS)sR&GJ%KpmwAkP1yD$^rFY6Ar;Sv^OvkEVH}M6(f0P=Y2Et z&HH9u9shpf;|P8CQq-irafvKZLN3M&5mwtE>^G6HJC!{`FBQ^JI3k{;y|5-ew?k!{ zeXjB*q7Pv9{yM~5J;7p()%FqgC?!iOQGX_gkZLbG1TVP`2nT)er7Px}+s?MIZzp0u zt&Xtm=j+^Mm<7y9?B3A>Lj6{arpys9|;i;S3O`Ke|~N?-lZRhW9)=N(Q-A;@_TC*jp^9uE6#C0_XF~mmH&fj9zJTC=PXUE zp5_|8_3togeg?NBg{rV6ofYayIPH#Yvu^)6-hPd+B9z=qi+Yl6wvlF|Pb^zw%cUeU z7g6{{seFG;58|4zAZOA4ZI0NZseO(VwLUIIznx=AfjaW_q??Bb@uJihWLLUe6Xgqk z2*hjGzn)^07N+2G+YSiIntwIS+L3=7{u=uTJITWAqg4%Fm0u7_8m!2v&VxQXqah+% z8iEaZ%v;h}^07huQobwK+9(nb_6TU6s?Z&;-1U4-JFCOilwNzG>PV&1K1PK(4X$-W zLGHLB=vw7k$1X`Yqrt|`h7jLfx!FBIg`x)Sz6lKBX7@7O@qJ;Pyys5{g%McsKZ&a+ z1n&7??s_eNnxXmaCn59jN}z{+3JZZ3_f$EC{I;#}7*)0HI*)lsu0u2MP3pYlbabAC zw0ytpyzS-wyaZ=MiEw|^Ij#jAznjOhBEw2>l-`4SFreJhuyDsu-mBZ^W7yeUOk2q{$ QetHDA+lBAza3(VOAG@JDga7~l delta 1037 zcmYjPO-vI}5T3W&pDq8D{;)0d2Wkr~RB5pw9;kv!G*KWL#S0KFD2XxP!GlRlB2m!; zFH_^iLy0j`E=U?wJeU$Vpa&BYmBhqY^g`&tc*08J`ntOiC)qcd_kA<-&AeS}&m5hu zCPND~5-|t0kRSjr+!;H~{s8)&2fCha<~)RpSK}pql=yLlKU?9TTRu%{i=jn~ea4Lr zjk79SL$jSg!vqp8aD4=ZK*mqM;zdmlH)F!*8i#qgjOJL~GKPJa3DI)qf4cFDCP3V% z)3(OszJ&E9w3yY25;!v8;y+1}WR>ed1LauGiFiGA^YOm-@PDsb$}?;@UPm>|--&wU zIz!rcUrOa=_<_#?!vqqh2Idv?t`E4JclIy#DREn_;#k8sYeb%vkvV_Tk zmOoO9JWtZ2XdXPMYWB*Ug678k*`oOo02ABEoS=!Ovb-?&mjjcWpY>5f;(gd6R5=K$RMmsHLqnEI6yA$Z>rj0(F3E*Af95)fb z4Z&YFW0D!$JVPg%u-p(aO$2CzyOF*6+f-Ihm^Ee%VOQE-^pcb%n+t=OP{mDXTO=^}SLkj|CXYPq2RmRD|bB$(cjD& zUT!di8x!RLI9U-ZO!W4s$StJC%~ScRqtP`epQb}qPIU;tq=xnil0^Edur?l9~^@= z(19{+yG!YlRdKZ|?8WRQWOE_4TZso#_6}pcU8(I-v2M)UcStw>s usize { /// - Values are provided by the linker script and must be trusted as-is. /// - The linker-provided addresses must be u64 aligned. pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> { - unsafe { RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()) } + let range; + unsafe { + range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get()); + } + assert!(!range.is_empty()); + + range } diff --git a/X1_JTAG_boot/src/memory.rs b/X1_JTAG_boot/src/memory.rs index 77e21c0c..827b8b85 100644 --- a/X1_JTAG_boot/src/memory.rs +++ b/X1_JTAG_boot/src/memory.rs @@ -23,12 +23,8 @@ where let mut ptr = *range.start(); let end_inclusive = *range.end(); - loop { + while ptr <= end_inclusive { core::ptr::write_volatile(ptr, T::from(0)); ptr = ptr.offset(1); - - if ptr > end_inclusive { - break; - } } }