Skip to content

Commit d174fb9

Browse files
veluca93Virv12
authored andcommitted
Remove RNG.
1 parent ad0f740 commit d174fb9

6 files changed

Lines changed: 5 additions & 86 deletions

File tree

pixie-uefi/Cargo.lock

Lines changed: 0 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixie-uefi/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ lz4_flex = { version = "0.11.5", default-features = false }
2323
managed = { version = "0.8.0", default-features = false, features = ["alloc"] }
2424
minicov = { version = "0.3.7", optional = true }
2525
postcard = { version = "1.1.3", default-features = false, features = ["alloc"] }
26-
rand = { version = "0.8.5", default-features = false }
27-
rand_xoshiro = { version = "0.6.0", default-features = false }
2826
smoltcp = { version = "0.12.0", default-features = false, features = ["alloc", "proto-ipv4", "medium-ethernet", "socket-udp", "socket-tcp", "socket-dhcpv4", "async", "socket-tcp-cubic"] }
2927
thingbuf = { version = "0.1.6", default-features = false, features = ["alloc"] }
3028
uefi = { version = "0.33.0", features = ["alloc", "global_allocator", "panic_handler"] }

pixie-uefi/src/os/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use self::{
44
error::{Error, Result},
55
executor::{Executor, Task},
66
net::NetworkInterface,
7-
rng::Rng,
87
sync::SyncRefCell,
98
timer::Timer,
109
};
@@ -49,14 +48,12 @@ pub mod disk;
4948
pub mod error;
5049
mod executor;
5150
mod net;
52-
mod rng;
5351
mod sync;
5452
mod timer;
5553

5654
pub use net::{TcpStream, UdpHandle, PACKET_SIZE};
5755

5856
struct UefiOSImpl {
59-
rng: Rng,
6057
tasks: Vec<Arc<Task>>,
6158
input: ScopedProtocol<Input>,
6259
vga: ScopedProtocol<Output>,
@@ -162,7 +159,6 @@ impl UefiOS {
162159
}
163160

164161
Timer::ensure_init();
165-
let rng = Rng::new();
166162

167163
let input_handles = uefi::boot::find_handles::<Input>().unwrap();
168164
let input = uefi::boot::open_protocol_exclusive::<Input>(input_handles[0]).unwrap();
@@ -177,7 +173,6 @@ impl UefiOS {
177173
vga.clear().unwrap();
178174

179175
*OS.borrow_mut() = Some(UefiOSImpl {
180-
rng,
181176
tasks: Vec::new(),
182177
input,
183178
vga,
@@ -270,10 +265,6 @@ impl UefiOS {
270265
RefMut::map(OS.borrow_mut(), |f| f.as_mut().unwrap())
271266
}
272267

273-
pub fn rng(&self) -> RefMut<'static, Rng> {
274-
RefMut::map(self.borrow_mut(), |f| &mut f.rng)
275-
}
276-
277268
fn tasks(&self) -> RefMut<'static, Vec<Arc<Task>>> {
278269
RefMut::map(self.borrow_mut(), |f| &mut f.tasks)
279270
}

pixie-uefi/src/os/net.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use crate::os::timer::rdtsc;
2+
13
use super::{
24
error::{Error, Result},
35
timer::Timer,
@@ -182,7 +184,7 @@ impl NetworkInterface {
182184
));
183185

184186
let mut interface_config = Config::new(hw_addr);
185-
interface_config.random_seed = os.rng().rand_u64();
187+
interface_config.random_seed = rdtsc() as u64;
186188
let now = Timer::instant();
187189
let interface = Interface::new(interface_config, &mut device, now);
188190
let mut dhcp_socket = Dhcpv4Socket::new();
@@ -198,7 +200,7 @@ impl NetworkInterface {
198200
dhcp_socket_handle,
199201
device,
200202
socket_set,
201-
ephemeral_port_counter: os.rng().rand_u64(),
203+
ephemeral_port_counter: 0,
202204
rx: 0,
203205
tx: 0,
204206
vrx: 0,

pixie-uefi/src/os/rng.rs

Lines changed: 0 additions & 46 deletions
This file was deleted.

pixie-uefi/src/os/timer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ static INITIALIZED: AtomicBool = AtomicBool::new(false);
1010

1111
pub struct Timer {}
1212

13-
fn rdtsc() -> i64 {
13+
pub(super) fn rdtsc() -> i64 {
1414
// SAFETY: modern x86 CPUs have this instruction.
1515
unsafe { _rdtsc() as i64 }
1616
}

0 commit comments

Comments
 (0)