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 self.gam
.draw_rectangle( .draw_rectangle(
self.content, self.content,
Rectangle::new_with_style(Point::new(0, 0), self.screensize, DrawStyle { Rectangle::new_with_style(
fill_color: Some(PixelColor::Light), Point::new(0, 0),
stroke_color: None, self.screensize,
stroke_width: 0, DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 },
}), ),
) )
.expect("can't clear content area"); .expect("can't clear content area");
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -691,11 +691,15 @@ impl Ui {
self.gam self.gam
.draw_rectangle( .draw_rectangle(
self.vp.canvas, self.vp.canvas,
Rectangle::new_with_style(Point::new(0, 0), self.vp.total_screensize, DrawStyle { Rectangle::new_with_style(
fill_color: Some(PixelColor::Light), Point::new(0, 0),
stroke_color: None, self.vp.total_screensize,
stroke_width: 0, DrawStyle {
}), fill_color: Some(PixelColor::Light),
stroke_color: None,
stroke_width: 0,
},
),
) )
.expect("can't clear canvas area"); .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), 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, R_PINS[0]), (KB_PORT, R_PINS[1]), (KB_PORT, R_PINS[2])],
(KB_PORT, C_PINS[1]), [(KB_PORT, C_PINS[0]), (KB_PORT, C_PINS[1]), (KB_PORT, C_PINS[2])],
(KB_PORT, C_PINS[2]), )
])
} }
pub fn setup_pmic_irq<T: IoIrq>(iox: &T, server: &str, opcode: usize) { 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); let code_right = analog_volume_db_to_code(gain_db_right);
self.w(0, &[1]); // select page 1 self.w(0, &[1]); // select page 1
self.w(31, &[0b1_1_00011_0]); // headphones powered up self.w(31, &[0b1_1_00011_0]); // headphones powered up
self.w(36, &[ self.w(
0b1_000_0000 | code_left, // HPL 36,
0b1_000_0000 | code_right, // HPR &[
]); 0b1_000_0000 | code_left, // HPL
0b1_000_0000 | code_right, // HPR
],
);
} }
self.i2c.i2c_mutex_release(); 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 = // 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 // *42* ^^ from page 68 of datasheet, fs=48kHz/12MHz clkin line, with *bold* items multiplied
// by 6 to get to 8kHz // by 6 to get to 8kHz
self.w(5, &[ self.w(
0b1001_0001, // P, R = 1, 1 and pll powered up 5,
7, // PLLJ = 7 &[
((1680 >> 8) & 0xFF) as u8, // D MSB of 1680 0b1001_0001, // P, R = 1, 1 and pll powered up
(1680 & 0xFF) as u8, // D LSB of 1680 7, // PLLJ = 7
]); ((1680 >> 8) & 0xFF) as u8, // D MSB of 1680
(1680 & 0xFF) as u8, // D LSB of 1680
],
);
self.w(11, &[ self.w(
0x80 | 12, // NADC = 12 (set to 2 for 48kHz) 11,
0x80 | 7, // MDAC = 7 &[
0, // DOSR = MSB of 128 0x80 | 12, // NADC = 12 (set to 2 for 48kHz)
128, // DOSR = LSB of 128 0x80 | 7, // MDAC = 7
]); 0, // DOSR = MSB of 128
128, // DOSR = LSB of 128
],
);
self.w(18, &[ self.w(
0x80 | 42, // NADC = 42 (set to 7 for 48kHz) 18,
0x80 | 2, // MADC = 2 &[
128, // AOSR = 128 0x80 | 42, // NADC = 42 (set to 7 for 48kHz)
]); 0x80 | 2, // MADC = 2
128, // AOSR = 128
],
);
self.i2c.i2c_mutex_release(); self.i2c.i2c_mutex_release();
} }
@ -437,13 +449,16 @@ impl Codec {
// 32 bits/word * 2 channels * 8000 samples/s = 512_000 = BCLK // 32 bits/word * 2 channels * 8000 samples/s = 512_000 = BCLK
// pick off of DAC_MOD_CLK = 1.024MHz // pick off of DAC_MOD_CLK = 1.024MHz
self.w(27, &[ self.w(
0b00_00_1_1_0_1, /* I2S standard, 16 bits per sample, BCLK output, WCLK output, DOUT is 27,
* Hi-Z when unused */ &[
0b0, // no offset on left justification 0b00_00_1_1_0_1, /* I2S standard, 16 bits per sample, BCLK output, WCLK output, DOUT is
0b0000_0_1_01, // BDIV_CLKIN = DAC_MOD_CLK, BCLK active even when powered down * Hi-Z when unused */
0b1000_0010, // BCLK_N_VAL = 2, N divider is powered up 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 // "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 // 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]); //self.w(35, &[0b01_0_1_01_1_0]);
// internal volume control // internal volume control
self.w(36, &[ self.w(
0b1_001_1110, // HPL channel control on, -15dB 36,
0b1_001_1110, // HPR channel control on, -15dB &[
0b1_000_1100, // SPK control on, -6dB 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 // driver PGA control
self.w(40, &[ self.w(
0b0_0011_111, // HPL driver PGA = 3dB, not muted, all gains applied 40,
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 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 // HP driver control -- 16us short circuit debounce, best DAC performance, HPL/HPR as headphone
// drivers // drivers
@ -542,15 +563,18 @@ impl Codec {
// ADC digital volume control coarse adjust // ADC digital volume control coarse adjust
self.w(83, &[0b0]); // +0.0 dB self.w(83, &[0b0]); // +0.0 dB
self.w(86, &[ self.w(
0b1_011_0000, // AGC enabled, target level = -12dB 86,
0b00_10101_0, // hysteresis 1dB, noise threshold = -((value-1)*2 + 30): 21 => -70dB &[
100, // max gain = code/2 dB 0b1_011_0000, // AGC enabled, target level = -12dB
0b_00010_000, // attack time = 0b_acode_mul = (acode*32*mul)/Fs 0b00_10101_0, // hysteresis 1dB, noise threshold = -((value-1)*2 + 30): 21 => -70dB
0b_01101_000, // decay time = 0b_dcode_mul = (dcode*32*mul)/Fs 100, // max gain = code/2 dB
0x01, // noise debounce time = code*4 / fs 0b_00010_000, // attack time = 0b_acode_mul = (acode*32*mul)/Fs
0x01, // signal debounce time = code*4 / 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(); self.i2c.i2c_mutex_release();
} }

View file

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

View file

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

View file

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

View file

@ -579,10 +579,12 @@ fn main() -> ! {
i2c.i2c_mutex_acquire(); i2c.i2c_mutex_acquire();
// set clock units to 1 second, output pulse length to ~218ms // set clock units to 1 second, output pulse length to ~218ms
// and program the elapsed time (TIMERB_CLK is followed by TIMERB) // and program the elapsed time (TIMERB_CLK is followed by TIMERB)
i2c.i2c_write(ABRTCMC_I2C_ADR, ABRTCMC_TIMERB_CLK, &[(TimerClk::CLK_1_S i2c.i2c_write(
| TimerClk::PULSE_218_MS) ABRTCMC_I2C_ADR,
.bits()]) ABRTCMC_TIMERB_CLK,
.expect("RTC access error"); &[(TimerClk::CLK_1_S | TimerClk::PULSE_218_MS).bits()],
)
.expect("RTC access error");
// program elapsed time // program elapsed time
i2c.i2c_write(ABRTCMC_I2C_ADR, ABRTCMC_TIMERB, &[seconds]).expect("RTC access error"); i2c.i2c_write(ABRTCMC_I2C_ADR, ABRTCMC_TIMERB, &[seconds]).expect("RTC access error");
// enable timerb countdown interrupt, also clears any prior interrupt flag // 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]) .wlan_fetch_loopback_packet(&mut self.rx_buffer[..rx_len as usize])
.expect("Couldn't call wlan_fetch_packet in device adapter"); .expect("Couldn't call wlan_fetch_packet in device adapter");
Some((NetPhyRxToken { buf: &mut self.rx_buffer[..rx_len as usize] }, NetPhyTxToken { Some((
buf: &mut self.tx_buffer[..], NetPhyRxToken { buf: &mut self.rx_buffer[..rx_len as usize] },
com: &self.com, NetPhyTxToken {
loopback_conn: self.loopback_conn, buf: &mut self.tx_buffer[..],
loopback_count: self.loopback_pending.clone(), com: &self.com,
caps: csum_copy, loopback_conn: self.loopback_conn,
})) loopback_count: self.loopback_pending.clone(),
caps: csum_copy,
},
))
} else { } else {
if let Some(rx_len) = self.rx_avail.take() { if let Some(rx_len) = self.rx_avail.take() {
log::debug!("device rx of {} bytes", rx_len); 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]) .wlan_fetch_packet(&mut self.rx_buffer[..rx_len as usize])
.expect("Couldn't call wlan_fetch_packet in device adapter"); .expect("Couldn't call wlan_fetch_packet in device adapter");
Some((NetPhyRxToken { buf: &mut self.rx_buffer[..rx_len as usize] }, NetPhyTxToken { Some((
buf: &mut self.tx_buffer[..], NetPhyRxToken { buf: &mut self.rx_buffer[..rx_len as usize] },
com: &self.com, NetPhyTxToken {
loopback_conn: self.loopback_conn, buf: &mut self.tx_buffer[..],
loopback_count: self.loopback_pending.clone(), com: &self.com,
caps: csum_copy, loopback_conn: self.loopback_conn,
})) loopback_count: self.loopback_pending.clone(),
caps: csum_copy,
},
))
} else { } else {
log::trace!("nothing to rx"); log::trace!("nothing to rx");
None 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 // 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 // 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. // in the .drop() method, this keeps the caller blocked for the lifetime of the message.
insert_or_append(tcp_accept_waiting, AcceptingSocket { insert_or_append(
env: msg, /* <-- msg is inserted into the tcp_accept_waiting vector, thus preventing the tcp_accept_waiting,
* lend_mut from returning. */ AcceptingSocket {
handle: *handle, env: msg, /* <-- msg is inserted into the tcp_accept_waiting vector, thus preventing the
fd, * lend_mut from returning. */
}); handle: *handle,
fd,
},
);
} }
pub(crate) fn tcp_accept_success(buf: &mut [u8], fd: u16, ep: IpEndpoint) { 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 // 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 // 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. // in the .drop() method, this keeps the caller blocked for the lifetime of the message.
insert_or_append(udp_rx_waiting, UdpStdState { insert_or_append(
msg, /* <-- msg is inserted into the udp_rx_waiting vector, thus preventing the lend_mut from udp_rx_waiting,
* returning. */ UdpStdState {
handle: *handle, msg, /* <-- msg is inserted into the udp_rx_waiting vector, thus preventing the lend_mut from
expiry, * returning. */
}); handle: *handle,
expiry,
},
);
} }
pub(crate) fn std_udp_tx( pub(crate) fn std_udp_tx(

View file

@ -2503,13 +2503,16 @@ impl PddbOs {
let aad_local = self.data_aad(&name); let aad_local = self.data_aad(&name);
self.dna_mode = DnaMode::Migration; self.dna_mode = DnaMode::Migration;
let aad_incoming = self.data_aad(&name); let aad_incoming = self.data_aad(&name);
keymap.insert(&name, MigrationCiphers { keymap.insert(
pt_ecb, &name,
data_gcm_siv, MigrationCiphers {
aad_incoming, pt_ecb,
aad_local, data_gcm_siv,
data_key: basis_keys.data.into(), aad_incoming,
}); aad_local,
data_key: basis_keys.data.into(),
},
);
modals.update_progress(index as u32 + 1).ok(); modals.update_progress(index as u32 + 1).ok();
} }
@ -2825,11 +2828,14 @@ impl PddbOs {
self.tt.sleep_ms(SWAP_DELAY_MS).unwrap(); self.tt.sleep_ms(SWAP_DELAY_MS).unwrap();
} }
// done! // done!
if self.yes_no_approval(&modals, match self.dna_mode { if self.yes_no_approval(
DnaMode::Normal => t!("pddb.freespace.finished", locales::LANG), &modals,
DnaMode::Migration => t!("pddb.rekey.finished", locales::LANG), match self.dna_mode {
DnaMode::Churn => t!("pddb.churn.finished", locales::LANG), 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) Some(ret)
} else { } else {
None 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 // Attempt decryption. This is None on failure
let plaintext = cipher let plaintext = cipher
.decrypt(Nonce::from_slice(&backup.nonce), Payload { .decrypt(
aad: BACKUP_AAD.as_bytes(), Nonce::from_slice(&backup.nonce),
msg: &backup.ct_plus_mac, Payload { aad: BACKUP_AAD.as_bytes(), msg: &backup.ct_plus_mac },
}) )
.ok(); .ok();
if kcom.0.ct_eq(&backup.commitment).into() { if kcom.0.ct_eq(&backup.commitment).into() {

View file

@ -658,10 +658,13 @@ mod tests {
crate::bcrypt::bcrypt(5, &salt, pw, &mut output); crate::bcrypt::bcrypt(5, &salt, pw, &mut output);
assert_eq!(output, [ assert_eq!(
22, 80, 102, 192, 193, 204, 118, 167, 41, 102, 241, 75, 103, 49, 4, 245, 194, 145, 85, 104, 179, output,
60, 88, 53 [
]); 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] #[test]
@ -670,10 +673,13 @@ mod tests {
let mut output: [u8; 24] = [0; 24]; let mut output: [u8; 24] = [0; 24];
let pw = "this is a test of a very long password that is exactly 72 characters lon"; 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); crate::bcrypt::bcrypt(10, &salt, pw, &mut output);
assert_eq!(output, [ assert_eq!(
46, 39, 41, 217, 39, 103, 62, 189, 120, 3, 248, 84, 175, 40, 134, 190, 76, 43, 232, 147, 129, output,
237, 116, 61 [
]); 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] #[test]
@ -682,9 +688,12 @@ mod tests {
let mut output: [u8; 24] = [0; 24]; 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"; 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); crate::bcrypt::bcrypt(10, &salt, pw, &mut output);
assert_eq!(output, [ assert_eq!(
46, 39, 41, 217, 39, 103, 62, 189, 120, 3, 248, 84, 175, 40, 134, 190, 76, 43, 232, 147, 129, output,
237, 116, 61 [
]); 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 self.gam
.draw_rectangle( .draw_rectangle(
self.content, self.content,
Rectangle::new_with_style(Point::new(0, 0), self.screensize, DrawStyle { Rectangle::new_with_style(
fill_color: Some(PixelColor::Light), Point::new(0, 0),
stroke_color: None, self.screensize,
stroke_width: 0, DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 },
}), ),
) )
.expect("can't clear content area"); .expect("can't clear content area");
} }

View file

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

View file

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

View file

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