On Wed, May 23, 2018 at 10:03:39PM -0600, Simon Glass wrote: > Export all of these through Python. > > Signed-off-by: Simon Glass <sjg@xxxxxxxxxxxx> > --- > > pylibfdt/libfdt.i | 66 ++++++++++++++++++++++++++++++++++++++++- > tests/pylibfdt_tests.py | 8 +++++ > 2 files changed, 73 insertions(+), 1 deletion(-) > > diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i > index dd924b0..e837168 100644 > --- a/pylibfdt/libfdt.i > +++ b/pylibfdt/libfdt.i > @@ -233,6 +233,14 @@ class Fdt: > """ > return check_err(fdt_next_subnode(self._fdt, nodeoffset), quiet) > > + def magic(self): > + """Return the magic word from the header > + > + Returns: > + Magic word > + """ > + return fdt_magic(self._fdt) & 0xffffffff What's the mask for? > def totalsize(self): > """Return the total size of the device tree > > @@ -242,13 +250,69 @@ class Fdt: > return check_err(fdt_totalsize(self._fdt)) > > def off_dt_struct(self): > - """Return the start of the device tree struct area > + """Return the start of the device-tree struct area > > Returns: > Start offset of struct area > """ > return check_err(fdt_off_dt_struct(self._fdt)) > > + def off_dt_strings(self): > + """Return the start of the device-tree string area > + > + Returns: > + Start offset of string area > + """ > + return check_err(fdt_off_dt_strings(self._fdt)) I don't think check_err() actually makes sense here (you didn't use it for fdt_magic()). But these functions (well, macros) return a full uint32_t and can't return error codes. > + > + def off_mem_rsvmap(self): > + """Return the start of the memory reserve map > + > + Returns: > + Start offset of memory reserve map > + """ > + return check_err(fdt_off_mem_rsvmap(self._fdt)) > + > + def version(self): > + """Return the version of the device tree > + > + Returns: > + Version number of the device tree > + """ > + return check_err(fdt_version(self._fdt)) > + > + def last_comp_version(self): > + """Return the last compatible version of the device tree > + > + Returns: > + Last compatible version number of the device tree > + """ > + return check_err(fdt_last_comp_version(self._fdt)) > + > + def boot_cpuid_phys(self): > + """Return the physical boot CPU ID > + > + Returns: > + Physical boot CPU ID > + """ > + return check_err(fdt_boot_cpuid_phys(self._fdt)) > + > + def size_dt_strings(self): > + """Return the start of the device-tree string area > + > + Returns: > + Start offset of string area > + """ > + return check_err(fdt_size_dt_strings(self._fdt)) > + > + def size_dt_struct(self): > + """Return the start of the device-tree struct area > + > + Returns: > + Start offset of struct area > + """ > + return check_err(fdt_size_dt_struct(self._fdt)) > + > def subnode_offset(self, parentoffset, name, quiet=()): > """Get the offset of a named subnode > > diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py > index b4efcea..8316499 100644 > --- a/tests/pylibfdt_tests.py > +++ b/tests/pylibfdt_tests.py > @@ -276,8 +276,16 @@ class PyLibfdtTests(unittest.TestCase): > > def testHeader(self): > """Test that we can access the header values""" > + self.assertEquals(self.fdt.magic(), 0xd00dfeed) > self.assertEquals(self.fdt.totalsize(), len(self.fdt._fdt)) > self.assertEquals(self.fdt.off_dt_struct(), 88) > + self.assertEquals(self.fdt.off_dt_strings(), 652) > + self.assertEquals(self.fdt.off_mem_rsvmap(), 40) > + self.assertEquals(self.fdt.version(), 17) > + self.assertEquals(self.fdt.last_comp_version(), 16) > + self.assertEquals(self.fdt.boot_cpuid_phys(), 0) > + self.assertEquals(self.fdt.size_dt_strings(), 105) > + self.assertEquals(self.fdt.size_dt_struct(), 564) > > def testPack(self): > """Test that we can pack the tree after deleting something""" -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature