(&mut self, _base: u64, offset: u64, data: &mut [u8])
| 3203 | |
| 3204 | impl BusDevice for AcpiCpuHotplugController { |
| 3205 | fn read(&mut self, _base: u64, offset: u64, data: &mut [u8]) { |
| 3206 | // The Linux kernel, quite reasonably, doesn't zero the memory it gives us. |
| 3207 | data.fill(0); |
| 3208 | let vcpu_states = self.vcpu_states.lock().unwrap(); |
| 3209 | |
| 3210 | match offset { |
| 3211 | Self::CPU_SELECTION_OFFSET => { |
| 3212 | assert!(data.len() >= core::mem::size_of::<u32>()); |
| 3213 | data[0..core::mem::size_of::<u32>()] |
| 3214 | .copy_from_slice(&self.selected_cpu.to_le_bytes()); |
| 3215 | } |
| 3216 | Self::CPU_STATUS_OFFSET => { |
| 3217 | if self.selected_cpu < self.max_vcpus { |
| 3218 | let state = &vcpu_states[usize::try_from(self.selected_cpu).unwrap()]; |
| 3219 | if state.active() { |
| 3220 | data[0] |= 1 << Self::CPU_ENABLE_FLAG; |
| 3221 | } |
| 3222 | if state.inserting { |
| 3223 | data[0] |= 1 << Self::CPU_INSERTING_FLAG; |
| 3224 | } |
| 3225 | if state.removing { |
| 3226 | data[0] |= 1 << Self::CPU_REMOVING_FLAG; |
| 3227 | } |
| 3228 | } else { |
| 3229 | warn!("Out of range vCPU id: {}", self.selected_cpu); |
| 3230 | } |
| 3231 | } |
| 3232 | _ => { |
| 3233 | warn!("Unexpected offset for accessing CPU manager device: {offset:#}"); |
| 3234 | } |
| 3235 | } |
| 3236 | } |
| 3237 | |
| 3238 | fn write(&mut self, _base: u64, offset: u64, data: &[u8]) -> Option<Arc<Barrier>> { |
| 3239 | match offset { |
no test coverage detected