1use super::{GUEST_REG_COUNT, GUEST_TMP_COUNT};
2
3pub const LANES: usize = 8;
4pub(crate) const EXEC_CACHE_SLOTS: usize = 64;
5
6#[repr(C)]
7#[cfg_attr(not(remu_generated), derive(Clone, Copy, Default))]
8pub(crate) struct ExecCache {
9 pub(crate) pc: u64,
10 pub(crate) size: usize,
11 pub(crate) valid: u8,
12}
13
14pub const COVERAGE_BITS: usize = 65_536;
15pub(crate) const COVERAGE_WORDS: usize = COVERAGE_BITS / 64;
16
17#[repr(u8)]
18#[cfg_attr(not(remu_generated), derive(Debug, Clone, Copy, PartialEq, Eq))]
19pub enum LaneExit {
20 Running = 0,
21 ReadFault = 1,
22 WriteFault = 2,
23 ExecFault = 3,
24 Syscall = 4,
25 Sysbreak = 5,
26 BlockLimit = 6,
27 Unsupported = 7,
28 GuestExit = 8,
29 UnsupportedCodeDivergence = 9,
30}
31
32#[repr(u8)]
33#[cfg_attr(not(remu_generated), derive(Debug, Clone, Copy, PartialEq, Eq))]
34pub enum FaultAccess {
35 None = 0,
36 Read = 1,
37 Write = 2,
38 Execute = 3,
39}
40
41pub(crate) type LoadFn = unsafe extern "C" fn(*mut u8, *const u64, u8, u8, *mut u64, *mut u64) -> u8;
42
43pub(crate) type StoreFn = unsafe extern "C" fn(*mut u8, *const u64, u8, u8, *const u64, *mut u64) -> u8;
44
45pub(crate) type ExecFn = unsafe extern "C" fn(*mut u8, u64, usize, u8, *mut u64) -> u8;
46
47#[repr(C, align(64))]
48pub struct VectorStateAbi {
49 pub(crate) regs: [[u64; LANES]; GUEST_REG_COUNT],
50 pub(crate) tmps: [[u64; LANES]; GUEST_TMP_COUNT],
51
52 pub(crate) pcs: [u64; LANES],
53 pub(crate) previous_pcs: [u64; LANES],
54 pub(crate) last_edges: [u64; LANES],
55 pub(crate) fault_addresses: [u64; LANES],
56
57 pub(crate) block_counts: [u64; LANES],
58 pub(crate) block_limits: [u64; LANES],
59
60 pub(crate) memory: *mut u8,
61 pub(crate) coverage: *mut u64,
62
63 pub(crate) load: LoadFn,
64 pub(crate) store: StoreFn,
65 pub(crate) exec: ExecFn,
66
67 pub(crate) exec_cache: *mut ExecCache,
68 pub(crate) reasons: [u8; LANES],
69 pub(crate) fault_access: [u8; LANES],
70 pub(crate) live_mask: u8,
71 pub(crate) active_mask: u8,
72 pub(crate) next_lane: u8,
73 pub(crate) pending_syscall_mask: u8,
74
75 pub(crate) _padding: [u8; 12],
76}