flash_store_refactor #49

Merged
sb10q merged 4 commits from flash_store_refactor into master 2021-01-13 17:30:12 +08:00
Showing only changes of commit cef9cf6f48 - Show all commits

View File

@ -20,9 +20,7 @@ pub struct FlashBackend {
} }
unsafe fn get_offset() -> usize { unsafe fn get_offset() -> usize {
let config = core::mem::transmute::<*const usize, usize>(&_config_start); (&_config_start as *const usize as usize) - (&_flash_start as *const usize as usize)
let flash = core::mem::transmute::<*const usize, usize>(&_flash_start);
config - flash
} }
impl StoreBackend for FlashBackend { impl StoreBackend for FlashBackend {
@ -30,13 +28,6 @@ impl StoreBackend for FlashBackend {
fn data(&self) -> &Self::Data { fn data(&self) -> &Self::Data {
unsafe { unsafe {
// This works
// let config = core::mem::transmute::<*const usize, usize>(&_config_start);
// let flash = core::mem::transmute::<*const usize, usize>(&_flash_start);
// let config_offset = config - flash;
// This doesn't
// let config_offset = (&_config_start - &_flash_start) as usize;
&self.flash.read()[get_offset()..(get_offset() + FLASH_SECTOR_SIZE)] &self.flash.read()[get_offset()..(get_offset() + FLASH_SECTOR_SIZE)]
} }
} }