use the newly extracted utra; fix ranges

in xous, you can't make a range smaller than 4096 bytes,
so range lengths have to be enforced at an abstraction layer
above the page allocator
This commit is contained in:
bunnie 2025-11-25 19:08:07 +08:00
parent 765a36bd3a
commit 1ebf9b8d94

View file

@ -25,9 +25,8 @@ impl BackupManager {
) )
.unwrap() .unwrap()
}; };
let bu_ram = unsafe { let bu_ram =
xous::MemoryRange::new(bao1x_api::offsets::AO_BU_MEM, bao1x_api::offsets::AO_BU_MEM_LEN).unwrap() unsafe { xous::MemoryRange::new(utralib::HW_AORAM_MEM, utralib::HW_AORAM_MEM_LEN).unwrap() };
};
BackupManager { bu_reg, bu_ram } BackupManager { bu_reg, bu_ram }
} }
@ -36,15 +35,15 @@ impl BackupManager {
let bu_reg = xous::map_memory( let bu_reg = xous::map_memory(
xous::MemoryAddress::new(utralib::utra::aobureg::HW_AOBUREG_BASE), xous::MemoryAddress::new(utralib::utra::aobureg::HW_AOBUREG_BASE),
None, None,
utralib::utra::aobureg::AOBUREG_NUMREGS * size_of::<u32>(), 4096,
xous::MemoryFlags::R | xous::MemoryFlags::W, xous::MemoryFlags::R | xous::MemoryFlags::W,
) )
.expect("Couldn't map backup register range"); .expect("Couldn't map backup register range");
let bu_ram = xous::map_memory( let bu_ram = xous::map_memory(
xous::MemoryAddress::new(bao1x_api::offsets::AO_BU_MEM), xous::MemoryAddress::new(utralib::HW_AORAM_MEM),
None, None,
bao1x_api::offsets::AO_BU_MEM_LEN, utralib::HW_AORAM_MEM_LEN,
xous::MemoryFlags::R | xous::MemoryFlags::W, xous::MemoryFlags::R | xous::MemoryFlags::W,
) )
.expect("couldn't map backup RAM range"); .expect("couldn't map backup RAM range");
@ -54,7 +53,7 @@ impl BackupManager {
pub fn is_backup_valid(&self) -> bool { pub fn is_backup_valid(&self) -> bool {
let bu_ram_u32: &[u32] = unsafe { self.bu_ram.as_slice() }; let bu_ram_u32: &[u32] = unsafe { self.bu_ram.as_slice() };
let hash = murmur3_32(bu_ram_u32, 0x0); let hash = murmur3_32(bu_ram_u32, 0x0);
let bu_reg: &[u32] = unsafe { self.bu_reg.as_slice() }; let bu_reg: &[u32] = &unsafe { self.bu_reg.as_slice() }[..utralib::utra::aobureg::AOBUREG_NUMREGS];
hash == bu_reg[HASH_LOC] hash == bu_reg[HASH_LOC]
} }