diff -Nru device-tree-compiler-1.4.2/checks.c device-tree-compiler-1.4.5/checks.c --- device-tree-compiler-1.4.2/checks.c 2016-09-03 11:02:30.000000000 +0000 +++ device-tree-compiler-1.4.5/checks.c 2017-09-27 10:00:10.000000000 +0000 @@ -40,7 +40,7 @@ struct check; -typedef void (*check_fn)(struct check *c, struct node *dt, struct node *node); +typedef void (*check_fn)(struct check *c, struct dt_info *dti, struct node *node); struct check { const char *name; @@ -72,17 +72,16 @@ #define CHECK(_nm, _fn, _d, ...) \ CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__) -#ifdef __GNUC__ -static inline void check_msg(struct check *c, const char *fmt, ...) __attribute__((format (printf, 2, 3))); -#endif -static inline void check_msg(struct check *c, const char *fmt, ...) +static inline void PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti, + const char *fmt, ...) { va_list ap; va_start(ap, fmt); if ((c->warn && (quiet < 1)) || (c->error && (quiet < 2))) { - fprintf(stderr, "%s (%s): ", + fprintf(stderr, "%s: %s (%s): ", + strcmp(dti->outname, "-") ? dti->outname : "", (c->error) ? "ERROR" : "Warning", c->name); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); @@ -90,27 +89,28 @@ va_end(ap); } -#define FAIL(c, ...) \ - do { \ - TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \ - (c)->status = FAILED; \ - check_msg((c), __VA_ARGS__); \ +#define FAIL(c, dti, ...) \ + do { \ + TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \ + (c)->status = FAILED; \ + check_msg((c), dti, __VA_ARGS__); \ } while (0) -static void check_nodes_props(struct check *c, struct node *dt, struct node *node) +static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node) { struct node *child; TRACE(c, "%s", node->fullpath); if (c->fn) - c->fn(c, dt, node); + c->fn(c, dti, node); for_each_child(node, child) - check_nodes_props(c, dt, child); + check_nodes_props(c, dti, child); } -static bool run_check(struct check *c, struct node *dt) +static bool run_check(struct check *c, struct dt_info *dti) { + struct node *dt = dti->dt; bool error = false; int i; @@ -123,10 +123,10 @@ for (i = 0; i < c->num_prereqs; i++) { struct check *prq = c->prereq[i]; - error = error || run_check(prq, dt); + error = error || run_check(prq, dti); if (prq->status != PASSED) { c->status = PREREQ; - check_msg(c, "Failed prerequisite '%s'", + check_msg(c, dti, "Failed prerequisite '%s'", c->prereq[i]->name); } } @@ -134,7 +134,7 @@ if (c->status != UNCHECKED) goto out; - check_nodes_props(c, dt, dt); + check_nodes_props(c, dti, dt); if (c->status == UNCHECKED) c->status = PASSED; @@ -153,14 +153,14 @@ */ /* A check which always fails, for testing purposes only */ -static inline void check_always_fail(struct check *c, struct node *dt, +static inline void check_always_fail(struct check *c, struct dt_info *dti, struct node *node) { - FAIL(c, "always_fail check"); + FAIL(c, dti, "always_fail check"); } CHECK(always_fail, check_always_fail, NULL); -static void check_is_string(struct check *c, struct node *root, +static void check_is_string(struct check *c, struct dt_info *dti, struct node *node) { struct property *prop; @@ -171,7 +171,7 @@ return; /* Not present, assumed ok */ if (!data_is_one_string(prop->val)) - FAIL(c, "\"%s\" property in %s is not a string", + FAIL(c, dti, "\"%s\" property in %s is not a string", propname, node->fullpath); } #define WARNING_IF_NOT_STRING(nm, propname) \ @@ -179,7 +179,7 @@ #define ERROR_IF_NOT_STRING(nm, propname) \ ERROR(nm, check_is_string, (propname)) -static void check_is_cell(struct check *c, struct node *root, +static void check_is_cell(struct check *c, struct dt_info *dti, struct node *node) { struct property *prop; @@ -190,7 +190,7 @@ return; /* Not present, assumed ok */ if (prop->val.len != sizeof(cell_t)) - FAIL(c, "\"%s\" property in %s is not a single cell", + FAIL(c, dti, "\"%s\" property in %s is not a single cell", propname, node->fullpath); } #define WARNING_IF_NOT_CELL(nm, propname) \ @@ -202,7 +202,7 @@ * Structural check functions */ -static void check_duplicate_node_names(struct check *c, struct node *dt, +static void check_duplicate_node_names(struct check *c, struct dt_info *dti, struct node *node) { struct node *child, *child2; @@ -212,12 +212,12 @@ child2; child2 = child2->next_sibling) if (streq(child->name, child2->name)) - FAIL(c, "Duplicate node name %s", + FAIL(c, dti, "Duplicate node name %s", child->fullpath); } ERROR(duplicate_node_names, check_duplicate_node_names, NULL); -static void check_duplicate_property_names(struct check *c, struct node *dt, +static void check_duplicate_property_names(struct check *c, struct dt_info *dti, struct node *node) { struct property *prop, *prop2; @@ -227,7 +227,7 @@ if (prop2->deleted) continue; if (streq(prop->name, prop2->name)) - FAIL(c, "Duplicate property name %s in %s", + FAIL(c, dti, "Duplicate property name %s in %s", prop->name, node->fullpath); } } @@ -238,29 +238,41 @@ #define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #define DIGITS "0123456789" #define PROPNODECHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-" +#define PROPNODECHARSSTRICT LOWERCASE UPPERCASE DIGITS ",-" -static void check_node_name_chars(struct check *c, struct node *dt, +static void check_node_name_chars(struct check *c, struct dt_info *dti, struct node *node) { int n = strspn(node->name, c->data); if (n < strlen(node->name)) - FAIL(c, "Bad character '%c' in node %s", + FAIL(c, dti, "Bad character '%c' in node %s", node->name[n], node->fullpath); } ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@"); -static void check_node_name_format(struct check *c, struct node *dt, +static void check_node_name_chars_strict(struct check *c, struct dt_info *dti, + struct node *node) +{ + int n = strspn(node->name, c->data); + + if (n < node->basenamelen) + FAIL(c, dti, "Character '%c' not recommended in node %s", + node->name[n], node->fullpath); +} +CHECK(node_name_chars_strict, check_node_name_chars_strict, PROPNODECHARSSTRICT); + +static void check_node_name_format(struct check *c, struct dt_info *dti, struct node *node) { if (strchr(get_unitname(node), '@')) - FAIL(c, "Node %s has multiple '@' characters in name", + FAIL(c, dti, "Node %s has multiple '@' characters in name", node->fullpath); } ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars); -static void check_unit_address_vs_reg(struct check *c, struct node *dt, - struct node *node) +static void check_unit_address_vs_reg(struct check *c, struct dt_info *dti, + struct node *node) { const char *unitname = get_unitname(node); struct property *prop = get_property(node, "reg"); @@ -273,17 +285,17 @@ if (prop) { if (!unitname[0]) - FAIL(c, "Node %s has a reg or ranges property, but no unit name", + FAIL(c, dti, "Node %s has a reg or ranges property, but no unit name", node->fullpath); } else { if (unitname[0]) - FAIL(c, "Node %s has a unit name, but no reg property", + FAIL(c, dti, "Node %s has a unit name, but no reg property", node->fullpath); } } WARNING(unit_address_vs_reg, check_unit_address_vs_reg, NULL); -static void check_property_name_chars(struct check *c, struct node *dt, +static void check_property_name_chars(struct check *c, struct dt_info *dti, struct node *node) { struct property *prop; @@ -292,12 +304,44 @@ int n = strspn(prop->name, c->data); if (n < strlen(prop->name)) - FAIL(c, "Bad character '%c' in property name \"%s\", node %s", + FAIL(c, dti, "Bad character '%c' in property name \"%s\", node %s", prop->name[n], prop->name, node->fullpath); } } ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS); +static void check_property_name_chars_strict(struct check *c, + struct dt_info *dti, + struct node *node) +{ + struct property *prop; + + for_each_property(node, prop) { + const char *name = prop->name; + int n = strspn(name, c->data); + + if (n == strlen(prop->name)) + continue; + + /* Certain names are whitelisted */ + if (streq(name, "device_type")) + continue; + + /* + * # is only allowed at the beginning of property names not counting + * the vendor prefix. + */ + if (name[n] == '#' && ((n == 0) || (name[n-1] == ','))) { + name += n + 1; + n = strspn(name, c->data); + } + if (n < strlen(name)) + FAIL(c, dti, "Character '%c' not recommended in property name \"%s\", node %s", + name[n], prop->name, node->fullpath); + } +} +CHECK(property_name_chars_strict, check_property_name_chars_strict, PROPNODECHARSSTRICT); + #define DESCLABEL_FMT "%s%s%s%s%s" #define DESCLABEL_ARGS(node,prop,mark) \ ((mark) ? "value of " : ""), \ @@ -305,10 +349,11 @@ ((prop) ? (prop)->name : ""), \ ((prop) ? "' in " : ""), (node)->fullpath -static void check_duplicate_label(struct check *c, struct node *dt, +static void check_duplicate_label(struct check *c, struct dt_info *dti, const char *label, struct node *node, struct property *prop, struct marker *mark) { + struct node *dt = dti->dt; struct node *othernode = NULL; struct property *otherprop = NULL; struct marker *othermark = NULL; @@ -325,36 +370,37 @@ return; if ((othernode != node) || (otherprop != prop) || (othermark != mark)) - FAIL(c, "Duplicate label '%s' on " DESCLABEL_FMT + FAIL(c, dti, "Duplicate label '%s' on " DESCLABEL_FMT " and " DESCLABEL_FMT, label, DESCLABEL_ARGS(node, prop, mark), DESCLABEL_ARGS(othernode, otherprop, othermark)); } -static void check_duplicate_label_node(struct check *c, struct node *dt, +static void check_duplicate_label_node(struct check *c, struct dt_info *dti, struct node *node) { struct label *l; struct property *prop; for_each_label(node->labels, l) - check_duplicate_label(c, dt, l->label, node, NULL, NULL); + check_duplicate_label(c, dti, l->label, node, NULL, NULL); for_each_property(node, prop) { struct marker *m = prop->val.markers; for_each_label(prop->labels, l) - check_duplicate_label(c, dt, l->label, node, prop, NULL); + check_duplicate_label(c, dti, l->label, node, prop, NULL); for_each_marker_of_type(m, LABEL) - check_duplicate_label(c, dt, m->ref, node, prop, m); + check_duplicate_label(c, dti, m->ref, node, prop, m); } } ERROR(duplicate_label, check_duplicate_label_node, NULL); -static cell_t check_phandle_prop(struct check *c, struct node *root, +static cell_t check_phandle_prop(struct check *c, struct dt_info *dti, struct node *node, const char *propname) { + struct node *root = dti->dt; struct property *prop; struct marker *m; cell_t phandle; @@ -364,7 +410,7 @@ return 0; if (prop->val.len != sizeof(cell_t)) { - FAIL(c, "%s has bad length (%d) %s property", + FAIL(c, dti, "%s has bad length (%d) %s property", node->fullpath, prop->val.len, prop->name); return 0; } @@ -376,7 +422,7 @@ /* "Set this node's phandle equal to some * other node's phandle". That's nonsensical * by construction. */ { - FAIL(c, "%s in %s is a reference to another node", + FAIL(c, dti, "%s in %s is a reference to another node", prop->name, node->fullpath); } /* But setting this node's phandle equal to its own @@ -390,7 +436,7 @@ phandle = propval_cell(prop); if ((phandle == 0) || (phandle == -1)) { - FAIL(c, "%s has bad value (0x%x) in %s property", + FAIL(c, dti, "%s has bad value (0x%x) in %s property", node->fullpath, phandle, prop->name); return 0; } @@ -398,25 +444,26 @@ return phandle; } -static void check_explicit_phandles(struct check *c, struct node *root, +static void check_explicit_phandles(struct check *c, struct dt_info *dti, struct node *node) { + struct node *root = dti->dt; struct node *other; cell_t phandle, linux_phandle; /* Nothing should have assigned phandles yet */ assert(!node->phandle); - phandle = check_phandle_prop(c, root, node, "phandle"); + phandle = check_phandle_prop(c, dti, node, "phandle"); - linux_phandle = check_phandle_prop(c, root, node, "linux,phandle"); + linux_phandle = check_phandle_prop(c, dti, node, "linux,phandle"); if (!phandle && !linux_phandle) /* No valid phandles; nothing further to check */ return; if (linux_phandle && phandle && (phandle != linux_phandle)) - FAIL(c, "%s has mismatching 'phandle' and 'linux,phandle'" + FAIL(c, dti, "%s has mismatching 'phandle' and 'linux,phandle'" " properties", node->fullpath); if (linux_phandle && !phandle) @@ -424,7 +471,7 @@ other = get_node_by_phandle(root, phandle); if (other && (other != node)) { - FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)", + FAIL(c, dti, "%s has duplicated phandle 0x%x (seen before at %s)", node->fullpath, phandle, other->fullpath); return; } @@ -433,7 +480,7 @@ } ERROR(explicit_phandles, check_explicit_phandles, NULL); -static void check_name_properties(struct check *c, struct node *root, +static void check_name_properties(struct check *c, struct dt_info *dti, struct node *node) { struct property **pp, *prop = NULL; @@ -449,7 +496,7 @@ if ((prop->val.len != node->basenamelen+1) || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) { - FAIL(c, "\"name\" property in %s is incorrect (\"%s\" instead" + FAIL(c, dti, "\"name\" property in %s is incorrect (\"%s\" instead" " of base node name)", node->fullpath, prop->val.val); } else { /* The name property is correct, and therefore redundant. @@ -467,9 +514,10 @@ * Reference fixup functions */ -static void fixup_phandle_references(struct check *c, struct node *dt, +static void fixup_phandle_references(struct check *c, struct dt_info *dti, struct node *node) { + struct node *dt = dti->dt; struct property *prop; for_each_property(node, prop) { @@ -482,22 +530,27 @@ refnode = get_node_by_ref(dt, m->ref); if (! refnode) { - FAIL(c, "Reference to non-existent node or label \"%s\"\n", - m->ref); + if (!(dti->dtsflags & DTSF_PLUGIN)) + FAIL(c, dti, "Reference to non-existent node or " + "label \"%s\"\n", m->ref); + else /* mark the entry as unresolved */ + *((fdt32_t *)(prop->val.val + m->offset)) = + cpu_to_fdt32(0xffffffff); continue; } phandle = get_node_phandle(dt, refnode); - *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); + *((fdt32_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); } } } ERROR(phandle_references, fixup_phandle_references, NULL, &duplicate_node_names, &explicit_phandles); -static void fixup_path_references(struct check *c, struct node *dt, +static void fixup_path_references(struct check *c, struct dt_info *dti, struct node *node) { + struct node *dt = dti->dt; struct property *prop; for_each_property(node, prop) { @@ -510,7 +563,7 @@ refnode = get_node_by_ref(dt, m->ref); if (!refnode) { - FAIL(c, "Reference to non-existent node or label \"%s\"\n", + FAIL(c, dti, "Reference to non-existent node or label \"%s\"\n", m->ref); continue; } @@ -534,7 +587,7 @@ WARNING_IF_NOT_STRING(model_is_string, "model"); WARNING_IF_NOT_STRING(status_is_string, "status"); -static void fixup_addr_size_cells(struct check *c, struct node *dt, +static void fixup_addr_size_cells(struct check *c, struct dt_info *dti, struct node *node) { struct property *prop; @@ -558,7 +611,7 @@ #define node_size_cells(n) \ (((n)->size_cells == -1) ? 1 : (n)->size_cells) -static void check_reg_format(struct check *c, struct node *dt, +static void check_reg_format(struct check *c, struct dt_info *dti, struct node *node) { struct property *prop; @@ -569,25 +622,25 @@ return; /* No "reg", that's fine */ if (!node->parent) { - FAIL(c, "Root node has a \"reg\" property"); + FAIL(c, dti, "Root node has a \"reg\" property"); return; } if (prop->val.len == 0) - FAIL(c, "\"reg\" property in %s is empty", node->fullpath); + FAIL(c, dti, "\"reg\" property in %s is empty", node->fullpath); addr_cells = node_addr_cells(node->parent); size_cells = node_size_cells(node->parent); entrylen = (addr_cells + size_cells) * sizeof(cell_t); if (!entrylen || (prop->val.len % entrylen) != 0) - FAIL(c, "\"reg\" property in %s has invalid length (%d bytes) " + FAIL(c, dti, "\"reg\" property in %s has invalid length (%d bytes) " "(#address-cells == %d, #size-cells == %d)", node->fullpath, prop->val.len, addr_cells, size_cells); } WARNING(reg_format, check_reg_format, NULL, &addr_size_cells); -static void check_ranges_format(struct check *c, struct node *dt, +static void check_ranges_format(struct check *c, struct dt_info *dti, struct node *node) { struct property *prop; @@ -598,7 +651,7 @@ return; if (!node->parent) { - FAIL(c, "Root node has a \"ranges\" property"); + FAIL(c, dti, "Root node has a \"ranges\" property"); return; } @@ -610,17 +663,17 @@ if (prop->val.len == 0) { if (p_addr_cells != c_addr_cells) - FAIL(c, "%s has empty \"ranges\" property but its " + FAIL(c, dti, "%s has empty \"ranges\" property but its " "#address-cells (%d) differs from %s (%d)", node->fullpath, c_addr_cells, node->parent->fullpath, p_addr_cells); if (p_size_cells != c_size_cells) - FAIL(c, "%s has empty \"ranges\" property but its " + FAIL(c, dti, "%s has empty \"ranges\" property but its " "#size-cells (%d) differs from %s (%d)", node->fullpath, c_size_cells, node->parent->fullpath, p_size_cells); } else if ((prop->val.len % entrylen) != 0) { - FAIL(c, "\"ranges\" property in %s has invalid length (%d bytes) " + FAIL(c, dti, "\"ranges\" property in %s has invalid length (%d bytes) " "(parent #address-cells == %d, child #address-cells == %d, " "#size-cells == %d)", node->fullpath, prop->val.len, p_addr_cells, c_addr_cells, c_size_cells); @@ -628,10 +681,233 @@ } WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells); +static const struct bus_type pci_bus = { + .name = "PCI", +}; + +static void check_pci_bridge(struct check *c, struct dt_info *dti, struct node *node) +{ + struct property *prop; + cell_t *cells; + + prop = get_property(node, "device_type"); + if (!prop || !streq(prop->val.val, "pci")) + return; + + node->bus = &pci_bus; + + if (!strneq(node->name, "pci", node->basenamelen) && + !strneq(node->name, "pcie", node->basenamelen)) + FAIL(c, dti, "Node %s node name is not \"pci\" or \"pcie\"", + node->fullpath); + + prop = get_property(node, "ranges"); + if (!prop) + FAIL(c, dti, "Node %s missing ranges for PCI bridge (or not a bridge)", + node->fullpath); + + if (node_addr_cells(node) != 3) + FAIL(c, dti, "Node %s incorrect #address-cells for PCI bridge", + node->fullpath); + if (node_size_cells(node) != 2) + FAIL(c, dti, "Node %s incorrect #size-cells for PCI bridge", + node->fullpath); + + prop = get_property(node, "bus-range"); + if (!prop) { + FAIL(c, dti, "Node %s missing bus-range for PCI bridge", + node->fullpath); + return; + } + if (prop->val.len != (sizeof(cell_t) * 2)) { + FAIL(c, dti, "Node %s bus-range must be 2 cells", + node->fullpath); + return; + } + cells = (cell_t *)prop->val.val; + if (fdt32_to_cpu(cells[0]) > fdt32_to_cpu(cells[1])) + FAIL(c, dti, "Node %s bus-range 1st cell must be less than or equal to 2nd cell", + node->fullpath); + if (fdt32_to_cpu(cells[1]) > 0xff) + FAIL(c, dti, "Node %s bus-range maximum bus number must be less than 256", + node->fullpath); +} +WARNING(pci_bridge, check_pci_bridge, NULL, + &device_type_is_string, &addr_size_cells); + +static void check_pci_device_bus_num(struct check *c, struct dt_info *dti, struct node *node) +{ + struct property *prop; + unsigned int bus_num, min_bus, max_bus; + cell_t *cells; + + if (!node->parent || (node->parent->bus != &pci_bus)) + return; + + prop = get_property(node, "reg"); + if (!prop) + return; + + cells = (cell_t *)prop->val.val; + bus_num = (fdt32_to_cpu(cells[0]) & 0x00ff0000) >> 16; + + prop = get_property(node->parent, "bus-range"); + if (!prop) { + min_bus = max_bus = 0; + } else { + cells = (cell_t *)prop->val.val; + min_bus = fdt32_to_cpu(cells[0]); + max_bus = fdt32_to_cpu(cells[0]); + } + if ((bus_num < min_bus) || (bus_num > max_bus)) + FAIL(c, dti, "Node %s PCI bus number %d out of range, expected (%d - %d)", + node->fullpath, bus_num, min_bus, max_bus); +} +WARNING(pci_device_bus_num, check_pci_device_bus_num, NULL, ®_format, &pci_bridge); + +static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct node *node) +{ + struct property *prop; + const char *unitname = get_unitname(node); + char unit_addr[5]; + unsigned int dev, func, reg; + cell_t *cells; + + if (!node->parent || (node->parent->bus != &pci_bus)) + return; + + prop = get_property(node, "reg"); + if (!prop) { + FAIL(c, dti, "Node %s missing PCI reg property", node->fullpath); + return; + } + + cells = (cell_t *)prop->val.val; + if (cells[1] || cells[2]) + FAIL(c, dti, "Node %s PCI reg config space address cells 2 and 3 must be 0", + node->fullpath); + + reg = fdt32_to_cpu(cells[0]); + dev = (reg & 0xf800) >> 11; + func = (reg & 0x700) >> 8; + + if (reg & 0xff000000) + FAIL(c, dti, "Node %s PCI reg address is not configuration space", + node->fullpath); + if (reg & 0x000000ff) + FAIL(c, dti, "Node %s PCI reg config space address register number must be 0", + node->fullpath); + + if (func == 0) { + snprintf(unit_addr, sizeof(unit_addr), "%x", dev); + if (streq(unitname, unit_addr)) + return; + } + + snprintf(unit_addr, sizeof(unit_addr), "%x,%x", dev, func); + if (streq(unitname, unit_addr)) + return; + + FAIL(c, dti, "Node %s PCI unit address format error, expected \"%s\"", + node->fullpath, unit_addr); +} +WARNING(pci_device_reg, check_pci_device_reg, NULL, ®_format, &pci_bridge); + +static const struct bus_type simple_bus = { + .name = "simple-bus", +}; + +static bool node_is_compatible(struct node *node, const char *compat) +{ + struct property *prop; + const char *str, *end; + + prop = get_property(node, "compatible"); + if (!prop) + return false; + + for (str = prop->val.val, end = str + prop->val.len; str < end; + str += strnlen(str, end - str) + 1) { + if (strneq(str, compat, end - str)) + return true; + } + return false; +} + +static void check_simple_bus_bridge(struct check *c, struct dt_info *dti, struct node *node) +{ + if (node_is_compatible(node, "simple-bus")) + node->bus = &simple_bus; +} +WARNING(simple_bus_bridge, check_simple_bus_bridge, NULL, &addr_size_cells); + +static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct node *node) +{ + struct property *prop; + const char *unitname = get_unitname(node); + char unit_addr[17]; + unsigned int size; + uint64_t reg = 0; + cell_t *cells = NULL; + + if (!node->parent || (node->parent->bus != &simple_bus)) + return; + + prop = get_property(node, "reg"); + if (prop) + cells = (cell_t *)prop->val.val; + else { + prop = get_property(node, "ranges"); + if (prop && prop->val.len) + /* skip of child address */ + cells = ((cell_t *)prop->val.val) + node_addr_cells(node); + } + + if (!cells) { + if (node->parent->parent && !(node->bus == &simple_bus)) + FAIL(c, dti, "Node %s missing or empty reg/ranges property", node->fullpath); + return; + } + + size = node_addr_cells(node->parent); + while (size--) + reg = (reg << 32) | fdt32_to_cpu(*(cells++)); + + snprintf(unit_addr, sizeof(unit_addr), "%"PRIx64, reg); + if (!streq(unitname, unit_addr)) + FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"", + node->fullpath, unit_addr); +} +WARNING(simple_bus_reg, check_simple_bus_reg, NULL, ®_format, &simple_bus_bridge); + +static void check_unit_address_format(struct check *c, struct dt_info *dti, + struct node *node) +{ + const char *unitname = get_unitname(node); + + if (node->parent && node->parent->bus) + return; + + if (!unitname[0]) + return; + + if (!strncmp(unitname, "0x", 2)) { + FAIL(c, dti, "Node %s unit name should not have leading \"0x\"", + node->fullpath); + /* skip over 0x for next test */ + unitname += 2; + } + if (unitname[0] == '0' && isxdigit(unitname[1])) + FAIL(c, dti, "Node %s unit name should not have leading 0s", + node->fullpath); +} +WARNING(unit_address_format, check_unit_address_format, NULL, + &node_name_format, &pci_bridge, &simple_bus_bridge); + /* * Style checks */ -static void check_avoid_default_addr_size(struct check *c, struct node *dt, +static void check_avoid_default_addr_size(struct check *c, struct dt_info *dti, struct node *node) { struct property *reg, *ranges; @@ -646,20 +922,21 @@ return; if (node->parent->addr_cells == -1) - FAIL(c, "Relying on default #address-cells value for %s", + FAIL(c, dti, "Relying on default #address-cells value for %s", node->fullpath); if (node->parent->size_cells == -1) - FAIL(c, "Relying on default #size-cells value for %s", + FAIL(c, dti, "Relying on default #size-cells value for %s", node->fullpath); } WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL, &addr_size_cells); static void check_obsolete_chosen_interrupt_controller(struct check *c, - struct node *dt, + struct dt_info *dti, struct node *node) { + struct node *dt = dti->dt; struct node *chosen; struct property *prop; @@ -673,12 +950,271 @@ prop = get_property(chosen, "interrupt-controller"); if (prop) - FAIL(c, "/chosen has obsolete \"interrupt-controller\" " + FAIL(c, dti, "/chosen has obsolete \"interrupt-controller\" " "property"); } WARNING(obsolete_chosen_interrupt_controller, check_obsolete_chosen_interrupt_controller, NULL); +struct provider { + const char *prop_name; + const char *cell_name; + bool optional; +}; + +static void check_property_phandle_args(struct check *c, + struct dt_info *dti, + struct node *node, + struct property *prop, + const struct provider *provider) +{ + struct node *root = dti->dt; + int cell, cellsize = 0; + + if (prop->val.len % sizeof(cell_t)) { + FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %ld in node %s", + prop->name, prop->val.len, sizeof(cell_t), node->fullpath); + return; + } + + for (cell = 0; cell < prop->val.len / sizeof(cell_t); cell += cellsize + 1) { + struct node *provider_node; + struct property *cellprop; + int phandle; + + phandle = propval_cell_n(prop, cell); + /* + * Some bindings use a cell value 0 or -1 to skip over optional + * entries when each index position has a specific definition. + */ + if (phandle == 0 || phandle == -1) { + cellsize = 0; + continue; + } + + /* If we have markers, verify the current cell is a phandle */ + if (prop->val.markers) { + struct marker *m = prop->val.markers; + for_each_marker_of_type(m, REF_PHANDLE) { + if (m->offset == (cell * sizeof(cell_t))) + break; + } + if (!m) + FAIL(c, dti, "Property '%s', cell %d is not a phandle reference in %s", + prop->name, cell, node->fullpath); + } + + provider_node = get_node_by_phandle(root, phandle); + if (!provider_node) { + FAIL(c, dti, "Could not get phandle node for %s:%s(cell %d)", + node->fullpath, prop->name, cell); + break; + } + + cellprop = get_property(provider_node, provider->cell_name); + if (cellprop) { + cellsize = propval_cell(cellprop); + } else if (provider->optional) { + cellsize = 0; + } else { + FAIL(c, dti, "Missing property '%s' in node %s or bad phandle (referred from %s:%s[%d])", + provider->cell_name, + provider_node->fullpath, + node->fullpath, prop->name, cell); + break; + } + + if (prop->val.len < ((cell + cellsize + 1) * sizeof(cell_t))) { + FAIL(c, dti, "%s property size (%d) too small for cell size %d in %s", + prop->name, prop->val.len, cellsize, node->fullpath); + } + } +} + +static void check_provider_cells_property(struct check *c, + struct dt_info *dti, + struct node *node) +{ + struct provider *provider = c->data; + struct property *prop; + + prop = get_property(node, provider->prop_name); + if (!prop) + return; + + check_property_phandle_args(c, dti, node, prop, provider); +} +#define WARNING_PROPERTY_PHANDLE_CELLS(nm, propname, cells_name, ...) \ + static struct provider nm##_provider = { (propname), (cells_name), __VA_ARGS__ }; \ + WARNING(nm##_property, check_provider_cells_property, &nm##_provider, &phandle_references); + +WARNING_PROPERTY_PHANDLE_CELLS(clocks, "clocks", "#clock-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(cooling_device, "cooling-device", "#cooling-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(dmas, "dmas", "#dma-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(hwlocks, "hwlocks", "#hwlock-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(interrupts_extended, "interrupts-extended", "#interrupt-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(io_channels, "io-channels", "#io-channel-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(iommus, "iommus", "#iommu-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(mboxes, "mboxes", "#mbox-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(msi_parent, "msi-parent", "#msi-cells", true); +WARNING_PROPERTY_PHANDLE_CELLS(mux_controls, "mux-controls", "#mux-control-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(phys, "phys", "#phy-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(power_domains, "power-domains", "#power-domain-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(pwms, "pwms", "#pwm-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(resets, "resets", "#reset-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(sound_dais, "sound-dais", "#sound-dai-cells"); +WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sensor-cells"); + +static bool prop_is_gpio(struct property *prop) +{ + char *str; + + /* + * *-gpios and *-gpio can appear in property names, + * so skip over any false matches (only one known ATM) + */ + if (strstr(prop->name, "nr-gpio")) + return false; + + str = strrchr(prop->name, '-'); + if (str) + str++; + else + str = prop->name; + if (!(streq(str, "gpios") || streq(str, "gpio"))) + return false; + + return true; +} + +static void check_gpios_property(struct check *c, + struct dt_info *dti, + struct node *node) +{ + struct property *prop; + + /* Skip GPIO hog nodes which have 'gpios' property */ + if (get_property(node, "gpio-hog")) + return; + + for_each_property(node, prop) { + struct provider provider; + + if (!prop_is_gpio(prop)) + continue; + + provider.prop_name = prop->name; + provider.cell_name = "#gpio-cells"; + provider.optional = false; + check_property_phandle_args(c, dti, node, prop, &provider); + } + +} +WARNING(gpios_property, check_gpios_property, NULL, &phandle_references); + +static void check_deprecated_gpio_property(struct check *c, + struct dt_info *dti, + struct node *node) +{ + struct property *prop; + + for_each_property(node, prop) { + char *str; + + if (!prop_is_gpio(prop)) + continue; + + str = strstr(prop->name, "gpio"); + if (!streq(str, "gpio")) + continue; + + FAIL(c, dti, "'[*-]gpio' is deprecated, use '[*-]gpios' instead for %s:%s", + node->fullpath, prop->name); + } + +} +CHECK(deprecated_gpio_property, check_deprecated_gpio_property, NULL); + +static bool node_is_interrupt_provider(struct node *node) +{ + struct property *prop; + + prop = get_property(node, "interrupt-controller"); + if (prop) + return true; + + prop = get_property(node, "interrupt-map"); + if (prop) + return true; + + return false; +} +static void check_interrupts_property(struct check *c, + struct dt_info *dti, + struct node *node) +{ + struct node *root = dti->dt; + struct node *irq_node = NULL, *parent = node; + struct property *irq_prop, *prop = NULL; + int irq_cells, phandle; + + irq_prop = get_property(node, "interrupts"); + if (!irq_prop) + return; + + if (irq_prop->val.len % sizeof(cell_t)) + FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %ld in node %s", + irq_prop->name, irq_prop->val.len, sizeof(cell_t), + node->fullpath); + + while (parent && !prop) { + if (parent != node && node_is_interrupt_provider(parent)) { + irq_node = parent; + break; + } + + prop = get_property(parent, "interrupt-parent"); + if (prop) { + phandle = propval_cell(prop); + irq_node = get_node_by_phandle(root, phandle); + if (!irq_node) { + FAIL(c, dti, "Bad interrupt-parent phandle for %s", + node->fullpath); + return; + } + if (!node_is_interrupt_provider(irq_node)) + FAIL(c, dti, + "Missing interrupt-controller or interrupt-map property in %s", + irq_node->fullpath); + + break; + } + + parent = parent->parent; + } + + if (!irq_node) { + FAIL(c, dti, "Missing interrupt-parent for %s", node->fullpath); + return; + } + + prop = get_property(irq_node, "#interrupt-cells"); + if (!prop) { + FAIL(c, dti, "Missing #interrupt-cells in interrupt-parent %s", + irq_node->fullpath); + return; + } + + irq_cells = propval_cell(prop); + if (irq_prop->val.len % (irq_cells * sizeof(cell_t))) { + FAIL(c, dti, + "interrupts size is (%d), expected multiple of %d in %s", + irq_prop->val.len, (int)(irq_cells * sizeof(cell_t)), + node->fullpath); + } +} +WARNING(interrupts_property, check_interrupts_property, &phandle_references); + static struct check *check_table[] = { &duplicate_node_names, &duplicate_property_names, &node_name_chars, &node_name_format, &property_name_chars, @@ -692,13 +1228,45 @@ &address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell, &device_type_is_string, &model_is_string, &status_is_string, + &property_name_chars_strict, + &node_name_chars_strict, + &addr_size_cells, ®_format, &ranges_format, &unit_address_vs_reg, + &unit_address_format, + + &pci_bridge, + &pci_device_reg, + &pci_device_bus_num, + + &simple_bus_bridge, + &simple_bus_reg, &avoid_default_addr_size, &obsolete_chosen_interrupt_controller, + &clocks_property, + &cooling_device_property, + &dmas_property, + &hwlocks_property, + &interrupts_extended_property, + &io_channels_property, + &iommus_property, + &mboxes_property, + &msi_parent_property, + &mux_controls_property, + &phys_property, + &power_domains_property, + &pwms_property, + &resets_property, + &sound_dais_property, + &thermal_sensors_property, + + &deprecated_gpio_property, + &gpios_property, + &interrupts_property, + &always_fail, }; @@ -763,9 +1331,8 @@ die("Unrecognized check name \"%s\"\n", name); } -void process_checks(bool force, struct boot_info *bi) +void process_checks(bool force, struct dt_info *dti) { - struct node *dt = bi->dt; int i; int error = 0; @@ -773,7 +1340,7 @@ struct check *c = check_table[i]; if (c->warn || c->error) - error = error || run_check(c, dt); + error = error || run_check(c, dti); } if (error) { diff -Nru device-tree-compiler-1.4.2/convert-dtsv0-lexer.l device-tree-compiler-1.4.5/convert-dtsv0-lexer.l --- device-tree-compiler-1.4.2/convert-dtsv0-lexer.l 2016-09-03 11:02:30.000000000 +0000 +++ device-tree-compiler-1.4.5/convert-dtsv0-lexer.l 2017-09-27 10:00:10.000000000 +0000 @@ -49,7 +49,7 @@ static unsigned long long last_val; static char *last_name; /* = NULL */ -const struct { +static const struct { const char *pattern; int obase, width; } guess_table[] = { diff -Nru device-tree-compiler-1.4.2/data.c device-tree-compiler-1.4.5/data.c --- device-tree-compiler-1.4.2/data.c 2016-09-03 11:02:30.000000000 +0000 +++ device-tree-compiler-1.4.5/data.c 2017-09-27 10:00:10.000000000 +0000 @@ -171,9 +171,9 @@ struct data data_append_integer(struct data d, uint64_t value, int bits) { uint8_t value_8; - uint16_t value_16; - uint32_t value_32; - uint64_t value_64; + fdt16_t value_16; + fdt32_t value_32; + fdt64_t value_64; switch (bits) { case 8: @@ -197,14 +197,14 @@ } } -struct data data_append_re(struct data d, const struct fdt_reserve_entry *re) +struct data data_append_re(struct data d, uint64_t address, uint64_t size) { - struct fdt_reserve_entry bere; + struct fdt_reserve_entry re; - bere.address = cpu_to_fdt64(re->address); - bere.size = cpu_to_fdt64(re->size); + re.address = cpu_to_fdt64(address); + re.size = cpu_to_fdt64(size); - return data_append_data(d, &bere, sizeof(bere)); + return data_append_data(d, &re, sizeof(re)); } struct data data_append_cell(struct data d, cell_t word) diff -Nru device-tree-compiler-1.4.2/debian/changelog device-tree-compiler-1.4.5/debian/changelog --- device-tree-compiler-1.4.2/debian/changelog 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/changelog 2017-11-01 13:26:36.000000000 +0000 @@ -1,8 +1,52 @@ -device-tree-compiler (1.4.2-1~cloud0) xenial-pike; urgency=medium +device-tree-compiler (1.4.5-3~cloud0) xenial-queens; urgency=medium - * New upstream release for the Ubuntu Cloud Archive. + * New update for the Ubuntu Cloud Archive. - -- Openstack Ubuntu Testing Bot Wed, 23 Aug 2017 20:57:42 +0000 + -- Openstack Ubuntu Testing Bot Wed, 01 Nov 2017 13:26:36 +0000 + +device-tree-compiler (1.4.5-3) unstable; urgency=medium + + * Add patch from upstream to fix bugs in testsuite for 32-bit arm. (Closes: #877797) + + -- Vagrant Cascadian Fri, 06 Oct 2017 11:51:12 -0700 + +device-tree-compiler (1.4.5-2) unstable; urgency=medium + + * Add patch from upstream to fix building on 32-bit systems. + + -- Vagrant Cascadian Thu, 28 Sep 2017 18:42:05 -0700 + +device-tree-compiler (1.4.5-1) unstable; urgency=medium + + * New upstream release + (Closes: #877033) + + -- Héctor Orón Martínez Fri, 29 Sep 2017 00:02:44 +0200 + +device-tree-compiler (1.4.4-1) unstable; urgency=medium + + * New upstream release: + - Add DT Overlay support, closes: #863174. + * Documentation: + - Only install .pdf of documentation paper, dropping .ps and .dvi + versions. + - Add documentation about dts format and dt objects. + * Add debian/watch file. + * Switch to source/format: 3.0 (quilt). + * Switch to dh and debhelper compat level 10. + * debian/rules: + - Enabled hardening. + - Ensure texlive generated documentation does not embed timestamps, + closes: #876657. + * debian/control: + - Set Priority to optional. + - Set Standards-Version to 4.1.0. + - Add Vagrant Cascadian to Uploaders. + - Use https:// URLs for Vcs-*. + * debian/copyright: + - Switch to copyright-format 1.0. + + -- Vagrant Cascadian Mon, 25 Sep 2017 09:10:56 -0700 device-tree-compiler (1.4.2-1) unstable; urgency=medium diff -Nru device-tree-compiler-1.4.2/debian/compat device-tree-compiler-1.4.5/debian/compat --- device-tree-compiler-1.4.2/debian/compat 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/compat 2017-10-06 17:35:17.000000000 +0000 @@ -1 +1 @@ -5 +10 diff -Nru device-tree-compiler-1.4.2/debian/control device-tree-compiler-1.4.5/debian/control --- device-tree-compiler-1.4.2/debian/control 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/control 2017-10-06 17:35:17.000000000 +0000 @@ -1,13 +1,13 @@ Source: device-tree-compiler Section: devel -Priority: extra +Priority: optional Maintainer: Héctor Orón Martínez -Uploaders: Riku Voipio -Standards-Version: 3.9.8 -Build-Depends: debhelper (>= 5), quilt, flex, bison, texlive, texlive-latex-extra +Uploaders: Riku Voipio , Vagrant Cascadian +Standards-Version: 4.1.0 +Build-Depends: debhelper (>= 10), flex, bison, texlive, texlive-latex-extra Homepage: https://git.kernel.org/cgit/utils/dtc/dtc.git -Vcs-Git: git://anonscm.debian.org/crosstoolchain/device-tree-compiler.git -Vcs-Browser: http://anonscm.debian.org/gitweb/?p=crosstoolchain/device-tree-compiler.git +Vcs-Git: https://anonscm.debian.org/git/crosstoolchain/device-tree-compiler.git +Vcs-Browser: https://anonscm.debian.org/cgit/crosstoolchain/device-tree-compiler.git/ Package: device-tree-compiler Architecture: any diff -Nru device-tree-compiler-1.4.2/debian/copyright device-tree-compiler-1.4.5/debian/copyright --- device-tree-compiler-1.4.2/debian/copyright 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/copyright 2017-10-06 17:35:17.000000000 +0000 @@ -1,65 +1,84 @@ -This package was debianized by Aurélien GÉRÔME on -Sat, 3 Mar 2007 23:13:14 +0100. +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: dtc +Source: https://git.kernel.org/cgit/utils/dtc/dtc.git + +Files: * +Copyright: + 2005-2008 David Gibson , IBM Corporation. + 2007-2008 Jon Loeliger, Freescale Semiconductor, Inc. + 2011 The Chromium OS Authors. + 2007 Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com +License: GPL-2+ + +Files: debian/* +Copyright: + 2007 Aurélien GÉRÔME +License: GPL-2+ + +Files: libfdt/* +Copyright: + 2006-2012 David Gibson, IBM Corporation. + 2012 Kim Phillips, Freescale Semiconductor. + 2014 David Gibson +License: GPL-2+ or BSD-2-clause + +Files: tests/* +Copyright: + 2006-2010 David Gibson , IBM Corporation. + 2011 The Chromium Authors. + 2012-2015 NVIDIA CORPORATION. + 2013 Google, Inc + 2014 David Gibson, + 2016 Free Electrons + 2016 Konsulko Inc. + 2016 NextThing Co. + 2008 Kumar Gala, Freescale Semiconductor, Inc. +License: LGPL-2.1+ + +Files: tests/dumptrees.c +Copyright: + David Gibson , IBM Corporation. 2006. +License: GPL-2+ + +License: GPL-2+ + This program is free software; you can redistribute it + and/or modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later + version. + . + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more + details. + . + You should have received a copy of the GNU General Public + License along with this package; if not, write to the Free + Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301 USA + . + On Debian systems, the full text of the GNU General Public + License version 2 can be found in the file + `/usr/share/common-licenses/GPL-2'. + +License: LGPL-2.1+ + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -It was checked out from . - -Upstream Authors: - - David Gibson - Jon Loeliger - -Copyright notices: - - Copyright 2005-2007 David Gibson, IBM Corporation. - Copyright 2007 Jon Loeliger, Freescale Semiconductor, Inc. - -Licenses: - - dtc code: - -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - - libfdt code: - -/* - * libfdt - Flat Device Tree manipulation - * - * libfdt is dual licensed: you can use it either under the terms of - * the GPL, or the BSD license, at your option. - * - * a) This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, - * MA 02110-1301 USA - * - * Alternatively, - * - * b) Redistribution and use in source and binary forms, with or +License: BSD-2-clause + * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * @@ -84,8 +103,3 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -The Debian packaging is (C) 2007, Aurélien GÉRÔME and -is licensed under the GPL, see `/usr/share/common-licenses/GPL'. diff -Nru device-tree-compiler-1.4.2/debian/device-tree-compiler.docs device-tree-compiler-1.4.5/debian/device-tree-compiler.docs --- device-tree-compiler-1.4.2/debian/device-tree-compiler.docs 1970-01-01 00:00:00.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/device-tree-compiler.docs 2017-10-06 17:35:17.000000000 +0000 @@ -0,0 +1,4 @@ +Documentation/dtc-paper.pdf +Documentation/dtc-manual.txt +Documentation/dt-object-internal.txt +Documentation/dts-format.txt diff -Nru device-tree-compiler-1.4.2/debian/device-tree-compiler.manpages device-tree-compiler-1.4.5/debian/device-tree-compiler.manpages --- device-tree-compiler-1.4.2/debian/device-tree-compiler.manpages 1970-01-01 00:00:00.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/device-tree-compiler.manpages 2017-10-06 17:35:17.000000000 +0000 @@ -0,0 +1 @@ +debian/manpages/*.1 diff -Nru device-tree-compiler-1.4.2/debian/dirs device-tree-compiler-1.4.5/debian/dirs --- device-tree-compiler-1.4.2/debian/dirs 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/dirs 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -usr/bin diff -Nru device-tree-compiler-1.4.2/debian/doc-base.dtc-paper device-tree-compiler-1.4.5/debian/doc-base.dtc-paper --- device-tree-compiler-1.4.2/debian/doc-base.dtc-paper 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/doc-base.dtc-paper 2017-10-06 17:35:17.000000000 +0000 @@ -7,9 +7,3 @@ Format: PDF Files: /usr/share/doc/device-tree-compiler/dtc-paper.pdf.gz - -Format: PostScript -Files: /usr/share/doc/device-tree-compiler/dtc-paper.ps.gz - -Format: DVI -Files: /usr/share/doc/device-tree-compiler/dtc-paper.dvi.gz diff -Nru device-tree-compiler-1.4.2/debian/patches/02-checks-Use-proper-format-modifier-for-size_t.patch device-tree-compiler-1.4.5/debian/patches/02-checks-Use-proper-format-modifier-for-size_t.patch --- device-tree-compiler-1.4.2/debian/patches/02-checks-Use-proper-format-modifier-for-size_t.patch 1970-01-01 00:00:00.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/02-checks-Use-proper-format-modifier-for-size_t.patch 2017-10-06 17:35:17.000000000 +0000 @@ -0,0 +1,41 @@ +From 497432fd2131967f349e69dc5d259072151cc4b4 Mon Sep 17 00:00:00 2001 +From: Thierry Reding +Date: Wed, 27 Sep 2017 15:04:09 +0200 +Subject: [PATCH 1/3] checks: Use proper format modifier for size_t + +The size of size_t can vary between architectures, so using %ld isn't +going to work on 32-bit builds. Use the %zu modifier to make sure it is +always correct. + +Signed-off-by: Thierry Reding +Acked-by: Rob Herring +Signed-off-by: David Gibson +--- + checks.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/checks.c b/checks.c +index 902f2e3..08a3a29 100644 +--- a/checks.c ++++ b/checks.c +@@ -972,7 +972,7 @@ static void check_property_phandle_args(struct check *c, + int cell, cellsize = 0; + + if (prop->val.len % sizeof(cell_t)) { +- FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %ld in node %s", ++ FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s", + prop->name, prop->val.len, sizeof(cell_t), node->fullpath); + return; + } +@@ -1163,7 +1163,7 @@ static void check_interrupts_property(struct check *c, + return; + + if (irq_prop->val.len % sizeof(cell_t)) +- FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %ld in node %s", ++ FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s", + irq_prop->name, irq_prop->val.len, sizeof(cell_t), + node->fullpath); + +-- +2.11.0 + diff -Nru device-tree-compiler-1.4.2/debian/patches/02_remove-unused-check-variable.patch device-tree-compiler-1.4.5/debian/patches/02_remove-unused-check-variable.patch --- device-tree-compiler-1.4.2/debian/patches/02_remove-unused-check-variable.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/02_remove-unused-check-variable.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -From: Josh Boyer -Date: Tue, 28 Jun 2011 12:47:09 +0000 (-0400) -Subject: dtc: Remove unused check variable -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=0a5aca98ba104ec4101322ccaf36da45064ad3ce - -dtc: Remove unused check variable - -Commit 376ab6f2 removed the old style check functionality from DTC, -however the check option and variable were not removed. This leads to -build failures when -Werror=unused-but-set-variable is specified: - - dtc.c: In function 'main': - dtc.c:102:17: error: variable 'check' set but not used [-Werror=unused-but-set-variable] - cc1: all warnings being treated as errors - make: *** [dtc.o] Error 1 - make: *** Waiting for unfinished jobs.... - -Remove the check variable. - -Signed-off-by: Josh Boyer -Acked-by: David Gibson ---- - -diff --git a/dtc.c b/dtc.c -index cbc0193..15d2fc2 100644 ---- a/dtc.c -+++ b/dtc.c -@@ -99,7 +99,7 @@ int main(int argc, char *argv[]) - const char *inform = "dts"; - const char *outform = "dts"; - const char *outname = "-"; -- int force = 0, check = 0, sort = 0; -+ int force = 0, sort = 0; - const char *arg; - int opt; - FILE *outf = NULL; -@@ -111,7 +111,7 @@ int main(int argc, char *argv[]) - minsize = 0; - padsize = 0; - -- while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:s")) != EOF) { -+ while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fqb:vH:s")) != EOF) { - switch (opt) { - case 'I': - inform = optarg; -@@ -137,9 +137,6 @@ int main(int argc, char *argv[]) - case 'f': - force = 1; - break; -- case 'c': -- check = 1; -- break; - case 'q': - quiet++; - break; diff -Nru device-tree-compiler-1.4.2/debian/patches/03_Remove-unused-variable-in-flat_read_mem_reserve.patch device-tree-compiler-1.4.5/debian/patches/03_Remove-unused-variable-in-flat_read_mem_reserve.patch --- device-tree-compiler-1.4.2/debian/patches/03_Remove-unused-variable-in-flat_read_mem_reserve.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/03_Remove-unused-variable-in-flat_read_mem_reserve.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -From: Josh Boyer -Date: Tue, 28 Jun 2011 13:47:11 +0000 (-0400) -Subject: dtc: Remove unused variable in flat_read_mem_reserve -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=d5b3165023b1cc3914e9943b91964ec9ad4be8b2 - -dtc: Remove unused variable in flat_read_mem_reserve - -The *p variable is declared and used to save inb->ptr, however p is -later never used. This has been the case since commit 6c0f3676 and can -lead to build failures with -Werror=unused-but-set-variable: - - flattree.c: In function 'flat_read_mem_reserve': - flattree.c:700:14: error: variable 'p' set but not used [-Werror=unused-but-set-variable] - cc1: all warnings being treated as errors - make: *** [flattree.o] Error 1 - -Remove the variable. - -Signed-off-by: Josh Boyer -Acked-by: David Gibson ---- - -diff --git a/flattree.c b/flattree.c -index ead0332..28d0b23 100644 ---- a/flattree.c -+++ b/flattree.c -@@ -697,7 +697,6 @@ static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb) - { - struct reserve_info *reservelist = NULL; - struct reserve_info *new; -- const char *p; - struct fdt_reserve_entry re; - - /* -@@ -706,7 +705,6 @@ static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb) - * - * First pass, count entries. - */ -- p = inb->ptr; - while (1) { - flat_read_chunk(inb, &re, sizeof(re)); - re.address = fdt64_to_cpu(re.address); diff -Nru device-tree-compiler-1.4.2/debian/patches/03-tests-Avoid-64-bit-arithmetic-in-assembler.patch device-tree-compiler-1.4.5/debian/patches/03-tests-Avoid-64-bit-arithmetic-in-assembler.patch --- device-tree-compiler-1.4.2/debian/patches/03-tests-Avoid-64-bit-arithmetic-in-assembler.patch 1970-01-01 00:00:00.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/03-tests-Avoid-64-bit-arithmetic-in-assembler.patch 2017-10-06 17:35:54.000000000 +0000 @@ -0,0 +1,138 @@ +From f8872e29ce06d78d3db71b3ab26a7465fc8a9586 Mon Sep 17 00:00:00 2001 +From: David Gibson +Date: Fri, 6 Oct 2017 23:07:30 +1100 +Subject: [PATCH] tests: Avoid 64-bit arithmetic in assembler + +For testing we (ab)use the assembler to build us a sample dtb, independent +of the other tools (dtc and libfdt) that we're trying to test. In a few +places this uses 64-bit arithmetic to decompose 64-bit constants into +the individual bytes in the blob. + +Unfortunately, it seems that some builds of GNU as don't support >32 bit +arithmetic, though it's not entirely clear to me which do and which don't +(Fedora i386 does support 64-bit, Debian arm32 doesn't). + +Anyway, to be safe, this avoids 64-bit arithmetic in assembler at the cost +of some extra awkwardness because we have to define the values in 32-bit +halves. + +Signed-off-by: David Gibson +--- + tests/testdata.h | 20 +++++++++++++++----- + tests/trees.S | 33 +++++++++++++-------------------- + 2 files changed, 28 insertions(+), 25 deletions(-) + +diff --git a/tests/testdata.h b/tests/testdata.h +index 3588778..f6bbe1d 100644 +--- a/tests/testdata.h ++++ b/tests/testdata.h +@@ -4,15 +4,25 @@ + #define ASM_CONST_LL(x) (x##ULL) + #endif + +-#define TEST_ADDR_1 ASM_CONST_LL(0xdeadbeef00000000) +-#define TEST_SIZE_1 ASM_CONST_LL(0x100000) +-#define TEST_ADDR_2 ASM_CONST_LL(123456789) +-#define TEST_SIZE_2 ASM_CONST_LL(010000) ++#define TEST_ADDR_1H ASM_CONST_LL(0xdeadbeef) ++#define TEST_ADDR_1L ASM_CONST_LL(0x00000000) ++#define TEST_ADDR_1 ((TEST_ADDR_1H << 32) | TEST_ADDR_1L) ++#define TEST_SIZE_1H ASM_CONST_LL(0x00000000) ++#define TEST_SIZE_1L ASM_CONST_LL(0x00100000) ++#define TEST_SIZE_1 ((TEST_SIZE_1H << 32) | TEST_SIZE_1L) ++#define TEST_ADDR_2H ASM_CONST_LL(0) ++#define TEST_ADDR_2L ASM_CONST_LL(123456789) ++#define TEST_ADDR_2 ((TEST_ADDR_2H << 32) | TEST_ADDR_2L) ++#define TEST_SIZE_2H ASM_CONST_LL(0) ++#define TEST_SIZE_2L ASM_CONST_LL(010000) ++#define TEST_SIZE_2 ((TEST_SIZE_2H << 32) | TEST_SIZE_2L) + + #define TEST_VALUE_1 0xdeadbeef + #define TEST_VALUE_2 123456789 + +-#define TEST_VALUE64_1 ASM_CONST_LL(0xdeadbeef01abcdef) ++#define TEST_VALUE64_1H ASM_CONST_LL(0xdeadbeef) ++#define TEST_VALUE64_1L ASM_CONST_LL(0x01abcdef) ++#define TEST_VALUE64_1 ((TEST_VALUE64_1H << 32) | TEST_VALUE64_1L) + + #define PHANDLE_1 0x2000 + #define PHANDLE_2 0x2001 +diff --git a/tests/trees.S b/tests/trees.S +index 9854d1d..9859914 100644 +--- a/tests/trees.S ++++ b/tests/trees.S +@@ -7,16 +7,6 @@ + .byte ((val) >> 8) & 0xff ; \ + .byte (val) & 0xff ; + +-#define FDTQUAD(val) \ +- .byte ((val) >> 56) & 0xff ; \ +- .byte ((val) >> 48) & 0xff ; \ +- .byte ((val) >> 40) & 0xff ; \ +- .byte ((val) >> 32) & 0xff ; \ +- .byte ((val) >> 24) & 0xff ; \ +- .byte ((val) >> 16) & 0xff ; \ +- .byte ((val) >> 8) & 0xff ; \ +- .byte (val) & 0xff ; +- + #define TREE_HDR(tree) \ + .balign 8 ; \ + .globl _##tree ; \ +@@ -33,14 +23,16 @@ tree: \ + FDTLONG(tree##_strings_end - tree##_strings) ; \ + FDTLONG(tree##_struct_end - tree##_struct) ; + +-#define RSVMAP_ENTRY(addr, len) \ +- FDTQUAD(addr) ; \ +- FDTQUAD(len) ; \ ++#define RSVMAP_ENTRY(addrh, addrl, lenh, lenl) \ ++ FDTLONG(addrh) ; \ ++ FDTLONG(addrl) ; \ ++ FDTLONG(lenh) ; \ ++ FDTLONG(lenl) + + #define EMPTY_RSVMAP(tree) \ + .balign 8 ; \ + tree##_rsvmap: ; \ +- RSVMAP_ENTRY(0, 0) \ ++ RSVMAP_ENTRY(0, 0, 0, 0) \ + tree##_rsvmap_end: ; + + #define PROPHDR(tree, name, len) \ +@@ -52,9 +44,10 @@ tree##_rsvmap_end: ; + PROPHDR(tree, name, 4) \ + FDTLONG(val) ; + +-#define PROP_INT64(tree, name, val) \ ++#define PROP_INT64(tree, name, valh, vall) \ + PROPHDR(tree, name, 8) \ +- FDTQUAD(val) ; ++ FDTLONG(valh) ; \ ++ FDTLONG(vall) ; + + #define PROP_STR(tree, name, str) \ + PROPHDR(tree, name, 55f - 54f) \ +@@ -81,16 +74,16 @@ tree##_##name: ; \ + + .balign 8 + test_tree1_rsvmap: +- RSVMAP_ENTRY(TEST_ADDR_1, TEST_SIZE_1) +- RSVMAP_ENTRY(TEST_ADDR_2, TEST_SIZE_2) +- RSVMAP_ENTRY(0, 0) ++ RSVMAP_ENTRY(TEST_ADDR_1H, TEST_ADDR_1L, TEST_SIZE_1H, TEST_SIZE_1L) ++ RSVMAP_ENTRY(TEST_ADDR_2H, TEST_ADDR_2L, TEST_SIZE_2H, TEST_SIZE_2L) ++ RSVMAP_ENTRY(0, 0, 0, 0) + test_tree1_rsvmap_end: + + test_tree1_struct: + BEGIN_NODE("") + PROP_STR(test_tree1, compatible, "test_tree1") + PROP_INT(test_tree1, prop_int, TEST_VALUE_1) +- PROP_INT64(test_tree1, prop_int64, TEST_VALUE64_1) ++ PROP_INT64(test_tree1, prop_int64, TEST_VALUE64_1H, TEST_VALUE64_1L) + PROP_STR(test_tree1, prop_str, TEST_STRING_1) + PROP_INT(test_tree1, address_cells, 1) + PROP_INT(test_tree1, size_cells, 0) +-- +2.11.0 + diff -Nru device-tree-compiler-1.4.2/debian/patches/04_Split-out-is_printable_string-into-util.patch device-tree-compiler-1.4.5/debian/patches/04_Split-out-is_printable_string-into-util.patch --- device-tree-compiler-1.4.2/debian/patches/04_Split-out-is_printable_string-into-util.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/04_Split-out-is_printable_string-into-util.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ -From: Simon Glass -Date: Tue, 5 Jul 2011 19:02:49 +0000 (-0700) -Subject: Split out is_printable_string() into util.c -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=492f9d5de7db74aeb3a905246c4efd7cb29227a8 - -Split out is_printable_string() into util.c - -This useful function is split out so it will be available to programs -other than ftdump. - -Signed-off-by: Simon Glass -Acked-by: David Gibson ---- - -diff --git a/Makefile.ftdump b/Makefile.ftdump -index b70905a..2744a18 100644 ---- a/Makefile.ftdump -+++ b/Makefile.ftdump -@@ -5,7 +5,8 @@ - # - - FTDUMP_SRCS = \ -- ftdump.c -+ ftdump.c \ -+ util.c - - FTDUMP_GEN_SRCS = - -diff --git a/ftdump.c b/ftdump.c -index bce6535..db932e3 100644 ---- a/ftdump.c -+++ b/ftdump.c -@@ -11,36 +11,14 @@ - #include - #include - -+#include "util.h" -+ - #define FTDUMP_BUF_SIZE 65536 - - #define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) - #define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) - #define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4))) - --static int is_printable_string(const void *data, int len) --{ -- const char *s = data; -- const char *ss; -- -- /* zero length is not */ -- if (len == 0) -- return 0; -- -- /* must terminate with zero */ -- if (s[len - 1] != '\0') -- return 0; -- -- ss = s; -- while (*s && isprint(*s)) -- s++; -- -- /* not zero, or not done yet */ -- if (*s != '\0' || (s + 1 - ss) < len) -- return 0; -- -- return 1; --} -- - static void print_data(const char *data, int len) - { - int i; -@@ -50,7 +28,7 @@ static void print_data(const char *data, int len) - if (len == 0) - return; - -- if (is_printable_string(data, len)) { -+ if (util_is_printable_string(data, len)) { - printf(" = \"%s\"", (const char *)data); - } else if ((len % 4) == 0) { - printf(" = <"); -diff --git a/util.c b/util.c -index d7ac27d..994436f 100644 ---- a/util.c -+++ b/util.c -@@ -1,6 +1,9 @@ - /* - * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. - * -+ * util_is_printable_string contributed by -+ * Pantelis Antoniou -+ * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the -@@ -17,6 +20,7 @@ - * USA - */ - -+#include - #include - #include - #include -@@ -57,3 +61,27 @@ char *join_path(const char *path, const char *name) - memcpy(str+lenp, name, lenn+1); - return str; - } -+ -+int util_is_printable_string(const void *data, int len) -+{ -+ const char *s = data; -+ const char *ss; -+ -+ /* zero length is not */ -+ if (len == 0) -+ return 0; -+ -+ /* must terminate with zero */ -+ if (s[len - 1] != '\0') -+ return 0; -+ -+ ss = s; -+ while (*s && isprint(*s)) -+ s++; -+ -+ /* not zero, or not done yet */ -+ if (*s != '\0' || (s + 1 - ss) < len) -+ return 0; -+ -+ return 1; -+} -diff --git a/util.h b/util.h -index 9cead84..cc68933 100644 ---- a/util.h -+++ b/util.h -@@ -1,6 +1,8 @@ - #ifndef _UTIL_H - #define _UTIL_H - -+#include -+ - /* - * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. - * -@@ -53,4 +55,13 @@ static inline void *xrealloc(void *p, size_t len) - extern char *xstrdup(const char *s); - extern char *join_path(const char *path, const char *name); - -+/** -+ * Check a string of a given length to see if it is all printable and -+ * has a valid terminator. -+ * -+ * @param data The string to check -+ * @param len The string length including terminator -+ * @return 1 if a valid printable string, 0 if not */ -+int util_is_printable_string(const void *data, int len); -+ - #endif /* _UTIL_H */ diff -Nru device-tree-compiler-1.4.2/debian/patches/05_Add-missing-tests-to-gitignore.patch device-tree-compiler-1.4.5/debian/patches/05_Add-missing-tests-to-gitignore.patch --- device-tree-compiler-1.4.2/debian/patches/05_Add-missing-tests-to-gitignore.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/05_Add-missing-tests-to-gitignore.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -From: Simon Glass -Date: Tue, 5 Jul 2011 19:02:52 +0000 (-0700) -Subject: Add missing tests to .gitignore -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=ed8fee1a649b5430afc9b551e3bb6746ebe32449 - -Add missing tests to .gitignore - -Signed-off-by: Simon Glass -Acked-by: David Gibson ---- - -diff --git a/tests/.gitignore b/tests/.gitignore -index c4e1205..f4e58b2 100644 ---- a/tests/.gitignore -+++ b/tests/.gitignore -@@ -45,3 +45,5 @@ - /sw_tree1 - /truncated_property - /value-labels -+/dtb_reverse -+/dtbs_equal_unordered diff -Nru device-tree-compiler-1.4.2/debian/patches/06_Refactor-character-literal-parsing-code.patch device-tree-compiler-1.4.5/debian/patches/06_Refactor-character-literal-parsing-code.patch --- device-tree-compiler-1.4.2/debian/patches/06_Refactor-character-literal-parsing-code.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/06_Refactor-character-literal-parsing-code.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,249 +0,0 @@ -From: Anton Staaf -Date: Fri, 9 Sep 2011 19:16:29 +0000 (-0700) -Subject: dtc: Refactor character literal parsing code -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=b43335a23854b2620140eda6cca2ffae59e8de23 - -dtc: Refactor character literal parsing code - -Move the parsing of hex, octal and escaped characters from data.c -to util.c where it can be used for character literal parsing within -strings as well as for stand alone C style character literals. - -Signed-off-by: Anton Staaf -Acked-by: David Gibson ---- - -diff --git a/data.c b/data.c -index fe555e8..b5f3066 100644 ---- a/data.c -+++ b/data.c -@@ -68,40 +68,6 @@ struct data data_copy_mem(const char *mem, int len) - return d; - } - --static char get_oct_char(const char *s, int *i) --{ -- char x[4]; -- char *endx; -- long val; -- -- x[3] = '\0'; -- strncpy(x, s + *i, 3); -- -- val = strtol(x, &endx, 8); -- -- assert(endx > x); -- -- (*i) += endx - x; -- return val; --} -- --static char get_hex_char(const char *s, int *i) --{ -- char x[3]; -- char *endx; -- long val; -- -- x[2] = '\0'; -- strncpy(x, s + *i, 2); -- -- val = strtol(x, &endx, 16); -- if (!(endx > x)) -- die("\\x used with no following hex digits\n"); -- -- (*i) += endx - x; -- return val; --} -- - struct data data_copy_escape_string(const char *s, int len) - { - int i = 0; -@@ -114,53 +80,10 @@ struct data data_copy_escape_string(const char *s, int len) - while (i < len) { - char c = s[i++]; - -- if (c != '\\') { -- q[d.len++] = c; -- continue; -- } -- -- c = s[i++]; -- assert(c); -- switch (c) { -- case 'a': -- q[d.len++] = '\a'; -- break; -- case 'b': -- q[d.len++] = '\b'; -- break; -- case 't': -- q[d.len++] = '\t'; -- break; -- case 'n': -- q[d.len++] = '\n'; -- break; -- case 'v': -- q[d.len++] = '\v'; -- break; -- case 'f': -- q[d.len++] = '\f'; -- break; -- case 'r': -- q[d.len++] = '\r'; -- break; -- case '0': -- case '1': -- case '2': -- case '3': -- case '4': -- case '5': -- case '6': -- case '7': -- i--; /* need to re-read the first digit as -- * part of the octal value */ -- q[d.len++] = get_oct_char(s, &i); -- break; -- case 'x': -- q[d.len++] = get_hex_char(s, &i); -- break; -- default: -- q[d.len++] = c; -- } -+ if (c == '\\') -+ c = get_escape_char(s, &i); -+ -+ q[d.len++] = c; - } - - q[d.len++] = '\0'; -diff --git a/util.c b/util.c -index 994436f..6d07292 100644 ---- a/util.c -+++ b/util.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - - #include "util.h" - -@@ -85,3 +86,101 @@ int util_is_printable_string(const void *data, int len) - - return 1; - } -+ -+/* -+ * Parse a octal encoded character starting at index i in string s. The -+ * resulting character will be returned and the index i will be updated to -+ * point at the character directly after the end of the encoding, this may be -+ * the '\0' terminator of the string. -+ */ -+static char get_oct_char(const char *s, int *i) -+{ -+ char x[4]; -+ char *endx; -+ long val; -+ -+ x[3] = '\0'; -+ strncpy(x, s + *i, 3); -+ -+ val = strtol(x, &endx, 8); -+ -+ assert(endx > x); -+ -+ (*i) += endx - x; -+ return val; -+} -+ -+/* -+ * Parse a hexadecimal encoded character starting at index i in string s. The -+ * resulting character will be returned and the index i will be updated to -+ * point at the character directly after the end of the encoding, this may be -+ * the '\0' terminator of the string. -+ */ -+static char get_hex_char(const char *s, int *i) -+{ -+ char x[3]; -+ char *endx; -+ long val; -+ -+ x[2] = '\0'; -+ strncpy(x, s + *i, 2); -+ -+ val = strtol(x, &endx, 16); -+ if (!(endx > x)) -+ die("\\x used with no following hex digits\n"); -+ -+ (*i) += endx - x; -+ return val; -+} -+ -+char get_escape_char(const char *s, int *i) -+{ -+ char c = s[*i]; -+ int j = *i + 1; -+ char val; -+ -+ assert(c); -+ switch (c) { -+ case 'a': -+ val = '\a'; -+ break; -+ case 'b': -+ val = '\b'; -+ break; -+ case 't': -+ val = '\t'; -+ break; -+ case 'n': -+ val = '\n'; -+ break; -+ case 'v': -+ val = '\v'; -+ break; -+ case 'f': -+ val = '\f'; -+ break; -+ case 'r': -+ val = '\r'; -+ break; -+ case '0': -+ case '1': -+ case '2': -+ case '3': -+ case '4': -+ case '5': -+ case '6': -+ case '7': -+ j--; /* need to re-read the first digit as -+ * part of the octal value */ -+ val = get_oct_char(s, &j); -+ break; -+ case 'x': -+ val = get_hex_char(s, &j); -+ break; -+ default: -+ val = c; -+ } -+ -+ (*i) = j; -+ return val; -+} -diff --git a/util.h b/util.h -index cc68933..f251480 100644 ---- a/util.h -+++ b/util.h -@@ -64,4 +64,12 @@ extern char *join_path(const char *path, const char *name); - * @return 1 if a valid printable string, 0 if not */ - int util_is_printable_string(const void *data, int len); - -+/* -+ * Parse an escaped character starting at index i in string s. The resulting -+ * character will be returned and the index i will be updated to point at the -+ * character directly after the end of the encoding, this may be the '\0' -+ * terminator of the string. -+ */ -+char get_escape_char(const char *s, int *i); -+ - #endif /* _UTIL_H */ diff -Nru device-tree-compiler-1.4.2/debian/patches/07_Remove-gcc-4.6-set-but-not-used-warnings.patch device-tree-compiler-1.4.5/debian/patches/07_Remove-gcc-4.6-set-but-not-used-warnings.patch --- device-tree-compiler-1.4.2/debian/patches/07_Remove-gcc-4.6-set-but-not-used-warnings.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/07_Remove-gcc-4.6-set-but-not-used-warnings.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -From: David Gibson -Date: Mon, 12 Sep 2011 01:18:43 +0000 (+1000) -Subject: dtc: Remove gcc 4.6 "set but not used" warnings -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=83df28bd39979b32a75656cac291c36dbd4e5497 - -dtc: Remove gcc 4.6 "set but not used" warnings - -A number of the dtc testcases trigger the new "variable set but not -used" warning from gcc 4.6. That is they have variables which are -assigned, but then never read after that point. - -In a couple of cases this is just because the variables aren't needed, -so this patch removes them. In subnode_offset.c, it's because one -pair of variables we clearly intended to test we don't actually test. -This patch also adds this missing check. - -This patch makes the testsuite compile clean with gcc 4.6. - -Signed-off-by: David Gibson ---- - -diff --git a/tests/notfound.c b/tests/notfound.c -index 38918ad..4d55b88 100644 ---- a/tests/notfound.c -+++ b/tests/notfound.c -@@ -37,27 +37,25 @@ static void check_error(const char *s, int err) - - int main(int argc, char *argv[]) - { -- const struct fdt_property *prop; - void *fdt; - int offset; - int subnode1_offset; -- const void *val; - int lenerr; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - -- prop = fdt_get_property(fdt, 0, "nonexistant-property", &lenerr); -+ fdt_get_property(fdt, 0, "nonexistant-property", &lenerr); - check_error("fdt_get_property(\"nonexistant-property\")", lenerr); - -- val = fdt_getprop(fdt, 0, "nonexistant-property", &lenerr); -+ fdt_getprop(fdt, 0, "nonexistant-property", &lenerr); - check_error("fdt_getprop(\"nonexistant-property\"", lenerr); - - subnode1_offset = fdt_subnode_offset(fdt, 0, "subnode@1"); - if (subnode1_offset < 0) - FAIL("Couldn't find subnode1: %s", fdt_strerror(subnode1_offset)); - -- val = fdt_getprop(fdt, subnode1_offset, "prop-str", &lenerr); -+ fdt_getprop(fdt, subnode1_offset, "prop-str", &lenerr); - check_error("fdt_getprop(\"prop-str\")", lenerr); - - offset = fdt_subnode_offset(fdt, 0, "nonexistant-subnode"); -diff --git a/tests/path_offset.c b/tests/path_offset.c -index bb092f1..d3e1f8e 100644 ---- a/tests/path_offset.c -+++ b/tests/path_offset.c -@@ -104,5 +104,9 @@ int main(int argc, char *argv[]) - FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)", - subsubnode2_offset, subsubnode2_offset_p); - -+ if (subsubnode2_offset2 != subsubnode2_offset2_p) -+ FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)", -+ subsubnode2_offset2, subsubnode2_offset2_p); -+ - PASS(); - } -diff --git a/tests/subnode_offset.c b/tests/subnode_offset.c -index b961070..e58c192 100644 ---- a/tests/subnode_offset.c -+++ b/tests/subnode_offset.c -@@ -60,7 +60,7 @@ int main(int argc, char *argv[]) - void *fdt; - int subnode1_offset, subnode2_offset; - int subsubnode1_offset, subsubnode2_offset, subsubnode2_offset2; -- int ss11_off, ss12_off, ss21_off, ss22_off; -+ int ss12_off, ss21_off; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); -@@ -85,7 +85,7 @@ int main(int argc, char *argv[]) - if (subsubnode2_offset != subsubnode2_offset2) - FAIL("Different offsets with and without unit address"); - -- ss11_off = check_subnode(fdt, subnode1_offset, "ss1"); -+ check_subnode(fdt, subnode1_offset, "ss1"); - ss21_off = fdt_subnode_offset(fdt, subnode2_offset, "ss1"); - if (ss21_off != -FDT_ERR_NOTFOUND) - FAIL("Incorrectly found ss1 in subnode2"); -@@ -93,7 +93,7 @@ int main(int argc, char *argv[]) - ss12_off = fdt_subnode_offset(fdt, subnode1_offset, "ss2"); - if (ss12_off != -FDT_ERR_NOTFOUND) - FAIL("Incorrectly found ss2 in subnode1"); -- ss22_off = check_subnode(fdt, subnode2_offset, "ss2"); -+ check_subnode(fdt, subnode2_offset, "ss2"); - - PASS(); - } diff -Nru device-tree-compiler-1.4.2/debian/patches/08_Support-character-literals-in-cell-lists.patch device-tree-compiler-1.4.5/debian/patches/08_Support-character-literals-in-cell-lists.patch --- device-tree-compiler-1.4.2/debian/patches/08_Support-character-literals-in-cell-lists.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/08_Support-character-literals-in-cell-lists.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,241 +0,0 @@ -From: Anton Staaf -Date: Fri, 9 Sep 2011 19:16:30 +0000 (-0700) -Subject: dtc: Support character literals in cell lists -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=a4ea2fa9518ff0f4d7f4a08647599a727faac2e0 - -dtc: Support character literals in cell lists - -With this patch the following property assignment: - - property = <0x12345678 'a' '\r' 100>; - -is equivalent to: - - property = <0x12345678 0x00000061 0x0000000D 0x00000064> - -Signed-off-by: Anton Staaf -Acked-by: David Gibson ---- - -diff --git a/Documentation/dts-format.txt b/Documentation/dts-format.txt -index a655b87..eae8b76 100644 ---- a/Documentation/dts-format.txt -+++ b/Documentation/dts-format.txt -@@ -33,7 +33,7 @@ Property values may be defined as an array of 32-bit integer cells, as - NUL-terminated strings, as bytestrings or a combination of these. - - * Arrays of cells are represented by angle brackets surrounding a -- space separated list of C-style integers -+ space separated list of C-style integers or character literals. - - e.g. interrupts = <17 0xc>; - -diff --git a/dtc-lexer.l b/dtc-lexer.l -index e866ea5..494e342 100644 ---- a/dtc-lexer.l -+++ b/dtc-lexer.l -@@ -29,6 +29,7 @@ PROPNODECHAR [a-zA-Z0-9,._+*#?@-] - PATHCHAR ({PROPNODECHAR}|[/]) - LABEL [a-zA-Z_][a-zA-Z0-9_]* - STRING \"([^\\"]|\\.)*\" -+CHAR_LITERAL '([^']|\\')*' - WS [[:space:]] - COMMENT "/*"([^*]|\*+[^*/])*\*+"/" - LINECOMMENT "//".*\n -@@ -109,6 +110,13 @@ static int pop_input_file(void); - return DT_LITERAL; - } - -+<*>{CHAR_LITERAL} { -+ yytext[yyleng-1] = '\0'; -+ yylval.literal = xstrdup(yytext+1); -+ DPRINT("Character literal: %s\n", yylval.literal); -+ return DT_CHAR_LITERAL; -+ } -+ - <*>\&{LABEL} { /* label reference */ - DPRINT("Ref: %s\n", yytext+1); - yylval.labelref = xstrdup(yytext+1); -diff --git a/dtc-parser.y b/dtc-parser.y -index 5e84a67..554f11a 100644 ---- a/dtc-parser.y -+++ b/dtc-parser.y -@@ -34,6 +34,7 @@ extern struct boot_info *the_boot_info; - extern int treesource_error; - - static unsigned long long eval_literal(const char *s, int base, int bits); -+static unsigned char eval_char_literal(const char *s); - %} - - %union { -@@ -57,6 +58,7 @@ static unsigned long long eval_literal(const char *s, int base, int bits); - %token DT_MEMRESERVE - %token DT_PROPNODENAME - %token DT_LITERAL -+%token DT_CHAR_LITERAL - %token DT_BASE - %token DT_BYTE - %token DT_STRING -@@ -265,6 +267,10 @@ cellval: - { - $$ = eval_literal($1, 0, 32); - } -+ | DT_CHAR_LITERAL -+ { -+ $$ = eval_char_literal($1); -+ } - ; - - bytestring: -@@ -343,3 +349,29 @@ static unsigned long long eval_literal(const char *s, int base, int bits) - print_error("bad literal"); - return val; - } -+ -+static unsigned char eval_char_literal(const char *s) -+{ -+ int i = 1; -+ char c = s[0]; -+ -+ if (c == '\0') -+ { -+ print_error("empty character literal"); -+ return 0; -+ } -+ -+ /* -+ * If the first character in the character literal is a \ then process -+ * the remaining characters as an escape encoding. If the first -+ * character is neither an escape or a terminator it should be the only -+ * character in the literal and will be returned. -+ */ -+ if (c == '\\') -+ c = get_escape_char(s, &i); -+ -+ if (s[i] != '\0') -+ print_error("malformed character literal"); -+ -+ return c; -+} -diff --git a/tests/.gitignore b/tests/.gitignore -index f4e58b2..a3e9bd1 100644 ---- a/tests/.gitignore -+++ b/tests/.gitignore -@@ -4,6 +4,7 @@ - /add_subnode_with_nops - /asm_tree_dump - /boot-cpuid -+/char_literal - /del_node - /del_property - /dtbs_equal_ordered -diff --git a/tests/Makefile.tests b/tests/Makefile.tests -index c564e72..e718b63 100644 ---- a/tests/Makefile.tests -+++ b/tests/Makefile.tests -@@ -5,6 +5,7 @@ LIB_TESTS_L = get_mem_rsv \ - node_offset_by_prop_value node_offset_by_phandle \ - node_check_compatible node_offset_by_compatible \ - get_alias \ -+ char_literal \ - notfound \ - setprop_inplace nop_property nop_node \ - sw_tree1 \ -diff --git a/tests/char_literal.c b/tests/char_literal.c -new file mode 100644 -index 0000000..150f2a0 ---- /dev/null -+++ b/tests/char_literal.c -@@ -0,0 +1,50 @@ -+/* -+ * libfdt - Flat Device Tree manipulation -+ * Testcase for character literals in dtc -+ * Copyright (C) 2006 David Gibson, IBM Corporation. -+ * Copyright (C) 2011 The Chromium Authors. All rights reserved. -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public License -+ * as published by the Free Software Foundation; either version 2.1 of -+ * the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+#include "tests.h" -+#include "testdata.h" -+ -+int main(int argc, char *argv[]) -+{ -+ void *fdt; -+ uint32_t expected_cells[5]; -+ -+ expected_cells[0] = cpu_to_fdt32((unsigned char)TEST_CHAR1); -+ expected_cells[1] = cpu_to_fdt32((unsigned char)TEST_CHAR2); -+ expected_cells[2] = cpu_to_fdt32((unsigned char)TEST_CHAR3); -+ expected_cells[3] = cpu_to_fdt32((unsigned char)TEST_CHAR4); -+ expected_cells[4] = cpu_to_fdt32((unsigned char)TEST_CHAR5); -+ -+ test_init(argc, argv); -+ fdt = load_blob_arg(argc, argv); -+ -+ check_getprop(fdt, 0, "char-literal-cells", -+ sizeof(expected_cells), expected_cells); -+ -+ PASS(); -+} -diff --git a/tests/char_literal.dts b/tests/char_literal.dts -new file mode 100644 -index 0000000..22e17ed ---- /dev/null -+++ b/tests/char_literal.dts -@@ -0,0 +1,5 @@ -+/dts-v1/; -+ -+/ { -+ char-literal-cells = <'\r' 'b' '\0' '\'' '\xff'>; -+}; -diff --git a/tests/run_tests.sh b/tests/run_tests.sh -index 72dda32..1246df1 100755 ---- a/tests/run_tests.sh -+++ b/tests/run_tests.sh -@@ -206,6 +206,9 @@ dtc_tests () { - run_dtc_test -I dts -O dtb -o dtc_escapes.test.dtb escapes.dts - run_test string_escapes dtc_escapes.test.dtb - -+ run_dtc_test -I dts -O dtb -o dtc_char_literal.test.dtb char_literal.dts -+ run_test char_literal dtc_char_literal.test.dtb -+ - run_dtc_test -I dts -O dtb -o dtc_extra-terminating-null.test.dtb extra-terminating-null.dts - run_test extra-terminating-null dtc_extra-terminating-null.test.dtb - -diff --git a/tests/testdata.h b/tests/testdata.h -index 5b5a9a3..d4c6759 100644 ---- a/tests/testdata.h -+++ b/tests/testdata.h -@@ -19,6 +19,12 @@ - #define TEST_STRING_2 "nastystring: \a\b\t\n\v\f\r\\\"" - #define TEST_STRING_3 "\xde\xad\xbe\xef" - -+#define TEST_CHAR1 '\r' -+#define TEST_CHAR2 'b' -+#define TEST_CHAR3 '\0' -+#define TEST_CHAR4 '\'' -+#define TEST_CHAR5 '\xff' -+ - #ifndef __ASSEMBLY__ - extern struct fdt_header _test_tree1; - extern struct fdt_header _truncated_property; diff -Nru device-tree-compiler-1.4.2/debian/patches/09_Create-Makefile_utils-and-move-ftdump-into-it.patch device-tree-compiler-1.4.5/debian/patches/09_Create-Makefile_utils-and-move-ftdump-into-it.patch --- device-tree-compiler-1.4.2/debian/patches/09_Create-Makefile_utils-and-move-ftdump-into-it.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/09_Create-Makefile_utils-and-move-ftdump-into-it.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -From: Simon Glass -Date: Wed, 21 Sep 2011 20:32:44 +0000 (-0700) -Subject: Create Makefile.utils and move ftdump into it -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=9ebd9b4a56e54656431111e5ea7cd74e651910bf - -Create Makefile.utils and move ftdump into it - -We want to avoid a separate Makefile include for each utility, so this sets -up a general one for utilities. - -Acked-by: David Gibson -Signed-off-by: Simon Glass ---- - -diff --git a/Makefile b/Makefile -index 2172d9a..380a705 100644 ---- a/Makefile -+++ b/Makefile -@@ -105,7 +105,7 @@ endef - - include Makefile.convert-dtsv0 - include Makefile.dtc --include Makefile.ftdump -+include Makefile.utils - - BIN += convert-dtsv0 - BIN += dtc -diff --git a/Makefile.ftdump b/Makefile.ftdump -deleted file mode 100644 -index 2744a18..0000000 ---- a/Makefile.ftdump -+++ /dev/null -@@ -1,13 +0,0 @@ --# --# This is not a complete Makefile of itself. --# Instead, it is designed to be easily embeddable --# into other systems of Makefiles. --# -- --FTDUMP_SRCS = \ -- ftdump.c \ -- util.c -- --FTDUMP_GEN_SRCS = -- --FTDUMP_OBJS = $(FTDUMP_SRCS:%.c=%.o) $(FTDUMP_GEN_SRCS:%.c=%.o) -diff --git a/Makefile.utils b/Makefile.utils -new file mode 100644 -index 0000000..0ed9297 ---- /dev/null -+++ b/Makefile.utils -@@ -0,0 +1,10 @@ -+# -+# This is not a complete Makefile of itself. Instead, it is designed to -+# be easily embeddable into other systems of Makefiles. -+# -+ -+FTDUMP_SRCS = \ -+ ftdump.c \ -+ util.c -+ -+FTDUMP_OBJS = $(FTDUMP_SRCS:%.c=%.o) diff -Nru device-tree-compiler-1.4.2/debian/patches/10_Add-fdt-read_write-utility-functions.patch device-tree-compiler-1.4.5/debian/patches/10_Add-fdt-read_write-utility-functions.patch --- device-tree-compiler-1.4.2/debian/patches/10_Add-fdt-read_write-utility-functions.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/10_Add-fdt-read_write-utility-functions.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,502 +0,0 @@ -From: Simon Glass -Date: Thu, 22 Sep 2011 17:11:02 +0000 (-0700) -Subject: Add fdt read/write utility functions -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=36204fdf742cabc074617648a5b2cf62409dc40b - -Add fdt read/write utility functions - -This adds higher-level libfdt operations for reading/writing an fdt -blob from/to a file, as well as a function to decode a data type string -as will be used by fdtget, fdtput. - -This also adds a few tests for the simple type argument supported by -utilfdt_decode_type. - -Signed-off-by: Simon Glass -Acked-by: David Gibson ---- - -diff --git a/Makefile b/Makefile -index 380a705..b32409b 100644 ---- a/Makefile -+++ b/Makefile -@@ -15,7 +15,7 @@ EXTRAVERSION = - LOCAL_VERSION = - CONFIG_LOCALVERSION = - --CPPFLAGS = -I libfdt -+CPPFLAGS = -I libfdt -I . - WARNINGS = -Werror -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \ - -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls - CFLAGS = -g -Os -fPIC -Werror $(WARNINGS) -diff --git a/tests/Makefile.tests b/tests/Makefile.tests -index e718b63..41695df 100644 ---- a/tests/Makefile.tests -+++ b/tests/Makefile.tests -@@ -16,7 +16,8 @@ LIB_TESTS_L = get_mem_rsv \ - extra-terminating-null \ - dtbs_equal_ordered \ - dtb_reverse dtbs_equal_unordered \ -- add_subnode_with_nops path_offset_aliases -+ add_subnode_with_nops path_offset_aliases \ -+ utilfdt_test - LIB_TESTS = $(LIB_TESTS_L:%=$(TESTS_PREFIX)%) - - LIBTREE_TESTS_L = truncated_property -@@ -42,7 +43,7 @@ TESTS_CLEANFILES = $(TESTS) $(TESTS_CLEANFILES_L:%=$(TESTS_PREFIX)%) - .PHONY: tests - tests: $(TESTS) $(TESTS_TREES) - --$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o $(LIBFDT_archive) -+$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_archive) - - $(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o $(LIBFDT_archive) - @$(VECHO) LD [libdl] $@ -diff --git a/tests/run_tests.sh b/tests/run_tests.sh -index 1246df1..e2c3046 100755 ---- a/tests/run_tests.sh -+++ b/tests/run_tests.sh -@@ -391,6 +391,10 @@ dtbs_equal_tests () { - cmp_tests test_tree1.dtb $WRONG_TREE1 - } - -+utilfdt_tests () { -+ run_test utilfdt_test -+} -+ - while getopts "vt:m" ARG ; do - case $ARG in - "v") -@@ -406,7 +410,7 @@ while getopts "vt:m" ARG ; do - done - - if [ -z "$TESTSETS" ]; then -- TESTSETS="libfdt dtc dtbs_equal" -+ TESTSETS="libfdt utilfdt dtc dtbs_equal" - fi - - # Make sure we don't have stale blobs lying around -@@ -417,6 +421,9 @@ for set in $TESTSETS; do - "libfdt") - libfdt_tests - ;; -+ "utilfdt") -+ utilfdt_tests -+ ;; - "dtc") - dtc_tests - ;; -diff --git a/tests/tests.h b/tests/tests.h -index fcb2b2a..a51556d 100644 ---- a/tests/tests.h -+++ b/tests/tests.h -@@ -93,22 +93,6 @@ void cleanup(void); - exit(RC_BUG); \ - } while (0) - --static inline void *xmalloc(size_t size) --{ -- void *p = malloc(size); -- if (! p) -- FAIL("malloc() failure"); -- return p; --} -- --static inline void *xrealloc(void *p, size_t size) --{ -- p = realloc(p, size); -- if (! p) -- FAIL("realloc() failure"); -- return p; --} -- - void check_mem_rsv(void *fdt, int n, uint64_t addr, uint64_t size); - - void check_property(void *fdt, int nodeoffset, const char *name, -@@ -135,4 +119,6 @@ void *load_blob_arg(int argc, char *argv[]); - void save_blob(const char *filename, void *blob); - void *open_blob_rw(void *blob); - -+#include "util.h" -+ - #endif /* _TESTS_H */ -diff --git a/tests/utilfdt_test.c b/tests/utilfdt_test.c -new file mode 100644 -index 0000000..36b4aa5 ---- /dev/null -+++ b/tests/utilfdt_test.c -@@ -0,0 +1,128 @@ -+/* -+ * Copyright 2011 The Chromium Authors, All Rights Reserved. -+ * -+ * utilfdt_test - Tests for utilfdt library -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public License -+ * as published by the Free Software Foundation; either version 2.1 of -+ * the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+ -+#include "tests.h" -+#include "testdata.h" -+ -+static void check(const char *fmt, int expect_type, int expect_size) -+{ -+ int type; -+ int size; -+ -+ if (utilfdt_decode_type(fmt, &type, &size)) -+ FAIL("format '%s': valid format string returned failure", fmt); -+ if (expect_type != type) -+ FAIL("format '%s': expected type='%c', got type='%c'", fmt, -+ expect_type, type); -+ if (expect_size != size) -+ FAIL("format '%s': expected size=%d, got size=%d", fmt, -+ expect_size, size); -+} -+ -+static void checkfail(const char *fmt) -+{ -+ int type; -+ int size; -+ -+ if (!utilfdt_decode_type(fmt, &type, &size)) -+ FAIL("format '%s': invalid format string returned success", -+ fmt); -+} -+ -+/** -+ * Add the given modifier to each of the valid sizes, and check that we get -+ * correct values. -+ * -+ * \param modifier Modifer string to use as a prefix -+ * \param expected_size The size (in bytes) that we expect (ignored for -+ * strings) -+ */ -+static void check_sizes(char *modifier, int expected_size) -+{ -+ char fmt[10], *ptr; -+ -+ /* set up a string with a hole in it for the format character */ -+ if (strlen(modifier) + 2 >= sizeof(fmt)) -+ FAIL("modifier string '%s' too long", modifier); -+ strcpy(fmt, modifier); -+ ptr = fmt + strlen(fmt); -+ ptr[1] = '\0'; -+ -+ /* now try each format character in turn */ -+ *ptr = 'i'; -+ check(fmt, 'i', expected_size); -+ -+ *ptr = 'u'; -+ check(fmt, 'u', expected_size); -+ -+ *ptr = 'x'; -+ check(fmt, 'x', expected_size); -+ -+ *ptr = 's'; -+ check(fmt, 's', -1); -+} -+ -+static void test_utilfdt_decode_type(void) -+{ -+ char fmt[10]; -+ int ch; -+ -+ /* check all the valid modifiers and sizes */ -+ check_sizes("", -1); -+ check_sizes("b", 1); -+ check_sizes("hh", 1); -+ check_sizes("h", 2); -+ check_sizes("l", 4); -+ -+ /* try every other character */ -+ checkfail(""); -+ for (ch = ' '; ch < 127; ch++) { -+ if (!strchr("iuxs", ch)) { -+ *fmt = ch; -+ fmt[1] = '\0'; -+ checkfail(fmt); -+ } -+ } -+ -+ /* try a few modifiers at the end */ -+ checkfail("sx"); -+ checkfail("ihh"); -+ checkfail("xb"); -+ -+ /* and one for the doomsday archives */ -+ checkfail("He has all the virtues I dislike and none of the vices " -+ "I admire."); -+} -+ -+int main(int argc, char *argv[]) -+{ -+ test_utilfdt_decode_type(); -+ PASS(); -+} -diff --git a/util.c b/util.c -index 6d07292..d82d41f 100644 ---- a/util.c -+++ b/util.c -@@ -1,4 +1,5 @@ - /* -+ * Copyright 2011 The Chromium Authors, All Rights Reserved. - * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. - * - * util_is_printable_string contributed by -@@ -27,6 +28,11 @@ - #include - #include - -+#include -+#include -+#include -+ -+#include "libfdt.h" - #include "util.h" - - char *xstrdup(const char *s) -@@ -184,3 +190,139 @@ char get_escape_char(const char *s, int *i) - (*i) = j; - return val; - } -+ -+int utilfdt_read_err(const char *filename, char **buffp) -+{ -+ int fd = 0; /* assume stdin */ -+ char *buf = NULL; -+ off_t bufsize = 1024, offset = 0; -+ int ret = 0; -+ -+ *buffp = NULL; -+ if (strcmp(filename, "-") != 0) { -+ fd = open(filename, O_RDONLY); -+ if (fd < 0) -+ return errno; -+ } -+ -+ /* Loop until we have read everything */ -+ buf = malloc(bufsize); -+ do { -+ /* Expand the buffer to hold the next chunk */ -+ if (offset == bufsize) { -+ bufsize *= 2; -+ buf = realloc(buf, bufsize); -+ if (!buf) { -+ ret = ENOMEM; -+ break; -+ } -+ } -+ -+ ret = read(fd, &buf[offset], bufsize - offset); -+ if (ret < 0) { -+ ret = errno; -+ break; -+ } -+ offset += ret; -+ } while (ret != 0); -+ -+ /* Clean up, including closing stdin; return errno on error */ -+ close(fd); -+ if (ret) -+ free(buf); -+ else -+ *buffp = buf; -+ return ret; -+} -+ -+char *utilfdt_read(const char *filename) -+{ -+ char *buff; -+ int ret = utilfdt_read_err(filename, &buff); -+ -+ if (ret) { -+ fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename, -+ strerror(ret)); -+ return NULL; -+ } -+ /* Successful read */ -+ return buff; -+} -+ -+int utilfdt_write_err(const char *filename, const void *blob) -+{ -+ int fd = 1; /* assume stdout */ -+ int totalsize; -+ int offset; -+ int ret = 0; -+ const char *ptr = blob; -+ -+ if (strcmp(filename, "-") != 0) { -+ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666); -+ if (fd < 0) -+ return errno; -+ } -+ -+ totalsize = fdt_totalsize(blob); -+ offset = 0; -+ -+ while (offset < totalsize) { -+ ret = write(fd, ptr + offset, totalsize - offset); -+ if (ret < 0) { -+ ret = -errno; -+ break; -+ } -+ offset += ret; -+ } -+ /* Close the file/stdin; return errno on error */ -+ if (fd != 1) -+ close(fd); -+ return ret < 0 ? -ret : 0; -+} -+ -+ -+int utilfdt_write(const char *filename, const void *blob) -+{ -+ int ret = utilfdt_write_err(filename, blob); -+ -+ if (ret) { -+ fprintf(stderr, "Couldn't write blob to '%s': %s\n", filename, -+ strerror(ret)); -+ } -+ return ret ? -1 : 0; -+} -+ -+int utilfdt_decode_type(const char *fmt, int *type, int *size) -+{ -+ int qualifier = 0; -+ -+ /* get the conversion qualifier */ -+ *size = -1; -+ if (strchr("hlLb", *fmt)) { -+ qualifier = *fmt++; -+ if (qualifier == *fmt) { -+ switch (*fmt++) { -+/* TODO: case 'l': qualifier = 'L'; break;*/ -+ case 'h': -+ qualifier = 'b'; -+ break; -+ } -+ } -+ } -+ -+ /* we should now have a type */ -+ if (!strchr("iuxs", *fmt)) -+ return -1; -+ -+ /* convert qualifier (bhL) to byte size */ -+ if (*fmt != 's') -+ *size = qualifier == 'b' ? 1 : -+ qualifier == 'h' ? 2 : -+ qualifier == 'l' ? 4 : -1; -+ *type = *fmt++; -+ -+ /* that should be it! */ -+ if (*fmt) -+ return -1; -+ return 0; -+} -diff --git a/util.h b/util.h -index f251480..730918e 100644 ---- a/util.h -+++ b/util.h -@@ -4,6 +4,7 @@ - #include - - /* -+ * Copyright 2011 The Chromium Authors, All Rights Reserved. - * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. - * - * This program is free software; you can redistribute it and/or -@@ -72,4 +73,71 @@ int util_is_printable_string(const void *data, int len); - */ - char get_escape_char(const char *s, int *i); - -+/** -+ * Read a device tree file into a buffer. This will report any errors on -+ * stderr. -+ * -+ * @param filename The filename to read, or - for stdin -+ * @return Pointer to allocated buffer containing fdt, or NULL on error -+ */ -+char *utilfdt_read(const char *filename); -+ -+/** -+ * Read a device tree file into a buffer. Does not report errors, but only -+ * returns them. The value returned can be passed to strerror() to obtain -+ * an error message for the user. -+ * -+ * @param filename The filename to read, or - for stdin -+ * @param buffp Returns pointer to buffer containing fdt -+ * @return 0 if ok, else an errno value representing the error -+ */ -+int utilfdt_read_err(const char *filename, char **buffp); -+ -+ -+/** -+ * Write a device tree buffer to a file. This will report any errors on -+ * stderr. -+ * -+ * @param filename The filename to write, or - for stdout -+ * @param blob Poiner to buffer containing fdt -+ * @return 0 if ok, -1 on error -+ */ -+int utilfdt_write(const char *filename, const void *blob); -+ -+/** -+ * Write a device tree buffer to a file. Does not report errors, but only -+ * returns them. The value returned can be passed to strerror() to obtain -+ * an error message for the user. -+ * -+ * @param filename The filename to write, or - for stdout -+ * @param blob Poiner to buffer containing fdt -+ * @return 0 if ok, else an errno value representing the error -+ */ -+int utilfdt_write_err(const char *filename, const void *blob); -+ -+/** -+ * Decode a data type string. The purpose of this string -+ * -+ * The string consists of an optional character followed by the type: -+ * Modifier characters: -+ * hh or b 1 byte -+ * h 2 byte -+ * l 4 byte, default -+ * -+ * Type character: -+ * s string -+ * i signed integer -+ * u unsigned integer -+ * x hex -+ * -+ * TODO: Implement ll modifier (8 bytes) -+ * TODO: Implement o type (octal) -+ * -+ * @param fmt Format string to process -+ * @param type Returns type found(s/d/u/x), or 0 if none -+ * @param size Returns size found(1,2,4,8) or 4 if none -+ * @return 0 if ok, -1 on error (no type given, or other invalid format) -+ */ -+int utilfdt_decode_type(const char *fmt, int *type, int *size); -+ - #endif /* _UTIL_H */ diff -Nru device-tree-compiler-1.4.2/debian/patches/11_Make-testutils-use-utilfdt.patch device-tree-compiler-1.4.5/debian/patches/11_Make-testutils-use-utilfdt.patch --- device-tree-compiler-1.4.2/debian/patches/11_Make-testutils-use-utilfdt.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/11_Make-testutils-use-utilfdt.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -From: Simon Glass -Date: Thu, 22 Sep 2011 17:11:03 +0000 (-0700) -Subject: Make testutils use utilfdt -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=1c25c0d520dee58bfd86626a07036fe9febfebe6 - -Make testutils use utilfdt - -The load_blob() and save_blob() functions are very similar to the utilfdt -versions. This removes the duplicated code. - -Signed-off-by: Simon Glass -Acked-by: David Gibson ---- - -diff --git a/tests/Makefile.tests b/tests/Makefile.tests -index 41695df..cae8390 100644 ---- a/tests/Makefile.tests -+++ b/tests/Makefile.tests -@@ -45,11 +45,12 @@ tests: $(TESTS) $(TESTS_TREES) - - $(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_archive) - --$(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o $(LIBFDT_archive) -+$(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_archive) - @$(VECHO) LD [libdl] $@ - $(LINK.c) -o $@ $^ -ldl - --$(LIBTREE_TESTS): %: $(TESTS_PREFIX)testutils.o $(TESTS_PREFIX)trees.o $(LIBFDT_archive) -+$(LIBTREE_TESTS): %: $(TESTS_PREFIX)testutils.o $(TESTS_PREFIX)trees.o \ -+ util.o $(LIBFDT_archive) - - $(TESTS_PREFIX)dumptrees: $(TESTS_PREFIX)trees.o - -diff --git a/tests/testutils.c b/tests/testutils.c -index b0a2230..f185133 100644 ---- a/tests/testutils.c -+++ b/tests/testutils.c -@@ -159,33 +159,13 @@ int nodename_eq(const char *s1, const char *s2) - - void *load_blob(const char *filename) - { -- int fd; -- int offset = 0; -- int bufsize = 1024; -- char *p = NULL; -- int ret; -- -- fd = open(filename, O_RDONLY); -- if (fd < 0) -- CONFIG("Couldn't open blob from \"%s\": %s", filename, -- strerror(errno)); -- -- p = xmalloc(bufsize); -- do { -- if (offset == bufsize) { -- bufsize *= 2; -- p = xrealloc(p, bufsize); -- } -- -- ret = read(fd, &p[offset], bufsize - offset); -- if (ret < 0) -- CONFIG("Couldn't read from \"%s\": %s", filename, -- strerror(errno)); -- -- offset += ret; -- } while (ret != 0); -+ char *blob; -+ int ret = utilfdt_read_err(filename, &blob); - -- return p; -+ if (ret) -+ CONFIG("Couldn't open blob from \"%s\": %s", filename, -+ strerror(ret)); -+ return blob; - } - - void *load_blob_arg(int argc, char *argv[]) -@@ -197,28 +177,11 @@ void *load_blob_arg(int argc, char *argv[]) - - void save_blob(const char *filename, void *fdt) - { -- int fd; -- int totalsize; -- int offset; -- char *p; -- int ret; -- -- fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666); -- if (fd < 0) -- CONFIG("Couldn't open \"%s\" to write blob: %s", filename, -- strerror(errno)); -- -- totalsize = fdt_totalsize(fdt); -- offset = 0; -- p = fdt; -- -- while (offset < totalsize) { -- ret = write(fd, p + offset, totalsize - offset); -- if (ret < 0) -- CONFIG("Couldn't write to \"%s\": %s", filename, -- strerror(errno)); -- offset += ret; -- } -+ int ret = utilfdt_write_err(filename, fdt); -+ -+ if (ret) -+ CONFIG("Couldn't write blob to \"%s\": %s", filename, -+ strerror(ret)); - } - - void *open_blob_rw(void *blob) diff -Nru device-tree-compiler-1.4.2/debian/patches/12_use-utilfdt-to-read-blob.patch device-tree-compiler-1.4.5/debian/patches/12_use-utilfdt-to-read-blob.patch --- device-tree-compiler-1.4.2/debian/patches/12_use-utilfdt-to-read-blob.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/12_use-utilfdt-to-read-blob.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -From: Simon Glass -Date: Thu, 22 Sep 2011 17:11:04 +0000 (-0700) -Subject: ftdump: use utilfdt to read blob -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=07a8691fbbeb2a7e0cff85fb24435e2dc71facaf - -ftdump: use utilfdt to read blob - -Now that we have utilfdt_read(), ftdump should use it too. - -Signed-off-by: Simon Glass -Acked-by: David Gibson ---- - -diff --git a/ftdump.c b/ftdump.c -index db932e3..cc55fe2 100644 ---- a/ftdump.c -+++ b/ftdump.c -@@ -13,8 +13,6 @@ - - #include "util.h" - --#define FTDUMP_BUF_SIZE 65536 -- - #define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) - #define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) - #define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4))) -@@ -147,40 +145,18 @@ static void dump_blob(void *blob) - - int main(int argc, char *argv[]) - { -- FILE *fp; - char *buf; -- int size; - - if (argc < 2) { - fprintf(stderr, "supply input filename\n"); - return 5; - } - -- if (strcmp(argv[1], "-") == 0) { -- fp = stdin; -- } else { -- fp = fopen(argv[1], "rb"); -- if (fp == NULL) { -- fprintf(stderr, "unable to open %s\n", argv[1]); -- return 10; -- } -- } -- -- buf = malloc(FTDUMP_BUF_SIZE); -- if (!buf) { -- fprintf(stderr, "Couldn't allocate %d byte buffer\n", FTDUMP_BUF_SIZE); -+ buf = utilfdt_read(argv[1]); -+ if (buf) -+ dump_blob(buf); -+ else - return 10; -- } -- -- size = fread(buf, 1, FTDUMP_BUF_SIZE, fp); -- if (size == FTDUMP_BUF_SIZE) { -- fprintf(stderr, "file too large (maximum is %d bytes)\n", FTDUMP_BUF_SIZE); -- return 10; -- } -- -- dump_blob(buf); -- -- fclose(fp); - - return 0; - } diff -Nru device-tree-compiler-1.4.2/debian/patches/13_Add-fdt16_to_cpu-utility-function.patch device-tree-compiler-1.4.5/debian/patches/13_Add-fdt16_to_cpu-utility-function.patch --- device-tree-compiler-1.4.2/debian/patches/13_Add-fdt16_to_cpu-utility-function.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/13_Add-fdt16_to_cpu-utility-function.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -From: Anton Staaf -Date: Tue, 11 Oct 2011 17:22:27 +0000 (-0700) -Subject: libfdt: Add fdt16_to_cpu utility function -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=2cd4c8d27d6b5ea83723754da4eba5d51aa71b95 - -libfdt: Add fdt16_to_cpu utility function - -This utility routine will be used in the variable size cell literal -append code. It is a straightforward adaptation of the fdt32_to_cpu -function. - -Signed-off-by: Anton Staaf -Acked-by: David Gibson ---- - -diff --git a/libfdt/libfdt_env.h b/libfdt/libfdt_env.h -index 449bf60..da952e7 100644 ---- a/libfdt/libfdt_env.h -+++ b/libfdt/libfdt_env.h -@@ -6,6 +6,12 @@ - #include - - #define _B(n) ((unsigned long long)((uint8_t *)&x)[n]) -+static inline uint16_t fdt16_to_cpu(uint16_t x) -+{ -+ return (_B(0) << 8) | _B(1); -+} -+#define cpu_to_fdt16(x) fdt16_to_cpu(x) -+ - static inline uint32_t fdt32_to_cpu(uint32_t x) - { - return (_B(0) << 24) | (_B(1) << 16) | (_B(2) << 8) | _B(3); diff -Nru device-tree-compiler-1.4.2/debian/patches/14_Add-data_append_integer-function.patch device-tree-compiler-1.4.5/debian/patches/14_Add-data_append_integer-function.patch --- device-tree-compiler-1.4.2/debian/patches/14_Add-data_append_integer-function.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/14_Add-data_append_integer-function.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -From: Anton Staaf -Date: Tue, 11 Oct 2011 17:22:28 +0000 (-0700) -Subject: dtc: Add data_append_integer function -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=a4b515c03804dbc0eff5bbf281bd22438717e773 - -dtc: Add data_append_integer function - -This function deals with appending integers of various sizes (8, 16 -32, and 64 bit currently). It handles endianess conversions. If the -integer will not fit in the requested number of bits of storage it -will have it's high bits ignored. - -This patch also rewrites data_append_cell and data_append_addr to use -data_append_integer. - -Signed-off-by: Anton Staaf -Acked-by: David Gibson ---- - -diff --git a/data.c b/data.c -index b5f3066..4a40c5b 100644 ---- a/data.c -+++ b/data.c -@@ -168,11 +168,33 @@ struct data data_merge(struct data d1, struct data d2) - return d; - } - --struct data data_append_cell(struct data d, cell_t word) -+struct data data_append_integer(struct data d, uint64_t value, int bits) - { -- cell_t beword = cpu_to_fdt32(word); -- -- return data_append_data(d, &beword, sizeof(beword)); -+ uint8_t value_8; -+ uint16_t value_16; -+ uint32_t value_32; -+ uint64_t value_64; -+ -+ switch (bits) { -+ case 8: -+ value_8 = value; -+ return data_append_data(d, &value_8, 1); -+ -+ case 16: -+ value_16 = cpu_to_fdt16(value); -+ return data_append_data(d, &value_16, 2); -+ -+ case 32: -+ value_32 = cpu_to_fdt32(value); -+ return data_append_data(d, &value_32, 4); -+ -+ case 64: -+ value_64 = cpu_to_fdt64(value); -+ return data_append_data(d, &value_64, 8); -+ -+ default: -+ die("Invalid literal size (%d)\n", bits); -+ } - } - - struct data data_append_re(struct data d, const struct fdt_reserve_entry *re) -@@ -185,11 +207,14 @@ struct data data_append_re(struct data d, const struct fdt_reserve_entry *re) - return data_append_data(d, &bere, sizeof(bere)); - } - --struct data data_append_addr(struct data d, uint64_t addr) -+struct data data_append_cell(struct data d, cell_t word) - { -- uint64_t beaddr = cpu_to_fdt64(addr); -+ return data_append_integer(d, word, sizeof(word) * 8); -+} - -- return data_append_data(d, &beaddr, sizeof(beaddr)); -+struct data data_append_addr(struct data d, uint64_t addr) -+{ -+ return data_append_integer(d, addr, sizeof(addr) * 8); - } - - struct data data_append_byte(struct data d, uint8_t byte) -diff --git a/dtc.h b/dtc.h -index f37c97e..7b4c65b 100644 ---- a/dtc.h -+++ b/dtc.h -@@ -109,6 +109,7 @@ struct data data_insert_at_marker(struct data d, struct marker *m, - const void *p, int len); - struct data data_merge(struct data d1, struct data d2); - struct data data_append_cell(struct data d, cell_t word); -+struct data data_append_integer(struct data d, uint64_t word, int bits); - struct data data_append_re(struct data d, const struct fdt_reserve_entry *re); - struct data data_append_addr(struct data d, uint64_t addr); - struct data data_append_byte(struct data d, uint8_t byte); diff -Nru device-tree-compiler-1.4.2/debian/patches/15_Add-support-for-variable-sized-elements.patch device-tree-compiler-1.4.5/debian/patches/15_Add-support-for-variable-sized-elements.patch --- device-tree-compiler-1.4.2/debian/patches/15_Add-support-for-variable-sized-elements.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/15_Add-support-for-variable-sized-elements.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,400 +0,0 @@ -From: Anton Staaf -Date: Tue, 11 Oct 2011 17:22:29 +0000 (-0700) -Subject: dtc: Add support for variable sized elements -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=033089f29099bdfd5c2d6986cdb9fd07b16cfde0 - -dtc: Add support for variable sized elements - -Elements of size 8, 16, 32, and 64 bits are supported. The new -/bits/ syntax was selected so as to not pollute the reserved -keyword space with uint8/uint16/... type names. - -With this patch the following property assignment: - - property = /bits/ 16 <0x1234 0x5678 0x0 0xffff>; - -is equivalent to: - - property = <0x12345678 0x0000ffff>; - -It is now also possible to directly specify a 64 bit literal in a -cell list, also known as an array using: - - property = /bits/ 64 <0xdeadbeef00000000>; - -It is an error to attempt to store a literal into an element that is -too small to hold the literal, and the compiler will generate an -error when it detects this. For instance: - - property = /bits/ 8 <256>; - -Will fail to compile. It is also an error to attempt to place a -reference in a non 32-bit element. - -The documentation has been changed to reflect that the cell list -is now an array of elements that can be of sizes other than the -default 32-bit cell size. - -The sized_cells test tests the creation and access of 8, 16, 32, -and 64-bit sized elements. It also tests that the creation of two -properties, one with 16 bit elements and one with 32 bit elements -result in the same property contents. - -Signed-off-by: Anton Staaf -Acked-by: David Gibson ---- - -diff --git a/Documentation/dts-format.txt b/Documentation/dts-format.txt -index eae8b76..41741df 100644 ---- a/Documentation/dts-format.txt -+++ b/Documentation/dts-format.txt -@@ -29,18 +29,28 @@ except for properties with empty (zero length) value which have the - form: - [label:] property-name; - --Property values may be defined as an array of 32-bit integer cells, as --NUL-terminated strings, as bytestrings or a combination of these. -+Property values may be defined as an array of 8, 16, 32, or 64-bit integer -+elements, as NUL-terminated strings, as bytestrings or a combination of these. - --* Arrays of cells are represented by angle brackets surrounding a -- space separated list of C-style integers or character literals. -+* Arrays are represented by angle brackets surrounding a space separated list -+ of C-style integers or character literals. Array elements default to 32-bits -+ in size. An array of 32-bit elements is also known as a cell list or a list -+ of cells. A cell being an unsigned 32-bit integer. - - e.g. interrupts = <17 0xc>; - --* A 64-bit value is represented with two 32-bit cells. -+* A 64-bit value can be represented with two 32-bit elements. - - e.g. clock-frequency = <0x00000001 0x00000000>; - -+* The storage size of an element can be changed using the /bits/ prefix. The -+ /bits/ prefix allows for the creation of 8, 16, 32, and 64-bit elements. -+ The resulting array will not be padded to a multiple of the default 32-bit -+ element size. -+ -+ e.g. interrupts = /bits/ 8 <17 0xc>; -+ e.g. clock-frequency = /bits/ 64 <0x0000000100000000>; -+ - * A NUL-terminated string value is represented using double quotes - (the property value is considered to include the terminating NUL - character). -@@ -59,19 +69,20 @@ NUL-terminated strings, as bytestrings or a combination of these. - e.g. compatible = "ns16550", "ns8250"; - example = <0xf00f0000 19>, "a strange property format"; - --* In a cell array a reference to another node will be expanded to that -- node's phandle. References may by '&' followed by a node's label: -+* In an array a reference to another node will be expanded to that node's -+ phandle. References may by '&' followed by a node's label: - e.g. interrupt-parent = < &mpic >; - or they may be '&' followed by a node's full path in braces: - e.g. interrupt-parent = < &{/soc/interrupt-controller@40000} >; -+ References are only permitted in arrays that have an element size of -+ 32-bits. - --* Outside a cell array, a reference to another node will be expanded -- to that node's full path. -+* Outside an array, a reference to another node will be expanded to that -+ node's full path. - e.g. ethernet0 = &EMAC0; - - * Labels may also appear before or after any component of a property -- value, or between cells of a cell array, or between bytes of a -- bytestring. -+ value, or between elements of an array, or between bytes of a bytestring. - e.g. reg = reglabel: <0 sizelabel: 0x1000000>; - e.g. prop = [ab cd ef byte4: 00 ff fe]; - e.g. str = start: "string value" end: ; -@@ -108,3 +119,4 @@ Version 1 DTS files have the overall layout: - - -- David Gibson - -- Yoder Stuart -+ -- Anton Staaf -diff --git a/dtc-lexer.l b/dtc-lexer.l -index 494e342..73d190c 100644 ---- a/dtc-lexer.l -+++ b/dtc-lexer.l -@@ -97,6 +97,12 @@ static int pop_input_file(void); - return DT_MEMRESERVE; - } - -+<*>"/bits/" { -+ DPRINT("Keyword: /bits/\n"); -+ BEGIN_DEFAULT(); -+ return DT_BITS; -+ } -+ - <*>{LABEL}: { - DPRINT("Label: %s\n", yytext); - yylval.labelref = xstrdup(yytext); -diff --git a/dtc-parser.y b/dtc-parser.y -index 554f11a..348616b 100644 ---- a/dtc-parser.y -+++ b/dtc-parser.y -@@ -45,8 +45,12 @@ static unsigned char eval_char_literal(const char *s); - uint8_t byte; - struct data data; - -+ struct { -+ struct data data; -+ int bits; -+ } array; -+ - uint64_t addr; -- cell_t cell; - struct property *prop; - struct property *proplist; - struct node *node; -@@ -56,6 +60,7 @@ static unsigned char eval_char_literal(const char *s); - - %token DT_V1 - %token DT_MEMRESERVE -+%token DT_BITS - %token DT_PROPNODENAME - %token DT_LITERAL - %token DT_CHAR_LITERAL -@@ -71,8 +76,7 @@ static unsigned char eval_char_literal(const char *s); - %type memreserve - %type memreserves - %type addr --%type celllist --%type cellval -+%type arrayprefix - %type bytestring - %type propdef - %type proplist -@@ -182,9 +186,9 @@ propdata: - { - $$ = data_merge($1, $2); - } -- | propdataprefix '<' celllist '>' -+ | propdataprefix arrayprefix '>' - { -- $$ = data_merge($1, $3); -+ $$ = data_merge($1, $2.data); - } - | propdataprefix '[' bytestring ']' - { -@@ -242,34 +246,56 @@ propdataprefix: - } - ; - --celllist: -- /* empty */ -+arrayprefix: -+ DT_BITS DT_LITERAL '<' - { -- $$ = empty_data; -+ $$.data = empty_data; -+ $$.bits = eval_literal($2, 0, 7); -+ -+ if (($$.bits != 8) && -+ ($$.bits != 16) && -+ ($$.bits != 32) && -+ ($$.bits != 64)) -+ { -+ print_error("Only 8, 16, 32 and 64-bit elements" -+ " are currently supported"); -+ $$.bits = 32; -+ } - } -- | celllist cellval -+ | '<' - { -- $$ = data_append_cell($1, $2); -+ $$.data = empty_data; -+ $$.bits = 32; - } -- | celllist DT_REF -+ | arrayprefix DT_LITERAL - { -- $$ = data_append_cell(data_add_marker($1, REF_PHANDLE, -- $2), -1); -+ uint64_t val = eval_literal($2, 0, $1.bits); -+ -+ $$.data = data_append_integer($1.data, val, $1.bits); - } -- | celllist DT_LABEL -+ | arrayprefix DT_CHAR_LITERAL - { -- $$ = data_add_marker($1, LABEL, $2); -- } -- ; -+ uint64_t val = eval_char_literal($2); - --cellval: -- DT_LITERAL -+ $$.data = data_append_integer($1.data, val, $1.bits); -+ } -+ | arrayprefix DT_REF - { -- $$ = eval_literal($1, 0, 32); -+ uint64_t val = ~0ULL >> (64 - $1.bits); -+ -+ if ($1.bits == 32) -+ $1.data = data_add_marker($1.data, -+ REF_PHANDLE, -+ $2); -+ else -+ print_error("References are only allowed in " -+ "arrays with 32-bit elements."); -+ -+ $$.data = data_append_integer($1.data, val, $1.bits); - } -- | DT_CHAR_LITERAL -+ | arrayprefix DT_LABEL - { -- $$ = eval_char_literal($1); -+ $$.data = data_add_marker($1.data, LABEL, $2); - } - ; - -diff --git a/tests/.gitignore b/tests/.gitignore -index a3e9bd1..9e062c3 100644 ---- a/tests/.gitignore -+++ b/tests/.gitignore -@@ -40,6 +40,7 @@ - /set_name - /setprop - /setprop_inplace -+/sized_cells - /string_escapes - /subnode_offset - /supernode_atdepth_offset -diff --git a/tests/Makefile.tests b/tests/Makefile.tests -index cae8390..215a8c5 100644 ---- a/tests/Makefile.tests -+++ b/tests/Makefile.tests -@@ -6,6 +6,7 @@ LIB_TESTS_L = get_mem_rsv \ - node_check_compatible node_offset_by_compatible \ - get_alias \ - char_literal \ -+ sized_cells \ - notfound \ - setprop_inplace nop_property nop_node \ - sw_tree1 \ -diff --git a/tests/run_tests.sh b/tests/run_tests.sh -index e2c3046..da6f970 100755 ---- a/tests/run_tests.sh -+++ b/tests/run_tests.sh -@@ -209,6 +209,9 @@ dtc_tests () { - run_dtc_test -I dts -O dtb -o dtc_char_literal.test.dtb char_literal.dts - run_test char_literal dtc_char_literal.test.dtb - -+ run_dtc_test -I dts -O dtb -o dtc_sized_cells.test.dtb sized_cells.dts -+ run_test sized_cells dtc_sized_cells.test.dtb -+ - run_dtc_test -I dts -O dtb -o dtc_extra-terminating-null.test.dtb extra-terminating-null.dts - run_test extra-terminating-null dtc_extra-terminating-null.test.dtb - -diff --git a/tests/sized_cells.c b/tests/sized_cells.c -new file mode 100644 -index 0000000..847ec96 ---- /dev/null -+++ b/tests/sized_cells.c -@@ -0,0 +1,84 @@ -+/* -+ * libfdt - Flat Device Tree manipulation -+ * Testcase for variable sized cells in dtc -+ * Copyright (C) 2006 David Gibson, IBM Corporation. -+ * Copyright (C) 2011 The Chromium Authors. All rights reserved. -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public License -+ * as published by the Free Software Foundation; either version 2.1 of -+ * the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+#include "tests.h" -+#include "testdata.h" -+ -+static void check_compare_properties(void *fdt, -+ char const *name_one, -+ char const *name_two) -+{ -+ const void *propval; -+ int proplen; -+ -+ propval = fdt_getprop(fdt, 0, name_one, &proplen); -+ -+ if (!propval) -+ FAIL("fdt_getprop(\"%s\"): %s", -+ name_one, -+ fdt_strerror(proplen)); -+ -+ check_getprop(fdt, 0, name_two, proplen, propval); -+} -+ -+int main(int argc, char *argv[]) -+{ -+ void *fdt; -+ uint8_t expected_8[6] = {TEST_CHAR1, -+ TEST_CHAR2, -+ TEST_CHAR3, -+ TEST_CHAR4, -+ TEST_CHAR5, -+ TEST_VALUE_1 >> 24}; -+ uint16_t expected_16[6]; -+ uint32_t expected_32[6]; -+ uint64_t expected_64[6]; -+ int i; -+ -+ for (i = 0; i < 5; ++i) { -+ expected_16[i] = cpu_to_fdt16(expected_8[i]); -+ expected_32[i] = cpu_to_fdt32(expected_8[i]); -+ expected_64[i] = cpu_to_fdt64(expected_8[i]); -+ } -+ -+ expected_16[5] = cpu_to_fdt16(TEST_VALUE_1 >> 16); -+ expected_32[5] = cpu_to_fdt32(TEST_VALUE_1); -+ expected_64[5] = cpu_to_fdt64(TEST_ADDR_1); -+ -+ test_init(argc, argv); -+ fdt = load_blob_arg(argc, argv); -+ -+ check_getprop(fdt, 0, "cells-8b", sizeof(expected_8), expected_8); -+ check_getprop(fdt, 0, "cells-16b", sizeof(expected_16), expected_16); -+ check_getprop(fdt, 0, "cells-32b", sizeof(expected_32), expected_32); -+ check_getprop(fdt, 0, "cells-64b", sizeof(expected_64), expected_64); -+ -+ check_compare_properties(fdt, "cells-one-16b", "cells-one-32b"); -+ -+ PASS(); -+} -diff --git a/tests/sized_cells.dts b/tests/sized_cells.dts -new file mode 100644 -index 0000000..efea9f5 ---- /dev/null -+++ b/tests/sized_cells.dts -@@ -0,0 +1,11 @@ -+/dts-v1/; -+ -+/ { -+ cells-8b = /bits/ 8 <'\r' 'b' '\0' '\'' '\xff' 0xde>; -+ cells-16b = /bits/ 16 <'\r' 'b' '\0' '\'' '\xff' 0xdead>; -+ cells-32b = /bits/ 32 <'\r' 'b' '\0' '\'' '\xff' 0xdeadbeef>; -+ cells-64b = /bits/ 64 <'\r' 'b' '\0' '\'' '\xff' 0xdeadbeef00000000>; -+ -+ cells-one-16b = /bits/ 16 <0x1234 0x5678 0x0 0xffff>; -+ cells-one-32b = <0x12345678 0x0000ffff>; -+}; diff -Nru device-tree-compiler-1.4.2/debian/patches/16_fdtdump-rename-from-ftdump.patch device-tree-compiler-1.4.5/debian/patches/16_fdtdump-rename-from-ftdump.patch --- device-tree-compiler-1.4.2/debian/patches/16_fdtdump-rename-from-ftdump.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/16_fdtdump-rename-from-ftdump.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,438 +0,0 @@ -From: Mike Frysinger -Date: Tue, 25 Oct 2011 21:29:24 +0000 (-0400) -Subject: fdtdump: rename from ftdump -X-Git-Url: http://git.jdl.com/gitweb/?p=dtc.git;a=commitdiff_plain;h=8f459c5d72673e1a3a119ac58a7eee56236fca73 - -fdtdump: rename from ftdump - -The freetype package already installs a binary named "ftdump", so the dtc -package conflicts with that. So rename the newer dtc tool to "fdtdump". -This even makes a bit more sense: - ftdump: [F]lat device [T]ree [dump] - fdtdump: [F]lat [D]evice [T]ree [dump] - -Signed-off-by: Mike Frysinger -Acked-by: David Gibson ---- - -Index: device-tree-compiler-1.3.0/.gitignore -=================================================================== ---- device-tree-compiler-1.3.0.orig/.gitignore 2012-01-30 15:03:30.095993353 +0100 -+++ device-tree-compiler-1.3.0/.gitignore 2012-01-30 15:03:34.487993309 +0100 -@@ -7,6 +7,6 @@ - lex.yy.c - *.lex.c - /dtc --/ftdump -+/fdtdump - /convert-dtsv0 - /version_gen.h -Index: device-tree-compiler-1.3.0/Documentation/manual.txt -=================================================================== ---- device-tree-compiler-1.3.0.orig/Documentation/manual.txt 2012-01-30 15:03:30.075993336 +0100 -+++ device-tree-compiler-1.3.0/Documentation/manual.txt 2012-01-30 15:03:34.487993309 +0100 -@@ -21,7 +21,7 @@ - - IV - Utility Tools - 1) convert-dtsv0 -- Conversion to Version 1 -- 1) ftdump -+ 1) fdtdump - - - I - "dtc", the device tree compiler -@@ -643,10 +643,10 @@ - Comments, empty lines, etc. are preserved. - - --2) ftdump -- Flat Tree dumping utility -+2) fdtdump -- Flat Device Tree dumping utility - --The ftdump program prints a readable version of a flat device tree file. -+The fdtdump program prints a readable version of a flat device tree file. - --The syntax of the ftdump command line is: -+The syntax of the fdtdump command line is: - -- ftdump -+ fdtdump -Index: device-tree-compiler-1.3.0/Makefile -=================================================================== ---- device-tree-compiler-1.3.0.orig/Makefile 2012-01-30 15:03:30.023993406 +0100 -+++ device-tree-compiler-1.3.0/Makefile 2012-01-30 15:03:34.487993309 +0100 -@@ -109,7 +109,7 @@ - - BIN += convert-dtsv0 - BIN += dtc --BIN += ftdump -+BIN += fdtdump - - SCRIPTS = dtdiff - -@@ -119,7 +119,7 @@ - ifneq ($(DEPTARGETS),) - -include $(DTC_OBJS:%.o=%.d) - -include $(CONVERT_OBJS:%.o=%.d) ---include $(FTDUMP_OBJS:%.o=%.d) -+-include $(FDTDUMP_OBJS:%.o=%.d) - endif - - -@@ -178,7 +178,7 @@ - @$(VECHO) LD $@ - $(LINK.c) -o $@ $^ - --ftdump: $(FTDUMP_OBJS) -+fdtdump: $(FDTDUMP_OBJS) - - - # -Index: device-tree-compiler-1.3.0/Makefile.utils -=================================================================== ---- device-tree-compiler-1.3.0.orig/Makefile.utils 2012-01-30 15:03:30.043993314 +0100 -+++ device-tree-compiler-1.3.0/Makefile.utils 2012-01-30 15:03:34.491993307 +0100 -@@ -3,8 +3,8 @@ - # be easily embeddable into other systems of Makefiles. - # - --FTDUMP_SRCS = \ -- ftdump.c \ -+FDTDUMP_SRCS = \ -+ fdtdump.c \ - util.c - --FTDUMP_OBJS = $(FTDUMP_SRCS:%.c=%.o) -+FDTDUMP_OBJS = $(FDTDUMP_SRCS:%.c=%.o) -Index: device-tree-compiler-1.3.0/ftdump.c -=================================================================== ---- device-tree-compiler-1.3.0.orig/ftdump.c 2012-01-30 15:03:30.059993370 +0100 -+++ /dev/null 1970-01-01 00:00:00.000000000 +0000 -@@ -1,162 +0,0 @@ --/* -- * ftdump.c - Contributed by Pantelis Antoniou -- */ -- --#include --#include --#include --#include --#include -- --#include --#include -- --#include "util.h" -- --#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) --#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) --#define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4))) -- --static void print_data(const char *data, int len) --{ -- int i; -- const char *p = data; -- -- /* no data, don't print */ -- if (len == 0) -- return; -- -- if (util_is_printable_string(data, len)) { -- printf(" = \"%s\"", (const char *)data); -- } else if ((len % 4) == 0) { -- printf(" = <"); -- for (i = 0; i < len; i += 4) -- printf("0x%08x%s", fdt32_to_cpu(GET_CELL(p)), -- i < (len - 4) ? " " : ""); -- printf(">"); -- } else { -- printf(" = ["); -- for (i = 0; i < len; i++) -- printf("%02x%s", *p++, i < len - 1 ? " " : ""); -- printf("]"); -- } --} -- --static void dump_blob(void *blob) --{ -- struct fdt_header *bph = blob; -- uint32_t off_mem_rsvmap = fdt32_to_cpu(bph->off_mem_rsvmap); -- uint32_t off_dt = fdt32_to_cpu(bph->off_dt_struct); -- uint32_t off_str = fdt32_to_cpu(bph->off_dt_strings); -- struct fdt_reserve_entry *p_rsvmap = -- (struct fdt_reserve_entry *)((char *)blob + off_mem_rsvmap); -- const char *p_struct = (const char *)blob + off_dt; -- const char *p_strings = (const char *)blob + off_str; -- uint32_t version = fdt32_to_cpu(bph->version); -- uint32_t totalsize = fdt32_to_cpu(bph->totalsize); -- uint32_t tag; -- const char *p, *s, *t; -- int depth, sz, shift; -- int i; -- uint64_t addr, size; -- -- depth = 0; -- shift = 4; -- -- printf("/dts-v1/;\n"); -- printf("// magic:\t\t0x%x\n", fdt32_to_cpu(bph->magic)); -- printf("// totalsize:\t\t0x%x (%d)\n", totalsize, totalsize); -- printf("// off_dt_struct:\t0x%x\n", off_dt); -- printf("// off_dt_strings:\t0x%x\n", off_str); -- printf("// off_mem_rsvmap:\t0x%x\n", off_mem_rsvmap); -- printf("// version:\t\t%d\n", version); -- printf("// last_comp_version:\t%d\n", -- fdt32_to_cpu(bph->last_comp_version)); -- if (version >= 2) -- printf("// boot_cpuid_phys:\t0x%x\n", -- fdt32_to_cpu(bph->boot_cpuid_phys)); -- -- if (version >= 3) -- printf("// size_dt_strings:\t0x%x\n", -- fdt32_to_cpu(bph->size_dt_strings)); -- if (version >= 17) -- printf("// size_dt_struct:\t0x%x\n", -- fdt32_to_cpu(bph->size_dt_struct)); -- printf("\n"); -- -- for (i = 0; ; i++) { -- addr = fdt64_to_cpu(p_rsvmap[i].address); -- size = fdt64_to_cpu(p_rsvmap[i].size); -- if (addr == 0 && size == 0) -- break; -- -- printf("/memreserve/ %llx %llx;\n", -- (unsigned long long)addr, (unsigned long long)size); -- } -- -- p = p_struct; -- while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) { -- -- /* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */ -- -- if (tag == FDT_BEGIN_NODE) { -- s = p; -- p = PALIGN(p + strlen(s) + 1, 4); -- -- if (*s == '\0') -- s = "/"; -- -- printf("%*s%s {\n", depth * shift, "", s); -- -- depth++; -- continue; -- } -- -- if (tag == FDT_END_NODE) { -- depth--; -- -- printf("%*s};\n", depth * shift, ""); -- continue; -- } -- -- if (tag == FDT_NOP) { -- printf("%*s// [NOP]\n", depth * shift, ""); -- continue; -- } -- -- if (tag != FDT_PROP) { -- fprintf(stderr, "%*s ** Unknown tag 0x%08x\n", depth * shift, "", tag); -- break; -- } -- sz = fdt32_to_cpu(GET_CELL(p)); -- s = p_strings + fdt32_to_cpu(GET_CELL(p)); -- if (version < 16 && sz >= 8) -- p = PALIGN(p, 8); -- t = p; -- -- p = PALIGN(p + sz, 4); -- -- printf("%*s%s", depth * shift, "", s); -- print_data(t, sz); -- printf(";\n"); -- } --} -- -- --int main(int argc, char *argv[]) --{ -- char *buf; -- -- if (argc < 2) { -- fprintf(stderr, "supply input filename\n"); -- return 5; -- } -- -- buf = utilfdt_read(argv[1]); -- if (buf) -- dump_blob(buf); -- else -- return 10; -- -- return 0; --} -Index: device-tree-compiler-1.3.0/fdtdump.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ device-tree-compiler-1.3.0/fdtdump.c 2012-01-30 15:04:46.255989457 +0100 -@@ -0,0 +1,162 @@ -+/* -+ * fdtdump.c - Contributed by Pantelis Antoniou -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+#include "util.h" -+ -+#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) -+#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) -+#define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4))) -+ -+static void print_data(const char *data, int len) -+{ -+ int i; -+ const char *p = data; -+ -+ /* no data, don't print */ -+ if (len == 0) -+ return; -+ -+ if (util_is_printable_string(data, len)) { -+ printf(" = \"%s\"", (const char *)data); -+ } else if ((len % 4) == 0) { -+ printf(" = <"); -+ for (i = 0; i < len; i += 4) -+ printf("0x%08x%s", fdt32_to_cpu(GET_CELL(p)), -+ i < (len - 4) ? " " : ""); -+ printf(">"); -+ } else { -+ printf(" = ["); -+ for (i = 0; i < len; i++) -+ printf("%02x%s", *p++, i < len - 1 ? " " : ""); -+ printf("]"); -+ } -+} -+ -+static void dump_blob(void *blob) -+{ -+ struct fdt_header *bph = blob; -+ uint32_t off_mem_rsvmap = fdt32_to_cpu(bph->off_mem_rsvmap); -+ uint32_t off_dt = fdt32_to_cpu(bph->off_dt_struct); -+ uint32_t off_str = fdt32_to_cpu(bph->off_dt_strings); -+ struct fdt_reserve_entry *p_rsvmap = -+ (struct fdt_reserve_entry *)((char *)blob + off_mem_rsvmap); -+ const char *p_struct = (const char *)blob + off_dt; -+ const char *p_strings = (const char *)blob + off_str; -+ uint32_t version = fdt32_to_cpu(bph->version); -+ uint32_t totalsize = fdt32_to_cpu(bph->totalsize); -+ uint32_t tag; -+ const char *p, *s, *t; -+ int depth, sz, shift; -+ int i; -+ uint64_t addr, size; -+ -+ depth = 0; -+ shift = 4; -+ -+ printf("/dts-v1/;\n"); -+ printf("// magic:\t\t0x%x\n", fdt32_to_cpu(bph->magic)); -+ printf("// totalsize:\t\t0x%x (%d)\n", totalsize, totalsize); -+ printf("// off_dt_struct:\t0x%x\n", off_dt); -+ printf("// off_dt_strings:\t0x%x\n", off_str); -+ printf("// off_mem_rsvmap:\t0x%x\n", off_mem_rsvmap); -+ printf("// version:\t\t%d\n", version); -+ printf("// last_comp_version:\t%d\n", -+ fdt32_to_cpu(bph->last_comp_version)); -+ if (version >= 2) -+ printf("// boot_cpuid_phys:\t0x%x\n", -+ fdt32_to_cpu(bph->boot_cpuid_phys)); -+ -+ if (version >= 3) -+ printf("// size_dt_strings:\t0x%x\n", -+ fdt32_to_cpu(bph->size_dt_strings)); -+ if (version >= 17) -+ printf("// size_dt_struct:\t0x%x\n", -+ fdt32_to_cpu(bph->size_dt_struct)); -+ printf("\n"); -+ -+ for (i = 0; ; i++) { -+ addr = fdt64_to_cpu(p_rsvmap[i].address); -+ size = fdt64_to_cpu(p_rsvmap[i].size); -+ if (addr == 0 && size == 0) -+ break; -+ -+ printf("/memreserve/ %llx %llx;\n", -+ (unsigned long long)addr, (unsigned long long)size); -+ } -+ -+ p = p_struct; -+ while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) { -+ -+ /* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */ -+ -+ if (tag == FDT_BEGIN_NODE) { -+ s = p; -+ p = PALIGN(p + strlen(s) + 1, 4); -+ -+ if (*s == '\0') -+ s = "/"; -+ -+ printf("%*s%s {\n", depth * shift, "", s); -+ -+ depth++; -+ continue; -+ } -+ -+ if (tag == FDT_END_NODE) { -+ depth--; -+ -+ printf("%*s};\n", depth * shift, ""); -+ continue; -+ } -+ -+ if (tag == FDT_NOP) { -+ printf("%*s// [NOP]\n", depth * shift, ""); -+ continue; -+ } -+ -+ if (tag != FDT_PROP) { -+ fprintf(stderr, "%*s ** Unknown tag 0x%08x\n", depth * shift, "", tag); -+ break; -+ } -+ sz = fdt32_to_cpu(GET_CELL(p)); -+ s = p_strings + fdt32_to_cpu(GET_CELL(p)); -+ if (version < 16 && sz >= 8) -+ p = PALIGN(p, 8); -+ t = p; -+ -+ p = PALIGN(p + sz, 4); -+ -+ printf("%*s%s", depth * shift, "", s); -+ print_data(t, sz); -+ printf(";\n"); -+ } -+} -+ -+ -+int main(int argc, char *argv[]) -+{ -+ char *buf; -+ -+ if (argc < 2) { -+ fprintf(stderr, "supply input filename\n"); -+ return 5; -+ } -+ -+ buf = utilfdt_read(argv[1]); -+ if (buf) -+ dump_blob(buf); -+ else -+ return 10; -+ -+ return 0; -+} diff -Nru device-tree-compiler-1.4.2/debian/patches/17_libfdt-Add-support-for-appending-the-values-to-a-exi.patch device-tree-compiler-1.4.5/debian/patches/17_libfdt-Add-support-for-appending-the-values-to-a-exi.patch --- device-tree-compiler-1.4.2/debian/patches/17_libfdt-Add-support-for-appending-the-values-to-a-exi.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/17_libfdt-Add-support-for-appending-the-values-to-a-exi.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,331 +0,0 @@ -From a31e3ef83bfce62d07695355e5f06cd4d0e44b86 Mon Sep 17 00:00:00 2001 -From: Minghuan Lian -Date: Mon, 5 Dec 2011 12:22:07 +1100 -Subject: [PATCH 2/7] libfdt: Add support for appending the values to a - existing property - -Some properties may contain multiple values, these values may need -to be added to the property respectively. this patch provides this -functionality. The main purpose of fdt_append_prop() is to append -the values to a existing property, or create a new property if it -dose not exist. - -Signed-off-by: Minghuan Lian -Signed-off-by: David Gibson ---- - libfdt/fdt_rw.c | 27 ++++++++++++++ - libfdt/libfdt.h | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++ - tests/appendprop.dts | 7 ++++ - tests/appendprop1.c | 70 ++++++++++++++++++++++++++++++++++++ - tests/appendprop2.c | 64 +++++++++++++++++++++++++++++++++ - 5 files changed, 263 insertions(+), 0 deletions(-) - create mode 100644 tests/appendprop.dts - create mode 100644 tests/appendprop1.c - create mode 100644 tests/appendprop2.c - -diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c -index 994037b..24437df 100644 ---- a/libfdt/fdt_rw.c -+++ b/libfdt/fdt_rw.c -@@ -289,6 +289,33 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, - return 0; - } - -+int fdt_appendprop(void *fdt, int nodeoffset, const char *name, -+ const void *val, int len) -+{ -+ struct fdt_property *prop; -+ int err, oldlen, newlen; -+ -+ FDT_RW_CHECK_HEADER(fdt); -+ -+ prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen); -+ if (prop) { -+ newlen = len + oldlen; -+ err = _fdt_splice_struct(fdt, prop->data, -+ FDT_TAGALIGN(oldlen), -+ FDT_TAGALIGN(newlen)); -+ if (err) -+ return err; -+ prop->len = cpu_to_fdt32(newlen); -+ memcpy(prop->data + oldlen, val, len); -+ } else { -+ err = _fdt_add_property(fdt, nodeoffset, name, len, &prop); -+ if (err) -+ return err; -+ memcpy(prop->data, val, len); -+ } -+ return 0; -+} -+ - int fdt_delprop(void *fdt, int nodeoffset, const char *name) - { - struct fdt_property *prop; -diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h -index 55f3eb3..060479e 100644 ---- a/libfdt/libfdt.h -+++ b/libfdt/libfdt.h -@@ -1134,6 +1134,101 @@ static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, - fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) - - /** -+ * fdt_appendprop - append to or create a property -+ * @fdt: pointer to the device tree blob -+ * @nodeoffset: offset of the node whose property to change -+ * @name: name of the property to append to -+ * @val: pointer to data to append to the property value -+ * @len: length of the data to append to the property value -+ * -+ * fdt_appendprop() appends the value to the named property in the -+ * given node, creating the property if it does not already exist. -+ * -+ * This function may insert data into the blob, and will therefore -+ * change the offsets of some existing nodes. -+ * -+ * returns: -+ * 0, on success -+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to -+ * contain the new property value -+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag -+ * -FDT_ERR_BADLAYOUT, -+ * -FDT_ERR_BADMAGIC, -+ * -FDT_ERR_BADVERSION, -+ * -FDT_ERR_BADSTATE, -+ * -FDT_ERR_BADSTRUCTURE, -+ * -FDT_ERR_BADLAYOUT, -+ * -FDT_ERR_TRUNCATED, standard meanings -+ */ -+int fdt_appendprop(void *fdt, int nodeoffset, const char *name, -+ const void *val, int len); -+ -+/** -+ * fdt_appendprop_cell - append a single cell value to a property -+ * @fdt: pointer to the device tree blob -+ * @nodeoffset: offset of the node whose property to change -+ * @name: name of the property to change -+ * @val: 32-bit integer value to append to the property (native endian) -+ * -+ * fdt_appendprop_cell() appends the given cell value (converting to -+ * big-endian if necessary) to the value of the named property in the -+ * given node, or creates a new property with that value if it does -+ * not already exist. -+ * -+ * This function may insert data into the blob, and will therefore -+ * change the offsets of some existing nodes. -+ * -+ * returns: -+ * 0, on success -+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to -+ * contain the new property value -+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag -+ * -FDT_ERR_BADLAYOUT, -+ * -FDT_ERR_BADMAGIC, -+ * -FDT_ERR_BADVERSION, -+ * -FDT_ERR_BADSTATE, -+ * -FDT_ERR_BADSTRUCTURE, -+ * -FDT_ERR_BADLAYOUT, -+ * -FDT_ERR_TRUNCATED, standard meanings -+ */ -+static inline int fdt_appendprop_cell(void *fdt, int nodeoffset, -+ const char *name, uint32_t val) -+{ -+ val = cpu_to_fdt32(val); -+ return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val)); -+} -+ -+/** -+ * fdt_appendprop_string - append a string to a property -+ * @fdt: pointer to the device tree blob -+ * @nodeoffset: offset of the node whose property to change -+ * @name: name of the property to change -+ * @str: string value to append to the property -+ * -+ * fdt_appendprop_string() appends the given string to the value of -+ * the named property in the given node, or creates a new property -+ * with that value if it does not already exist. -+ * -+ * This function may insert data into the blob, and will therefore -+ * change the offsets of some existing nodes. -+ * -+ * returns: -+ * 0, on success -+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to -+ * contain the new property value -+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag -+ * -FDT_ERR_BADLAYOUT, -+ * -FDT_ERR_BADMAGIC, -+ * -FDT_ERR_BADVERSION, -+ * -FDT_ERR_BADSTATE, -+ * -FDT_ERR_BADSTRUCTURE, -+ * -FDT_ERR_BADLAYOUT, -+ * -FDT_ERR_TRUNCATED, standard meanings -+ */ -+#define fdt_appendprop_string(fdt, nodeoffset, name, str) \ -+ fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) -+ -+/** - * fdt_delprop - delete a property - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to nop -diff --git a/tests/appendprop.dts b/tests/appendprop.dts -new file mode 100644 -index 0000000..6e3a3eb ---- /dev/null -+++ b/tests/appendprop.dts -@@ -0,0 +1,7 @@ -+/dts-v1/; -+ -+/ { -+ prop-str = "hello world", "nastystring: \a\b\t\n\v\f\r\\\""; -+ prop-int = <0xdeadbeef 123456789>; -+ prop-bytes = [00010203040001020304]; -+}; -diff --git a/tests/appendprop1.c b/tests/appendprop1.c -new file mode 100644 -index 0000000..180d296 ---- /dev/null -+++ b/tests/appendprop1.c -@@ -0,0 +1,70 @@ -+/* -+ * libfdt - Flat Device Tree manipulation -+ * Testcase for fdt_appendprop() -+ * Copyright (C) 2006 David Gibson, IBM Corporation. -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public License -+ * as published by the Free Software Foundation; either version 2.1 of -+ * the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+#include "tests.h" -+#include "testdata.h" -+ -+#define SPACE 65536 -+ -+#define CHECK(code) \ -+ { \ -+ err = (code); \ -+ if (err) \ -+ FAIL(#code ": %s", fdt_strerror(err)); \ -+ } -+ -+int main(int argc, char *argv[]) -+{ -+ void *fdt; -+ int err; -+ uint8_t bytes[] = {0x00, 0x01, 0x02, 0x03, 0x04}; -+ -+ test_init(argc, argv); -+ -+ /* Create an empty tree first */ -+ fdt = xmalloc(SPACE); -+ CHECK(fdt_create(fdt, SPACE)); -+ CHECK(fdt_finish_reservemap(fdt)); -+ CHECK(fdt_begin_node(fdt, "")); -+ CHECK(fdt_end_node(fdt)); -+ CHECK(fdt_finish(fdt)); -+ -+ /* Now use appendprop to add properties */ -+ CHECK(fdt_open_into(fdt, fdt, SPACE)); -+ -+ CHECK(fdt_appendprop(fdt, 0, "prop-bytes", bytes, sizeof(bytes))); -+ CHECK(fdt_appendprop_cell(fdt, 0, "prop-int", TEST_VALUE_1)); -+ CHECK(fdt_appendprop_string(fdt, 0, "prop-str", TEST_STRING_1)); -+ -+ CHECK(fdt_pack(fdt)); -+ -+ save_blob("appendprop1.test.dtb", fdt); -+ -+ PASS(); -+} -diff --git a/tests/appendprop2.c b/tests/appendprop2.c -new file mode 100644 -index 0000000..d651a89 ---- /dev/null -+++ b/tests/appendprop2.c -@@ -0,0 +1,64 @@ -+/* -+ * libfdt - Flat Device Tree manipulation -+ * Testcase for fdt_appendprop() -+ * Copyright (C) 2006 David Gibson, IBM Corporation. -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public License -+ * as published by the Free Software Foundation; either version 2.1 of -+ * the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+#include "tests.h" -+#include "testdata.h" -+ -+#define SPACE 65536 -+ -+#define CHECK(code) \ -+ { \ -+ err = (code); \ -+ if (err) \ -+ FAIL(#code ": %s", fdt_strerror(err)); \ -+ } -+ -+int main(int argc, char *argv[]) -+{ -+ void *fdt, *buf; -+ int err; -+ uint8_t bytes[] = {0x00, 0x01, 0x02, 0x03, 0x04}; -+ -+ test_init(argc, argv); -+ fdt = load_blob_arg(argc, argv); -+ -+ buf = xmalloc(SPACE); -+ CHECK(fdt_open_into(fdt, buf, SPACE)); -+ fdt = buf; -+ -+ CHECK(fdt_appendprop(fdt, 0, "prop-bytes", bytes, sizeof(bytes))); -+ CHECK(fdt_appendprop_cell(fdt, 0, "prop-int", TEST_VALUE_2)); -+ CHECK(fdt_appendprop_string(fdt, 0, "prop-str", TEST_STRING_2)); -+ -+ CHECK(fdt_pack(fdt)); -+ -+ save_blob("appendprop2.test.dtb", fdt); -+ -+ PASS(); -+} --- -1.7.8.3 - diff -Nru device-tree-compiler-1.4.2/debian/patches/18_libfdt-Activate-testcase-for-appending-properties.patch device-tree-compiler-1.4.5/debian/patches/18_libfdt-Activate-testcase-for-appending-properties.patch --- device-tree-compiler-1.4.2/debian/patches/18_libfdt-Activate-testcase-for-appending-properties.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/18_libfdt-Activate-testcase-for-appending-properties.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -From 97b909f852039daaae267a66f5df2c90ed05b586 Mon Sep 17 00:00:00 2001 -From: David Gibson -Date: Wed, 11 Jan 2012 23:41:32 +1100 -Subject: [PATCH 3/7] libfdt: Activate testcase for appending properties - -Commit a31e3ef83bfce62d07695355e5f06cd4d0e44b86 introduced new libfdt -functions to append to existing properties. It also included a test case -for this, but neglected to update the Makefile and run_tests.sh script -to actually build and execute this testcase. - -This patch corrects the oversight. - -Signed-off-by: David Gibson ---- - tests/Makefile.tests | 1 + - tests/run_tests.sh | 4 ++++ - 2 files changed, 5 insertions(+), 0 deletions(-) - -diff --git a/tests/Makefile.tests b/tests/Makefile.tests -index 215a8c5..3f92074 100644 ---- a/tests/Makefile.tests -+++ b/tests/Makefile.tests -@@ -12,6 +12,7 @@ LIB_TESTS_L = get_mem_rsv \ - sw_tree1 \ - move_and_save mangle-layout nopulate \ - open_pack rw_tree1 set_name setprop del_property del_node \ -+ appendprop1 appendprop2 \ - string_escapes references path-references phandle_format \ - boot-cpuid incbin \ - extra-terminating-null \ -diff --git a/tests/run_tests.sh b/tests/run_tests.sh -index da6f970..c72b9d2 100755 ---- a/tests/run_tests.sh -+++ b/tests/run_tests.sh -@@ -178,6 +178,10 @@ libfdt_tests () { - run_test rw_tree1 - tree1_tests rw_tree1.test.dtb - tree1_tests_rw rw_tree1.test.dtb -+ run_test appendprop1 -+ run_test appendprop2 appendprop1.test.dtb -+ run_dtc_test -I dts -O dtb -o appendprop.test.dtb appendprop.dts -+ run_test dtbs_equal_ordered appendprop2.test.dtb appendprop.test.dtb - - for basetree in test_tree1.dtb sw_tree1.test.dtb rw_tree1.test.dtb; do - run_test nopulate $basetree --- -1.7.8.3 - diff -Nru device-tree-compiler-1.4.2/debian/patches/19_dtc-Implement-d-option-to-write-out-a-dependency-fil.patch device-tree-compiler-1.4.5/debian/patches/19_dtc-Implement-d-option-to-write-out-a-dependency-fil.patch --- device-tree-compiler-1.4.2/debian/patches/19_dtc-Implement-d-option-to-write-out-a-dependency-fil.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/19_dtc-Implement-d-option-to-write-out-a-dependency-fil.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,191 +0,0 @@ -From 69df9f0de25db1c37970850115cdf48335d41802 Mon Sep 17 00:00:00 2001 -From: Stephen Warren -Date: Thu, 12 Jan 2012 11:31:00 -0700 -Subject: [PATCH 4/7] dtc: Implement -d option to write out a dependency file - -This will allow callers to rebuild .dtb files when any of the /include/d -.dtsi files are modified, not just the top-level .dts file. - -Signed-off-by: Stephen Warren -Acked-by: David Gibson ---- - Documentation/manual.txt | 3 +++ - dtc.c | 20 +++++++++++++++++++- - srcpos.c | 4 ++++ - srcpos.h | 1 + - tests/dependencies.cmp | 1 + - tests/dependencies.dts | 6 ++++++ - tests/deps_inc1.dtsi | 1 + - tests/deps_inc2.dtsi | 1 + - tests/run_tests.sh | 4 ++++ - 9 files changed, 40 insertions(+), 1 deletions(-) - create mode 100644 tests/dependencies.cmp - create mode 100644 tests/dependencies.dts - create mode 100644 tests/deps_inc1.dtsi - create mode 100644 tests/deps_inc2.dtsi - -diff --git a/Documentation/manual.txt b/Documentation/manual.txt -index 14508f3..989c589 100644 ---- a/Documentation/manual.txt -+++ b/Documentation/manual.txt -@@ -106,6 +106,9 @@ Options: - -O - The generated output format, as listed above. - -+ -d -+ Generate a dependency file during compilation. -+ - -q - Quiet: -q suppress warnings, -qq errors, -qqq all - -diff --git a/dtc.c b/dtc.c -index 15d2fc2..7a0c605 100644 ---- a/dtc.c -+++ b/dtc.c -@@ -71,6 +71,7 @@ static void __attribute__ ((noreturn)) usage(void) - fprintf(stderr, "\t\t\tasm - assembler source\n"); - fprintf(stderr, "\t-V \n"); - fprintf(stderr, "\t\tBlob version to produce, defaults to %d (relevant for dtb\n\t\tand asm output only)\n", DEFAULT_FDT_VERSION); -+ fprintf(stderr, "\t-d \n"); - fprintf(stderr, "\t-R \n"); - fprintf(stderr, "\t\tMake space for reserve map entries (relevant for \n\t\tdtb and asm output only)\n"); - fprintf(stderr, "\t-S \n"); -@@ -99,6 +100,7 @@ int main(int argc, char *argv[]) - const char *inform = "dts"; - const char *outform = "dts"; - const char *outname = "-"; -+ const char *depname = NULL; - int force = 0, sort = 0; - const char *arg; - int opt; -@@ -111,7 +113,7 @@ int main(int argc, char *argv[]) - minsize = 0; - padsize = 0; - -- while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fqb:vH:s")) != EOF) { -+ while ((opt = getopt(argc, argv, "hI:O:o:V:d:R:S:p:fqb:vH:s")) != EOF) { - switch (opt) { - case 'I': - inform = optarg; -@@ -125,6 +127,9 @@ int main(int argc, char *argv[]) - case 'V': - outversion = strtol(optarg, NULL, 0); - break; -+ case 'd': -+ depname = optarg; -+ break; - case 'R': - reservenum = strtol(optarg, NULL, 0); - break; -@@ -185,6 +190,14 @@ int main(int argc, char *argv[]) - fprintf(stderr, "DTC: %s->%s on file \"%s\"\n", - inform, outform, arg); - -+ if (depname) { -+ depfile = fopen(depname, "w"); -+ if (!depfile) -+ die("Couldn't open dependency file %s: %s\n", depname, -+ strerror(errno)); -+ fprintf(depfile, "%s:", outname); -+ } -+ - if (streq(inform, "dts")) - bi = dt_from_source(arg); - else if (streq(inform, "fs")) -@@ -194,6 +207,11 @@ int main(int argc, char *argv[]) - else - die("Unknown input format \"%s\"\n", inform); - -+ if (depfile) { -+ fputc('\n', depfile); -+ fclose(depfile); -+ } -+ - if (cmdline_boot_cpuid != -1) - bi->boot_cpuid_phys = cmdline_boot_cpuid; - -diff --git a/srcpos.c b/srcpos.c -index 2dbc874..36a38e9 100644 ---- a/srcpos.c -+++ b/srcpos.c -@@ -40,6 +40,7 @@ static char *dirname(const char *path) - return NULL; - } - -+FILE *depfile; /* = NULL */ - struct srcfile_state *current_srcfile; /* = NULL */ - - /* Detect infinite include recursion. */ -@@ -67,6 +68,9 @@ FILE *srcfile_relative_open(const char *fname, char **fullnamep) - strerror(errno)); - } - -+ if (depfile) -+ fprintf(depfile, " %s", fullname); -+ - if (fullnamep) - *fullnamep = fullname; - else -diff --git a/srcpos.h b/srcpos.h -index bd7966e..ce980ca 100644 ---- a/srcpos.h -+++ b/srcpos.h -@@ -30,6 +30,7 @@ struct srcfile_state { - struct srcfile_state *prev; - }; - -+extern FILE *depfile; /* = NULL */ - extern struct srcfile_state *current_srcfile; /* = NULL */ - - FILE *srcfile_relative_open(const char *fname, char **fullnamep); -diff --git a/tests/dependencies.cmp b/tests/dependencies.cmp -new file mode 100644 -index 0000000..bcd9432 ---- /dev/null -+++ b/tests/dependencies.cmp -@@ -0,0 +1 @@ -+dependencies.test.dtb: dependencies.dts deps_inc1.dtsi deps_inc2.dtsi -diff --git a/tests/dependencies.dts b/tests/dependencies.dts -new file mode 100644 -index 0000000..2cfe31b ---- /dev/null -+++ b/tests/dependencies.dts -@@ -0,0 +1,6 @@ -+/dts-v1/; -+ -+/include/ "deps_inc1.dtsi" -+ -+/ { -+}; -diff --git a/tests/deps_inc1.dtsi b/tests/deps_inc1.dtsi -new file mode 100644 -index 0000000..5c607dc ---- /dev/null -+++ b/tests/deps_inc1.dtsi -@@ -0,0 +1 @@ -+/include/ "deps_inc2.dtsi" -diff --git a/tests/deps_inc2.dtsi b/tests/deps_inc2.dtsi -new file mode 100644 -index 0000000..710cecc ---- /dev/null -+++ b/tests/deps_inc2.dtsi -@@ -0,0 +1 @@ -+/* Empty */ -diff --git a/tests/run_tests.sh b/tests/run_tests.sh -index c72b9d2..e42154b 100755 ---- a/tests/run_tests.sh -+++ b/tests/run_tests.sh -@@ -357,6 +357,10 @@ dtc_tests () { - run_sh_test dtc-fatal.sh -I dts -O dtb nosuchfile.dts - run_sh_test dtc-fatal.sh -I dtb -O dtb nosuchfile.dtb - run_sh_test dtc-fatal.sh -I fs -O dtb nosuchfile -+ -+ # Dependencies -+ run_dtc_test -I dts -O dtb -o dependencies.test.dtb -d dependencies.test.d dependencies.dts -+ run_wrap_test cmp dependencies.test.d dependencies.cmp - } - - cmp_tests () { --- -1.7.8.3 - diff -Nru device-tree-compiler-1.4.2/debian/patches/20_Add-fdtget-utility-to-read-property-values-from-a-de.patch device-tree-compiler-1.4.5/debian/patches/20_Add-fdtget-utility-to-read-property-values-from-a-de.patch --- device-tree-compiler-1.4.2/debian/patches/20_Add-fdtget-utility-to-read-property-values-from-a-de.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/20_Add-fdtget-utility-to-read-property-values-from-a-de.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,486 +0,0 @@ -From 68d057f20d7c3a93b441d2892c4749392bc83b45 Mon Sep 17 00:00:00 2001 -From: Simon Glass -Date: Sat, 21 Jan 2012 10:14:47 -0800 -Subject: [PATCH 5/7] Add fdtget utility to read property values from a device - tree - -This simply utility makes it easy for scripts to read values from the device -tree. It is written in C and uses the same libfdt as the rest of the dtc -package. - -What is it for: -- Reading fdt values from scripts -- Extracting fdt information within build systems -- Looking at particular values without having to dump the entire tree - -To use it, specify the fdt binary file on command line followed by a list of -node, property pairs. The utility then looks up each node, finds the property -and displays the value. - -Each value is printed on a new line. - -fdtget tries to guess the type of each property based on its contents. This -is not always reliable, so you can use the -t option to force fdtget to decode -the value as a string, or byte, etc. - -To read from stdin, use - as the file. - -Usage: - fdtget
[ ]... -Options: - -t Type of data - -h Print this help - - s=string, i=int, u=unsigned, x=hex - Optional modifier prefix: - hh or b=byte, h=2 byte, l=4 byte (default) - -Signed-off-by: Simon Glass ---- - .gitignore | 1 + - Makefile | 4 + - Makefile.utils | 7 ++ - fdtget.c | 226 +++++++++++++++++++++++++++++++++++++++++++++++ - tests/fdtget-runtest.sh | 35 +++++++ - tests/run_tests.sh | 43 +++++++++- - tests/tests.sh | 1 + - util.h | 10 ++ - 8 files changed, 326 insertions(+), 1 deletions(-) - create mode 100644 fdtget.c - create mode 100755 tests/fdtget-runtest.sh - -diff --git a/.gitignore b/.gitignore -index 74714cd..2d82b71 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -10,3 +10,4 @@ lex.yy.c - /fdtdump - /convert-dtsv0 - /version_gen.h -+/fdtget -diff --git a/Makefile b/Makefile -index 4582f5d..a54a209 100644 ---- a/Makefile -+++ b/Makefile -@@ -110,6 +110,7 @@ include Makefile.utils - BIN += convert-dtsv0 - BIN += dtc - BIN += fdtdump -+BIN += fdtget - - SCRIPTS = dtdiff - -@@ -120,6 +121,7 @@ ifneq ($(DEPTARGETS),) - -include $(DTC_OBJS:%.o=%.d) - -include $(CONVERT_OBJS:%.o=%.d) - -include $(FDTDUMP_OBJS:%.o=%.d) -+-include $(FDTGET_OBJS:%.o=%.d) - endif - - -@@ -180,6 +182,8 @@ convert-dtsv0: $(CONVERT_OBJS) - - fdtdump: $(FDTDUMP_OBJS) - -+fdtget: $(FDTGET_OBJS) $(LIBFDT_archive) -+ - - # - # Testsuite rules -diff --git a/Makefile.utils b/Makefile.utils -index fae5b00..38efa3c 100644 ---- a/Makefile.utils -+++ b/Makefile.utils -@@ -8,3 +8,10 @@ FDTDUMP_SRCS = \ - util.c - - FDTDUMP_OBJS = $(FDTDUMP_SRCS:%.c=%.o) -+ -+ -+FDTGET_SRCS = \ -+ fdtget.c \ -+ util.c -+ -+FDTGET_OBJS = $(FDTGET_SRCS:%.c=%.o) -diff --git a/fdtget.c b/fdtget.c -new file mode 100644 -index 0000000..48ab615 ---- /dev/null -+++ b/fdtget.c -@@ -0,0 +1,226 @@ -+/* -+ * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License as -+ * published by the Free Software Foundation; either version 2 of -+ * the License, or (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, -+ * MA 02111-1307 USA -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include -+ -+#include "util.h" -+ -+/* Holds information which controls our output and options */ -+struct display_info { -+ int type; /* data type (s/i/u/x or 0 for default) */ -+ int size; /* data size (1/2/4) */ -+}; -+ -+static void report_error(const char *where, int err) -+{ -+ fprintf(stderr, "Error at '%s': %s\n", where, fdt_strerror(err)); -+} -+ -+/** -+ * Displays data of a given length according to selected options -+ * -+ * If a specific data type is provided in disp, then this is used. Otherwise -+ * we try to guess the data type / size from the contents. -+ * -+ * @param disp Display information / options -+ * @param data Data to display -+ * @param len Maximum length of buffer -+ * @return 0 if ok, -1 if data does not match format -+ */ -+static int show_data(struct display_info *disp, const char *data, int len) -+{ -+ int i, size; -+ const uint8_t *p = (const uint8_t *)data; -+ const char *s; -+ int value; -+ int is_string; -+ char fmt[3]; -+ -+ /* no data, don't print */ -+ if (len == 0) -+ return 0; -+ -+ is_string = (disp->type) == 's' || -+ (!disp->type && util_is_printable_string(data, len)); -+ if (is_string) { -+ if (data[len - 1] != '\0') { -+ fprintf(stderr, "Unterminated string\n"); -+ return -1; -+ } -+ for (s = data; s - data < len; s += strlen(s) + 1) { -+ if (s != data) -+ printf(" "); -+ printf("%s", (const char *)s); -+ } -+ return 0; -+ } -+ size = disp->size; -+ if (size == -1) -+ size = (len % 4) == 0 ? 4 : 1; -+ else if (len % size) { -+ fprintf(stderr, "Property length must be a multiple of " -+ "selected data size\n"); -+ return -1; -+ } -+ fmt[0] = '%'; -+ fmt[1] = disp->type ? disp->type : 'd'; -+ fmt[2] = '\0'; -+ for (i = 0; i < len; i += size, p += size) { -+ if (i) -+ printf(" "); -+ value = size == 4 ? fdt32_to_cpu(*(const uint32_t *)p) : -+ size == 2 ? (*p << 8) | p[1] : *p; -+ printf(fmt, value); -+ } -+ return 0; -+} -+ -+/** -+ * Show the data for a given node (and perhaps property) according to the -+ * display option provided. -+ * -+ * @param blob FDT blob -+ * @param disp Display information / options -+ * @param node Node to display -+ * @param property Name of property to display, or NULL if none -+ * @return 0 if ok, -ve on error -+ */ -+static int show_data_for_item(const void *blob, struct display_info *disp, -+ int node, const char *property) -+{ -+ const void *value = NULL; -+ int len, err = 0; -+ -+ value = fdt_getprop(blob, node, property, &len); -+ if (value) { -+ if (show_data(disp, value, len)) -+ err = -1; -+ else -+ printf("\n"); -+ } else { -+ report_error(property, len); -+ err = -1; -+ } -+ return err; -+} -+ -+/** -+ * Run the main fdtget operation, given a filename and valid arguments -+ * -+ * @param disp Display information / options -+ * @param filename Filename of blob file -+ * @param arg List of arguments to process -+ * @param arg_count Number of arguments -+ * @param return 0 if ok, -ve on error -+ */ -+static int do_fdtget(struct display_info *disp, const char *filename, -+ char **arg, int arg_count) -+{ -+ char *blob; -+ int i, node; -+ -+ blob = utilfdt_read(filename); -+ if (!blob) -+ return -1; -+ -+ for (i = 0; i + 2 <= arg_count; i += 2) { -+ node = fdt_path_offset(blob, arg[0]); -+ if (node < 0) { -+ report_error(arg[0], node); -+ return -1; -+ } -+ -+ if (show_data_for_item(blob, disp, node, arg[1])) -+ return -1; -+ } -+ return 0; -+} -+ -+static const char *usage_msg = -+ "fdtget - read values from device tree\n" -+ "\n" -+ "Each value is printed on a new line.\n\n" -+ "Usage:\n" -+ " fdtget
[ ]...\n" -+ "Options:\n" -+ "\t-t \tType of data\n" -+ "\t-h\t\tPrint this help\n\n" -+ USAGE_TYPE_MSG; -+ -+static void usage(const char *msg) -+{ -+ if (msg) -+ fprintf(stderr, "Error: %s\n\n", msg); -+ -+ fprintf(stderr, "%s", usage_msg); -+ exit(2); -+} -+ -+int main(int argc, char *argv[]) -+{ -+ char *filename = NULL; -+ struct display_info disp; -+ -+ /* set defaults */ -+ memset(&disp, '\0', sizeof(disp)); -+ disp.size = -1; -+ for (;;) { -+ int c = getopt(argc, argv, "ht:"); -+ if (c == -1) -+ break; -+ -+ switch (c) { -+ case 'h': -+ case '?': -+ usage(NULL); -+ -+ case 't': -+ if (utilfdt_decode_type(optarg, &disp.type, -+ &disp.size)) -+ usage("Invalid type string"); -+ break; -+ } -+ } -+ -+ if (optind < argc) -+ filename = argv[optind++]; -+ if (!filename) -+ usage("Missing filename"); -+ -+ argv += optind; -+ argc -= optind; -+ -+ /* Allow no arguments, and silently succeed */ -+ if (!argc) -+ return 0; -+ -+ /* Check for node, property arguments */ -+ if (argc % 2) -+ usage("Must have an even number of arguments"); -+ -+ if (do_fdtget(&disp, filename, argv, argc)) -+ return 1; -+ return 0; -+} -diff --git a/tests/fdtget-runtest.sh b/tests/fdtget-runtest.sh -new file mode 100755 -index 0000000..f38184f ---- /dev/null -+++ b/tests/fdtget-runtest.sh -@@ -0,0 +1,35 @@ -+#! /bin/sh -+ -+. ./tests.sh -+ -+LOG="tmp.log.$$" -+EXPECT="tmp.expect.$$" -+ -+rm -f $TMPFILE $LOG -+ -+expect="$1" -+echo "$expect" >$EXPECT -+shift -+ -+verbose_run_log "$LOG" $VALGRIND "$DTGET" "$@" -+ret="$?" -+ -+if [ "$ret" -ne 0 -a "$expect" = "ERR" ]; then -+ PASS -+fi -+ -+if [ "$ret" -gt 127 ]; then -+ signame=$(kill -l $[ret - 128]) -+ FAIL "Killed by SIG$signame" -+fi -+ -+diff $EXPECT $LOG -+ret="$?" -+ -+rm -f $LOG $EXPECT -+ -+if [ "$ret" -eq 0 ]; then -+ PASS -+else -+ FAIL -+fi -diff --git a/tests/run_tests.sh b/tests/run_tests.sh -index e42154b..e6184df 100755 ---- a/tests/run_tests.sh -+++ b/tests/run_tests.sh -@@ -83,6 +83,13 @@ asm_to_so_test () { - run_wrap_test asm_to_so "$@" - } - -+run_fdtget_test () { -+ # run_fdtget_test name expected_output dtb_file args... -+ echo -n "$1: " -+ shift -+ base_run_test sh fdtget-runtest.sh "$@" -+} -+ - tree1_tests () { - TREE=$1 - -@@ -402,6 +409,37 @@ dtbs_equal_tests () { - cmp_tests test_tree1.dtb $WRONG_TREE1 - } - -+fdtget_tests () { -+ file=label01.dtb -+ $DTC -O dtb -o $file ${file%.dtb}.dts 2>/dev/null -+ -+ # run_fdtget_test ... -+ run_fdtget_test "Simple string" "MyBoardName" $file / model -+ run_fdtget_test "Multiple string i" "77 121 66 111 \ -+97 114 100 78 97 109 101 0 77 121 66 111 97 114 100 70 97 109 105 \ -+108 121 78 97 109 101 0" $file / compatible -+ run_fdtget_test "Multiple string s" "MyBoardName MyBoardFamilyName" \ -+ -t s $file / compatible -+ run_fdtget_test "Integer" "32768" $file /cpus/PowerPC,970@1 d-cache-size -+ run_fdtget_test "Integer hex" "8000" -tx $file \ -+ /cpus/PowerPC,970@1 d-cache-size -+ run_fdtget_test "Integer list" "61 62 63 0" -tbx $file \ -+ /randomnode tricky1 -+ run_fdtget_test "Byte list short" "a b c d de ea ad be ef" -tbx \ -+ $file /randomnode blob -+ -+ # Here the property size is not a multiple of 4 bytes, so it should fail -+ run_fdtget_test "Integer list invalid" ERR -tlx \ -+ $file /randomnode mixed -+ run_fdtget_test "Integer list halfword" "6162 6300 1234 0 a 0 b 0 c" -thx \ -+ $file /randomnode mixed -+ run_fdtget_test "Integer list byte" \ -+ "61 62 63 0 12 34 0 0 0 a 0 0 0 b 0 0 0 c" -thhx \ -+ $file /randomnode mixed -+ run_fdtget_test "Missing property" ERR -ts \ -+ $file /randomnode doctor-who -+} -+ - utilfdt_tests () { - run_test utilfdt_test - } -@@ -421,7 +459,7 @@ while getopts "vt:m" ARG ; do - done - - if [ -z "$TESTSETS" ]; then -- TESTSETS="libfdt utilfdt dtc dtbs_equal" -+ TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget" - fi - - # Make sure we don't have stale blobs lying around -@@ -441,6 +479,9 @@ for set in $TESTSETS; do - "dtbs_equal") - dtbs_equal_tests - ;; -+ "fdtget") -+ fdtget_tests -+ ;; - esac - done - -diff --git a/tests/tests.sh b/tests/tests.sh -index 30ffead..d9a0524 100644 ---- a/tests/tests.sh -+++ b/tests/tests.sh -@@ -11,6 +11,7 @@ FAIL () { - } - - DTC=../dtc -+DTGET=../fdtget - - verbose_run () { - if [ -z "$QUIET_TEST" ]; then -diff --git a/util.h b/util.h -index 730918e..c8eb45d 100644 ---- a/util.h -+++ b/util.h -@@ -140,4 +140,14 @@ int utilfdt_write_err(const char *filename, const void *blob); - */ - int utilfdt_decode_type(const char *fmt, int *type, int *size); - -+/* -+ * This is a usage message fragment for the -t option. It is the format -+ * supported by utilfdt_decode_type. -+ */ -+ -+#define USAGE_TYPE_MSG \ -+ "\ts=string, i=int, u=unsigned, x=hex\n" \ -+ "\tOptional modifier prefix:\n" \ -+ "\t\thh or b=byte, h=2 byte, l=4 byte (default)\n"; -+ - #endif /* _UTIL_H */ --- -1.7.8.3 - diff -Nru device-tree-compiler-1.4.2/debian/patches/21_Add-fdtput-utility-to-write-property-values-to-a-dev.patch device-tree-compiler-1.4.5/debian/patches/21_Add-fdtput-utility-to-write-property-values-to-a-dev.patch --- device-tree-compiler-1.4.2/debian/patches/21_Add-fdtput-utility-to-write-property-values-to-a-dev.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/21_Add-fdtput-utility-to-write-property-values-to-a-dev.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,534 +0,0 @@ -From 1ede50c3559bbfca79fadcbfd8acb9388f4aac87 Mon Sep 17 00:00:00 2001 -From: Simon Glass -Date: Sat, 21 Jan 2012 10:14:48 -0800 -Subject: [PATCH 6/7] Add fdtput utility to write property values to a device - tree - -This simple utility allows writing of values into a device tree from the -command line. It aimes to be the opposite of fdtget. - -What is it for: -- Updating fdt values when a binary blob already exists - (even though source may be available it might be easier to use this - utility rather than sed, etc.) -- Writing machine-specific fdt values within a build system - -To use it, specify the fdt binary file on command line followed by the node -and property to set. Then, provide a list of values to put into that -property. Often there will be just one, but fdtput also supports arrays and -string lists. - -fdtput does not try to guess the type of the property based on looking at -the arguments. Instead it always assumes that an integer is provided. To -indicate that you want to write a string, use -ts. You can also provide -hex values with -tx. - -The command line arguments are joined together into a single value. For -strings, a nul terminator is placed between each string when it is packed -into the property. To avoid this, pass the string as a single argument. - -Usage: - fdtput
< [...] -Options: - -t Type of data - -v Verbose: display each value decoded from command line - -h Print this help - - s=string, i=int, u=unsigned, x=hex - Optional modifier prefix: - hh or b=byte, h=2 byte, l=4 byte (default) - -To read from stdin and write to stdout, use - as the file. So you can do: - -cat somefile.dtb | fdtput -ts - /node prop "My string value" > newfile.dtb - -This commit also adds basic tests to verify the major features. - -Signed-off-by: Simon Glass ---- - .gitignore | 1 + - Makefile | 4 + - Makefile.utils | 7 ++ - fdtput.c | 235 +++++++++++++++++++++++++++++++++++++++++++++++ - tests/fdtput-runtest.sh | 55 +++++++++++ - tests/run_tests.sh | 73 ++++++++++++++- - tests/tests.sh | 1 + - 7 files changed, 375 insertions(+), 1 deletions(-) - create mode 100644 fdtput.c - create mode 100644 tests/fdtput-runtest.sh - -diff --git a/.gitignore b/.gitignore -index 2d82b71..5074980 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -11,3 +11,4 @@ lex.yy.c - /convert-dtsv0 - /version_gen.h - /fdtget -+/fdtput -diff --git a/Makefile b/Makefile -index a54a209..510caa6 100644 ---- a/Makefile -+++ b/Makefile -@@ -111,6 +111,7 @@ BIN += convert-dtsv0 - BIN += dtc - BIN += fdtdump - BIN += fdtget -+BIN += fdtput - - SCRIPTS = dtdiff - -@@ -122,6 +123,7 @@ ifneq ($(DEPTARGETS),) - -include $(CONVERT_OBJS:%.o=%.d) - -include $(FDTDUMP_OBJS:%.o=%.d) - -include $(FDTGET_OBJS:%.o=%.d) -+-include $(FDTPUT_OBJS:%.o=%.d) - endif - - -@@ -184,6 +186,8 @@ fdtdump: $(FDTDUMP_OBJS) - - fdtget: $(FDTGET_OBJS) $(LIBFDT_archive) - -+fdtput: $(FDTPUT_OBJS) $(LIBFDT_archive) -+ - - # - # Testsuite rules -diff --git a/Makefile.utils b/Makefile.utils -index 38efa3c..48ece49 100644 ---- a/Makefile.utils -+++ b/Makefile.utils -@@ -15,3 +15,10 @@ FDTGET_SRCS = \ - util.c - - FDTGET_OBJS = $(FDTGET_SRCS:%.c=%.o) -+ -+ -+FDTPUT_SRCS = \ -+ fdtput.c \ -+ util.c -+ -+FDTPUT_OBJS = $(FDTPUT_SRCS:%.c=%.o) -diff --git a/fdtput.c b/fdtput.c -new file mode 100644 -index 0000000..f6ebd24 ---- /dev/null -+++ b/fdtput.c -@@ -0,0 +1,235 @@ -+/* -+ * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License as -+ * published by the Free Software Foundation; either version 2 of -+ * the License, or (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, -+ * MA 02111-1307 USA -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+ -+#include "util.h" -+ -+struct display_info { -+ int type; /* data type (s/i/u/x or 0 for default) */ -+ int size; /* data size (1/2/4) */ -+ int verbose; /* verbose output */ -+}; -+ -+static void report_error(const char *where, int err) -+{ -+ fprintf(stderr, "Error at '%s': %s\n", where, fdt_strerror(err)); -+} -+ -+/** -+ * Encode a series of arguments in a property value. -+ * -+ * @param disp Display information / options -+ * @param arg List of arguments from command line -+ * @param arg_count Number of arguments (may be 0) -+ * @param valuep Returns buffer containing value -+ * @param *value_len Returns length of value encoded -+ */ -+static int encode_value(struct display_info *disp, char **arg, int arg_count, -+ char **valuep, int *value_len) -+{ -+ char *value = NULL; /* holding area for value */ -+ int value_size = 0; /* size of holding area */ -+ char *ptr; /* pointer to current value position */ -+ int len; /* length of this cell/string/byte */ -+ int ival; -+ int upto; /* the number of bytes we have written to buf */ -+ char fmt[3]; -+ -+ upto = 0; -+ -+ if (disp->verbose) -+ fprintf(stderr, "Decoding value:\n"); -+ -+ fmt[0] = '%'; -+ fmt[1] = disp->type ? disp->type : 'd'; -+ fmt[2] = '\0'; -+ for (; arg_count > 0; arg++, arg_count--, upto += len) { -+ /* assume integer unless told otherwise */ -+ if (disp->type == 's') -+ len = strlen(*arg) + 1; -+ else -+ len = disp->size == -1 ? 4 : disp->size; -+ -+ /* enlarge our value buffer by a suitable margin if needed */ -+ if (upto + len > value_size) { -+ value_size = (upto + len) + 500; -+ value = realloc(value, value_size); -+ if (!value) { -+ fprintf(stderr, "Out of mmory: cannot alloc " -+ "%d bytes\n", value_size); -+ return -1; -+ } -+ } -+ -+ ptr = value + upto; -+ if (disp->type == 's') { -+ memcpy(ptr, *arg, len); -+ if (disp->verbose) -+ fprintf(stderr, "\tstring: '%s'\n", ptr); -+ } else { -+ int *iptr = (int *)ptr; -+ sscanf(*arg, fmt, &ival); -+ if (len == 4) -+ *iptr = cpu_to_fdt32(ival); -+ else -+ *ptr = (uint8_t)ival; -+ if (disp->verbose) { -+ fprintf(stderr, "\t%s: %d\n", -+ disp->size == 1 ? "byte" : -+ disp->size == 2 ? "short" : "int", -+ ival); -+ } -+ } -+ } -+ *value_len = upto; -+ *valuep = value; -+ if (disp->verbose) -+ fprintf(stderr, "Value size %d\n", upto); -+ return 0; -+} -+ -+static int store_key_value(void *blob, const char *node_name, -+ const char *property, const char *buf, int len) -+{ -+ int node; -+ int err; -+ -+ node = fdt_path_offset(blob, node_name); -+ if (node < 0) { -+ report_error(node_name, node); -+ return -1; -+ } -+ -+ err = fdt_setprop(blob, node, property, buf, len); -+ if (err) { -+ report_error(property, err); -+ return -1; -+ } -+ return 0; -+} -+ -+static int do_fdtput(struct display_info *disp, const char *filename, -+ char **arg, int arg_count) -+{ -+ char *value; -+ char *blob; -+ int len, ret = 0; -+ -+ blob = utilfdt_read(filename); -+ if (!blob) -+ return -1; -+ -+ /* convert the arguments into a single binary value, then store */ -+ assert(arg_count >= 2); -+ if (encode_value(disp, arg + 2, arg_count - 2, &value, &len) || -+ store_key_value(blob, *arg, arg[1], value, len)) -+ ret = -1; -+ -+ if (!ret) -+ ret = utilfdt_write(filename, blob); -+ -+ free(blob); -+ return ret; -+} -+ -+static const char *usage_msg = -+ "fdtput - write a property value to a device tree\n" -+ "\n" -+ "The command line arguments are joined together into a single value.\n" -+ "\n" -+ "Usage:\n" -+ " fdtput
< [...]\n" -+ "Options:\n" -+ "\t-t \tType of data\n" -+ "\t-v\t\tVerbose: display each value decoded from command line\n" -+ "\t-h\t\tPrint this help\n\n" -+ USAGE_TYPE_MSG; -+ -+static void usage(const char *msg) -+{ -+ if (msg) -+ fprintf(stderr, "Error: %s\n\n", msg); -+ -+ fprintf(stderr, "%s", usage_msg); -+ exit(2); -+} -+ -+int main(int argc, char *argv[]) -+{ -+ struct display_info disp; -+ char *filename = NULL; -+ -+ memset(&disp, '\0', sizeof(disp)); -+ disp.size = -1; -+ for (;;) { -+ int c = getopt(argc, argv, "ht:v"); -+ if (c == -1) -+ break; -+ -+ /* -+ * TODO: add options to: -+ * - delete property -+ * - delete node (optionally recursively) -+ * - rename node -+ * - pack fdt before writing -+ * - set amount of free space when writing -+ * - expand fdt if value doesn't fit -+ */ -+ switch (c) { -+ case 'h': -+ case '?': -+ usage(NULL); -+ -+ case 't': -+ if (utilfdt_decode_type(optarg, &disp.type, -+ &disp.size)) -+ usage("Invalid type string"); -+ break; -+ -+ case 'v': -+ disp.verbose = 1; -+ break; -+ } -+ } -+ -+ if (optind < argc) -+ filename = argv[optind++]; -+ if (!filename) -+ usage("Missing filename"); -+ -+ argv += optind; -+ argc -= optind; -+ -+ if (argc < 1) -+ usage("Missing node"); -+ if (argc < 2) -+ usage("Missing property"); -+ -+ if (do_fdtput(&disp, filename, argv, argc)) -+ return 1; -+ return 0; -+} -diff --git a/tests/fdtput-runtest.sh b/tests/fdtput-runtest.sh -new file mode 100644 -index 0000000..ea51569 ---- /dev/null -+++ b/tests/fdtput-runtest.sh -@@ -0,0 +1,55 @@ -+#! /bin/sh -+ -+# Run script for fdtput tests -+# We run fdtput to update the device tree, thn fdtget to check it -+ -+# Usage -+# fdtput-runtest.sh name expected_output dtb_file node property flags value -+ -+. ./tests.sh -+ -+LOG="tmp.log.$$" -+EXPECT="tmp.expect.$$" -+ -+rm -f $TMPFILE $LOG -+ -+expect="$1" -+echo "$expect" >$EXPECT -+dtb="$2" -+node="$3" -+property="$4" -+flags="$5" -+shift 5 -+value="$@" -+ -+# First run fdtput -+verbose_run $VALGRIND "$DTPUT" "$dtb" "$node" "$property" $value $flags -+ret="$?" -+ -+if [ "$ret" -ne 0 -a "$expect" = "ERR" ]; then -+ PASS -+fi -+if [ "$ret" -gt 127 ]; then -+ signame=$(kill -l $[ret - 128]) -+ FAIL "Killed by SIG$signame" -+fi -+ -+# Now fdtget to read the value -+verbose_run_log "$LOG" $VALGRIND "$DTGET" "$dtb" "$node" "$property" $flags -+ret="$?" -+ -+if [ "$ret" -gt 127 ]; then -+ signame=$(kill -l $[ret - 128]) -+ FAIL "Killed by SIG$signame" -+fi -+ -+diff $EXPECT $LOG -+ret="$?" -+ -+rm -f $LOG $EXPECT -+ -+if [ "$ret" -eq 0 ]; then -+ PASS -+else -+ FAIL -+fi -diff --git a/tests/run_tests.sh b/tests/run_tests.sh -index e6184df..2650559 100755 ---- a/tests/run_tests.sh -+++ b/tests/run_tests.sh -@@ -90,6 +90,21 @@ run_fdtget_test () { - base_run_test sh fdtget-runtest.sh "$@" - } - -+run_fdtput_test () { -+ # run_fdtput_test name expected_output dtb_file node property flags value... -+ echo -n "$1: " -+ shift -+ output="$1" -+ dtb="$2" -+ node="$3" -+ property="$4" -+ flags="$5" -+ shift 5 -+ base_run_test sh fdtput-runtest.sh "$output" "$dtb" "$node" "$property" \ -+ "$flags" $@ -+# base_run_test sh fdtput-runtest.sh "$@" -+} -+ - tree1_tests () { - TREE=$1 - -@@ -440,6 +455,59 @@ fdtget_tests () { - $file /randomnode doctor-who - } - -+fdtput_tests () { -+ file=label01.dtb -+ src=label01.dts -+ -+ # Create some test files containing useful strings -+ base=tmp.test0 -+ file1=tmp.test1 -+ file2=tmp.test2 -+ bigfile1=tmp.test3 -+ bigfile2=tmp.test4 -+ -+ # Filter out anything the shell might not like -+ cat $src | tr -d "'\"\n\;/\.\*{}\-" | tr -s "[:blank:]" " " >$base -+ -+ # Make two small files -+ head -5 $base >$file1 -+ cat $file1 | tr a-z A-Z | cut -c10-30 | sort -r >$file2 -+ -+ # and two larger ones -+ cat $base > $bigfile1 -+ tac $base | tr a-z A-Z | sort -r >$bigfile2 -+ -+ # Allow just enough space for both file1 and file2 -+ (( space = $(stat -c %s $file1) + $(stat -c %s $file2) )) -+ $DTC -O dtb -p $space -o $file ${file%.dtb}.dts 2>/dev/null -+ -+ # run_fdtput_test -+ # ... -+ run_fdtput_test "Simple string" "a_model" $file / model -ts "a_model" -+ run_fdtput_test "Multiple string s" "board1 board2" \ -+ $file / compatible -ts board1 board2 -+ run_fdtput_test "Single string with spaces" "board1 board2" \ -+ $file / compatible -ts "board1 board2" -+ run_fdtput_test "Integer" "32768" \ -+ $file /cpus/PowerPC,970@1 d-cache-size "" "32768" -+ run_fdtput_test "Integer hex" "8001" \ -+ $file /cpus/PowerPC,970@1 d-cache-size -tx 0x8001 -+ run_fdtput_test "Integer list" "2 3 12" \ -+ $file /randomnode tricky1 -tbi "02 003 12" -+ run_fdtput_test "Byte list short" "a b c ea ad be ef" \ -+ $file /randomnode blob -tbx "a b c ea ad be ef" -+ run_fdtput_test "Integer list short" "a0b0c0d deeaae ef000000" \ -+ $file /randomnode blob -tx "a0b0c0d deeaae ef000000" -+ run_fdtput_test "Large string list" "`cat $file1 $file2`" \ -+ $file /randomnode blob -ts "`cat $file1`" "`cat $file2`" -+ -+ # This should be larger than available space in the fdt ($space) -+ run_fdtput_test "Enormous string list" ERR \ -+ $file /randomnode blob -ts "`cat $bigfile1`" "`cat $bigfile2`" -+ -+ # TODO: Add tests for verbose mode? -+} -+ - utilfdt_tests () { - run_test utilfdt_test - } -@@ -459,7 +527,7 @@ while getopts "vt:m" ARG ; do - done - - if [ -z "$TESTSETS" ]; then -- TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget" -+ TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget fdtput" - fi - - # Make sure we don't have stale blobs lying around -@@ -482,6 +550,9 @@ for set in $TESTSETS; do - "fdtget") - fdtget_tests - ;; -+ "fdtput") -+ fdtput_tests -+ ;; - esac - done - -diff --git a/tests/tests.sh b/tests/tests.sh -index d9a0524..6e5e76a 100644 ---- a/tests/tests.sh -+++ b/tests/tests.sh -@@ -12,6 +12,7 @@ FAIL () { - - DTC=../dtc - DTGET=../fdtget -+DTPUT=../fdtput - - verbose_run () { - if [ -z "$QUIET_TEST" ]; then --- -1.7.8.3 - diff -Nru device-tree-compiler-1.4.2/debian/patches/22_Introduce-TESTS_BIN-in-Makefiles-to-identify-tested-.patch device-tree-compiler-1.4.5/debian/patches/22_Introduce-TESTS_BIN-in-Makefiles-to-identify-tested-.patch --- device-tree-compiler-1.4.2/debian/patches/22_Introduce-TESTS_BIN-in-Makefiles-to-identify-tested-.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/22_Introduce-TESTS_BIN-in-Makefiles-to-identify-tested-.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -From 1456da7e2d3054882b20c120d817096bea21571e Mon Sep 17 00:00:00 2001 -From: Jon Loeliger -Date: Sat, 21 Jan 2012 15:24:51 -0600 -Subject: [PATCH 7/7] Introduce ${TESTS_BIN} in Makefiles to identify tested - executables. - ---- - Makefile | 6 ++++++ - tests/Makefile.tests | 6 +++--- - 2 files changed, 9 insertions(+), 3 deletions(-) - -diff --git a/Makefile b/Makefile -index 510caa6..1169e6c 100644 ---- a/Makefile -+++ b/Makefile -@@ -193,6 +193,12 @@ fdtput: $(FDTPUT_OBJS) $(LIBFDT_archive) - # Testsuite rules - # - TESTS_PREFIX=tests/ -+ -+TESTS_BIN += dtc -+TESTS_BIN += convert-dtsv0 -+TESTS_BIN += fdtput -+TESTS_BIN += fdtget -+ - include tests/Makefile.tests - - # -diff --git a/tests/Makefile.tests b/tests/Makefile.tests -index 3f92074..2eee708 100644 ---- a/tests/Makefile.tests -+++ b/tests/Makefile.tests -@@ -65,13 +65,13 @@ tests_clean: - rm -f $(STD_CLEANFILES:%=$(TESTS_PREFIX)%) - rm -f $(TESTS_CLEANFILES) - --check: tests dtc convert-dtsv0 -+check: tests ${TESTS_BIN} - cd $(TESTS_PREFIX); ./run_tests.sh - --checkm: tests dtc convert-dtsv0 -+checkm: tests ${TESTS_BIN} - cd $(TESTS_PREFIX); ./run_tests.sh -m 2>&1 | tee vglog.$$$$ - --checkv: tests dtc convert-dtsv0 -+checkv: tests ${TESTS_BIN} - cd $(TESTS_PREFIX); ./run_tests.sh -v - - ifneq ($(DEPTARGETS),) --- -1.7.8.3 - diff -Nru device-tree-compiler-1.4.2/debian/patches/local-add-missing-header-706137.patch device-tree-compiler-1.4.5/debian/patches/local-add-missing-header-706137.patch --- device-tree-compiler-1.4.2/debian/patches/local-add-missing-header-706137.patch 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/local-add-missing-header-706137.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -Description: libfdt-dev: Missing header file prevents the library usage - device-tree-compiler (1.3.0-3) unstable; urgency=low - . - * libfdt-dev: Missing header file prevents the library usage - Thanks Domenico Andreoli (Closes: #706137) -Author: Hector Oron -Bug-Debian: http://bugs.debian.org/706137 - ---- device-tree-compiler-1.3.0.orig/libfdt/Makefile.libfdt -+++ device-tree-compiler-1.3.0/libfdt/Makefile.libfdt -@@ -4,7 +4,7 @@ - # be easily embeddable into other systems of Makefiles. - # - LIBFDT_soname = libfdt.$(SHAREDLIB_EXT).1 --LIBFDT_INCLUDES = fdt.h libfdt.h -+LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h - LIBFDT_VERSION = version.lds - LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c - LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o) diff -Nru device-tree-compiler-1.4.2/debian/patches/series device-tree-compiler-1.4.5/debian/patches/series --- device-tree-compiler-1.4.2/debian/patches/series 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/patches/series 2017-10-06 17:36:17.000000000 +0000 @@ -1,23 +1,3 @@ 01_build_doc.patch -#02_remove-unused-check-variable.patch -#03_Remove-unused-variable-in-flat_read_mem_reserve.patch -#04_Split-out-is_printable_string-into-util.patch -#05_Add-missing-tests-to-gitignore.patch -#06_Refactor-character-literal-parsing-code.patch -#07_Remove-gcc-4.6-set-but-not-used-warnings.patch -#08_Support-character-literals-in-cell-lists.patch -#09_Create-Makefile_utils-and-move-ftdump-into-it.patch -#10_Add-fdt-read_write-utility-functions.patch -#11_Make-testutils-use-utilfdt.patch -#12_use-utilfdt-to-read-blob.patch -#13_Add-fdt16_to_cpu-utility-function.patch -#14_Add-data_append_integer-function.patch -#15_Add-support-for-variable-sized-elements.patch -#16_fdtdump-rename-from-ftdump.patch -#17_libfdt-Add-support-for-appending-the-values-to-a-exi.patch -#18_libfdt-Activate-testcase-for-appending-properties.patch -#19_dtc-Implement-d-option-to-write-out-a-dependency-fil.patch -#20_Add-fdtget-utility-to-read-property-values-from-a-de.patch -#21_Add-fdtput-utility-to-write-property-values-to-a-dev.patch -#22_Introduce-TESTS_BIN-in-Makefiles-to-identify-tested-.patch -#local-add-missing-header-706137.patch +02-checks-Use-proper-format-modifier-for-size_t.patch +03-tests-Avoid-64-bit-arithmetic-in-assembler.patch diff -Nru device-tree-compiler-1.4.2/debian/rules device-tree-compiler-1.4.5/debian/rules --- device-tree-compiler-1.4.2/debian/rules 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/rules 2017-10-06 17:35:17.000000000 +0000 @@ -1,15 +1,17 @@ #!/usr/bin/make -f # -*- makefile -*- -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 +# reproducible builds: texlive needs FORCE_SOURCE_DATE set in order to +# respect SOURCE_DATE_EPOCH. +export FORCE_SOURCE_DATE=1 + +export DEB_BUILD_MAINT_OPTIONS=hardening=+all export CFLAGS = -Wall -g -fPIC +# python library builds with warnings, temporarily disabled. +export NO_PYTHON = 1 + include /usr/share/dpkg/architecture.mk ifeq ($(origin CC),default) export CC = $(DEB_HOST_GNU_TYPE)-gcc @@ -21,58 +23,17 @@ CFLAGS += -O2 endif -build: build-arch build-indep -build-arch: build-stamp -build-indep: build-stamp -build-stamp: - dh_testdir - QUILT_PATCHES=debian/patches quilt push -a || test $$? = 2 - $(MAKE) CFLAGS="$(CFLAGS)" +%: + dh $@ + +override_dh_auto_build: + dh_auto_build $(MAKE) -C Documentation - touch build-stamp -clean: clean1 -clean1: - dh_testdir - dh_testroot - rm -f build-stamp install-stamp - $(MAKE) clean - [ ! -f Documentation/Makefile ] || $(MAKE) -C Documentation clean - QUILT_PATCHES=debian/patches quilt pop -a -R || test $$? = 2 - rm -rf .pc - dh_clean - -install: build - dh_testdir - dh_testroot - dh_prep - dh_installdirs +override_dh_auto_install: $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp PREFIX=/usr LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) - dh_install --list-missing --sourcedir=debian/tmp - touch install-stamp -# Build architecture-independent files here. -binary-indep: build install - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installchangelogs - dh_installdocs Documentation/dtc-paper.dvi Documentation/dtc-paper.ps \ - Documentation/dtc-paper.pdf Documentation/dtc-manual.txt - dh_installexamples - dh_installman debian/manpages/* - dh_link - dh_strip - dh_compress - dh_fixperms - dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install +override_dh_auto_clean: + dh_auto_clean + [ ! -f Documentation/Makefile ] || $(MAKE) -C Documentation clean + [ ! -d build ] || rm -rf build diff -Nru device-tree-compiler-1.4.2/debian/source/format device-tree-compiler-1.4.5/debian/source/format --- device-tree-compiler-1.4.2/debian/source/format 2017-11-01 13:39:36.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/source/format 2017-10-06 17:35:17.000000000 +0000 @@ -1 +1 @@ -1.0 +3.0 (quilt) diff -Nru device-tree-compiler-1.4.2/debian/watch device-tree-compiler-1.4.5/debian/watch --- device-tree-compiler-1.4.2/debian/watch 1970-01-01 00:00:00.000000000 +0000 +++ device-tree-compiler-1.4.5/debian/watch 2017-10-06 17:35:17.000000000 +0000 @@ -0,0 +1,3 @@ +version=4 +https://git.kernel.org/pub/scm/utils/dtc/dtc.git \ + .*/snapshot/dtc-@ANY_VERSION@@ARCHIVE_EXT@ diff -Nru device-tree-compiler-1.4.2/Documentation/dt-object-internal.txt device-tree-compiler-1.4.5/Documentation/dt-object-internal.txt --- device-tree-compiler-1.4.2/Documentation/dt-object-internal.txt 1970-01-01 00:00:00.000000000 +0000 +++ device-tree-compiler-1.4.5/Documentation/dt-object-internal.txt 2017-09-27 10:00:10.000000000 +0000 @@ -0,0 +1,310 @@ +Device Tree Dynamic Object format internals +------------------------------------------- + +The Device Tree for most platforms is a static representation of +the hardware capabilities. This is insufficient for platforms +that need to dynamically insert Device Tree fragments into the +live tree. + +This document explains the the Device Tree object format and +modifications made to the Device Tree compiler, which make it possible. + +1. Simplified Problem Definition +-------------------------------- + +Assume we have a platform which boots using following simplified Device Tree. + +---- foo.dts ----------------------------------------------------------------- + /* FOO platform */ + / { + compatible = "corp,foo"; + + /* shared resources */ + res: res { + }; + + /* On chip peripherals */ + ocp: ocp { + /* peripherals that are always instantiated */ + peripheral1 { ... }; + }; + }; +---- foo.dts ----------------------------------------------------------------- + +We have a number of peripherals that after probing (using some undefined method) +should result in different Device Tree configuration. + +We cannot boot with this static tree because due to the configuration of the +foo platform there exist multiple conficting peripherals DT fragments. + +So for the bar peripheral we would have this: + +---- foo+bar.dts ------------------------------------------------------------- + /* FOO platform + bar peripheral */ + / { + compatible = "corp,foo"; + + /* shared resources */ + res: res { + }; + + /* On chip peripherals */ + ocp: ocp { + /* peripherals that are always instantiated */ + peripheral1 { ... }; + + /* bar peripheral */ + bar { + compatible = "corp,bar"; + ... /* various properties and child nodes */ + }; + }; + }; +---- foo+bar.dts ------------------------------------------------------------- + +While for the baz peripheral we would have this: + +---- foo+baz.dts ------------------------------------------------------------- + /* FOO platform + baz peripheral */ + / { + compatible = "corp,foo"; + + /* shared resources */ + res: res { + /* baz resources */ + baz_res: res_baz { ... }; + }; + + /* On chip peripherals */ + ocp: ocp { + /* peripherals that are always instantiated */ + peripheral1 { ... }; + + /* baz peripheral */ + baz { + compatible = "corp,baz"; + /* reference to another point in the tree */ + ref-to-res = <&baz_res>; + ... /* various properties and child nodes */ + }; + }; + }; +---- foo+baz.dts ------------------------------------------------------------- + +We note that the baz case is more complicated, since the baz peripheral needs to +reference another node in the DT tree. + +2. Device Tree Object Format Requirements +----------------------------------------- + +Since the Device Tree is used for booting a number of very different hardware +platforms it is imperative that we tread very carefully. + +2.a) No changes to the Device Tree binary format for the base tree. We cannot +modify the tree format at all and all the information we require should be +encoded using Device Tree itself. We can add nodes that can be safely ignored +by both bootloaders and the kernel. The plugin dtbs are optionally tagged +with a different magic number in the header but otherwise they're simple +blobs. + +2.b) Changes to the DTS source format should be absolutely minimal, and should +only be needed for the DT fragment definitions, and not the base boot DT. + +2.c) An explicit option should be used to instruct DTC to generate the required +information needed for object resolution. Platforms that don't use the +dynamic object format can safely ignore it. + +2.d) Finally, DT syntax changes should be kept to a minimum. It should be +possible to express everything using the existing DT syntax. + +3. Implementation +----------------- + +The basic unit of addressing in Device Tree is the phandle. Turns out it's +relatively simple to extend the way phandles are generated and referenced +so that it's possible to dynamically convert symbolic references (labels) +to phandle values. This is a valid assumption as long as the author uses +reference syntax and does not assign phandle values manually (which might +be a problem with decompiled source files). + +We can roughly divide the operation into two steps. + +3.a) Compilation of the base board DTS file using the '-@' option +generates a valid DT blob with an added __symbols__ node at the root node, +containing a list of all nodes that are marked with a label. + +Using the foo.dts file above the following node will be generated; + +$ dtc -@ -O dtb -o foo.dtb -b 0 foo.dts +$ fdtdump foo.dtb +... +/ { + ... + res { + ... + phandle = <0x00000001>; + ... + }; + ocp { + ... + phandle = <0x00000002>; + ... + }; + __symbols__ { + res="/res"; + ocp="/ocp"; + }; +}; + +Notice that all the nodes that had a label have been recorded, and that +phandles have been generated for them. + +This blob can be used to boot the board normally, the __symbols__ node will +be safely ignored both by the bootloader and the kernel (the only loss will +be a few bytes of memory and disk space). + +We generate a __symbols__ node to record nodes that had labels in the base +tree (or subsequent loaded overlays) so that they can be matched up with +references made to them in Device Tree objects. + +3.b) The Device Tree fragments must be compiled with the same option but they +must also have a tag (/plugin/) that allows undefined references to nodes +that are not present at compilation time to be recorded so that the runtime +loader can fix them. + +So the bar peripheral's DTS format would be of the form: + +/dts-v1/; +/plugin/; /* allow undefined references and record them */ +/ { + .... /* various properties for loader use; i.e. part id etc. */ + fragment@0 { + target = <&ocp>; + __overlay__ { + /* bar peripheral */ + bar { + compatible = "corp,bar"; + ... /* various properties and child nodes */ + } + }; + }; +}; + +Note that there's a target property that specifies the location where the +contents of the overlay node will be placed, and it references the node +in the foo.dts file. + +$ dtc -@ -O dtb -o bar.dtbo -b 0 bar.dts +$ fdtdump bar.dtbo +... +/ { + ... /* properties */ + fragment@0 { + target = <0xffffffff>; + __overlay__ { + bar { + compatible = "corp,bar"; + ... /* various properties and child nodes */ + } + }; + }; + __fixups__ { + ocp = "/fragment@0:target:0"; + }; +}; + +No __symbols__ node has been generated (no label in bar.dts). +Note that the target's ocp label is undefined, so the phandle +value is filled with the illegal value '0xffffffff', while a __fixups__ +node has been generated, which marks the location in the tree where +the label lookup should store the runtime phandle value of the ocp node. + +The format of the __fixups__ node entry is + +