From 6fc7d67dc1211153877c78bda7757d90c9522adf Mon Sep 17 00:00:00 2001 From: Zach Halvorsen Date: Thu, 29 Jun 2023 08:48:55 -0700 Subject: [PATCH] Add ability to get more storage information. This adds parameters to the storage location syscalls to specify which storage location to get the address and size for. --- src/env/tock/storage.rs | 8 ++++---- third_party/libtock-drivers/src/storage.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/env/tock/storage.rs b/src/env/tock/storage.rs index 669612be..89d67200 100644 --- a/src/env/tock/storage.rs +++ b/src/env/tock/storage.rs @@ -87,8 +87,8 @@ impl T if !matches!(storage_type, StorageType::Store) { continue; } - let storage_ptr = to_storage_result(LibtockStorage::::storage_ptr())?; - let storage_len = to_storage_result(LibtockStorage::::storage_len())?; + let storage_ptr = to_storage_result(LibtockStorage::::storage_ptr(i))?; + let storage_len = to_storage_result(LibtockStorage::::storage_len(i))?; if !syscall.is_page_aligned(storage_ptr) || !syscall.is_page_aligned(storage_len) { return Err(StorageError::CustomError); } @@ -210,8 +210,8 @@ where if !matches!(storage_type, StorageType::Partition) { continue; }; - let storage_ptr = to_storage_result(LibtockStorage::::storage_ptr())?; - let storage_len = to_storage_result(LibtockStorage::::storage_len())?; + let storage_ptr = to_storage_result(LibtockStorage::::storage_ptr(i))?; + let storage_len = to_storage_result(LibtockStorage::::storage_len(i))?; if !locations.is_page_aligned(storage_ptr) || !locations.is_page_aligned(storage_len) { return Err(StorageError::CustomError); } diff --git a/third_party/libtock-drivers/src/storage.rs b/third_party/libtock-drivers/src/storage.rs index 78b43942..45574bed 100644 --- a/third_party/libtock-drivers/src/storage.rs +++ b/third_party/libtock-drivers/src/storage.rs @@ -147,12 +147,12 @@ impl S Ok(Self::memop(memop_nr::STORAGE_CNT, 0)? as usize) } - pub fn storage_ptr() -> TockResult { - Ok(Self::memop(memop_nr::STORAGE_PTR, 0)? as usize) + pub fn storage_ptr(index: usize) -> TockResult { + Ok(Self::memop(memop_nr::STORAGE_PTR, index as u32)? as usize) } - pub fn storage_len() -> TockResult { - Ok(Self::memop(memop_nr::STORAGE_LEN, 0)? as usize) + pub fn storage_len(index: usize) -> TockResult { + Ok(Self::memop(memop_nr::STORAGE_LEN, index as u32)? as usize) } pub fn storage_type(index: usize) -> TockResult {