Giter Site home page Giter Site logo

fdt-rs's People

Contributors

berkus avatar dgarrett avatar kritzefitz avatar lf- avatar skallwar avatar spwilson2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fdt-rs's Issues

cargo doc not working

I included this library in a no_std project. Unfortunately, this breaks cargo doc builds.
It seems like the issue is fixed in master, so maybe push a new point release to crates.io?

fdt_rs::base prop().node() iteration appears to be bugged.

The following test fails in the "Device tree memory node missing 'reg' prop." expect clause using the riscv-5 device tree.

#[test]
fn get_memory_prop_node() {
    unsafe {
        let blob = DevTree::new(FDT).unwrap();

        let mem_prop = blob.props().find(|p| Ok(p.name()? == "device_type" && p.str()? == "memory"))
            .unwrap()
            .expect("Unable to find memory node.");
        let mem_node = mem_prop.node();
        let mem_reg_prop = mem_node.props()
            .find(|p| Ok(p.name()? == "reg"))
            .unwrap()
            .expect("Device tree memory node missing 'reg' prop.");
}

Doesn't build on new nightly

error[E0557]: feature has been removed
  --> /home/jade/.cargo/git/checkouts/fdt-rs-13c2679c47ec7b62/2364d50/src/lib.rs:27:39
   |
27 | #![cfg_attr(RUSTC_IS_NIGHTLY, feature(external_doc))]
   |                                       ^^^^^^^^^^^^ feature has been removed
   |
   = note: use #[doc = include_str!("filename")] instead, which handles macro invocations

Misaligned pointer read of fdt_reserve_entry

Issue stems from my faulty assertion that structs would be 32-bit aligned. (The fdt_reserve_entry is 64-bit aligned since its members are uniquely 64be typed.)

Unfortunately, because the API returns a reference to each parsed field the API to access this field will need to change. (We can't return a misaligned reference.) Since internally this isn't a particularly widely used field, API blowback should be minimal.

We should either return a special wrapper that supports misaligned references/raw pointers or just return a raw pointer and have the consumer deal with the read_unaligned call. (I'm leaning towards using a wrapper type for safety.)

    /// Return the current offset as a fdt_reserve_entry reference.
    ///
    /// # Safety
    ///
    /// The caller must verify that the current offset of this iterator is 32-bit aligned.
    /// (Each field is 32-bit aligned and they may be read individually.)
    unsafe fn read(&'a self) -> Result<&'dt fdt_reserve_entry> {
        Ok(&*self.fdt.ptr_at(self.offset)?)
    }
}

impl<'a, 'dt: 'a> Iterator for DevTreeReserveEntryIter<'a, 'dt> {
    type Item = &'dt fdt_reserve_entry;
    fn next(&mut self) -> Option<Self::Item> {
...
            // We guaruntee the read will be aligned to 32 bits because:
            // - We construct with guarunteed 32-bit aligned offset
            // - We always increment by an aligned amount
            let ret = unsafe { self.read().unwrap() };

...
            Some(ret)

thread 'reserved_entries_iter' panicked at 'misaligned pointer dereference: address must be a multiple of 0x8 but is 0x1026398c4', src/base/iters.rs:41:12
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: core::panicking::panic_misaligned_pointer_dereference
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:174:5
   3: fdt_rs::base::iters::DevTreeReserveEntryIter::read
             at ./src/base/iters.rs:41:12
   4: <fdt_rs::base::iters::DevTreeReserveEntryIter as core::iter::traits::iterator::Iterator>::next
             at ./src/base/iters.rs:54:32
   5: core::iter::traits::iterator::Iterator::fold
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/iter/traits/iterator.rs:2481:29
   6: core::iter::traits::iterator::Iterator::count
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/iter/traits/iterator.rs:267:9
   7: parsing_test::reserved_entries_iter
             at ./tests/parsing_test.rs:88:17
   8: parsing_test::reserved_entries_iter::{{closure}}
             at ./tests/parsing_test.rs:85:28
   9: core::ops::function::FnOnce::call_once
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
  10: core::ops::function::FnOnce::call_once
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5

Documentation incomplete

Hi!

The documentation here states two examples in the base module which are identical and use index instead of actually devTree that is created in the example above. I believe his is an omission and should be improved somehow?

Compatible Search

Find all DevTreeNode objects which have their compatible property defined as "ns16550a":

vs.

Custom Search

Find all DevTreeNode objects which have their compatible property defined as "ns16550a":

Code is exactly the same in both sections.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.