fn render_region_pass(
        &self,
        base: GuestAddress,
        addr_range: AddressRange,
        flat_view: &mut FlatView,
    ) -> Result<()> {
        match self.region_type {
            RegionType::Container => {
                let region_base = base.unchecked_add(self.offset().raw_value());
                let region_range = AddressRange::new(region_base, self.size());
                let intersect = match region_range.find_intersection(addr_range) {
                    Some(r) => r,
                    None => bail!(
                        "Generate flat view failed: region_addr 0x{:X} exceeds parent region range (0x{:X}, 0x{:X})",
                        region_base.raw_value(),
                        addr_range.base.raw_value(),
                        addr_range.size
                    ),
                };

                for sub_r in self.subregions.read().unwrap().iter() {
                    sub_r
                        .render_region_pass(region_base, intersect, flat_view)
                        .chain_err(|| {
                            format!(
                                "Failed to render subregion, base 0x{:X}, addr_range (0x{:X}, 0x{:X})",
                                base.raw_value(),
                                addr_range.base.raw_value(),
                                addr_range.size
                            )
                        })?;
                }
            }
            RegionType::Ram | RegionType::IO | RegionType::RomDevice | RegionType::RamDevice => {
                self.render_terminate_region(base, addr_range, flat_view)
                    .chain_err(||
                        format!(
                            "Failed to render terminate region, base 0x{:X}, addr_range (0x{:X}, 0x{:X})",
                            base.raw_value(), addr_range.base.raw_value(),
                            addr_range.size
                        ))?;
            }
        }
        Ok(())
    }
/// Recursive function to render region, terminate if this region is not a container.
///
/// # Arguments
///
/// * `base` - Base address of a Region.
/// * `addr_range` - Address Range.
/// * `flat_view` - FlatView of a Region.
///
/// # Errors
///
/// Return Error if the input address range `addr_range` has no intersection with this region.
Recursive function to render region, terminate if this region is not a container.
Recursive function to render region terminate if this region is not a container .
fn render_region_pass(
        &self,
        base: GuestAddress,
        addr_range: AddressRange,
        flat_view: &mut FlatView,
    ) -> Result<()> {
        match self.region_type {
            RegionType::Container => {
                let region_base = base.unchecked_add(self.offset().raw_value());
                let region_range = AddressRange::new(region_base, self.size());
                let intersect = match region_range.find_intersection(addr_range) {
                    Some(r) => r,
                    None => bail!(
                        "Generate flat view failed: region_addr 0x{:X} exceeds parent region range (0x{:X}, 0x{:X})",
                        region_base.raw_value(),
                        addr_range.base.raw_value(),
                        addr_range.size
                    ),
                };
                for sub_r in self.subregions.read().unwrap().iter() {
                    sub_r
                        .render_region_pass(region_base, intersect, flat_view)
                        .chain_err(|| {
                            format!(
                                "Failed to render subregion, base 0x{:X}, addr_range (0x{:X}, 0x{:X})",
                                base.raw_value(),
                                addr_range.base.raw_value(),
                                addr_range.size
                            )
                        })?;
                }
            }
            RegionType::Ram | RegionType::IO | RegionType::RomDevice | RegionType::RamDevice => {
                self.render_terminate_region(base, addr_range, flat_view)
                    .chain_err(||
                        format!(
                            "Failed to render terminate region, base 0x{:X}, addr_range (0x{:X}, 0x{:X})",
                            base.raw_value(), addr_range.base.raw_value(),
                            addr_range.size
                        ))?;
            }
        }
        Ok(())
    }
fn render_region_pass ( & self , base : GuestAddress , addr_range : AddressRange , flat_view : & mut FlatView , ) -> Result < ( ) > { match self . region_type { RegionType :: Container => { let region_base = base . unchecked_add ( self . offset ( ) . raw_value ( ) ) ; let region_range = AddressRange :: new ( region_base , self . size ( ) ) ; let intersect = match region_range . find_intersection ( addr_range ) { Some ( r ) => r , None => bail ! ( " " region_base raw_value ( ) addr_range base raw_value ( ) addr_range size ) , } ; for sub_r in self . subregions . read ( ) . unwrap ( ) . iter ( ) { sub_r . render_region_pass ( region_base , intersect , flat_view ) . chain_err ( | | { format ! ( " " base raw_value ( ) addr_range base raw_value ( ) addr_range size ) } ) ? ; } } RegionType :: Ram | RegionType :: IO | RegionType :: RomDevice | RegionType :: RamDevice => { self . render_terminate_region ( base , addr_range , flat_view ) . chain_err ( | | format ! ( " " base raw_value ( ) addr_range base raw_value ( ) addr_range size ) ) ? ; } } Ok ( ( ) ) }
Recursive function to render region, terminate if this region is not a container.
Recursive function to render region terminate if this region is not a container .
&self
base
GuestAddress
addr_range
AddressRange
flat_view
&mut FlatView
&self
base
GuestAddress
addr_range
AddressRange
flat_view
&mut FlatView
errors
Return Error if the input address range `addr_range` has no intersection with this region.
Return Error if the input address range ` addr_range ` has no intersection with this region .