mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
unbreak hosted mode
This commit is contained in:
parent
f1d91b5b25
commit
b4b6fc2a49
4 changed files with 39 additions and 10 deletions
|
|
@ -254,6 +254,7 @@ pub const BACKUP_VERSION: u32 = 0x00_01_00_00;
|
|||
|
||||
#[repr(u32)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub enum BackupOp {
|
||||
/// This is the value that's kept inside the BackupDataPt
|
||||
Archive = 0,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ use aes::Aes256;
|
|||
use aes::cipher::{KeyInit, BlockDecrypt, BlockEncrypt};
|
||||
use cipher::generic_array::GenericArray;
|
||||
|
||||
use crate::{SignatureResult, GatewareRegion, MetadataInFlash};
|
||||
use crate::{SignatureResult, GatewareRegion, MetadataInFlash, UpdateType};
|
||||
|
||||
use root_keys::key2bits::*;
|
||||
|
||||
|
|
@ -72,13 +72,6 @@ struct PasswordCache {
|
|||
fpga_key_valid: u32,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
pub(crate) enum UpdateType {
|
||||
Regular,
|
||||
BbramProvision,
|
||||
Restore,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
struct SignatureInFlash {
|
||||
pub version: u32,
|
||||
|
|
|
|||
|
|
@ -48,6 +48,12 @@ pub enum GatewareRegion {
|
|||
Staging,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
pub(crate) enum UpdateType {
|
||||
Regular,
|
||||
BbramProvision,
|
||||
Restore,
|
||||
}
|
||||
|
||||
/// An "easily" parseable metadata structure in flash. There's nothing that guarantees the authenticity
|
||||
/// of the metadata in and of itself, other than the digital signature that wraps the entire gateware record.
|
||||
|
|
@ -101,6 +107,8 @@ mod implementation {
|
|||
use aes::cipher::{BlockDecrypt, BlockEncrypt, KeyInit, generic_array::GenericArray};
|
||||
use std::convert::TryInto;
|
||||
use crate::UpdateType;
|
||||
use xous_semver::SemVer;
|
||||
use crate::backups;
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[allow(dead_code)]
|
||||
|
|
@ -135,6 +143,7 @@ mod implementation {
|
|||
}
|
||||
pub fn resume(&self) {
|
||||
}
|
||||
pub fn pddb_recycle(&self) {}
|
||||
|
||||
pub fn update_policy(&mut self, policy: Option<PasswordRetentionPolicy>) {
|
||||
log::info!("policy updated: {:?}", policy);
|
||||
|
|
@ -333,6 +342,24 @@ mod implementation {
|
|||
}
|
||||
pub fn should_prompt_for_update(&self) -> bool {true}
|
||||
pub fn set_prompt_for_update(&self, _state: bool) {}
|
||||
pub fn write_backup(&mut self, header: BackupHeader, backup_ct: backups::BackupDataCt) -> Result<(), xous::Error> {
|
||||
log::info!("backup header: {:?}", header);
|
||||
log::info!("backup ciphertext: {:x?}", backup_ct.as_ref());
|
||||
Ok(())
|
||||
}
|
||||
pub fn read_backup(&mut self) -> Result<(BackupHeader, backups::BackupDataCt), xous::Error> {
|
||||
Err(xous::Error::InternalError)
|
||||
}
|
||||
pub fn erase_backup(&mut self) {}
|
||||
pub fn read_backup_header(&mut self) -> Option<BackupHeader> {
|
||||
None
|
||||
}
|
||||
pub fn get_backup_key(&mut self) -> Option<(backups::BackupKey, backups::KeyRomExport)> {
|
||||
None
|
||||
}
|
||||
pub fn is_zero_key(&self) -> Option<bool> { Some(true) }
|
||||
pub fn setup_restore_init(&mut self, _key: backups::BackupKey, _rom: backups::KeyRomExport) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,19 +73,23 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) {
|
|||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
).expect("couldn't map EC wf200 package memory range");
|
||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||
let ec_package = xous::syscall::map_memory(
|
||||
let mut ec_package = xous::syscall::map_memory(
|
||||
None,
|
||||
None,
|
||||
xous::EC_FW_PKG_LEN as usize,
|
||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
).expect("couldn't map EC firmware package memory range");
|
||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||
let wf_package = xous::syscall::map_memory(
|
||||
for d in ec_package.as_slice_mut::<u8>().iter_mut() { *d = 0xFF } // simulate blank flash
|
||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||
let mut wf_package = xous::syscall::map_memory(
|
||||
None,
|
||||
None,
|
||||
xous::EC_WF200_PKG_LEN as usize,
|
||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
).expect("couldn't map EC wf200 package memory range");
|
||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||
for d in wf_package.as_slice_mut::<u8>().iter_mut() { *d = 0xFF }
|
||||
|
||||
loop {
|
||||
let msg = xous::receive_message(sid).unwrap();
|
||||
|
|
@ -188,6 +192,10 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) {
|
|||
// the semver *could* be bogus at this point, but we'll validate the package (which contains the semver) before we use it.
|
||||
// however, this check is much less computationally expensive than the package validation.
|
||||
let length = u32::from_le_bytes(package[0x28..0x2c].try_into().unwrap());
|
||||
if length == 0xffff_ffff { // nothing was staged at all
|
||||
xous::return_scalar(msg.sender, UpdateResult::PackageInvalid.to_usize().unwrap()).unwrap();
|
||||
continue;
|
||||
}
|
||||
let semver_bytes = &package[0x1000 + length as usize - SEMVER_OFFSET..0x1000 + length as usize - SEMVER_OFFSET + SEMVER_LEN];
|
||||
let pkg_ver = SemVer::from(&semver_bytes[..16].try_into().unwrap());
|
||||
if pkg_ver > ec_reported_rev {
|
||||
|
|
|
|||
Loading…
Reference in a new issue