(
fdt: &mut FdtWriter,
dev_info: &HashMap<(DeviceType, String), T, S>,
)
| 880 | } |
| 881 | |
| 882 | fn create_devices_node<T: DeviceInfoForFdt + Clone + Debug, S: ::std::hash::BuildHasher>( |
| 883 | fdt: &mut FdtWriter, |
| 884 | dev_info: &HashMap<(DeviceType, String), T, S>, |
| 885 | ) -> FdtWriterResult<()> { |
| 886 | // Create one temp Vec to store all virtio devices |
| 887 | let mut ordered_virtio_device: Vec<&T> = Vec::new(); |
| 888 | |
| 889 | for ((device_type, _device_id), info) in dev_info { |
| 890 | match device_type { |
| 891 | DeviceType::Gpio => create_gpio_node(fdt, info)?, |
| 892 | DeviceType::Rtc => create_rtc_node(fdt, info)?, |
| 893 | DeviceType::Serial => create_serial_node(fdt, info)?, |
| 894 | DeviceType::Virtio(_) => { |
| 895 | ordered_virtio_device.push(info); |
| 896 | } |
| 897 | #[cfg(feature = "fw_cfg")] |
| 898 | DeviceType::FwCfg => create_fw_cfg_node(fdt, info)?, |
| 899 | } |
| 900 | } |
| 901 | |
| 902 | // Sort out virtio devices by address from low to high and insert them into fdt table. |
| 903 | ordered_virtio_device.sort_by_key(|&a| a.addr()); |
| 904 | // Current address allocation strategy in cloud-hypervisor is: the first created device |
| 905 | // will be allocated to higher address. Here we reverse the vector to make sure that |
| 906 | // the older created device will appear in front of the newer created device in FDT. |
| 907 | ordered_virtio_device.reverse(); |
| 908 | for ordered_device_info in ordered_virtio_device.drain(..) { |
| 909 | create_virtio_node(fdt, ordered_device_info)?; |
| 910 | } |
| 911 | |
| 912 | Ok(()) |
| 913 | } |
| 914 | |
| 915 | fn create_pmu_node(fdt: &mut FdtWriter) -> FdtWriterResult<()> { |
| 916 | let compatible = "arm,armv8-pmuv3"; |
no test coverage detected