pub fn sys_vmar_allocate(
        &self,
        parent_vmar: HandleValue,
        options: u32,
        offset: u64,
        size: u64,
        mut out_child_vmar: UserOutPtr<HandleValue>,
        mut out_child_addr: UserOutPtr<usize>,
    ) -> ZxResult {
        let vm_options = VmOptions::from_bits(options).ok_or(ZxError::INVALID_ARGS)?;
        info!(
            "vmar.allocate: parent={:#x?}, options={:#x?}, offset={:#x?}, size={:#x?}",
            parent_vmar, options, offset, size,
        );
        // try to get parent_vmar
        let perm_rights = vm_options.to_rights();
        let proc = self.thread.proc();
        let parent = proc.get_object_with_rights::<VmAddressRegion>(parent_vmar, perm_rights)?;

        if vm_options.intersects(VmOptions::PERM_RXW | VmOptions::MAP_RANGE) {
            return Err(ZxError::INVALID_ARGS);
        }
        // get vmar_flags
        let vmar_flags = vm_options.to_flags();
        if vmar_flags.intersects(
            !(VmarFlags::SPECIFIC
                | VmarFlags::CAN_MAP_SPECIFIC
                | VmarFlags::COMPACT
                | VmarFlags::CAN_MAP_RXW),
        ) {
            return Err(ZxError::INVALID_ARGS);
        }

        // get align
        let align = amount_of_alignments(options)?;

        // get offest with options
        let offset = if vm_options.contains(VmOptions::SPECIFIC) {
            Some(offset as usize)
        } else if vm_options.contains(VmOptions::SPECIFIC_OVERWRITE) {
            unimplemented!()
        } else {
            if offset != 0 {
                return Err(ZxError::INVALID_ARGS);
            }
            None
        };

        let size = roundup_pages(size as usize);
        // check `size`
        if size == 0 {
            return Err(ZxError::INVALID_ARGS);
        }
        let child = parent.allocate(offset, size, vmar_flags, align)?;
        let child_addr = child.addr();
        let child_handle = proc.add_handle(Handle::new(child, Rights::DEFAULT_VMAR | perm_rights));
        info!("vmar.allocate: at {:#x?}", child_addr);
        out_child_vmar.write(child_handle)?;
        out_child_addr.write(child_addr)?;
        Ok(())
    }
/// Allocate a new subregion.
///
/// Creates a new VMAR within the one specified by `parent_vmar`.
Allocate a new subregion.
Creates a new VMAR within the one specified by `parent_vmar`.
Allocate a new subregion . Creates a new VMAR within the one specified by ` parent_vmar ` .
pub fn sys_vmar_allocate(
        &self,
        parent_vmar: HandleValue,
        options: u32,
        offset: u64,
        size: u64,
        mut out_child_vmar: UserOutPtr<HandleValue>,
        mut out_child_addr: UserOutPtr<usize>,
    ) -> ZxResult {
        let vm_options = VmOptions::from_bits(options).ok_or(ZxError::INVALID_ARGS)?;
        info!(
            "vmar.allocate: parent={:#x?}, options={:#x?}, offset={:#x?}, size={:#x?}",
            parent_vmar, options, offset, size,
        );
        // try to get parent_vmar
        let perm_rights = vm_options.to_rights();
        let proc = self.thread.proc();
        let parent = proc.get_object_with_rights::<VmAddressRegion>(parent_vmar, perm_rights)?;
        if vm_options.intersects(VmOptions::PERM_RXW | VmOptions::MAP_RANGE) {
            return Err(ZxError::INVALID_ARGS);
        }
        // get vmar_flags
        let vmar_flags = vm_options.to_flags();
        if vmar_flags.intersects(
            !(VmarFlags::SPECIFIC
                | VmarFlags::CAN_MAP_SPECIFIC
                | VmarFlags::COMPACT
                | VmarFlags::CAN_MAP_RXW),
        ) {
            return Err(ZxError::INVALID_ARGS);
        }
        // get align
        let align = amount_of_alignments(options)?;
        // get offest with options
        let offset = if vm_options.contains(VmOptions::SPECIFIC) {
            Some(offset as usize)
        } else if vm_options.contains(VmOptions::SPECIFIC_OVERWRITE) {
            unimplemented!()
        } else {
            if offset != 0 {
                return Err(ZxError::INVALID_ARGS);
            }
            None
        };
        let size = roundup_pages(size as usize);
        // check `size`
        if size == 0 {
            return Err(ZxError::INVALID_ARGS);
        }
        let child = parent.allocate(offset, size, vmar_flags, align)?;
        let child_addr = child.addr();
        let child_handle = proc.add_handle(Handle::new(child, Rights::DEFAULT_VMAR | perm_rights));
        info!("vmar.allocate: at {:#x?}", child_addr);
        out_child_vmar.write(child_handle)?;
        out_child_addr.write(child_addr)?;
        Ok(())
    }
pub fn sys_vmar_allocate ( & self , parent_vmar : HandleValue , options : u32 , offset : u64 , size : u64 , mut out_child_vmar : UserOutPtr < HandleValue > , mut out_child_addr : UserOutPtr < usize > , ) -> ZxResult { let vm_options = VmOptions :: from_bits ( options ) . ok_or ( ZxError :: INVALID_ARGS ) ? ; info ! ( " " parent_vmar options offset size ) ; // try to get parent_vmar let perm_rights = vm_options . to_rights ( ) ; let proc = self . thread . proc ( ) ; let parent = proc . get_object_with_rights :: < VmAddressRegion > ( parent_vmar , perm_rights ) ? ; if vm_options . intersects ( VmOptions :: PERM_RXW | VmOptions :: MAP_RANGE ) { return Err ( ZxError :: INVALID_ARGS ) ; } // get vmar_flags let vmar_flags = vm_options . to_flags ( ) ; if vmar_flags . intersects ( ! ( VmarFlags :: SPECIFIC | VmarFlags :: CAN_MAP_SPECIFIC | VmarFlags :: COMPACT | VmarFlags :: CAN_MAP_RXW ) , ) { return Err ( ZxError :: INVALID_ARGS ) ; } // get align let align = amount_of_alignments ( options ) ? ; // get offest with options let offset = if vm_options . contains ( VmOptions :: SPECIFIC ) { Some ( offset as usize ) } else if vm_options . contains ( VmOptions :: SPECIFIC_OVERWRITE ) { unimplemented ! ( ) } else { if offset != 0 { return Err ( ZxError :: INVALID_ARGS ) ; } None } ; let size = roundup_pages ( size as usize ) ; // check `size` if size == 0 { return Err ( ZxError :: INVALID_ARGS ) ; } let child = parent . allocate ( offset , size , vmar_flags , align ) ? ; let child_addr = child . addr ( ) ; let child_handle = proc . add_handle ( Handle :: new ( child , Rights :: DEFAULT_VMAR | perm_rights ) ) ; info ! ( " " child_addr ) ; out_child_vmar . write ( child_handle ) ? ; out_child_addr . write ( child_addr ) ? ; Ok ( ( ) ) }
Allocate a new subregion.
Allocate a new subregion .
&self
parent_vmar
HandleValue
options
u32
offset
u64
size
u64
out_child_vmar
UserOutPtr<HandleValue>
out_child_addr
UserOutPtr<usize>
&self
parent_vmar
HandleValue
options
u32
offset
u64
size
u64
out_child_vmar
UserOutPtr<HandleValue>
out_child_addr
UserOutPtr<usize>