(fdt: &mut FdtWriter, aia_device: &Arc<Mutex<dyn Vaia>>)
| 216 | } |
| 217 | |
| 218 | fn create_aia_node(fdt: &mut FdtWriter, aia_device: &Arc<Mutex<dyn Vaia>>) -> FdtWriterResult<()> { |
| 219 | // IMSIC |
| 220 | if aia_device.lock().unwrap().msi_compatible() { |
| 221 | use super::layout::IMSIC_START; |
| 222 | let imsic_name = format!("imsics@{:x}", IMSIC_START.0); |
| 223 | let imsic_node = fdt.begin_node(&imsic_name)?; |
| 224 | |
| 225 | fdt.property_string( |
| 226 | "compatible", |
| 227 | aia_device.lock().unwrap().imsic_compatibility(), |
| 228 | )?; |
| 229 | let imsic_reg_prop = aia_device.lock().unwrap().imsic_properties(); |
| 230 | fdt.property_array_u32("reg", &imsic_reg_prop)?; |
| 231 | fdt.property_u32("#interrupt-cells", 0u32)?; |
| 232 | fdt.property_null("interrupt-controller")?; |
| 233 | fdt.property_null("msi-controller")?; |
| 234 | // TODO complete num-ids |
| 235 | fdt.property_u32("riscv,num-ids", 2047u32)?; |
| 236 | fdt.property_u32("phandle", AIA_IMSIC_PHANDLE)?; |
| 237 | |
| 238 | let mut irq_cells = Vec::new(); |
| 239 | let num_cpus = aia_device.lock().unwrap().vcpu_count(); |
| 240 | for i in 0..num_cpus { |
| 241 | irq_cells.push(CPU_INTC_BASE_PHANDLE + i); |
| 242 | irq_cells.push(S_MODE_EXT_IRQ); |
| 243 | } |
| 244 | fdt.property_array_u32("interrupts-extended", &irq_cells)?; |
| 245 | |
| 246 | fdt.end_node(imsic_node)?; |
| 247 | } |
| 248 | |
| 249 | // APLIC |
| 250 | use super::layout::APLIC_START; |
| 251 | let aplic_name = format!("aplic@{:x}", APLIC_START.0); |
| 252 | let aplic_node = fdt.begin_node(&aplic_name)?; |
| 253 | |
| 254 | fdt.property_string( |
| 255 | "compatible", |
| 256 | aia_device.lock().unwrap().aplic_compatibility(), |
| 257 | )?; |
| 258 | let reg_cells = aia_device.lock().unwrap().aplic_properties(); |
| 259 | fdt.property_array_u32("reg", ®_cells)?; |
| 260 | fdt.property_u32("#interrupt-cells", 2u32)?; |
| 261 | fdt.property_null("interrupt-controller")?; |
| 262 | // TODO complete num-srcs |
| 263 | fdt.property_u32("riscv,num-sources", 96u32)?; |
| 264 | fdt.property_u32("phandle", AIA_APLIC_PHANDLE)?; |
| 265 | fdt.property_u32("msi-parent", AIA_IMSIC_PHANDLE)?; |
| 266 | |
| 267 | fdt.end_node(aplic_node)?; |
| 268 | |
| 269 | Ok(()) |
| 270 | } |
| 271 | |
| 272 | fn create_serial_node<T: DeviceInfoForFdt + Clone + Debug>( |
| 273 | fdt: &mut FdtWriter, |
no test coverage detected