update boot1 to use slotmanager API

also add the hook for setting up/checking all the other slots
This commit is contained in:
bunnie 2025-10-20 02:20:45 +08:00
parent 356ab47c3c
commit 1d5cc0806b
No known key found for this signature in database
4 changed files with 16 additions and 3 deletions

View file

@ -3,6 +3,7 @@ pub use bao1x::*;
pub mod debug;
pub mod gfx;
pub mod irq;
pub mod slots;
pub mod usb;
pub const UART_BAUD: u32 = 1_000_000;

View file

@ -70,6 +70,8 @@ pub fn setup_dabao_se0_pin<T: IoSetup + IoGpio>(iox: &T) -> (IoxPort, u8) {
/// This can change the board type coding to a safer, simpler board type if the declared board type has
/// problems booting.
pub fn early_init(mut board_type: bao1x_api::BoardTypeCoding) -> (bao1x_api::BoardTypeCoding, u32) {
crate::platform::slots::check_slots(&board_type);
let iox = Iox::new(utra::iox::HW_IOX_BASE as *mut u32);
// setup board-specific I/Os - early boot set. These are items that have to be

View file

@ -0,0 +1,9 @@
/// This function is designed to be called "frequently" to audit the state
/// of the security slots. Its role is to:
/// - Initialize any keys that have not yet been initialized
/// - Update the one-way counters to lock out re-initializations
/// - Verify that the ACLs have been set according to the spec
/// - Repair any ACLs that are not set correctly. "Repair" is expected on first boot at the factory, since
/// the chip comes blank. But repair is also useful in case an adversary manages to flip any ACL states
/// on us.
pub fn check_slots(board_type: &bao1x_api::BoardTypeCoding) {}

View file

@ -201,6 +201,8 @@ impl Repl {
count += 1;
}
crate::println!("Board type set to {:?} after {} increments", new_type, count);
crate::platform::slots::check_slots(&new_type);
crate::println!("Key & data slots checked according to the new type");
}
"audit" => {
let owc = OneWayCounter::new();
@ -214,9 +216,8 @@ impl Repl {
);
crate::println!("Semver is: {}", crate::version::SEMVER);
crate::println!("Description is: {}", crate::RELEASE_DESCRIPTION);
let slot_mgr = bao1x_hal::protected_rram::SlotManager::new();
// TODO: replace with a proper `const` value once we have the slots defined properly
let sn = slot_mgr.read(&bao1x_hal::protected_rram::SlotIndex::Data(0)).unwrap();
let slot_mgr = bao1x_hal::acram::SlotManager::new();
let sn = slot_mgr.read(&bao1x_hal::board::SERIAL_NUMBER).unwrap();
crate::println!(
"Device serializer: {:08x}-{:08x}-{:08x}-{:08x}",
u32::from_le_bytes(sn[12..16].try_into().unwrap()),