Merge branch 'main' into cram-dev

This commit is contained in:
bunnie 2025-02-01 22:33:29 +08:00 committed by GitHub
commit 7ce19868ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 419 additions and 290 deletions

View file

@ -69,11 +69,11 @@ impl Hello {
self.gam
.draw_rectangle(
self.content,
Rectangle::new_with_style(Point::new(0, 0), self.screensize, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, 0),
self.screensize,
DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 },
),
)
.expect("can't clear content area");
}

View file

@ -79,11 +79,11 @@ impl HIDv2Demo {
self.gam
.draw_rectangle(
self.content,
Rectangle::new_with_style(Point::new(0, 0), self.screensize, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, 0),
self.screensize,
DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 },
),
)
.expect("can't clear content area");
}

View file

@ -148,11 +148,11 @@ impl Mtxcli {
self.gam
.draw_rectangle(
self.content,
Rectangle::new_with_style(Point::new(0, 0), self.screensize, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, 0),
self.screensize,
DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 },
),
)
.expect("can't clear content area");
}

View file

@ -153,11 +153,11 @@ impl Repl {
self.gam
.draw_rectangle(
self.content,
Rectangle::new_with_style(Point::new(0, 0), self.screensize, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, 0),
self.screensize,
DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 },
),
)
.expect("can't clear content area");
}

View file

@ -64,11 +64,11 @@ impl UI {
self.gam
.draw_rectangle(
self.content,
Rectangle::new_with_style(Point::new(0, 0), self.screensize, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, 0),
self.screensize,
DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 },
),
)
.expect("can't clear content area");
}

View file

@ -84,11 +84,15 @@ pub(crate) fn prereqs(sid: xous::SID, time_conn: xous::CID) -> ([u32; 4], bool)
if allow_redraw {
gam.draw_rectangle(
content,
Rectangle::new_with_style(Point::new(0, 0), screensize, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, 0),
screensize,
DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
},
),
)
.expect("can't clear content area");

View file

@ -313,11 +313,15 @@ impl VaultUx {
self.gam
.draw_rectangle(
self.content,
Rectangle::new_with_style(Point::new(0, 0), self.screensize, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, 0),
self.screensize,
DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
},
),
)
.expect("can't clear content area");
self.title_dirty = true; // just blanked the whole area, have to redraw the title.
@ -360,11 +364,15 @@ impl VaultUx {
self.gam
.draw_rectangle(
self.content,
Rectangle::new_with_style(tl, br, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
tl,
br,
DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
},
),
)
.expect("can't clear content area");
// reset the search
@ -379,11 +387,15 @@ impl VaultUx {
self.gam
.draw_rectangle(
self.content,
Rectangle::new_with_style(tl, self.screensize, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
tl,
self.screensize,
DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
},
),
)
.expect("can't clear content area");
} else if dirty_tl.is_none() && dirty_br.is_none() {
@ -393,11 +405,15 @@ impl VaultUx {
self.gam
.draw_rectangle(
self.content,
Rectangle::new_with_style(Point::new(0, insert_at + 1), self.screensize, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, insert_at + 1),
self.screensize,
DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
},
),
)
.expect("can't clear content area");
}
@ -451,18 +467,21 @@ impl VaultUx {
let width = (self.screensize.x - (self.margin.x * 2)) as i32;
let delta_width = (delta * width * 100) / (30 * 100);
self.gam
.draw_rectangle(self.content, Rectangle {
tl: Point::new(self.margin.x, TITLE_HEIGHT - (BAR_HEIGHT + BAR_GAP)),
br: Point::new(
self.screensize.x - self.margin.x - delta_width as i16,
TITLE_HEIGHT - BAR_GAP,
),
style: DrawStyle {
fill_color: Some(PixelColor::Dark),
stroke_color: None,
stroke_width: 0,
.draw_rectangle(
self.content,
Rectangle {
tl: Point::new(self.margin.x, TITLE_HEIGHT - (BAR_HEIGHT + BAR_GAP)),
br: Point::new(
self.screensize.x - self.margin.x - delta_width as i16,
TITLE_HEIGHT - BAR_GAP,
),
style: DrawStyle {
fill_color: Some(PixelColor::Dark),
stroke_color: None,
stroke_width: 0,
},
},
})
)
.ok();
}
self.title_dirty = false;

View file

@ -364,9 +364,14 @@ impl Process {
if sp <= 16 {
return Err(xous_kernel::Error::BadAddress);
}
crate::arch::syscall::invoke(thread, pid == 1, entrypoint, (sp - 16) & !0xf, EXIT_THREAD, &[
setup.arg1, setup.arg2, setup.arg3, setup.arg4,
]);
crate::arch::syscall::invoke(
thread,
pid == 1,
entrypoint,
(sp - 16) & !0xf,
EXIT_THREAD,
&[setup.arg1, setup.arg2, setup.arg3, setup.arg4],
);
Ok(())
}

View file

@ -414,9 +414,14 @@ impl Process {
*val = 0;
}
thread.sepc = 0;
crate::arch::syscall::invoke(thread, pid == 1, entrypoint, (sp - 16) & !0xf, EXIT_THREAD, &[
setup.arg1, setup.arg2, setup.arg3, setup.arg4,
]);
crate::arch::syscall::invoke(
thread,
pid == 1,
entrypoint,
(sp - 16) & !0xf,
EXIT_THREAD,
&[setup.arg1, setup.arg2, setup.arg3, setup.arg4],
);
Ok(())
}

View file

@ -258,10 +258,13 @@ pub fn report_stop(_pid: xous_kernel::PID, tid: xous_kernel::TID, _pc: usize) {
return;
};
let Ok(new_gdb) = inner.report_stop(&mut target, MultiThreadStopReason::SignalWithThread {
signal: Signal::EXC_BREAKPOINT,
tid: Tid::new(tid).unwrap(),
}) else {
let Ok(new_gdb) = inner.report_stop(
&mut target,
MultiThreadStopReason::SignalWithThread {
signal: Signal::EXC_BREAKPOINT,
tid: Tid::new(tid).unwrap(),
},
) else {
println!("Unable to report stop");
return;
};

View file

@ -691,11 +691,15 @@ impl Ui {
self.gam
.draw_rectangle(
self.vp.canvas,
Rectangle::new_with_style(Point::new(0, 0), self.vp.total_screensize, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, 0),
self.vp.total_screensize,
DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
},
),
)
.expect("can't clear canvas area");

View file

@ -266,11 +266,10 @@ pub fn setup_kb_pins<T: IoSetup + IoGpio>(iox: &T) -> ([(IoxPort, u8); 3], [(Iox
Some(IoxDriveStrength::Drive2mA),
);
}
([(KB_PORT, R_PINS[0]), (KB_PORT, R_PINS[1]), (KB_PORT, R_PINS[2])], [
(KB_PORT, C_PINS[0]),
(KB_PORT, C_PINS[1]),
(KB_PORT, C_PINS[2]),
])
(
[(KB_PORT, R_PINS[0]), (KB_PORT, R_PINS[1]), (KB_PORT, R_PINS[2])],
[(KB_PORT, C_PINS[0]), (KB_PORT, C_PINS[1]), (KB_PORT, C_PINS[2])],
)
}
pub fn setup_pmic_irq<T: IoIrq>(iox: &T, server: &str, opcode: usize) {

View file

@ -288,10 +288,13 @@ impl Codec {
let code_right = analog_volume_db_to_code(gain_db_right);
self.w(0, &[1]); // select page 1
self.w(31, &[0b1_1_00011_0]); // headphones powered up
self.w(36, &[
0b1_000_0000 | code_left, // HPL
0b1_000_0000 | code_right, // HPR
]);
self.w(
36,
&[
0b1_000_0000 | code_left, // HPL
0b1_000_0000 | code_right, // HPR
],
);
}
self.i2c.i2c_mutex_release();
}
@ -405,25 +408,34 @@ impl Codec {
// PLLP = 1, PLLR = 1, PLLJ = 7, PLLD = 1680, NDAC = *12*, MDAC = 7, DOSR = 128, MADC = 2 , NADC =
// *42* ^^ from page 68 of datasheet, fs=48kHz/12MHz clkin line, with *bold* items multiplied
// by 6 to get to 8kHz
self.w(5, &[
0b1001_0001, // P, R = 1, 1 and pll powered up
7, // PLLJ = 7
((1680 >> 8) & 0xFF) as u8, // D MSB of 1680
(1680 & 0xFF) as u8, // D LSB of 1680
]);
self.w(
5,
&[
0b1001_0001, // P, R = 1, 1 and pll powered up
7, // PLLJ = 7
((1680 >> 8) & 0xFF) as u8, // D MSB of 1680
(1680 & 0xFF) as u8, // D LSB of 1680
],
);
self.w(11, &[
0x80 | 12, // NADC = 12 (set to 2 for 48kHz)
0x80 | 7, // MDAC = 7
0, // DOSR = MSB of 128
128, // DOSR = LSB of 128
]);
self.w(
11,
&[
0x80 | 12, // NADC = 12 (set to 2 for 48kHz)
0x80 | 7, // MDAC = 7
0, // DOSR = MSB of 128
128, // DOSR = LSB of 128
],
);
self.w(18, &[
0x80 | 42, // NADC = 42 (set to 7 for 48kHz)
0x80 | 2, // MADC = 2
128, // AOSR = 128
]);
self.w(
18,
&[
0x80 | 42, // NADC = 42 (set to 7 for 48kHz)
0x80 | 2, // MADC = 2
128, // AOSR = 128
],
);
self.i2c.i2c_mutex_release();
}
@ -437,13 +449,16 @@ impl Codec {
// 32 bits/word * 2 channels * 8000 samples/s = 512_000 = BCLK
// pick off of DAC_MOD_CLK = 1.024MHz
self.w(27, &[
0b00_00_1_1_0_1, /* I2S standard, 16 bits per sample, BCLK output, WCLK output, DOUT is
* Hi-Z when unused */
0b0, // no offset on left justification
0b0000_0_1_01, // BDIV_CLKIN = DAC_MOD_CLK, BCLK active even when powered down
0b1000_0010, // BCLK_N_VAL = 2, N divider is powered up
]);
self.w(
27,
&[
0b00_00_1_1_0_1, /* I2S standard, 16 bits per sample, BCLK output, WCLK output, DOUT is
* Hi-Z when unused */
0b0, // no offset on left justification
0b0000_0_1_01, // BDIV_CLKIN = DAC_MOD_CLK, BCLK active even when powered down
0b1000_0010, // BCLK_N_VAL = 2, N divider is powered up
],
);
// "word width" (WCLK) timing is implied based on the DAC fs computed
// at the end of the clock tree, and WCLK simply toggles every other sample, so there is no
@ -494,18 +509,24 @@ impl Codec {
//self.w(35, &[0b01_0_1_01_1_0]);
// internal volume control
self.w(36, &[
0b1_001_1110, // HPL channel control on, -15dB
0b1_001_1110, // HPR channel control on, -15dB
0b1_000_1100, // SPK control on, -6dB
]);
self.w(
36,
&[
0b1_001_1110, // HPL channel control on, -15dB
0b1_001_1110, // HPR channel control on, -15dB
0b1_000_1100, // SPK control on, -6dB
],
);
// driver PGA control
self.w(40, &[
0b0_0011_111, // HPL driver PGA = 3dB, not muted, all gains applied
0b0_0011_111, // HPR driver PGA = 3dB, not muted, all gains applied
0b000_01_1_0_1, // SPK gain = 12 dB, driver not muted, all gains applied
]);
self.w(
40,
&[
0b0_0011_111, // HPL driver PGA = 3dB, not muted, all gains applied
0b0_0011_111, // HPR driver PGA = 3dB, not muted, all gains applied
0b000_01_1_0_1, // SPK gain = 12 dB, driver not muted, all gains applied
],
);
// HP driver control -- 16us short circuit debounce, best DAC performance, HPL/HPR as headphone
// drivers
@ -542,15 +563,18 @@ impl Codec {
// ADC digital volume control coarse adjust
self.w(83, &[0b0]); // +0.0 dB
self.w(86, &[
0b1_011_0000, // AGC enabled, target level = -12dB
0b00_10101_0, // hysteresis 1dB, noise threshold = -((value-1)*2 + 30): 21 => -70dB
100, // max gain = code/2 dB
0b_00010_000, // attack time = 0b_acode_mul = (acode*32*mul)/Fs
0b_01101_000, // decay time = 0b_dcode_mul = (dcode*32*mul)/Fs
0x01, // noise debounce time = code*4 / fs
0x01, // signal debounce time = code*4 / fs
]);
self.w(
86,
&[
0b1_011_0000, // AGC enabled, target level = -12dB
0b00_10101_0, // hysteresis 1dB, noise threshold = -((value-1)*2 + 30): 21 => -70dB
100, // max gain = code/2 dB
0b_00010_000, // attack time = 0b_acode_mul = (acode*32*mul)/Fs
0b_01101_000, // decay time = 0b_dcode_mul = (dcode*32*mul)/Fs
0x01, // noise debounce time = code*4 / fs
0x01, // signal debounce time = code*4 / fs
],
);
self.i2c.i2c_mutex_release();
}

View file

@ -160,11 +160,11 @@ impl Repl {
self.gam
.draw_rectangle(
self.content,
Rectangle::new_with_style(Point::new(0, 0), self.screensize, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, 0),
self.screensize,
DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 },
),
)
.expect("can't clear content area");
}

View file

@ -150,11 +150,16 @@ impl XousDisplay {
impl MinifbThread {
pub fn run_while(self, mut predicate: impl FnMut() -> bool) {
let mut window = Window::new("Precursor", WIDTH as usize, HEIGHT as usize, WindowOptions {
scale_mode: minifb::ScaleMode::AspectRatioStretch,
resize: true,
..WindowOptions::default()
})
let mut window = Window::new(
"Precursor",
WIDTH as usize,
HEIGHT as usize,
WindowOptions {
scale_mode: minifb::ScaleMode::AspectRatioStretch,
resize: true,
..WindowOptions::default()
},
)
.unwrap_or_else(|e| {
log::error!("{e:?}");
std::process::abort();

View file

@ -142,22 +142,26 @@ impl InputTracker {
self.gam
.draw_rectangle(
pc,
Rectangle::new_with_style(Point::new(0, 0), pc_bounds, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, 0),
pc_bounds,
DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
},
),
)
.expect("can't clear prediction area");
// add the border line on top
self.gam
.draw_line(
pc,
Line::new_with_style(Point::new(0, 0), Point::new(pc_bounds.x, 0), DrawStyle {
fill_color: None,
stroke_color: Some(PixelColor::Dark),
stroke_width: 1,
}),
Line::new_with_style(
Point::new(0, 0),
Point::new(pc_bounds.x, 0),
DrawStyle { fill_color: None, stroke_color: Some(PixelColor::Dark), stroke_width: 1 },
),
)
.expect("can't draw prediction top border");
}
@ -167,11 +171,15 @@ impl InputTracker {
self.gam
.draw_rectangle(
ic,
Rectangle::new_with_style(Point::new(0, 0), ic_bounds, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, 0),
ic_bounds,
DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
},
),
)
.expect("can't clear input area");
@ -179,11 +187,11 @@ impl InputTracker {
self.gam
.draw_line(
ic,
Line::new_with_style(Point::new(0, 0), Point::new(ic_bounds.x, 0), DrawStyle {
fill_color: None,
stroke_color: Some(PixelColor::Dark),
stroke_width: 1,
}),
Line::new_with_style(
Point::new(0, 0),
Point::new(ic_bounds.x, 0),
DrawStyle { fill_color: None, stroke_color: Some(PixelColor::Dark), stroke_width: 1 },
),
)
.expect("can't draw input top line border");
}
@ -676,11 +684,11 @@ impl InputTracker {
}
let pc_bounds: Point =
self.gam.get_canvas_bounds(pc).expect("Couldn't get prediction canvas bounds");
let pc_clip: Rectangle = Rectangle::new_with_style(Point::new(0, 1), pc_bounds, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
});
let pc_clip: Rectangle = Rectangle::new_with_style(
Point::new(0, 1),
pc_bounds,
DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 },
);
if debug1 {
info!("got pc_bound {:?}", pc_bounds);
}

View file

@ -579,10 +579,12 @@ fn main() -> ! {
i2c.i2c_mutex_acquire();
// set clock units to 1 second, output pulse length to ~218ms
// and program the elapsed time (TIMERB_CLK is followed by TIMERB)
i2c.i2c_write(ABRTCMC_I2C_ADR, ABRTCMC_TIMERB_CLK, &[(TimerClk::CLK_1_S
| TimerClk::PULSE_218_MS)
.bits()])
.expect("RTC access error");
i2c.i2c_write(
ABRTCMC_I2C_ADR,
ABRTCMC_TIMERB_CLK,
&[(TimerClk::CLK_1_S | TimerClk::PULSE_218_MS).bits()],
)
.expect("RTC access error");
// program elapsed time
i2c.i2c_write(ABRTCMC_I2C_ADR, ABRTCMC_TIMERB, &[seconds]).expect("RTC access error");
// enable timerb countdown interrupt, also clears any prior interrupt flag

View file

@ -64,13 +64,16 @@ impl phy::Device for NetPhy {
.wlan_fetch_loopback_packet(&mut self.rx_buffer[..rx_len as usize])
.expect("Couldn't call wlan_fetch_packet in device adapter");
Some((NetPhyRxToken { buf: &mut self.rx_buffer[..rx_len as usize] }, NetPhyTxToken {
buf: &mut self.tx_buffer[..],
com: &self.com,
loopback_conn: self.loopback_conn,
loopback_count: self.loopback_pending.clone(),
caps: csum_copy,
}))
Some((
NetPhyRxToken { buf: &mut self.rx_buffer[..rx_len as usize] },
NetPhyTxToken {
buf: &mut self.tx_buffer[..],
com: &self.com,
loopback_conn: self.loopback_conn,
loopback_count: self.loopback_pending.clone(),
caps: csum_copy,
},
))
} else {
if let Some(rx_len) = self.rx_avail.take() {
log::debug!("device rx of {} bytes", rx_len);
@ -78,13 +81,16 @@ impl phy::Device for NetPhy {
.wlan_fetch_packet(&mut self.rx_buffer[..rx_len as usize])
.expect("Couldn't call wlan_fetch_packet in device adapter");
Some((NetPhyRxToken { buf: &mut self.rx_buffer[..rx_len as usize] }, NetPhyTxToken {
buf: &mut self.tx_buffer[..],
com: &self.com,
loopback_conn: self.loopback_conn,
loopback_count: self.loopback_pending.clone(),
caps: csum_copy,
}))
Some((
NetPhyRxToken { buf: &mut self.rx_buffer[..rx_len as usize] },
NetPhyTxToken {
buf: &mut self.tx_buffer[..],
com: &self.com,
loopback_conn: self.loopback_conn,
loopback_count: self.loopback_pending.clone(),
caps: csum_copy,
},
))
} else {
log::trace!("nothing to rx");
None

View file

@ -147,12 +147,15 @@ pub(crate) fn std_tcp_accept(
// Adding the message to the udp_rx_waiting list prevents it from going out of scope and
// thus prevents the .drop() method from being called. Since messages are returned to the sender
// in the .drop() method, this keeps the caller blocked for the lifetime of the message.
insert_or_append(tcp_accept_waiting, AcceptingSocket {
env: msg, /* <-- msg is inserted into the tcp_accept_waiting vector, thus preventing the
* lend_mut from returning. */
handle: *handle,
fd,
});
insert_or_append(
tcp_accept_waiting,
AcceptingSocket {
env: msg, /* <-- msg is inserted into the tcp_accept_waiting vector, thus preventing the
* lend_mut from returning. */
handle: *handle,
fd,
},
);
}
pub(crate) fn tcp_accept_success(buf: &mut [u8], fd: u16, ep: IpEndpoint) {

View file

@ -169,12 +169,15 @@ pub(crate) fn std_udp_rx(
// Adding the message to the udp_rx_waiting list prevents it from going out of scope and
// thus prevents the .drop() method from being called. Since messages are returned to the sender
// in the .drop() method, this keeps the caller blocked for the lifetime of the message.
insert_or_append(udp_rx_waiting, UdpStdState {
msg, /* <-- msg is inserted into the udp_rx_waiting vector, thus preventing the lend_mut from
* returning. */
handle: *handle,
expiry,
});
insert_or_append(
udp_rx_waiting,
UdpStdState {
msg, /* <-- msg is inserted into the udp_rx_waiting vector, thus preventing the lend_mut from
* returning. */
handle: *handle,
expiry,
},
);
}
pub(crate) fn std_udp_tx(

View file

@ -2503,13 +2503,16 @@ impl PddbOs {
let aad_local = self.data_aad(&name);
self.dna_mode = DnaMode::Migration;
let aad_incoming = self.data_aad(&name);
keymap.insert(&name, MigrationCiphers {
pt_ecb,
data_gcm_siv,
aad_incoming,
aad_local,
data_key: basis_keys.data.into(),
});
keymap.insert(
&name,
MigrationCiphers {
pt_ecb,
data_gcm_siv,
aad_incoming,
aad_local,
data_key: basis_keys.data.into(),
},
);
modals.update_progress(index as u32 + 1).ok();
}
@ -2825,11 +2828,14 @@ impl PddbOs {
self.tt.sleep_ms(SWAP_DELAY_MS).unwrap();
}
// done!
if self.yes_no_approval(&modals, match self.dna_mode {
DnaMode::Normal => t!("pddb.freespace.finished", locales::LANG),
DnaMode::Migration => t!("pddb.rekey.finished", locales::LANG),
DnaMode::Churn => t!("pddb.churn.finished", locales::LANG),
}) {
if self.yes_no_approval(
&modals,
match self.dna_mode {
DnaMode::Normal => t!("pddb.freespace.finished", locales::LANG),
DnaMode::Migration => t!("pddb.rekey.finished", locales::LANG),
DnaMode::Churn => t!("pddb.churn.finished", locales::LANG),
},
) {
Some(ret)
} else {
None

View file

@ -189,10 +189,10 @@ pub(crate) fn restore_backup(key: &BackupKey, backup: &BackupDataCt) -> Option<B
// Attempt decryption. This is None on failure
let plaintext = cipher
.decrypt(Nonce::from_slice(&backup.nonce), Payload {
aad: BACKUP_AAD.as_bytes(),
msg: &backup.ct_plus_mac,
})
.decrypt(
Nonce::from_slice(&backup.nonce),
Payload { aad: BACKUP_AAD.as_bytes(), msg: &backup.ct_plus_mac },
)
.ok();
if kcom.0.ct_eq(&backup.commitment).into() {

View file

@ -658,10 +658,13 @@ mod tests {
crate::bcrypt::bcrypt(5, &salt, pw, &mut output);
assert_eq!(output, [
22, 80, 102, 192, 193, 204, 118, 167, 41, 102, 241, 75, 103, 49, 4, 245, 194, 145, 85, 104, 179,
60, 88, 53
]);
assert_eq!(
output,
[
22, 80, 102, 192, 193, 204, 118, 167, 41, 102, 241, 75, 103, 49, 4, 245, 194, 145, 85, 104,
179, 60, 88, 53
]
);
}
#[test]
@ -670,10 +673,13 @@ mod tests {
let mut output: [u8; 24] = [0; 24];
let pw = "this is a test of a very long password that is exactly 72 characters lon";
crate::bcrypt::bcrypt(10, &salt, pw, &mut output);
assert_eq!(output, [
46, 39, 41, 217, 39, 103, 62, 189, 120, 3, 248, 84, 175, 40, 134, 190, 76, 43, 232, 147, 129,
237, 116, 61
]);
assert_eq!(
output,
[
46, 39, 41, 217, 39, 103, 62, 189, 120, 3, 248, 84, 175, 40, 134, 190, 76, 43, 232, 147, 129,
237, 116, 61
]
);
}
#[test]
@ -682,9 +688,12 @@ mod tests {
let mut output: [u8; 24] = [0; 24];
let pw = "this is a test of a very long password that is exactly 72 characters long, but this one is even longer";
crate::bcrypt::bcrypt(10, &salt, pw, &mut output);
assert_eq!(output, [
46, 39, 41, 217, 39, 103, 62, 189, 120, 3, 248, 84, 175, 40, 134, 190, 76, 43, 232, 147, 129,
237, 116, 61
]);
assert_eq!(
output,
[
46, 39, 41, 217, 39, 103, 62, 189, 120, 3, 248, 84, 175, 40, 134, 190, 76, 43, 232, 147, 129,
237, 116, 61
]
);
}
}

View file

@ -281,11 +281,11 @@ impl Repl {
self.gam
.draw_rectangle(
self.content,
Rectangle::new_with_style(Point::new(0, 0), self.screensize, DrawStyle {
fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
}),
Rectangle::new_with_style(
Point::new(0, 0),
self.screensize,
DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 },
),
)
.expect("can't clear content area");
}

View file

@ -135,14 +135,17 @@ impl CheckedHashMap {
.expect("couldn't create token")
.to_array(),
);
self.map.insert(name, Connection {
sid,
current_conns: 0,
max_conns,
_allow_authenticate: false, // for now, we don't support authenticated connections
_auth_conns: 0,
token,
});
self.map.insert(
name,
Connection {
sid,
current_conns: 0,
max_conns,
_allow_authenticate: false, // for now, we don't support authenticated connections
_auth_conns: 0,
token,
},
);
Ok(())
}

View file

@ -260,15 +260,21 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} else {
((csr_top - region.base) & !(PAGE_SIZE - 1)) + PAGE_SIZE
} + PAGE_SIZE;
map.insert(region.name.to_lowercase(), tools::utils::CsrMemoryRegion {
start: region.base.try_into().unwrap(),
length: length.try_into().unwrap(),
});
map.insert(
region.name.to_lowercase(),
tools::utils::CsrMemoryRegion {
start: region.base.try_into().unwrap(),
length: length.try_into().unwrap(),
},
);
} else {
map.insert(region.name.to_lowercase(), tools::utils::CsrMemoryRegion {
start: region.base.try_into().unwrap(),
length: region.size.try_into().unwrap(),
});
map.insert(
region.name.to_lowercase(),
tools::utils::CsrMemoryRegion {
start: region.base.try_into().unwrap(),
length: region.size.try_into().unwrap(),
},
);
}
}
// insert additional regions from core.svd, if specified
@ -296,10 +302,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
break;
}
println!("{}: {:x}", region.name, region.base);
map.insert(region.name.to_lowercase(), tools::utils::CsrMemoryRegion {
start: region.base.try_into().unwrap(),
length: region.size.try_into().unwrap(),
});
map.insert(
region.name.to_lowercase(),
tools::utils::CsrMemoryRegion {
start: region.base.try_into().unwrap(),
length: region.size.try_into().unwrap(),
},
);
}
}
}

View file

@ -90,15 +90,21 @@ fn create_image(init_programs: &[String]) -> std::io::Result<Vec<u8>> {
} else {
((csr_top - region.base) & !(PAGE_SIZE - 1)) + PAGE_SIZE
} + PAGE_SIZE;
map.insert(region.name.to_lowercase(), tools::utils::CsrMemoryRegion {
start: region.base.try_into().unwrap(),
length: length.try_into().unwrap(),
});
map.insert(
region.name.to_lowercase(),
tools::utils::CsrMemoryRegion {
start: region.base.try_into().unwrap(),
length: length.try_into().unwrap(),
},
);
} else {
map.insert(region.name.to_lowercase(), tools::utils::CsrMemoryRegion {
start: region.base.try_into().unwrap(),
length: region.size.try_into().unwrap(),
});
map.insert(
region.name.to_lowercase(),
tools::utils::CsrMemoryRegion {
start: region.base.try_into().unwrap(),
length: region.size.try_into().unwrap(),
},
);
}
}
csr_to_config(tools::utils::CsrConfig { regions: map }, &mut ram_config);

View file

@ -85,10 +85,10 @@ pub fn parse_csr_csv(filename: &str) -> Result<CsrConfig, ConfigError> {
if region_name == "csr" {
csr_base = base_addr;
} else {
map.insert(region_name.to_string().to_lowercase(), CsrMemoryRegion {
start: base_addr,
length,
});
map.insert(
region_name.to_string().to_lowercase(),
CsrMemoryRegion { start: base_addr, length },
);
}
}
_ => (),

View file

@ -70,40 +70,46 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
]
.to_vec();
// minimal set of packages to do bare-iron graphical I/O
let gfx_base_pkgs = [&base_pkgs[..], &[
"graphics-server", // raw (unprotected) frame buffer primitives
"early_settings", // required by keyboard
"keyboard", // required by graphics-server
"spinor", // required by keyboard - to save key mapping
"llio", // required by spinor
]]
let gfx_base_pkgs = [
&base_pkgs[..],
&[
"graphics-server", // raw (unprotected) frame buffer primitives
"early_settings", // required by keyboard
"keyboard", // required by graphics-server
"spinor", // required by keyboard - to save key mapping
"llio", // required by spinor
],
]
.concat();
// packages in the user image - most of the services at this layer have cross-dependencies
let user_pkgs = [&gfx_base_pkgs[..], &[
// net services
"com",
"net",
"dns",
// UX abstractions
"gam",
"ime-frontend",
"ime-plugin-shell",
"codec",
"modals",
// security
"root-keys",
"trng",
"sha2",
// "engine-25519",
"jtag",
// GUI front end
"status",
"shellchat",
// filesystem
"pddb",
// usb services
"usb-device-xous",
]]
let user_pkgs = [
&gfx_base_pkgs[..],
&[
// net services
"com",
"net",
"dns",
// UX abstractions
"gam",
"ime-frontend",
"ime-plugin-shell",
"codec",
"modals",
// security
"root-keys",
"trng",
"sha2",
// "engine-25519",
"jtag",
// GUI front end
"status",
"shellchat",
// filesystem
"pddb",
// usb services
"usb-device-xous",
],
]
.concat();
// for fast testing of compilation targets of the PDDB to real hardware
let pddb_dev_pkgs = [&base_pkgs[..], &["pddb", "sha2"]].concat();