pub fn create_fdt<T: DeviceInfoForFDT + Clone + Debug, S: std::hash::BuildHasher>(
    guest_mem: &GuestMemoryMmap,
    vcpu_mpidr: Vec<u64>,
    cmdline: &str,
    device_info: &HashMap<(DeviceType, String), T, S>,
    gic_device: &dyn GICDevice,
    initrd: &Option<InitrdConfig>,
) -> Result<Vec<u8>> {
    // Allocate stuff necessary for storing the blob.
    let mut fdt_writer = FdtWriter::new()?;

    // For an explanation why these nodes were introduced in the blob take a look at
    // https://github.com/torvalds/linux/blob/master/Documentation/devicetree/booting-without-of.txt#L845
    // Look for "Required nodes and properties".

    // Header or the root node as per above mentioned documentation.
    let root = fdt_writer.begin_node("")?;
    fdt_writer.property_string("compatible", "linux,dummy-virt")?;
    // For info on #address-cells and size-cells read "Note about cells and address representation"
    // from the above mentioned txt file.
    fdt_writer.property_u32("#address-cells", ADDRESS_CELLS)?;
    fdt_writer.property_u32("#size-cells", SIZE_CELLS)?;
    // This is not mandatory but we use it to point the root node to the node
    // containing description of the interrupt controller for this VM.
    fdt_writer.property_u32("interrupt-parent", GIC_PHANDLE)?;
    create_cpu_nodes(&mut fdt_writer, &vcpu_mpidr)?;
    create_memory_node(&mut fdt_writer, guest_mem)?;
    create_chosen_node(&mut fdt_writer, cmdline, initrd)?;
    create_gic_node(&mut fdt_writer, gic_device)?;
    create_timer_node(&mut fdt_writer)?;
    create_clock_node(&mut fdt_writer)?;
    create_psci_node(&mut fdt_writer)?;
    create_devices_node(&mut fdt_writer, &device_info)?;

    // End Header node.
    fdt_writer.end_node(root)?;

    // Allocate another buffer so we can format and then write fdt to guest.
    let fdt_final = fdt_writer.finish()?;

    // Write FDT to memory.
    let fdt_address = GuestAddress(get_fdt_addr(&guest_mem));
    guest_mem
        .write_slice(fdt_final.as_slice(), fdt_address)
        .map_err(Error::WriteFdtToMemory)?;
    Ok(fdt_final)
}
/// Creates the flattened device tree for this aarch64 microVM.
Creates the flattened device tree for this aarch64 microVM.
Creates the flattened device tree for this aarch64 microVM .
pub fn create_fdt<T: DeviceInfoForFDT + Clone + Debug, S: std::hash::BuildHasher>(
    guest_mem: &GuestMemoryMmap,
    vcpu_mpidr: Vec<u64>,
    cmdline: &str,
    device_info: &HashMap<(DeviceType, String), T, S>,
    gic_device: &dyn GICDevice,
    initrd: &Option<InitrdConfig>,
) -> Result<Vec<u8>> {
    // Allocate stuff necessary for storing the blob.
    let mut fdt_writer = FdtWriter::new()?;
    // For an explanation why these nodes were introduced in the blob take a look at
    // https://github.com/torvalds/linux/blob/master/Documentation/devicetree/booting-without-of.txt#L845
    // Look for "Required nodes and properties".
    // Header or the root node as per above mentioned documentation.
    let root = fdt_writer.begin_node("")?;
    fdt_writer.property_string("compatible", "linux,dummy-virt")?;
    // For info on #address-cells and size-cells read "Note about cells and address representation"
    // from the above mentioned txt file.
    fdt_writer.property_u32("#address-cells", ADDRESS_CELLS)?;
    fdt_writer.property_u32("#size-cells", SIZE_CELLS)?;
    // This is not mandatory but we use it to point the root node to the node
    // containing description of the interrupt controller for this VM.
    fdt_writer.property_u32("interrupt-parent", GIC_PHANDLE)?;
    create_cpu_nodes(&mut fdt_writer, &vcpu_mpidr)?;
    create_memory_node(&mut fdt_writer, guest_mem)?;
    create_chosen_node(&mut fdt_writer, cmdline, initrd)?;
    create_gic_node(&mut fdt_writer, gic_device)?;
    create_timer_node(&mut fdt_writer)?;
    create_clock_node(&mut fdt_writer)?;
    create_psci_node(&mut fdt_writer)?;
    create_devices_node(&mut fdt_writer, &device_info)?;
    // End Header node.
    fdt_writer.end_node(root)?;
    // Allocate another buffer so we can format and then write fdt to guest.
    let fdt_final = fdt_writer.finish()?;
    // Write FDT to memory.
    let fdt_address = GuestAddress(get_fdt_addr(&guest_mem));
    guest_mem
        .write_slice(fdt_final.as_slice(), fdt_address)
        .map_err(Error::WriteFdtToMemory)?;
    Ok(fdt_final)
}
pub fn create_fdt < T : DeviceInfoForFDT + Clone + Debug , S : std :: hash :: BuildHasher > ( guest_mem : & GuestMemoryMmap , vcpu_mpidr : Vec < u64 > , cmdline : & str , device_info : & HashMap < ( DeviceType , String ) , T , S > , gic_device : & dyn GICDevice , initrd : & Option < InitrdConfig > , ) -> Result < Vec < u8 > > { // Allocate stuff necessary for storing the blob. let mut fdt_writer = FdtWriter :: new ( ) ? ; // For an explanation why these nodes were introduced in the blob take a look at // https://github.com/torvalds/linux/blob/master/Documentation/devicetree/booting-without-of.txt#L845 // Look for "Required nodes and properties". // Header or the root node as per above mentioned documentation. let root = fdt_writer . begin_node ( " " ) ? ; fdt_writer . property_string ( " " , " " ) ? ; // For info on #address-cells and size-cells read "Note about cells and address representation" // from the above mentioned txt file. fdt_writer . property_u32 ( " " , ADDRESS_CELLS ) ? ; fdt_writer . property_u32 ( " " , SIZE_CELLS ) ? ; // This is not mandatory but we use it to point the root node to the node // containing description of the interrupt controller for this VM. fdt_writer . property_u32 ( " " , GIC_PHANDLE ) ? ; create_cpu_nodes ( & mut fdt_writer , & vcpu_mpidr ) ? ; create_memory_node ( & mut fdt_writer , guest_mem ) ? ; create_chosen_node ( & mut fdt_writer , cmdline , initrd ) ? ; create_gic_node ( & mut fdt_writer , gic_device ) ? ; create_timer_node ( & mut fdt_writer ) ? ; create_clock_node ( & mut fdt_writer ) ? ; create_psci_node ( & mut fdt_writer ) ? ; create_devices_node ( & mut fdt_writer , & device_info ) ? ; // End Header node. fdt_writer . end_node ( root ) ? ; // Allocate another buffer so we can format and then write fdt to guest. let fdt_final = fdt_writer . finish ( ) ? ; // Write FDT to memory. let fdt_address = GuestAddress ( get_fdt_addr ( & guest_mem ) ) ; guest_mem . write_slice ( fdt_final . as_slice ( ) , fdt_address ) . map_err ( Error :: WriteFdtToMemory ) ? ; Ok ( fdt_final ) }
Creates the flattened device tree for this aarch64 microVM.
Creates the flattened device tree for this aarch64 microVM .
guest_mem
&GuestMemoryMmap
vcpu_mpidr
Vec<u64>
cmdline
&str
device_info
&HashMap<(DeviceType, String), T, S>
gic_device
&dyn GICDevice
initrd
&Option<InitrdConfig>
guest_mem
&GuestMemoryMmap
vcpu_mpidr
Vec<u64>
cmdline
&str
device_info
&HashMap<(DeviceType, String), T, S>
gic_device
&dyn GICDevice
initrd
&Option<InitrdConfig>