islet_rmm/rsi/
constraint.rs1use crate::config::SMCCC_1_3_SVE_HINT;
2use crate::event::{Command, Context};
3use crate::rmi::constraint::Constraint; use crate::rsi;
5
6fn pick(cmd: Command) -> Option<Constraint> {
7 let constraint = match cmd {
8 rsi::ABI_VERSION => Constraint::new(rsi::ABI_VERSION, 2, 3),
12 rsi::FEATURES => Constraint::new(rsi::FEATURES, 2, 2),
13 rsi::MEASUREMENT_READ => Constraint::new(rsi::MEASUREMENT_READ, 2, 9),
14 rsi::MEASUREMENT_EXTEND => Constraint::new(rsi::MEASUREMENT_EXTEND, 11, 1),
15 rsi::ATTEST_TOKEN_INIT => Constraint::new(rsi::ATTEST_TOKEN_INIT, 9, 2),
16 rsi::ATTEST_TOKEN_CONTINUE => Constraint::new(rsi::ATTEST_TOKEN_CONTINUE, 4, 2),
17 rsi::REALM_CONFIG => Constraint::new(rsi::REALM_CONFIG, 2, 1),
18 rsi::IPA_STATE_SET => Constraint::new(rsi::IPA_STATE_SET, 5, 3),
19 rsi::IPA_STATE_GET => Constraint::new(rsi::IPA_STATE_GET, 3, 3),
20 rsi::HOST_CALL => Constraint::new(rsi::HOST_CALL, 2, 1),
21 rsi::PSCI_VERSION => Constraint::new(rsi::PSCI_VERSION, 1, 1),
25 rsi::PSCI_CPU_SUSPEND => Constraint::new(rsi::PSCI_CPU_SUSPEND, 4, 1),
26 rsi::PSCI_CPU_OFF => Constraint::new(rsi::PSCI_CPU_OFF, 1, 1),
27 rsi::PSCI_CPU_ON => Constraint::new(rsi::PSCI_CPU_ON, 4, 1),
28 rsi::PSCI_AFFINITY_INFO => Constraint::new(rsi::PSCI_AFFINITY_INFO, 3, 1),
29 rsi::PSCI_SYSTEM_OFF => Constraint::new(rsi::PSCI_SYSTEM_OFF, 1, 1),
30 rsi::PSCI_SYSTEM_RESET => Constraint::new(rsi::PSCI_SYSTEM_RESET, 1, 1),
31
32 rsi::PSCI_FEATURES => Constraint::new(rsi::PSCI_FEATURES, 2, 1),
33 rsi::SMCCC_VERSION => Constraint::new(rsi::SMCCC_VERSION, 2, 1),
35 rsi::ISLET_REALM_SEALING_KEY => Constraint::new(rsi::ISLET_REALM_SEALING_KEY, 2, 5),
37 _ => return None,
38 };
39 Some(constraint)
40}
41
42pub fn validate(cmd: Command) -> Context {
43 let fid = cmd & !SMCCC_1_3_SVE_HINT;
44 let mut ctx = Context::new(fid);
45 if cmd & SMCCC_1_3_SVE_HINT != 0 {
46 ctx.sve_hint = true;
47 }
48 if let Some(c) = pick(fid) {
49 ctx.resize_ret(c.ret_num);
50 } else {
51 ctx.resize_ret(1);
54 }
55 ctx
56}