Fix formatting.

This commit is contained in:
Guillaume Endignoux
2020-10-02 13:52:24 +02:00
parent ea7ee9f1f9
commit 2ca541fb33

View File

@@ -1,5 +1,5 @@
diff --git a/boards/nordic/nrf52840_dongle/src/main.rs b/boards/nordic/nrf52840_dongle/src/main.rs
index fc53f59..d72d204 100644
index fc53f59c8..d72d20482 100644
--- a/boards/nordic/nrf52840_dongle/src/main.rs
+++ b/boards/nordic/nrf52840_dongle/src/main.rs
@@ -55,6 +55,11 @@ const NUM_PROCS: usize = 8;
@@ -22,7 +22,7 @@ index fc53f59..d72d204 100644
}
impl kernel::Platform for Platform {
@@ -108,19 +114,42 @@ impl kernel::Platform for Platform {
@@ -108,10 +114,30 @@ impl kernel::Platform for Platform {
capsules::ieee802154::DRIVER_NUM => f(Some(self.ieee802154_radio)),
capsules::temperature::DRIVER_NUM => f(Some(self.temp)),
capsules::analog_comparator::DRIVER_NUM => f(Some(self.analog_comparator)),
@@ -53,8 +53,7 @@ index fc53f59..d72d204 100644
}
/// Entry point in the vector table called on hard reset.
#[no_mangle]
pub unsafe fn reset_handler() {
@@ -120,7 +146,10 @@ pub unsafe fn reset_handler() {
// Loads relocations and clears BSS
nrf52840::init();
@@ -90,7 +89,7 @@ index fc53f59..d72d204 100644
};
diff --git a/boards/nordic/nrf52840dk/src/main.rs b/boards/nordic/nrf52840dk/src/main.rs
index 169f3d3..2ebb384 100644
index 169f3d393..2ebb384d8 100644
--- a/boards/nordic/nrf52840dk/src/main.rs
+++ b/boards/nordic/nrf52840dk/src/main.rs
@@ -123,6 +123,11 @@ const NUM_PROCS: usize = 8;
@@ -180,10 +179,10 @@ index 169f3d3..2ebb384 100644
};
diff --git a/chips/nrf52/src/nvmc.rs b/chips/nrf52/src/nvmc.rs
index b70162c..9dcb82b 100644
index b70162cae..9dcb82b07 100644
--- a/chips/nrf52/src/nvmc.rs
+++ b/chips/nrf52/src/nvmc.rs
@@ -3,15 +3,16 @@
@@ -3,6 +3,7 @@
//! Used in order read and write to internal flash.
use core::cell::Cell;
@@ -191,8 +190,7 @@ index b70162c..9dcb82b 100644
use core::ops::{Index, IndexMut};
use kernel::common::cells::OptionalCell;
use kernel::common::cells::TakeCell;
use kernel::common::cells::VolatileCell;
use kernel::common::deferred_call::DeferredCall;
@@ -11,7 +12,7 @@ use kernel::common::deferred_call::DeferredCall;
use kernel::common::registers::{register_bitfields, ReadOnly, ReadWrite};
use kernel::common::StaticRef;
use kernel::hil;
@@ -427,7 +425,7 @@ index b70162c..9dcb82b 100644
+ }
+}
diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs
index dbe5035..428d90c 100644
index dbe503515..428d90c29 100644
--- a/kernel/src/lib.rs
+++ b/kernel/src/lib.rs
@@ -123,7 +123,7 @@ pub use crate::sched::cooperative::{CoopProcessNode, CooperativeSched};
@@ -440,7 +438,7 @@ index dbe5035..428d90c 100644
// Export only select items from the process module. To remove the name conflict
// this cannot be called `process`, so we use a shortened version. These
diff --git a/kernel/src/memop.rs b/kernel/src/memop.rs
index 348c746..5465c95 100644
index 348c746a5..5465c95f4 100644
--- a/kernel/src/memop.rs
+++ b/kernel/src/memop.rs
@@ -108,6 +108,25 @@ pub(crate) fn memop(process: &dyn ProcessType, op_type: usize, r1: usize) -> Ret
@@ -470,7 +468,7 @@ index 348c746..5465c95 100644
}
}
diff --git a/kernel/src/process.rs b/kernel/src/process.rs
index 4dfde3b..0ceff3e 100644
index 4dfde3b4f..8380af673 100644
--- a/kernel/src/process.rs
+++ b/kernel/src/process.rs
@@ -360,6 +360,15 @@ pub trait ProcessType {
@@ -489,7 +487,7 @@ index 4dfde3b..0ceff3e 100644
/// Debug function to update the kernel on where the stack starts for this
/// process. Processes are not required to call this through the memop
/// system call, but it aids in debugging the process.
@@ -1015,6 +1024,32 @@ impl<C: Chip> ProcessType for Process<'_, C> {
@@ -1015,6 +1024,35 @@ impl<C: Chip> ProcessType for Process<'_, C> {
self.header.get_writeable_flash_region(region_index)
}
@@ -502,27 +500,30 @@ index 4dfde3b..0ceff3e 100644
+ }
+
+ fn fits_in_storage_location(&self, ptr: usize, len: usize) -> bool {
+ self.kernel.storage_locations().iter().any(|storage_location| {
+ let storage_ptr = storage_location.address;
+ let storage_len = storage_location.size;
+ // We want to check the 2 following inequalities:
+ // (1) `storage_ptr <= ptr`
+ // (2) `ptr + len <= storage_ptr + storage_len`
+ // However, the second one may overflow written as is. We introduce a third
+ // inequality to solve this issue:
+ // (3) `len <= storage_len`
+ // Using this third inequality, we can rewrite the second one as:
+ // (4) `ptr - storage_ptr <= storage_len - len`
+ // This fourth inequality is equivalent to the second one but doesn't overflow when
+ // the first and third inequalities hold.
+ storage_ptr <= ptr && len <= storage_len && ptr - storage_ptr <= storage_len - len
+ })
+ self.kernel
+ .storage_locations()
+ .iter()
+ .any(|storage_location| {
+ let storage_ptr = storage_location.address;
+ let storage_len = storage_location.size;
+ // We want to check the 2 following inequalities:
+ // (1) `storage_ptr <= ptr`
+ // (2) `ptr + len <= storage_ptr + storage_len`
+ // However, the second one may overflow written as is. We introduce a third
+ // inequality to solve this issue:
+ // (3) `len <= storage_len`
+ // Using this third inequality, we can rewrite the second one as:
+ // (4) `ptr - storage_ptr <= storage_len - len`
+ // This fourth inequality is equivalent to the second one but doesn't overflow when
+ // the first and third inequalities hold.
+ storage_ptr <= ptr && len <= storage_len && ptr - storage_ptr <= storage_len - len
+ })
+ }
+
fn update_stack_start_pointer(&self, stack_pointer: *const u8) {
if stack_pointer >= self.mem_start() && stack_pointer < self.mem_end() {
self.debug.map(|debug| {
@@ -1664,6 +1699,33 @@ impl<C: 'static + Chip> Process<'_, C> {
@@ -1664,6 +1702,33 @@ impl<C: 'static + Chip> Process<'_, C> {
return Err(ProcessLoadError::MpuInvalidFlashLength);
}
@@ -557,10 +558,10 @@ index 4dfde3b..0ceff3e 100644
// memory space just for kernel and grant state. We need to make
// sure we allocate enough memory just for that.
diff --git a/kernel/src/sched.rs b/kernel/src/sched.rs
index 88eea40..ed3ae82 100644
index 88eea4042..ed3ae8260 100644
--- a/kernel/src/sched.rs
+++ b/kernel/src/sched.rs
@@ -118,15 +118,24 @@ pub enum SchedulingDecision {
@@ -118,6 +118,12 @@ pub enum SchedulingDecision {
TrySleep,
}
@@ -573,9 +574,7 @@ index 88eea40..ed3ae82 100644
/// Main object for the kernel. Each board will need to create one.
pub struct Kernel {
/// How many "to-do" items exist at any given time. These include
/// outstanding callbacks and processes in the Running state.
work: Cell<usize>,
@@ -127,6 +133,9 @@ pub struct Kernel {
/// This holds a pointer to the static array of Process pointers.
processes: &'static [Option<&'static dyn process::ProcessType>],