Skip to content

Commit 22ad23c

Browse files
committed
Add struct Rng and test instantiate it
1 parent ff8d367 commit 22ad23c

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

src/proto/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ pub mod loaded_image;
3535
pub mod media;
3636
pub mod pi;
3737
pub mod shim;
38+
pub mod rng;

src/proto/rng.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! `Rng` protocol.
2+
3+
use crate::{data_types::Guid, proto::Protocol, Status, unsafe_guid};
4+
5+
/// Contain a Rng algorithm Guid
6+
#[repr(C)]
7+
struct RngAlgorithm(Guid);
8+
9+
/// Rng protocol
10+
#[repr(C)]
11+
#[unsafe_guid("3152bca5-eade-433d-862e-c01cdc291f44")]
12+
#[derive(Protocol)]
13+
pub struct Rng {
14+
get_info: extern "efiapi" fn(this: &Rng, algorithm_list_size: *mut usize, algorithm_list: *mut RngAlgorithm) -> Status,
15+
get_rng: extern "efiapi" fn(this: &Rng, algorithm: Option<RngAlgorithm>, value_length: usize, value: *mut u8) -> Status,
16+
}
17+
18+
/*impl Rng {
19+
fn get_info(&mut self) -> Result<[RngAlgorithm]> {
20+
let mut algorithm_list_size: usize;
21+
let mut algorithm_list: []
22+
}
23+
}*/

uefi-test-runner/src/proto/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub fn test(image: Handle, st: &mut SystemTable<Boot>) {
1717
loaded_image::test(image, bt);
1818
media::test(image, bt);
1919
pi::test(bt);
20+
rng::test(image, bt);
2021

2122
#[cfg(any(
2223
target_arch = "i386",
@@ -67,3 +68,4 @@ mod pi;
6768
target_arch = "aarch64"
6869
))]
6970
mod shim;
71+
mod rng;

uefi-test-runner/src/proto/rng.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use uefi::prelude::*;
2+
use uefi::proto::rng::Rng;
3+
use uefi::table::boot::{BootServices, OpenProtocolAttributes, OpenProtocolParams};
4+
5+
pub fn test(image: Handle, bt: &BootServices) {
6+
info!("Running loaded image protocol test");
7+
8+
let rng = bt
9+
.open_protocol::<Rng>(
10+
OpenProtocolParams {
11+
handle: image,
12+
agent: image,
13+
controller: None,
14+
},
15+
OpenProtocolAttributes::Exclusive,
16+
)
17+
.expect_success("Failed to open LoadedImage protocol");
18+
let _rng = unsafe { &*rng.interface.get() };
19+
20+
info!("Rng loaded !");
21+
}

0 commit comments

Comments
 (0)