add some apis for owc frobbing

This commit is contained in:
bunnie 2026-04-03 23:43:46 +08:00
parent 53dccf0df2
commit 9452422751
2 changed files with 14 additions and 1 deletions

View file

@ -30,12 +30,17 @@ pub const ONEWAY_MAX_VALUE: u32 = 10_0000;
/// a single boot attempt.
pub const ONEWAY_MAX_DELTA: u32 = 512;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, num_derive::FromPrimitive, num_derive::ToPrimitive)]
pub enum OneWayErr {
OutOfBounds,
IncFail,
InvalidCoding,
// used to report messaging errors in xous environments
InternalError,
// used to indicate things are OK in xous environments
None,
}
pub struct OneWayCounter {
#[cfg(feature = "std")]
mapping: MemoryRange,

View file

@ -24,6 +24,9 @@ pub enum Opcode {
/// Flag operations
GetFlags = 512,
SetFlags = 513,
/// One way counter operations
GetOneWayCounter = 768,
IncOneWayCounter = 769,
// ----- below are non-cryptographic opcodes but used to manipulate sensitive state -----
/// Set bootwait parameters
@ -41,3 +44,8 @@ pub enum EphemeralOp {
GetMsb,
SetMsb,
}
/// Series of magic numbers not meant for cryptographic authentication,
/// but for detecting fat-fingered API implementations.
pub const OWC_MAGIC_GET: [usize; 3] = [0x2b46_2ab3, 0xf7e3_1b59, 0x7bba_d222];
pub const OWC_MAGIC_INC: [usize; 3] = [0xeb5d_fc81, 0x8b6d_6a90, 0xf720_491a];