pub fn new(dtb_base_vaddr: usize, io_mapper: M) -> DeviceResult<Self> {
        // read device tree blob header firstly
        let header = unsafe { core::slice::from_raw_parts(dtb_base_vaddr as *const u32, 2) };
        let magic = u32::from_be(header[0]);
        let size = u32::from_be(header[1]);
        if magic != MAGIC_NUMBER {
            return Err(DeviceError::InvalidParam);
        }
        // then read dtb
        let buf =
            unsafe { core::slice::from_raw_parts(dtb_base_vaddr as *const u8, size as usize) };
        let dt = DeviceTree::load(buf).map_err(|e| {
            warn!(
                "device-tree: failed to load DTB @ {:#x}: {:?}",
                dtb_base_vaddr, e
            );
            DeviceError::InvalidParam
        })?;
        Ok(Self { dt, io_mapper })
    }
/// Prepare to parse DTB from the given virtual address.
Prepare to parse DTB from the given virtual address.
Prepare to parse DTB from the given virtual address .
pub fn new(dtb_base_vaddr: usize, io_mapper: M) -> DeviceResult<Self> {
        // read device tree blob header firstly
        let header = unsafe { core::slice::from_raw_parts(dtb_base_vaddr as *const u32, 2) };
        let magic = u32::from_be(header[0]);
        let size = u32::from_be(header[1]);
        if magic != MAGIC_NUMBER {
            return Err(DeviceError::InvalidParam);
        }
        // then read dtb
        let buf =
            unsafe { core::slice::from_raw_parts(dtb_base_vaddr as *const u8, size as usize) };
        let dt = DeviceTree::load(buf).map_err(|e| {
            warn!(
                "device-tree: failed to load DTB @ {:#x}: {:?}",
                dtb_base_vaddr, e
            );
            DeviceError::InvalidParam
        })?;
        Ok(Self { dt, io_mapper })
    }
pub fn new ( dtb_base_vaddr : usize , io_mapper : M ) -> DeviceResult < Self > { // read device tree blob header firstly let header = unsafe { core :: slice :: from_raw_parts ( dtb_base_vaddr as * const u32 , 2 ) } ; let magic = u32 :: from_be ( header [ 0 ] ) ; let size = u32 :: from_be ( header [ 1 ] ) ; if magic != MAGIC_NUMBER { return Err ( DeviceError :: InvalidParam ) ; } // then read dtb let buf = unsafe { core :: slice :: from_raw_parts ( dtb_base_vaddr as * const u8 , size as usize ) } ; let dt = DeviceTree :: load ( buf ) . map_err ( | e | { warn ! ( " " dtb_base_vaddr e ) ; DeviceError :: InvalidParam } ) ? ; Ok ( Self { dt , io_mapper } ) }
Prepare to parse DTB from the given virtual address.
Prepare to parse DTB from the given virtual address .
dtb_base_vaddr
usize
io_mapper
M
dtb_base_vaddr
usize
io_mapper
M