[PATCH 03/10] pylibfdt: Add support for the rest of the header functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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
+
     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))
+
+    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"""
-- 
2.17.0.441.gb46fe60e1d-goog

--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux