|
1 | 1 | use core::marker::PhantomData; |
2 | 2 |
|
3 | 3 | use aarch64_cpu::registers::{CNTHCTL_EL2, HCR_EL2, SP_EL0, SPSR_EL1, VTCR_EL2}; |
| 4 | +use axaddrspace::device::SysRegAddr; |
4 | 5 | use tock_registers::interfaces::{ReadWriteable, Readable, Writeable}; |
5 | 6 |
|
6 | 7 | use crate::TrapFrame; |
@@ -303,14 +304,46 @@ impl<H: AxVCpuHal> Aarch64VCpu<H> { |
303 | 304 | _ => panic!("Unhandled exception {:?}", exit_reason), |
304 | 305 | }; |
305 | 306 |
|
| 307 | + const SYSREG_ICC_SGI1R_EL1: SysRegAddr = SysRegAddr::new(0x3A_3016); // ICC_SGI1R_EL1 |
306 | 308 | match result { |
307 | | - Ok(AxVCpuExitReason::MmioRead { |
308 | | - addr, |
309 | | - width, |
310 | | - reg, |
311 | | - reg_width, |
312 | | - }) if false => {} |
313 | | - Ok(AxVCpuExitReason::MmioWrite { addr, width, data }) if false => {} |
| 309 | + Ok(AxVCpuExitReason::SysRegWrite { addr, value }) if addr == SYSREG_ICC_SGI1R_EL1 => { |
| 310 | + debug!("arm_vcpu ICC_SGI1R_EL1 write: {:#x}", value); |
| 311 | + |
| 312 | + // TODO: support RangeSelector |
| 313 | + |
| 314 | + let intid = (value >> 24) & 0b1111; |
| 315 | + let irm = ((value >> 40) & 0b1) != 0; |
| 316 | + |
| 317 | + // IRM == 1 => send to all except self |
| 318 | + if irm { |
| 319 | + debug!("arm_vcpu ICC_SGI1R_EL1 write: irm == 1, send to all except self"); |
| 320 | + |
| 321 | + return Ok(AxVCpuExitReason::SendIPI { |
| 322 | + target_cpu: 0, |
| 323 | + target_cpu_aux: 0, |
| 324 | + send_to_all: true, |
| 325 | + send_to_self: false, |
| 326 | + vector: intid, |
| 327 | + }); |
| 328 | + } |
| 329 | + |
| 330 | + let aff3 = (value >> 48) & 0xff; |
| 331 | + let aff2 = (value >> 32) & 0xff; |
| 332 | + let aff1 = (value >> 16) & 0xff; |
| 333 | + let target_list = (value & 0xffff); |
| 334 | + |
| 335 | + debug!( |
| 336 | + "arm_vcpu ICC_SGI1R_EL1 write: aff3:{:#x} aff2:{:#x} aff1:{:#x} intid:{:#x} target_list:{:#x}", |
| 337 | + aff3, aff2, aff1, intid, target_list |
| 338 | + ); |
| 339 | + return Ok(AxVCpuExitReason::SendIPI { |
| 340 | + target_cpu: (aff3 << 24) | (aff2 << 16) | (aff1 << 8), |
| 341 | + target_cpu_aux: target_list, |
| 342 | + send_to_all: false, |
| 343 | + send_to_self: false, |
| 344 | + vector: intid, |
| 345 | + }); |
| 346 | + } |
314 | 347 | r => return r, |
315 | 348 | } |
316 | 349 |
|
|
0 commit comments