mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +00:00
Merge branch 'libstd-fs'
This commit is contained in:
commit
13b6669445
6 changed files with 201 additions and 190 deletions
|
|
@ -431,7 +431,7 @@ impl SystemServices {
|
||||||
entry.state = ProcessState::Ready(1 << INITIAL_TID);
|
entry.state = ProcessState::Ready(1 << INITIAL_TID);
|
||||||
}
|
}
|
||||||
// entry.ppid = _ppid;
|
// entry.ppid = _ppid;
|
||||||
klog!("created new process for PID {} with PPID {}", new_pid, ppid);
|
klog!("created new process for PID {} with PPID {}", new_pid, _ppid);
|
||||||
return Ok(startup);
|
return Ok(startup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,93 +113,93 @@ pub struct UxRegistration {
|
||||||
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
||||||
pub(crate) enum Opcode {
|
pub(crate) enum Opcode {
|
||||||
// clears a canvas with a given GID
|
// clears a canvas with a given GID
|
||||||
ClearCanvas, //(Gid),
|
ClearCanvas = 0, //(Gid),
|
||||||
|
|
||||||
// return the dimensions of a canvas as a Point (the top left is always (0,0))
|
// return the dimensions of a canvas as a Point (the top left is always (0,0))
|
||||||
GetCanvasBounds, //(Gid),
|
GetCanvasBounds = 1, //(Gid),
|
||||||
|
|
||||||
// request a new size for my canvas.
|
// request a new size for my canvas.
|
||||||
// This normally will be denied, unless the requested Gid corresponds to a special canvas that allows resizing.
|
// This normally will be denied, unless the requested Gid corresponds to a special canvas that allows resizing.
|
||||||
SetCanvasBounds, //(SetCanvasBoundsRequest),
|
SetCanvasBounds = 2, //(SetCanvasBoundsRequest),
|
||||||
|
|
||||||
// draws an object
|
// draws an object
|
||||||
RenderObject, //(GamObject),
|
RenderObject = 3, //(GamObject),
|
||||||
RenderObjectList,
|
RenderObjectList = 4,
|
||||||
// draws a tile. this is *not* part of the ObjectList because then every vector object suddenly also carries
|
// draws a tile. this is *not* part of the ObjectList because then every vector object suddenly also carries
|
||||||
// the allocation burden of a bitmap tile.
|
// the allocation burden of a bitmap tile.
|
||||||
#[cfg(feature="ditherpunk")]
|
#[cfg(feature="ditherpunk")]
|
||||||
RenderTile,
|
RenderTile = 5,
|
||||||
|
|
||||||
// renders a TextView
|
// renders a TextView
|
||||||
RenderTextView, //(TextView),
|
RenderTextView = 6, //(TextView),
|
||||||
|
|
||||||
// forces a redraw (which also does defacement, etc.)
|
// forces a redraw (which also does defacement, etc.)
|
||||||
Redraw,
|
Redraw = 7,
|
||||||
|
|
||||||
// returns a GID to the "content" Canvas of the token holder
|
// returns a GID to the "content" Canvas of the token holder
|
||||||
RequestContentCanvas,
|
RequestContentCanvas = 8,
|
||||||
|
|
||||||
// registers a Ux of a requested type
|
// registers a Ux of a requested type
|
||||||
// takes in the LayoutType, default PredictorType, a SID for UxEvents, a human-readable identifier token; returns a content canvas GID
|
// takes in the LayoutType, default PredictorType, a SID for UxEvents, a human-readable identifier token; returns a content canvas GID
|
||||||
// also takes a bunch of optional ID codes for the various callbacks
|
// also takes a bunch of optional ID codes for the various callbacks
|
||||||
// internally assigns a trust level, based on a first-come first-serve basis for known services, and then a much lower trust for rando ones
|
// internally assigns a trust level, based on a first-come first-serve basis for known services, and then a much lower trust for rando ones
|
||||||
RegisterUx,
|
RegisterUx = 9,
|
||||||
|
|
||||||
// updates the audio connection ID post-registration
|
// updates the audio connection ID post-registration
|
||||||
SetAudioOpcode,
|
SetAudioOpcode = 10,
|
||||||
|
|
||||||
// Requests setting the UI to the power down screen
|
// Requests setting the UI to the power down screen
|
||||||
PowerDownRequest,
|
PowerDownRequest = 11,
|
||||||
|
|
||||||
// Request blank screen for ship mode
|
// Request blank screen for ship mode
|
||||||
ShipModeBlankRequest,
|
ShipModeBlankRequest = 12,
|
||||||
|
|
||||||
// used to claim a GAM registration token (should be used only by status.rs)
|
// used to claim a GAM registration token (should be used only by status.rs)
|
||||||
ClaimToken,
|
ClaimToken = 13,
|
||||||
// used to set a predictor API token (should be used only by ime-frontend)
|
// used to set a predictor API token (should be used only by ime-frontend)
|
||||||
PredictorApiToken,
|
PredictorApiToken = 14,
|
||||||
|
|
||||||
/// system-level API that can be called by the Xous process launcher to check if we're at a state where less trusted code could be run
|
/// system-level API that can be called by the Xous process launcher to check if we're at a state where less trusted code could be run
|
||||||
/// it basically checks that all tokens have been claimed by trusted OS procesess, thus blocking any further token creation
|
/// it basically checks that all tokens have been claimed by trusted OS procesess, thus blocking any further token creation
|
||||||
TrustedInitDone,
|
TrustedInitDone = 15,
|
||||||
|
|
||||||
/// this is used internally to route input lines from the IMEF
|
/// this is used internally to route input lines from the IMEF
|
||||||
InputLine,
|
InputLine = 16,
|
||||||
|
|
||||||
/// passed to the keyboard server to notify me of a keyboard event
|
/// passed to the keyboard server to notify me of a keyboard event
|
||||||
KeyboardEvent,
|
KeyboardEvent = 17,
|
||||||
|
|
||||||
/// used to turn keyboard vibrate on and off
|
/// used to turn keyboard vibrate on and off
|
||||||
Vibe,
|
Vibe = 18,
|
||||||
/// used to toggle menu mode behavior for the prediction area (default: false)
|
/// used to toggle menu mode behavior for the prediction area (default: false)
|
||||||
ToggleMenuMode,
|
ToggleMenuMode = 19,
|
||||||
|
|
||||||
/// called by a context when it's done with taking the screen; requests the GAM to revert focus to the last-focused app
|
/// called by a context when it's done with taking the screen; requests the GAM to revert focus to the last-focused app
|
||||||
RevertFocus,
|
RevertFocus = 20,
|
||||||
RevertFocusNb, // non-blocking version
|
RevertFocusNb = 21, // non-blocking version
|
||||||
|
|
||||||
/// pass-through to get glyph heights to assist with layout planning, without having to create a gfx connection
|
/// pass-through to get glyph heights to assist with layout planning, without having to create a gfx connection
|
||||||
QueryGlyphProps,
|
QueryGlyphProps = 22,
|
||||||
|
|
||||||
/// request redraw of IME area
|
/// request redraw of IME area
|
||||||
RedrawIme,
|
RedrawIme = 23,
|
||||||
|
|
||||||
/// switch focus to an app
|
/// switch focus to an app
|
||||||
SwitchToApp,
|
SwitchToApp = 24,
|
||||||
|
|
||||||
/// raise a context menu
|
/// raise a context menu
|
||||||
RaiseMenu,
|
RaiseMenu = 25,
|
||||||
|
|
||||||
/// Turn on Devboot Flag
|
/// Turn on Devboot Flag
|
||||||
Devboot,
|
Devboot = 26,
|
||||||
|
|
||||||
/// Show a test pattern. Can only call this once (to prevent abuse)
|
/// Show a test pattern. Can only call this once (to prevent abuse)
|
||||||
TestPattern,
|
TestPattern = 27,
|
||||||
|
|
||||||
/// Toggle debug on serial console
|
/// Toggle debug on serial console
|
||||||
SetDebugLevel,
|
SetDebugLevel = 28,
|
||||||
|
|
||||||
Quit,
|
Quit = 29,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
|
|
|
||||||
|
|
@ -77,43 +77,43 @@ pub struct DynamicNotification {
|
||||||
pub(crate) enum Opcode {
|
pub(crate) enum Opcode {
|
||||||
// these are blocking calls
|
// these are blocking calls
|
||||||
/// ask a question, get a single response from a list of defined items (radio box)
|
/// ask a question, get a single response from a list of defined items (radio box)
|
||||||
PromptWithFixedResponse,
|
PromptWithFixedResponse = 0,
|
||||||
/// ask a question, get multiple responses from a list of defined items (check box)
|
/// ask a question, get multiple responses from a list of defined items (check box)
|
||||||
PromptWithMultiResponse,
|
PromptWithMultiResponse = 1,
|
||||||
/// simple notification
|
/// simple notification
|
||||||
Notification,
|
Notification = 2,
|
||||||
/// display an image
|
/// display an image
|
||||||
#[cfg(feature = "ditherpunk")]
|
#[cfg(feature = "ditherpunk")]
|
||||||
Image,
|
Image = 3,
|
||||||
/// dynamic notification - a simple non-interactive notification that allows its text to be dynamically updated
|
/// dynamic notification - a simple non-interactive notification that allows its text to be dynamically updated
|
||||||
DynamicNotification,
|
DynamicNotification = 4,
|
||||||
/// listen to dynamic notification - a blocking call, meant to be called from a separate thread from the control loop
|
/// listen to dynamic notification - a blocking call, meant to be called from a separate thread from the control loop
|
||||||
ListenToDynamicNotification,
|
ListenToDynamicNotification = 5,
|
||||||
|
|
||||||
/// ask a question, get a free-form answer back
|
/// ask a question, get a free-form answer back
|
||||||
PromptWithTextResponse,
|
PromptWithTextResponse = 6,
|
||||||
/// must be used by the PromptWithTextResponse caller to acknowledge correct input
|
/// must be used by the PromptWithTextResponse caller to acknowledge correct input
|
||||||
TextResponseValid,
|
TextResponseValid = 7,
|
||||||
|
|
||||||
// these are non-blocking calls
|
// these are non-blocking calls
|
||||||
/// add an item to the radio box or check box. Note that all added items
|
/// add an item to the radio box or check box. Note that all added items
|
||||||
/// are cleared after the relevant "action" call happens (PromptWith[Fixed,Multi]Response)
|
/// are cleared after the relevant "action" call happens (PromptWith[Fixed,Multi]Response)
|
||||||
AddModalItem,
|
AddModalItem = 8,
|
||||||
/// get the index of the selected radio button / checkboxes
|
/// get the index of the selected radio button / checkboxes
|
||||||
GetModalIndex,
|
GetModalIndex = 9,
|
||||||
/// raise a progress bar
|
/// raise a progress bar
|
||||||
StartProgress,
|
StartProgress = 10,
|
||||||
/// update the progress bar
|
/// update the progress bar
|
||||||
DoUpdateProgress,
|
DoUpdateProgress = 11,
|
||||||
/// lower a progress bar
|
/// lower a progress bar
|
||||||
StopProgress,
|
StopProgress = 12,
|
||||||
/// update a dynamic notification's text
|
/// update a dynamic notification's text
|
||||||
UpdateDynamicNotification,
|
UpdateDynamicNotification = 13,
|
||||||
/// close dynamic notification
|
/// close dynamic notification
|
||||||
CloseDynamicNotification,
|
CloseDynamicNotification = 14,
|
||||||
|
|
||||||
/// used by libraries to get the mutex on the server
|
/// used by libraries to get the mutex on the server
|
||||||
GetMutex,
|
GetMutex = 15,
|
||||||
|
|
||||||
// these are used internally by the modals to handle intermediate state. Do not call from the outside.
|
// these are used internally by the modals to handle intermediate state. Do not call from the outside.
|
||||||
// these were originally handled in a separate thread for deferred responses using busy-waits. They are
|
// these were originally handled in a separate thread for deferred responses using busy-waits. They are
|
||||||
|
|
@ -121,24 +121,24 @@ pub(crate) enum Opcode {
|
||||||
// it does expose some of the internal API mechanics to outside processes. This is fine for the modals
|
// it does expose some of the internal API mechanics to outside processes. This is fine for the modals
|
||||||
// box because it's a convenience routine used by "everyone"; password boxes are always handled within
|
// box because it's a convenience routine used by "everyone"; password boxes are always handled within
|
||||||
// a given secured server so that the attack surface for these do not extend into the modals boundary.
|
// a given secured server so that the attack surface for these do not extend into the modals boundary.
|
||||||
InitiateOp,
|
InitiateOp = 16,
|
||||||
FinishProgress,
|
FinishProgress = 17,
|
||||||
|
|
||||||
TextEntryReturn,
|
TextEntryReturn = 18,
|
||||||
RadioReturn,
|
RadioReturn = 19,
|
||||||
CheckBoxReturn,
|
CheckBoxReturn = 20,
|
||||||
NotificationReturn,
|
NotificationReturn = 21,
|
||||||
#[cfg(feature = "ditherpunk")]
|
#[cfg(feature = "ditherpunk")]
|
||||||
ImageReturn,
|
ImageReturn = 22,
|
||||||
|
|
||||||
DoUpdateDynamicNotification,
|
DoUpdateDynamicNotification = 23,
|
||||||
DoCloseDynamicNotification,
|
DoCloseDynamicNotification = 24,
|
||||||
HandleDynamicNotificationKeyhit,
|
HandleDynamicNotificationKeyhit = 25,
|
||||||
|
|
||||||
ModalRedraw,
|
ModalRedraw = 26,
|
||||||
ModalKeypress,
|
ModalKeypress = 27,
|
||||||
ModalDrop,
|
ModalDrop = 28,
|
||||||
Gutter,
|
Gutter = 29,
|
||||||
|
|
||||||
Quit,
|
Quit = 30,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,82 +85,88 @@ pub(crate) const BCRYPT_COST: u32 = 7; // 10 is the minimum recommended by OWA
|
||||||
|
|
||||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||||
pub(crate) enum Opcode {
|
pub(crate) enum Opcode {
|
||||||
IsMounted,
|
IsMounted = 0,
|
||||||
TryMount,
|
TryMount = 1,
|
||||||
|
|
||||||
ListBasis,
|
ListBasis = 2,
|
||||||
LatestBasis,
|
LatestBasis = 3,
|
||||||
/// Note that creating a basis does not automatically open it!
|
/// Note that creating a basis does not automatically open it!
|
||||||
CreateBasis,
|
CreateBasis = 4,
|
||||||
OpenBasis,
|
OpenBasis = 5,
|
||||||
CloseBasis,
|
CloseBasis = 6,
|
||||||
/// warning, the Delete routines have not been well tested
|
/// warning, the Delete routines have not been well tested
|
||||||
DeleteBasis,
|
DeleteBasis = 7,
|
||||||
DeleteKey,
|
DeleteKey = 8,
|
||||||
DeleteDict,
|
DeleteDict = 9,
|
||||||
KeyAttributes,
|
KeyAttributes = 10,
|
||||||
|
|
||||||
// routines to list available resources
|
// routines to list available resources
|
||||||
KeyCountInDict,
|
KeyCountInDict = 11,
|
||||||
GetKeyNameAtIndex,
|
GetKeyNameAtIndex = 12,
|
||||||
DictCountInBasis,
|
DictCountInBasis = 13,
|
||||||
GetDictNameAtIndex,
|
GetDictNameAtIndex = 14,
|
||||||
|
|
||||||
/// primary method for accessing the database
|
/// primary method for accessing the database
|
||||||
KeyRequest,
|
KeyRequest = 15,
|
||||||
|
|
||||||
// pddbkey methods
|
// pddbkey methods
|
||||||
ReadKey,
|
ReadKey = 16,
|
||||||
WriteKey,
|
WriteKey = 17,
|
||||||
WriteKeyFlush,
|
WriteKeyFlush = 18,
|
||||||
|
|
||||||
// GC methods
|
// GC methods
|
||||||
PeriodicScrub,
|
PeriodicScrub = 19,
|
||||||
|
|
||||||
/// drops any connection state associated with a given key
|
/// drops any connection state associated with a given key
|
||||||
KeyDrop,
|
KeyDrop = 20,
|
||||||
|
|
||||||
/// Menu opcodes
|
/// Menu opcodes
|
||||||
MenuListBasis,
|
MenuListBasis = 21,
|
||||||
|
|
||||||
/// Security state checks
|
/// Security state checks
|
||||||
IsEfuseSecured,
|
IsEfuseSecured = 22,
|
||||||
|
|
||||||
/// Suspend/resume callback
|
/// Suspend/resume callback
|
||||||
SuspendResume,
|
SuspendResume = 23,
|
||||||
/// quit the server
|
/// quit the server
|
||||||
Quit,
|
Quit = 24,
|
||||||
/// Write debug dump (only available in hosted mode)
|
/// Write debug dump (only available in hosted mode)
|
||||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||||
DangerousDebug,
|
DangerousDebug = 25,
|
||||||
|
|
||||||
|
/// This key type could not be decoded
|
||||||
|
InvalidOpcode = u32::MAX as _,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||||
pub(crate) enum PollOp {
|
pub(crate) enum PollOp {
|
||||||
Poll,
|
Poll = 0,
|
||||||
Quit,
|
Quit = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ApiToken = [u32; 3];
|
pub type ApiToken = [u32; 3];
|
||||||
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct PddbBasisList {
|
pub struct PddbBasisList {
|
||||||
/// the first 63 that fit in the list -- generally we anticipate not more than a few being open at a time, so this should be enough.
|
/// the first 63 that fit in the list -- generally we anticipate not more than a few being open at a time, so this should be enough.
|
||||||
pub list: [xous_ipc::String::<BASIS_NAME_LEN>; 63],
|
pub list: [xous_ipc::String::<BASIS_NAME_LEN>; 63],
|
||||||
/// total number of basis open. Should be <= 63, but we allow it to be larger to indicate cases where this structure wasn't big enough.
|
/// total number of basis open. Should be <= 63, but we allow it to be larger to indicate cases where this structure wasn't big enough.
|
||||||
pub num: u32,
|
pub num: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
pub enum PddbRequestCode {
|
pub enum PddbRequestCode {
|
||||||
Create,
|
Create = 0,
|
||||||
Open,
|
Open = 1,
|
||||||
Close,
|
Close = 2,
|
||||||
Delete,
|
Delete = 3,
|
||||||
NoErr,
|
NoErr = 4,
|
||||||
NotMounted,
|
NotMounted = 5,
|
||||||
NoFreeSpace,
|
NoFreeSpace = 6,
|
||||||
NotFound,
|
NotFound = 7,
|
||||||
InternalError,
|
InternalError = 8,
|
||||||
AccessDenied,
|
AccessDenied = 9,
|
||||||
Uninit,
|
Uninit = 10,
|
||||||
}
|
}
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||||
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
|
|
@ -222,26 +228,31 @@ pub(crate) enum PddbRetcode {
|
||||||
InternalError = 5,
|
InternalError = 5,
|
||||||
DiskFull = 6,
|
DiskFull = 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// PddbBuf is a C-representation of a page of memory that's used
|
/// PddbBuf is a C-representation of a page of memory that's used
|
||||||
/// to shuttle data for streaming channels. It must be exactly one
|
/// to shuttle data for streaming channels. It must be exactly one
|
||||||
/// page in size, with some overhead specific to the PDDB book-keeping
|
/// page in size, with some overhead specific to the PDDB book-keeping
|
||||||
/// at the top, and the remainder available for shuttling data.
|
/// at the top, and the remainder available for shuttling data.
|
||||||
///
|
#[repr(C, align(4096))]
|
||||||
/// It does not use rkyv, as the blanket implementation of that tends to
|
|
||||||
/// incur too many extra copies an/or zeroing operations.
|
|
||||||
#[repr(C, packed)]
|
|
||||||
pub(crate) struct PddbBuf {
|
pub(crate) struct PddbBuf {
|
||||||
/// api token for the given buffer
|
/// api token for the given buffer
|
||||||
pub(crate) token: ApiToken,
|
pub(crate) token: ApiToken,
|
||||||
/// point in the key stream. 64-bit for future-compatibility; but, can't be larger than 32 bits on a 32-bit target.
|
|
||||||
pub(crate) position: u64,
|
|
||||||
/// length of the data field
|
|
||||||
pub(crate) len: u16,
|
|
||||||
/// a field reserved for the return code
|
/// a field reserved for the return code
|
||||||
pub(crate) retcode: PddbRetcode,
|
pub(crate) retcode: PddbRetcode,
|
||||||
pub(crate) reserved: u8,
|
reserved: u8,
|
||||||
|
/// length of the data field
|
||||||
|
pub(crate) len: u16,
|
||||||
|
/// point in the key stream. 64-bit for future-compatibility; but, can't be larger than 32 bits on a 32-bit target.
|
||||||
|
pub(crate) position: u64,
|
||||||
pub(crate) data: [u8; 4072],
|
pub(crate) data: [u8; 4072],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
/// Ensure that the `PddbBuf` struct is exactly one page big
|
||||||
|
const fn _assert_pddbbuf_is_4096_bytes() {
|
||||||
|
unsafe { core::mem::transmute::<_, PddbBuf>([0u8; 4096]); }
|
||||||
|
}
|
||||||
|
|
||||||
impl PddbBuf {
|
impl PddbBuf {
|
||||||
pub(crate) fn from_slice_mut(slice: &mut [u8]) -> &mut PddbBuf {
|
pub(crate) fn from_slice_mut(slice: &mut [u8]) -> &mut PddbBuf {
|
||||||
// this transforms the slice [u8] into a PddbBuf ref.
|
// this transforms the slice [u8] into a PddbBuf ref.
|
||||||
|
|
@ -342,8 +353,8 @@ pub struct PddbDangerousDebug {
|
||||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||||
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
pub enum DebugRequest {
|
pub enum DebugRequest {
|
||||||
Dump,
|
Dump = 0,
|
||||||
Remount,
|
Remount = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
||||||
|
|
@ -551,26 +551,26 @@ fn main() -> ! {
|
||||||
Opcode::SuspendResume as u32, my_cid).expect("couldn't create suspend/resume object");
|
Opcode::SuspendResume as u32, my_cid).expect("couldn't create suspend/resume object");
|
||||||
loop {
|
loop {
|
||||||
let mut msg = xous::receive_message(pddb_sid).unwrap();
|
let mut msg = xous::receive_message(pddb_sid).unwrap();
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()).unwrap_or(Opcode::InvalidOpcode) {
|
||||||
Some(Opcode::SuspendResume) => xous::msg_scalar_unpack!(msg, token, _, _, _, {
|
Opcode::SuspendResume => xous::msg_scalar_unpack!(msg, token, _, _, _, {
|
||||||
basis_cache.suspend(&mut pddb_os);
|
basis_cache.suspend(&mut pddb_os);
|
||||||
susres.suspend_until_resume(token).expect("couldn't execute suspend/resume");
|
susres.suspend_until_resume(token).expect("couldn't execute suspend/resume");
|
||||||
}),
|
}),
|
||||||
Some(Opcode::IsEfuseSecured) => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
Opcode::IsEfuseSecured => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||||
if pddb_os.is_efuse_secured() {
|
if pddb_os.is_efuse_secured() {
|
||||||
xous::return_scalar(msg.sender, 1).unwrap();
|
xous::return_scalar(msg.sender, 1).unwrap();
|
||||||
} else {
|
} else {
|
||||||
xous::return_scalar(msg.sender, 0).unwrap();
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Some(Opcode::IsMounted) => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
Opcode::IsMounted => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||||
if basis_cache.basis_count() > 0 { // if there's anything in the cache, we're mounted.
|
if basis_cache.basis_count() > 0 { // if there's anything in the cache, we're mounted.
|
||||||
xous::return_scalar(msg.sender, 1).expect("couldn't return scalar");
|
xous::return_scalar(msg.sender, 1).expect("couldn't return scalar");
|
||||||
} else {
|
} else {
|
||||||
mount_notifications.push(msg.sender); // defer response until later
|
mount_notifications.push(msg.sender); // defer response until later
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Some(Opcode::TryMount) => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
Opcode::TryMount => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||||
if basis_cache.basis_count() > 0 {
|
if basis_cache.basis_count() > 0 {
|
||||||
xous::return_scalar(msg.sender, 1).expect("couldn't return scalar");
|
xous::return_scalar(msg.sender, 1).expect("couldn't return scalar");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -617,7 +617,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Some(Opcode::PeriodicScrub) => {
|
Opcode::PeriodicScrub => {
|
||||||
let current_heap = heap_usage();
|
let current_heap = heap_usage();
|
||||||
let current_cache = basis_cache.cache_size();
|
let current_cache = basis_cache.cache_size();
|
||||||
if current_heap != latest_heap || current_cache != latest_cache {
|
if current_heap != latest_heap || current_cache != latest_cache {
|
||||||
|
|
@ -661,7 +661,7 @@ fn main() -> ! {
|
||||||
heap_increased = true;
|
heap_increased = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Opcode::ListBasis) => {
|
Opcode::ListBasis => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut list_ipc = buffer.to_original::<PddbBasisList, _>().unwrap();
|
let mut list_ipc = buffer.to_original::<PddbBasisList, _>().unwrap();
|
||||||
let basis_list = basis_cache.basis_list();
|
let basis_list = basis_cache.basis_list();
|
||||||
|
|
@ -672,7 +672,7 @@ fn main() -> ! {
|
||||||
list_ipc.num = basis_list.len() as u32;
|
list_ipc.num = basis_list.len() as u32;
|
||||||
buffer.replace(list_ipc).unwrap();
|
buffer.replace(list_ipc).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::LatestBasis) => {
|
Opcode::LatestBasis => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut mgmt = buffer.to_original::<PddbBasisRequest, _>().unwrap();
|
let mut mgmt = buffer.to_original::<PddbBasisRequest, _>().unwrap();
|
||||||
if let Some(name) = basis_cache.basis_latest() {
|
if let Some(name) = basis_cache.basis_latest() {
|
||||||
|
|
@ -684,7 +684,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
buffer.replace(mgmt).unwrap();
|
buffer.replace(mgmt).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::CreateBasis) => {
|
Opcode::CreateBasis => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut mgmt = buffer.to_original::<PddbBasisRequest, _>().unwrap();
|
let mut mgmt = buffer.to_original::<PddbBasisRequest, _>().unwrap();
|
||||||
match mgmt.code {
|
match mgmt.code {
|
||||||
|
|
@ -711,7 +711,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
buffer.replace(mgmt).unwrap();
|
buffer.replace(mgmt).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::OpenBasis) => {
|
Opcode::OpenBasis => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut mgmt = buffer.to_original::<PddbBasisRequest, _>().unwrap();
|
let mut mgmt = buffer.to_original::<PddbBasisRequest, _>().unwrap();
|
||||||
match mgmt.code {
|
match mgmt.code {
|
||||||
|
|
@ -764,7 +764,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
buffer.replace(mgmt).unwrap();
|
buffer.replace(mgmt).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::CloseBasis) => {
|
Opcode::CloseBasis => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut mgmt = buffer.to_original::<PddbBasisRequest, _>().unwrap();
|
let mut mgmt = buffer.to_original::<PddbBasisRequest, _>().unwrap();
|
||||||
notify_of_disconnect(&mut pddb_os, &token_dict, &mut basis_cache);
|
notify_of_disconnect(&mut pddb_os, &token_dict, &mut basis_cache);
|
||||||
|
|
@ -784,7 +784,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
buffer.replace(mgmt).unwrap();
|
buffer.replace(mgmt).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::DeleteBasis) => {
|
Opcode::DeleteBasis => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut mgmt = buffer.to_original::<PddbBasisRequest, _>().unwrap();
|
let mut mgmt = buffer.to_original::<PddbBasisRequest, _>().unwrap();
|
||||||
notify_of_disconnect(&mut pddb_os, &token_dict, &mut basis_cache);
|
notify_of_disconnect(&mut pddb_os, &token_dict, &mut basis_cache);
|
||||||
|
|
@ -804,7 +804,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
buffer.replace(mgmt).unwrap();
|
buffer.replace(mgmt).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::KeyRequest) => {
|
Opcode::KeyRequest => {
|
||||||
for basis in basis_cache.access_list().iter() {
|
for basis in basis_cache.access_list().iter() {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut req: PddbKeyRequest = buffer.to_original::<PddbKeyRequest, _>().unwrap();
|
let mut req: PddbKeyRequest = buffer.to_original::<PddbKeyRequest, _>().unwrap();
|
||||||
|
|
@ -878,7 +878,7 @@ fn main() -> ! {
|
||||||
break; // if we got here, entry was found, stop searching
|
break; // if we got here, entry was found, stop searching
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Opcode::KeyDrop) => msg_blocking_scalar_unpack!(msg, t0, t1, t2, _, {
|
Opcode::KeyDrop => msg_blocking_scalar_unpack!(msg, t0, t1, t2, _, {
|
||||||
let token: ApiToken = [t0 as u32, t1 as u32, t2 as u32];
|
let token: ApiToken = [t0 as u32, t1 as u32, t2 as u32];
|
||||||
if let Some(rec) = token_dict.remove(&token) {
|
if let Some(rec) = token_dict.remove(&token) {
|
||||||
// now check if we can safely disconnect and recycle our connection number.
|
// now check if we can safely disconnect and recycle our connection number.
|
||||||
|
|
@ -904,7 +904,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
xous::return_scalar(msg.sender, 1).expect("couldn't ack KeyDrop");
|
xous::return_scalar(msg.sender, 1).expect("couldn't ack KeyDrop");
|
||||||
}),
|
}),
|
||||||
Some(Opcode::DeleteKey) => {
|
Opcode::DeleteKey => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut req: PddbKeyRequest = buffer.to_original::<PddbKeyRequest, _>().unwrap();
|
let mut req: PddbKeyRequest = buffer.to_original::<PddbKeyRequest, _>().unwrap();
|
||||||
let bname = if req.basis_specified {
|
let bname = if req.basis_specified {
|
||||||
|
|
@ -954,7 +954,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
buffer.replace(req).unwrap();
|
buffer.replace(req).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::DeleteDict) => {
|
Opcode::DeleteDict => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut req: PddbKeyRequest = buffer.to_original::<PddbKeyRequest, _>().unwrap();
|
let mut req: PddbKeyRequest = buffer.to_original::<PddbKeyRequest, _>().unwrap();
|
||||||
let bname = if req.basis_specified {
|
let bname = if req.basis_specified {
|
||||||
|
|
@ -1004,7 +1004,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
buffer.replace(req).unwrap();
|
buffer.replace(req).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::KeyAttributes) => {
|
Opcode::KeyAttributes => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut req = buffer.to_original::<PddbKeyAttrIpc, _>().unwrap();
|
let mut req = buffer.to_original::<PddbKeyAttrIpc, _>().unwrap();
|
||||||
if let Some(token_record) = token_dict.get(&req.token) {
|
if let Some(token_record) = token_dict.get(&req.token) {
|
||||||
|
|
@ -1024,7 +1024,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Opcode::KeyCountInDict) => {
|
Opcode::KeyCountInDict => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut req = buffer.to_original::<PddbDictRequest, _>().unwrap();
|
let mut req = buffer.to_original::<PddbDictRequest, _>().unwrap();
|
||||||
if key_token.is_some() {
|
if key_token.is_some() {
|
||||||
|
|
@ -1070,7 +1070,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
buffer.replace(req).unwrap();
|
buffer.replace(req).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::GetKeyNameAtIndex) => {
|
Opcode::GetKeyNameAtIndex => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut req = buffer.to_original::<PddbDictRequest, _>().unwrap();
|
let mut req = buffer.to_original::<PddbDictRequest, _>().unwrap();
|
||||||
if let Some(token) = key_token {
|
if let Some(token) = key_token {
|
||||||
|
|
@ -1097,7 +1097,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
buffer.replace(req).unwrap();
|
buffer.replace(req).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::DictCountInBasis) => {
|
Opcode::DictCountInBasis => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut req = buffer.to_original::<PddbDictRequest, _>().unwrap();
|
let mut req = buffer.to_original::<PddbDictRequest, _>().unwrap();
|
||||||
if key_token.is_some() {
|
if key_token.is_some() {
|
||||||
|
|
@ -1125,7 +1125,7 @@ fn main() -> ! {
|
||||||
req.code = PddbRequestCode::NoErr;
|
req.code = PddbRequestCode::NoErr;
|
||||||
buffer.replace(req).unwrap();
|
buffer.replace(req).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::GetDictNameAtIndex) => {
|
Opcode::GetDictNameAtIndex => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut req = buffer.to_original::<PddbDictRequest, _>().unwrap();
|
let mut req = buffer.to_original::<PddbDictRequest, _>().unwrap();
|
||||||
if let Some(token) = dict_token {
|
if let Some(token) = dict_token {
|
||||||
|
|
@ -1149,7 +1149,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
buffer.replace(req).unwrap();
|
buffer.replace(req).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::ReadKey) => {
|
Opcode::ReadKey => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let pbuf = PddbBuf::from_slice_mut(buffer.as_mut()); // direct translation, no serialization necessary for performance
|
let pbuf = PddbBuf::from_slice_mut(buffer.as_mut()); // direct translation, no serialization necessary for performance
|
||||||
let token = pbuf.token;
|
let token = pbuf.token;
|
||||||
|
|
@ -1183,7 +1183,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
// we don't nede a "replace" operation because all ops happen in-place
|
// we don't nede a "replace" operation because all ops happen in-place
|
||||||
}
|
}
|
||||||
Some(Opcode::WriteKey) => {
|
Opcode::WriteKey => {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let pbuf = PddbBuf::from_slice_mut(buffer.as_mut()); // direct translation, no serialization necessary for performance
|
let pbuf = PddbBuf::from_slice_mut(buffer.as_mut()); // direct translation, no serialization necessary for performance
|
||||||
let token = pbuf.token;
|
let token = pbuf.token;
|
||||||
|
|
@ -1217,7 +1217,7 @@ fn main() -> ! {
|
||||||
// for now, do an expensive sync operation after every write to ensure data integrity
|
// for now, do an expensive sync operation after every write to ensure data integrity
|
||||||
basis_cache.sync(&mut pddb_os, None).expect("couldn't sync basis");
|
basis_cache.sync(&mut pddb_os, None).expect("couldn't sync basis");
|
||||||
}
|
}
|
||||||
Some(Opcode::WriteKeyFlush) => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
Opcode::WriteKeyFlush => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||||
match basis_cache.sync(&mut pddb_os, None) {
|
match basis_cache.sync(&mut pddb_os, None) {
|
||||||
Ok(_) => xous::return_scalar(msg.sender, PddbRetcode::Ok.to_usize().unwrap()).unwrap(),
|
Ok(_) => xous::return_scalar(msg.sender, PddbRetcode::Ok.to_usize().unwrap()).unwrap(),
|
||||||
Err(e) => match e.kind() {
|
Err(e) => match e.kind() {
|
||||||
|
|
@ -1227,7 +1227,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
Some(Opcode::MenuListBasis) => {
|
Opcode::MenuListBasis => {
|
||||||
let bases = basis_cache.basis_list();
|
let bases = basis_cache.basis_list();
|
||||||
let mut note = String::from(t!("pddb.menu.listbasis_response", xous::LANG));
|
let mut note = String::from(t!("pddb.menu.listbasis_response", xous::LANG));
|
||||||
for basis in bases.iter() {
|
for basis in bases.iter() {
|
||||||
|
|
@ -1237,7 +1237,7 @@ fn main() -> ! {
|
||||||
modals.show_notification(¬e, None).expect("couldn't show basis list");
|
modals.show_notification(¬e, None).expect("couldn't show basis list");
|
||||||
},
|
},
|
||||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||||
Some(Opcode::DangerousDebug) => {
|
Opcode::DangerousDebug => {
|
||||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||||
let dbg = buffer.to_original::<PddbDangerousDebug, _>().unwrap();
|
let dbg = buffer.to_original::<PddbDangerousDebug, _>().unwrap();
|
||||||
match dbg.request {
|
match dbg.request {
|
||||||
|
|
@ -1257,7 +1257,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Opcode::Quit) => {
|
Opcode::Quit => {
|
||||||
log::warn!("quitting the PDDB server");
|
log::warn!("quitting the PDDB server");
|
||||||
send_message(
|
send_message(
|
||||||
pw_cid,
|
pw_cid,
|
||||||
|
|
@ -1266,7 +1266,7 @@ fn main() -> ! {
|
||||||
xous::return_scalar(msg.sender, 0).unwrap();
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
None => {
|
Opcode::InvalidOpcode => {
|
||||||
log::error!("couldn't convert opcode: {:?}", msg);
|
log::error!("couldn't convert opcode: {:?}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,74 +6,74 @@ pub(crate) const SIG_VERSION: u32 = 1;
|
||||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||||
pub(crate) enum Opcode {
|
pub(crate) enum Opcode {
|
||||||
/// use to check if we've been initialized
|
/// use to check if we've been initialized
|
||||||
KeysInitialized,
|
KeysInitialized = 0,
|
||||||
/// check that the digital signature on the gateware
|
/// check that the digital signature on the gateware
|
||||||
CheckGatewareSignature,
|
CheckGatewareSignature = 1,
|
||||||
/// check if the efuse has been locked down
|
/// check if the efuse has been locked down
|
||||||
IsEfuseSecured,
|
IsEfuseSecured = 2,
|
||||||
/// quick check to see if the JTAG can read its IDCODE
|
/// quick check to see if the JTAG can read its IDCODE
|
||||||
IsJtagWorking,
|
IsJtagWorking = 3,
|
||||||
/// initiate an AES oracle operation
|
/// initiate an AES oracle operation
|
||||||
AesOracle,
|
AesOracle = 4,
|
||||||
/// initiate key wrapper operation
|
/// initiate key wrapper operation
|
||||||
AesKwp,
|
AesKwp = 5,
|
||||||
/// create new FPGA keys; provisioning requires a slave device to be connected that can run the JTAG sequence
|
/// create new FPGA keys; provisioning requires a slave device to be connected that can run the JTAG sequence
|
||||||
BbramProvision,
|
BbramProvision = 6,
|
||||||
/// clear a cached password
|
/// clear a cached password
|
||||||
ClearPasswordCacheEntry,
|
ClearPasswordCacheEntry = 7,
|
||||||
|
|
||||||
TestUx,
|
TestUx = 8,
|
||||||
|
|
||||||
/// attempt to initialize keys on a brand new system. Does nothing if the keys are already provisioned.
|
/// attempt to initialize keys on a brand new system. Does nothing if the keys are already provisioned.
|
||||||
UxTryInitKeys,
|
UxTryInitKeys = 9,
|
||||||
UxInitBootPasswordReturn,
|
UxInitBootPasswordReturn = 10,
|
||||||
UxInitUpdatePasswordReturn,
|
UxInitUpdatePasswordReturn = 11,
|
||||||
|
|
||||||
/// provision a gateware update with our secret data
|
/// provision a gateware update with our secret data
|
||||||
UxUpdateGateware,
|
UxUpdateGateware = 12,
|
||||||
UxUpdateGwPasswordReturn,
|
UxUpdateGwPasswordReturn = 13,
|
||||||
UxUpdateGwRun,
|
UxUpdateGwRun = 14,
|
||||||
|
|
||||||
/// self-sign kernel/loader
|
/// self-sign kernel/loader
|
||||||
UxSelfSignXous,
|
UxSelfSignXous = 15,
|
||||||
UxSignXousPasswordReturn,
|
UxSignXousPasswordReturn = 16,
|
||||||
UxSignXousRun,
|
UxSignXousRun = 17,
|
||||||
|
|
||||||
/// Ux AES calls
|
/// Ux AES calls
|
||||||
UxAesEnsurePassword,
|
UxAesEnsurePassword = 18,
|
||||||
UxAesPasswordPolicy,
|
UxAesPasswordPolicy = 19,
|
||||||
UxAesEnsureReturn,
|
UxAesEnsureReturn = 20,
|
||||||
|
|
||||||
/// Ux BBRAM flow
|
/// Ux BBRAM flow
|
||||||
UxBbramCheckReturn,
|
UxBbramCheckReturn = 21,
|
||||||
UxBbramPasswordReturn,
|
UxBbramPasswordReturn = 22,
|
||||||
UxBbramRun,
|
UxBbramRun = 23,
|
||||||
|
|
||||||
// General Ux calls
|
// General Ux calls
|
||||||
UxGutter, // NOP for UX calls that require a destination
|
UxGutter = 24, // NOP for UX calls that require a destination
|
||||||
#[cfg(feature = "policy-menu")]
|
#[cfg(feature = "policy-menu")]
|
||||||
UxGetPolicy,
|
UxGetPolicy = 25,
|
||||||
#[cfg(feature = "policy-menu")]
|
#[cfg(feature = "policy-menu")]
|
||||||
UxPolicyReturn,
|
UxPolicyReturn = 26,
|
||||||
UxTryReboot,
|
UxTryReboot = 27,
|
||||||
UxDoReboot,
|
UxDoReboot = 28,
|
||||||
|
|
||||||
/// UX opcodes
|
/// UX opcodes
|
||||||
ModalRedraw,
|
ModalRedraw = 29,
|
||||||
ModalKeys,
|
ModalKeys = 30,
|
||||||
ModalDrop,
|
ModalDrop = 31,
|
||||||
|
|
||||||
/// Suspend/resume callback
|
/// Suspend/resume callback
|
||||||
SuspendResume,
|
SuspendResume = 32,
|
||||||
|
|
||||||
Quit
|
Quit = 33,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive, PartialEq, Eq)]
|
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive, PartialEq, Eq)]
|
||||||
pub enum PasswordRetentionPolicy {
|
pub enum PasswordRetentionPolicy {
|
||||||
AlwaysKeep,
|
AlwaysKeep = 0,
|
||||||
EraseOnSuspend,
|
EraseOnSuspend = 1,
|
||||||
AlwaysPurge,
|
AlwaysPurge = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enumerate the possible password types dealt with by this manager.
|
/// Enumerate the possible password types dealt with by this manager.
|
||||||
|
|
@ -89,10 +89,10 @@ pub enum PasswordType {
|
||||||
#[cfg_attr(not(any(target_os = "none", target_os = "xous")), allow(dead_code))]
|
#[cfg_attr(not(any(target_os = "none", target_os = "xous")), allow(dead_code))]
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum RootkeyResult {
|
pub enum RootkeyResult {
|
||||||
AlignmentError,
|
AlignmentError = 0,
|
||||||
KeyError,
|
KeyError = 1,
|
||||||
IntegrityError,
|
IntegrityError = 2,
|
||||||
FlashError,
|
FlashError = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// AES operation definitions
|
/// AES operation definitions
|
||||||
|
|
@ -125,8 +125,8 @@ pub enum AesBlockType {
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Zeroize)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Zeroize)]
|
||||||
#[zeroize(drop)]
|
#[zeroize(drop)]
|
||||||
pub enum AesOpType {
|
pub enum AesOpType {
|
||||||
Encrypt,
|
Encrypt = 0,
|
||||||
Decrypt,
|
Decrypt = 1,
|
||||||
}
|
}
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Zeroize)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Zeroize)]
|
||||||
#[zeroize(drop)]
|
#[zeroize(drop)]
|
||||||
|
|
@ -158,20 +158,20 @@ impl AesOp {
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Zeroize, Eq, PartialEq, Copy, Clone)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Zeroize, Eq, PartialEq, Copy, Clone)]
|
||||||
pub enum KeywrapError {
|
pub enum KeywrapError {
|
||||||
/// Input is too big.
|
/// Input is too big.
|
||||||
TooBig,
|
TooBig = 0,
|
||||||
/// Input is too small.
|
/// Input is too small.
|
||||||
TooSmall,
|
TooSmall = 1,
|
||||||
/// Ciphertext has invalid padding.
|
/// Ciphertext has invalid padding.
|
||||||
Unpadded,
|
Unpadded = 2,
|
||||||
/// The ciphertext is not valid for the expected length.
|
/// The ciphertext is not valid for the expected length.
|
||||||
InvalidExpectedLen,
|
InvalidExpectedLen = 3,
|
||||||
/// The ciphertext couldn't be authenticated.
|
/// The ciphertext couldn't be authenticated.
|
||||||
AuthenticationFailed,
|
AuthenticationFailed = 4,
|
||||||
}
|
}
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Zeroize, Eq, PartialEq)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Zeroize, Eq, PartialEq)]
|
||||||
pub enum KeyWrapOp {
|
pub enum KeyWrapOp {
|
||||||
Wrap,
|
Wrap = 0,
|
||||||
Unwrap,
|
Unwrap = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue