Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax the MultiwriteNorFlash to only need clearing of words #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub(crate) trait PrivateCacheImpl: Invalidate {
&mut self,
flash_range: Range<u32>,
item_address: u32,
item_header: &ItemHeader,
item_header: &ItemHeader<S>,
) {
self.mark_dirty();
self.page_pointers()
Expand All @@ -108,7 +108,7 @@ pub(crate) trait PrivateCacheImpl: Invalidate {
&mut self,
flash_range: Range<u32>,
item_address: u32,
item_header: &ItemHeader,
item_header: &ItemHeader<S>,
) {
self.mark_dirty();
self.page_pointers()
Expand Down
16 changes: 8 additions & 8 deletions src/cache/page_pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ pub(crate) trait PagePointersCache: Debug {
&mut self,
flash_range: Range<u32>,
item_address: u32,
item_header: &ItemHeader,
item_header: &ItemHeader<S>,
);
fn notice_item_erased<S: NorFlash>(
&mut self,
flash_range: Range<u32>,
item_address: u32,
item_header: &ItemHeader,
item_header: &ItemHeader<S>,
);

fn notice_page_state(&mut self, page_index: usize, new_state: PageState);
Expand Down Expand Up @@ -89,11 +89,11 @@ impl<const PAGE_COUNT: usize> PagePointersCache for CachedPagePointers<PAGE_COUN
&mut self,
flash_range: Range<u32>,
item_address: u32,
item_header: &ItemHeader,
item_header: &ItemHeader<S>,
) {
let page_index = calculate_page_index::<S>(flash_range, item_address);

let next_item_address = item_header.next_item_address::<S>(item_address);
let next_item_address = item_header.next_item_address(item_address);

// We only care about the furthest written item, so discard if this is an earlier item
if let Some(first_item_after_written) = self.first_item_after_written(page_index) {
Expand All @@ -109,7 +109,7 @@ impl<const PAGE_COUNT: usize> PagePointersCache for CachedPagePointers<PAGE_COUN
&mut self,
flash_range: Range<u32>,
item_address: u32,
item_header: &ItemHeader,
item_header: &ItemHeader<S>,
) {
let page_index = calculate_page_index::<S>(flash_range.clone(), item_address);

Expand All @@ -120,7 +120,7 @@ impl<const PAGE_COUNT: usize> PagePointersCache for CachedPagePointers<PAGE_COUN

if item_address == next_unerased_item {
self.after_erased_pointers[page_index] =
NonZeroU32::new(item_header.next_item_address::<S>(item_address));
NonZeroU32::new(item_header.next_item_address(item_address));
}
}

Expand Down Expand Up @@ -155,15 +155,15 @@ impl PagePointersCache for UncachedPagePointers {
&mut self,
_flash_range: Range<u32>,
_item_address: u32,
_item_header: &ItemHeader,
_item_header: &ItemHeader<S>,
) {
}

fn notice_item_erased<S: NorFlash>(
&mut self,
_flash_range: Range<u32>,
_item_address: u32,
_item_header: &ItemHeader,
_item_header: &ItemHeader<S>,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/cache/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod queue_tests {
reads: 594934,
writes: 6299,
bytes_read: 2766058,
bytes_written: 53299
bytes_written: 45299,
}
);
}
Expand All @@ -37,7 +37,7 @@ mod queue_tests {
reads: 308740,
writes: 6299,
bytes_read: 2479864,
bytes_written: 53299
bytes_written: 45299
}
);
}
Expand All @@ -51,7 +51,7 @@ mod queue_tests {
reads: 211172,
writes: 6299,
bytes_read: 1699320,
bytes_written: 53299
bytes_written: 45299
}
);
}
Expand Down
Loading
Loading