/// Load a region of bytes into the virtual address space of the process.
Load a region of bytes into the virtual address space of the process.
Load a region of bytes into the virtual address space of the process .
fn load(
        &mut self,
        _flags: elfloader::Flags,
        destination: u64,
        region: &[u8],
    ) -> Result<(), ElfLoaderErr> {
        let destination = self.offset + destination;
        debug!(
            "ELF Load at {:#x} -- {:#x}",
            destination,
            destination + region.len()
        );
        // Load the region at destination in the kernel space
        for (idx, val) in region.iter().enumerate() {
            let vaddr = VAddr::from(destination + idx);
            let paddr = self.vspace.resolve_addr(vaddr);
            if paddr.is_some() {
                // Inefficient byte-wise copy since we don't necessarily
                // have consecutive "physical" memory in UEFI we can
                // just memcopy this stuff into.
                // Best way would probably mean to map replicate the kernel mappings
                // in UEFI space if this ever becomes a problem.
                let ptr = paddr.unwrap().as_u64() as *mut u8;
                unsafe {
                    *ptr = *val;
                }
            } else {
                panic!("Can't write to the resolved address in the kernel vspace.");
            }
        }
        Ok(())
    }
fn load ( & mut self , _flags : elfloader :: Flags , destination : u64 , region : & [ u8 ] , ) -> Result < ( ) , ElfLoaderErr > { let destination = self . offset + destination ; debug ! ( " " destination destination region len ( ) ) ; // Load the region at destination in the kernel space for ( idx , val ) in region . iter ( ) . enumerate ( ) { let vaddr = VAddr :: from ( destination + idx ) ; let paddr = self . vspace . resolve_addr ( vaddr ) ; if paddr . is_some ( ) { // Inefficient byte-wise copy since we don't necessarily // have consecutive "physical" memory in UEFI we can // just memcopy this stuff into. // Best way would probably mean to map replicate the kernel mappings // in UEFI space if this ever becomes a problem. let ptr = paddr . unwrap ( ) . as_u64 ( ) as * mut u8 ; unsafe { * ptr = * val ; } } else { panic ! ( " " ) ; } } Ok ( ( ) ) }
Load a region of bytes into the virtual address space of the process.
Load a region of bytes into the virtual address space of the process .
&mut self
_flags
elfloader::Flags
destination
u64
region
&[u8]