Commit becfc3c8 authored by Grant Likely's avatar Grant Likely

Merge remote-tracking branch 'robh/for-next' into devicetree/next

parents ce32f859 0b34c1a4
File mode changed from 100755 to 100644
...@@ -211,3 +211,4 @@ xillybus Xillybus Ltd. ...@@ -211,3 +211,4 @@ xillybus Xillybus Ltd.
xlnx Xilinx xlnx Xilinx
zyxel ZyXEL Communications Corp. zyxel ZyXEL Communications Corp.
zarlink Zarlink Semiconductor zarlink Zarlink Semiconductor
zii Zodiac Inflight Innovations
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
#include <linux/string.h> #include <linux/string.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
typedef __be16 fdt16_t;
typedef __be32 fdt32_t;
typedef __be64 fdt64_t;
#define fdt16_to_cpu(x) be16_to_cpu(x) #define fdt16_to_cpu(x) be16_to_cpu(x)
#define cpu_to_fdt16(x) cpu_to_be16(x) #define cpu_to_fdt16(x) cpu_to_be16(x)
#define fdt32_to_cpu(x) be32_to_cpu(x) #define fdt32_to_cpu(x) be32_to_cpu(x)
......
...@@ -9,9 +9,6 @@ ...@@ -9,9 +9,6 @@
# Copyright (C) 2005-2009 Cavium Networks # Copyright (C) 2005-2009 Cavium Networks
# #
CFLAGS_octeon-platform.o = -I$(src)/../../../scripts/dtc/libfdt
CFLAGS_setup.o = -I$(src)/../../../scripts/dtc/libfdt
obj-y := cpu.o setup.o octeon-platform.o octeon-irq.o csrc-octeon.o obj-y := cpu.o setup.o octeon-platform.o octeon-irq.o csrc-octeon.o
obj-y += dma-octeon.o obj-y += dma-octeon.o
obj-y += octeon-memcpy.o obj-y += octeon-memcpy.o
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#ifndef __ASM_PROM_H #ifndef __ASM_PROM_H
#define __ASM_PROM_H #define __ASM_PROM_H
#ifdef CONFIG_OF #ifdef CONFIG_USE_OF
#include <linux/bug.h> #include <linux/bug.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/types.h> #include <linux/types.h>
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/of_fdt.h> #include <linux/of_fdt.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <asm/bootinfo.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/prom.h> #include <asm/prom.h>
......
...@@ -15,5 +15,3 @@ obj-y := sead3-lcd.o sead3-display.o sead3-init.o \ ...@@ -15,5 +15,3 @@ obj-y := sead3-lcd.o sead3-display.o sead3-init.o \
obj-y += leds-sead3.o obj-y += leds-sead3.o
obj-$(CONFIG_EARLY_PRINTK) += sead3-console.o obj-$(CONFIG_EARLY_PRINTK) += sead3-console.o
CFLAGS_sead3-setup.o = -I$(src)/../../../scripts/dtc/libfdt
...@@ -10,6 +10,10 @@ typedef u32 uint32_t; ...@@ -10,6 +10,10 @@ typedef u32 uint32_t;
typedef u64 uint64_t; typedef u64 uint64_t;
typedef unsigned long uintptr_t; typedef unsigned long uintptr_t;
typedef __be16 fdt16_t;
typedef __be32 fdt32_t;
typedef __be64 fdt64_t;
#define fdt16_to_cpu(x) be16_to_cpu(x) #define fdt16_to_cpu(x) be16_to_cpu(x)
#define cpu_to_fdt16(x) cpu_to_be16(x) #define cpu_to_fdt16(x) cpu_to_be16(x)
#define fdt32_to_cpu(x) be32_to_cpu(x) #define fdt32_to_cpu(x) be32_to_cpu(x)
......
...@@ -21,7 +21,9 @@ int of_setprop(const void *phandle, const char *name, const void *buf, ...@@ -21,7 +21,9 @@ int of_setprop(const void *phandle, const char *name, const void *buf,
/* Console functions */ /* Console functions */
void of_console_init(void); void of_console_init(void);
typedef u16 __be16;
typedef u32 __be32; typedef u32 __be32;
typedef u64 __be64;
#ifdef __LITTLE_ENDIAN__ #ifdef __LITTLE_ENDIAN__
#define cpu_to_be16(x) swab16(x) #define cpu_to_be16(x) swab16(x)
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# Makefile for the linux kernel. # Makefile for the linux kernel.
# #
CFLAGS_prom.o = -I$(src)/../../../scripts/dtc/libfdt
CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"' CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
......
...@@ -24,8 +24,6 @@ KASAN_SANITIZE := n ...@@ -24,8 +24,6 @@ KASAN_SANITIZE := n
lib-y := efi-stub-helper.o lib-y := efi-stub-helper.o
lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o
CFLAGS_fdt.o += -I$(srctree)/scripts/dtc/libfdt/
# #
# arm64 puts the stub in the kernel proper, which will unnecessarily retain all # arm64 puts the stub in the kernel proper, which will unnecessarily retain all
# code indefinitely unless it is annotated as __init/__initdata/__initconst etc. # code indefinitely unless it is annotated as __init/__initdata/__initconst etc.
......
config DTC config DTC
bool bool
config OF menuconfig OF
bool bool "Device Tree and Open Firmware support"
help
This option enables the device tree infrastructure.
It is automatically selected by platforms that need it or can
be enabled manually for unittests, overlays or
compile-coverage.
menu "Device Tree and Open Firmware support" if OF
depends on OF
config OF_UNITTEST config OF_UNITTEST
bool "Device Tree runtime unit tests" bool "Device Tree runtime unit tests"
depends on OF_IRQ && OF_EARLY_FLATTREE depends on OF_IRQ
select OF_EARLY_FLATTREE
select OF_RESOLVE select OF_RESOLVE
help help
This option builds in test cases for the device tree infrastructure This option builds in test cases for the device tree infrastructure
...@@ -97,4 +102,4 @@ config OF_OVERLAY ...@@ -97,4 +102,4 @@ config OF_OVERLAY
While this option is selected automatically when needed, you can While this option is selected automatically when needed, you can
enable it manually to improve device tree unit test coverage. enable it manually to improve device tree unit test coverage.
endmenu # OF endif # OF
...@@ -16,6 +16,3 @@ obj-$(CONFIG_OF_RESOLVE) += resolver.o ...@@ -16,6 +16,3 @@ obj-$(CONFIG_OF_RESOLVE) += resolver.o
obj-$(CONFIG_OF_OVERLAY) += overlay.o obj-$(CONFIG_OF_OVERLAY) += overlay.o
obj-$(CONFIG_OF_UNITTEST) += unittest-data/ obj-$(CONFIG_OF_UNITTEST) += unittest-data/
CFLAGS_fdt.o = -I$(src)/../../scripts/dtc/libfdt
CFLAGS_fdt_address.o = -I$(src)/../../scripts/dtc/libfdt
...@@ -712,7 +712,7 @@ int __weak pci_register_io_range(phys_addr_t addr, resource_size_t size) ...@@ -712,7 +712,7 @@ int __weak pci_register_io_range(phys_addr_t addr, resource_size_t size)
} }
/* add the range to the list */ /* add the range to the list */
range = kzalloc(sizeof(*range), GFP_KERNEL); range = kzalloc(sizeof(*range), GFP_ATOMIC);
if (!range) { if (!range) {
err = -ENOMEM; err = -ENOMEM;
goto end_register; goto end_register;
......
...@@ -163,6 +163,18 @@ void of_device_unregister(struct platform_device *ofdev) ...@@ -163,6 +163,18 @@ void of_device_unregister(struct platform_device *ofdev)
} }
EXPORT_SYMBOL(of_device_unregister); EXPORT_SYMBOL(of_device_unregister);
const void *of_device_get_match_data(const struct device *dev)
{
const struct of_device_id *match;
match = of_match_device(dev->driver->of_match_table, dev);
if (!match)
return NULL;
return match->data;
}
EXPORT_SYMBOL(of_device_get_match_data);
ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len) ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
{ {
const char *compat; const char *compat;
......
...@@ -171,7 +171,7 @@ static void *unflatten_dt_alloc(void **mem, unsigned long size, ...@@ -171,7 +171,7 @@ static void *unflatten_dt_alloc(void **mem, unsigned long size,
* @dryrun: If true, do not allocate device nodes but still calculate needed * @dryrun: If true, do not allocate device nodes but still calculate needed
* memory size * memory size
*/ */
static void * unflatten_dt_node(void *blob, static void * unflatten_dt_node(const void *blob,
void *mem, void *mem,
int *poffset, int *poffset,
struct device_node *dad, struct device_node *dad,
...@@ -381,7 +381,7 @@ static void * unflatten_dt_node(void *blob, ...@@ -381,7 +381,7 @@ static void * unflatten_dt_node(void *blob,
* @dt_alloc: An allocator that provides a virtual address to memory * @dt_alloc: An allocator that provides a virtual address to memory
* for the resulting tree * for the resulting tree
*/ */
static void __unflatten_device_tree(void *blob, static void __unflatten_device_tree(const void *blob,
struct device_node **mynodes, struct device_node **mynodes,
void * (*dt_alloc)(u64 size, u64 align)) void * (*dt_alloc)(u64 size, u64 align))
{ {
...@@ -444,7 +444,7 @@ static void *kernel_tree_alloc(u64 size, u64 align) ...@@ -444,7 +444,7 @@ static void *kernel_tree_alloc(u64 size, u64 align)
* pointers of the nodes so the normal device-tree walking functions * pointers of the nodes so the normal device-tree walking functions
* can be used. * can be used.
*/ */
void of_fdt_unflatten_tree(unsigned long *blob, void of_fdt_unflatten_tree(const unsigned long *blob,
struct device_node **mynodes) struct device_node **mynodes)
{ {
__unflatten_device_tree(blob, mynodes, &kernel_tree_alloc); __unflatten_device_tree(blob, mynodes, &kernel_tree_alloc);
...@@ -1018,6 +1018,11 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) ...@@ -1018,6 +1018,11 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align)
return __va(memblock_alloc(size, align)); return __va(memblock_alloc(size, align));
} }
#else #else
void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
{
WARN_ON(1);
}
int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base,
phys_addr_t size, bool nomap) phys_addr_t size, bool nomap)
{ {
...@@ -1025,6 +1030,12 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, ...@@ -1025,6 +1030,12 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base,
&base, &size, nomap ? " (nomap)" : ""); &base, &size, nomap ? " (nomap)" : "");
return -ENOSYS; return -ENOSYS;
} }
void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align)
{
WARN_ON(1);
return NULL;
}
#endif #endif
bool __init early_init_dt_verify(void *params) bool __init early_init_dt_verify(void *params)
......
...@@ -333,7 +333,7 @@ static DEFINE_IDR(ov_idr); ...@@ -333,7 +333,7 @@ static DEFINE_IDR(ov_idr);
* of the overlay in a list. This list can be used to prevent * of the overlay in a list. This list can be used to prevent
* illegal overlay removals. * illegal overlay removals.
* *
* Returns the id of the created overlay, or an negative error number * Returns the id of the created overlay, or a negative error number
*/ */
int of_overlay_create(struct device_node *tree) int of_overlay_create(struct device_node *tree)
{ {
...@@ -481,7 +481,7 @@ static int overlay_removal_is_ok(struct of_overlay *ov) ...@@ -481,7 +481,7 @@ static int overlay_removal_is_ok(struct of_overlay *ov)
* *
* Removes an overlay if it is permissible. * Removes an overlay if it is permissible.
* *
* Returns 0 on success, or an negative error number * Returns 0 on success, or a negative error number
*/ */
int of_overlay_destroy(int id) int of_overlay_destroy(int id)
{ {
...@@ -528,7 +528,7 @@ EXPORT_SYMBOL_GPL(of_overlay_destroy); ...@@ -528,7 +528,7 @@ EXPORT_SYMBOL_GPL(of_overlay_destroy);
* *
* Removes all overlays from the system in the correct order. * Removes all overlays from the system in the correct order.
* *
* Returns 0 on success, or an negative error number * Returns 0 on success, or a negative error number
*/ */
int of_overlay_destroy_all(void) int of_overlay_destroy_all(void)
{ {
......
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
#include <asm/byteorder.h> #include <asm/byteorder.h>
typedef __be16 fdt16_t;
typedef __be32 fdt32_t;
typedef __be64 fdt64_t;
#define fdt32_to_cpu(x) be32_to_cpu(x) #define fdt32_to_cpu(x) be32_to_cpu(x)
#define cpu_to_fdt32(x) cpu_to_be32(x) #define cpu_to_fdt32(x) cpu_to_be32(x)
#define fdt64_to_cpu(x) be64_to_cpu(x) #define fdt64_to_cpu(x) be64_to_cpu(x)
......
...@@ -120,6 +120,12 @@ extern struct device_node *of_aliases; ...@@ -120,6 +120,12 @@ extern struct device_node *of_aliases;
extern struct device_node *of_stdout; extern struct device_node *of_stdout;
extern raw_spinlock_t devtree_lock; extern raw_spinlock_t devtree_lock;
/* flag descriptions (need to be visible even when !CONFIG_OF) */
#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
#define OF_DETACHED 2 /* node has been detached from the device tree */
#define OF_POPULATED 3 /* device already created for the node */
#define OF_POPULATED_BUS 4 /* of_platform_populate recursed to children of this node */
#ifdef CONFIG_OF #ifdef CONFIG_OF
static inline bool is_of_node(struct fwnode_handle *fwnode) static inline bool is_of_node(struct fwnode_handle *fwnode)
{ {
...@@ -217,12 +223,6 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size) ...@@ -217,12 +223,6 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size)
#define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) #define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
#endif #endif
/* flag descriptions */
#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
#define OF_DETACHED 2 /* node has been detached from the device tree */
#define OF_POPULATED 3 /* device already created for the node */
#define OF_POPULATED_BUS 4 /* of_platform_populate recursed to children of this node */
#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
...@@ -422,6 +422,11 @@ static inline struct device_node *of_find_node_opts_by_path(const char *path, ...@@ -422,6 +422,11 @@ static inline struct device_node *of_find_node_opts_by_path(const char *path,
return NULL; return NULL;
} }
static inline struct device_node *of_find_node_by_phandle(phandle handle)
{
return NULL;
}
static inline struct device_node *of_get_parent(const struct device_node *node) static inline struct device_node *of_get_parent(const struct device_node *node)
{ {
return NULL; return NULL;
...@@ -818,7 +823,7 @@ static inline int of_property_read_string_index(struct device_node *np, ...@@ -818,7 +823,7 @@ static inline int of_property_read_string_index(struct device_node *np,
* @propname: name of the property to be searched. * @propname: name of the property to be searched.
* *
* Search for a property in a device node. * Search for a property in a device node.
* Returns true if the property exist false otherwise. * Returns true if the property exists false otherwise.
*/ */
static inline bool of_property_read_bool(const struct device_node *np, static inline bool of_property_read_bool(const struct device_node *np,
const char *propname) const char *propname)
......
...@@ -33,6 +33,8 @@ extern int of_device_add(struct platform_device *pdev); ...@@ -33,6 +33,8 @@ extern int of_device_add(struct platform_device *pdev);
extern int of_device_register(struct platform_device *ofdev); extern int of_device_register(struct platform_device *ofdev);
extern void of_device_unregister(struct platform_device *ofdev); extern void of_device_unregister(struct platform_device *ofdev);
extern const void *of_device_get_match_data(const struct device *dev);
extern ssize_t of_device_get_modalias(struct device *dev, extern ssize_t of_device_get_modalias(struct device *dev,
char *str, ssize_t len); char *str, ssize_t len);
...@@ -65,6 +67,11 @@ static inline int of_driver_match_device(struct device *dev, ...@@ -65,6 +67,11 @@ static inline int of_driver_match_device(struct device *dev,
static inline void of_device_uevent(struct device *dev, static inline void of_device_uevent(struct device *dev,
struct kobj_uevent_env *env) { } struct kobj_uevent_env *env) { }
static inline const void *of_device_get_match_data(const struct device *dev)
{
return NULL;
}
static inline int of_device_get_modalias(struct device *dev, static inline int of_device_get_modalias(struct device *dev,
char *str, ssize_t len) char *str, ssize_t len)
{ {
......
...@@ -37,7 +37,7 @@ extern bool of_fdt_is_big_endian(const void *blob, ...@@ -37,7 +37,7 @@ extern bool of_fdt_is_big_endian(const void *blob,
unsigned long node); unsigned long node);
extern int of_fdt_match(const void *blob, unsigned long node, extern int of_fdt_match(const void *blob, unsigned long node,
const char *const *compat); const char *const *compat);
extern void of_fdt_unflatten_tree(unsigned long *blob, extern void of_fdt_unflatten_tree(const unsigned long *blob,
struct device_node **mynodes); struct device_node **mynodes);
/* TBD: Temporary export of fdt globals - remove when code fully merged */ /* TBD: Temporary export of fdt globals - remove when code fully merged */
......
...@@ -53,7 +53,7 @@ struct check { ...@@ -53,7 +53,7 @@ struct check {
void *data; void *data;
bool warn, error; bool warn, error;
enum checkstatus status; enum checkstatus status;
int inprogress; bool inprogress;
int num_prereqs; int num_prereqs;
struct check **prereq; struct check **prereq;
}; };
...@@ -113,6 +113,7 @@ static inline void check_msg(struct check *c, const char *fmt, ...) ...@@ -113,6 +113,7 @@ static inline void check_msg(struct check *c, const char *fmt, ...)
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
va_end(ap);
} }
#define FAIL(c, ...) \ #define FAIL(c, ...) \
...@@ -141,9 +142,9 @@ static void check_nodes_props(struct check *c, struct node *dt, struct node *nod ...@@ -141,9 +142,9 @@ static void check_nodes_props(struct check *c, struct node *dt, struct node *nod
check_nodes_props(c, dt, child); check_nodes_props(c, dt, child);
} }
static int run_check(struct check *c, struct node *dt) static bool run_check(struct check *c, struct node *dt)
{ {
int error = 0; bool error = false;
int i; int i;
assert(!c->inprogress); assert(!c->inprogress);
...@@ -151,11 +152,11 @@ static int run_check(struct check *c, struct node *dt) ...@@ -151,11 +152,11 @@ static int run_check(struct check *c, struct node *dt)
if (c->status != UNCHECKED) if (c->status != UNCHECKED)
goto out; goto out;
c->inprogress = 1; c->inprogress = true;
for (i = 0; i < c->num_prereqs; i++) { for (i = 0; i < c->num_prereqs; i++) {
struct check *prq = c->prereq[i]; struct check *prq = c->prereq[i];
error |= run_check(prq, dt); error = error || run_check(prq, dt);
if (prq->status != PASSED) { if (prq->status != PASSED) {
c->status = PREREQ; c->status = PREREQ;
check_msg(c, "Failed prerequisite '%s'", check_msg(c, "Failed prerequisite '%s'",
...@@ -177,9 +178,9 @@ static int run_check(struct check *c, struct node *dt) ...@@ -177,9 +178,9 @@ static int run_check(struct check *c, struct node *dt)
TRACE(c, "\tCompleted, status %d", c->status); TRACE(c, "\tCompleted, status %d", c->status);
out: out:
c->inprogress = 0; c->inprogress = false;
if ((c->status != PASSED) && (c->error)) if ((c->status != PASSED) && (c->error))
error = 1; error = true;
return error; return error;
} }
...@@ -624,11 +625,11 @@ static void check_avoid_default_addr_size(struct check *c, struct node *dt, ...@@ -624,11 +625,11 @@ static void check_avoid_default_addr_size(struct check *c, struct node *dt,
if (!reg && !ranges) if (!reg && !ranges)
return; return;
if ((node->parent->addr_cells == -1)) if (node->parent->addr_cells == -1)
FAIL(c, "Relying on default #address-cells value for %s", FAIL(c, "Relying on default #address-cells value for %s",
node->fullpath); node->fullpath);
if ((node->parent->size_cells == -1)) if (node->parent->size_cells == -1)
FAIL(c, "Relying on default #size-cells value for %s", FAIL(c, "Relying on default #size-cells value for %s",
node->fullpath); node->fullpath);
} }
...@@ -706,15 +707,15 @@ static void disable_warning_error(struct check *c, bool warn, bool error) ...@@ -706,15 +707,15 @@ static void disable_warning_error(struct check *c, bool warn, bool error)
c->error = c->error && !error; c->error = c->error && !error;
} }
void parse_checks_option(bool warn, bool error, const char *optarg) void parse_checks_option(bool warn, bool error, const char *arg)
{ {
int i; int i;
const char *name = optarg; const char *name = arg;
bool enable = true; bool enable = true;
if ((strncmp(optarg, "no-", 3) == 0) if ((strncmp(arg, "no-", 3) == 0)
|| (strncmp(optarg, "no_", 3) == 0)) { || (strncmp(arg, "no_", 3) == 0)) {
name = optarg + 3; name = arg + 3;
enable = false; enable = false;
} }
...@@ -733,7 +734,7 @@ void parse_checks_option(bool warn, bool error, const char *optarg) ...@@ -733,7 +734,7 @@ void parse_checks_option(bool warn, bool error, const char *optarg)
die("Unrecognized check name \"%s\"\n", name); die("Unrecognized check name \"%s\"\n", name);
} }
void process_checks(int force, struct boot_info *bi) void process_checks(bool force, struct boot_info *bi)
{ {
struct node *dt = bi->dt; struct node *dt = bi->dt;
int i; int i;
......
...@@ -74,7 +74,7 @@ struct data data_copy_escape_string(const char *s, int len) ...@@ -74,7 +74,7 @@ struct data data_copy_escape_string(const char *s, int len)
struct data d; struct data d;
char *q; char *q;
d = data_grow_for(empty_data, strlen(s)+1); d = data_grow_for(empty_data, len + 1);
q = d.val; q = d.val;
while (i < len) { while (i < len) {
...@@ -250,20 +250,20 @@ struct data data_add_marker(struct data d, enum markertype type, char *ref) ...@@ -250,20 +250,20 @@ struct data data_add_marker(struct data d, enum markertype type, char *ref)
return data_append_markers(d, m); return data_append_markers(d, m);
} }
int data_is_one_string(struct data d) bool data_is_one_string(struct data d)
{ {
int i; int i;
int len = d.len; int len = d.len;
if (len == 0) if (len == 0)
return 0; return false;
for (i = 0; i < len-1; i++) for (i = 0; i < len-1; i++)
if (d.val[i] == '\0') if (d.val[i] == '\0')
return 0; return false;
if (d.val[len-1] != '\0') if (d.val[len-1] != '\0')
return 0; return false;
return 1; return true;
} }
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
%option noyywrap nounput noinput never-interactive %option noyywrap nounput noinput never-interactive
%x INCLUDE
%x BYTESTRING %x BYTESTRING
%x PROPNODENAME %x PROPNODENAME
%s V1 %s V1
...@@ -40,6 +39,7 @@ LINECOMMENT "//".*\n ...@@ -40,6 +39,7 @@ LINECOMMENT "//".*\n
#include "dtc-parser.tab.h" #include "dtc-parser.tab.h"
YYLTYPE yylloc; YYLTYPE yylloc;
extern bool treesource_error;
/* CAUTION: this will stop working if we ever use yyless() or yyunput() */ /* CAUTION: this will stop working if we ever use yyless() or yyunput() */
#define YY_USER_ACTION \ #define YY_USER_ACTION \
...@@ -61,7 +61,8 @@ static int dts_version = 1; ...@@ -61,7 +61,8 @@ static int dts_version = 1;
BEGIN(V1); \ BEGIN(V1); \
static void push_input_file(const char *filename); static void push_input_file(const char *filename);
static int pop_input_file(void); static bool pop_input_file(void);
static void lexical_error(const char *fmt, ...);
%} %}
%% %%
...@@ -75,11 +76,11 @@ static int pop_input_file(void); ...@@ -75,11 +76,11 @@ static int pop_input_file(void);
char *line, *tmp, *fn; char *line, *tmp, *fn;
/* skip text before line # */ /* skip text before line # */
line = yytext; line = yytext;
while (!isdigit(*line)) while (!isdigit((unsigned char)*line))
line++; line++;
/* skip digits in line # */ /* skip digits in line # */
tmp = line; tmp = line;
while (!isspace(*tmp)) while (!isspace((unsigned char)*tmp))
tmp++; tmp++;
/* "NULL"-terminate line # */ /* "NULL"-terminate line # */
*tmp = '\0'; *tmp = '\0';
...@@ -146,15 +147,42 @@ static int pop_input_file(void); ...@@ -146,15 +147,42 @@ static int pop_input_file(void);
} }
<V1>([0-9]+|0[xX][0-9a-fA-F]+)(U|L|UL|LL|ULL)? { <V1>([0-9]+|0[xX][0-9a-fA-F]+)(U|L|UL|LL|ULL)? {
yylval.literal = xstrdup(yytext); char *e;
DPRINT("Literal: '%s'\n", yylval.literal); DPRINT("Integer Literal: '%s'\n", yytext);
errno = 0;
yylval.integer = strtoull(yytext, &e, 0);
assert(!(*e) || !e[strspn(e, "UL")]);
if (errno == ERANGE)
lexical_error("Integer literal '%s' out of range",
yytext);
else
/* ERANGE is the only strtoull error triggerable
* by strings matching the pattern */
assert(errno == 0);
return DT_LITERAL; return DT_LITERAL;
} }
<*>{CHAR_LITERAL} { <*>{CHAR_LITERAL} {
yytext[yyleng-1] = '\0'; struct data d;
yylval.literal = xstrdup(yytext+1); DPRINT("Character literal: %s\n", yytext);
DPRINT("Character literal: %s\n", yylval.literal);
d = data_copy_escape_string(yytext+1, yyleng-2);
if (d.len == 1) {
lexical_error("Empty character literal");
yylval.integer = 0;
return DT_CHAR_LITERAL;
}
yylval.integer = (unsigned char)d.val[0];
if (d.len > 2)
lexical_error("Character literal has %d"
" characters instead of 1",
d.len - 1);
return DT_CHAR_LITERAL; return DT_CHAR_LITERAL;
} }
...@@ -164,7 +192,7 @@ static int pop_input_file(void); ...@@ -164,7 +192,7 @@ static int pop_input_file(void);
return DT_REF; return DT_REF;
} }
<*>"&{/"{PATHCHAR}+\} { /* new-style path reference */ <*>"&{/"{PATHCHAR}*\} { /* new-style path reference */
yytext[yyleng-1] = '\0'; yytext[yyleng-1] = '\0';
DPRINT("Ref: %s\n", yytext+2); DPRINT("Ref: %s\n", yytext+2);
yylval.labelref = xstrdup(yytext+2); yylval.labelref = xstrdup(yytext+2);
...@@ -238,13 +266,24 @@ static void push_input_file(const char *filename) ...@@ -238,13 +266,24 @@ static void push_input_file(const char *filename)
} }
static int pop_input_file(void) static bool pop_input_file(void)
{ {
if (srcfile_pop() == 0) if (srcfile_pop() == 0)
return 0; return false;
yypop_buffer_state(); yypop_buffer_state();
yyin = current_srcfile->f; yyin = current_srcfile->f;
return 1; return true;
}
static void lexical_error(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
srcpos_verror(&yylloc, "Lexical error", fmt, ap);
va_end(ap);
treesource_error = true;
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#define FLEX_SCANNER #define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35 #define YY_FLEX_SUBMINOR_VERSION 39
#if YY_FLEX_SUBMINOR_VERSION > 0 #if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA #define FLEX_BETA
#endif #endif
...@@ -162,7 +162,12 @@ typedef unsigned int flex_uint32_t; ...@@ -162,7 +162,12 @@ typedef unsigned int flex_uint32_t;
typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif #endif
extern int yyleng; #ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
extern yy_size_t yyleng;
extern FILE *yyin, *yyout; extern FILE *yyin, *yyout;
...@@ -171,6 +176,7 @@ extern FILE *yyin, *yyout; ...@@ -171,6 +176,7 @@ extern FILE *yyin, *yyout;
#define EOB_ACT_LAST_MATCH 2 #define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n) #define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */ /* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \ #define yyless(n) \
...@@ -188,11 +194,6 @@ extern FILE *yyin, *yyout; ...@@ -188,11 +194,6 @@ extern FILE *yyin, *yyout;
#define unput(c) yyunput( c, (yytext_ptr) ) #define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE #ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state struct yy_buffer_state
...@@ -210,7 +211,7 @@ struct yy_buffer_state ...@@ -210,7 +211,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB /* Number of characters read into yy_ch_buf, not including EOB
* characters. * characters.
*/ */
int yy_n_chars; yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it, /* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to * and can realloc() it to grow it, and should free() it to
...@@ -280,8 +281,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ ...@@ -280,8 +281,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* yy_hold_char holds the character lost when yytext is formed. */ /* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char; static char yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */ static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
int yyleng; yy_size_t yyleng;
/* Points to current character in buffer. */ /* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0; static char *yy_c_buf_p = (char *) 0;
...@@ -309,7 +310,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); ...@@ -309,7 +310,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
void *yyalloc (yy_size_t ); void *yyalloc (yy_size_t );
void *yyrealloc (void *,yy_size_t ); void *yyrealloc (void *,yy_size_t );
...@@ -341,7 +342,7 @@ void yyfree (void * ); ...@@ -341,7 +342,7 @@ void yyfree (void * );
/* Begin user sect3 */ /* Begin user sect3 */
#define yywrap(n) 1 #define yywrap() 1
#define YY_SKIP_YYWRAP #define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR; typedef unsigned char YY_CHAR;
...@@ -381,25 +382,25 @@ struct yy_trans_info ...@@ -381,25 +382,25 @@ struct yy_trans_info
flex_int32_t yy_verify; flex_int32_t yy_verify;
flex_int32_t yy_nxt; flex_int32_t yy_nxt;
}; };
static yyconst flex_int16_t yy_accept[161] = static yyconst flex_int16_t yy_accept[159] =
{ 0, { 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 29,
31, 29, 18, 18, 29, 29, 29, 29, 29, 29, 18, 18, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 15, 16, 29, 29, 29, 29, 29, 29, 15, 16, 16, 29,
16, 29, 16, 10, 10, 18, 26, 0, 3, 0, 16, 10, 10, 18, 26, 0, 3, 0, 27, 12,
27, 12, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0,
0, 0, 21, 23, 25, 24, 22, 0, 9, 28, 21, 23, 25, 24, 22, 0, 9, 28, 0, 0,
0, 0, 0, 14, 14, 16, 16, 16, 10, 10, 0, 14, 14, 16, 16, 16, 10, 10, 10, 0,
10, 0, 12, 0, 11, 0, 0, 0, 20, 0, 12, 0, 11, 0, 0, 0, 20, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 16, 10, 10, 0, 0, 0, 0, 0, 16, 10, 10, 10, 0,
10, 0, 19, 0, 0, 0, 0, 0, 0, 0, 13, 19, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 16, 13, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 6, 0, 0, 0, 0, 0, 0, 16, 6, 0, 0, 0, 0, 0, 0, 2,
0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17,
4, 17, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 5, 8, 0, 0, 0, 0, 7, 0 5, 8, 0, 0, 0, 0, 7, 0
} ; } ;
static yyconst flex_int32_t yy_ec[256] = static yyconst flex_int32_t yy_ec[256] =
...@@ -440,157 +441,157 @@ static yyconst flex_int32_t yy_meta[47] = ...@@ -440,157 +441,157 @@ static yyconst flex_int32_t yy_meta[47] =
2, 2, 4, 5, 5, 5, 6, 1, 1, 1, 2, 2, 4, 5, 5, 5, 6, 1, 1, 1,
7, 8, 8, 8, 8, 1, 1, 7, 7, 7, 7, 8, 8, 8, 8, 1, 1, 7, 7, 7,
7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 3, 1, 1 8, 8, 8, 3, 1, 4
} ; } ;
static yyconst flex_int16_t yy_base[175] = static yyconst flex_int16_t yy_base[173] =
{ 0, { 0,
0, 385, 378, 40, 41, 383, 72, 382, 34, 44, 0, 383, 34, 382, 65, 381, 37, 105, 387, 391,
388, 393, 61, 117, 368, 116, 115, 115, 115, 48, 54, 111, 367, 110, 109, 109, 112, 41, 366, 104,
367, 107, 368, 339, 127, 120, 0, 147, 393, 0, 367, 338, 124, 117, 0, 144, 391, 0, 121, 0,
127, 0, 133, 156, 168, 153, 393, 125, 393, 380, 135, 155, 140, 179, 391, 160, 391, 379, 391, 0,
393, 0, 369, 127, 393, 160, 371, 377, 347, 21, 368, 141, 391, 167, 370, 376, 346, 103, 342, 345,
343, 346, 393, 393, 393, 393, 393, 359, 393, 393, 391, 391, 391, 391, 391, 358, 391, 391, 175, 342,
183, 343, 339, 393, 356, 0, 183, 340, 187, 348, 338, 391, 355, 0, 185, 339, 184, 347, 346, 0,
347, 0, 0, 0, 178, 359, 195, 365, 354, 326, 0, 322, 175, 357, 175, 363, 352, 324, 330, 323,
332, 325, 334, 328, 204, 326, 331, 324, 393, 335, 332, 326, 201, 324, 329, 322, 391, 333, 181, 309,
150, 311, 343, 342, 315, 322, 340, 179, 313, 207, 391, 341, 340, 313, 320, 338, 178, 311, 146, 317,
319, 316, 317, 393, 337, 333, 305, 302, 311, 301, 314, 315, 335, 331, 303, 300, 309, 299, 308, 188,
310, 190, 338, 337, 393, 307, 322, 301, 305, 277, 336, 335, 391, 305, 320, 281, 283, 271, 203, 288,
208, 311, 307, 278, 271, 270, 248, 246, 213, 130, 281, 271, 266, 264, 245, 242, 208, 104, 391, 391,
393, 393, 263, 235, 207, 221, 218, 229, 213, 213, 244, 218, 204, 219, 206, 224, 201, 212, 204, 229,
206, 234, 218, 210, 208, 193, 219, 393, 223, 204, 215, 208, 207, 200, 219, 391, 233, 221, 200, 181,
176, 157, 393, 393, 120, 106, 97, 119, 393, 393, 391, 391, 149, 122, 86, 41, 391, 391, 245, 251,
245, 251, 259, 263, 267, 273, 280, 284, 292, 300, 259, 263, 267, 273, 280, 284, 292, 300, 304, 310,
304, 310, 318, 326 318, 326
} ; } ;
static yyconst flex_int16_t yy_def[175] = static yyconst flex_int16_t yy_def[173] =
{ 0, { 0,
160, 1, 1, 1, 1, 5, 160, 7, 1, 1, 158, 1, 1, 3, 158, 5, 1, 1, 158, 158,
160, 160, 160, 160, 160, 161, 162, 163, 160, 160, 158, 158, 158, 159, 160, 161, 158, 158, 158, 158,
160, 160, 164, 160, 160, 160, 165, 164, 160, 166, 162, 158, 158, 158, 163, 162, 158, 164, 165, 164,
167, 166, 166, 160, 160, 160, 160, 161, 160, 161, 164, 158, 158, 158, 158, 159, 158, 159, 158, 166,
160, 168, 160, 163, 160, 163, 169, 170, 160, 160, 158, 161, 158, 161, 167, 168, 158, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 164, 160, 160, 158, 158, 158, 158, 158, 162, 158, 158, 158, 158,
160, 160, 160, 160, 164, 166, 167, 166, 160, 160, 158, 158, 162, 164, 165, 164, 158, 158, 158, 169,
160, 171, 168, 172, 163, 169, 169, 170, 160, 160, 166, 170, 161, 167, 167, 168, 158, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 166, 160, 160, 158, 158, 158, 158, 158, 164, 158, 158, 169, 170,
171, 172, 160, 160, 160, 160, 160, 160, 160, 160, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 166, 160, 160, 160, 160, 160, 160, 160, 158, 164, 158, 158, 158, 158, 158, 158, 158, 171,
160, 173, 160, 166, 160, 160, 160, 160, 160, 160, 158, 164, 158, 158, 158, 158, 158, 158, 171, 158,
173, 160, 173, 160, 160, 160, 160, 160, 160, 160, 171, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 174, 160, 160, 160, 174, 160, 174, 160, 172, 158, 158, 158, 172, 158, 172, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 160, 160, 0, 158, 158, 158, 158, 158, 158, 158, 0, 158, 158,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 160, 160 158, 158
} ; } ;
static yyconst flex_int16_t yy_nxt[440] = static yyconst flex_int16_t yy_nxt[438] =
{ 0, { 0,
12, 13, 14, 13, 15, 16, 12, 17, 18, 12, 10, 11, 12, 11, 13, 14, 10, 15, 16, 10,
12, 12, 19, 12, 12, 12, 12, 20, 21, 22, 10, 10, 17, 10, 10, 10, 10, 18, 19, 20,
23, 23, 23, 23, 23, 12, 12, 23, 23, 23, 21, 21, 21, 21, 21, 10, 10, 21, 21, 21,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
23, 23, 23, 12, 24, 12, 25, 34, 35, 35, 21, 21, 21, 10, 22, 10, 24, 25, 25, 25,
25, 81, 26, 26, 27, 27, 27, 34, 35, 35, 32, 33, 33, 157, 26, 34, 34, 34, 51, 52,
82, 28, 36, 36, 36, 53, 54, 29, 28, 28, 27, 26, 26, 26, 26, 10, 11, 12, 11, 13,
28, 28, 12, 13, 14, 13, 15, 16, 30, 17, 14, 28, 15, 16, 28, 28, 28, 24, 28, 28,
18, 30, 30, 30, 26, 30, 30, 30, 12, 20, 28, 10, 18, 19, 20, 29, 29, 29, 29, 29,
21, 22, 31, 31, 31, 31, 31, 32, 12, 31, 30, 10, 29, 29, 29, 29, 29, 29, 29, 29,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 29, 29, 29, 29, 29, 29, 29, 29, 10, 22,
31, 31, 31, 31, 31, 12, 24, 12, 36, 36, 10, 23, 34, 34, 34, 37, 39, 43, 32, 33,
36, 39, 41, 45, 47, 56, 57, 48, 61, 47, 33, 45, 54, 55, 46, 59, 45, 64, 156, 46,
39, 159, 48, 66, 61, 45, 66, 66, 66, 158, 64, 64, 64, 79, 44, 38, 59, 57, 134, 47,
46, 40, 49, 59, 50, 157, 51, 49, 52, 50, 135, 48, 80, 49, 47, 50, 48, 99, 61, 43,
40, 63, 46, 52, 36, 36, 36, 156, 43, 62, 50, 110, 41, 67, 67, 67, 60, 63, 63, 63,
65, 65, 65, 59, 136, 68, 137, 65, 75, 69, 57, 155, 68, 69, 63, 37, 44, 66, 67, 67,
69, 69, 70, 71, 65, 65, 65, 65, 70, 71, 67, 63, 63, 63, 63, 73, 59, 68, 69, 70,
72, 69, 69, 69, 61, 46, 45, 155, 154, 66, 34, 34, 34, 43, 75, 38, 154, 92, 83, 83,
70, 71, 66, 66, 66, 122, 85, 85, 85, 59, 83, 64, 44, 120, 64, 64, 64, 67, 67, 67,
69, 69, 69, 46, 77, 100, 109, 93, 100, 70, 44, 57, 99, 68, 69, 107, 68, 69, 120, 127,
71, 110, 112, 122, 129, 123, 153, 85, 85, 85, 108, 153, 152, 121, 83, 83, 83, 133, 133, 133,
135, 135, 135, 148, 148, 160, 135, 135, 135, 152, 146, 133, 133, 133, 146, 140, 140, 140, 121, 141,
142, 142, 142, 123, 143, 142, 142, 142, 151, 143, 140, 140, 140, 151, 141, 158, 150, 149, 148, 144,
150, 146, 145, 149, 149, 38, 38, 38, 38, 38, 147, 143, 142, 139, 147, 36, 36, 36, 36, 36,
38, 38, 38, 42, 144, 141, 140, 42, 42, 44, 36, 36, 36, 40, 138, 137, 136, 40, 40, 42,
44, 44, 44, 44, 44, 44, 44, 58, 58, 58, 42, 42, 42, 42, 42, 42, 42, 56, 56, 56,
58, 64, 139, 64, 66, 138, 134, 66, 133, 66, 56, 62, 132, 62, 64, 131, 130, 64, 129, 64,
66, 67, 132, 131, 67, 67, 67, 67, 73, 130, 64, 65, 128, 158, 65, 65, 65, 65, 71, 127,
73, 73, 76, 76, 76, 76, 76, 76, 76, 76, 71, 71, 74, 74, 74, 74, 74, 74, 74, 74,
78, 78, 78, 78, 78, 78, 78, 78, 91, 160, 76, 76, 76, 76, 76, 76, 76, 76, 89, 126,
91, 92, 129, 92, 92, 128, 92, 92, 121, 121, 89, 90, 125, 90, 90, 124, 90, 90, 119, 119,
121, 121, 121, 121, 121, 121, 147, 147, 147, 147, 119, 119, 119, 119, 119, 119, 145, 145, 145, 145,
147, 147, 147, 147, 127, 126, 125, 124, 61, 61, 145, 145, 145, 145, 123, 122, 59, 59, 118, 117,
120, 119, 118, 117, 116, 115, 47, 114, 110, 113, 116, 115, 114, 113, 45, 112, 108, 111, 109, 106,
111, 108, 107, 106, 48, 105, 104, 89, 103, 102, 105, 104, 46, 103, 91, 87, 102, 101, 100, 98,
101, 99, 98, 97, 96, 95, 94, 79, 77, 90, 97, 96, 95, 94, 93, 77, 75, 91, 88, 87,
89, 88, 59, 87, 86, 59, 84, 83, 80, 79, 86, 57, 85, 84, 57, 82, 81, 78, 77, 75,
77, 74, 160, 60, 59, 55, 37, 160, 33, 25, 72, 158, 58, 57, 53, 35, 158, 31, 23, 23,
26, 25, 11, 160, 160, 160, 160, 160, 160, 160, 9, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 160, 160 158, 158, 158, 158, 158, 158, 158
} ; } ;
static yyconst flex_int16_t yy_chk[440] = static yyconst flex_int16_t yy_chk[438] =
{ 0, { 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 4, 9, 9, 9, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3,
10, 50, 4, 5, 5, 5, 5, 10, 10, 10, 7, 7, 7, 156, 3, 11, 11, 11, 18, 18,
50, 5, 13, 13, 13, 20, 20, 5, 5, 5, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5,
5, 5, 7, 7, 7, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
7, 7, 7, 7, 7, 7, 7, 7, 14, 14, 5, 8, 12, 12, 12, 14, 15, 16, 8, 8,
14, 16, 17, 18, 19, 22, 22, 19, 25, 26, 8, 17, 20, 20, 17, 23, 24, 29, 155, 24,
38, 158, 26, 31, 33, 44, 31, 31, 31, 157, 29, 29, 29, 48, 16, 14, 31, 29, 128, 17,
18, 16, 19, 31, 19, 156, 19, 26, 19, 26, 128, 17, 48, 17, 24, 17, 24, 99, 24, 42,
38, 26, 44, 26, 36, 36, 36, 155, 17, 25, 24, 99, 15, 33, 33, 33, 23, 26, 26, 26,
28, 28, 28, 28, 130, 33, 130, 28, 46, 34, 26, 154, 33, 33, 26, 36, 42, 31, 32, 32,
34, 34, 91, 91, 28, 28, 28, 28, 34, 34, 32, 26, 26, 26, 26, 44, 59, 32, 32, 32,
34, 35, 35, 35, 61, 46, 75, 152, 151, 67, 34, 34, 34, 73, 75, 36, 153, 75, 59, 59,
35, 35, 67, 67, 67, 112, 61, 61, 61, 67, 59, 65, 44, 110, 65, 65, 65, 67, 67, 67,
69, 69, 69, 75, 77, 85, 98, 77, 100, 69, 73, 65, 83, 89, 89, 97, 67, 67, 119, 127,
69, 98, 100, 121, 129, 112, 150, 85, 85, 85, 97, 150, 149, 110, 83, 83, 83, 133, 133, 133,
135, 135, 135, 143, 147, 149, 129, 129, 129, 146, 141, 127, 127, 127, 145, 136, 136, 136, 119, 136,
138, 138, 138, 121, 138, 142, 142, 142, 145, 142, 140, 140, 140, 148, 140, 147, 144, 143, 142, 139,
144, 141, 140, 143, 147, 161, 161, 161, 161, 161, 141, 138, 137, 135, 145, 159, 159, 159, 159, 159,
161, 161, 161, 162, 139, 137, 136, 162, 162, 163, 159, 159, 159, 160, 134, 132, 131, 160, 160, 161,
163, 163, 163, 163, 163, 163, 163, 164, 164, 164, 161, 161, 161, 161, 161, 161, 161, 162, 162, 162,
164, 165, 134, 165, 166, 133, 128, 166, 127, 166, 162, 163, 126, 163, 164, 125, 124, 164, 123, 164,
166, 167, 126, 125, 167, 167, 167, 167, 168, 124, 164, 165, 122, 121, 165, 165, 165, 165, 166, 120,
168, 168, 169, 169, 169, 169, 169, 169, 169, 169, 166, 166, 167, 167, 167, 167, 167, 167, 167, 167,
170, 170, 170, 170, 170, 170, 170, 170, 171, 123, 168, 168, 168, 168, 168, 168, 168, 168, 169, 118,
171, 172, 122, 172, 172, 120, 172, 172, 173, 173, 169, 170, 117, 170, 170, 116, 170, 170, 171, 171,
173, 173, 173, 173, 173, 173, 174, 174, 174, 174, 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
174, 174, 174, 174, 119, 118, 117, 116, 114, 113, 172, 172, 172, 172, 115, 114, 112, 111, 109, 108,
111, 110, 109, 108, 107, 106, 105, 103, 102, 101, 107, 106, 105, 104, 103, 102, 101, 100, 98, 96,
99, 97, 96, 95, 94, 93, 92, 90, 88, 87, 95, 94, 93, 92, 90, 88, 86, 85, 84, 82,
86, 84, 83, 82, 81, 80, 79, 78, 76, 71, 81, 80, 79, 78, 77, 76, 74, 72, 69, 68,
70, 68, 65, 63, 62, 58, 52, 51, 49, 48, 66, 63, 61, 60, 56, 50, 49, 47, 46, 45,
47, 43, 40, 24, 23, 21, 15, 11, 8, 6, 41, 38, 22, 21, 19, 13, 9, 6, 4, 2,
3, 2, 160, 160, 160, 160, 160, 160, 160, 160, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 160, 160 158, 158, 158, 158, 158, 158, 158
} ; } ;
static yy_state_type yy_last_accepting_state; static yy_state_type yy_last_accepting_state;
...@@ -631,13 +632,13 @@ char *yytext; ...@@ -631,13 +632,13 @@ char *yytext;
#line 37 "dtc-lexer.l"
#line 38 "dtc-lexer.l"
#include "dtc.h" #include "dtc.h"
#include "srcpos.h" #include "srcpos.h"
#include "dtc-parser.tab.h" #include "dtc-parser.tab.h"
YYLTYPE yylloc; YYLTYPE yylloc;
extern bool treesource_error;
/* CAUTION: this will stop working if we ever use yyless() or yyunput() */ /* CAUTION: this will stop working if we ever use yyless() or yyunput() */
#define YY_USER_ACTION \ #define YY_USER_ACTION \
...@@ -659,14 +660,14 @@ static int dts_version = 1; ...@@ -659,14 +660,14 @@ static int dts_version = 1;
BEGIN(V1); \ BEGIN(V1); \
static void push_input_file(const char *filename); static void push_input_file(const char *filename);
static int pop_input_file(void); static bool pop_input_file(void);
#line 664 "dtc-lexer.lex.c" static void lexical_error(const char *fmt, ...);
#line 666 "dtc-lexer.lex.c"
#define INITIAL 0 #define INITIAL 0
#define INCLUDE 1 #define BYTESTRING 1
#define BYTESTRING 2 #define PROPNODENAME 2
#define PROPNODENAME 3 #define V1 3
#define V1 4
#ifndef YY_NO_UNISTD_H #ifndef YY_NO_UNISTD_H
/* Special case for "unistd.h", since it is non-ANSI. We include it way /* Special case for "unistd.h", since it is non-ANSI. We include it way
...@@ -703,7 +704,7 @@ FILE *yyget_out (void ); ...@@ -703,7 +704,7 @@ FILE *yyget_out (void );
void yyset_out (FILE * out_str ); void yyset_out (FILE * out_str );
int yyget_leng (void ); yy_size_t yyget_leng (void );
char *yyget_text (void ); char *yyget_text (void );
...@@ -852,10 +853,6 @@ YY_DECL ...@@ -852,10 +853,6 @@ YY_DECL
register char *yy_cp, *yy_bp; register char *yy_cp, *yy_bp;
register int yy_act; register int yy_act;
#line 67 "dtc-lexer.l"
#line 858 "dtc-lexer.lex.c"
if ( !(yy_init) ) if ( !(yy_init) )
{ {
(yy_init) = 1; (yy_init) = 1;
...@@ -882,6 +879,11 @@ YY_DECL ...@@ -882,6 +879,11 @@ YY_DECL
yy_load_buffer_state( ); yy_load_buffer_state( );
} }
{
#line 68 "dtc-lexer.l"
#line 886 "dtc-lexer.lex.c"
while ( 1 ) /* loops until end-of-file is reached */ while ( 1 ) /* loops until end-of-file is reached */
{ {
yy_cp = (yy_c_buf_p); yy_cp = (yy_c_buf_p);
...@@ -899,7 +901,7 @@ YY_DECL ...@@ -899,7 +901,7 @@ YY_DECL
yy_match: yy_match:
do do
{ {
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] ) if ( yy_accept[yy_current_state] )
{ {
(yy_last_accepting_state) = yy_current_state; (yy_last_accepting_state) = yy_current_state;
...@@ -908,13 +910,13 @@ yy_match: ...@@ -908,13 +910,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 161 ) if ( yy_current_state >= 159 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp; ++yy_cp;
} }
while ( yy_current_state != 160 ); while ( yy_current_state != 158 );
yy_cp = (yy_last_accepting_cpos); yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state); yy_current_state = (yy_last_accepting_state);
...@@ -937,7 +939,7 @@ do_action: /* This label is used only to access EOF actions. */ ...@@ -937,7 +939,7 @@ do_action: /* This label is used only to access EOF actions. */
case 1: case 1:
/* rule 1 can match eol */ /* rule 1 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 68 "dtc-lexer.l" #line 69 "dtc-lexer.l"
{ {
char *name = strchr(yytext, '\"') + 1; char *name = strchr(yytext, '\"') + 1;
yytext[yyleng-1] = '\0'; yytext[yyleng-1] = '\0';
...@@ -947,16 +949,16 @@ YY_RULE_SETUP ...@@ -947,16 +949,16 @@ YY_RULE_SETUP
case 2: case 2:
/* rule 2 can match eol */ /* rule 2 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 74 "dtc-lexer.l" #line 75 "dtc-lexer.l"
{ {
char *line, *tmp, *fn; char *line, *tmp, *fn;
/* skip text before line # */ /* skip text before line # */
line = yytext; line = yytext;
while (!isdigit(*line)) while (!isdigit((unsigned char)*line))
line++; line++;
/* skip digits in line # */ /* skip digits in line # */
tmp = line; tmp = line;
while (!isspace(*tmp)) while (!isspace((unsigned char)*tmp))
tmp++; tmp++;
/* "NULL"-terminate line # */ /* "NULL"-terminate line # */
*tmp = '\0'; *tmp = '\0';
...@@ -970,11 +972,10 @@ YY_RULE_SETUP ...@@ -970,11 +972,10 @@ YY_RULE_SETUP
} }
YY_BREAK YY_BREAK
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(INCLUDE):
case YY_STATE_EOF(BYTESTRING): case YY_STATE_EOF(BYTESTRING):
case YY_STATE_EOF(PROPNODENAME): case YY_STATE_EOF(PROPNODENAME):
case YY_STATE_EOF(V1): case YY_STATE_EOF(V1):
#line 95 "dtc-lexer.l" #line 96 "dtc-lexer.l"
{ {
if (!pop_input_file()) { if (!pop_input_file()) {
yyterminate(); yyterminate();
...@@ -984,7 +985,7 @@ case YY_STATE_EOF(V1): ...@@ -984,7 +985,7 @@ case YY_STATE_EOF(V1):
case 3: case 3:
/* rule 3 can match eol */ /* rule 3 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 101 "dtc-lexer.l" #line 102 "dtc-lexer.l"
{ {
DPRINT("String: %s\n", yytext); DPRINT("String: %s\n", yytext);
yylval.data = data_copy_escape_string(yytext+1, yylval.data = data_copy_escape_string(yytext+1,
...@@ -994,7 +995,7 @@ YY_RULE_SETUP ...@@ -994,7 +995,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 108 "dtc-lexer.l" #line 109 "dtc-lexer.l"
{ {
DPRINT("Keyword: /dts-v1/\n"); DPRINT("Keyword: /dts-v1/\n");
dts_version = 1; dts_version = 1;
...@@ -1004,7 +1005,7 @@ YY_RULE_SETUP ...@@ -1004,7 +1005,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
#line 115 "dtc-lexer.l" #line 116 "dtc-lexer.l"
{ {
DPRINT("Keyword: /memreserve/\n"); DPRINT("Keyword: /memreserve/\n");
BEGIN_DEFAULT(); BEGIN_DEFAULT();
...@@ -1013,7 +1014,7 @@ YY_RULE_SETUP ...@@ -1013,7 +1014,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 6: case 6:
YY_RULE_SETUP YY_RULE_SETUP
#line 121 "dtc-lexer.l" #line 122 "dtc-lexer.l"
{ {
DPRINT("Keyword: /bits/\n"); DPRINT("Keyword: /bits/\n");
BEGIN_DEFAULT(); BEGIN_DEFAULT();
...@@ -1022,7 +1023,7 @@ YY_RULE_SETUP ...@@ -1022,7 +1023,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 7: case 7:
YY_RULE_SETUP YY_RULE_SETUP
#line 127 "dtc-lexer.l" #line 128 "dtc-lexer.l"
{ {
DPRINT("Keyword: /delete-property/\n"); DPRINT("Keyword: /delete-property/\n");
DPRINT("<PROPNODENAME>\n"); DPRINT("<PROPNODENAME>\n");
...@@ -1032,7 +1033,7 @@ YY_RULE_SETUP ...@@ -1032,7 +1033,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 8: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 134 "dtc-lexer.l" #line 135 "dtc-lexer.l"
{ {
DPRINT("Keyword: /delete-node/\n"); DPRINT("Keyword: /delete-node/\n");
DPRINT("<PROPNODENAME>\n"); DPRINT("<PROPNODENAME>\n");
...@@ -1042,7 +1043,7 @@ YY_RULE_SETUP ...@@ -1042,7 +1043,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 141 "dtc-lexer.l" #line 142 "dtc-lexer.l"
{ {
DPRINT("Label: %s\n", yytext); DPRINT("Label: %s\n", yytext);
yylval.labelref = xstrdup(yytext); yylval.labelref = xstrdup(yytext);
...@@ -1052,27 +1053,54 @@ YY_RULE_SETUP ...@@ -1052,27 +1053,54 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 148 "dtc-lexer.l" #line 149 "dtc-lexer.l"
{ {
yylval.literal = xstrdup(yytext); char *e;
DPRINT("Literal: '%s'\n", yylval.literal); DPRINT("Integer Literal: '%s'\n", yytext);
errno = 0;
yylval.integer = strtoull(yytext, &e, 0);
assert(!(*e) || !e[strspn(e, "UL")]);
if (errno == ERANGE)
lexical_error("Integer literal '%s' out of range",
yytext);
else
/* ERANGE is the only strtoull error triggerable
* by strings matching the pattern */
assert(errno == 0);
return DT_LITERAL; return DT_LITERAL;
} }
YY_BREAK YY_BREAK
case 11: case 11:
/* rule 11 can match eol */ /* rule 11 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 154 "dtc-lexer.l" #line 168 "dtc-lexer.l"
{ {
yytext[yyleng-1] = '\0'; struct data d;
yylval.literal = xstrdup(yytext+1); DPRINT("Character literal: %s\n", yytext);
DPRINT("Character literal: %s\n", yylval.literal);
d = data_copy_escape_string(yytext+1, yyleng-2);
if (d.len == 1) {
lexical_error("Empty character literal");
yylval.integer = 0;
return DT_CHAR_LITERAL;
}
yylval.integer = (unsigned char)d.val[0];
if (d.len > 2)
lexical_error("Character literal has %d"
" characters instead of 1",
d.len - 1);
return DT_CHAR_LITERAL; return DT_CHAR_LITERAL;
} }
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 161 "dtc-lexer.l" #line 189 "dtc-lexer.l"
{ /* label reference */ { /* label reference */
DPRINT("Ref: %s\n", yytext+1); DPRINT("Ref: %s\n", yytext+1);
yylval.labelref = xstrdup(yytext+1); yylval.labelref = xstrdup(yytext+1);
...@@ -1081,7 +1109,7 @@ YY_RULE_SETUP ...@@ -1081,7 +1109,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 167 "dtc-lexer.l" #line 195 "dtc-lexer.l"
{ /* new-style path reference */ { /* new-style path reference */
yytext[yyleng-1] = '\0'; yytext[yyleng-1] = '\0';
DPRINT("Ref: %s\n", yytext+2); DPRINT("Ref: %s\n", yytext+2);
...@@ -1091,7 +1119,7 @@ YY_RULE_SETUP ...@@ -1091,7 +1119,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 14: case 14:
YY_RULE_SETUP YY_RULE_SETUP
#line 174 "dtc-lexer.l" #line 202 "dtc-lexer.l"
{ {
yylval.byte = strtol(yytext, NULL, 16); yylval.byte = strtol(yytext, NULL, 16);
DPRINT("Byte: %02x\n", (int)yylval.byte); DPRINT("Byte: %02x\n", (int)yylval.byte);
...@@ -1100,7 +1128,7 @@ YY_RULE_SETUP ...@@ -1100,7 +1128,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 15: case 15:
YY_RULE_SETUP YY_RULE_SETUP
#line 180 "dtc-lexer.l" #line 208 "dtc-lexer.l"
{ {
DPRINT("/BYTESTRING\n"); DPRINT("/BYTESTRING\n");
BEGIN_DEFAULT(); BEGIN_DEFAULT();
...@@ -1109,7 +1137,7 @@ YY_RULE_SETUP ...@@ -1109,7 +1137,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 16: case 16:
YY_RULE_SETUP YY_RULE_SETUP
#line 186 "dtc-lexer.l" #line 214 "dtc-lexer.l"
{ {
DPRINT("PropNodeName: %s\n", yytext); DPRINT("PropNodeName: %s\n", yytext);
yylval.propnodename = xstrdup((yytext[0] == '\\') ? yylval.propnodename = xstrdup((yytext[0] == '\\') ?
...@@ -1120,7 +1148,7 @@ YY_RULE_SETUP ...@@ -1120,7 +1148,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 17: case 17:
YY_RULE_SETUP YY_RULE_SETUP
#line 194 "dtc-lexer.l" #line 222 "dtc-lexer.l"
{ {
DPRINT("Binary Include\n"); DPRINT("Binary Include\n");
return DT_INCBIN; return DT_INCBIN;
...@@ -1129,64 +1157,64 @@ YY_RULE_SETUP ...@@ -1129,64 +1157,64 @@ YY_RULE_SETUP
case 18: case 18:
/* rule 18 can match eol */ /* rule 18 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 199 "dtc-lexer.l" #line 227 "dtc-lexer.l"
/* eat whitespace */ /* eat whitespace */
YY_BREAK YY_BREAK
case 19: case 19:
/* rule 19 can match eol */ /* rule 19 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 200 "dtc-lexer.l" #line 228 "dtc-lexer.l"
/* eat C-style comments */ /* eat C-style comments */
YY_BREAK YY_BREAK
case 20: case 20:
/* rule 20 can match eol */ /* rule 20 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 201 "dtc-lexer.l" #line 229 "dtc-lexer.l"
/* eat C++-style comments */ /* eat C++-style comments */
YY_BREAK YY_BREAK
case 21: case 21:
YY_RULE_SETUP YY_RULE_SETUP
#line 203 "dtc-lexer.l" #line 231 "dtc-lexer.l"
{ return DT_LSHIFT; }; { return DT_LSHIFT; };
YY_BREAK YY_BREAK
case 22: case 22:
YY_RULE_SETUP YY_RULE_SETUP
#line 204 "dtc-lexer.l" #line 232 "dtc-lexer.l"
{ return DT_RSHIFT; }; { return DT_RSHIFT; };
YY_BREAK YY_BREAK
case 23: case 23:
YY_RULE_SETUP YY_RULE_SETUP
#line 205 "dtc-lexer.l" #line 233 "dtc-lexer.l"
{ return DT_LE; }; { return DT_LE; };
YY_BREAK YY_BREAK
case 24: case 24:
YY_RULE_SETUP YY_RULE_SETUP
#line 206 "dtc-lexer.l" #line 234 "dtc-lexer.l"
{ return DT_GE; }; { return DT_GE; };
YY_BREAK YY_BREAK
case 25: case 25:
YY_RULE_SETUP YY_RULE_SETUP
#line 207 "dtc-lexer.l" #line 235 "dtc-lexer.l"
{ return DT_EQ; }; { return DT_EQ; };
YY_BREAK YY_BREAK
case 26: case 26:
YY_RULE_SETUP YY_RULE_SETUP
#line 208 "dtc-lexer.l" #line 236 "dtc-lexer.l"
{ return DT_NE; }; { return DT_NE; };
YY_BREAK YY_BREAK
case 27: case 27:
YY_RULE_SETUP YY_RULE_SETUP
#line 209 "dtc-lexer.l" #line 237 "dtc-lexer.l"
{ return DT_AND; }; { return DT_AND; };
YY_BREAK YY_BREAK
case 28: case 28:
YY_RULE_SETUP YY_RULE_SETUP
#line 210 "dtc-lexer.l" #line 238 "dtc-lexer.l"
{ return DT_OR; }; { return DT_OR; };
YY_BREAK YY_BREAK
case 29: case 29:
YY_RULE_SETUP YY_RULE_SETUP
#line 212 "dtc-lexer.l" #line 240 "dtc-lexer.l"
{ {
DPRINT("Char: %c (\\x%02x)\n", yytext[0], DPRINT("Char: %c (\\x%02x)\n", yytext[0],
(unsigned)yytext[0]); (unsigned)yytext[0]);
...@@ -1204,10 +1232,10 @@ YY_RULE_SETUP ...@@ -1204,10 +1232,10 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 30: case 30:
YY_RULE_SETUP YY_RULE_SETUP
#line 227 "dtc-lexer.l" #line 255 "dtc-lexer.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1211 "dtc-lexer.lex.c" #line 1239 "dtc-lexer.lex.c"
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
{ {
...@@ -1337,6 +1365,7 @@ ECHO; ...@@ -1337,6 +1365,7 @@ ECHO;
"fatal flex scanner internal error--no action found" ); "fatal flex scanner internal error--no action found" );
} /* end of action switch */ } /* end of action switch */
} /* end of scanning one token */ } /* end of scanning one token */
} /* end of user's declarations */
} /* end of yylex */ } /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer /* yy_get_next_buffer - try to read in a new buffer
...@@ -1392,21 +1421,21 @@ static int yy_get_next_buffer (void) ...@@ -1392,21 +1421,21 @@ static int yy_get_next_buffer (void)
else else
{ {
int num_to_read = yy_size_t num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 ) while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */ { /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */ /* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER; YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
int yy_c_buf_p_offset = int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf); (int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer ) if ( b->yy_is_our_buffer )
{ {
int new_size = b->yy_buf_size * 2; yy_size_t new_size = b->yy_buf_size * 2;
if ( new_size <= 0 ) if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8; b->yy_buf_size += b->yy_buf_size / 8;
...@@ -1437,7 +1466,7 @@ static int yy_get_next_buffer (void) ...@@ -1437,7 +1466,7 @@ static int yy_get_next_buffer (void)
/* Read in more data. */ /* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
(yy_n_chars), (size_t) num_to_read ); (yy_n_chars), num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
} }
...@@ -1499,7 +1528,7 @@ static int yy_get_next_buffer (void) ...@@ -1499,7 +1528,7 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 161 ) if ( yy_current_state >= 159 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
...@@ -1527,11 +1556,11 @@ static int yy_get_next_buffer (void) ...@@ -1527,11 +1556,11 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 161 ) if ( yy_current_state >= 159 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 160); yy_is_jam = (yy_current_state == 158);
return yy_is_jam ? 0 : yy_current_state; return yy_is_jam ? 0 : yy_current_state;
} }
...@@ -1560,7 +1589,7 @@ static int yy_get_next_buffer (void) ...@@ -1560,7 +1589,7 @@ static int yy_get_next_buffer (void)
else else
{ /* need more input */ { /* need more input */
int offset = (yy_c_buf_p) - (yytext_ptr); yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p); ++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) ) switch ( yy_get_next_buffer( ) )
...@@ -1834,7 +1863,7 @@ void yypop_buffer_state (void) ...@@ -1834,7 +1863,7 @@ void yypop_buffer_state (void)
*/ */
static void yyensure_buffer_stack (void) static void yyensure_buffer_stack (void)
{ {
int num_to_alloc; yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) { if (!(yy_buffer_stack)) {
...@@ -1931,12 +1960,12 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) ...@@ -1931,12 +1960,12 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
* *
* @return the newly allocated buffer state object. * @return the newly allocated buffer state object.
*/ */
YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
{ {
YY_BUFFER_STATE b; YY_BUFFER_STATE b;
char *buf; char *buf;
yy_size_t n; yy_size_t n;
int i; yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */ /* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2; n = _yybytes_len + 2;
...@@ -2018,7 +2047,7 @@ FILE *yyget_out (void) ...@@ -2018,7 +2047,7 @@ FILE *yyget_out (void)
/** Get the length of the current token. /** Get the length of the current token.
* *
*/ */
int yyget_leng (void) yy_size_t yyget_leng (void)
{ {
return yyleng; return yyleng;
} }
...@@ -2166,7 +2195,7 @@ void yyfree (void * ptr ) ...@@ -2166,7 +2195,7 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables" #define YYTABLES_NAME "yytables"
#line 227 "dtc-lexer.l" #line 254 "dtc-lexer.l"
...@@ -2182,14 +2211,25 @@ static void push_input_file(const char *filename) ...@@ -2182,14 +2211,25 @@ static void push_input_file(const char *filename)
} }
static int pop_input_file(void) static bool pop_input_file(void)
{ {
if (srcfile_pop() == 0) if (srcfile_pop() == 0)
return 0; return false;
yypop_buffer_state(); yypop_buffer_state();
yyin = current_srcfile->f; yyin = current_srcfile->f;
return 1; return true;
}
static void lexical_error(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
srcpos_verror(&yylloc, "Lexical error", fmt, ap);
va_end(ap);
treesource_error = true;
} }
/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* A Bison parser, made by GNU Bison 3.0.2. */
/* Bison implementation for Yacc-like parsers in C /* Bison implementation for Yacc-like parsers in C
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#define YYBISON 1 #define YYBISON 1
/* Bison version. */ /* Bison version. */
#define YYBISON_VERSION "2.7.12-4996" #define YYBISON_VERSION "3.0.2"
/* Skeleton name. */ /* Skeleton name. */
#define YYSKELETON_NAME "yacc.c" #define YYSKELETON_NAME "yacc.c"
...@@ -62,34 +62,31 @@ ...@@ -62,34 +62,31 @@
/* Copy the first part of user declarations. */ /* Copy the first part of user declarations. */
/* Line 371 of yacc.c */ #line 20 "dtc-parser.y" /* yacc.c:339 */
#line 21 "dtc-parser.y"
#include <stdio.h> #include <stdio.h>
#include "dtc.h" #include "dtc.h"
#include "srcpos.h" #include "srcpos.h"
YYLTYPE yylloc;
extern int yylex(void); extern int yylex(void);
extern void print_error(char const *fmt, ...);
extern void yyerror(char const *s); extern void yyerror(char const *s);
#define ERROR(loc, ...) \
do { \
srcpos_error((loc), "Error", __VA_ARGS__); \
treesource_error = true; \
} while (0)
extern struct boot_info *the_boot_info; extern struct boot_info *the_boot_info;
extern int treesource_error; extern bool treesource_error;
static unsigned long long eval_literal(const char *s, int base, int bits);
static unsigned char eval_char_literal(const char *s);
/* Line 371 of yacc.c */ #line 84 "dtc-parser.tab.c" /* yacc.c:339 */
#line 87 "dtc-parser.tab.c"
# ifndef YY_NULL # ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus # if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULL nullptr # define YY_NULLPTR nullptr
# else # else
# define YY_NULL 0 # define YY_NULLPTR 0
# endif # endif
# endif # endif
...@@ -105,7 +102,7 @@ static unsigned char eval_char_literal(const char *s); ...@@ -105,7 +102,7 @@ static unsigned char eval_char_literal(const char *s);
by #include "dtc-parser.tab.h". */ by #include "dtc-parser.tab.h". */
#ifndef YY_YY_DTC_PARSER_TAB_H_INCLUDED #ifndef YY_YY_DTC_PARSER_TAB_H_INCLUDED
# define YY_YY_DTC_PARSER_TAB_H_INCLUDED # define YY_YY_DTC_PARSER_TAB_H_INCLUDED
/* Enabling traces. */ /* Debug traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
# define YYDEBUG 0 # define YYDEBUG 0
#endif #endif
...@@ -113,12 +110,11 @@ static unsigned char eval_char_literal(const char *s); ...@@ -113,12 +110,11 @@ static unsigned char eval_char_literal(const char *s);
extern int yydebug; extern int yydebug;
#endif #endif
/* Tokens. */ /* Token type. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers enum yytokentype
know about them. */ {
enum yytokentype {
DT_V1 = 258, DT_V1 = 258,
DT_MEMRESERVE = 259, DT_MEMRESERVE = 259,
DT_LSHIFT = 260, DT_LSHIFT = 260,
...@@ -135,26 +131,23 @@ extern int yydebug; ...@@ -135,26 +131,23 @@ extern int yydebug;
DT_PROPNODENAME = 271, DT_PROPNODENAME = 271,
DT_LITERAL = 272, DT_LITERAL = 272,
DT_CHAR_LITERAL = 273, DT_CHAR_LITERAL = 273,
DT_BASE = 274, DT_BYTE = 274,
DT_BYTE = 275, DT_STRING = 275,
DT_STRING = 276, DT_LABEL = 276,
DT_LABEL = 277, DT_REF = 277,
DT_REF = 278, DT_INCBIN = 278
DT_INCBIN = 279
}; };
#endif #endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{ {
/* Line 387 of yacc.c */ #line 38 "dtc-parser.y" /* yacc.c:355 */
#line 40 "dtc-parser.y"
char *propnodename; char *propnodename;
char *literal;
char *labelref; char *labelref;
unsigned int cbase;
uint8_t byte; uint8_t byte;
struct data data; struct data data;
...@@ -170,37 +163,36 @@ typedef union YYSTYPE ...@@ -170,37 +163,36 @@ typedef union YYSTYPE
struct reserve_info *re; struct reserve_info *re;
uint64_t integer; uint64_t integer;
#line 167 "dtc-parser.tab.c" /* yacc.c:355 */
/* Line 387 of yacc.c */ };
#line 176 "dtc-parser.tab.c"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
#endif #endif
extern YYSTYPE yylval; /* Location type. */
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
#ifdef YYPARSE_PARAM typedef struct YYLTYPE YYLTYPE;
#if defined __STDC__ || defined __cplusplus struct YYLTYPE
int yyparse (void *YYPARSE_PARAM); {
#else int first_line;
int yyparse (); int first_column;
int last_line;
int last_column;
};
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif #endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
extern YYSTYPE yylval;
extern YYLTYPE yylloc;
int yyparse (void); int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_YY_DTC_PARSER_TAB_H_INCLUDED */ #endif /* !YY_YY_DTC_PARSER_TAB_H_INCLUDED */
/* Copy the second part of user declarations. */ /* Copy the second part of user declarations. */
/* Line 390 of yacc.c */ #line 196 "dtc-parser.tab.c" /* yacc.c:358 */
#line 204 "dtc-parser.tab.c"
#ifdef short #ifdef short
# undef short # undef short
...@@ -214,11 +206,8 @@ typedef unsigned char yytype_uint8; ...@@ -214,11 +206,8 @@ typedef unsigned char yytype_uint8;
#ifdef YYTYPE_INT8 #ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8; typedef YYTYPE_INT8 yytype_int8;
#elif (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
typedef signed char yytype_int8;
#else #else
typedef short int yytype_int8; typedef signed char yytype_int8;
#endif #endif
#ifdef YYTYPE_UINT16 #ifdef YYTYPE_UINT16
...@@ -238,8 +227,7 @@ typedef short int yytype_int16; ...@@ -238,8 +227,7 @@ typedef short int yytype_int16;
# define YYSIZE_T __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__
# elif defined size_t # elif defined size_t
# define YYSIZE_T size_t # define YYSIZE_T size_t
# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ # elif ! defined YYSIZE_T
|| defined __cplusplus || defined _MSC_VER)
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t # define YYSIZE_T size_t
# else # else
...@@ -261,11 +249,30 @@ typedef short int yytype_int16; ...@@ -261,11 +249,30 @@ typedef short int yytype_int16;
# endif # endif
#endif #endif
#ifndef __attribute__ #ifndef YY_ATTRIBUTE
/* This feature is available in gcc versions 2.5 and later. */ # if (defined __GNUC__ \
# if (! defined __GNUC__ || __GNUC__ < 2 \ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|| (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
# define __attribute__(Spec) /* empty */ # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
# else
# define YY_ATTRIBUTE(Spec) /* empty */
# endif
#endif
#ifndef YY_ATTRIBUTE_PURE
# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
#endif
#ifndef YY_ATTRIBUTE_UNUSED
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
#if !defined _Noreturn \
&& (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
# if defined _MSC_VER && 1200 <= _MSC_VER
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
# endif # endif
#endif #endif
...@@ -276,24 +283,25 @@ typedef short int yytype_int16; ...@@ -276,24 +283,25 @@ typedef short int yytype_int16;
# define YYUSE(E) /* empty */ # define YYUSE(E) /* empty */
#endif #endif
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Identity function, used to suppress warnings about constant conditions. */ /* Suppress an incorrect diagnostic about yylval being uninitialized. */
#ifndef lint # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
# define YYID(N) (N) _Pragma ("GCC diagnostic push") \
#else _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
#if (defined __STDC__ || defined __C99__FUNC__ \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
|| defined __cplusplus || defined _MSC_VER) # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
static int _Pragma ("GCC diagnostic pop")
YYID (int yyi)
#else #else
static int # define YY_INITIAL_VALUE(Value) Value
YYID (yyi)
int yyi;
#endif #endif
{ #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
return yyi; # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
} # define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif #endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
#if ! defined yyoverflow || YYERROR_VERBOSE #if ! defined yyoverflow || YYERROR_VERBOSE
...@@ -312,8 +320,7 @@ YYID (yyi) ...@@ -312,8 +320,7 @@ YYID (yyi)
# define alloca _alloca # define alloca _alloca
# else # else
# define YYSTACK_ALLOC alloca # define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
|| defined __cplusplus || defined _MSC_VER)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
/* Use EXIT_SUCCESS as a witness for stdlib.h. */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */
# ifndef EXIT_SUCCESS # ifndef EXIT_SUCCESS
...@@ -325,8 +332,8 @@ YYID (yyi) ...@@ -325,8 +332,8 @@ YYID (yyi)
# endif # endif
# ifdef YYSTACK_ALLOC # ifdef YYSTACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */ /* Pacify GCC's 'empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# ifndef YYSTACK_ALLOC_MAXIMUM # ifndef YYSTACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack, /* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely and a page size can be as small as 4096 bytes. So we cannot safely
...@@ -350,15 +357,13 @@ YYID (yyi) ...@@ -350,15 +357,13 @@ YYID (yyi)
# endif # endif
# ifndef YYMALLOC # ifndef YYMALLOC
# define YYMALLOC malloc # define YYMALLOC malloc
# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ # if ! defined malloc && ! defined EXIT_SUCCESS
|| defined __cplusplus || defined _MSC_VER)
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif # endif
# endif # endif
# ifndef YYFREE # ifndef YYFREE
# define YYFREE free # define YYFREE free
# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ # if ! defined free && ! defined EXIT_SUCCESS
|| defined __cplusplus || defined _MSC_VER)
void free (void *); /* INFRINGES ON USER NAME SPACE */ void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif # endif
# endif # endif
...@@ -368,13 +373,15 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ ...@@ -368,13 +373,15 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
#if (! defined yyoverflow \ #if (! defined yyoverflow \
&& (! defined __cplusplus \ && (! defined __cplusplus \
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
&& defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */ /* A type that is properly aligned for any stack member. */
union yyalloc union yyalloc
{ {
yytype_int16 yyss_alloc; yytype_int16 yyss_alloc;
YYSTYPE yyvs_alloc; YYSTYPE yyvs_alloc;
YYLTYPE yyls_alloc;
}; };
/* The size of the maximum gap between one aligned stack and the next. */ /* The size of the maximum gap between one aligned stack and the next. */
...@@ -383,8 +390,8 @@ union yyalloc ...@@ -383,8 +390,8 @@ union yyalloc
/* The size of an array large to enough to hold all stacks, each with /* The size of an array large to enough to hold all stacks, each with
N elements. */ N elements. */
# define YYSTACK_BYTES(N) \ # define YYSTACK_BYTES(N) \
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+ YYSTACK_GAP_MAXIMUM) + 2 * YYSTACK_GAP_MAXIMUM)
# define YYCOPY_NEEDED 1 # define YYCOPY_NEEDED 1
...@@ -402,7 +409,7 @@ union yyalloc ...@@ -402,7 +409,7 @@ union yyalloc
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \ yyptr += yynewbytes / sizeof (*yyptr); \
} \ } \
while (YYID (0)) while (0)
#endif #endif
...@@ -421,7 +428,7 @@ union yyalloc ...@@ -421,7 +428,7 @@ union yyalloc
for (yyi = 0; yyi < (Count); yyi++) \ for (yyi = 0; yyi < (Count); yyi++) \
(Dst)[yyi] = (Src)[yyi]; \ (Dst)[yyi] = (Src)[yyi]; \
} \ } \
while (YYID (0)) while (0)
# endif # endif
# endif # endif
#endif /* !YYCOPY_NEEDED */ #endif /* !YYCOPY_NEEDED */
...@@ -429,40 +436,42 @@ union yyalloc ...@@ -429,40 +436,42 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */ /* YYFINAL -- State number of the termination state. */
#define YYFINAL 4 #define YYFINAL 4
/* YYLAST -- Last index in YYTABLE. */ /* YYLAST -- Last index in YYTABLE. */
#define YYLAST 133 #define YYLAST 136
/* YYNTOKENS -- Number of terminals. */ /* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 48 #define YYNTOKENS 47
/* YYNNTS -- Number of nonterminals. */ /* YYNNTS -- Number of nonterminals. */
#define YYNNTS 28 #define YYNNTS 28
/* YYNRULES -- Number of rules. */ /* YYNRULES -- Number of rules. */
#define YYNRULES 79 #define YYNRULES 80
/* YYNRULES -- Number of states. */ /* YYNSTATES -- Number of states. */
#define YYNSTATES 141 #define YYNSTATES 144
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2 #define YYUNDEFTOK 2
#define YYMAXUTOK 279 #define YYMAXUTOK 278
#define YYTRANSLATE(YYX) \ #define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, without out-of-bounds checking. */
static const yytype_uint8 yytranslate[] = static const yytype_uint8 yytranslate[] =
{ {
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 47, 2, 2, 2, 45, 41, 2, 2, 2, 2, 46, 2, 2, 2, 44, 40, 2,
33, 35, 44, 42, 34, 43, 2, 26, 2, 2, 32, 34, 43, 41, 33, 42, 2, 25, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 38, 25, 2, 2, 2, 2, 2, 2, 2, 2, 37, 24,
36, 29, 30, 37, 2, 2, 2, 2, 2, 2, 35, 28, 29, 36, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 31, 2, 32, 40, 2, 2, 2, 2, 2, 2, 30, 2, 31, 39, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 27, 39, 28, 46, 2, 2, 2, 2, 2, 2, 26, 38, 27, 45, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
...@@ -477,67 +486,22 @@ static const yytype_uint8 yytranslate[] = ...@@ -477,67 +486,22 @@ static const yytype_uint8 yytranslate[] =
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24 15, 16, 17, 18, 19, 20, 21, 22, 23
}; };
#if YYDEBUG #if YYDEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
YYRHS. */
static const yytype_uint16 yyprhs[] =
{
0, 0, 3, 8, 9, 12, 17, 20, 23, 27,
31, 36, 42, 43, 46, 51, 54, 58, 61, 64,
68, 73, 76, 86, 92, 95, 96, 99, 102, 106,
108, 111, 114, 117, 119, 121, 125, 127, 129, 135,
137, 141, 143, 147, 149, 153, 155, 159, 161, 165,
167, 171, 175, 177, 181, 185, 189, 193, 197, 201,
203, 207, 211, 213, 217, 221, 225, 227, 229, 232,
235, 238, 239, 242, 245, 246, 249, 252, 255, 259
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] =
{
49, 0, -1, 3, 25, 50, 52, -1, -1, 51,
50, -1, 4, 59, 59, 25, -1, 22, 51, -1,
26, 53, -1, 52, 26, 53, -1, 52, 23, 53,
-1, 52, 15, 23, 25, -1, 27, 54, 74, 28,
25, -1, -1, 54, 55, -1, 16, 29, 56, 25,
-1, 16, 25, -1, 14, 16, 25, -1, 22, 55,
-1, 57, 21, -1, 57, 58, 30, -1, 57, 31,
73, 32, -1, 57, 23, -1, 57, 24, 33, 21,
34, 59, 34, 59, 35, -1, 57, 24, 33, 21,
35, -1, 56, 22, -1, -1, 56, 34, -1, 57,
22, -1, 13, 17, 36, -1, 36, -1, 58, 59,
-1, 58, 23, -1, 58, 22, -1, 17, -1, 18,
-1, 33, 60, 35, -1, 61, -1, 62, -1, 62,
37, 60, 38, 61, -1, 63, -1, 62, 12, 63,
-1, 64, -1, 63, 11, 64, -1, 65, -1, 64,
39, 65, -1, 66, -1, 65, 40, 66, -1, 67,
-1, 66, 41, 67, -1, 68, -1, 67, 9, 68,
-1, 67, 10, 68, -1, 69, -1, 68, 36, 69,
-1, 68, 30, 69, -1, 68, 7, 69, -1, 68,
8, 69, -1, 69, 5, 70, -1, 69, 6, 70,
-1, 70, -1, 70, 42, 71, -1, 70, 43, 71,
-1, 71, -1, 71, 44, 72, -1, 71, 26, 72,
-1, 71, 45, 72, -1, 72, -1, 59, -1, 43,
72, -1, 46, 72, -1, 47, 72, -1, -1, 73,
20, -1, 73, 22, -1, -1, 75, 74, -1, 75,
55, -1, 16, 53, -1, 15, 16, 25, -1, 22,
75, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] = static const yytype_uint16 yyrline[] =
{ {
0, 109, 109, 118, 121, 128, 132, 140, 144, 148, 0, 104, 104, 113, 116, 123, 127, 135, 139, 144,
158, 172, 180, 183, 190, 194, 198, 202, 210, 214, 155, 165, 180, 188, 191, 198, 202, 206, 210, 218,
218, 222, 226, 243, 253, 261, 264, 268, 275, 290, 222, 226, 230, 234, 250, 260, 268, 271, 275, 282,
295, 315, 329, 336, 340, 344, 351, 355, 356, 360, 298, 303, 322, 336, 343, 344, 345, 352, 356, 357,
361, 365, 366, 370, 371, 375, 376, 380, 381, 385, 361, 362, 366, 367, 371, 372, 376, 377, 381, 382,
386, 387, 391, 392, 393, 394, 395, 399, 400, 401, 386, 387, 388, 392, 393, 394, 395, 396, 400, 401,
405, 406, 407, 411, 412, 413, 414, 418, 419, 420, 402, 406, 407, 408, 412, 413, 414, 415, 419, 420,
421, 426, 429, 433, 441, 444, 448, 456, 460, 464 421, 422, 427, 430, 434, 442, 445, 449, 457, 461,
465
}; };
#endif #endif
...@@ -549,185 +513,190 @@ static const char *const yytname[] = ...@@ -549,185 +513,190 @@ static const char *const yytname[] =
"$end", "error", "$undefined", "DT_V1", "DT_MEMRESERVE", "DT_LSHIFT", "$end", "error", "$undefined", "DT_V1", "DT_MEMRESERVE", "DT_LSHIFT",
"DT_RSHIFT", "DT_LE", "DT_GE", "DT_EQ", "DT_NE", "DT_AND", "DT_OR", "DT_RSHIFT", "DT_LE", "DT_GE", "DT_EQ", "DT_NE", "DT_AND", "DT_OR",
"DT_BITS", "DT_DEL_PROP", "DT_DEL_NODE", "DT_PROPNODENAME", "DT_LITERAL", "DT_BITS", "DT_DEL_PROP", "DT_DEL_NODE", "DT_PROPNODENAME", "DT_LITERAL",
"DT_CHAR_LITERAL", "DT_BASE", "DT_BYTE", "DT_STRING", "DT_LABEL", "DT_CHAR_LITERAL", "DT_BYTE", "DT_STRING", "DT_LABEL", "DT_REF",
"DT_REF", "DT_INCBIN", "';'", "'/'", "'{'", "'}'", "'='", "'>'", "'['", "DT_INCBIN", "';'", "'/'", "'{'", "'}'", "'='", "'>'", "'['", "']'",
"']'", "'('", "','", "')'", "'<'", "'?'", "':'", "'|'", "'^'", "'&'", "'('", "','", "')'", "'<'", "'?'", "':'", "'|'", "'^'", "'&'", "'+'",
"'+'", "'-'", "'*'", "'%'", "'~'", "'!'", "$accept", "sourcefile", "'-'", "'*'", "'%'", "'~'", "'!'", "$accept", "sourcefile",
"memreserves", "memreserve", "devicetree", "nodedef", "proplist", "memreserves", "memreserve", "devicetree", "nodedef", "proplist",
"propdef", "propdata", "propdataprefix", "arrayprefix", "integer_prim", "propdef", "propdata", "propdataprefix", "arrayprefix", "integer_prim",
"integer_expr", "integer_trinary", "integer_or", "integer_and", "integer_expr", "integer_trinary", "integer_or", "integer_and",
"integer_bitor", "integer_bitxor", "integer_bitand", "integer_eq", "integer_bitor", "integer_bitxor", "integer_bitand", "integer_eq",
"integer_rela", "integer_shift", "integer_add", "integer_mul", "integer_rela", "integer_shift", "integer_add", "integer_mul",
"integer_unary", "bytestring", "subnodes", "subnode", YY_NULL "integer_unary", "bytestring", "subnodes", "subnode", YY_NULLPTR
}; };
#endif #endif
# ifdef YYPRINT # ifdef YYPRINT
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to /* YYTOKNUM[NUM] -- (External) token number corresponding to the
token YYLEX-NUM. */ (internal) symbol number NUM (which must be that of a token). */
static const yytype_uint16 yytoknum[] = static const yytype_uint16 yytoknum[] =
{ {
0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 59, 47, 123, 125, 61, 275, 276, 277, 278, 59, 47, 123, 125, 61, 62,
62, 91, 93, 40, 44, 41, 60, 63, 58, 124, 91, 93, 40, 44, 41, 60, 63, 58, 124, 94,
94, 38, 43, 45, 42, 37, 126, 33 38, 43, 45, 42, 37, 126, 33
}; };
# endif # endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ #define YYPACT_NINF -81
static const yytype_uint8 yyr1[] =
{
0, 48, 49, 50, 50, 51, 51, 52, 52, 52,
52, 53, 54, 54, 55, 55, 55, 55, 56, 56,
56, 56, 56, 56, 56, 57, 57, 57, 58, 58,
58, 58, 58, 59, 59, 59, 60, 61, 61, 62,
62, 63, 63, 64, 64, 65, 65, 66, 66, 67,
67, 67, 68, 68, 68, 68, 68, 69, 69, 69,
70, 70, 70, 71, 71, 71, 71, 72, 72, 72,
72, 73, 73, 73, 74, 74, 74, 75, 75, 75
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ #define yypact_value_is_default(Yystate) \
static const yytype_uint8 yyr2[] = (!!((Yystate) == (-81)))
#define YYTABLE_NINF -1
#define yytable_value_is_error(Yytable_value) \
0
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
static const yytype_int8 yypact[] =
{ {
0, 2, 4, 0, 2, 4, 2, 2, 3, 3, 16, -11, 21, 10, -81, 25, 10, 19, 10, -81,
4, 5, 0, 2, 4, 2, 3, 2, 2, 3, -81, -9, 25, -81, 2, 51, -81, -9, -9, -9,
4, 2, 9, 5, 2, 0, 2, 2, 3, 1, -81, 1, -81, -6, 50, 14, 28, 29, 36, 3,
2, 2, 2, 1, 1, 3, 1, 1, 5, 1, 58, 44, -3, -81, 47, -81, -81, 65, 68, 2,
3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 2, -81, -81, -81, -81, -9, -9, -9, -9, -9,
3, 3, 1, 3, 3, 3, 3, 3, 3, 1, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
3, 3, 1, 3, 3, 3, 1, 1, 2, 2, -9, -9, -9, -9, -81, 63, 69, 2, -81, -81,
2, 0, 2, 2, 0, 2, 2, 2, 3, 2 50, 57, 14, 28, 29, 36, 3, 3, 58, 58,
58, 58, 44, 44, -3, -3, -81, -81, -81, 79,
80, -8, 63, -81, 72, 63, -81, -81, -9, 76,
77, -81, -81, -81, -81, -81, 78, -81, -81, -81,
-81, -81, 35, 4, -81, -81, -81, -81, 86, -81,
-81, -81, 73, -81, -81, 33, 71, 84, 39, -81,
-81, -81, -81, -81, 41, -81, -81, -81, 25, -81,
74, 25, 75, -81
}; };
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
Performed when YYTABLE doesn't specify something else to do. Zero Performed when YYTABLE does not specify something else to do. Zero
means the default is an error. */ means the default is an error. */
static const yytype_uint8 yydefact[] = static const yytype_uint8 yydefact[] =
{ {
0, 0, 0, 3, 1, 0, 0, 0, 3, 33, 0, 0, 0, 3, 1, 0, 0, 0, 3, 34,
34, 0, 0, 6, 0, 2, 4, 0, 0, 0, 35, 0, 0, 6, 0, 2, 4, 0, 0, 0,
67, 0, 36, 37, 39, 41, 43, 45, 47, 49, 68, 0, 37, 38, 40, 42, 44, 46, 48, 50,
52, 59, 62, 66, 0, 12, 7, 0, 0, 0, 53, 60, 63, 67, 0, 13, 7, 0, 0, 0,
68, 69, 70, 35, 0, 0, 0, 0, 0, 0, 0, 69, 70, 71, 36, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 5, 74, 0, 9, 8, 40, 0, 0, 0, 0, 0, 5, 75, 0, 0, 10, 8,
42, 44, 46, 48, 50, 51, 55, 56, 54, 53, 41, 0, 43, 45, 47, 49, 51, 52, 56, 57,
57, 58, 60, 61, 64, 63, 65, 0, 0, 0, 55, 54, 58, 59, 61, 62, 65, 64, 66, 0,
0, 13, 0, 74, 10, 0, 0, 0, 15, 25, 0, 0, 0, 14, 0, 75, 11, 9, 0, 0,
77, 17, 79, 0, 76, 75, 38, 16, 78, 0, 0, 16, 26, 78, 18, 80, 0, 77, 76, 39,
0, 11, 24, 14, 26, 0, 18, 27, 21, 0, 17, 79, 0, 0, 12, 25, 15, 27, 0, 19,
71, 29, 0, 0, 0, 0, 32, 31, 19, 30, 28, 22, 0, 72, 30, 0, 0, 0, 0, 33,
28, 0, 72, 73, 20, 0, 23, 0, 0, 0, 32, 20, 31, 29, 0, 73, 74, 21, 0, 24,
22 0, 0, 0, 23
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
-1, 2, 7, 8, 15, 36, 64, 91, 109, 110,
122, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 125, 92, 93
}; };
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing /* YYPGOTO[NTERM-NUM]. */
STATE-NUM. */ static const yytype_int8 yypgoto[] =
#define YYPACT_NINF -78
static const yytype_int8 yypact[] =
{ {
22, 11, 51, 10, -78, 23, 10, 2, 10, -78, -81, -81, 100, 104, -81, -38, -81, -80, -81, -81,
-78, -9, 23, -78, 30, 38, -78, -9, -9, -9, -81, -5, 66, 13, -81, 70, 67, 81, 64, 82,
-78, 35, -78, -6, 52, 29, 48, 49, 33, 3, 37, 27, 34, 38, -14, -81, 22, 24
71, 36, 0, -78, 64, -78, -78, 68, 30, 30,
-78, -78, -78, -78, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -78, 44, 67, -78, -78, 52, 55,
29, 48, 49, 33, 3, 3, 71, 71, 71, 71,
36, 36, 0, 0, -78, -78, -78, 78, 79, 42,
44, -78, 69, 44, -78, -9, 73, 74, -78, -78,
-78, -78, -78, 75, -78, -78, -78, -78, -78, -7,
-1, -78, -78, -78, -78, 84, -78, -78, -78, 63,
-78, -78, 32, 66, 82, -3, -78, -78, -78, -78,
-78, 46, -78, -78, -78, 23, -78, 70, 23, 72,
-78
}; };
/* YYPGOTO[NTERM-NUM]. */ /* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] = static const yytype_int16 yydefgoto[] =
{ {
-78, -78, 97, 100, -78, -37, -78, -77, -78, -78, -1, 2, 7, 8, 15, 36, 65, 93, 112, 113,
-78, -5, 65, 13, -78, 76, 77, 62, 80, 83, 125, 20, 21, 22, 23, 24, 25, 26, 27, 28,
34, 20, 26, 28, -14, -78, 18, 24 29, 30, 31, 32, 33, 128, 94, 95
}; };
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which positive, shift that token. If negative, reduce the rule whose
number is the opposite. If YYTABLE_NINF, syntax error. */ number is the opposite. If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF -1
static const yytype_uint8 yytable[] = static const yytype_uint8 yytable[] =
{ {
12, 66, 67, 40, 41, 42, 44, 34, 9, 10, 12, 68, 69, 41, 42, 43, 45, 34, 9, 10,
52, 53, 115, 101, 5, 112, 104, 132, 113, 133, 53, 54, 104, 3, 5, 107, 101, 118, 35, 1,
116, 117, 118, 119, 11, 1, 60, 114, 14, 134, 102, 4, 61, 11, 119, 120, 121, 122, 35, 97,
120, 45, 6, 54, 17, 121, 3, 18, 19, 55, 46, 6, 55, 17, 123, 44, 18, 19, 56, 124,
9, 10, 50, 51, 61, 62, 84, 85, 86, 9, 62, 63, 9, 10, 14, 51, 52, 86, 87, 88,
10, 4, 100, 37, 126, 127, 11, 35, 87, 88, 9, 10, 48, 103, 129, 130, 115, 11, 135, 116,
89, 38, 128, 46, 39, 11, 90, 98, 47, 35, 136, 47, 131, 57, 58, 11, 37, 49, 117, 50,
43, 99, 76, 77, 78, 79, 56, 57, 58, 59, 137, 64, 38, 39, 138, 139, 40, 89, 90, 91,
135, 136, 80, 81, 74, 75, 82, 83, 48, 63, 78, 79, 80, 81, 92, 59, 60, 66, 76, 77,
49, 65, 94, 95, 96, 97, 124, 103, 107, 108, 67, 82, 83, 96, 98, 99, 100, 84, 85, 106,
111, 123, 130, 131, 138, 16, 13, 140, 106, 71, 110, 111, 114, 126, 134, 127, 133, 141, 16, 143,
69, 105, 0, 0, 102, 0, 0, 129, 0, 0, 13, 109, 71, 74, 72, 70, 105, 108, 0, 0,
68, 0, 0, 70, 0, 0, 0, 0, 72, 0, 132, 0, 0, 0, 0, 0, 0, 0, 0, 73,
137, 0, 73, 139 0, 0, 75, 140, 0, 0, 142
}; };
#define yypact_value_is_default(Yystate) \
(!!((Yystate) == (-78)))
#define yytable_value_is_error(Yytable_value) \
YYID (0)
static const yytype_int16 yycheck[] = static const yytype_int16 yycheck[] =
{ {
5, 38, 39, 17, 18, 19, 12, 12, 17, 18, 5, 39, 40, 17, 18, 19, 12, 12, 17, 18,
7, 8, 13, 90, 4, 22, 93, 20, 25, 22, 7, 8, 92, 24, 4, 95, 24, 13, 26, 3,
21, 22, 23, 24, 33, 3, 26, 34, 26, 32, 28, 0, 25, 32, 20, 21, 22, 23, 26, 67,
31, 37, 22, 30, 43, 36, 25, 46, 47, 36, 36, 21, 29, 42, 30, 34, 45, 46, 35, 35,
17, 18, 9, 10, 44, 45, 60, 61, 62, 17, 43, 44, 17, 18, 25, 9, 10, 61, 62, 63,
18, 0, 89, 15, 22, 23, 33, 27, 14, 15, 17, 18, 38, 91, 21, 22, 21, 32, 19, 24,
16, 23, 30, 11, 26, 33, 22, 25, 39, 27, 21, 11, 29, 5, 6, 32, 15, 39, 33, 40,
35, 29, 52, 53, 54, 55, 5, 6, 42, 43, 31, 24, 21, 22, 33, 34, 25, 14, 15, 16,
34, 35, 56, 57, 50, 51, 58, 59, 40, 25, 53, 54, 55, 56, 21, 41, 42, 22, 51, 52,
41, 23, 25, 38, 16, 16, 33, 28, 25, 25, 22, 57, 58, 24, 37, 16, 16, 59, 60, 27,
25, 17, 36, 21, 34, 8, 6, 35, 95, 47, 24, 24, 24, 17, 20, 32, 35, 33, 8, 34,
45, 93, -1, -1, 90, -1, -1, 122, -1, -1, 6, 98, 46, 49, 47, 45, 92, 95, -1, -1,
44, -1, -1, 46, -1, -1, -1, -1, 48, -1, 125, -1, -1, -1, -1, -1, -1, -1, -1, 48,
135, -1, 49, 138 -1, -1, 50, 138, -1, -1, 141
}; };
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */ symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] = static const yytype_uint8 yystos[] =
{ {
0, 3, 49, 25, 0, 4, 22, 50, 51, 17, 0, 3, 48, 24, 0, 4, 21, 49, 50, 17,
18, 33, 59, 51, 26, 52, 50, 43, 46, 47, 18, 32, 58, 50, 25, 51, 49, 42, 45, 46,
59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
69, 70, 71, 72, 59, 27, 53, 15, 23, 26, 68, 69, 70, 71, 58, 26, 52, 15, 21, 22,
72, 72, 72, 35, 12, 37, 11, 39, 40, 41, 25, 71, 71, 71, 34, 12, 36, 11, 38, 39,
9, 10, 7, 8, 30, 36, 5, 6, 42, 43, 40, 9, 10, 7, 8, 29, 35, 5, 6, 41,
26, 44, 45, 25, 54, 23, 53, 53, 63, 60, 42, 25, 43, 44, 24, 53, 22, 22, 52, 52,
64, 65, 66, 67, 68, 68, 69, 69, 69, 69, 62, 59, 63, 64, 65, 66, 67, 67, 68, 68,
70, 70, 71, 71, 72, 72, 72, 14, 15, 16, 68, 68, 69, 69, 70, 70, 71, 71, 71, 14,
22, 55, 74, 75, 25, 38, 16, 16, 25, 29, 15, 16, 21, 54, 73, 74, 24, 52, 37, 16,
53, 55, 75, 28, 55, 74, 61, 25, 25, 56, 16, 24, 28, 52, 54, 74, 27, 54, 73, 60,
57, 25, 22, 25, 34, 13, 21, 22, 23, 24, 24, 24, 55, 56, 24, 21, 24, 33, 13, 20,
31, 36, 58, 17, 33, 73, 22, 23, 30, 59, 21, 22, 23, 30, 35, 57, 17, 32, 72, 21,
36, 21, 20, 22, 32, 34, 35, 59, 34, 59, 22, 29, 58, 35, 20, 19, 21, 31, 33, 34,
35 58, 33, 58, 34
}; };
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
0, 47, 48, 49, 49, 50, 50, 51, 51, 51,
51, 51, 52, 53, 53, 54, 54, 54, 54, 55,
55, 55, 55, 55, 55, 55, 56, 56, 56, 57,
57, 57, 57, 57, 58, 58, 58, 59, 60, 60,
61, 61, 62, 62, 63, 63, 64, 64, 65, 65,
66, 66, 66, 67, 67, 67, 67, 67, 68, 68,
68, 69, 69, 69, 70, 70, 70, 70, 71, 71,
71, 71, 72, 72, 72, 73, 73, 73, 74, 74,
74
};
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 4, 0, 2, 4, 2, 2, 3, 4,
3, 4, 5, 0, 2, 4, 2, 3, 2, 2,
3, 4, 2, 9, 5, 2, 0, 2, 2, 3,
1, 2, 2, 2, 1, 1, 3, 1, 1, 5,
1, 3, 1, 3, 1, 3, 1, 3, 1, 3,
1, 3, 3, 1, 3, 3, 3, 3, 3, 3,
1, 3, 3, 1, 3, 3, 3, 1, 1, 2,
2, 2, 0, 2, 2, 0, 2, 2, 2, 3,
2
};
#define yyerrok (yyerrstatus = 0) #define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY) #define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2) #define YYEMPTY (-2)
...@@ -738,21 +707,6 @@ static const yytype_uint8 yystos[] = ...@@ -738,21 +707,6 @@ static const yytype_uint8 yystos[] =
#define YYERROR goto yyerrorlab #define YYERROR goto yyerrorlab
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. However,
YYFAIL appears to be in use. Nevertheless, it is formally deprecated
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
discussed. */
#define YYFAIL goto yyerrlab
#if defined YYFAIL
/* This is here to suppress warnings from the GCC cpp's
-Wunused-macros. Normally we don't worry about that warning, but
some users do, and we want to make it easy for users to remove
YYFAIL uses, which will produce warnings from Bison 2.5. */
#endif
#define YYRECOVERING() (!!yyerrstatus) #define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \ #define YYBACKUP(Token, Value) \
...@@ -770,25 +724,39 @@ do \ ...@@ -770,25 +724,39 @@ do \
yyerror (YY_("syntax error: cannot back up")); \ yyerror (YY_("syntax error: cannot back up")); \
YYERROR; \ YYERROR; \
} \ } \
while (YYID (0)) while (0)
/* Error token number */ /* Error token number */
#define YYTERROR 1 #define YYTERROR 1
#define YYERRCODE 256 #define YYERRCODE 256
/* This macro is provided for backward compatibility. */ /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
#ifndef YY_LOCATION_PRINT If N is 0, then set CURRENT to the empty location which ends
# define YY_LOCATION_PRINT(File, Loc) ((void) 0) the previous symbol: RHS[0] (always defined). */
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
while (0)
#endif #endif
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
/* YYLEX -- calling `yylex' with the right arguments. */
#ifdef YYLEX_PARAM
# define YYLEX yylex (YYLEX_PARAM)
#else
# define YYLEX yylex ()
#endif
/* Enable debugging if requested. */ /* Enable debugging if requested. */
#if YYDEBUG #if YYDEBUG
...@@ -802,7 +770,52 @@ while (YYID (0)) ...@@ -802,7 +770,52 @@ while (YYID (0))
do { \ do { \
if (yydebug) \ if (yydebug) \
YYFPRINTF Args; \ YYFPRINTF Args; \
} while (YYID (0)) } while (0)
/* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
YY_ATTRIBUTE_UNUSED
static unsigned
yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
{
unsigned res = 0;
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
if (0 <= yylocp->first_line)
{
res += YYFPRINTF (yyo, "%d", yylocp->first_line);
if (0 <= yylocp->first_column)
res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
}
if (0 <= yylocp->last_line)
{
if (yylocp->first_line < yylocp->last_line)
{
res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
if (0 <= end_col)
res += YYFPRINTF (yyo, ".%d", end_col);
}
else if (0 <= end_col && yylocp->first_column < end_col)
res += YYFPRINTF (yyo, "-%d", end_col);
}
return res;
}
# define YY_LOCATION_PRINT(File, Loc) \
yy_location_print_ (File, &(Loc))
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
#endif
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \ do { \
...@@ -810,38 +823,27 @@ do { \ ...@@ -810,38 +823,27 @@ do { \
{ \ { \
YYFPRINTF (stderr, "%s ", Title); \ YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \ yy_symbol_print (stderr, \
Type, Value); \ Type, Value, Location); \
YYFPRINTF (stderr, "\n"); \ YYFPRINTF (stderr, "\n"); \
} \ } \
} while (YYID (0)) } while (0)
/*--------------------------------. /*----------------------------------------.
| Print this symbol on YYOUTPUT. | | Print this symbol's value on YYOUTPUT. |
`--------------------------------*/ `----------------------------------------*/
/*ARGSUSED*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
#else
static void static void
yy_symbol_value_print (yyoutput, yytype, yyvaluep) yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
FILE *yyoutput;
int yytype;
YYSTYPE const * const yyvaluep;
#endif
{ {
FILE *yyo = yyoutput; FILE *yyo = yyoutput;
YYUSE (yyo); YYUSE (yyo);
YYUSE (yylocationp);
if (!yyvaluep) if (!yyvaluep)
return; return;
# ifdef YYPRINT # ifdef YYPRINT
if (yytype < YYNTOKENS) if (yytype < YYNTOKENS)
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# else
YYUSE (yyoutput);
# endif # endif
YYUSE (yytype); YYUSE (yytype);
} }
...@@ -851,24 +853,15 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep) ...@@ -851,24 +853,15 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep)
| Print this symbol on YYOUTPUT. | | Print this symbol on YYOUTPUT. |
`--------------------------------*/ `--------------------------------*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
#else
static void static void
yy_symbol_print (yyoutput, yytype, yyvaluep) yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
FILE *yyoutput;
int yytype;
YYSTYPE const * const yyvaluep;
#endif
{ {
if (yytype < YYNTOKENS) YYFPRINTF (yyoutput, "%s %s (",
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
else
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
yy_symbol_value_print (yyoutput, yytype, yyvaluep); YY_LOCATION_PRINT (yyoutput, *yylocationp);
YYFPRINTF (yyoutput, ": ");
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
YYFPRINTF (yyoutput, ")"); YYFPRINTF (yyoutput, ")");
} }
...@@ -877,16 +870,8 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) ...@@ -877,16 +870,8 @@ yy_symbol_print (yyoutput, yytype, yyvaluep)
| TOP (included). | | TOP (included). |
`------------------------------------------------------------------*/ `------------------------------------------------------------------*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
#else
static void
yy_stack_print (yybottom, yytop)
yytype_int16 *yybottom;
yytype_int16 *yytop;
#endif
{ {
YYFPRINTF (stderr, "Stack now"); YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++) for (; yybottom <= yytop; yybottom++)
...@@ -901,36 +886,29 @@ yy_stack_print (yybottom, yytop) ...@@ -901,36 +886,29 @@ yy_stack_print (yybottom, yytop)
do { \ do { \
if (yydebug) \ if (yydebug) \
yy_stack_print ((Bottom), (Top)); \ yy_stack_print ((Bottom), (Top)); \
} while (YYID (0)) } while (0)
/*------------------------------------------------. /*------------------------------------------------.
| Report that the YYRULE is going to be reduced. | | Report that the YYRULE is going to be reduced. |
`------------------------------------------------*/ `------------------------------------------------*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void static void
yy_reduce_print (YYSTYPE *yyvsp, int yyrule) yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
#else
static void
yy_reduce_print (yyvsp, yyrule)
YYSTYPE *yyvsp;
int yyrule;
#endif
{ {
unsigned long int yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule]; int yynrhs = yyr2[yyrule];
int yyi; int yyi;
unsigned long int yylno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
yyrule - 1, yylno); yyrule - 1, yylno);
/* The symbols being reduced. */ /* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++) for (yyi = 0; yyi < yynrhs; yyi++)
{ {
YYFPRINTF (stderr, " $%d = ", yyi + 1); YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], yy_symbol_print (stderr,
yystos[yyssp[yyi + 1 - yynrhs]],
&(yyvsp[(yyi + 1) - (yynrhs)]) &(yyvsp[(yyi + 1) - (yynrhs)])
); , &(yylsp[(yyi + 1) - (yynrhs)]) );
YYFPRINTF (stderr, "\n"); YYFPRINTF (stderr, "\n");
} }
} }
...@@ -938,8 +916,8 @@ yy_reduce_print (yyvsp, yyrule) ...@@ -938,8 +916,8 @@ yy_reduce_print (yyvsp, yyrule)
# define YY_REDUCE_PRINT(Rule) \ # define YY_REDUCE_PRINT(Rule) \
do { \ do { \
if (yydebug) \ if (yydebug) \
yy_reduce_print (yyvsp, Rule); \ yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \
} while (YYID (0)) } while (0)
/* Nonzero means print parse trace. It is left uninitialized so that /* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */ multiple parsers can coexist. */
...@@ -976,15 +954,8 @@ int yydebug; ...@@ -976,15 +954,8 @@ int yydebug;
# define yystrlen strlen # define yystrlen strlen
# else # else
/* Return the length of YYSTR. */ /* Return the length of YYSTR. */
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static YYSIZE_T static YYSIZE_T
yystrlen (const char *yystr) yystrlen (const char *yystr)
#else
static YYSIZE_T
yystrlen (yystr)
const char *yystr;
#endif
{ {
YYSIZE_T yylen; YYSIZE_T yylen;
for (yylen = 0; yystr[yylen]; yylen++) for (yylen = 0; yystr[yylen]; yylen++)
...@@ -1000,16 +971,8 @@ yystrlen (yystr) ...@@ -1000,16 +971,8 @@ yystrlen (yystr)
# else # else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */ YYDEST. */
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static char * static char *
yystpcpy (char *yydest, const char *yysrc) yystpcpy (char *yydest, const char *yysrc)
#else
static char *
yystpcpy (yydest, yysrc)
char *yydest;
const char *yysrc;
#endif
{ {
char *yyd = yydest; char *yyd = yydest;
const char *yys = yysrc; const char *yys = yysrc;
...@@ -1082,11 +1045,11 @@ static int ...@@ -1082,11 +1045,11 @@ static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yytype_int16 *yyssp, int yytoken) yytype_int16 *yyssp, int yytoken)
{ {
YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
YYSIZE_T yysize = yysize0; YYSIZE_T yysize = yysize0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */ /* Internationalized format string. */
const char *yyformat = YY_NULL; const char *yyformat = YY_NULLPTR;
/* Arguments of yyformat. */ /* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per /* Number of reported tokens (one for the "unexpected", one per
...@@ -1094,10 +1057,6 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, ...@@ -1094,10 +1057,6 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
int yycount = 0; int yycount = 0;
/* There are many possibilities here to consider: /* There are many possibilities here to consider:
- Assume YYFAIL is not used. It's too flawed to consider. See
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
for details. YYERROR is fine as it does not invoke this
function.
- If this state is a consistent state with a default action, then - If this state is a consistent state with a default action, then
the only way this function was invoked is if the default action the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected is an error action. In that case, don't check for expected
...@@ -1147,7 +1106,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, ...@@ -1147,7 +1106,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
} }
yyarg[yycount++] = yytname[yyx]; yyarg[yycount++] = yytname[yyx];
{ {
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
if (! (yysize <= yysize1 if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM)) && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2; return 2;
...@@ -1214,26 +1173,18 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, ...@@ -1214,26 +1173,18 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
| Release the memory associated to this symbol. | | Release the memory associated to this symbol. |
`-----------------------------------------------*/ `-----------------------------------------------*/
/*ARGSUSED*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
#else
static void static void
yydestruct (yymsg, yytype, yyvaluep) yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
const char *yymsg;
int yytype;
YYSTYPE *yyvaluep;
#endif
{ {
YYUSE (yyvaluep); YYUSE (yyvaluep);
YYUSE (yylocationp);
if (!yymsg) if (!yymsg)
yymsg = "Deleting"; yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YYUSE (yytype); YYUSE (yytype);
YY_IGNORE_MAYBE_UNINITIALIZED_END
} }
...@@ -1242,18 +1193,14 @@ yydestruct (yymsg, yytype, yyvaluep) ...@@ -1242,18 +1193,14 @@ yydestruct (yymsg, yytype, yyvaluep)
/* The lookahead symbol. */ /* The lookahead symbol. */
int yychar; int yychar;
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
/* The semantic value of the lookahead symbol. */ /* The semantic value of the lookahead symbol. */
YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); YYSTYPE yylval;
/* Location data for the lookahead symbol. */
YYLTYPE yylloc
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
= { 1, 1, 1, 1 }
# endif
;
/* Number of syntax errors so far. */ /* Number of syntax errors so far. */
int yynerrs; int yynerrs;
...@@ -1262,35 +1209,17 @@ int yynerrs; ...@@ -1262,35 +1209,17 @@ int yynerrs;
| yyparse. | | yyparse. |
`----------*/ `----------*/
#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
int
yyparse (void *YYPARSE_PARAM)
#else
int
yyparse (YYPARSE_PARAM)
void *YYPARSE_PARAM;
#endif
#else /* ! YYPARSE_PARAM */
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
int int
yyparse (void) yyparse (void)
#else
int
yyparse ()
#endif
#endif
{ {
int yystate; int yystate;
/* Number of tokens to shift before error messages enabled. */ /* Number of tokens to shift before error messages enabled. */
int yyerrstatus; int yyerrstatus;
/* The stacks and their tools: /* The stacks and their tools:
`yyss': related to states. 'yyss': related to states.
`yyvs': related to semantic values. 'yyvs': related to semantic values.
'yyls': related to locations.
Refer to the stacks through separate pointers, to allow yyoverflow Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */ to reallocate them elsewhere. */
...@@ -1305,6 +1234,14 @@ yyparse () ...@@ -1305,6 +1234,14 @@ yyparse ()
YYSTYPE *yyvs; YYSTYPE *yyvs;
YYSTYPE *yyvsp; YYSTYPE *yyvsp;
/* The location stack. */
YYLTYPE yylsa[YYINITDEPTH];
YYLTYPE *yyls;
YYLTYPE *yylsp;
/* The locations where the error started and ended. */
YYLTYPE yyerror_range[3];
YYSIZE_T yystacksize; YYSIZE_T yystacksize;
int yyn; int yyn;
...@@ -1314,6 +1251,7 @@ yyparse () ...@@ -1314,6 +1251,7 @@ yyparse ()
/* The variables used to return semantic value and location from the /* The variables used to return semantic value and location from the
action routines. */ action routines. */
YYSTYPE yyval; YYSTYPE yyval;
YYLTYPE yyloc;
#if YYERROR_VERBOSE #if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */ /* Buffer for error messages, and its allocated size. */
...@@ -1322,7 +1260,7 @@ yyparse () ...@@ -1322,7 +1260,7 @@ yyparse ()
YYSIZE_T yymsg_alloc = sizeof yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif #endif
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
/* The number of symbols on the RHS of the reduced rule. /* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */ Keep to zero when no symbol should be popped. */
...@@ -1330,6 +1268,7 @@ yyparse () ...@@ -1330,6 +1268,7 @@ yyparse ()
yyssp = yyss = yyssa; yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa; yyvsp = yyvs = yyvsa;
yylsp = yyls = yylsa;
yystacksize = YYINITDEPTH; yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n")); YYDPRINTF ((stderr, "Starting parse\n"));
...@@ -1338,6 +1277,7 @@ yyparse () ...@@ -1338,6 +1277,7 @@ yyparse ()
yyerrstatus = 0; yyerrstatus = 0;
yynerrs = 0; yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */ yychar = YYEMPTY; /* Cause a token to be read. */
yylsp[0] = yylloc;
goto yysetstate; goto yysetstate;
/*------------------------------------------------------------. /*------------------------------------------------------------.
...@@ -1363,6 +1303,7 @@ yyparse () ...@@ -1363,6 +1303,7 @@ yyparse ()
memory. */ memory. */
YYSTYPE *yyvs1 = yyvs; YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss; yytype_int16 *yyss1 = yyss;
YYLTYPE *yyls1 = yyls;
/* Each stack pointer address is followed by the size of the /* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a data in use in that stack, in bytes. This used to be a
...@@ -1371,8 +1312,10 @@ yyparse () ...@@ -1371,8 +1312,10 @@ yyparse ()
yyoverflow (YY_("memory exhausted"), yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp), &yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp), &yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
&yystacksize); &yystacksize);
yyls = yyls1;
yyss = yyss1; yyss = yyss1;
yyvs = yyvs1; yyvs = yyvs1;
} }
...@@ -1395,6 +1338,7 @@ yyparse () ...@@ -1395,6 +1338,7 @@ yyparse ()
goto yyexhaustedlab; goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs); YYSTACK_RELOCATE (yyvs_alloc, yyvs);
YYSTACK_RELOCATE (yyls_alloc, yyls);
# undef YYSTACK_RELOCATE # undef YYSTACK_RELOCATE
if (yyss1 != yyssa) if (yyss1 != yyssa)
YYSTACK_FREE (yyss1); YYSTACK_FREE (yyss1);
...@@ -1404,6 +1348,7 @@ yyparse () ...@@ -1404,6 +1348,7 @@ yyparse ()
yyssp = yyss + yysize - 1; yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1; yyvsp = yyvs + yysize - 1;
yylsp = yyls + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n", YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize)); (unsigned long int) yystacksize));
...@@ -1438,7 +1383,7 @@ yybackup: ...@@ -1438,7 +1383,7 @@ yybackup:
if (yychar == YYEMPTY) if (yychar == YYEMPTY)
{ {
YYDPRINTF ((stderr, "Reading a token: ")); YYDPRINTF ((stderr, "Reading a token: "));
yychar = YYLEX; yychar = yylex ();
} }
if (yychar <= YYEOF) if (yychar <= YYEOF)
...@@ -1481,7 +1426,7 @@ yybackup: ...@@ -1481,7 +1426,7 @@ yybackup:
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval; *++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END YY_IGNORE_MAYBE_UNINITIALIZED_END
*++yylsp = yylloc;
goto yynewstate; goto yynewstate;
...@@ -1503,7 +1448,7 @@ yyreduce: ...@@ -1503,7 +1448,7 @@ yyreduce:
yylen = yyr2[yyn]; yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action: /* If YYLEN is nonzero, implement the default value of the action:
`$$ = $1'. '$$ = $1'.
Otherwise, the following line sets YYVAL to garbage. Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison This behavior is undocumented and Bison
...@@ -1512,287 +1457,303 @@ yyreduce: ...@@ -1512,287 +1457,303 @@ yyreduce:
GCC warning that YYVAL may be used uninitialized. */ GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen]; yyval = yyvsp[1-yylen];
/* Default location. */
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
YY_REDUCE_PRINT (yyn); YY_REDUCE_PRINT (yyn);
switch (yyn) switch (yyn)
{ {
case 2: case 2:
/* Line 1787 of yacc.c */ #line 105 "dtc-parser.y" /* yacc.c:1646 */
#line 110 "dtc-parser.y"
{ {
the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), the_boot_info = build_boot_info((yyvsp[-1].re), (yyvsp[0].node),
guess_boot_cpuid((yyvsp[(4) - (4)].node))); guess_boot_cpuid((yyvsp[0].node)));
} }
#line 1472 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 3: case 3:
/* Line 1787 of yacc.c */ #line 113 "dtc-parser.y" /* yacc.c:1646 */
#line 118 "dtc-parser.y"
{ {
(yyval.re) = NULL; (yyval.re) = NULL;
} }
#line 1480 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 4: case 4:
/* Line 1787 of yacc.c */ #line 117 "dtc-parser.y" /* yacc.c:1646 */
#line 122 "dtc-parser.y"
{ {
(yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); (yyval.re) = chain_reserve_entry((yyvsp[-1].re), (yyvsp[0].re));
} }
#line 1488 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 5: case 5:
/* Line 1787 of yacc.c */ #line 124 "dtc-parser.y" /* yacc.c:1646 */
#line 129 "dtc-parser.y"
{ {
(yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].integer), (yyvsp[(3) - (4)].integer)); (yyval.re) = build_reserve_entry((yyvsp[-2].integer), (yyvsp[-1].integer));
} }
#line 1496 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 6: case 6:
/* Line 1787 of yacc.c */ #line 128 "dtc-parser.y" /* yacc.c:1646 */
#line 133 "dtc-parser.y"
{ {
add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref)); add_label(&(yyvsp[0].re)->labels, (yyvsp[-1].labelref));
(yyval.re) = (yyvsp[(2) - (2)].re); (yyval.re) = (yyvsp[0].re);
} }
#line 1505 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 7: case 7:
/* Line 1787 of yacc.c */ #line 136 "dtc-parser.y" /* yacc.c:1646 */
#line 141 "dtc-parser.y"
{ {
(yyval.node) = name_node((yyvsp[(2) - (2)].node), ""); (yyval.node) = name_node((yyvsp[0].node), "");
} }
#line 1513 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 8: case 8:
/* Line 1787 of yacc.c */ #line 140 "dtc-parser.y" /* yacc.c:1646 */
#line 145 "dtc-parser.y"
{ {
(yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); (yyval.node) = merge_nodes((yyvsp[-2].node), (yyvsp[0].node));
} }
#line 1521 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 9: case 9:
/* Line 1787 of yacc.c */ #line 145 "dtc-parser.y" /* yacc.c:1646 */
#line 149 "dtc-parser.y"
{ {
struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref)); struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref));
add_label(&target->labels, (yyvsp[-2].labelref));
if (target) if (target)
merge_nodes(target, (yyvsp[(3) - (3)].node)); merge_nodes(target, (yyvsp[0].node));
else else
print_error("label or path, '%s', not found", (yyvsp[(2) - (3)].labelref)); ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref));
(yyval.node) = (yyvsp[(1) - (3)].node); (yyval.node) = (yyvsp[-3].node);
} }
#line 1536 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 10: case 10:
/* Line 1787 of yacc.c */ #line 156 "dtc-parser.y" /* yacc.c:1646 */
#line 159 "dtc-parser.y"
{ {
struct node *target = get_node_by_ref((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].labelref)); struct node *target = get_node_by_ref((yyvsp[-2].node), (yyvsp[-1].labelref));
if (!target) if (target)
print_error("label or path, '%s', not found", (yyvsp[(3) - (4)].labelref)); merge_nodes(target, (yyvsp[0].node));
else else
delete_node(target); ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref));
(yyval.node) = (yyvsp[-2].node);
(yyval.node) = (yyvsp[(1) - (4)].node);
} }
#line 1550 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 11: case 11:
/* Line 1787 of yacc.c */ #line 166 "dtc-parser.y" /* yacc.c:1646 */
#line 173 "dtc-parser.y"
{ {
(yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref));
if (target)
delete_node(target);
else
ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref));
(yyval.node) = (yyvsp[-3].node);
} }
#line 1566 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 12: case 12:
/* Line 1787 of yacc.c */ #line 181 "dtc-parser.y" /* yacc.c:1646 */
#line 180 "dtc-parser.y"
{ {
(yyval.proplist) = NULL; (yyval.node) = build_node((yyvsp[-3].proplist), (yyvsp[-2].nodelist));
} }
#line 1574 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 13: case 13:
/* Line 1787 of yacc.c */ #line 188 "dtc-parser.y" /* yacc.c:1646 */
#line 184 "dtc-parser.y"
{ {
(yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); (yyval.proplist) = NULL;
} }
#line 1582 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 14: case 14:
/* Line 1787 of yacc.c */ #line 192 "dtc-parser.y" /* yacc.c:1646 */
#line 191 "dtc-parser.y"
{ {
(yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data)); (yyval.proplist) = chain_property((yyvsp[0].prop), (yyvsp[-1].proplist));
} }
#line 1590 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 15: case 15:
/* Line 1787 of yacc.c */ #line 199 "dtc-parser.y" /* yacc.c:1646 */
#line 195 "dtc-parser.y"
{ {
(yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data); (yyval.prop) = build_property((yyvsp[-3].propnodename), (yyvsp[-1].data));
} }
#line 1598 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 16: case 16:
/* Line 1787 of yacc.c */ #line 203 "dtc-parser.y" /* yacc.c:1646 */
#line 199 "dtc-parser.y"
{ {
(yyval.prop) = build_property_delete((yyvsp[(2) - (3)].propnodename)); (yyval.prop) = build_property((yyvsp[-1].propnodename), empty_data);
} }
#line 1606 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 17: case 17:
/* Line 1787 of yacc.c */ #line 207 "dtc-parser.y" /* yacc.c:1646 */
#line 203 "dtc-parser.y"
{ {
add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref)); (yyval.prop) = build_property_delete((yyvsp[-1].propnodename));
(yyval.prop) = (yyvsp[(2) - (2)].prop);
} }
#line 1614 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 18: case 18:
/* Line 1787 of yacc.c */ #line 211 "dtc-parser.y" /* yacc.c:1646 */
#line 211 "dtc-parser.y"
{ {
(yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data)); add_label(&(yyvsp[0].prop)->labels, (yyvsp[-1].labelref));
(yyval.prop) = (yyvsp[0].prop);
} }
#line 1623 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 19: case 19:
/* Line 1787 of yacc.c */ #line 219 "dtc-parser.y" /* yacc.c:1646 */
#line 215 "dtc-parser.y"
{ {
(yyval.data) = data_merge((yyvsp[(1) - (3)].data), (yyvsp[(2) - (3)].array).data); (yyval.data) = data_merge((yyvsp[-1].data), (yyvsp[0].data));
} }
#line 1631 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 20: case 20:
/* Line 1787 of yacc.c */ #line 223 "dtc-parser.y" /* yacc.c:1646 */
#line 219 "dtc-parser.y"
{ {
(yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); (yyval.data) = data_merge((yyvsp[-2].data), (yyvsp[-1].array).data);
} }
#line 1639 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 21: case 21:
/* Line 1787 of yacc.c */ #line 227 "dtc-parser.y" /* yacc.c:1646 */
#line 223 "dtc-parser.y"
{ {
(yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref)); (yyval.data) = data_merge((yyvsp[-3].data), (yyvsp[-1].data));
} }
#line 1647 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 22: case 22:
/* Line 1787 of yacc.c */ #line 231 "dtc-parser.y" /* yacc.c:1646 */
#line 227 "dtc-parser.y" {
(yyval.data) = data_add_marker((yyvsp[-1].data), REF_PATH, (yyvsp[0].labelref));
}
#line 1655 "dtc-parser.tab.c" /* yacc.c:1646 */
break;
case 23:
#line 235 "dtc-parser.y" /* yacc.c:1646 */
{ {
FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL); FILE *f = srcfile_relative_open((yyvsp[-5].data).val, NULL);
struct data d; struct data d;
if ((yyvsp[(6) - (9)].integer) != 0) if ((yyvsp[-3].integer) != 0)
if (fseek(f, (yyvsp[(6) - (9)].integer), SEEK_SET) != 0) if (fseek(f, (yyvsp[-3].integer), SEEK_SET) != 0)
print_error("Couldn't seek to offset %llu in \"%s\": %s", die("Couldn't seek to offset %llu in \"%s\": %s",
(unsigned long long)(yyvsp[(6) - (9)].integer), (unsigned long long)(yyvsp[-3].integer), (yyvsp[-5].data).val,
(yyvsp[(4) - (9)].data).val,
strerror(errno)); strerror(errno));
d = data_copy_file(f, (yyvsp[(8) - (9)].integer)); d = data_copy_file(f, (yyvsp[-1].integer));
(yyval.data) = data_merge((yyvsp[(1) - (9)].data), d); (yyval.data) = data_merge((yyvsp[-8].data), d);
fclose(f); fclose(f);
} }
#line 1675 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 23: case 24:
/* Line 1787 of yacc.c */ #line 251 "dtc-parser.y" /* yacc.c:1646 */
#line 244 "dtc-parser.y"
{ {
FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL); FILE *f = srcfile_relative_open((yyvsp[-1].data).val, NULL);
struct data d = empty_data; struct data d = empty_data;
d = data_copy_file(f, -1); d = data_copy_file(f, -1);
(yyval.data) = data_merge((yyvsp[(1) - (5)].data), d); (yyval.data) = data_merge((yyvsp[-4].data), d);
fclose(f); fclose(f);
} }
break; #line 1689 "dtc-parser.tab.c" /* yacc.c:1646 */
case 24:
/* Line 1787 of yacc.c */
#line 254 "dtc-parser.y"
{
(yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
}
break; break;
case 25: case 25:
/* Line 1787 of yacc.c */ #line 261 "dtc-parser.y" /* yacc.c:1646 */
#line 261 "dtc-parser.y"
{ {
(yyval.data) = empty_data; (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref));
} }
#line 1697 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 26: case 26:
/* Line 1787 of yacc.c */ #line 268 "dtc-parser.y" /* yacc.c:1646 */
#line 265 "dtc-parser.y"
{ {
(yyval.data) = (yyvsp[(1) - (2)].data); (yyval.data) = empty_data;
} }
#line 1705 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 27: case 27:
/* Line 1787 of yacc.c */ #line 272 "dtc-parser.y" /* yacc.c:1646 */
#line 269 "dtc-parser.y"
{ {
(yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); (yyval.data) = (yyvsp[-1].data);
} }
#line 1713 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 28: case 28:
/* Line 1787 of yacc.c */ #line 276 "dtc-parser.y" /* yacc.c:1646 */
#line 276 "dtc-parser.y"
{ {
(yyval.array).data = empty_data; (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref));
(yyval.array).bits = eval_literal((yyvsp[(2) - (3)].literal), 0, 7); }
#line 1721 "dtc-parser.tab.c" /* yacc.c:1646 */
break;
if (((yyval.array).bits != 8) && case 29:
((yyval.array).bits != 16) && #line 283 "dtc-parser.y" /* yacc.c:1646 */
((yyval.array).bits != 32) &&
((yyval.array).bits != 64))
{ {
print_error("Only 8, 16, 32 and 64-bit elements" unsigned long long bits;
" are currently supported");
(yyval.array).bits = 32; bits = (yyvsp[-1].integer);
if ((bits != 8) && (bits != 16) &&
(bits != 32) && (bits != 64)) {
ERROR(&(yylsp[-1]), "Array elements must be"
" 8, 16, 32 or 64-bits");
bits = 32;
} }
(yyval.array).data = empty_data;
(yyval.array).bits = bits;
} }
#line 1741 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 29: case 30:
/* Line 1787 of yacc.c */ #line 299 "dtc-parser.y" /* yacc.c:1646 */
#line 291 "dtc-parser.y"
{ {
(yyval.array).data = empty_data; (yyval.array).data = empty_data;
(yyval.array).bits = 32; (yyval.array).bits = 32;
} }
#line 1750 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 30: case 31:
/* Line 1787 of yacc.c */ #line 304 "dtc-parser.y" /* yacc.c:1646 */
#line 296 "dtc-parser.y"
{ {
if ((yyvsp[(1) - (2)].array).bits < 64) { if ((yyvsp[-1].array).bits < 64) {
uint64_t mask = (1ULL << (yyvsp[(1) - (2)].array).bits) - 1; uint64_t mask = (1ULL << (yyvsp[-1].array).bits) - 1;
/* /*
* Bits above mask must either be all zero * Bits above mask must either be all zero
* (positive within range of mask) or all one * (positive within range of mask) or all one
...@@ -1801,275 +1762,258 @@ yyreduce: ...@@ -1801,275 +1762,258 @@ yyreduce:
* within the mask to one (i.e. | in the * within the mask to one (i.e. | in the
* mask), all bits are one. * mask), all bits are one.
*/ */
if (((yyvsp[(2) - (2)].integer) > mask) && (((yyvsp[(2) - (2)].integer) | mask) != -1ULL)) if (((yyvsp[0].integer) > mask) && (((yyvsp[0].integer) | mask) != -1ULL))
print_error( ERROR(&(yylsp[0]), "Value out of range for"
"integer value out of range " " %d-bit array element", (yyvsp[-1].array).bits);
"%016lx (%d bits)", (yyvsp[(1) - (2)].array).bits);
} }
(yyval.array).data = data_append_integer((yyvsp[(1) - (2)].array).data, (yyvsp[(2) - (2)].integer), (yyvsp[(1) - (2)].array).bits); (yyval.array).data = data_append_integer((yyvsp[-1].array).data, (yyvsp[0].integer), (yyvsp[-1].array).bits);
} }
#line 1773 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 31: case 32:
/* Line 1787 of yacc.c */ #line 323 "dtc-parser.y" /* yacc.c:1646 */
#line 316 "dtc-parser.y"
{ {
uint64_t val = ~0ULL >> (64 - (yyvsp[(1) - (2)].array).bits); uint64_t val = ~0ULL >> (64 - (yyvsp[-1].array).bits);
if ((yyvsp[(1) - (2)].array).bits == 32) if ((yyvsp[-1].array).bits == 32)
(yyvsp[(1) - (2)].array).data = data_add_marker((yyvsp[(1) - (2)].array).data, (yyvsp[-1].array).data = data_add_marker((yyvsp[-1].array).data,
REF_PHANDLE, REF_PHANDLE,
(yyvsp[(2) - (2)].labelref)); (yyvsp[0].labelref));
else else
print_error("References are only allowed in " ERROR(&(yylsp[0]), "References are only allowed in "
"arrays with 32-bit elements."); "arrays with 32-bit elements.");
(yyval.array).data = data_append_integer((yyvsp[(1) - (2)].array).data, val, (yyvsp[(1) - (2)].array).bits); (yyval.array).data = data_append_integer((yyvsp[-1].array).data, val, (yyvsp[-1].array).bits);
}
break;
case 32:
/* Line 1787 of yacc.c */
#line 330 "dtc-parser.y"
{
(yyval.array).data = data_add_marker((yyvsp[(1) - (2)].array).data, LABEL, (yyvsp[(2) - (2)].labelref));
} }
#line 1791 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 33: case 33:
/* Line 1787 of yacc.c */ #line 337 "dtc-parser.y" /* yacc.c:1646 */
#line 337 "dtc-parser.y"
{
(yyval.integer) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64);
}
break;
case 34:
/* Line 1787 of yacc.c */
#line 341 "dtc-parser.y"
{ {
(yyval.integer) = eval_char_literal((yyvsp[(1) - (1)].literal)); (yyval.array).data = data_add_marker((yyvsp[-1].array).data, LABEL, (yyvsp[0].labelref));
} }
#line 1799 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 35: case 36:
/* Line 1787 of yacc.c */ #line 346 "dtc-parser.y" /* yacc.c:1646 */
#line 345 "dtc-parser.y"
{ {
(yyval.integer) = (yyvsp[(2) - (3)].integer); (yyval.integer) = (yyvsp[-1].integer);
} }
#line 1807 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 38: case 39:
/* Line 1787 of yacc.c */ #line 357 "dtc-parser.y" /* yacc.c:1646 */
#line 356 "dtc-parser.y" { (yyval.integer) = (yyvsp[-4].integer) ? (yyvsp[-2].integer) : (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (5)].integer) ? (yyvsp[(3) - (5)].integer) : (yyvsp[(5) - (5)].integer); } #line 1813 "dtc-parser.tab.c" /* yacc.c:1646 */
break;
case 40:
/* Line 1787 of yacc.c */
#line 361 "dtc-parser.y"
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) || (yyvsp[(3) - (3)].integer); }
break; break;
case 42: case 41:
/* Line 1787 of yacc.c */ #line 362 "dtc-parser.y" /* yacc.c:1646 */
#line 366 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) || (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) && (yyvsp[(3) - (3)].integer); } #line 1819 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 44: case 43:
/* Line 1787 of yacc.c */ #line 367 "dtc-parser.y" /* yacc.c:1646 */
#line 371 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) && (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) | (yyvsp[(3) - (3)].integer); } #line 1825 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 46: case 45:
/* Line 1787 of yacc.c */ #line 372 "dtc-parser.y" /* yacc.c:1646 */
#line 376 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) | (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) ^ (yyvsp[(3) - (3)].integer); } #line 1831 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 48: case 47:
/* Line 1787 of yacc.c */ #line 377 "dtc-parser.y" /* yacc.c:1646 */
#line 381 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) ^ (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) & (yyvsp[(3) - (3)].integer); } #line 1837 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 50: case 49:
/* Line 1787 of yacc.c */ #line 382 "dtc-parser.y" /* yacc.c:1646 */
#line 386 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) & (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) == (yyvsp[(3) - (3)].integer); } #line 1843 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 51: case 51:
/* Line 1787 of yacc.c */ #line 387 "dtc-parser.y" /* yacc.c:1646 */
#line 387 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) == (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) != (yyvsp[(3) - (3)].integer); } #line 1849 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 53: case 52:
/* Line 1787 of yacc.c */ #line 388 "dtc-parser.y" /* yacc.c:1646 */
#line 392 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) != (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) < (yyvsp[(3) - (3)].integer); } #line 1855 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 54: case 54:
/* Line 1787 of yacc.c */ #line 393 "dtc-parser.y" /* yacc.c:1646 */
#line 393 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) < (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer); } #line 1861 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 55: case 55:
/* Line 1787 of yacc.c */ #line 394 "dtc-parser.y" /* yacc.c:1646 */
#line 394 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) > (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) <= (yyvsp[(3) - (3)].integer); } #line 1867 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 56: case 56:
/* Line 1787 of yacc.c */ #line 395 "dtc-parser.y" /* yacc.c:1646 */
#line 395 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) <= (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) >= (yyvsp[(3) - (3)].integer); } #line 1873 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 57: case 57:
/* Line 1787 of yacc.c */ #line 396 "dtc-parser.y" /* yacc.c:1646 */
#line 399 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) >= (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) << (yyvsp[(3) - (3)].integer); } #line 1879 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 58: case 58:
/* Line 1787 of yacc.c */ #line 400 "dtc-parser.y" /* yacc.c:1646 */
#line 400 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) << (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) >> (yyvsp[(3) - (3)].integer); } #line 1885 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 60: case 59:
/* Line 1787 of yacc.c */ #line 401 "dtc-parser.y" /* yacc.c:1646 */
#line 405 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) >> (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) + (yyvsp[(3) - (3)].integer); } #line 1891 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 61: case 61:
/* Line 1787 of yacc.c */ #line 406 "dtc-parser.y" /* yacc.c:1646 */
#line 406 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) + (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) - (yyvsp[(3) - (3)].integer); } #line 1897 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 63: case 62:
/* Line 1787 of yacc.c */ #line 407 "dtc-parser.y" /* yacc.c:1646 */
#line 411 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) - (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) * (yyvsp[(3) - (3)].integer); } #line 1903 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 64: case 64:
/* Line 1787 of yacc.c */ #line 412 "dtc-parser.y" /* yacc.c:1646 */
#line 412 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) * (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) / (yyvsp[(3) - (3)].integer); } #line 1909 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 65: case 65:
/* Line 1787 of yacc.c */ #line 413 "dtc-parser.y" /* yacc.c:1646 */
#line 413 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) / (yyvsp[0].integer); }
{ (yyval.integer) = (yyvsp[(1) - (3)].integer) % (yyvsp[(3) - (3)].integer); } #line 1915 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 68: case 66:
/* Line 1787 of yacc.c */ #line 414 "dtc-parser.y" /* yacc.c:1646 */
#line 419 "dtc-parser.y" { (yyval.integer) = (yyvsp[-2].integer) % (yyvsp[0].integer); }
{ (yyval.integer) = -(yyvsp[(2) - (2)].integer); } #line 1921 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 69: case 69:
/* Line 1787 of yacc.c */ #line 420 "dtc-parser.y" /* yacc.c:1646 */
#line 420 "dtc-parser.y" { (yyval.integer) = -(yyvsp[0].integer); }
{ (yyval.integer) = ~(yyvsp[(2) - (2)].integer); } #line 1927 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 70: case 70:
/* Line 1787 of yacc.c */ #line 421 "dtc-parser.y" /* yacc.c:1646 */
#line 421 "dtc-parser.y" { (yyval.integer) = ~(yyvsp[0].integer); }
{ (yyval.integer) = !(yyvsp[(2) - (2)].integer); } #line 1933 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 71: case 71:
/* Line 1787 of yacc.c */ #line 422 "dtc-parser.y" /* yacc.c:1646 */
#line 426 "dtc-parser.y" { (yyval.integer) = !(yyvsp[0].integer); }
{ #line 1939 "dtc-parser.tab.c" /* yacc.c:1646 */
(yyval.data) = empty_data;
}
break; break;
case 72: case 72:
/* Line 1787 of yacc.c */ #line 427 "dtc-parser.y" /* yacc.c:1646 */
#line 430 "dtc-parser.y"
{ {
(yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); (yyval.data) = empty_data;
} }
#line 1947 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 73: case 73:
/* Line 1787 of yacc.c */ #line 431 "dtc-parser.y" /* yacc.c:1646 */
#line 434 "dtc-parser.y"
{ {
(yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); (yyval.data) = data_append_byte((yyvsp[-1].data), (yyvsp[0].byte));
} }
#line 1955 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 74: case 74:
/* Line 1787 of yacc.c */ #line 435 "dtc-parser.y" /* yacc.c:1646 */
#line 441 "dtc-parser.y"
{ {
(yyval.nodelist) = NULL; (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref));
} }
#line 1963 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 75: case 75:
/* Line 1787 of yacc.c */ #line 442 "dtc-parser.y" /* yacc.c:1646 */
#line 445 "dtc-parser.y"
{ {
(yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); (yyval.nodelist) = NULL;
} }
#line 1971 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 76: case 76:
/* Line 1787 of yacc.c */ #line 446 "dtc-parser.y" /* yacc.c:1646 */
#line 449 "dtc-parser.y"
{ {
print_error("syntax error: properties must precede subnodes"); (yyval.nodelist) = chain_node((yyvsp[-1].node), (yyvsp[0].nodelist));
YYERROR;
} }
#line 1979 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 77: case 77:
/* Line 1787 of yacc.c */ #line 450 "dtc-parser.y" /* yacc.c:1646 */
#line 457 "dtc-parser.y"
{ {
(yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename)); ERROR(&(yylsp[0]), "Properties must precede subnodes");
YYERROR;
} }
#line 1988 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 78: case 78:
/* Line 1787 of yacc.c */ #line 458 "dtc-parser.y" /* yacc.c:1646 */
#line 461 "dtc-parser.y"
{ {
(yyval.node) = name_node(build_node_delete(), (yyvsp[(2) - (3)].propnodename)); (yyval.node) = name_node((yyvsp[0].node), (yyvsp[-1].propnodename));
} }
#line 1996 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
case 79: case 79:
/* Line 1787 of yacc.c */ #line 462 "dtc-parser.y" /* yacc.c:1646 */
#line 465 "dtc-parser.y" {
(yyval.node) = name_node(build_node_delete(), (yyvsp[-1].propnodename));
}
#line 2004 "dtc-parser.tab.c" /* yacc.c:1646 */
break;
case 80:
#line 466 "dtc-parser.y" /* yacc.c:1646 */
{ {
add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref)); add_label(&(yyvsp[0].node)->labels, (yyvsp[-1].labelref));
(yyval.node) = (yyvsp[(2) - (2)].node); (yyval.node) = (yyvsp[0].node);
} }
#line 2013 "dtc-parser.tab.c" /* yacc.c:1646 */
break; break;
/* Line 1787 of yacc.c */ #line 2017 "dtc-parser.tab.c" /* yacc.c:1646 */
#line 2073 "dtc-parser.tab.c"
default: break; default: break;
} }
/* User semantic actions sometimes alter yychar, and that requires /* User semantic actions sometimes alter yychar, and that requires
...@@ -2090,8 +2034,9 @@ yyreduce: ...@@ -2090,8 +2034,9 @@ yyreduce:
YY_STACK_PRINT (yyss, yyssp); YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval; *++yyvsp = yyval;
*++yylsp = yyloc;
/* Now `shift' the result of the reduction. Determine what state /* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule that goes to, based on the state we popped back to and the rule
number reduced by. */ number reduced by. */
...@@ -2106,9 +2051,9 @@ yyreduce: ...@@ -2106,9 +2051,9 @@ yyreduce:
goto yynewstate; goto yynewstate;
/*------------------------------------. /*--------------------------------------.
| yyerrlab -- here on detecting error | | yyerrlab -- here on detecting error. |
`------------------------------------*/ `--------------------------------------*/
yyerrlab: yyerrlab:
/* Make sure we have latest lookahead translation. See comments at /* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */ user semantic actions for why this is necessary. */
...@@ -2154,7 +2099,7 @@ yyerrlab: ...@@ -2154,7 +2099,7 @@ yyerrlab:
#endif #endif
} }
yyerror_range[1] = yylloc;
if (yyerrstatus == 3) if (yyerrstatus == 3)
{ {
...@@ -2170,7 +2115,7 @@ yyerrlab: ...@@ -2170,7 +2115,7 @@ yyerrlab:
else else
{ {
yydestruct ("Error: discarding", yydestruct ("Error: discarding",
yytoken, &yylval); yytoken, &yylval, &yylloc);
yychar = YYEMPTY; yychar = YYEMPTY;
} }
} }
...@@ -2191,7 +2136,8 @@ yyerrorlab: ...@@ -2191,7 +2136,8 @@ yyerrorlab:
if (/*CONSTCOND*/ 0) if (/*CONSTCOND*/ 0)
goto yyerrorlab; goto yyerrorlab;
/* Do not reclaim the symbols of the rule which action triggered yyerror_range[1] = yylsp[1-yylen];
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */ this YYERROR. */
YYPOPSTACK (yylen); YYPOPSTACK (yylen);
yylen = 0; yylen = 0;
...@@ -2224,9 +2170,9 @@ yyerrlab1: ...@@ -2224,9 +2170,9 @@ yyerrlab1:
if (yyssp == yyss) if (yyssp == yyss)
YYABORT; YYABORT;
yyerror_range[1] = *yylsp;
yydestruct ("Error: popping", yydestruct ("Error: popping",
yystos[yystate], yyvsp); yystos[yystate], yyvsp, yylsp);
YYPOPSTACK (1); YYPOPSTACK (1);
yystate = *yyssp; yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp); YY_STACK_PRINT (yyss, yyssp);
...@@ -2236,6 +2182,11 @@ yyerrlab1: ...@@ -2236,6 +2182,11 @@ yyerrlab1:
*++yyvsp = yylval; *++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END YY_IGNORE_MAYBE_UNINITIALIZED_END
yyerror_range[2] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
the lookahead. YYLOC is available though. */
YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
*++yylsp = yyloc;
/* Shift the error token. */ /* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
...@@ -2275,16 +2226,16 @@ yyreturn: ...@@ -2275,16 +2226,16 @@ yyreturn:
user semantic actions for why this is necessary. */ user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar); yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead", yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval); yytoken, &yylval, &yylloc);
} }
/* Do not reclaim the symbols of the rule which action triggered /* Do not reclaim the symbols of the rule whose action triggered
this YYABORT or YYACCEPT. */ this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen); YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp); YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss) while (yyssp != yyss)
{ {
yydestruct ("Cleanup: popping", yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp); yystos[*yyssp], yyvsp, yylsp);
YYPOPSTACK (1); YYPOPSTACK (1);
} }
#ifndef yyoverflow #ifndef yyoverflow
...@@ -2295,72 +2246,12 @@ yyreturn: ...@@ -2295,72 +2246,12 @@ yyreturn:
if (yymsg != yymsgbuf) if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg); YYSTACK_FREE (yymsg);
#endif #endif
/* Make sure YYID is used. */ return yyresult;
return YYID (yyresult);
}
/* Line 2050 of yacc.c */
#line 471 "dtc-parser.y"
void print_error(char const *fmt, ...)
{
va_list va;
va_start(va, fmt);
srcpos_verror(&yylloc, fmt, va);
va_end(va);
treesource_error = 1;
}
void yyerror(char const *s) {
print_error("%s", s);
} }
#line 472 "dtc-parser.y" /* yacc.c:1906 */
static unsigned long long eval_literal(const char *s, int base, int bits)
{
unsigned long long val;
char *e;
errno = 0;
val = strtoull(s, &e, base);
if (*e) {
size_t uls = strspn(e, "UL");
if (e[uls])
print_error("bad characters in literal");
}
if ((errno == ERANGE)
|| ((bits < 64) && (val >= (1ULL << bits))))
print_error("literal out of range");
else if (errno != 0)
print_error("bad literal");
return val;
}
static unsigned char eval_char_literal(const char *s) void yyerror(char const *s)
{ {
int i = 1; ERROR(&yylloc, "%s", s);
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;
} }
/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* A Bison parser, made by GNU Bison 3.0.2. */
/* Bison interface for Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#ifndef YY_YY_DTC_PARSER_TAB_H_INCLUDED #ifndef YY_YY_DTC_PARSER_TAB_H_INCLUDED
# define YY_YY_DTC_PARSER_TAB_H_INCLUDED # define YY_YY_DTC_PARSER_TAB_H_INCLUDED
/* Enabling traces. */ /* Debug traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
# define YYDEBUG 0 # define YYDEBUG 0
#endif #endif
...@@ -40,12 +40,11 @@ ...@@ -40,12 +40,11 @@
extern int yydebug; extern int yydebug;
#endif #endif
/* Tokens. */ /* Token type. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers enum yytokentype
know about them. */ {
enum yytokentype {
DT_V1 = 258, DT_V1 = 258,
DT_MEMRESERVE = 259, DT_MEMRESERVE = 259,
DT_LSHIFT = 260, DT_LSHIFT = 260,
...@@ -62,26 +61,23 @@ extern int yydebug; ...@@ -62,26 +61,23 @@ extern int yydebug;
DT_PROPNODENAME = 271, DT_PROPNODENAME = 271,
DT_LITERAL = 272, DT_LITERAL = 272,
DT_CHAR_LITERAL = 273, DT_CHAR_LITERAL = 273,
DT_BASE = 274, DT_BYTE = 274,
DT_BYTE = 275, DT_STRING = 275,
DT_STRING = 276, DT_LABEL = 276,
DT_LABEL = 277, DT_REF = 277,
DT_REF = 278, DT_INCBIN = 278
DT_INCBIN = 279
}; };
#endif #endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{ {
/* Line 2053 of yacc.c */ #line 38 "dtc-parser.y" /* yacc.c:1909 */
#line 40 "dtc-parser.y"
char *propnodename; char *propnodename;
char *literal;
char *labelref; char *labelref;
unsigned int cbase;
uint8_t byte; uint8_t byte;
struct data data; struct data data;
...@@ -97,29 +93,29 @@ typedef union YYSTYPE ...@@ -97,29 +93,29 @@ typedef union YYSTYPE
struct reserve_info *re; struct reserve_info *re;
uint64_t integer; uint64_t integer;
#line 97 "dtc-parser.tab.h" /* yacc.c:1909 */
/* Line 2053 of yacc.c */ };
#line 103 "dtc-parser.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
#endif #endif
extern YYSTYPE yylval; /* Location type. */
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
#ifdef YYPARSE_PARAM typedef struct YYLTYPE YYLTYPE;
#if defined __STDC__ || defined __cplusplus struct YYLTYPE
int yyparse (void *YYPARSE_PARAM); {
#else int first_line;
int yyparse (); int first_column;
int last_line;
int last_column;
};
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif #endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
extern YYSTYPE yylval;
extern YYLTYPE yylloc;
int yyparse (void); int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_YY_DTC_PARSER_TAB_H_INCLUDED */ #endif /* !YY_YY_DTC_PARSER_TAB_H_INCLUDED */
...@@ -17,31 +17,27 @@ ...@@ -17,31 +17,27 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA * USA
*/ */
%{ %{
#include <stdio.h> #include <stdio.h>
#include "dtc.h" #include "dtc.h"
#include "srcpos.h" #include "srcpos.h"
YYLTYPE yylloc;
extern int yylex(void); extern int yylex(void);
extern void print_error(char const *fmt, ...);
extern void yyerror(char const *s); extern void yyerror(char const *s);
#define ERROR(loc, ...) \
do { \
srcpos_error((loc), "Error", __VA_ARGS__); \
treesource_error = true; \
} while (0)
extern struct boot_info *the_boot_info; extern struct boot_info *the_boot_info;
extern int treesource_error; extern bool 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 { %union {
char *propnodename; char *propnodename;
char *literal;
char *labelref; char *labelref;
unsigned int cbase;
uint8_t byte; uint8_t byte;
struct data data; struct data data;
...@@ -65,9 +61,8 @@ static unsigned char eval_char_literal(const char *s); ...@@ -65,9 +61,8 @@ static unsigned char eval_char_literal(const char *s);
%token DT_DEL_PROP %token DT_DEL_PROP
%token DT_DEL_NODE %token DT_DEL_NODE
%token <propnodename> DT_PROPNODENAME %token <propnodename> DT_PROPNODENAME
%token <literal> DT_LITERAL %token <integer> DT_LITERAL
%token <literal> DT_CHAR_LITERAL %token <integer> DT_CHAR_LITERAL
%token <cbase> DT_BASE
%token <byte> DT_BYTE %token <byte> DT_BYTE
%token <data> DT_STRING %token <data> DT_STRING
%token <labelref> DT_LABEL %token <labelref> DT_LABEL
...@@ -145,6 +140,18 @@ devicetree: ...@@ -145,6 +140,18 @@ devicetree:
{ {
$$ = merge_nodes($1, $3); $$ = merge_nodes($1, $3);
} }
| devicetree DT_LABEL DT_REF nodedef
{
struct node *target = get_node_by_ref($1, $3);
add_label(&target->labels, $2);
if (target)
merge_nodes(target, $4);
else
ERROR(&@3, "Label or path %s not found", $3);
$$ = $1;
}
| devicetree DT_REF nodedef | devicetree DT_REF nodedef
{ {
struct node *target = get_node_by_ref($1, $2); struct node *target = get_node_by_ref($1, $2);
...@@ -152,17 +159,18 @@ devicetree: ...@@ -152,17 +159,18 @@ devicetree:
if (target) if (target)
merge_nodes(target, $3); merge_nodes(target, $3);
else else
print_error("label or path, '%s', not found", $2); ERROR(&@2, "Label or path %s not found", $2);
$$ = $1; $$ = $1;
} }
| devicetree DT_DEL_NODE DT_REF ';' | devicetree DT_DEL_NODE DT_REF ';'
{ {
struct node *target = get_node_by_ref($1, $3); struct node *target = get_node_by_ref($1, $3);
if (!target) if (target)
print_error("label or path, '%s', not found", $3);
else
delete_node(target); delete_node(target);
else
ERROR(&@3, "Label or path %s not found", $3);
$$ = $1; $$ = $1;
} }
...@@ -230,9 +238,8 @@ propdata: ...@@ -230,9 +238,8 @@ propdata:
if ($6 != 0) if ($6 != 0)
if (fseek(f, $6, SEEK_SET) != 0) if (fseek(f, $6, SEEK_SET) != 0)
print_error("Couldn't seek to offset %llu in \"%s\": %s", die("Couldn't seek to offset %llu in \"%s\": %s",
(unsigned long long)$6, (unsigned long long)$6, $4.val,
$4.val,
strerror(errno)); strerror(errno));
d = data_copy_file(f, $8); d = data_copy_file(f, $8);
...@@ -274,18 +281,19 @@ propdataprefix: ...@@ -274,18 +281,19 @@ propdataprefix:
arrayprefix: arrayprefix:
DT_BITS DT_LITERAL '<' DT_BITS DT_LITERAL '<'
{ {
$$.data = empty_data; unsigned long long bits;
$$.bits = eval_literal($2, 0, 7);
if (($$.bits != 8) && bits = $2;
($$.bits != 16) &&
($$.bits != 32) && if ((bits != 8) && (bits != 16) &&
($$.bits != 64)) (bits != 32) && (bits != 64)) {
{ ERROR(&@2, "Array elements must be"
print_error("Only 8, 16, 32 and 64-bit elements" " 8, 16, 32 or 64-bits");
" are currently supported"); bits = 32;
$$.bits = 32;
} }
$$.data = empty_data;
$$.bits = bits;
} }
| '<' | '<'
{ {
...@@ -305,9 +313,8 @@ arrayprefix: ...@@ -305,9 +313,8 @@ arrayprefix:
* mask), all bits are one. * mask), all bits are one.
*/ */
if (($2 > mask) && (($2 | mask) != -1ULL)) if (($2 > mask) && (($2 | mask) != -1ULL))
print_error( ERROR(&@2, "Value out of range for"
"integer value out of range " " %d-bit array element", $1.bits);
"%016lx (%d bits)", $1.bits);
} }
$$.data = data_append_integer($1.data, $2, $1.bits); $$.data = data_append_integer($1.data, $2, $1.bits);
...@@ -321,7 +328,7 @@ arrayprefix: ...@@ -321,7 +328,7 @@ arrayprefix:
REF_PHANDLE, REF_PHANDLE,
$2); $2);
else else
print_error("References are only allowed in " ERROR(&@2, "References are only allowed in "
"arrays with 32-bit elements."); "arrays with 32-bit elements.");
$$.data = data_append_integer($1.data, val, $1.bits); $$.data = data_append_integer($1.data, val, $1.bits);
...@@ -334,13 +341,7 @@ arrayprefix: ...@@ -334,13 +341,7 @@ arrayprefix:
integer_prim: integer_prim:
DT_LITERAL DT_LITERAL
{
$$ = eval_literal($1, 0, 64);
}
| DT_CHAR_LITERAL | DT_CHAR_LITERAL
{
$$ = eval_char_literal($1);
}
| '(' integer_expr ')' | '(' integer_expr ')'
{ {
$$ = $2; $$ = $2;
...@@ -447,7 +448,7 @@ subnodes: ...@@ -447,7 +448,7 @@ subnodes:
} }
| subnode propdef | subnode propdef
{ {
print_error("syntax error: properties must precede subnodes"); ERROR(&@2, "Properties must precede subnodes");
YYERROR; YYERROR;
} }
; ;
...@@ -470,63 +471,7 @@ subnode: ...@@ -470,63 +471,7 @@ subnode:
%% %%
void print_error(char const *fmt, ...) void yyerror(char const *s)
{ {
va_list va; ERROR(&yylloc, "%s", s);
va_start(va, fmt);
srcpos_verror(&yylloc, fmt, va);
va_end(va);
treesource_error = 1;
}
void yyerror(char const *s) {
print_error("%s", s);
}
static unsigned long long eval_literal(const char *s, int base, int bits)
{
unsigned long long val;
char *e;
errno = 0;
val = strtoull(s, &e, base);
if (*e) {
size_t uls = strspn(e, "UL");
if (e[uls])
print_error("bad characters in literal");
}
if ((errno == ERANGE)
|| ((bits < 64) && (val >= (1ULL << bits))))
print_error("literal out of range");
else if (errno != 0)
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;
} }
...@@ -48,6 +48,8 @@ static void fill_fullpaths(struct node *tree, const char *prefix) ...@@ -48,6 +48,8 @@ static void fill_fullpaths(struct node *tree, const char *prefix)
} }
/* Usage related data. */ /* Usage related data. */
#define FDT_VERSION(version) _FDT_VERSION(version)
#define _FDT_VERSION(version) #version
static const char usage_synopsis[] = "dtc [options] <input file>"; static const char usage_synopsis[] = "dtc [options] <input file>";
static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv"; static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv";
static struct option const usage_long_opts[] = { static struct option const usage_long_opts[] = {
...@@ -82,9 +84,9 @@ static const char * const usage_opts_help[] = { ...@@ -82,9 +84,9 @@ static const char * const usage_opts_help[] = {
"\t\tdts - device tree source text\n" "\t\tdts - device tree source text\n"
"\t\tdtb - device tree blob\n" "\t\tdtb - device tree blob\n"
"\t\tasm - assembler source", "\t\tasm - assembler source",
"\n\tBlob version to produce, defaults to %d (for dtb and asm output)", //, DEFAULT_FDT_VERSION); "\n\tBlob version to produce, defaults to "FDT_VERSION(DEFAULT_FDT_VERSION)" (for dtb and asm output)",
"\n\tOutput dependency file", "\n\tOutput dependency file",
"\n\ttMake space for <number> reserve map entries (for dtb and asm output)", "\n\tMake space for <number> reserve map entries (for dtb and asm output)",
"\n\tMake the blob at least <bytes> long (extra space)", "\n\tMake the blob at least <bytes> long (extra space)",
"\n\tAdd padding to the blob of <bytes> long (extra space)", "\n\tAdd padding to the blob of <bytes> long (extra space)",
"\n\tSet the physical boot cpu", "\n\tSet the physical boot cpu",
...@@ -109,7 +111,7 @@ int main(int argc, char *argv[]) ...@@ -109,7 +111,7 @@ int main(int argc, char *argv[])
const char *outform = "dts"; const char *outform = "dts";
const char *outname = "-"; const char *outname = "-";
const char *depname = NULL; const char *depname = NULL;
int force = 0, sort = 0; bool force = false, sort = false;
const char *arg; const char *arg;
int opt; int opt;
FILE *outf = NULL; FILE *outf = NULL;
...@@ -148,7 +150,7 @@ int main(int argc, char *argv[]) ...@@ -148,7 +150,7 @@ int main(int argc, char *argv[])
padsize = strtol(optarg, NULL, 0); padsize = strtol(optarg, NULL, 0);
break; break;
case 'f': case 'f':
force = 1; force = true;
break; break;
case 'q': case 'q':
quiet++; quiet++;
...@@ -174,7 +176,7 @@ int main(int argc, char *argv[]) ...@@ -174,7 +176,7 @@ int main(int argc, char *argv[])
break; break;
case 's': case 's':
sort = 1; sort = true;
break; break;
case 'W': case 'W':
...@@ -237,7 +239,7 @@ int main(int argc, char *argv[]) ...@@ -237,7 +239,7 @@ int main(int argc, char *argv[])
if (streq(outname, "-")) { if (streq(outname, "-")) {
outf = stdout; outf = stdout;
} else { } else {
outf = fopen(outname, "w"); outf = fopen(outname, "wb");
if (! outf) if (! outf)
die("Couldn't open output file %s: %s\n", die("Couldn't open output file %s: %s\n",
outname, strerror(errno)); outname, strerror(errno));
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
#include "util.h" #include "util.h"
#ifdef DEBUG #ifdef DEBUG
#define debug(fmt,args...) printf(fmt, ##args) #define debug(...) printf(__VA_ARGS__)
#else #else
#define debug(fmt,args...) #define debug(...)
#endif #endif
...@@ -88,7 +88,7 @@ struct data { ...@@ -88,7 +88,7 @@ struct data {
}; };
#define empty_data ((struct data){ /* all .members = 0 or NULL */ }) #define empty_data ((struct data){ 0 /* all .members = 0 or NULL */ })
#define for_each_marker(m) \ #define for_each_marker(m) \
for (; (m); (m) = (m)->next) for (; (m); (m) = (m)->next)
...@@ -118,7 +118,7 @@ struct data data_append_align(struct data d, int align); ...@@ -118,7 +118,7 @@ struct data data_append_align(struct data d, int align);
struct data data_add_marker(struct data d, enum markertype type, char *ref); struct data data_add_marker(struct data d, enum markertype type, char *ref);
int data_is_one_string(struct data d); bool data_is_one_string(struct data d);
/* DT constraints */ /* DT constraints */
...@@ -127,13 +127,13 @@ int data_is_one_string(struct data d); ...@@ -127,13 +127,13 @@ int data_is_one_string(struct data d);
/* Live trees */ /* Live trees */
struct label { struct label {
int deleted; bool deleted;
char *label; char *label;
struct label *next; struct label *next;
}; };
struct property { struct property {
int deleted; bool deleted;
char *name; char *name;
struct data val; struct data val;
...@@ -143,7 +143,7 @@ struct property { ...@@ -143,7 +143,7 @@ struct property {
}; };
struct node { struct node {
int deleted; bool deleted;
char *name; char *name;
struct property *proplist; struct property *proplist;
struct node *children; struct node *children;
...@@ -247,8 +247,8 @@ void sort_tree(struct boot_info *bi); ...@@ -247,8 +247,8 @@ void sort_tree(struct boot_info *bi);
/* Checks */ /* Checks */
void parse_checks_option(bool warn, bool error, const char *optarg); void parse_checks_option(bool warn, bool error, const char *arg);
void process_checks(int force, struct boot_info *bi); void process_checks(bool force, struct boot_info *bi);
/* Flattened trees */ /* Flattened trees */
......
...@@ -261,7 +261,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, ...@@ -261,7 +261,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit,
{ {
struct property *prop; struct property *prop;
struct node *child; struct node *child;
int seen_name_prop = 0; bool seen_name_prop = false;
if (tree->deleted) if (tree->deleted)
return; return;
...@@ -279,7 +279,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, ...@@ -279,7 +279,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit,
int nameoff; int nameoff;
if (streq(prop->name, "name")) if (streq(prop->name, "name"))
seen_name_prop = 1; seen_name_prop = true;
nameoff = stringtable_insert(strbuf, prop->name); nameoff = stringtable_insert(strbuf, prop->name);
......
...@@ -37,26 +37,26 @@ static struct node *read_fstree(const char *dirname) ...@@ -37,26 +37,26 @@ static struct node *read_fstree(const char *dirname)
tree = build_node(NULL, NULL); tree = build_node(NULL, NULL);
while ((de = readdir(d)) != NULL) { while ((de = readdir(d)) != NULL) {
char *tmpnam; char *tmpname;
if (streq(de->d_name, ".") if (streq(de->d_name, ".")
|| streq(de->d_name, "..")) || streq(de->d_name, ".."))
continue; continue;
tmpnam = join_path(dirname, de->d_name); tmpname = join_path(dirname, de->d_name);
if (lstat(tmpnam, &st) < 0) if (lstat(tmpname, &st) < 0)
die("stat(%s): %s\n", tmpnam, strerror(errno)); die("stat(%s): %s\n", tmpname, strerror(errno));
if (S_ISREG(st.st_mode)) { if (S_ISREG(st.st_mode)) {
struct property *prop; struct property *prop;
FILE *pfile; FILE *pfile;
pfile = fopen(tmpnam, "r"); pfile = fopen(tmpname, "rb");
if (! pfile) { if (! pfile) {
fprintf(stderr, fprintf(stderr,
"WARNING: Cannot open %s: %s\n", "WARNING: Cannot open %s: %s\n",
tmpnam, strerror(errno)); tmpname, strerror(errno));
} else { } else {
prop = build_property(xstrdup(de->d_name), prop = build_property(xstrdup(de->d_name),
data_copy_file(pfile, data_copy_file(pfile,
...@@ -67,12 +67,12 @@ static struct node *read_fstree(const char *dirname) ...@@ -67,12 +67,12 @@ static struct node *read_fstree(const char *dirname)
} else if (S_ISDIR(st.st_mode)) { } else if (S_ISDIR(st.st_mode)) {
struct node *newchild; struct node *newchild;
newchild = read_fstree(tmpnam); newchild = read_fstree(tmpname);
newchild = name_node(newchild, xstrdup(de->d_name)); newchild = name_node(newchild, xstrdup(de->d_name));
add_child(tree, newchild); add_child(tree, newchild);
} }
free(tmpnam); free(tmpname);
} }
closedir(d); closedir(d);
...@@ -88,3 +88,4 @@ struct boot_info *dt_from_fs(const char *dirname) ...@@ -88,3 +88,4 @@ struct boot_info *dt_from_fs(const char *dirname)
return build_boot_info(NULL, tree, guess_boot_cpuid(tree)); return build_boot_info(NULL, tree, guess_boot_cpuid(tree));
} }
...@@ -6,5 +6,6 @@ ...@@ -6,5 +6,6 @@
LIBFDT_soname = libfdt.$(SHAREDLIB_EXT).1 LIBFDT_soname = libfdt.$(SHAREDLIB_EXT).1
LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h
LIBFDT_VERSION = version.lds LIBFDT_VERSION = version.lds
LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c \
fdt_addresses.c
LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o) LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)
...@@ -92,7 +92,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) ...@@ -92,7 +92,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
{ {
const uint32_t *tagp, *lenp; const fdt32_t *tagp, *lenp;
uint32_t tag; uint32_t tag;
int offset = startoffset; int offset = startoffset;
const char *p; const char *p;
...@@ -198,6 +198,34 @@ int fdt_next_node(const void *fdt, int offset, int *depth) ...@@ -198,6 +198,34 @@ int fdt_next_node(const void *fdt, int offset, int *depth)
return offset; return offset;
} }
int fdt_first_subnode(const void *fdt, int offset)
{
int depth = 0;
offset = fdt_next_node(fdt, offset, &depth);
if (offset < 0 || depth != 1)
return -FDT_ERR_NOTFOUND;
return offset;
}
int fdt_next_subnode(const void *fdt, int offset)
{
int depth = 1;
/*
* With respect to the parent, the depth of the next subnode will be
* the same as the last.
*/
do {
offset = fdt_next_node(fdt, offset, &depth);
if (offset < 0 || depth < 1)
return -FDT_ERR_NOTFOUND;
} while (depth > 1);
return offset;
}
const char *_fdt_find_string(const char *strtab, int tabsize, const char *s) const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)
{ {
int len = strlen(s) + 1; int len = strlen(s) + 1;
......
#ifndef _FDT_H #ifndef _FDT_H
#define _FDT_H #define _FDT_H
/*
* libfdt - Flat Device Tree manipulation
* Copyright (C) 2006 David Gibson, IBM Corporation.
* Copyright 2012 Kim Phillips, Freescale Semiconductor.
*
* 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
* without modification, are permitted provided that the following
* conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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.
*/
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
struct fdt_header { struct fdt_header {
uint32_t magic; /* magic word FDT_MAGIC */ fdt32_t magic; /* magic word FDT_MAGIC */
uint32_t totalsize; /* total size of DT block */ fdt32_t totalsize; /* total size of DT block */
uint32_t off_dt_struct; /* offset to structure */ fdt32_t off_dt_struct; /* offset to structure */
uint32_t off_dt_strings; /* offset to strings */ fdt32_t off_dt_strings; /* offset to strings */
uint32_t off_mem_rsvmap; /* offset to memory reserve map */ fdt32_t off_mem_rsvmap; /* offset to memory reserve map */
uint32_t version; /* format version */ fdt32_t version; /* format version */
uint32_t last_comp_version; /* last compatible version */ fdt32_t last_comp_version; /* last compatible version */
/* version 2 fields below */ /* version 2 fields below */
uint32_t boot_cpuid_phys; /* Which physical CPU id we're fdt32_t boot_cpuid_phys; /* Which physical CPU id we're
booting on */ booting on */
/* version 3 fields below */ /* version 3 fields below */
uint32_t size_dt_strings; /* size of the strings block */ fdt32_t size_dt_strings; /* size of the strings block */
/* version 17 fields below */ /* version 17 fields below */
uint32_t size_dt_struct; /* size of the structure block */ fdt32_t size_dt_struct; /* size of the structure block */
}; };
struct fdt_reserve_entry { struct fdt_reserve_entry {
uint64_t address; fdt64_t address;
uint64_t size; fdt64_t size;
}; };
struct fdt_node_header { struct fdt_node_header {
uint32_t tag; fdt32_t tag;
char name[0]; char name[0];
}; };
struct fdt_property { struct fdt_property {
uint32_t tag; fdt32_t tag;
uint32_t len; fdt32_t len;
uint32_t nameoff; fdt32_t nameoff;
char data[0]; char data[0];
}; };
#endif /* !__ASSEMBLY */ #endif /* !__ASSEMBLY */
#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ #define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */
#define FDT_TAGSIZE sizeof(uint32_t) #define FDT_TAGSIZE sizeof(fdt32_t)
#define FDT_BEGIN_NODE 0x1 /* Start node: full name */ #define FDT_BEGIN_NODE 0x1 /* Start node: full name */
#define FDT_END_NODE 0x2 /* End node */ #define FDT_END_NODE 0x2 /* End node */
...@@ -51,10 +102,10 @@ struct fdt_property { ...@@ -51,10 +102,10 @@ struct fdt_property {
#define FDT_NOP 0x4 /* nop */ #define FDT_NOP 0x4 /* nop */
#define FDT_END 0x9 #define FDT_END 0x9
#define FDT_V1_SIZE (7*sizeof(uint32_t)) #define FDT_V1_SIZE (7*sizeof(fdt32_t))
#define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(uint32_t)) #define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t))
#define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(uint32_t)) #define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t))
#define FDT_V16_SIZE FDT_V3_SIZE #define FDT_V16_SIZE FDT_V3_SIZE
#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(uint32_t)) #define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t))
#endif /* _FDT_H */ #endif /* _FDT_H */
...@@ -81,3 +81,4 @@ int fdt_create_empty_tree(void *buf, int bufsize) ...@@ -81,3 +81,4 @@ int fdt_create_empty_tree(void *buf, int bufsize)
return fdt_open_into(buf, buf, bufsize); return fdt_open_into(buf, buf, bufsize);
} }
...@@ -154,9 +154,9 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, ...@@ -154,9 +154,9 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
return fdt_subnode_offset_namelen(fdt, parentoffset, name, strlen(name)); return fdt_subnode_offset_namelen(fdt, parentoffset, name, strlen(name));
} }
int fdt_path_offset(const void *fdt, const char *path) int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)
{ {
const char *end = path + strlen(path); const char *end = path + namelen;
const char *p = path; const char *p = path;
int offset = 0; int offset = 0;
...@@ -164,7 +164,7 @@ int fdt_path_offset(const void *fdt, const char *path) ...@@ -164,7 +164,7 @@ int fdt_path_offset(const void *fdt, const char *path)
/* see if we have an alias */ /* see if we have an alias */
if (*path != '/') { if (*path != '/') {
const char *q = strchr(path, '/'); const char *q = memchr(path, '/', end - p);
if (!q) if (!q)
q = end; q = end;
...@@ -177,14 +177,15 @@ int fdt_path_offset(const void *fdt, const char *path) ...@@ -177,14 +177,15 @@ int fdt_path_offset(const void *fdt, const char *path)
p = q; p = q;
} }
while (*p) { while (p < end) {
const char *q; const char *q;
while (*p == '/') while (*p == '/') {
p++; p++;
if (! *p) if (p == end)
return offset; return offset;
q = strchr(p, '/'); }
q = memchr(p, '/', end - p);
if (! q) if (! q)
q = end; q = end;
...@@ -198,6 +199,11 @@ int fdt_path_offset(const void *fdt, const char *path) ...@@ -198,6 +199,11 @@ int fdt_path_offset(const void *fdt, const char *path)
return offset; return offset;
} }
int fdt_path_offset(const void *fdt, const char *path)
{
return fdt_path_offset_namelen(fdt, path, strlen(path));
}
const char *fdt_get_name(const void *fdt, int nodeoffset, int *len) const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)
{ {
const struct fdt_node_header *nh = _fdt_offset_ptr(fdt, nodeoffset); const struct fdt_node_header *nh = _fdt_offset_ptr(fdt, nodeoffset);
...@@ -322,7 +328,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset, ...@@ -322,7 +328,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset,
uint32_t fdt_get_phandle(const void *fdt, int nodeoffset) uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
{ {
const uint32_t *php; const fdt32_t *php;
int len; int len;
/* FIXME: This is a bit sub-optimal, since we potentially scan /* FIXME: This is a bit sub-optimal, since we potentially scan
...@@ -515,8 +521,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle) ...@@ -515,8 +521,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
return offset; /* error from fdt_next_node() */ return offset; /* error from fdt_next_node() */
} }
static int _fdt_stringlist_contains(const char *strlist, int listlen, int fdt_stringlist_contains(const char *strlist, int listlen, const char *str)
const char *str)
{ {
int len = strlen(str); int len = strlen(str);
const char *p; const char *p;
...@@ -542,7 +547,7 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset, ...@@ -542,7 +547,7 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset,
prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); prop = fdt_getprop(fdt, nodeoffset, "compatible", &len);
if (!prop) if (!prop)
return len; return len;
if (_fdt_stringlist_contains(prop, len, compatible)) if (fdt_stringlist_contains(prop, len, compatible))
return 0; return 0;
else else
return 1; return 1;
......
...@@ -84,9 +84,9 @@ static int _fdt_rw_check_header(void *fdt) ...@@ -84,9 +84,9 @@ static int _fdt_rw_check_header(void *fdt)
#define FDT_RW_CHECK_HEADER(fdt) \ #define FDT_RW_CHECK_HEADER(fdt) \
{ \ { \
int err; \ int __err; \
if ((err = _fdt_rw_check_header(fdt)) != 0) \ if ((__err = _fdt_rw_check_header(fdt)) != 0) \
return err; \ return __err; \
} }
static inline int _fdt_data_size(void *fdt) static inline int _fdt_data_size(void *fdt)
...@@ -339,7 +339,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset, ...@@ -339,7 +339,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
int nodelen; int nodelen;
int err; int err;
uint32_t tag; uint32_t tag;
uint32_t *endtag; fdt32_t *endtag;
FDT_RW_CHECK_HEADER(fdt); FDT_RW_CHECK_HEADER(fdt);
...@@ -366,7 +366,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset, ...@@ -366,7 +366,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE); nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
memset(nh->name, 0, FDT_TAGALIGN(namelen+1)); memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
memcpy(nh->name, name, namelen); memcpy(nh->name, name, namelen);
endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE); endtag = (fdt32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
*endtag = cpu_to_fdt32(FDT_END_NODE); *endtag = cpu_to_fdt32(FDT_END_NODE);
return offset; return offset;
......
...@@ -107,6 +107,38 @@ int fdt_create(void *buf, int bufsize) ...@@ -107,6 +107,38 @@ int fdt_create(void *buf, int bufsize)
return 0; return 0;
} }
int fdt_resize(void *fdt, void *buf, int bufsize)
{
size_t headsize, tailsize;
char *oldtail, *newtail;
FDT_SW_CHECK_HEADER(fdt);
headsize = fdt_off_dt_struct(fdt);
tailsize = fdt_size_dt_strings(fdt);
if ((headsize + tailsize) > bufsize)
return -FDT_ERR_NOSPACE;
oldtail = (char *)fdt + fdt_totalsize(fdt) - tailsize;
newtail = (char *)buf + bufsize - tailsize;
/* Two cases to avoid clobbering data if the old and new
* buffers partially overlap */
if (buf <= fdt) {
memmove(buf, fdt, headsize);
memmove(newtail, oldtail, tailsize);
} else {
memmove(newtail, oldtail, tailsize);
memmove(buf, fdt, headsize);
}
fdt_set_off_dt_strings(buf, bufsize);
fdt_set_totalsize(buf, bufsize);
return 0;
}
int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size) int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size)
{ {
struct fdt_reserve_entry *re; struct fdt_reserve_entry *re;
...@@ -153,7 +185,7 @@ int fdt_begin_node(void *fdt, const char *name) ...@@ -153,7 +185,7 @@ int fdt_begin_node(void *fdt, const char *name)
int fdt_end_node(void *fdt) int fdt_end_node(void *fdt)
{ {
uint32_t *en; fdt32_t *en;
FDT_SW_CHECK_HEADER(fdt); FDT_SW_CHECK_HEADER(fdt);
...@@ -213,7 +245,7 @@ int fdt_property(void *fdt, const char *name, const void *val, int len) ...@@ -213,7 +245,7 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
int fdt_finish(void *fdt) int fdt_finish(void *fdt)
{ {
char *p = (char *)fdt; char *p = (char *)fdt;
uint32_t *end; fdt32_t *end;
int oldstroffset, newstroffset; int oldstroffset, newstroffset;
uint32_t tag; uint32_t tag;
int offset, nextoffset; int offset, nextoffset;
......
...@@ -74,7 +74,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, ...@@ -74,7 +74,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
static void _fdt_nop_region(void *start, int len) static void _fdt_nop_region(void *start, int len)
{ {
uint32_t *p; fdt32_t *p;
for (p = start; (char *)p < ((char *)start + len); p++) for (p = start; (char *)p < ((char *)start + len); p++)
*p = cpu_to_fdt32(FDT_NOP); *p = cpu_to_fdt32(FDT_NOP);
......
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <libfdt_env.h> #include "libfdt_env.h"
#include <fdt.h> #include "fdt.h"
#define FDT_FIRST_SUPPORTED_VERSION 0x10 #define FDT_FIRST_SUPPORTED_VERSION 0x10
#define FDT_LAST_SUPPORTED_VERSION 0x11 #define FDT_LAST_SUPPORTED_VERSION 0x11
...@@ -116,7 +116,12 @@ ...@@ -116,7 +116,12 @@
* Should never be returned, if it is, it indicates a bug in * Should never be returned, if it is, it indicates a bug in
* libfdt itself. */ * libfdt itself. */
#define FDT_ERR_MAX 13 /* Errors in device tree content */
#define FDT_ERR_BADNCELLS 14
/* FDT_ERR_BADNCELLS: Device tree has a #address-cells, #size-cells
* or similar property with a bad format or value */
#define FDT_ERR_MAX 14
/**********************************************************************/ /**********************************************************************/
/* Low-level functions (you probably don't need these) */ /* Low-level functions (you probably don't need these) */
...@@ -136,6 +141,28 @@ uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset); ...@@ -136,6 +141,28 @@ uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
int fdt_next_node(const void *fdt, int offset, int *depth); int fdt_next_node(const void *fdt, int offset, int *depth);
/**
* fdt_first_subnode() - get offset of first direct subnode
*
* @fdt: FDT blob
* @offset: Offset of node to check
* @return offset of first subnode, or -FDT_ERR_NOTFOUND if there is none
*/
int fdt_first_subnode(const void *fdt, int offset);
/**
* fdt_next_subnode() - get offset of next direct subnode
*
* After first calling fdt_first_subnode(), call this function repeatedly to
* get direct subnodes of a parent node.
*
* @fdt: FDT blob
* @offset: Offset of previous subnode
* @return offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more
* subnodes
*/
int fdt_next_subnode(const void *fdt, int offset);
/**********************************************************************/ /**********************************************************************/
/* General functions */ /* General functions */
/**********************************************************************/ /**********************************************************************/
...@@ -295,6 +322,17 @@ int fdt_subnode_offset_namelen(const void *fdt, int parentoffset, ...@@ -295,6 +322,17 @@ int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
*/ */
int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name); int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
/**
* fdt_path_offset_namelen - find a tree node by its full path
* @fdt: pointer to the device tree blob
* @path: full path of the node to locate
* @namelen: number of characters of path to consider
*
* Identical to fdt_path_offset(), but only consider the first namelen
* characters of path as the path name.
*/
int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
/** /**
* fdt_path_offset - find a tree node by its full path * fdt_path_offset - find a tree node by its full path
* @fdt: pointer to the device tree blob * @fdt: pointer to the device tree blob
...@@ -582,7 +620,7 @@ const char *fdt_get_alias_namelen(const void *fdt, ...@@ -582,7 +620,7 @@ const char *fdt_get_alias_namelen(const void *fdt,
* value of the property named 'name' in the node /aliases. * value of the property named 'name' in the node /aliases.
* *
* returns: * returns:
* a pointer to the expansion of the alias named 'name', of it exists * a pointer to the expansion of the alias named 'name', if it exists
* NULL, if the given alias or the /aliases node does not exist * NULL, if the given alias or the /aliases node does not exist
*/ */
const char *fdt_get_alias(const void *fdt, const char *name); const char *fdt_get_alias(const void *fdt, const char *name);
...@@ -816,6 +854,75 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset, ...@@ -816,6 +854,75 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset,
int fdt_node_offset_by_compatible(const void *fdt, int startoffset, int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
const char *compatible); const char *compatible);
/**
* fdt_stringlist_contains - check a string list property for a string
* @strlist: Property containing a list of strings to check
* @listlen: Length of property
* @str: String to search for
*
* This is a utility function provided for convenience. The list contains
* one or more strings, each terminated by \0, as is found in a device tree
* "compatible" property.
*
* @return: 1 if the string is found in the list, 0 not found, or invalid list
*/
int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);
/**********************************************************************/
/* Read-only functions (addressing related) */
/**********************************************************************/
/**
* FDT_MAX_NCELLS - maximum value for #address-cells and #size-cells
*
* This is the maximum value for #address-cells, #size-cells and
* similar properties that will be processed by libfdt. IEE1275
* requires that OF implementations handle values up to 4.
* Implementations may support larger values, but in practice higher
* values aren't used.
*/
#define FDT_MAX_NCELLS 4
/**
* fdt_address_cells - retrieve address size for a bus represented in the tree
* @fdt: pointer to the device tree blob
* @nodeoffset: offset of the node to find the address size for
*
* When the node has a valid #address-cells property, returns its value.
*
* returns:
* 0 <= n < FDT_MAX_NCELLS, on success
* 2, if the node has no #address-cells property
* -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid #address-cells property
* -FDT_ERR_BADMAGIC,
* -FDT_ERR_BADVERSION,
* -FDT_ERR_BADSTATE,
* -FDT_ERR_BADSTRUCTURE,
* -FDT_ERR_TRUNCATED, standard meanings
*/
int fdt_address_cells(const void *fdt, int nodeoffset);
/**
* fdt_size_cells - retrieve address range size for a bus represented in the
* tree
* @fdt: pointer to the device tree blob
* @nodeoffset: offset of the node to find the address range size for
*
* When the node has a valid #size-cells property, returns its value.
*
* returns:
* 0 <= n < FDT_MAX_NCELLS, on success
* 2, if the node has no #address-cells property
* -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid #size-cells property
* -FDT_ERR_BADMAGIC,
* -FDT_ERR_BADVERSION,
* -FDT_ERR_BADSTATE,
* -FDT_ERR_BADSTRUCTURE,
* -FDT_ERR_TRUNCATED, standard meanings
*/
int fdt_size_cells(const void *fdt, int nodeoffset);
/**********************************************************************/ /**********************************************************************/
/* Write-in-place functions */ /* Write-in-place functions */
/**********************************************************************/ /**********************************************************************/
...@@ -882,8 +989,8 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, ...@@ -882,8 +989,8 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset, static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
const char *name, uint32_t val) const char *name, uint32_t val)
{ {
val = cpu_to_fdt32(val); fdt32_t tmp = cpu_to_fdt32(val);
return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val)); return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
} }
/** /**
...@@ -917,8 +1024,8 @@ static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset, ...@@ -917,8 +1024,8 @@ static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset, static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,
const char *name, uint64_t val) const char *name, uint64_t val)
{ {
val = cpu_to_fdt64(val); fdt64_t tmp = cpu_to_fdt64(val);
return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val)); return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
} }
/** /**
...@@ -987,19 +1094,20 @@ int fdt_nop_node(void *fdt, int nodeoffset); ...@@ -987,19 +1094,20 @@ int fdt_nop_node(void *fdt, int nodeoffset);
/**********************************************************************/ /**********************************************************************/
int fdt_create(void *buf, int bufsize); int fdt_create(void *buf, int bufsize);
int fdt_resize(void *fdt, void *buf, int bufsize);
int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size); int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size);
int fdt_finish_reservemap(void *fdt); int fdt_finish_reservemap(void *fdt);
int fdt_begin_node(void *fdt, const char *name); int fdt_begin_node(void *fdt, const char *name);
int fdt_property(void *fdt, const char *name, const void *val, int len); int fdt_property(void *fdt, const char *name, const void *val, int len);
static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val) static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)
{ {
val = cpu_to_fdt32(val); fdt32_t tmp = cpu_to_fdt32(val);
return fdt_property(fdt, name, &val, sizeof(val)); return fdt_property(fdt, name, &tmp, sizeof(tmp));
} }
static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val) static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)
{ {
val = cpu_to_fdt64(val); fdt64_t tmp = cpu_to_fdt64(val);
return fdt_property(fdt, name, &val, sizeof(val)); return fdt_property(fdt, name, &tmp, sizeof(tmp));
} }
static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
{ {
...@@ -1154,8 +1262,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, ...@@ -1154,8 +1262,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name, static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
uint32_t val) uint32_t val)
{ {
val = cpu_to_fdt32(val); fdt32_t tmp = cpu_to_fdt32(val);
return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val)); return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
} }
/** /**
...@@ -1189,8 +1297,8 @@ static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name, ...@@ -1189,8 +1297,8 @@ static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name, static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,
uint64_t val) uint64_t val)
{ {
val = cpu_to_fdt64(val); fdt64_t tmp = cpu_to_fdt64(val);
return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val)); return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
} }
/** /**
...@@ -1296,8 +1404,8 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name, ...@@ -1296,8 +1404,8 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
static inline int fdt_appendprop_u32(void *fdt, int nodeoffset, static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
const char *name, uint32_t val) const char *name, uint32_t val)
{ {
val = cpu_to_fdt32(val); fdt32_t tmp = cpu_to_fdt32(val);
return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val)); return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
} }
/** /**
...@@ -1331,8 +1439,8 @@ static inline int fdt_appendprop_u32(void *fdt, int nodeoffset, ...@@ -1331,8 +1439,8 @@ static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
static inline int fdt_appendprop_u64(void *fdt, int nodeoffset, static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,
const char *name, uint64_t val) const char *name, uint64_t val)
{ {
val = cpu_to_fdt64(val); fdt64_t tmp = cpu_to_fdt64(val);
return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val)); return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
} }
/** /**
......
#ifndef _LIBFDT_ENV_H #ifndef _LIBFDT_ENV_H
#define _LIBFDT_ENV_H #define _LIBFDT_ENV_H
/*
* libfdt - Flat Device Tree manipulation
* Copyright (C) 2006 David Gibson, IBM Corporation.
* Copyright 2012 Kim Phillips, Freescale Semiconductor.
*
* 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
* without modification, are permitted provided that the following
* conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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.
*/
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#define EXTRACT_BYTE(n) ((unsigned long long)((uint8_t *)&x)[n]) #ifdef __CHECKER__
static inline uint16_t fdt16_to_cpu(uint16_t x) #define __force __attribute__((force))
#define __bitwise __attribute__((bitwise))
#else
#define __force
#define __bitwise
#endif
typedef uint16_t __bitwise fdt16_t;
typedef uint32_t __bitwise fdt32_t;
typedef uint64_t __bitwise fdt64_t;
#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n])
#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
#define CPU_TO_FDT32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \
(EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))
#define CPU_TO_FDT64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \
(EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \
(EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
(EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))
static inline uint16_t fdt16_to_cpu(fdt16_t x)
{
return (__force uint16_t)CPU_TO_FDT16(x);
}
static inline fdt16_t cpu_to_fdt16(uint16_t x)
{ {
return (EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1); return (__force fdt16_t)CPU_TO_FDT16(x);
} }
#define cpu_to_fdt16(x) fdt16_to_cpu(x)
static inline uint32_t fdt32_to_cpu(uint32_t x) static inline uint32_t fdt32_to_cpu(fdt32_t x)
{ {
return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3); return (__force uint32_t)CPU_TO_FDT32(x);
}
static inline fdt32_t cpu_to_fdt32(uint32_t x)
{
return (__force fdt32_t)CPU_TO_FDT32(x);
} }
#define cpu_to_fdt32(x) fdt32_to_cpu(x)
static inline uint64_t fdt64_to_cpu(uint64_t x) static inline uint64_t fdt64_to_cpu(fdt64_t x)
{
return (__force uint64_t)CPU_TO_FDT64(x);
}
static inline fdt64_t cpu_to_fdt64(uint64_t x)
{ {
return (EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) << 40) | (EXTRACT_BYTE(3) << 32) return (__force fdt64_t)CPU_TO_FDT64(x);
| (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8) | EXTRACT_BYTE(7);
} }
#define cpu_to_fdt64(x) fdt64_to_cpu(x) #undef CPU_TO_FDT64
#undef CPU_TO_FDT32
#undef CPU_TO_FDT16
#undef EXTRACT_BYTE #undef EXTRACT_BYTE
#endif /* _LIBFDT_ENV_H */ #endif /* _LIBFDT_ENV_H */
...@@ -57,9 +57,9 @@ ...@@ -57,9 +57,9 @@
#define FDT_CHECK_HEADER(fdt) \ #define FDT_CHECK_HEADER(fdt) \
{ \ { \
int err; \ int __err; \
if ((err = fdt_check_header(fdt)) != 0) \ if ((__err = fdt_check_header(fdt)) != 0) \
return err; \ return __err; \
} }
int _fdt_check_node_offset(const void *fdt, int offset); int _fdt_check_node_offset(const void *fdt, int offset);
......
...@@ -511,7 +511,9 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle) ...@@ -511,7 +511,9 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle)
struct node *get_node_by_ref(struct node *tree, const char *ref) struct node *get_node_by_ref(struct node *tree, const char *ref)
{ {
if (ref[0] == '/') if (streq(ref, "/"))
return tree;
else if (ref[0] == '/')
return get_node_by_path(tree, ref); return get_node_by_path(tree, ref);
else else
return get_node_by_label(tree, ref); return get_node_by_label(tree, ref);
......
...@@ -34,7 +34,7 @@ struct search_path { ...@@ -34,7 +34,7 @@ struct search_path {
static struct search_path *search_path_head, **search_path_tail; static struct search_path *search_path_head, **search_path_tail;
static char *dirname(const char *path) static char *get_dirname(const char *path)
{ {
const char *slash = strrchr(path, '/'); const char *slash = strrchr(path, '/');
...@@ -77,7 +77,7 @@ static char *try_open(const char *dirname, const char *fname, FILE **fp) ...@@ -77,7 +77,7 @@ static char *try_open(const char *dirname, const char *fname, FILE **fp)
else else
fullname = join_path(dirname, fname); fullname = join_path(dirname, fname);
*fp = fopen(fullname, "r"); *fp = fopen(fullname, "rb");
if (!*fp) { if (!*fp) {
free(fullname); free(fullname);
fullname = NULL; fullname = NULL;
...@@ -150,7 +150,7 @@ void srcfile_push(const char *fname) ...@@ -150,7 +150,7 @@ void srcfile_push(const char *fname)
srcfile = xmalloc(sizeof(*srcfile)); srcfile = xmalloc(sizeof(*srcfile));
srcfile->f = srcfile_relative_open(fname, &srcfile->name); srcfile->f = srcfile_relative_open(fname, &srcfile->name);
srcfile->dir = dirname(srcfile->name); srcfile->dir = get_dirname(srcfile->name);
srcfile->prev = current_srcfile; srcfile->prev = current_srcfile;
srcfile->lineno = 1; srcfile->lineno = 1;
...@@ -159,7 +159,7 @@ void srcfile_push(const char *fname) ...@@ -159,7 +159,7 @@ void srcfile_push(const char *fname)
current_srcfile = srcfile; current_srcfile = srcfile;
} }
int srcfile_pop(void) bool srcfile_pop(void)
{ {
struct srcfile_state *srcfile = current_srcfile; struct srcfile_state *srcfile = current_srcfile;
...@@ -177,7 +177,7 @@ int srcfile_pop(void) ...@@ -177,7 +177,7 @@ int srcfile_pop(void)
* fix this we could either allocate all the files from a * fix this we could either allocate all the files from a
* table, or use a pool allocator. */ * table, or use a pool allocator. */
return current_srcfile ? 1 : 0; return current_srcfile ? true : false;
} }
void srcfile_add_search_path(const char *dirname) void srcfile_add_search_path(const char *dirname)
...@@ -290,42 +290,27 @@ srcpos_string(struct srcpos *pos) ...@@ -290,42 +290,27 @@ srcpos_string(struct srcpos *pos)
return pos_str; return pos_str;
} }
void void srcpos_verror(struct srcpos *pos, const char *prefix,
srcpos_verror(struct srcpos *pos, char const *fmt, va_list va) const char *fmt, va_list va)
{ {
const char *srcstr; char *srcstr;
srcstr = srcpos_string(pos); srcstr = srcpos_string(pos);
fprintf(stderr, "Error: %s ", srcstr); fprintf(stderr, "%s: %s ", prefix, srcstr);
vfprintf(stderr, fmt, va); vfprintf(stderr, fmt, va);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
}
void free(srcstr);
srcpos_error(struct srcpos *pos, char const *fmt, ...)
{
va_list va;
va_start(va, fmt);
srcpos_verror(pos, fmt, va);
va_end(va);
} }
void srcpos_error(struct srcpos *pos, const char *prefix,
void const char *fmt, ...)
srcpos_warn(struct srcpos *pos, char const *fmt, ...)
{ {
const char *srcstr;
va_list va; va_list va;
va_start(va, fmt);
srcstr = srcpos_string(pos);
fprintf(stderr, "Warning: %s ", srcstr);
vfprintf(stderr, fmt, va);
fprintf(stderr, "\n");
va_start(va, fmt);
srcpos_verror(pos, prefix, fmt, va);
va_end(va); va_end(va);
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define _SRCPOS_H_ #define _SRCPOS_H_
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
struct srcfile_state { struct srcfile_state {
FILE *f; FILE *f;
...@@ -55,7 +56,7 @@ extern struct srcfile_state *current_srcfile; /* = NULL */ ...@@ -55,7 +56,7 @@ extern struct srcfile_state *current_srcfile; /* = NULL */
FILE *srcfile_relative_open(const char *fname, char **fullnamep); FILE *srcfile_relative_open(const char *fname, char **fullnamep);
void srcfile_push(const char *fname); void srcfile_push(const char *fname);
int srcfile_pop(void); bool srcfile_pop(void);
/** /**
* Add a new directory to the search path for input files * Add a new directory to the search path for input files
...@@ -106,12 +107,12 @@ extern struct srcpos *srcpos_copy(struct srcpos *pos); ...@@ -106,12 +107,12 @@ extern struct srcpos *srcpos_copy(struct srcpos *pos);
extern char *srcpos_string(struct srcpos *pos); extern char *srcpos_string(struct srcpos *pos);
extern void srcpos_dump(struct srcpos *pos); extern void srcpos_dump(struct srcpos *pos);
extern void srcpos_verror(struct srcpos *pos, char const *, va_list va) extern void srcpos_verror(struct srcpos *pos, const char *prefix,
__attribute__((format(printf, 2, 0))); const char *fmt, va_list va)
extern void srcpos_error(struct srcpos *pos, char const *, ...) __attribute__((format(printf, 3, 0)));
__attribute__((format(printf, 2, 3))); extern void srcpos_error(struct srcpos *pos, const char *prefix,
extern void srcpos_warn(struct srcpos *pos, char const *, ...) const char *fmt, ...)
__attribute__((format(printf, 2, 3))); __attribute__((format(printf, 3, 4)));
extern void srcpos_set_line(char *f, int l); extern void srcpos_set_line(char *f, int l);
......
...@@ -26,12 +26,12 @@ extern int yyparse(void); ...@@ -26,12 +26,12 @@ extern int yyparse(void);
extern YYLTYPE yylloc; extern YYLTYPE yylloc;
struct boot_info *the_boot_info; struct boot_info *the_boot_info;
int treesource_error; bool treesource_error;
struct boot_info *dt_from_source(const char *fname) struct boot_info *dt_from_source(const char *fname)
{ {
the_boot_info = NULL; the_boot_info = NULL;
treesource_error = 0; treesource_error = false;
srcfile_push(fname); srcfile_push(fname);
yyin = current_srcfile->f; yyin = current_srcfile->f;
...@@ -54,9 +54,9 @@ static void write_prefix(FILE *f, int level) ...@@ -54,9 +54,9 @@ static void write_prefix(FILE *f, int level)
fputc('\t', f); fputc('\t', f);
} }
static int isstring(char c) static bool isstring(char c)
{ {
return (isprint(c) return (isprint((unsigned char)c)
|| (c == '\0') || (c == '\0')
|| strchr("\a\b\t\n\v\f\r", c)); || strchr("\a\b\t\n\v\f\r", c));
} }
...@@ -109,7 +109,7 @@ static void write_propval_string(FILE *f, struct data val) ...@@ -109,7 +109,7 @@ static void write_propval_string(FILE *f, struct data val)
break; break;
case '\0': case '\0':
fprintf(f, "\", "); fprintf(f, "\", ");
while (m && (m->offset < i)) { while (m && (m->offset <= (i + 1))) {
if (m->type == LABEL) { if (m->type == LABEL) {
assert(m->offset == (i+1)); assert(m->offset == (i+1));
fprintf(f, "%s: ", m->ref); fprintf(f, "%s: ", m->ref);
...@@ -119,7 +119,7 @@ static void write_propval_string(FILE *f, struct data val) ...@@ -119,7 +119,7 @@ static void write_propval_string(FILE *f, struct data val)
fprintf(f, "\""); fprintf(f, "\"");
break; break;
default: default:
if (isprint(c)) if (isprint((unsigned char)c))
fprintf(f, "%c", c); fprintf(f, "%c", c);
else else
fprintf(f, "\\x%02hhx", c); fprintf(f, "\\x%02hhx", c);
...@@ -178,7 +178,7 @@ static void write_propval_bytes(FILE *f, struct data val) ...@@ -178,7 +178,7 @@ static void write_propval_bytes(FILE *f, struct data val)
m = m->next; m = m->next;
} }
fprintf(f, "%02hhx", *bp++); fprintf(f, "%02hhx", (unsigned char)(*bp++));
if ((const void *)bp >= propend) if ((const void *)bp >= propend)
break; break;
fprintf(f, " "); fprintf(f, " ");
...@@ -281,3 +281,4 @@ void dt_to_source(FILE *f, struct boot_info *bi) ...@@ -281,3 +281,4 @@ void dt_to_source(FILE *f, struct boot_info *bi)
write_tree_source_node(f, bi->dt, 0); write_tree_source_node(f, bi->dt, 0);
} }
...@@ -34,6 +34,7 @@ DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c ...@@ -34,6 +34,7 @@ DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c
srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \ srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \
dtc-lexer.l dtc-parser.y" dtc-lexer.l dtc-parser.y"
DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h" DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h"
LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_empty_tree.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h"
# Build DTC # Build DTC
cd $DTC_UPSTREAM_PATH cd $DTC_UPSTREAM_PATH
...@@ -50,5 +51,13 @@ for f in $DTC_GENERATED; do ...@@ -50,5 +51,13 @@ for f in $DTC_GENERATED; do
cp ${DTC_UPSTREAM_PATH}/$f ${f}_shipped cp ${DTC_UPSTREAM_PATH}/$f ${f}_shipped
git add ${f}_shipped git add ${f}_shipped
done done
for f in $LIBFDT_SOURCE; do
cp ${DTC_UPSTREAM_PATH}/libfdt/${f} libfdt/${f}
git add libfdt/${f}
done
sed -i -- 's/#include <libfdt_env.h>/#include "libfdt_env.h"/g' ./libfdt/libfdt.h
sed -i -- 's/#include <fdt.h>/#include "fdt.h"/g' ./libfdt/libfdt.h
git add ./libfdt/libfdt.h
git commit -e -v -m "scripts/dtc: Update to upstream version [CHANGEME]" git commit -e -v -m "scripts/dtc: Update to upstream version [CHANGEME]"
...@@ -39,11 +39,11 @@ ...@@ -39,11 +39,11 @@
char *xstrdup(const char *s) char *xstrdup(const char *s)
{ {
int len = strlen(s) + 1; int len = strlen(s) + 1;
char *dup = xmalloc(len); char *d = xmalloc(len);
memcpy(dup, s, len); memcpy(d, s, len);
return dup; return d;
} }
char *join_path(const char *path, const char *name) char *join_path(const char *path, const char *name)
...@@ -70,7 +70,7 @@ char *join_path(const char *path, const char *name) ...@@ -70,7 +70,7 @@ char *join_path(const char *path, const char *name)
return str; return str;
} }
int util_is_printable_string(const void *data, int len) bool util_is_printable_string(const void *data, int len)
{ {
const char *s = data; const char *s = data;
const char *ss, *se; const char *ss, *se;
...@@ -87,7 +87,7 @@ int util_is_printable_string(const void *data, int len) ...@@ -87,7 +87,7 @@ int util_is_printable_string(const void *data, int len)
while (s < se) { while (s < se) {
ss = s; ss = s;
while (s < se && *s && isprint(*s)) while (s < se && *s && isprint((unsigned char)*s))
s++; s++;
/* not zero, or not done yet */ /* not zero, or not done yet */
...@@ -219,10 +219,6 @@ int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len) ...@@ -219,10 +219,6 @@ int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len)
if (offset == bufsize) { if (offset == bufsize) {
bufsize *= 2; bufsize *= 2;
buf = xrealloc(buf, bufsize); buf = xrealloc(buf, bufsize);
if (!buf) {
ret = ENOMEM;
break;
}
} }
ret = read(fd, &buf[offset], bufsize - offset); ret = read(fd, &buf[offset], bufsize - offset);
...@@ -375,9 +371,9 @@ void utilfdt_print_data(const char *data, int len) ...@@ -375,9 +371,9 @@ void utilfdt_print_data(const char *data, int len)
const uint32_t *cell = (const uint32_t *)data; const uint32_t *cell = (const uint32_t *)data;
printf(" = <"); printf(" = <");
for (i = 0; i < len; i += 4) for (i = 0, len /= 4; i < len; i++)
printf("0x%08x%s", fdt32_to_cpu(cell[i]), printf("0x%08x%s", fdt32_to_cpu(cell[i]),
i < (len - 4) ? " " : ""); i < (len - 1) ? " " : "");
printf(">"); printf(">");
} else { } else {
printf(" = ["); printf(" = [");
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define _UTIL_H #define _UTIL_H
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h>
#include <getopt.h> #include <getopt.h>
/* /*
...@@ -33,6 +34,7 @@ static inline void __attribute__((noreturn)) die(const char *str, ...) ...@@ -33,6 +34,7 @@ static inline void __attribute__((noreturn)) die(const char *str, ...)
va_start(ap, str); va_start(ap, str);
fprintf(stderr, "FATAL ERROR: "); fprintf(stderr, "FATAL ERROR: ");
vfprintf(stderr, str, ap); vfprintf(stderr, str, ap);
va_end(ap);
exit(1); exit(1);
} }
...@@ -68,7 +70,7 @@ extern char *join_path(const char *path, const char *name); ...@@ -68,7 +70,7 @@ extern char *join_path(const char *path, const char *name);
* @param len The string length including terminator * @param len The string length including terminator
* @return 1 if a valid printable string, 0 if not * @return 1 if a valid printable string, 0 if not
*/ */
int util_is_printable_string(const void *data, int len); bool util_is_printable_string(const void *data, int len);
/* /*
* Parse an escaped character starting at index i in string s. The resulting * Parse an escaped character starting at index i in string s. The resulting
......
#define DTC_VERSION "DTC 1.4.0-dirty" #define DTC_VERSION "DTC 1.4.1-g9d3649bd"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment