1#![allow(non_camel_case_types)]
6#![expect(missing_docs)]
7
8use zerocopy::FromBytes;
15use zerocopy::Immutable;
16use zerocopy::IntoBytes;
17use zerocopy::KnownLayout;
18
19#[expect(missing_docs)]
22#[repr(u64)]
23#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
24pub enum CcaMemPermIndex {
25 Index0,
26 Index1,
27 Index2,
28 Index3,
29 Index4,
30 Index5,
31 Index6,
32 Index7,
33 Index8,
34 Index9,
35 Index10,
36 Index11,
37 Index12,
38 Index13,
39 #[default]
40 Index14,
41}
42
43pub const RSI_PLANE_NR_GPRS: usize = 31;
44pub const RSI_PLANE_GIC_NUM_LRS: usize = 16;
45pub const RSI_PLANE_ENTER_FLAGS_TRAP_SIMD: u64 = 1 << 4;
46
47#[repr(C, align(0x1000))]
49#[derive(IntoBytes, Immutable, KnownLayout, FromBytes)]
50pub struct cca_realm_config {
51 pub ipa_width: u64,
52 pub algorithm: u64,
53 pub num_aux_planes: u64,
54 pub gicv3_vtr: u64,
55 pub pad1: [u8; 0x1000 - 4 * 8],
57}
58
59#[repr(C)]
61#[derive(IntoBytes, Immutable, KnownLayout, FromBytes)]
62pub struct cca_rsi_plane_entry {
63 pub flags: u64,
64 pub pc: u64,
65 pub pstate: u64,
66 pub pad0: [u8; 0x100 - 3 * 8],
67 pub gprs: [u64; RSI_PLANE_NR_GPRS],
68 pub pad2: [u8; 0x100 - RSI_PLANE_NR_GPRS * 8],
69 pub gicv3_hcr: u64,
70 pub gicv3_lrs: [u64; RSI_PLANE_GIC_NUM_LRS],
71 pub pad3: [u8; 0x100 - (1 + RSI_PLANE_GIC_NUM_LRS) * 8],
72}
73
74#[repr(C)]
76#[derive(IntoBytes, Immutable, KnownLayout, FromBytes, Debug)]
77pub struct cca_rsi_plane_exit {
78 pub exit_reason: u64,
79 pub pad1: [u8; 0x100 - 8],
80 pub elr_el2: u64,
81 pub esr_el2: u64,
82 pub far_el2: u64,
83 pub hpfar_el2: u64,
84 pub pstate: u64,
85 pub pad2: [u8; 0x100 - 5 * 8],
86 pub gprs: [u64; RSI_PLANE_NR_GPRS],
87 pub pad3: [u8; 0x100 - RSI_PLANE_NR_GPRS * 8],
88 pub gicv3_hcr: u64,
89 pub gicv3_lrs: [u64; RSI_PLANE_GIC_NUM_LRS],
90 pub gicv3_misr: u64,
91 pub gicv3_vmcr: u64,
92 pub cntp_ctl_el0: u64,
93 pub cntp_cval_el0: u64,
94 pub cntv_ctl_el0: u64,
95 pub cntv_cval_el0: u64,
96 pub pad4: [u8; 0x100 - (7 + RSI_PLANE_GIC_NUM_LRS) * 8],
97}
98
99#[repr(C)]
101#[derive(IntoBytes, Immutable, KnownLayout, FromBytes)]
102pub struct cca_rsi_plane_run {
103 pub entry: cca_rsi_plane_entry,
104 pub pad4: [u8; 0x800 - size_of::<cca_rsi_plane_entry>()],
105 pub exit: cca_rsi_plane_exit,
106 pub pad9: [u8; 0x800 - size_of::<cca_rsi_plane_exit>()],
107}
108
109const _: () = assert!(size_of::<cca_realm_config>() == 0x1000);
110const _: () = assert!(size_of::<cca_rsi_plane_entry>() == 0x300);
111const _: () = assert!(size_of::<cca_rsi_plane_exit>() == 0x400);
112const _: () = assert!(size_of::<cca_rsi_plane_run>() == 0x1000);