More sound Phantom in MMIO deref wrapper

pull/84/head
Andre Richter 4 years ago
parent ae878182d7
commit 02f9f34af3
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

@ -779,7 +779,7 @@ diff -uNr 05_safe_globals/src/bsp/device_driver/common.rs 06_drivers_gpio_uart/s
+
+pub struct MMIODerefWrapper<T> {
+ start_addr: usize,
+ phantom: PhantomData<T>,
+ phantom: PhantomData<fn() -> T>,
+}
+
+//--------------------------------------------------------------------------------------------------
@ -1205,7 +1205,15 @@ diff -uNr 05_safe_globals/src/main.rs 06_drivers_gpio_uart/src/main.rs
//! # Code organization and architecture
//!
//! The code is divided into different *modules*, each representing a typical **subsystem** of the
@@ -105,6 +113,7 @@
@@ -92,6 +100,7 @@
//! - `crate::memory::*`
//! - `crate::bsp::memory::*`
+#![feature(const_fn_fn_ptr_basics)]
#![feature(format_args_nl)]
#![feature(naked_functions)]
#![feature(panic_info_message)]
@@ -105,6 +114,7 @@
mod bsp;
mod console;
mod cpu;
@ -1213,7 +1221,7 @@ diff -uNr 05_safe_globals/src/main.rs 06_drivers_gpio_uart/src/main.rs
mod memory;
mod panic_wait;
mod print;
@@ -116,16 +125,53 @@
@@ -116,16 +126,53 @@
/// # Safety
///
/// - Only a single core must be active and running this function.

@ -12,7 +12,7 @@ use core::{marker::PhantomData, ops};
pub struct MMIODerefWrapper<T> {
start_addr: usize,
phantom: PhantomData<T>,
phantom: PhantomData<fn() -> T>,
}
//--------------------------------------------------------------------------------------------------

@ -100,6 +100,7 @@
//! - `crate::memory::*`
//! - `crate::bsp::memory::*`
#![feature(const_fn_fn_ptr_basics)]
#![feature(format_args_nl)]
#![feature(naked_functions)]
#![feature(panic_info_message)]

@ -403,16 +403,17 @@ diff -uNr 06_drivers_gpio_uart/src/console.rs 07_uart_chainloader/src/console.rs
diff -uNr 06_drivers_gpio_uart/src/main.rs 07_uart_chainloader/src/main.rs
--- 06_drivers_gpio_uart/src/main.rs
+++ 07_uart_chainloader/src/main.rs
@@ -100,6 +100,8 @@
@@ -100,7 +100,9 @@
//! - `crate::memory::*`
//! - `crate::bsp::memory::*`
+#![feature(asm)]
#![feature(const_fn_fn_ptr_basics)]
+#![feature(core_intrinsics)]
#![feature(format_args_nl)]
#![feature(naked_functions)]
#![feature(panic_info_message)]
@@ -108,7 +110,8 @@
@@ -109,7 +111,8 @@
#![no_std]
// `mod cpu` provides the `_start()` function, the first function to run. `_start()` then calls
@ -422,7 +423,7 @@ diff -uNr 06_drivers_gpio_uart/src/main.rs 07_uart_chainloader/src/main.rs
mod bsp;
mod console;
@@ -117,6 +120,7 @@
@@ -118,6 +121,7 @@
mod memory;
mod panic_wait;
mod print;
@ -430,7 +431,7 @@ diff -uNr 06_drivers_gpio_uart/src/main.rs 07_uart_chainloader/src/main.rs
mod runtime_init;
mod synchronization;
@@ -143,35 +147,52 @@
@@ -144,35 +148,52 @@
/// The main function running after the early init.
fn kernel_main() -> ! {

@ -12,7 +12,7 @@ use core::{marker::PhantomData, ops};
pub struct MMIODerefWrapper<T> {
start_addr: usize,
phantom: PhantomData<T>,
phantom: PhantomData<fn() -> T>,
}
//--------------------------------------------------------------------------------------------------

@ -101,6 +101,7 @@
//! - `crate::bsp::memory::*`
#![feature(asm)]
#![feature(const_fn_fn_ptr_basics)]
#![feature(core_intrinsics)]
#![feature(format_args_nl)]
#![feature(naked_functions)]

@ -454,16 +454,17 @@ diff -uNr 07_uart_chainloader/src/main.rs 08_timestamps/src/main.rs
//!
//! # Code organization and architecture
//!
@@ -100,8 +102,6 @@
@@ -100,9 +102,7 @@
//! - `crate::memory::*`
//! - `crate::bsp::memory::*`
-#![feature(asm)]
#![feature(const_fn_fn_ptr_basics)]
-#![feature(core_intrinsics)]
#![feature(format_args_nl)]
#![feature(naked_functions)]
#![feature(panic_info_message)]
@@ -110,8 +110,7 @@
@@ -111,8 +111,7 @@
#![no_std]
// `mod cpu` provides the `_start()` function, the first function to run. `_start()` then calls
@ -473,7 +474,7 @@ diff -uNr 07_uart_chainloader/src/main.rs 08_timestamps/src/main.rs
mod bsp;
mod console;
@@ -120,9 +119,9 @@
@@ -121,9 +120,9 @@
mod memory;
mod panic_wait;
mod print;
@ -484,7 +485,7 @@ diff -uNr 07_uart_chainloader/src/main.rs 08_timestamps/src/main.rs
/// Early init code.
///
@@ -147,52 +146,31 @@
@@ -148,52 +147,31 @@
/// The main function running after the early init.
fn kernel_main() -> ! {

@ -12,7 +12,7 @@ use core::{marker::PhantomData, ops};
pub struct MMIODerefWrapper<T> {
start_addr: usize,
phantom: PhantomData<T>,
phantom: PhantomData<fn() -> T>,
}
//--------------------------------------------------------------------------------------------------

@ -102,6 +102,7 @@
//! - `crate::memory::*`
//! - `crate::bsp::memory::*`
#![feature(const_fn_fn_ptr_basics)]
#![feature(format_args_nl)]
#![feature(naked_functions)]
#![feature(panic_info_message)]

@ -12,7 +12,7 @@ use core::{marker::PhantomData, ops};
pub struct MMIODerefWrapper<T> {
start_addr: usize,
phantom: PhantomData<T>,
phantom: PhantomData<fn() -> T>,
}
//--------------------------------------------------------------------------------------------------

@ -102,6 +102,7 @@
//! - `crate::memory::*`
//! - `crate::bsp::memory::*`
#![feature(const_fn_fn_ptr_basics)]
#![feature(format_args_nl)]
#![feature(naked_functions)]
#![feature(panic_info_message)]

@ -444,7 +444,7 @@ diff -uNr 09_hw_debug_JTAG/src/exception.rs 10_privilege_level/src/exception.rs
diff -uNr 09_hw_debug_JTAG/src/main.rs 10_privilege_level/src/main.rs
--- 09_hw_debug_JTAG/src/main.rs
+++ 10_privilege_level/src/main.rs
@@ -116,6 +116,7 @@
@@ -117,6 +117,7 @@
mod console;
mod cpu;
mod driver;
@ -452,7 +452,7 @@ diff -uNr 09_hw_debug_JTAG/src/main.rs 10_privilege_level/src/main.rs
mod memory;
mod panic_wait;
mod print;
@@ -146,12 +147,19 @@
@@ -147,12 +148,19 @@
/// The main function running after the early init.
fn kernel_main() -> ! {
@ -472,7 +472,7 @@ diff -uNr 09_hw_debug_JTAG/src/main.rs 10_privilege_level/src/main.rs
info!(
"Architectural timer resolution: {} ns",
time::time_manager().resolution().as_nanos()
@@ -166,11 +174,12 @@
@@ -167,11 +175,12 @@
info!(" {}. {}", i + 1, driver.compatible());
}

@ -12,7 +12,7 @@ use core::{marker::PhantomData, ops};
pub struct MMIODerefWrapper<T> {
start_addr: usize,
phantom: PhantomData<T>,
phantom: PhantomData<fn() -> T>,
}
//--------------------------------------------------------------------------------------------------

@ -102,6 +102,7 @@
//! - `crate::memory::*`
//! - `crate::bsp::memory::*`
#![feature(const_fn_fn_ptr_basics)]
#![feature(format_args_nl)]
#![feature(naked_functions)]
#![feature(panic_info_message)]

@ -855,17 +855,18 @@ diff -uNr 10_privilege_level/src/main.rs 11_virtual_mem_part1_identity_mapping/s
//! [timer interface]: ../libkernel/time/interface/trait.TimeManager.html
//!
//! # Code organization and architecture
@@ -102,6 +104,9 @@
@@ -102,7 +104,10 @@
//! - `crate::memory::*`
//! - `crate::bsp::memory::*`
+#![allow(incomplete_features)]
#![feature(const_fn_fn_ptr_basics)]
+#![feature(const_generics)]
+#![feature(const_panic)]
#![feature(format_args_nl)]
#![feature(naked_functions)]
#![feature(panic_info_message)]
@@ -129,9 +134,18 @@
@@ -130,9 +135,18 @@
/// # Safety
///
/// - Only a single core must be active and running this function.
@ -885,7 +886,7 @@ diff -uNr 10_privilege_level/src/main.rs 11_virtual_mem_part1_identity_mapping/s
for i in bsp::driver::driver_manager().all_device_drivers().iter() {
if let Err(x) = i.init() {
@@ -154,6 +168,9 @@
@@ -155,6 +169,9 @@
info!("Booting on: {}", bsp::board_name());
@ -895,7 +896,7 @@ diff -uNr 10_privilege_level/src/main.rs 11_virtual_mem_part1_identity_mapping/s
let (_, privilege_level) = exception::current_privilege_level();
info!("Current privilege level: {}", privilege_level);
@@ -177,6 +194,13 @@
@@ -178,6 +195,13 @@
info!("Timer test, spinning for 1 second");
time::time_manager().spin_for(Duration::from_secs(1));

@ -12,7 +12,7 @@ use core::{marker::PhantomData, ops};
pub struct MMIODerefWrapper<T> {
start_addr: usize,
phantom: PhantomData<T>,
phantom: PhantomData<fn() -> T>,
}
//--------------------------------------------------------------------------------------------------

@ -105,6 +105,7 @@
//! - `crate::bsp::memory::*`
#![allow(incomplete_features)]
#![feature(const_fn_fn_ptr_basics)]
#![feature(const_generics)]
#![feature(const_panic)]
#![feature(format_args_nl)]

@ -955,7 +955,7 @@ diff -uNr 11_virtual_mem_part1_identity_mapping/src/bsp.rs 12_exceptions_part1_g
diff -uNr 11_virtual_mem_part1_identity_mapping/src/main.rs 12_exceptions_part1_groundwork/src/main.rs
--- 11_virtual_mem_part1_identity_mapping/src/main.rs
+++ 12_exceptions_part1_groundwork/src/main.rs
@@ -108,6 +108,7 @@
@@ -109,6 +109,7 @@
#![feature(const_generics)]
#![feature(const_panic)]
#![feature(format_args_nl)]
@ -963,7 +963,7 @@ diff -uNr 11_virtual_mem_part1_identity_mapping/src/main.rs 12_exceptions_part1_
#![feature(naked_functions)]
#![feature(panic_info_message)]
#![feature(trait_alias)]
@@ -143,6 +144,8 @@
@@ -144,6 +145,8 @@
use driver::interface::DriverManager;
use memory::mmu::interface::MMU;
@ -972,7 +972,7 @@ diff -uNr 11_virtual_mem_part1_identity_mapping/src/main.rs 12_exceptions_part1_
if let Err(string) = memory::mmu::mmu().init() {
panic!("MMU: {}", string);
}
@@ -194,13 +197,28 @@
@@ -195,13 +198,28 @@
info!("Timer test, spinning for 1 second");
time::time_manager().spin_for(Duration::from_secs(1));

@ -12,7 +12,7 @@ use core::{marker::PhantomData, ops};
pub struct MMIODerefWrapper<T> {
start_addr: usize,
phantom: PhantomData<T>,
phantom: PhantomData<fn() -> T>,
}
//--------------------------------------------------------------------------------------------------

@ -105,6 +105,7 @@
//! - `crate::bsp::memory::*`
#![allow(incomplete_features)]
#![feature(const_fn_fn_ptr_basics)]
#![feature(const_generics)]
#![feature(const_panic)]
#![feature(format_args_nl)]

@ -1130,7 +1130,7 @@ diff -uNr 12_exceptions_part1_groundwork/src/exception.rs 13_integrated_testing/
diff -uNr 12_exceptions_part1_groundwork/src/lib.rs 13_integrated_testing/src/lib.rs
--- 12_exceptions_part1_groundwork/src/lib.rs
+++ 13_integrated_testing/src/lib.rs
@@ -0,0 +1,169 @@
@@ -0,0 +1,170 @@
+// SPDX-License-Identifier: MIT OR Apache-2.0
+//
+// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
@ -1240,6 +1240,7 @@ diff -uNr 12_exceptions_part1_groundwork/src/lib.rs 13_integrated_testing/src/li
+//! - `crate::bsp::memory::*`
+
+#![allow(incomplete_features)]
+#![feature(const_fn_fn_ptr_basics)]
+#![feature(const_generics)]
+#![feature(const_panic)]
+#![feature(format_args_nl)]
@ -1304,7 +1305,7 @@ diff -uNr 12_exceptions_part1_groundwork/src/lib.rs 13_integrated_testing/src/li
diff -uNr 12_exceptions_part1_groundwork/src/main.rs 13_integrated_testing/src/main.rs
--- 12_exceptions_part1_groundwork/src/main.rs
+++ 13_integrated_testing/src/main.rs
@@ -6,129 +6,12 @@
@@ -6,130 +6,12 @@
#![doc(html_logo_url = "https://git.io/JeGIp")]
//! The `kernel` binary.
@ -1407,6 +1408,7 @@ diff -uNr 12_exceptions_part1_groundwork/src/main.rs 13_integrated_testing/src/m
-//! - `crate::bsp::memory::*`
-
-#![allow(incomplete_features)]
-#![feature(const_fn_fn_ptr_basics)]
-#![feature(const_generics)]
-#![feature(const_panic)]
+
@ -1436,7 +1438,7 @@ diff -uNr 12_exceptions_part1_groundwork/src/main.rs 13_integrated_testing/src/m
/// Early init code.
///
@@ -140,6 +23,7 @@
@@ -141,6 +23,7 @@
/// - Without it, any atomic operations, e.g. the yet-to-be-introduced spinlocks in the device
/// drivers (which currently employ NullLocks instead of spinlocks), will fail to work on
/// the RPi SoCs.
@ -1444,7 +1446,7 @@ diff -uNr 12_exceptions_part1_groundwork/src/main.rs 13_integrated_testing/src/m
unsafe fn kernel_init() -> ! {
use driver::interface::DriverManager;
use memory::mmu::interface::MMU;
@@ -165,9 +49,7 @@
@@ -166,9 +49,7 @@
/// The main function running after the early init.
fn kernel_main() -> ! {
use console::interface::All;
@ -1454,7 +1456,7 @@ diff -uNr 12_exceptions_part1_groundwork/src/main.rs 13_integrated_testing/src/m
info!("Booting on: {}", bsp::board_name());
@@ -194,31 +76,6 @@
@@ -195,31 +76,6 @@
info!(" {}. {}", i + 1, driver.compatible());
}

@ -12,7 +12,7 @@ use core::{marker::PhantomData, ops};
pub struct MMIODerefWrapper<T> {
start_addr: usize,
phantom: PhantomData<T>,
phantom: PhantomData<fn() -> T>,
}
//--------------------------------------------------------------------------------------------------

@ -107,6 +107,7 @@
//! - `crate::bsp::memory::*`
#![allow(incomplete_features)]
#![feature(const_fn_fn_ptr_basics)]
#![feature(const_generics)]
#![feature(const_panic)]
#![feature(format_args_nl)]

@ -2403,18 +2403,19 @@ diff -uNr 13_integrated_testing/src/lib.rs 14_exceptions_part2_peripheral_IRQs/s
//! [timer interface]: ../libkernel/time/interface/trait.TimeManager.html
//!
//! # Code organization and architecture
@@ -107,8 +112,10 @@
@@ -107,9 +112,11 @@
//! - `crate::bsp::memory::*`
#![allow(incomplete_features)]
+#![feature(asm)]
#![feature(const_fn_fn_ptr_basics)]
#![feature(const_generics)]
#![feature(const_panic)]
+#![feature(core_intrinsics)]
#![feature(format_args_nl)]
#![feature(global_asm)]
#![feature(linkage)]
@@ -136,6 +143,7 @@
@@ -137,6 +144,7 @@
pub mod exception;
pub mod memory;
pub mod print;

@ -12,7 +12,7 @@ use core::{marker::PhantomData, ops};
pub struct MMIODerefWrapper<T> {
start_addr: usize,
phantom: PhantomData<T>,
phantom: PhantomData<fn() -> T>,
}
//--------------------------------------------------------------------------------------------------

@ -113,6 +113,7 @@
#![allow(incomplete_features)]
#![feature(asm)]
#![feature(const_fn_fn_ptr_basics)]
#![feature(const_generics)]
#![feature(const_panic)]
#![feature(core_intrinsics)]

@ -2019,10 +2019,10 @@ diff -uNr 14_exceptions_part2_peripheral_IRQs/src/lib.rs 15_virtual_mem_part2_mm
#![allow(incomplete_features)]
#![feature(asm)]
+#![feature(const_fn)]
#![feature(const_fn_fn_ptr_basics)]
#![feature(const_generics)]
#![feature(const_panic)]
#![feature(core_intrinsics)]
@@ -137,6 +138,7 @@
@@ -138,6 +139,7 @@
mod synchronization;
pub mod bsp;

@ -12,7 +12,7 @@ use core::{marker::PhantomData, ops};
pub struct MMIODerefWrapper<T> {
start_addr: usize,
phantom: PhantomData<T>,
phantom: PhantomData<fn() -> T>,
}
//--------------------------------------------------------------------------------------------------

@ -114,6 +114,7 @@
#![allow(incomplete_features)]
#![feature(asm)]
#![feature(const_fn)]
#![feature(const_fn_fn_ptr_basics)]
#![feature(const_generics)]
#![feature(const_panic)]
#![feature(core_intrinsics)]

Binary file not shown.

Binary file not shown.

@ -12,7 +12,7 @@ use core::{marker::PhantomData, ops};
pub struct MMIODerefWrapper<T> {
start_addr: usize,
phantom: PhantomData<T>,
phantom: PhantomData<fn() -> T>,
}
//--------------------------------------------------------------------------------------------------

@ -102,6 +102,7 @@
//! - `crate::memory::*`
//! - `crate::bsp::memory::*`
#![feature(const_fn_fn_ptr_basics)]
#![feature(format_args_nl)]
#![feature(naked_functions)]
#![feature(panic_info_message)]

Loading…
Cancel
Save