diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 807170195..a13413791 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -122,7 +122,7 @@ pub use crate::sched::cooperative::{CoopProcessNode, CooperativeSched}; pub use crate::sched::mlfq::{MLFQProcessNode, MLFQSched}; pub use crate::sched::priority::PrioritySched; pub use crate::sched::round_robin::{RoundRobinProcessNode, RoundRobinSched}; -pub use crate::sched::{Kernel, Scheduler, StorageLocation}; +pub use crate::sched::{Kernel, Scheduler, StorageLocation, StorageType}; // 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 5465c95f4..e596648f7 100644 --- a/kernel/src/memop.rs +++ b/kernel/src/memop.rs @@ -127,6 +127,14 @@ pub(crate) fn memop(process: &dyn ProcessType, op_type: usize, r1: usize) -> Ret } } + // Op Type 15: The type of the storage location indexed by r1. + 15 => { + match process.get_storage_location(r1) { + None => ReturnCode::FAIL, + Some(x) => ReturnCode::SuccessWithValue { value: x.storage_type as usize } + } + } + _ => ReturnCode::ENOSUPPORT, } } diff --git a/kernel/src/sched.rs b/kernel/src/sched.rs index 031159500..0cbfea929 100644 --- a/kernel/src/sched.rs +++ b/kernel/src/sched.rs @@ -118,10 +118,19 @@ pub enum SchedulingDecision { TrySleep, } +/// Represents the type of a storage slice. +#[derive(Copy, Clone)] +pub enum StorageType { + STORE = 1, + PARTITION = 2, + METADATA = 3, +} + /// Represents a storage location in flash. pub struct StorageLocation { pub address: usize, pub size: usize, + pub storage_type: StorageType, } /// Main object for the kernel. Each board will need to create one.