diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-08-27 07:45:15 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-09-06 15:47:50 +0200 |
| commit | e1b830309d86f6b1fff803ed94f34ce7002eb532 (patch) | |
| tree | e21794a14e8b7e7fabbab6e6e0e5051aa710e69f | |
| parent | aa89b4c22f12e9e6ebf18eba371c567ac5cd5c9b (diff) | |
| download | tools.nes-e1b830309d86f6b1fff803ed94f34ce7002eb532.tar.gz tools.nes-e1b830309d86f6b1fff803ed94f34ce7002eb532.zip | |
vnf: implement the randomized initialization for memory
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
| -rw-r--r-- | Cargo.lock | 68 | ||||
| -rw-r--r-- | lib/vnf/Cargo.toml | 1 | ||||
| -rw-r--r-- | lib/vnf/src/lib.rs | 3 |
3 files changed, 70 insertions, 2 deletions
@@ -3,10 +3,54 @@ version = 4 [[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chacha20" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" +dependencies = [ + "cfg-if", + "cpufeatures", + "rand_core", +] + +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "rand_core", +] + +[[package]] name = "header" version = "0.1.0" [[package]] +name = "libc" +version = "0.2.189" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" + +[[package]] name = "nasm" version = "0.1.0" dependencies = [ @@ -15,6 +59,29 @@ dependencies = [ ] [[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" +dependencies = [ + "chacha20", + "getrandom", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] name = "readrom" version = "0.1.0" dependencies = [ @@ -35,6 +102,7 @@ name = "vnf" version = "0.1.0" dependencies = [ "header", + "rand", "xixanta", ] diff --git a/lib/vnf/Cargo.toml b/lib/vnf/Cargo.toml index 66bed81..e119a27 100644 --- a/lib/vnf/Cargo.toml +++ b/lib/vnf/Cargo.toml @@ -8,3 +8,4 @@ authors.workspace = true [dependencies] header.workspace = true xixanta.workspace = true +rand = "0.10" diff --git a/lib/vnf/src/lib.rs b/lib/vnf/src/lib.rs index dc314bd..7fbe264 100644 --- a/lib/vnf/src/lib.rs +++ b/lib/vnf/src/lib.rs @@ -307,7 +307,7 @@ fn init_memory(policy: &MemoryPolicy) -> Vec<MemoryCell> { vec.push(MemoryCell { value: match policy.initial_value { MemoryInitialValue::Fixed(n) => n, - MemoryInitialValue::Random => todo!(), + MemoryInitialValue::Random => rand::random(), }, write_allowed, read_allowed, @@ -369,7 +369,6 @@ impl Machine { } } - // TODO: allow for randomized initialization. Ok(Self { active: true, run_function_mode: false, |
