fn create_cpu_nodes(fdt: &mut Vec<u8>, num_cpus: u32) -> Result<()> {
    // See https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/arm/cpus.yaml.
    append_begin_node(fdt, "cpus")?;
    // As per documentation, on ARM v8 64-bit systems value should be set to 2.
    append_property_u32(fdt, "#address-cells", 0x2)?;
    append_property_u32(fdt, "#size-cells", 0x0)?;

    for cpu_id in 0..num_cpus {
        let cpu_name = format!("cpu@{:x}", cpu_id);
        append_begin_node(fdt, &cpu_name)?;
        append_property_string(fdt, "device_type", "cpu")?;
        append_property_string(fdt, "compatible", "arm,arm-v8")?;
        if num_cpus > 1 {
            // This is required on armv8 64-bit. See aforementioned documentation.
            append_property_string(fdt, "enable-method", "psci")?;
        }
        // If we ever see scheduling problems we might need to set the cpu reg property
        // to contain data from the MPIDR - Multiprocessor Affinity Register
        // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0488c/BABHBJCI.html.
        append_property_u64(fdt, "reg", u64::from(cpu_id))?;
        append_end_node(fdt)?;
    }
    append_end_node(fdt)?;
    Ok(())
}
// Following are the auxiliary function for creating the different nodes that we append to our FDT.
Following are the auxiliary function for creating the different nodes that we append to our FDT.
Following are the auxiliary function for creating the different nodes that we append to our FDT .
fn create_cpu_nodes(fdt: &mut Vec<u8>, num_cpus: u32) -> Result<()> {
    // See https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/arm/cpus.yaml.
    append_begin_node(fdt, "cpus")?;
    // As per documentation, on ARM v8 64-bit systems value should be set to 2.
    append_property_u32(fdt, "#address-cells", 0x2)?;
    append_property_u32(fdt, "#size-cells", 0x0)?;
    for cpu_id in 0..num_cpus {
        let cpu_name = format!("cpu@{:x}", cpu_id);
        append_begin_node(fdt, &cpu_name)?;
        append_property_string(fdt, "device_type", "cpu")?;
        append_property_string(fdt, "compatible", "arm,arm-v8")?;
        if num_cpus > 1 {
            // This is required on armv8 64-bit. See aforementioned documentation.
            append_property_string(fdt, "enable-method", "psci")?;
        }
        // If we ever see scheduling problems we might need to set the cpu reg property
        // to contain data from the MPIDR - Multiprocessor Affinity Register
        // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0488c/BABHBJCI.html.
        append_property_u64(fdt, "reg", u64::from(cpu_id))?;
        append_end_node(fdt)?;
    }
    append_end_node(fdt)?;
    Ok(())
}
fn create_cpu_nodes ( fdt : & mut Vec < u8 > , num_cpus : u32 ) -> Result < ( ) > { // See https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/arm/cpus.yaml. append_begin_node ( fdt , " " ) ? ; // As per documentation, on ARM v8 64-bit systems value should be set to 2. append_property_u32 ( fdt , " " , 0x2 ) ? ; append_property_u32 ( fdt , " " , 0x0 ) ? ; for cpu_id in 0 .. num_cpus { let cpu_name = format ! ( " " cpu_id ) ; append_begin_node ( fdt , & cpu_name ) ? ; append_property_string ( fdt , " " , " " ) ? ; append_property_string ( fdt , " " , " " ) ? ; if num_cpus > 1 { // This is required on armv8 64-bit. See aforementioned documentation. append_property_string ( fdt , " " , " " ) ? ; } // If we ever see scheduling problems we might need to set the cpu reg property // to contain data from the MPIDR - Multiprocessor Affinity Register // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0488c/BABHBJCI.html. append_property_u64 ( fdt , " " , u64 :: from ( cpu_id ) ) ? ; append_end_node ( fdt ) ? ; } append_end_node ( fdt ) ? ; Ok ( ( ) ) }
Following are the auxiliary function for creating the different nodes that we append to our FDT.
Following are the auxiliary function for creating the different nodes that we append to our FDT .
fdt
&mut Vec<u8>
num_cpus
u32
fdt
&mut Vec<u8>
num_cpus
u32