mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
some progress on compatibility
This commit is contained in:
parent
eb7a861def
commit
e7a2c97ca3
5 changed files with 35 additions and 20 deletions
|
|
@ -37,6 +37,8 @@ subtle = { version = "2.4.1", default-features = false }
|
||||||
tts-frontend = { path = "../tts", optional = true }
|
tts-frontend = { path = "../tts", optional = true }
|
||||||
rand_core = "0.6.4"
|
rand_core = "0.6.4"
|
||||||
cram-hal-service = { path = "../cram-hal-service", optional = true }
|
cram-hal-service = { path = "../cram-hal-service", optional = true }
|
||||||
|
cramium-emu = { path = "../cramium-emu", optional = true }
|
||||||
|
cramium-api = { path = "../../libs/cramium-api", optional = true }
|
||||||
|
|
||||||
# passwords
|
# passwords
|
||||||
sha2 = { version = "0.10.8" }
|
sha2 = { version = "0.10.8" }
|
||||||
|
|
@ -52,6 +54,7 @@ blowfish = { version = "0.9.1", features = ["bcrypt"] }
|
||||||
gam = { path = "../gam", optional = true }
|
gam = { path = "../gam", optional = true }
|
||||||
locales = { path = "../../locales", optional = true }
|
locales = { path = "../../locales", optional = true }
|
||||||
modals = { path = "../modals", optional = true }
|
modals = { path = "../modals", optional = true }
|
||||||
|
ux-api = { path = "../../libs/ux-api", optional = true, features = ["std"] }
|
||||||
|
|
||||||
utralib = { version = "0.1.25", optional = true, default-features = false }
|
utralib = { version = "0.1.25", optional = true, default-features = false }
|
||||||
|
|
||||||
|
|
@ -71,6 +74,13 @@ precursor = ["utralib/precursor", "sha2/precursor", "gen1"]
|
||||||
hosted = ["utralib/hosted", "sha2/hosted", "gen1"]
|
hosted = ["utralib/hosted", "sha2/hosted", "gen1"]
|
||||||
renode = ["utralib/renode", "sha2/renode", "gen1"]
|
renode = ["utralib/renode", "sha2/renode", "gen1"]
|
||||||
cramium-soc = ["utralib/cramium-soc", "gen2", "cram-hal-service"]
|
cramium-soc = ["utralib/cramium-soc", "gen2", "cram-hal-service"]
|
||||||
|
hosted-baosec = [
|
||||||
|
"gen2",
|
||||||
|
"modals/hosted-baosec",
|
||||||
|
"cramium-emu",
|
||||||
|
"ux-api/hosted-baosec",
|
||||||
|
"cramium-api",
|
||||||
|
]
|
||||||
|
|
||||||
# gen1 PDDB pulls in the graphical libraries for direct capture of passwords
|
# gen1 PDDB pulls in the graphical libraries for direct capture of passwords
|
||||||
# from users. This gives maximum control over the flow of sensitive password data,
|
# from users. This gives maximum control over the flow of sensitive password data,
|
||||||
|
|
@ -95,9 +105,9 @@ gen1 = [
|
||||||
]
|
]
|
||||||
|
|
||||||
# gen-2 features
|
# gen-2 features
|
||||||
gen2 = []
|
gen2 = ["locales", "modals"]
|
||||||
# gen-2 boards
|
# gen-2 boards
|
||||||
board-baosec = []
|
board-baosec = ["ux-api/board-baosec", "cramium-api"]
|
||||||
|
|
||||||
# when selected, physical disk addresses are set to 64 bits, otherwise, they are 32 bits.
|
# when selected, physical disk addresses are set to 64 bits, otherwise, they are 32 bits.
|
||||||
# 32 bit addressing is recommended for Precursor, as its disk is only 128MiB and it has limited RAM for bookkeeping.
|
# 32 bit addressing is recommended for Precursor, as its disk is only 128MiB and it has limited RAM for bookkeeping.
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ use aes::{Aes256, BLOCK_SIZE, Block};
|
||||||
use aes_gcm_siv::aead::{Aead, Payload};
|
use aes_gcm_siv::aead::{Aead, Payload};
|
||||||
use aes_gcm_siv::{Aes256GcmSiv, Nonce, Tag};
|
use aes_gcm_siv::{Aes256GcmSiv, Nonce, Tag};
|
||||||
use backend::bcrypt::*;
|
use backend::bcrypt::*;
|
||||||
#[cfg(feature = "gen1")]
|
#[cfg(not(any(feature = "hosted-baosec", feature = "board-baosec")))]
|
||||||
|
use gam::modal::*;
|
||||||
use modals::Modals;
|
use modals::Modals;
|
||||||
#[cfg(feature = "gen1")]
|
#[cfg(feature = "gen1")]
|
||||||
use root_keys::api::AesRootkeyType;
|
use root_keys::api::AesRootkeyType;
|
||||||
|
|
@ -24,6 +25,8 @@ use root_keys::api::KeywrapError;
|
||||||
use sha2::{Digest, Sha512_256Hw, Sha512_256Sw};
|
use sha2::{Digest, Sha512_256Hw, Sha512_256Sw};
|
||||||
use spinor::SPINOR_BULK_ERASE_SIZE;
|
use spinor::SPINOR_BULK_ERASE_SIZE;
|
||||||
use subtle::ConstantTimeEq;
|
use subtle::ConstantTimeEq;
|
||||||
|
#[cfg(any(feature = "hosted-baosec", feature = "board-baosec"))]
|
||||||
|
use ux_api::widgets::*;
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,10 @@ use core::ops::DerefMut;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
#[cfg(feature = "gen2")]
|
#[cfg(all(feature = "gen2", feature = "cramium-soc"))]
|
||||||
use cram_hal_service::trng;
|
use cram_hal_service::trng;
|
||||||
|
#[cfg(all(feature = "gen2", feature = "hosted-baosec"))]
|
||||||
|
use cramium_emu::trng;
|
||||||
|
|
||||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||||
pub enum CbOp {
|
pub enum CbOp {
|
||||||
|
|
|
||||||
|
|
@ -366,10 +366,8 @@ mod api;
|
||||||
use api::*;
|
use api::*;
|
||||||
mod backend;
|
mod backend;
|
||||||
use backend::*;
|
use backend::*;
|
||||||
#[cfg(feature = "gen1")]
|
|
||||||
mod ux;
|
mod ux;
|
||||||
use rkyv::with::Identity;
|
use rkyv::with::Identity;
|
||||||
#[cfg(feature = "gen1")]
|
|
||||||
use ux::*;
|
use ux::*;
|
||||||
#[cfg(feature = "gen1")]
|
#[cfg(feature = "gen1")]
|
||||||
mod menu;
|
mod menu;
|
||||||
|
|
@ -403,8 +401,10 @@ use std::sync::Arc;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
#[cfg(feature = "gen1")]
|
#[cfg(not(any(feature = "hosted-baosec", feature = "cramium-soc")))]
|
||||||
|
use gam::*;
|
||||||
use locales::t;
|
use locales::t;
|
||||||
|
use modals::Modals;
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
use rkyv::{
|
use rkyv::{
|
||||||
Archive, Place, Serialize,
|
Archive, Place, Serialize,
|
||||||
|
|
@ -413,6 +413,8 @@ use rkyv::{
|
||||||
ser::{Positional, allocator::SubAllocator, writer::Buffer as RkyvBuffer},
|
ser::{Positional, allocator::SubAllocator, writer::Buffer as RkyvBuffer},
|
||||||
with::{ArchiveWith, SerializeWith},
|
with::{ArchiveWith, SerializeWith},
|
||||||
};
|
};
|
||||||
|
#[cfg(any(feature = "hosted-baosec", feature = "cramium-soc"))]
|
||||||
|
use ux_api::widgets::*;
|
||||||
use xous::{Message, msg_blocking_scalar_unpack, send_message};
|
use xous::{Message, msg_blocking_scalar_unpack, send_message};
|
||||||
use xous_ipc::Buffer;
|
use xous_ipc::Buffer;
|
||||||
|
|
||||||
|
|
@ -509,16 +511,12 @@ fn wrapped_main() -> ! {
|
||||||
let entropy = Rc::new(RefCell::new(TrngPool::new()));
|
let entropy = Rc::new(RefCell::new(TrngPool::new()));
|
||||||
|
|
||||||
// for less-secured user prompts (everything but password entry)
|
// for less-secured user prompts (everything but password entry)
|
||||||
#[cfg(feature = "gen1")]
|
let modals = Modals::new(&xns).expect("can't connect to Modals server");
|
||||||
let modals = modals::Modals::new(&xns).expect("can't connect to Modals server");
|
|
||||||
|
|
||||||
// our very own password modal. Password modals are precious and privately owned, to avoid
|
// our very own password modal. Password modals are precious and privately owned, to avoid
|
||||||
// other processes from crafting them.
|
// other processes from crafting them.
|
||||||
#[cfg(feature = "gen1")]
|
|
||||||
let pw_sid = xous::create_server().expect("couldn't create a server for the password UX handler");
|
let pw_sid = xous::create_server().expect("couldn't create a server for the password UX handler");
|
||||||
#[cfg(feature = "gen1")]
|
|
||||||
let pw_cid = xous::connect(pw_sid).expect("couldn't connect to the password UX handler");
|
let pw_cid = xous::connect(pw_sid).expect("couldn't connect to the password UX handler");
|
||||||
#[cfg(feature = "gen1")]
|
|
||||||
let pw_handle = thread::spawn({
|
let pw_handle = thread::spawn({
|
||||||
// this comment keeps rustfmt from flattening this block
|
// this comment keeps rustfmt from flattening this block
|
||||||
move || password_ux_manager(xous::connect(pddb_sid).unwrap(), pw_sid)
|
move || password_ux_manager(xous::connect(pddb_sid).unwrap(), pw_sid)
|
||||||
|
|
@ -726,13 +724,10 @@ fn wrapped_main() -> ! {
|
||||||
// retries.
|
// retries.
|
||||||
// If we need more nuance out of this routine, consider creating a custom public enum type to help
|
// If we need more nuance out of this routine, consider creating a custom public enum type to help
|
||||||
// marshall this.
|
// marshall this.
|
||||||
#[cfg(feature = "gen2")]
|
|
||||||
Opcode::TryMount => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
Opcode::TryMount => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||||
unimplemented!();
|
|
||||||
}),
|
|
||||||
#[cfg(feature = "gen1")]
|
#[cfg(feature = "gen1")]
|
||||||
Opcode::TryMount => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
|
||||||
let llio = llio::Llio::new(&xns);
|
let llio = llio::Llio::new(&xns);
|
||||||
|
#[cfg(feature = "gen1")]
|
||||||
while !llio.is_ec_ready() {
|
while !llio.is_ec_ready() {
|
||||||
// spin-wait while the EC is not ready -- so that a PDDB mount does not interfere with
|
// spin-wait while the EC is not ready -- so that a PDDB mount does not interfere with
|
||||||
// on-going EC updates. Also causes the mount dialog to delay until the EC status has been
|
// on-going EC updates. Also causes the mount dialog to delay until the EC status has been
|
||||||
|
|
@ -746,7 +741,9 @@ fn wrapped_main() -> ! {
|
||||||
// can't mount if we have no root keys
|
// can't mount if we have no root keys
|
||||||
log::info!("{}PDDB.SKIPMOUNT,{}", xous::BOOKEND_START, xous::BOOKEND_END);
|
log::info!("{}PDDB.SKIPMOUNT,{}", xous::BOOKEND_START, xous::BOOKEND_END);
|
||||||
// allow the main menu to be used in this case
|
// allow the main menu to be used in this case
|
||||||
|
#[cfg(feature = "gen1")]
|
||||||
let gam = gam::Gam::new(&xns).unwrap();
|
let gam = gam::Gam::new(&xns).unwrap();
|
||||||
|
#[cfg(feature = "gen1")]
|
||||||
gam.allow_mainmenu().expect("couldn't allow main menu activation");
|
gam.allow_mainmenu().expect("couldn't allow main menu activation");
|
||||||
xous::return_scalar2(msg.sender, 1, 0).expect("could't return scalar");
|
xous::return_scalar2(msg.sender, 1, 0).expect("could't return scalar");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -816,7 +813,9 @@ fn wrapped_main() -> ! {
|
||||||
}
|
}
|
||||||
// get a handle to the GAM and inform it that main menu should be allowed. The handle
|
// get a handle to the GAM and inform it that main menu should be allowed. The handle
|
||||||
// is dropped when this routine finishes.
|
// is dropped when this routine finishes.
|
||||||
|
#[cfg(feature = "gen1")]
|
||||||
let gam = gam::Gam::new(&xns).unwrap();
|
let gam = gam::Gam::new(&xns).unwrap();
|
||||||
|
#[cfg(feature = "gen1")]
|
||||||
gam.allow_mainmenu().expect("couldn't allow main menu activation");
|
gam.allow_mainmenu().expect("couldn't allow main menu activation");
|
||||||
// setup the heap
|
// setup the heap
|
||||||
initial_heap = heap_usage();
|
initial_heap = heap_usage();
|
||||||
|
|
@ -2346,7 +2345,6 @@ fn wrapped_main() -> ! {
|
||||||
xous::terminate_process(0)
|
xous::terminate_process(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gen1")]
|
|
||||||
fn ensure_password(modals: &modals::Modals, pddb_os: &mut PddbOs, _pw_cid: xous::CID) -> PasswordState {
|
fn ensure_password(modals: &modals::Modals, pddb_os: &mut PddbOs, _pw_cid: xous::CID) -> PasswordState {
|
||||||
log::info!("Requesting login password");
|
log::info!("Requesting login password");
|
||||||
loop {
|
loop {
|
||||||
|
|
@ -2407,7 +2405,6 @@ fn ensure_password(modals: &modals::Modals, pddb_os: &mut PddbOs, _pw_cid: xous:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gen1")]
|
|
||||||
fn try_mount_or_format(
|
fn try_mount_or_format(
|
||||||
modals: &modals::Modals,
|
modals: &modals::Modals,
|
||||||
pddb_os: &mut PddbOs,
|
pddb_os: &mut PddbOs,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
|
#[cfg(not(any(feature = "hosted-baosec", feature = "cramium-soc")))]
|
||||||
use gam::modal::*;
|
use gam::modal::*;
|
||||||
use locales::t;
|
use locales::t;
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
|
#[cfg(any(feature = "hosted-baosec", feature = "cramium-soc"))]
|
||||||
|
use ux_api::widgets::*;
|
||||||
use xous::msg_scalar_unpack;
|
use xous::msg_scalar_unpack;
|
||||||
use xous::{CID, SID};
|
use xous::{CID, SID};
|
||||||
use xous_ipc::Buffer;
|
use xous_ipc::Buffer;
|
||||||
|
|
@ -116,7 +119,7 @@ pub(crate) fn password_ux_manager(
|
||||||
}
|
}
|
||||||
Some(PwManagerOpcode::PwReturn) => {
|
Some(PwManagerOpcode::PwReturn) => {
|
||||||
let mut buf = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
let mut buf = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||||
let pw = buf.to_original::<gam::modal::TextEntryPayloads, _>().unwrap();
|
let pw = buf.to_original::<TextEntryPayloads, _>().unwrap();
|
||||||
|
|
||||||
if let Some(mut response) = dr.take() {
|
if let Some(mut response) = dr.take() {
|
||||||
let mut buffer = unsafe {
|
let mut buffer = unsafe {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue