(
&mut self,
interrupt_manager: &dyn InterruptManager<GroupConfig = LegacyIrqGroupConfig>,
serial_writer: Option<Box<dyn io::Write + Send>>,
)
| 2221 | |
| 2222 | #[cfg(target_arch = "x86_64")] |
| 2223 | fn add_serial_device( |
| 2224 | &mut self, |
| 2225 | interrupt_manager: &dyn InterruptManager<GroupConfig = LegacyIrqGroupConfig>, |
| 2226 | serial_writer: Option<Box<dyn io::Write + Send>>, |
| 2227 | ) -> DeviceManagerResult<Arc<Mutex<Serial>>> { |
| 2228 | // Serial is tied to IRQ #4 |
| 2229 | let serial_irq = 4; |
| 2230 | |
| 2231 | let id = String::from(SERIAL_DEVICE_NAME); |
| 2232 | |
| 2233 | let interrupt_group = interrupt_manager |
| 2234 | .create_group(LegacyIrqGroupConfig { |
| 2235 | irq: serial_irq as InterruptIndex, |
| 2236 | }) |
| 2237 | .map_err(DeviceManagerError::CreateInterruptGroup)?; |
| 2238 | |
| 2239 | let serial = Arc::new(Mutex::new(Serial::new( |
| 2240 | id.clone(), |
| 2241 | interrupt_group, |
| 2242 | serial_writer, |
| 2243 | state_from_id(self.snapshot.as_ref(), id.as_str()) |
| 2244 | .map_err(DeviceManagerError::RestoreGetState)?, |
| 2245 | ))); |
| 2246 | |
| 2247 | self.bus_devices |
| 2248 | .push(Arc::clone(&serial) as Arc<dyn BusDeviceSync>); |
| 2249 | |
| 2250 | self.address_manager |
| 2251 | .allocator |
| 2252 | .lock() |
| 2253 | .unwrap() |
| 2254 | .allocate_io_addresses(Some(GuestAddress(0x3f8)), 0x8, None) |
| 2255 | .ok_or(DeviceManagerError::AllocateIoPort)?; |
| 2256 | |
| 2257 | self.address_manager |
| 2258 | .io_bus |
| 2259 | .insert(serial.clone(), 0x3f8, 0x8) |
| 2260 | .map_err(DeviceManagerError::BusError)?; |
| 2261 | |
| 2262 | // Fill the device tree with a new node. In case of restore, we |
| 2263 | // know there is nothing to do, so we can simply override the |
| 2264 | // existing entry. |
| 2265 | self.device_tree |
| 2266 | .lock() |
| 2267 | .unwrap() |
| 2268 | .insert(id.clone(), device_node!(id, serial)); |
| 2269 | |
| 2270 | Ok(serial) |
| 2271 | } |
| 2272 | |
| 2273 | #[cfg(target_arch = "aarch64")] |
| 2274 | fn add_serial_device( |
no test coverage detected