mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +00:00
Merge branch 'bunnie-dev' into main
This commit is contained in:
commit
f9cc193a53
5 changed files with 18 additions and 10 deletions
|
|
@ -67,13 +67,14 @@ static LOCAL_RNG_STATE: AtomicU64 = AtomicU64::new(2);
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
fn generate_pid_key() -> [u8; 16] {
|
fn generate_pid_key() -> [u8; 16] {
|
||||||
use ::rand::prelude::*;
|
|
||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
|
use rand_chacha::rand_core::SeedableRng;
|
||||||
|
use rand_chacha::rand_core::RngCore;
|
||||||
|
|
||||||
let mut process_key = [0u8; 16];
|
let mut process_key = [0u8; 16];
|
||||||
let mut rng = ChaCha8Rng::seed_from_u64(LOCAL_RNG_STATE.load(Ordering::SeqCst) + xous_kernel::TESTING_RNG_SEED.load(core::sync::atomic::Ordering::SeqCst));
|
let mut rng = ChaCha8Rng::seed_from_u64(LOCAL_RNG_STATE.load(Ordering::SeqCst) + xous_kernel::TESTING_RNG_SEED.load(core::sync::atomic::Ordering::SeqCst));
|
||||||
for b in process_key.iter_mut() {
|
for b in process_key.iter_mut() {
|
||||||
*b = rng.gen();
|
*b = rng.next_u32() as u8;
|
||||||
}
|
}
|
||||||
LOCAL_RNG_STATE.store(rng.next_u64(), Ordering::SeqCst);
|
LOCAL_RNG_STATE.store(rng.next_u64(), Ordering::SeqCst);
|
||||||
process_key
|
process_key
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,9 @@ use core::sync::atomic::Ordering;
|
||||||
use crate::arch::hosted::LOCAL_RNG_STATE;
|
use crate::arch::hosted::LOCAL_RNG_STATE;
|
||||||
|
|
||||||
pub fn get_u32() -> u32 {
|
pub fn get_u32() -> u32 {
|
||||||
use ::rand::prelude::*;
|
|
||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
|
use rand_chacha::rand_core::RngCore;
|
||||||
|
use rand_chacha::rand_core::SeedableRng;
|
||||||
|
|
||||||
let mut rng = ChaCha8Rng::seed_from_u64(LOCAL_RNG_STATE.load(Ordering::SeqCst));
|
let mut rng = ChaCha8Rng::seed_from_u64(LOCAL_RNG_STATE.load(Ordering::SeqCst));
|
||||||
let r = rng.next_u32();
|
let r = rng.next_u32();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use rand::prelude::*;
|
|
||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
|
use rand_chacha::rand_core::RngCore;
|
||||||
|
use rand_chacha::rand_core::SeedableRng;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use core::sync::atomic::{AtomicU64, Ordering};
|
use core::sync::atomic::{AtomicU64, Ordering};
|
||||||
use std::collections::{BTreeSet, HashSet};
|
use std::collections::{BTreeSet, HashSet};
|
||||||
|
|
@ -13,10 +14,12 @@ static RNG_LOCAL_STATE: AtomicU64 = AtomicU64::new(3);
|
||||||
fn gen_key(dictname: &str, keynum: usize, lower_size_bound: usize, upper_size_bound: usize) -> (String, Vec::<u8>) {
|
fn gen_key(dictname: &str, keynum: usize, lower_size_bound: usize, upper_size_bound: usize) -> (String, Vec::<u8>) {
|
||||||
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::TESTING_RNG_SEED.load(core::sync::atomic::Ordering::SeqCst));
|
||||||
// we want roughly half our keys to be in the small bin, and half in the large bin
|
// we want roughly half our keys to be in the small bin, and half in the large bin
|
||||||
let keylen = if rng.gen_bool(0.5) {
|
let keylen = if rng.next_u32() < (u32::MAX / 2) {
|
||||||
rng.gen_range(lower_size_bound..VPAGE_SIZE)
|
((rng.next_u64() as usize) % (VPAGE_SIZE - lower_size_bound)) + lower_size_bound
|
||||||
|
//rng.gen_range(lower_size_bound..VPAGE_SIZE) // older API used to minimize crate count
|
||||||
} else {
|
} else {
|
||||||
rng.gen_range(VPAGE_SIZE..upper_size_bound)
|
((rng.next_u64() as usize) % (upper_size_bound - VPAGE_SIZE)) + VPAGE_SIZE
|
||||||
|
//rng.gen_range(VPAGE_SIZE..upper_size_bound) // older API used to minimize crate count
|
||||||
};
|
};
|
||||||
// record the owning dictionary name & length with the key. This isn't mandatory for a key name,
|
// record the owning dictionary name & length with the key. This isn't mandatory for a key name,
|
||||||
// but it helps the test checking program check things.
|
// but it helps the test checking program check things.
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ impl Susres {
|
||||||
// different and have a lot of overhead; it seems like the system goes into a form of deadlock
|
// different and have a lot of overhead; it seems like the system goes into a form of deadlock
|
||||||
// during boot when all the hosted mode servers try to connect. This isn't an issue on real hardware.
|
// during boot when all the hosted mode servers try to connect. This isn't an issue on real hardware.
|
||||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||||
pub fn new(xns: &xous_names::XousNames, cb_discriminant: u32, cid: CID) -> Result<Self, xous::Error> {
|
pub fn new(_ordering: Option<SuspendOrder>, xns: &xous_names::XousNames, cb_discriminant: u32, cid: CID) -> Result<Self, xous::Error> {
|
||||||
REFCOUNT.store(REFCOUNT.load(Ordering::Relaxed) + 1, Ordering::Relaxed);
|
REFCOUNT.store(REFCOUNT.load(Ordering::Relaxed) + 1, Ordering::Relaxed);
|
||||||
Ok(Susres {
|
Ok(Susres {
|
||||||
conn: 0,
|
conn: 0,
|
||||||
|
|
|
||||||
|
|
@ -467,8 +467,9 @@ mod implementation {
|
||||||
// a stub to try to avoid breaking hosted mode for as long as possible.
|
// a stub to try to avoid breaking hosted mode for as long as possible.
|
||||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||||
mod implementation {
|
mod implementation {
|
||||||
use rand::prelude::*;
|
|
||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
|
use rand_chacha::rand_core::SeedableRng;
|
||||||
|
use rand_chacha::rand_core::RngCore;
|
||||||
use crate::api::{HealthTests, TrngBuf, TrngErrors};
|
use crate::api::{HealthTests, TrngBuf, TrngErrors};
|
||||||
|
|
||||||
pub struct Trng {
|
pub struct Trng {
|
||||||
|
|
@ -502,7 +503,9 @@ mod implementation {
|
||||||
}
|
}
|
||||||
self.msgcount += 1;
|
self.msgcount += 1;
|
||||||
let mut data = [0; 1024];
|
let mut data = [0; 1024];
|
||||||
self.rng.fill(&mut data);
|
for d in data.iter_mut() {
|
||||||
|
*d = self.rng.next_u32();
|
||||||
|
}
|
||||||
TrngBuf {
|
TrngBuf {
|
||||||
data,
|
data,
|
||||||
len,
|
len,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue