mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
Complete move of cramium-emu from libs to services
I thought originally cramium-emu would be a library crate, but actually, it makes more sense as a "services" crate. The APIs that cramium-emu would live in cramium-api, and cramium-emu itself is a bit closer to cramium-hal-service, filling in the executable bits of code that allow emulation to run.
This commit is contained in:
parent
7321169854
commit
b33ca44e3b
4 changed files with 0 additions and 97 deletions
|
|
@ -1,11 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "cramium-emu"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
xous = "0.9.64"
|
|
||||||
xous-names = { package = "xous-api-names", version = "0.9.65" }
|
|
||||||
"ux-api" = { path = "../ux-api" }
|
|
||||||
"rand" = "0.8"
|
|
||||||
rand_core = "0.6.4"
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
use ux_api::minigfx::{ColorNative, FrameBuffer, Point};
|
|
||||||
|
|
||||||
pub const COLUMN: isize = 128;
|
|
||||||
pub const ROW: isize = 128;
|
|
||||||
pub const PAGE: u8 = ROW as u8 / 8;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
|
||||||
pub struct MonoColor(ColorNative);
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
|
||||||
pub enum Mono {
|
|
||||||
Black,
|
|
||||||
White,
|
|
||||||
}
|
|
||||||
impl From<ColorNative> for Mono {
|
|
||||||
fn from(value: ColorNative) -> Self {
|
|
||||||
match value.0 {
|
|
||||||
0 => Mono::Black,
|
|
||||||
_ => Mono::White,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Into<ColorNative> for Mono {
|
|
||||||
fn into(self) -> ColorNative {
|
|
||||||
match self {
|
|
||||||
Mono::Black => ColorNative::from(0),
|
|
||||||
Mono::White => ColorNative::from(1),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
pub mod display;
|
|
||||||
pub mod trng;
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
use rand::rngs::ThreadRng;
|
|
||||||
use rand::{CryptoRng, Rng, RngCore};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Trng {}
|
|
||||||
impl Trng {
|
|
||||||
pub fn new(_xns: &xous_names::XousNames) -> Result<Self, xous::Error> { Ok(Trng {}) }
|
|
||||||
|
|
||||||
fn reseed(&self) {}
|
|
||||||
|
|
||||||
pub fn get_u32(&self) -> Result<u32, xous::Error> { Ok(rand::thread_rng().gen()) }
|
|
||||||
|
|
||||||
pub fn get_u64(&self) -> Result<u64, xous::Error> { Ok(rand::thread_rng().gen()) }
|
|
||||||
|
|
||||||
pub fn fill_buf(&self, data: &mut [u32]) -> Result<(), xous::Error> {
|
|
||||||
for d in data.iter_mut() {
|
|
||||||
*d = rand::thread_rng().gen();
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 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(rand::thread_rng().next_u64().to_le()) };
|
|
||||||
l.copy_from_slice(&chunk);
|
|
||||||
}
|
|
||||||
let n = left.len();
|
|
||||||
if n > 4 {
|
|
||||||
let chunk: [u8; 8] = unsafe { transmute(rand::thread_rng().next_u64().to_le()) };
|
|
||||||
left.copy_from_slice(&chunk[..n]);
|
|
||||||
} else if n > 0 {
|
|
||||||
let chunk: [u8; 4] = unsafe { transmute(rand::thread_rng().next_u32().to_le()) };
|
|
||||||
left.copy_from_slice(&chunk[..n]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RngCore for Trng {
|
|
||||||
fn next_u32(&mut self) -> u32 { rand::thread_rng().gen() }
|
|
||||||
|
|
||||||
fn next_u64(&mut self) -> u64 { rand::thread_rng().gen() }
|
|
||||||
|
|
||||||
fn fill_bytes(&mut self, dest: &mut [u8]) { self.fill_bytes_via_next(dest); }
|
|
||||||
|
|
||||||
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
|
|
||||||
Ok(self.fill_bytes(dest))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CryptoRng for Trng {}
|
|
||||||
Loading…
Reference in a new issue