removes metadata storage type (#538)

This commit is contained in:
kaczmarczyck
2022-08-29 12:05:58 +02:00
committed by GitHub
parent 01cc8333e5
commit 932924ea85
10 changed files with 43 additions and 50 deletions

View File

@@ -69,12 +69,12 @@ static mut STORAGE_LOCATIONS: [kernel::StorageLocation; 2] = [
kernel::StorageLocation { kernel::StorageLocation {
address: 0xC0000, address: 0xC0000,
size: 0x10000, // 16 pages size: 0x10000, // 16 pages
storage_type: kernel::StorageType::STORE, storage_type: kernel::StorageType::Store,
}, },
kernel::StorageLocation { kernel::StorageLocation {
address: 0xD0000, address: 0xD0000,
size: 0x4000, // 4 pages size: 0x4000, // 4 pages
storage_type: kernel::StorageType::STORE, storage_type: kernel::StorageType::Store,
}, },
]; ];

View File

@@ -63,12 +63,12 @@ static mut STORAGE_LOCATIONS: [kernel::StorageLocation; 2] = [
kernel::StorageLocation { kernel::StorageLocation {
address: 0xC0000, address: 0xC0000,
size: 0x10000, // 16 pages size: 0x10000, // 16 pages
storage_type: kernel::StorageType::STORE, storage_type: kernel::StorageType::Store,
}, },
kernel::StorageLocation { kernel::StorageLocation {
address: 0xD0000, address: 0xD0000,
size: 0x4000, // 4 pages size: 0x4000, // 4 pages
storage_type: kernel::StorageType::STORE, storage_type: kernel::StorageType::Store,
}, },
]; ];

View File

@@ -16,12 +16,12 @@ static mut STORAGE_LOCATIONS: [kernel::StorageLocation; 2] = [
kernel::StorageLocation { kernel::StorageLocation {
address: 0xC0000, address: 0xC0000,
size: 0x10000, // 16 pages size: 0x10000, // 16 pages
storage_type: kernel::StorageType::STORE, storage_type: kernel::StorageType::Store,
}, },
kernel::StorageLocation { kernel::StorageLocation {
address: 0xD0000, address: 0xD0000,
size: 0x4000, // 4 pages size: 0x4000, // 4 pages
storage_type: kernel::StorageType::STORE, storage_type: kernel::StorageType::Store,
}, },
]; ];
" "

View File

@@ -16,28 +16,28 @@ static mut STORAGE_LOCATIONS: [kernel::StorageLocation; 5] = [
kernel::StorageLocation { kernel::StorageLocation {
address: 0xC0000, address: 0xC0000,
size: 0x10000, // 16 pages size: 0x10000, // 16 pages
storage_type: kernel::StorageType::STORE, storage_type: kernel::StorageType::Store,
}, },
kernel::StorageLocation { kernel::StorageLocation {
address: 0xD0000, address: 0xD0000,
size: 0x4000, // 4 pages size: 0x4000, // 4 pages
storage_type: kernel::StorageType::STORE, storage_type: kernel::StorageType::Store,
}, },
// Partitions can also be split to maximize MPU happiness. // Partitions can also be split to maximize MPU happiness.
kernel::StorageLocation {
address: 0x5000,
size: 0x1000,
storage_type: kernel::StorageType::Partition,
},
kernel::StorageLocation { kernel::StorageLocation {
address: 0x60000, address: 0x60000,
size: 0x20000, size: 0x20000,
storage_type: kernel::StorageType::PARTITION, storage_type: kernel::StorageType::Partition,
}, },
kernel::StorageLocation { kernel::StorageLocation {
address: 0x80000, address: 0x80000,
size: 0x20000, size: 0x20000,
storage_type: kernel::StorageType::PARTITION, storage_type: kernel::StorageType::Partition,
},
kernel::StorageLocation {
address: 0x5000,
size: 0x1000,
storage_type: kernel::StorageType::METADATA,
}, },
]; ];
" "

View File

@@ -16,28 +16,28 @@ static mut STORAGE_LOCATIONS: [kernel::StorageLocation; 5] = [
kernel::StorageLocation { kernel::StorageLocation {
address: 0xC0000, address: 0xC0000,
size: 0x10000, // 16 pages size: 0x10000, // 16 pages
storage_type: kernel::StorageType::STORE, storage_type: kernel::StorageType::Store,
}, },
kernel::StorageLocation { kernel::StorageLocation {
address: 0xD0000, address: 0xD0000,
size: 0x4000, // 4 pages size: 0x4000, // 4 pages
storage_type: kernel::StorageType::STORE, storage_type: kernel::StorageType::Store,
}, },
// Partitions can also be split to maximize MPU happiness. // Partitions can also be split to maximize MPU happiness.
kernel::StorageLocation {
address: 0x4000,
size: 0x1000,
storage_type: kernel::StorageType::Partition,
},
kernel::StorageLocation { kernel::StorageLocation {
address: 0x20000, address: 0x20000,
size: 0x20000, size: 0x20000,
storage_type: kernel::StorageType::PARTITION, storage_type: kernel::StorageType::Partition,
}, },
kernel::StorageLocation { kernel::StorageLocation {
address: 0x40000, address: 0x40000,
size: 0x20000, size: 0x20000,
storage_type: kernel::StorageType::PARTITION, storage_type: kernel::StorageType::Partition,
},
kernel::StorageLocation {
address: 0x4000,
size: 0x1000,
storage_type: kernel::StorageType::METADATA,
}, },
]; ];
" "

View File

@@ -31,19 +31,18 @@ index 5465c95f4..e596648f7 100644
} }
} }
diff --git a/kernel/src/sched.rs b/kernel/src/sched.rs diff --git a/kernel/src/sched.rs b/kernel/src/sched.rs
index 8844bc6c3..692bad2d3 100644 index 8844bc6c3..00c13a7c6 100644
--- a/kernel/src/sched.rs --- a/kernel/src/sched.rs
+++ b/kernel/src/sched.rs +++ b/kernel/src/sched.rs
@@ -118,10 +118,19 @@ pub enum SchedulingDecision { @@ -118,10 +118,18 @@ pub enum SchedulingDecision {
TrySleep, TrySleep,
} }
+/// Represents the type of a storage slice. +/// Represents the type of a storage slice.
+#[derive(Copy, Clone)] +#[derive(Copy, Clone)]
+pub enum StorageType { +pub enum StorageType {
+ STORE = 1, + Store = 1,
+ PARTITION = 2, + Partition = 2,
+ METADATA = 3,
+} +}
+ +
/// Represents a storage location in flash. /// Represents a storage location in flash.

View File

@@ -156,7 +156,7 @@ index f7899d8c5..6956523c6 100644
hil::usb::CtrlSetupResult::ErrGeneric hil::usb::CtrlSetupResult::ErrGeneric
} }
diff --git a/capsules/src/usb/usbc_ctap_hid.rs b/capsules/src/usb/usbc_ctap_hid.rs diff --git a/capsules/src/usb/usbc_ctap_hid.rs b/capsules/src/usb/usbc_ctap_hid.rs
index 642039120..adb7fde14 100644 index 642039120..abf224f97 100644
--- a/capsules/src/usb/usbc_ctap_hid.rs --- a/capsules/src/usb/usbc_ctap_hid.rs
+++ b/capsules/src/usb/usbc_ctap_hid.rs +++ b/capsules/src/usb/usbc_ctap_hid.rs
@@ -44,21 +44,59 @@ static CTAP_REPORT_DESCRIPTOR: &'static [u8] = &[ @@ -44,21 +44,59 @@ static CTAP_REPORT_DESCRIPTOR: &'static [u8] = &[

View File

@@ -262,7 +262,7 @@ index da3d16d85..e8f1a87a4 100644
if !app.waiting { if !app.waiting {
// The call to receive_packet() collected a pending packet. // The call to receive_packet() collected a pending packet.
diff --git a/capsules/src/usb/usbc_ctap_hid.rs b/capsules/src/usb/usbc_ctap_hid.rs diff --git a/capsules/src/usb/usbc_ctap_hid.rs b/capsules/src/usb/usbc_ctap_hid.rs
index adb7fde14..f6762b4b9 100644 index abf224f97..d47e5f644 100644
--- a/capsules/src/usb/usbc_ctap_hid.rs --- a/capsules/src/usb/usbc_ctap_hid.rs
+++ b/capsules/src/usb/usbc_ctap_hid.rs +++ b/capsules/src/usb/usbc_ctap_hid.rs
@@ -11,6 +11,7 @@ use super::descriptors::HIDSubordinateDescriptor; @@ -11,6 +11,7 @@ use super::descriptors::HIDSubordinateDescriptor;

View File

@@ -108,7 +108,7 @@ index e8f1a87a4..2c91c0968 100644
} else { } else {
// Cannot cancel now because the transaction is already in process. // Cannot cancel now because the transaction is already in process.
diff --git a/capsules/src/usb/usbc_ctap_hid.rs b/capsules/src/usb/usbc_ctap_hid.rs diff --git a/capsules/src/usb/usbc_ctap_hid.rs b/capsules/src/usb/usbc_ctap_hid.rs
index f6762b4b9..16b80cb10 100644 index d47e5f644..76f6af73b 100644
--- a/capsules/src/usb/usbc_ctap_hid.rs --- a/capsules/src/usb/usbc_ctap_hid.rs
+++ b/capsules/src/usb/usbc_ctap_hid.rs +++ b/capsules/src/usb/usbc_ctap_hid.rs
@@ -18,13 +18,27 @@ use core::cell::Cell; @@ -18,13 +18,27 @@ use core::cell::Cell;

View File

@@ -52,7 +52,6 @@ mod memop_nr {
mod storage_type { mod storage_type {
pub const STORE: usize = 1; pub const STORE: usize = 1;
pub const PARTITION: usize = 2; pub const PARTITION: usize = 2;
pub const METADATA: usize = 3;
} }
fn get_info(nr: usize, arg: usize) -> StorageResult<usize> { fn get_info(nr: usize, arg: usize) -> StorageResult<usize> {
@@ -225,6 +224,9 @@ pub struct TockUpgradeStorage {
} }
impl TockUpgradeStorage { impl TockUpgradeStorage {
const METADATA_ADDRESS_A: usize = 0x4000;
const METADATA_ADDRESS_B: usize = 0x5000;
/// Provides access to the other upgrade partition and metadata if available. /// Provides access to the other upgrade partition and metadata if available.
/// ///
/// The implementation assumes that storage locations returned by the kernel through /// The implementation assumes that storage locations returned by the kernel through
@@ -250,9 +252,8 @@ impl TockUpgradeStorage {
} }
for i in 0..memop(memop_nr::STORAGE_CNT, 0)? { for i in 0..memop(memop_nr::STORAGE_CNT, 0)? {
let storage_type = memop(memop_nr::STORAGE_TYPE, i)?; let storage_type = memop(memop_nr::STORAGE_TYPE, i)?;
match storage_type { if !matches!(storage_type, storage_type::PARTITION) {
storage_type::PARTITION | storage_type::METADATA => (), continue;
_ => continue,
}; };
let storage_ptr = memop(memop_nr::STORAGE_PTR, i)?; let storage_ptr = memop(memop_nr::STORAGE_PTR, i)?;
let storage_len = memop(memop_nr::STORAGE_LEN, i)?; let storage_len = memop(memop_nr::STORAGE_LEN, i)?;
@@ -260,27 +261,20 @@ impl TockUpgradeStorage {
return Err(StorageError::CustomError); return Err(StorageError::CustomError);
} }
let range = ModRange::new(storage_ptr, storage_len); let range = ModRange::new(storage_ptr, storage_len);
match storage_type { match range.start() {
storage_type::PARTITION => { Self::METADATA_ADDRESS_A | Self::METADATA_ADDRESS_B => locations.metadata = range,
_ => {
locations.partition = locations locations.partition = locations
.partition .partition
.append(range) .append(range)
.ok_or(StorageError::NotAligned)? .ok_or(StorageError::NotAligned)?
} }
storage_type::METADATA => { }
locations.metadata = locations
.metadata
.append(range)
.ok_or(StorageError::NotAligned)?
}
_ => (),
};
} }
if locations.partition.is_empty() || locations.metadata.is_empty() { if locations.partition.is_empty() {
Err(StorageError::CustomError) return Err(StorageError::CustomError);
} else {
Ok(locations)
} }
Ok(locations)
} }
fn is_page_aligned(&self, x: usize) -> bool { fn is_page_aligned(&self, x: usize) -> bool {