1pub const PAGE_SHIFT: u64 = 12;
18pub const PAGE_SIZE: u64 = 1 << 12;
19pub const PAGE_SIZE_USIZE: usize = 1 << 12;
20
21#[derive(Debug, Clone, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
23#[repr(C)]
24pub struct GuestMemoryRegion {
25 pub size: u64,
27 pub ptr: u64,
29}
30
31#[derive(Debug, Clone, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
32#[repr(C)]
33pub struct HyperlightPEB {
34 pub input_stack: GuestMemoryRegion,
35 pub output_stack: GuestMemoryRegion,
36 pub init_data: GuestMemoryRegion,
37 pub guest_heap: GuestMemoryRegion,
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn peb_round_trip() {
46 let peb = HyperlightPEB {
47 input_stack: GuestMemoryRegion {
48 size: 0x1111,
49 ptr: 0x2222,
50 },
51 output_stack: GuestMemoryRegion {
52 size: 0x3333,
53 ptr: 0x4444,
54 },
55 init_data: GuestMemoryRegion {
56 size: 0x5555,
57 ptr: 0x6666,
58 },
59 guest_heap: GuestMemoryRegion {
60 size: 0x7777,
61 ptr: 0x8888,
62 },
63 };
64 let bytes = bytemuck::bytes_of(&peb);
65 let peb2 = *bytemuck::from_bytes::<HyperlightPEB>(bytes);
66 let peb2_bytes = bytemuck::bytes_of(&peb2);
67 assert_eq!(peb, peb2);
68 assert_eq!(bytes, peb2_bytes);
69 }
70}