|
@@ -26,6 +26,27 @@ import tools
|
|
our_path = os.path.dirname(os.path.realpath(__file__))
|
|
our_path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
|
|
|
|
|
|
|
+HEADER = '''/*
|
|
|
|
+ * DO NOT MODIFY
|
|
|
|
+ *
|
|
|
|
+ * This file was generated by dtoc from a .dtb (device tree binary) file.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#include <stdbool.h>
|
|
|
|
+#include <libfdt.h>'''
|
|
|
|
+
|
|
|
|
+C_HEADER = '''/*
|
|
|
|
+ * DO NOT MODIFY
|
|
|
|
+ *
|
|
|
|
+ * This file was generated by dtoc from a .dtb (device tree binary) file.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#include <common.h>
|
|
|
|
+#include <dm.h>
|
|
|
|
+#include <dt-structs.h>
|
|
|
|
+'''
|
|
|
|
+
|
|
|
|
+
|
|
def get_dtb_file(dts_fname):
|
|
def get_dtb_file(dts_fname):
|
|
"""Compile a .dts file to a .dtb
|
|
"""Compile a .dts file to a .dtb
|
|
|
|
|
|
@@ -104,13 +125,12 @@ class TestDtoc(unittest.TestCase):
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
lines = infile.read().splitlines()
|
|
lines = infile.read().splitlines()
|
|
- self.assertEqual(['#include <stdbool.h>', '#include <libfdt.h>'], lines)
|
|
|
|
|
|
+ self.assertEqual(HEADER.splitlines(), lines)
|
|
|
|
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
lines = infile.read().splitlines()
|
|
lines = infile.read().splitlines()
|
|
- self.assertEqual(['#include <common.h>', '#include <dm.h>',
|
|
|
|
- '#include <dt-structs.h>', ''], lines)
|
|
|
|
|
|
+ self.assertEqual(C_HEADER.splitlines() + [''], lines)
|
|
|
|
|
|
def test_simple(self):
|
|
def test_simple(self):
|
|
"""Test output from some simple nodes with various types of data"""
|
|
"""Test output from some simple nodes with various types of data"""
|
|
@@ -119,8 +139,7 @@ class TestDtoc(unittest.TestCase):
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <stdbool.h>
|
|
|
|
-#include <libfdt.h>
|
|
|
|
|
|
+ self.assertEqual(HEADER + '''
|
|
struct dtd_sandbox_i2c_test {
|
|
struct dtd_sandbox_i2c_test {
|
|
};
|
|
};
|
|
struct dtd_sandbox_pmic_test {
|
|
struct dtd_sandbox_pmic_test {
|
|
@@ -144,10 +163,7 @@ struct dtd_sandbox_spl_test_2 {
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <common.h>
|
|
|
|
-#include <dm.h>
|
|
|
|
-#include <dt-structs.h>
|
|
|
|
-
|
|
|
|
|
|
+ self.assertEqual(C_HEADER + '''
|
|
static struct dtd_sandbox_spl_test dtv_spl_test = {
|
|
static struct dtd_sandbox_spl_test dtv_spl_test = {
|
|
\t.bytearray\t\t= {0x6, 0x0, 0x0},
|
|
\t.bytearray\t\t= {0x6, 0x0, 0x0},
|
|
\t.byteval\t\t= 0x5,
|
|
\t.byteval\t\t= 0x5,
|
|
@@ -225,8 +241,7 @@ U_BOOT_DEVICE(pmic_at_9) = {
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <stdbool.h>
|
|
|
|
-#include <libfdt.h>
|
|
|
|
|
|
+ self.assertEqual(HEADER + '''
|
|
struct dtd_source {
|
|
struct dtd_source {
|
|
\tstruct phandle_2_arg clocks[4];
|
|
\tstruct phandle_2_arg clocks[4];
|
|
};
|
|
};
|
|
@@ -238,10 +253,7 @@ struct dtd_target {
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <common.h>
|
|
|
|
-#include <dm.h>
|
|
|
|
-#include <dt-structs.h>
|
|
|
|
-
|
|
|
|
|
|
+ self.assertEqual(C_HEADER + '''
|
|
static struct dtd_target dtv_phandle_target = {
|
|
static struct dtd_target dtv_phandle_target = {
|
|
\t.intval\t\t\t= 0x0,
|
|
\t.intval\t\t\t= 0x0,
|
|
};
|
|
};
|
|
@@ -291,8 +303,7 @@ U_BOOT_DEVICE(phandle_source) = {
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <stdbool.h>
|
|
|
|
-#include <libfdt.h>
|
|
|
|
|
|
+ self.assertEqual(HEADER + '''
|
|
struct dtd_compat1 {
|
|
struct dtd_compat1 {
|
|
\tfdt32_t\t\tintval;
|
|
\tfdt32_t\t\tintval;
|
|
};
|
|
};
|
|
@@ -303,10 +314,7 @@ struct dtd_compat1 {
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <common.h>
|
|
|
|
-#include <dm.h>
|
|
|
|
-#include <dt-structs.h>
|
|
|
|
-
|
|
|
|
|
|
+ self.assertEqual(C_HEADER + '''
|
|
static struct dtd_compat1 dtv_spl_test = {
|
|
static struct dtd_compat1 dtv_spl_test = {
|
|
\t.intval\t\t\t= 0x1,
|
|
\t.intval\t\t\t= 0x1,
|
|
};
|
|
};
|
|
@@ -325,8 +333,7 @@ U_BOOT_DEVICE(spl_test) = {
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <stdbool.h>
|
|
|
|
-#include <libfdt.h>
|
|
|
|
|
|
+ self.assertEqual(HEADER + '''
|
|
struct dtd_test1 {
|
|
struct dtd_test1 {
|
|
\tfdt64_t\t\treg[2];
|
|
\tfdt64_t\t\treg[2];
|
|
};
|
|
};
|
|
@@ -341,10 +348,7 @@ struct dtd_test3 {
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <common.h>
|
|
|
|
-#include <dm.h>
|
|
|
|
-#include <dt-structs.h>
|
|
|
|
-
|
|
|
|
|
|
+ self.assertEqual(C_HEADER + '''
|
|
static struct dtd_test1 dtv_test1 = {
|
|
static struct dtd_test1 dtv_test1 = {
|
|
\t.reg\t\t\t= {0x1234, 0x5678},
|
|
\t.reg\t\t\t= {0x1234, 0x5678},
|
|
};
|
|
};
|
|
@@ -381,8 +385,7 @@ U_BOOT_DEVICE(test3) = {
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <stdbool.h>
|
|
|
|
-#include <libfdt.h>
|
|
|
|
|
|
+ self.assertEqual(HEADER + '''
|
|
struct dtd_test1 {
|
|
struct dtd_test1 {
|
|
\tfdt32_t\t\treg[2];
|
|
\tfdt32_t\t\treg[2];
|
|
};
|
|
};
|
|
@@ -394,10 +397,7 @@ struct dtd_test2 {
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <common.h>
|
|
|
|
-#include <dm.h>
|
|
|
|
-#include <dt-structs.h>
|
|
|
|
-
|
|
|
|
|
|
+ self.assertEqual(C_HEADER + '''
|
|
static struct dtd_test1 dtv_test1 = {
|
|
static struct dtd_test1 dtv_test1 = {
|
|
\t.reg\t\t\t= {0x1234, 0x5678},
|
|
\t.reg\t\t\t= {0x1234, 0x5678},
|
|
};
|
|
};
|
|
@@ -425,8 +425,7 @@ U_BOOT_DEVICE(test2) = {
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <stdbool.h>
|
|
|
|
-#include <libfdt.h>
|
|
|
|
|
|
+ self.assertEqual(HEADER + '''
|
|
struct dtd_test1 {
|
|
struct dtd_test1 {
|
|
\tfdt64_t\t\treg[2];
|
|
\tfdt64_t\t\treg[2];
|
|
};
|
|
};
|
|
@@ -441,10 +440,7 @@ struct dtd_test3 {
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <common.h>
|
|
|
|
-#include <dm.h>
|
|
|
|
-#include <dt-structs.h>
|
|
|
|
-
|
|
|
|
|
|
+ self.assertEqual(C_HEADER + '''
|
|
static struct dtd_test1 dtv_test1 = {
|
|
static struct dtd_test1 dtv_test1 = {
|
|
\t.reg\t\t\t= {0x123400000000, 0x5678},
|
|
\t.reg\t\t\t= {0x123400000000, 0x5678},
|
|
};
|
|
};
|
|
@@ -481,8 +477,7 @@ U_BOOT_DEVICE(test3) = {
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['struct'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <stdbool.h>
|
|
|
|
-#include <libfdt.h>
|
|
|
|
|
|
+ self.assertEqual(HEADER + '''
|
|
struct dtd_test1 {
|
|
struct dtd_test1 {
|
|
\tfdt64_t\t\treg[2];
|
|
\tfdt64_t\t\treg[2];
|
|
};
|
|
};
|
|
@@ -497,10 +492,7 @@ struct dtd_test3 {
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
|
|
with open(output) as infile:
|
|
with open(output) as infile:
|
|
data = infile.read()
|
|
data = infile.read()
|
|
- self.assertEqual('''#include <common.h>
|
|
|
|
-#include <dm.h>
|
|
|
|
-#include <dt-structs.h>
|
|
|
|
-
|
|
|
|
|
|
+ self.assertEqual(C_HEADER + '''
|
|
static struct dtd_test1 dtv_test1 = {
|
|
static struct dtd_test1 dtv_test1 = {
|
|
\t.reg\t\t\t= {0x1234, 0x567800000000},
|
|
\t.reg\t\t\t= {0x1234, 0x567800000000},
|
|
};
|
|
};
|