mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
Merge branch 'main' into nto-bringup
This commit is contained in:
commit
ffc226b9a8
28 changed files with 42 additions and 28 deletions
|
|
@ -49,7 +49,7 @@ struct Writer<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Writer<'a> {
|
||||
pub fn new(encoded_cbor: &mut Vec<u8>) -> Writer {
|
||||
pub fn new(encoded_cbor: &mut Vec<u8>) -> Writer<'_> {
|
||||
Writer { encoded_cbor }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ impl<S: Storage> Linear<S> {
|
|||
///
|
||||
/// This function may allocate if the slice spans multiple pages (because they may not be
|
||||
/// contiguous). However, a slice is returned if the range fits within a page.
|
||||
pub fn read(&self, range: Range<usize>) -> StorageResult<Cow<[u8]>> {
|
||||
pub fn read(&self, range: Range<usize>) -> StorageResult<Cow<'_, [u8]>> {
|
||||
if range.is_empty() {
|
||||
return Ok(Cow::Borrowed(&[]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ pub trait Storage {
|
|||
///
|
||||
/// Note that we use `Cow` just because it derefs to `[u8]`. We don't really need the fact that
|
||||
/// one can convert it to a `Vec`. In particular we don't do it in the store implementation.
|
||||
fn read_slice(&self, index: StorageIndex, length: usize) -> StorageResult<Cow<[u8]>>;
|
||||
fn read_slice(&self, index: StorageIndex, length: usize) -> StorageResult<Cow<'_, [u8]>>;
|
||||
|
||||
/// Writes a word slice to the storage.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ impl CtapHid {
|
|||
}
|
||||
|
||||
/// Helper function to parse a raw packet.
|
||||
pub fn process_single_packet(packet: &HidPacket) -> (ChannelID, ProcessedPacket) {
|
||||
pub fn process_single_packet(packet: &HidPacket) -> (ChannelID, ProcessedPacket<'_>) {
|
||||
let (&cid, rest) = array_refs![packet, 4, 60];
|
||||
if rest[0] & CtapHid::PACKET_TYPE_MASK != 0 {
|
||||
let cmd = rest[0] & !CtapHid::PACKET_TYPE_MASK;
|
||||
|
|
|
|||
2
apps/vault/src/env/xous/storage.rs
vendored
2
apps/vault/src/env/xous/storage.rs
vendored
|
|
@ -48,7 +48,7 @@ impl Storage for XousStorage {
|
|||
100_000
|
||||
}
|
||||
|
||||
fn read_slice(&self, _index: StorageIndex, _length: usize) -> StorageResult<Cow<[u8]>> {
|
||||
fn read_slice(&self, _index: StorageIndex, _length: usize) -> StorageResult<Cow<'_, [u8]>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,20 +85,19 @@ pub fn next_u64() -> u64 {
|
|||
}
|
||||
|
||||
pub fn fill_bytes_via_next(dest: &mut [MaybeUninit<u8>]) {
|
||||
use core::mem::transmute;
|
||||
let mut left = dest;
|
||||
while left.len() >= 8 {
|
||||
let (l, r) = { left }.split_at_mut(8);
|
||||
left = r;
|
||||
let chunk: [u8; 8] = unsafe { transmute(next_u64().to_le()) };
|
||||
let chunk: [u8; 8] = next_u64().to_ne_bytes();
|
||||
l.copy_from_slice(slice_as_uninit(&chunk));
|
||||
}
|
||||
let n = left.len();
|
||||
if n > 4 {
|
||||
let chunk: [u8; 8] = unsafe { transmute(next_u64().to_le()) };
|
||||
let chunk: [u8; 8] = next_u64().to_ne_bytes();
|
||||
left.copy_from_slice(slice_as_uninit(&chunk[..n]));
|
||||
} else if n > 0 {
|
||||
let chunk: [u8; 4] = unsafe { transmute(next_u32().to_le()) };
|
||||
let chunk: [u8; 4] = next_u32().to_ne_bytes();
|
||||
left.copy_from_slice(slice_as_uninit(&chunk[..n]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ enum ClaimReleaseMove {
|
|||
Move(PID /* from */),
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[repr(C)]
|
||||
pub struct MemoryRangeExtra {
|
||||
mem_start: u32,
|
||||
|
|
|
|||
|
|
@ -2201,7 +2201,7 @@ impl CorigineWrapper {
|
|||
c
|
||||
}
|
||||
|
||||
pub fn core(&self) -> std::sync::MutexGuard<CorigineUsb> {
|
||||
pub fn core(&self) -> std::sync::MutexGuard<'_, CorigineUsb> {
|
||||
#[cfg(feature = "verbose-debug")]
|
||||
crate::println!("lock status: {}", if self.hw.try_lock().is_err() { "locked " } else { "unlocked" });
|
||||
self.hw.lock().unwrap()
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
use packing::Packed;
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Debug, Packed)]
|
||||
#[allow(dead_code)]
|
||||
pub enum VersionDescriptor {
|
||||
None = 0x0000,
|
||||
/// SAM (no version claimed)
|
||||
|
|
@ -216,7 +217,7 @@ pub enum VersionDescriptor {
|
|||
/// MMC-4 (no version claimed)
|
||||
MMC4NoVersionClaimed = 0x03A0,
|
||||
/// MMC-4 T10/1545-D revision 5"},
|
||||
MMC4T101545DRevision5 = 0x03B0,
|
||||
MMC4T101545DRevision5 = 0x03B0,
|
||||
/// MMC-4 T10/1545-D revision 5a
|
||||
MMC4T101545DRevision5a = 0x03B1,
|
||||
/// MMC-4 T10/1545-D revision 3
|
||||
|
|
@ -971,7 +972,5 @@ pub enum VersionDescriptor {
|
|||
Ieee16672018 = 0xFFC4,
|
||||
}
|
||||
impl Default for VersionDescriptor {
|
||||
fn default() -> Self {
|
||||
VersionDescriptor::None
|
||||
}
|
||||
}
|
||||
fn default() -> Self { VersionDescriptor::None }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
use utralib::generated::*;
|
||||
#[allow(dead_code)]
|
||||
pub struct Uart {
|
||||
// pub base: *mut u32,
|
||||
}
|
||||
|
||||
impl Uart {
|
||||
#[cfg(any(feature = "precursor", feature = "renode"))]
|
||||
#[allow(dead_code)]
|
||||
pub fn putc(&self, c: u8) {
|
||||
let base = utra::uart::HW_UART_BASE as *mut u32;
|
||||
let mut uart = CSR::new(base);
|
||||
|
|
|
|||
|
|
@ -172,12 +172,14 @@ macro_rules! define_aes_impl {
|
|||
#[doc=$doc]
|
||||
///block cipher (decrypt-only)
|
||||
#[derive(Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct $name_dec {
|
||||
inner: $name,
|
||||
}
|
||||
|
||||
impl $name_dec {
|
||||
#[inline(always)]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn get_dec_backend(&self) -> $name_back_dec<'_> { self.inner.get_dec_backend() }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,20 +83,19 @@ impl Trng {
|
|||
|
||||
/// This is copied out of the 0.5 API for rand_core
|
||||
pub fn fill_bytes_via_next(&mut self, dest: &mut [u8]) {
|
||||
use core::mem::transmute;
|
||||
let mut left = dest;
|
||||
while left.len() >= 8 {
|
||||
let (l, r) = { left }.split_at_mut(8);
|
||||
left = r;
|
||||
let chunk: [u8; 8] = unsafe { transmute(self.next_u64().to_le()) };
|
||||
let chunk: [u8; 8] = self.next_u64().to_ne_bytes();
|
||||
l.copy_from_slice(&chunk);
|
||||
}
|
||||
let n = left.len();
|
||||
if n > 4 {
|
||||
let chunk: [u8; 8] = unsafe { transmute(self.next_u64().to_le()) };
|
||||
let chunk: [u8; 8] = self.next_u64().to_ne_bytes();
|
||||
left.copy_from_slice(&chunk[..n]);
|
||||
} else if n > 0 {
|
||||
let chunk: [u8; 4] = unsafe { transmute(self.next_u32().to_le()) };
|
||||
let chunk: [u8; 4] = self.next_u32().to_ne_bytes();
|
||||
left.copy_from_slice(&chunk[..n]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ pub(crate) const DNS_NAME_LENGTH_LIMIT: usize = 256;
|
|||
pub(crate) const DNS_PKT_MAX_LEN: usize = 512;
|
||||
|
||||
/// These opcodes can be called by anyone at any time
|
||||
#[allow(dead_code)]
|
||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||
#[repr(C)]
|
||||
pub(crate) enum Opcode {
|
||||
|
|
|
|||
|
|
@ -828,6 +828,7 @@ pub(crate) fn start_time_ux() {
|
|||
}
|
||||
|
||||
// RTC Ux helper functions
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
||||
pub(crate) enum ValidatorOp {
|
||||
UxMonth,
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ pub enum MenuOpcode {
|
|||
}
|
||||
|
||||
impl<'a> Menu<'a> {
|
||||
pub fn new(name: &str) -> Menu {
|
||||
pub fn new(name: &str) -> Menu<'_> {
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
let sid = xous::create_server().expect("can't create private menu message server");
|
||||
let gam = Gam::new(&xns).expect("can't connect to GAM");
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ pub enum I2cStatus {
|
|||
/// interrupt handler error
|
||||
ResponseInterruptError,
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
||||
pub(crate) enum I2cCallback {
|
||||
Result,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ pub struct Validation {
|
|||
pub text: TextEntryPayload,
|
||||
pub opcode: u32,
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||
pub(crate) enum ValidationOp {
|
||||
Validate,
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ impl Modals {
|
|||
Ok(Modals { conn, token, have_lock: Cell::new(false) })
|
||||
}
|
||||
|
||||
pub fn alert_builder(&self, prompt: &str) -> AlertModalBuilder {
|
||||
pub fn alert_builder(&self, prompt: &str) -> AlertModalBuilder<'_> {
|
||||
AlertModalBuilder {
|
||||
prompt: String::from(prompt),
|
||||
validators: vec![],
|
||||
|
|
|
|||
|
|
@ -387,6 +387,7 @@ pub(crate) struct SsidList {
|
|||
|
||||
/// These opcodes are reserved for private SIDs shared from a DNS server to
|
||||
/// reconfigure DNS on IP change/update.
|
||||
#[allow(dead_code)]
|
||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||
pub(crate) enum PrivateDnsOp {
|
||||
AddIpv4DnsServer,
|
||||
|
|
@ -408,6 +409,7 @@ pub(crate) struct WifiStateSubscription {
|
|||
pub opcode: u32,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
||||
pub(crate) enum NetCallback {
|
||||
Ping,
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ pub(crate) struct NetTcpListenCallback {
|
|||
pub(crate) local_port: u16,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
||||
pub(crate) enum NetTcpCallback {
|
||||
RxData,
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ const PING_IDENT: u16 = 0x22b;
|
|||
/// so the poll interval should be OK to be set quite high.
|
||||
const NET_DEFAULT_POLL_MS: u64 = 900;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||
enum WaitOp {
|
||||
WaitMs,
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ impl Pddb {
|
|||
create_key: bool,
|
||||
alloc_hint: Option<usize>,
|
||||
key_changed_cb: Option<impl Fn() + 'static + Send>,
|
||||
) -> Result<PddbKey> {
|
||||
) -> Result<PddbKey<'_>> {
|
||||
if key_name.len() > (KEY_NAME_LEN - 1) {
|
||||
return Err(Error::new(ErrorKind::InvalidInput, "key name too long"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ pub trait Senres {
|
|||
|
||||
fn can_create_writer(&self) -> bool { true }
|
||||
|
||||
fn reader(&self, fourcc: [u8; 4]) -> Option<Reader<Self>>
|
||||
fn reader(&self, fourcc: [u8; 4]) -> Option<Reader<'_, Self>>
|
||||
where
|
||||
Self: core::marker::Sized,
|
||||
{
|
||||
|
|
@ -207,7 +207,7 @@ pub trait Senres {
|
|||
pub trait SenresMut: Senres {
|
||||
fn as_mut_slice(&mut self) -> &mut [u8];
|
||||
fn as_mut_ptr(&mut self) -> *mut u8;
|
||||
fn writer(&mut self, fourcc: [u8; 4]) -> Option<Writer<Self>>
|
||||
fn writer(&mut self, fourcc: [u8; 4]) -> Option<Writer<'_, Self>>
|
||||
where
|
||||
Self: core::marker::Sized,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ pub(crate) fn password_ux_manager(
|
|||
xous::destroy_server(ux_sid).unwrap();
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||
pub(crate) enum UxOpcode {
|
||||
// add UX opcodes here, separate from the main loop's
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ impl Test {
|
|||
const SAMPLE_RATE_HZ: f32 = 8000.0;
|
||||
// note to self: A4 = 440.0, E4 = 329.63, C4 = 261.63
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||
enum TestOp {
|
||||
KeyCode,
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ pub(crate) enum Opcode {
|
|||
// Erase/Write are uninterruptable operations. Split suspend/resume
|
||||
// into a separate server to asynchronously manage this.
|
||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) enum SusResOps {
|
||||
/// Suspend/resume callback
|
||||
SuspendResume,
|
||||
|
|
|
|||
|
|
@ -115,20 +115,19 @@ impl Trng {
|
|||
|
||||
/// This is copied out of the 0.5 API for rand_core
|
||||
pub fn fill_bytes_via_next(&mut self, dest: &mut [u8]) {
|
||||
use core::mem::transmute;
|
||||
let mut left = dest;
|
||||
while left.len() >= 8 {
|
||||
let (l, r) = { left }.split_at_mut(8);
|
||||
left = r;
|
||||
let chunk: [u8; 8] = unsafe { transmute(self.next_u64().to_le()) };
|
||||
let chunk: [u8; 8] = self.next_u64().to_ne_bytes();
|
||||
l.copy_from_slice(&chunk);
|
||||
}
|
||||
let n = left.len();
|
||||
if n > 4 {
|
||||
let chunk: [u8; 8] = unsafe { transmute(self.next_u64().to_le()) };
|
||||
let chunk: [u8; 8] = self.next_u64().to_ne_bytes();
|
||||
left.copy_from_slice(&chunk[..n]);
|
||||
} else if n > 0 {
|
||||
let chunk: [u8; 4] = unsafe { transmute(self.next_u32().to_le()) };
|
||||
let chunk: [u8; 4] = self.next_u32().to_ne_bytes();
|
||||
left.copy_from_slice(&chunk[..n]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ pub enum U2fCode {
|
|||
Denied,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Eq, PartialEq, Copy, Clone)]
|
||||
#[repr(usize)]
|
||||
pub enum UsbDeviceType {
|
||||
|
|
@ -188,6 +189,7 @@ pub(crate) struct UsbListenerRegistration {
|
|||
pub listener_op_id: usize,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
||||
#[repr(usize)]
|
||||
pub enum LogLevel {
|
||||
|
|
|
|||
Loading…
Reference in a new issue