Merge branch 'bunnie-dev' into main

This commit is contained in:
bunnie 2022-01-08 01:06:17 +08:00
commit ea3b78c18c
3 changed files with 5 additions and 5 deletions

View file

@ -62,9 +62,7 @@ pub fn set_send_addr(send_addr: Sender<SocketAddr>) {
});
}
#[cfg(not(test))]
use core::sync::atomic::{AtomicU64, Ordering};
#[cfg(not(test))]
static LOCAL_RNG_STATE: AtomicU64 = AtomicU64::new(2);
#[cfg(not(test))]

View file

@ -32,7 +32,8 @@ fn start_kernel(server_spec: &str) -> JoinHandle<()> {
use rand::prelude::*;
use rand_chacha::ChaCha8Rng;
let mut pid1_key = [0u8; 16];
let mut rng = ChaCha8Rng::seed_from_u64(RNG_LOCAL_STATE.load(Ordering::SeqCst) + xous::TESTING_RNG_SEED.load(core::sync::atomic::Ordering::SeqCst));
let mut rng = ChaCha8Rng::seed_from_u64(RNG_LOCAL_STATE.load(Ordering::SeqCst) + xous_kernel::TESTING_RNG_SEED.load(core::sync::atomic::Ordering::SeqCst));
//let mut rng = thread_rng();
for b in pid1_key.iter_mut() {
*b = rng.gen();
}

View file

@ -39,16 +39,17 @@ pub const EC_REGION_LEN: u32 = 0x0008_0000;
pub const PDDB_LOC: u32 = 0x0100_0000; // PDDB start
pub const PDDB_LEN: u32 = EC_REGION_LOC - PDDB_LOC; // must be 64k-aligned (bulk erase block size) for proper function.
#[cfg(all(any(windows, unix), not(feature = "processes-as-threads")))]
#[cfg(not(any(target_os = "none", target_os = "xous")))]
use core::sync::atomic::AtomicU64;
// Secretly, you can change this by setting the XOUS_SEED environment variable.
// I don't lke environment variables because where do you document features like this?
// But, this was the most expedient way to get all the threads in Hosted mode to pick up a seed.
// The code that reads the varable this is all the way over in xous-rs\src\arch\hosted\mod.rs#29, and
// it's glommed onto some other static process initialization code because I don't fully understand
// what's going on over there.
#[cfg(all(any(windows, unix), not(feature = "processes-as-threads")))]
#[cfg(not(any(target_os = "none", target_os = "xous")))]
pub static TESTING_RNG_SEED: AtomicU64 = AtomicU64::new(0);
pub mod exceptions;