diff options
45 files changed, 1555 insertions, 728 deletions
diff --git a/Documentation/ABI/testing/sysfs-firmware-ofw b/Documentation/ABI/testing/sysfs-firmware-ofw new file mode 100644 index 000000000000..f562b188e71d --- /dev/null +++ b/Documentation/ABI/testing/sysfs-firmware-ofw | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | What: /sys/firmware/devicetree/* | ||
| 2 | Date: November 2013 | ||
| 3 | Contact: Grant Likely <grant.likely@linaro.org> | ||
| 4 | Description: | ||
| 5 | When using OpenFirmware or a Flattened Device Tree to enumerate | ||
| 6 | hardware, the device tree structure will be exposed in this | ||
| 7 | directory. | ||
| 8 | |||
| 9 | It is possible for multiple device-tree directories to exist. | ||
| 10 | Some device drivers use a separate detached device tree which | ||
| 11 | have no attachment to the system tree and will appear in a | ||
| 12 | different subdirectory under /sys/firmware/devicetree. | ||
| 13 | |||
| 14 | Userspace must not use the /sys/firmware/devicetree/base | ||
| 15 | path directly, but instead should follow /proc/device-tree | ||
| 16 | symlink. It is possible that the absolute path will change | ||
| 17 | in the future, but the symlink is the stable ABI. | ||
| 18 | |||
| 19 | The /proc/device-tree symlink replaces the devicetree /proc | ||
| 20 | filesystem support, and has largely the same semantics and | ||
| 21 | should be compatible with existing userspace. | ||
| 22 | |||
| 23 | The contents of /sys/firmware/devicetree/ is a | ||
| 24 | hierarchy of directories, one per device tree node. The | ||
| 25 | directory name is the resolved path component name (node | ||
| 26 | name plus address). Properties are represented as files | ||
| 27 | in the directory. The contents of each file is the exact | ||
| 28 | binary data from the device tree. | ||
diff --git a/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt b/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt new file mode 100644 index 000000000000..3da0ebdba8d9 --- /dev/null +++ b/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt | |||
| @@ -0,0 +1,133 @@ | |||
| 1 | *** Reserved memory regions *** | ||
| 2 | |||
| 3 | Reserved memory is specified as a node under the /reserved-memory node. | ||
| 4 | The operating system shall exclude reserved memory from normal usage | ||
| 5 | one can create child nodes describing particular reserved (excluded from | ||
| 6 | normal use) memory regions. Such memory regions are usually designed for | ||
| 7 | the special usage by various device drivers. | ||
| 8 | |||
| 9 | Parameters for each memory region can be encoded into the device tree | ||
| 10 | with the following nodes: | ||
| 11 | |||
| 12 | /reserved-memory node | ||
| 13 | --------------------- | ||
| 14 | #address-cells, #size-cells (required) - standard definition | ||
| 15 | - Should use the same values as the root node | ||
| 16 | ranges (required) - standard definition | ||
| 17 | - Should be empty | ||
| 18 | |||
| 19 | /reserved-memory/ child nodes | ||
| 20 | ----------------------------- | ||
| 21 | Each child of the reserved-memory node specifies one or more regions of | ||
| 22 | reserved memory. Each child node may either use a 'reg' property to | ||
| 23 | specify a specific range of reserved memory, or a 'size' property with | ||
| 24 | optional constraints to request a dynamically allocated block of memory. | ||
| 25 | |||
| 26 | Following the generic-names recommended practice, node names should | ||
| 27 | reflect the purpose of the node (ie. "framebuffer" or "dma-pool"). Unit | ||
| 28 | address (@<address>) should be appended to the name if the node is a | ||
| 29 | static allocation. | ||
| 30 | |||
| 31 | Properties: | ||
| 32 | Requires either a) or b) below. | ||
| 33 | a) static allocation | ||
| 34 | reg (required) - standard definition | ||
| 35 | b) dynamic allocation | ||
| 36 | size (required) - length based on parent's #size-cells | ||
| 37 | - Size in bytes of memory to reserve. | ||
| 38 | alignment (optional) - length based on parent's #size-cells | ||
| 39 | - Address boundary for alignment of allocation. | ||
| 40 | alloc-ranges (optional) - prop-encoded-array (address, length pairs). | ||
| 41 | - Specifies regions of memory that are | ||
| 42 | acceptable to allocate from. | ||
| 43 | |||
| 44 | If both reg and size are present, then the reg property takes precedence | ||
| 45 | and size is ignored. | ||
| 46 | |||
| 47 | Additional properties: | ||
| 48 | compatible (optional) - standard definition | ||
| 49 | - may contain the following strings: | ||
| 50 | - shared-dma-pool: This indicates a region of memory meant to be | ||
| 51 | used as a shared pool of DMA buffers for a set of devices. It can | ||
| 52 | be used by an operating system to instanciate the necessary pool | ||
| 53 | management subsystem if necessary. | ||
| 54 | - vendor specific string in the form <vendor>,[<device>-]<usage> | ||
| 55 | no-map (optional) - empty property | ||
| 56 | - Indicates the operating system must not create a virtual mapping | ||
| 57 | of the region as part of its standard mapping of system memory, | ||
| 58 | nor permit speculative access to it under any circumstances other | ||
| 59 | than under the control of the device driver using the region. | ||
| 60 | reusable (optional) - empty property | ||
| 61 | - The operating system can use the memory in this region with the | ||
| 62 | limitation that the device driver(s) owning the region need to be | ||
| 63 | able to reclaim it back. Typically that means that the operating | ||
| 64 | system can use that region to store volatile or cached data that | ||
| 65 | can be otherwise regenerated or migrated elsewhere. | ||
| 66 | |||
| 67 | Linux implementation note: | ||
| 68 | - If a "linux,cma-default" property is present, then Linux will use the | ||
| 69 | region for the default pool of the contiguous memory allocator. | ||
| 70 | |||
| 71 | Device node references to reserved memory | ||
| 72 | ----------------------------------------- | ||
| 73 | Regions in the /reserved-memory node may be referenced by other device | ||
| 74 | nodes by adding a memory-region property to the device node. | ||
| 75 | |||
| 76 | memory-region (optional) - phandle, specifier pairs to children of /reserved-memory | ||
| 77 | |||
| 78 | Example | ||
| 79 | ------- | ||
| 80 | This example defines 3 contiguous regions are defined for Linux kernel: | ||
| 81 | one default of all device drivers (named linux,cma@72000000 and 64MiB in size), | ||
| 82 | one dedicated to the framebuffer device (named framebuffer@78000000, 8MiB), and | ||
| 83 | one for multimedia processing (named multimedia-memory@77000000, 64MiB). | ||
| 84 | |||
| 85 | / { | ||
| 86 | #address-cells = <1>; | ||
| 87 | #size-cells = <1>; | ||
| 88 | |||
| 89 | memory { | ||
| 90 | reg = <0x40000000 0x40000000>; | ||
| 91 | }; | ||
| 92 | |||
| 93 | reserved-memory { | ||
| 94 | #address-cells = <1>; | ||
| 95 | #size-cells = <1>; | ||
| 96 | ranges; | ||
| 97 | |||
| 98 | /* global autoconfigured region for contiguous allocations */ | ||
| 99 | linux,cma { | ||
| 100 | compatible = "shared-dma-pool"; | ||
| 101 | reusable; | ||
| 102 | size = <0x4000000>; | ||
| 103 | alignment = <0x2000>; | ||
| 104 | linux,cma-default; | ||
| 105 | }; | ||
| 106 | |||
| 107 | display_reserved: framebuffer@78000000 { | ||
| 108 | reg = <0x78000000 0x800000>; | ||
| 109 | }; | ||
| 110 | |||
| 111 | multimedia_reserved: multimedia@77000000 { | ||
| 112 | compatible = "acme,multimedia-memory"; | ||
| 113 | reg = <0x77000000 0x4000000>; | ||
| 114 | }; | ||
| 115 | }; | ||
| 116 | |||
| 117 | /* ... */ | ||
| 118 | |||
| 119 | fb0: video@12300000 { | ||
| 120 | memory-region = <&display_reserved>; | ||
| 121 | /* ... */ | ||
| 122 | }; | ||
| 123 | |||
| 124 | scaler: scaler@12500000 { | ||
| 125 | memory-region = <&multimedia_reserved>; | ||
| 126 | /* ... */ | ||
| 127 | }; | ||
| 128 | |||
| 129 | codec: codec@12600000 { | ||
| 130 | memory-region = <&multimedia_reserved>; | ||
| 131 | /* ... */ | ||
| 132 | }; | ||
| 133 | }; | ||
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 40ce2df0e0e9..95465d57eb31 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt | |||
| @@ -3,6 +3,7 @@ Device tree binding vendor prefix registry. Keep list in alphabetical order. | |||
| 3 | This isn't an exhaustive list, but you should add new prefixes to it before | 3 | This isn't an exhaustive list, but you should add new prefixes to it before |
| 4 | using them to avoid name-space collisions. | 4 | using them to avoid name-space collisions. |
| 5 | 5 | ||
| 6 | abilis Abilis Systems | ||
| 6 | active-semi Active-Semi International Inc | 7 | active-semi Active-Semi International Inc |
| 7 | ad Avionic Design GmbH | 8 | ad Avionic Design GmbH |
| 8 | adi Analog Devices, Inc. | 9 | adi Analog Devices, Inc. |
| @@ -11,14 +12,17 @@ ak Asahi Kasei Corp. | |||
| 11 | allwinner Allwinner Technology Co., Ltd. | 12 | allwinner Allwinner Technology Co., Ltd. |
| 12 | altr Altera Corp. | 13 | altr Altera Corp. |
| 13 | amcc Applied Micro Circuits Corporation (APM, formally AMCC) | 14 | amcc Applied Micro Circuits Corporation (APM, formally AMCC) |
| 15 | amd Advanced Micro Devices (AMD), Inc. | ||
| 14 | amstaos AMS-Taos Inc. | 16 | amstaos AMS-Taos Inc. |
| 15 | apm Applied Micro Circuits Corporation (APM) | 17 | apm Applied Micro Circuits Corporation (APM) |
| 16 | arm ARM Ltd. | 18 | arm ARM Ltd. |
| 19 | armadeus ARMadeus Systems SARL | ||
| 17 | atmel Atmel Corporation | 20 | atmel Atmel Corporation |
| 18 | auo AU Optronics Corporation | 21 | auo AU Optronics Corporation |
| 19 | avago Avago Technologies | 22 | avago Avago Technologies |
| 20 | bosch Bosch Sensortec GmbH | 23 | bosch Bosch Sensortec GmbH |
| 21 | brcm Broadcom Corporation | 24 | brcm Broadcom Corporation |
| 25 | calxeda Calxeda | ||
| 22 | capella Capella Microsystems, Inc | 26 | capella Capella Microsystems, Inc |
| 23 | cavium Cavium, Inc. | 27 | cavium Cavium, Inc. |
| 24 | cdns Cadence Design Systems Inc. | 28 | cdns Cadence Design Systems Inc. |
| @@ -26,8 +30,10 @@ chrp Common Hardware Reference Platform | |||
| 26 | chunghwa Chunghwa Picture Tubes Ltd. | 30 | chunghwa Chunghwa Picture Tubes Ltd. |
| 27 | cirrus Cirrus Logic, Inc. | 31 | cirrus Cirrus Logic, Inc. |
| 28 | cortina Cortina Systems, Inc. | 32 | cortina Cortina Systems, Inc. |
| 33 | crystalfontz Crystalfontz America, Inc. | ||
| 29 | dallas Maxim Integrated Products (formerly Dallas Semiconductor) | 34 | dallas Maxim Integrated Products (formerly Dallas Semiconductor) |
| 30 | davicom DAVICOM Semiconductor, Inc. | 35 | davicom DAVICOM Semiconductor, Inc. |
| 36 | dlink D-Link Systems, Inc. | ||
| 31 | denx Denx Software Engineering | 37 | denx Denx Software Engineering |
| 32 | edt Emerging Display Technologies | 38 | edt Emerging Display Technologies |
| 33 | emmicro EM Microelectronic | 39 | emmicro EM Microelectronic |
| @@ -37,7 +43,9 @@ est ESTeem Wireless Modems | |||
| 37 | fsl Freescale Semiconductor | 43 | fsl Freescale Semiconductor |
| 38 | GEFanuc GE Fanuc Intelligent Platforms Embedded Systems, Inc. | 44 | GEFanuc GE Fanuc Intelligent Platforms Embedded Systems, Inc. |
| 39 | gef GE Fanuc Intelligent Platforms Embedded Systems, Inc. | 45 | gef GE Fanuc Intelligent Platforms Embedded Systems, Inc. |
| 46 | globalscale Globalscale Technologies, Inc. | ||
| 40 | gmt Global Mixed-mode Technology, Inc. | 47 | gmt Global Mixed-mode Technology, Inc. |
| 48 | google Google, Inc. | ||
| 41 | gumstix Gumstix, Inc. | 49 | gumstix Gumstix, Inc. |
| 42 | haoyu Haoyu Microelectronic Co. Ltd. | 50 | haoyu Haoyu Microelectronic Co. Ltd. |
| 43 | hisilicon Hisilicon Limited. | 51 | hisilicon Hisilicon Limited. |
| @@ -46,9 +54,12 @@ hp Hewlett Packard | |||
| 46 | ibm International Business Machines (IBM) | 54 | ibm International Business Machines (IBM) |
| 47 | idt Integrated Device Technologies, Inc. | 55 | idt Integrated Device Technologies, Inc. |
| 48 | img Imagination Technologies Ltd. | 56 | img Imagination Technologies Ltd. |
| 57 | intel Intel Corporation | ||
| 49 | intercontrol Inter Control Group | 58 | intercontrol Inter Control Group |
| 50 | isl Intersil | 59 | isl Intersil |
| 51 | karo Ka-Ro electronics GmbH | 60 | karo Ka-Ro electronics GmbH |
| 61 | lacie LaCie | ||
| 62 | lantiq Lantiq Semiconductor | ||
| 52 | lg LG Corporation | 63 | lg LG Corporation |
| 53 | linux Linux-specific binding | 64 | linux Linux-specific binding |
| 54 | lsi LSI Corp. (LSI Logic) | 65 | lsi LSI Corp. (LSI Logic) |
| @@ -56,12 +67,16 @@ marvell Marvell Technology Group Ltd. | |||
| 56 | maxim Maxim Integrated Products | 67 | maxim Maxim Integrated Products |
| 57 | microchip Microchip Technology Inc. | 68 | microchip Microchip Technology Inc. |
| 58 | mosaixtech Mosaix Technologies, Inc. | 69 | mosaixtech Mosaix Technologies, Inc. |
| 70 | moxa Moxa | ||
| 59 | national National Semiconductor | 71 | national National Semiconductor |
| 60 | neonode Neonode Inc. | 72 | neonode Neonode Inc. |
| 73 | netgear NETGEAR | ||
| 61 | nintendo Nintendo | 74 | nintendo Nintendo |
| 75 | nokia Nokia | ||
| 62 | nvidia NVIDIA | 76 | nvidia NVIDIA |
| 63 | nxp NXP Semiconductors | 77 | nxp NXP Semiconductors |
| 64 | onnn ON Semiconductor Corp. | 78 | onnn ON Semiconductor Corp. |
| 79 | opencores OpenCores.org | ||
| 65 | panasonic Panasonic Corporation | 80 | panasonic Panasonic Corporation |
| 66 | phytec PHYTEC Messtechnik GmbH | 81 | phytec PHYTEC Messtechnik GmbH |
| 67 | picochip Picochip Ltd | 82 | picochip Picochip Ltd |
| @@ -80,6 +95,7 @@ sil Silicon Image | |||
| 80 | silabs Silicon Laboratories | 95 | silabs Silicon Laboratories |
| 81 | simtek | 96 | simtek |
| 82 | sirf SiRF Technology, Inc. | 97 | sirf SiRF Technology, Inc. |
| 98 | smsc Standard Microsystems Corporation | ||
| 83 | snps Synopsys, Inc. | 99 | snps Synopsys, Inc. |
| 84 | spansion Spansion Inc. | 100 | spansion Spansion Inc. |
| 85 | st STMicroelectronics | 101 | st STMicroelectronics |
| @@ -94,4 +110,5 @@ via VIA Technologies, Inc. | |||
| 94 | winbond Winbond Electronics corp. | 110 | winbond Winbond Electronics corp. |
| 95 | wlf Wolfson Microelectronics | 111 | wlf Wolfson Microelectronics |
| 96 | wm Wondermedia Technologies, Inc. | 112 | wm Wondermedia Technologies, Inc. |
| 113 | xes Extreme Engineering Solutions (X-ES) | ||
| 97 | xlnx Xilinx | 114 | xlnx Xilinx |
| @@ -729,6 +729,13 @@ export KBUILD_IMAGE ?= vmlinux | |||
| 729 | export INSTALL_PATH ?= /boot | 729 | export INSTALL_PATH ?= /boot |
| 730 | 730 | ||
| 731 | # | 731 | # |
| 732 | # INSTALL_DTBS_PATH specifies a prefix for relocations required by build roots. | ||
| 733 | # Like INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed as | ||
| 734 | # an argument if needed. Otherwise it defaults to the kernel install path | ||
| 735 | # | ||
| 736 | export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE) | ||
| 737 | |||
| 738 | # | ||
| 732 | # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory | 739 | # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory |
| 733 | # relocations required by build roots. This is not defined in the | 740 | # relocations required by build roots. This is not defined in the |
| 734 | # makefile but the argument can be passed to make if needed. | 741 | # makefile but the argument can be passed to make if needed. |
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index b76ae4185a3b..503da0a2a8ea 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
| @@ -1918,6 +1918,7 @@ config USE_OF | |||
| 1918 | select IRQ_DOMAIN | 1918 | select IRQ_DOMAIN |
| 1919 | select OF | 1919 | select OF |
| 1920 | select OF_EARLY_FLATTREE | 1920 | select OF_EARLY_FLATTREE |
| 1921 | select OF_RESERVED_MEM | ||
| 1921 | help | 1922 | help |
| 1922 | Include support for flattened device tree machine descriptions. | 1923 | Include support for flattened device tree machine descriptions. |
| 1923 | 1924 | ||
diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 08a9ef58d9c3..fddf4beaee45 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile | |||
| @@ -310,9 +310,9 @@ $(INSTALL_TARGETS): | |||
| 310 | %.dtb: | scripts | 310 | %.dtb: | scripts |
| 311 | $(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) $(boot)/dts/$@ | 311 | $(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) $(boot)/dts/$@ |
| 312 | 312 | ||
| 313 | PHONY += dtbs | 313 | PHONY += dtbs dtbs_install |
| 314 | dtbs: scripts | 314 | dtbs dtbs_install: prepare scripts |
| 315 | $(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) dtbs | 315 | $(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) $@ |
| 316 | 316 | ||
| 317 | # We use MRPROPER_FILES and CLEAN_FILES now | 317 | # We use MRPROPER_FILES and CLEAN_FILES now |
| 318 | archclean: | 318 | archclean: |
| @@ -331,6 +331,7 @@ define archhelp | |||
| 331 | echo ' bootpImage - Combined zImage and initial RAM disk' | 331 | echo ' bootpImage - Combined zImage and initial RAM disk' |
| 332 | echo ' (supply initrd image via make variable INITRD=<path>)' | 332 | echo ' (supply initrd image via make variable INITRD=<path>)' |
| 333 | echo '* dtbs - Build device tree blobs for enabled boards' | 333 | echo '* dtbs - Build device tree blobs for enabled boards' |
| 334 | echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)' | ||
| 334 | echo ' install - Install uncompressed kernel' | 335 | echo ' install - Install uncompressed kernel' |
| 335 | echo ' zinstall - Install compressed kernel' | 336 | echo ' zinstall - Install compressed kernel' |
| 336 | echo ' uinstall - Install U-Boot wrapped compressed kernel' | 337 | echo ' uinstall - Install U-Boot wrapped compressed kernel' |
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index 032030361bef..d3cb0126a102 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile | |||
| @@ -323,7 +323,7 @@ dtb-$(CONFIG_ARCH_ZYNQ) += zynq-zc702.dtb \ | |||
| 323 | zynq-zc706.dtb \ | 323 | zynq-zc706.dtb \ |
| 324 | zynq-zed.dtb | 324 | zynq-zed.dtb |
| 325 | 325 | ||
| 326 | targets += dtbs | 326 | targets += dtbs dtbs_install |
| 327 | targets += $(dtb-y) | 327 | targets += $(dtb-y) |
| 328 | endif | 328 | endif |
| 329 | 329 | ||
| @@ -333,3 +333,5 @@ dtbs: $(addprefix $(obj)/, $(dtb-y)) | |||
| 333 | $(Q)rm -f $(obj)/../*.dtb | 333 | $(Q)rm -f $(obj)/../*.dtb |
| 334 | 334 | ||
| 335 | clean-files := *.dtb | 335 | clean-files := *.dtb |
| 336 | |||
| 337 | dtbs_install: $(addsuffix _dtbinst_, $(dtb-y)) | ||
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index 5e269d7263ce..df9e7d270810 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig | |||
| @@ -16,6 +16,7 @@ config ARCH_MVEBU | |||
| 16 | select ARCH_REQUIRE_GPIOLIB | 16 | select ARCH_REQUIRE_GPIOLIB |
| 17 | select MIGHT_HAVE_PCI | 17 | select MIGHT_HAVE_PCI |
| 18 | select PCI_QUIRKS if PCI | 18 | select PCI_QUIRKS if PCI |
| 19 | select OF_ADDRESS_PCI | ||
| 19 | 20 | ||
| 20 | if ARCH_MVEBU | 21 | if ARCH_MVEBU |
| 21 | 22 | ||
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig index 6fb91fb604a0..ac4882511749 100644 --- a/arch/arm/mach-omap2/Kconfig +++ b/arch/arm/mach-omap2/Kconfig | |||
| @@ -102,7 +102,6 @@ config ARCH_OMAP2PLUS | |||
| 102 | select MACH_OMAP_GENERIC | 102 | select MACH_OMAP_GENERIC |
| 103 | select OMAP_DM_TIMER | 103 | select OMAP_DM_TIMER |
| 104 | select PINCTRL | 104 | select PINCTRL |
| 105 | select PROC_DEVICETREE if PROC_FS | ||
| 106 | select SOC_BUS | 105 | select SOC_BUS |
| 107 | select SPARSE_IRQ | 106 | select SPARSE_IRQ |
| 108 | select TI_PRIV_EDMA | 107 | select TI_PRIV_EDMA |
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 804d61566a53..2a77ba8796ae 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
| @@ -323,6 +323,8 @@ void __init arm_memblock_init(struct meminfo *mi, | |||
| 323 | if (mdesc->reserve) | 323 | if (mdesc->reserve) |
| 324 | mdesc->reserve(); | 324 | mdesc->reserve(); |
| 325 | 325 | ||
| 326 | early_init_fdt_scan_reserved_mem(); | ||
| 327 | |||
| 326 | /* | 328 | /* |
| 327 | * reserve memory for DMA contigouos allocations, | 329 | * reserve memory for DMA contigouos allocations, |
| 328 | * must come from DMA area inside low memory | 330 | * must come from DMA area inside low memory |
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 8033b9b8a2df..9711a5fd948d 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig | |||
| @@ -47,6 +47,7 @@ config ARM64 | |||
| 47 | select NO_BOOTMEM | 47 | select NO_BOOTMEM |
| 48 | select OF | 48 | select OF |
| 49 | select OF_EARLY_FLATTREE | 49 | select OF_EARLY_FLATTREE |
| 50 | select OF_RESERVED_MEM | ||
| 50 | select PERF_USE_VMALLOC | 51 | select PERF_USE_VMALLOC |
| 51 | select POWER_RESET | 52 | select POWER_RESET |
| 52 | select POWER_SUPPLY | 53 | select POWER_SUPPLY |
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 88627c450a6c..51d5352e6ad5 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c | |||
| @@ -161,6 +161,7 @@ void __init arm64_memblock_init(void) | |||
| 161 | memblock_reserve(base, size); | 161 | memblock_reserve(base, size); |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | early_init_fdt_scan_reserved_mem(); | ||
| 164 | dma_contiguous_reserve(0); | 165 | dma_contiguous_reserve(0); |
| 165 | 166 | ||
| 166 | memblock_allow_resize(); | 167 | memblock_allow_resize(); |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index f3d7846bc9b2..6c03a94991ad 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
| @@ -90,6 +90,7 @@ config PPC | |||
| 90 | select BINFMT_ELF | 90 | select BINFMT_ELF |
| 91 | select OF | 91 | select OF |
| 92 | select OF_EARLY_FLATTREE | 92 | select OF_EARLY_FLATTREE |
| 93 | select OF_RESERVED_MEM | ||
| 93 | select HAVE_FTRACE_MCOUNT_RECORD | 94 | select HAVE_FTRACE_MCOUNT_RECORD |
| 94 | select HAVE_DYNAMIC_FTRACE | 95 | select HAVE_DYNAMIC_FTRACE |
| 95 | select HAVE_FUNCTION_TRACER | 96 | select HAVE_FUNCTION_TRACER |
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index d711b7eb05aa..dd72bebd708a 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | #include <linux/irq.h> | 33 | #include <linux/irq.h> |
| 34 | #include <linux/memblock.h> | 34 | #include <linux/memblock.h> |
| 35 | #include <linux/of.h> | 35 | #include <linux/of.h> |
| 36 | #include <linux/of_fdt.h> | ||
| 36 | 37 | ||
| 37 | #include <asm/prom.h> | 38 | #include <asm/prom.h> |
| 38 | #include <asm/rtas.h> | 39 | #include <asm/rtas.h> |
| @@ -588,6 +589,8 @@ static void __init early_reserve_mem_dt(void) | |||
| 588 | memblock_reserve(base, size); | 589 | memblock_reserve(base, size); |
| 589 | } | 590 | } |
| 590 | } | 591 | } |
| 592 | |||
| 593 | early_init_fdt_scan_reserved_mem(); | ||
| 591 | } | 594 | } |
| 592 | 595 | ||
| 593 | static void __init early_reserve_mem(void) | 596 | static void __init early_reserve_mem(void) |
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index a8fe5aa3d34f..022b38e6a80b 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
| 14 | #include <linux/kref.h> | ||
| 15 | #include <linux/notifier.h> | 14 | #include <linux/notifier.h> |
| 16 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
| 17 | #include <linux/cpu.h> | 16 | #include <linux/cpu.h> |
| @@ -87,7 +86,6 @@ static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa, | |||
| 87 | } | 86 | } |
| 88 | 87 | ||
| 89 | of_node_set_flag(dn, OF_DYNAMIC); | 88 | of_node_set_flag(dn, OF_DYNAMIC); |
| 90 | kref_init(&dn->kref); | ||
| 91 | 89 | ||
| 92 | return dn; | 90 | return dn; |
| 93 | } | 91 | } |
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c index f93cdf55628c..0435bb65d0aa 100644 --- a/arch/powerpc/platforms/pseries/reconfig.c +++ b/arch/powerpc/platforms/pseries/reconfig.c | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | */ | 12 | */ |
| 13 | 13 | ||
| 14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
| 15 | #include <linux/kref.h> | ||
| 16 | #include <linux/notifier.h> | 15 | #include <linux/notifier.h> |
| 17 | #include <linux/proc_fs.h> | 16 | #include <linux/proc_fs.h> |
| 18 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
| @@ -70,7 +69,6 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist | |||
| 70 | 69 | ||
| 71 | np->properties = proplist; | 70 | np->properties = proplist; |
| 72 | of_node_set_flag(np, OF_DYNAMIC); | 71 | of_node_set_flag(np, OF_DYNAMIC); |
| 73 | kref_init(&np->kref); | ||
| 74 | 72 | ||
| 75 | np->parent = derive_parent(path); | 73 | np->parent = derive_parent(path); |
| 76 | if (IS_ERR(np->parent)) { | 74 | if (IS_ERR(np->parent)) { |
diff --git a/arch/powerpc/sysdev/msi_bitmap.c b/arch/powerpc/sysdev/msi_bitmap.c index 0968b66b4cf9..8ba60424be95 100644 --- a/arch/powerpc/sysdev/msi_bitmap.c +++ b/arch/powerpc/sysdev/msi_bitmap.c | |||
| @@ -202,7 +202,7 @@ void __init test_of_node(void) | |||
| 202 | 202 | ||
| 203 | /* There should really be a struct device_node allocator */ | 203 | /* There should really be a struct device_node allocator */ |
| 204 | memset(&of_node, 0, sizeof(of_node)); | 204 | memset(&of_node, 0, sizeof(of_node)); |
| 205 | kref_init(&of_node.kref); | 205 | kref_init(&of_node.kobj.kref); |
| 206 | of_node.full_name = node_name; | 206 | of_node.full_name = node_name; |
| 207 | 207 | ||
| 208 | check(0 == msi_bitmap_alloc(&bmp, size, &of_node)); | 208 | check(0 == msi_bitmap_alloc(&bmp, size, &of_node)); |
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index c6973f101a3e..889005fa4d04 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig | |||
| @@ -7,14 +7,6 @@ config OF | |||
| 7 | menu "Device Tree and Open Firmware support" | 7 | menu "Device Tree and Open Firmware support" |
| 8 | depends on OF | 8 | depends on OF |
| 9 | 9 | ||
| 10 | config PROC_DEVICETREE | ||
| 11 | bool "Support for device tree in /proc" | ||
| 12 | depends on PROC_FS && !SPARC | ||
| 13 | help | ||
| 14 | This option adds a device-tree directory under /proc which contains | ||
| 15 | an image of the device tree that the kernel copies from Open | ||
| 16 | Firmware or other boot firmware. If unsure, say Y here. | ||
| 17 | |||
| 18 | config OF_SELFTEST | 10 | config OF_SELFTEST |
| 19 | bool "Device Tree Runtime self tests" | 11 | bool "Device Tree Runtime self tests" |
| 20 | depends on OF_IRQ | 12 | depends on OF_IRQ |
| @@ -44,6 +36,10 @@ config OF_DYNAMIC | |||
| 44 | config OF_ADDRESS | 36 | config OF_ADDRESS |
| 45 | def_bool y | 37 | def_bool y |
| 46 | depends on !SPARC | 38 | depends on !SPARC |
| 39 | select OF_ADDRESS_PCI if PCI | ||
| 40 | |||
| 41 | config OF_ADDRESS_PCI | ||
| 42 | bool | ||
| 47 | 43 | ||
| 48 | config OF_IRQ | 44 | config OF_IRQ |
| 49 | def_bool y | 45 | def_bool y |
| @@ -75,4 +71,10 @@ config OF_MTD | |||
| 75 | depends on MTD | 71 | depends on MTD |
| 76 | def_bool y | 72 | def_bool y |
| 77 | 73 | ||
| 74 | config OF_RESERVED_MEM | ||
| 75 | depends on OF_EARLY_FLATTREE | ||
| 76 | bool | ||
| 77 | help | ||
| 78 | Helpers to allow for reservation of memory regions | ||
| 79 | |||
| 78 | endmenu # OF | 80 | endmenu # OF |
diff --git a/drivers/of/Makefile b/drivers/of/Makefile index efd05102c405..ed9660adad77 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile | |||
| @@ -9,3 +9,4 @@ obj-$(CONFIG_OF_MDIO) += of_mdio.o | |||
| 9 | obj-$(CONFIG_OF_PCI) += of_pci.o | 9 | obj-$(CONFIG_OF_PCI) += of_pci.o |
| 10 | obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o | 10 | obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o |
| 11 | obj-$(CONFIG_OF_MTD) += of_mtd.o | 11 | obj-$(CONFIG_OF_MTD) += of_mtd.o |
| 12 | obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o | ||
diff --git a/drivers/of/address.c b/drivers/of/address.c index 1a54f1ffaadb..cb4242a69cd5 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c | |||
| @@ -91,7 +91,7 @@ static unsigned int of_bus_default_get_flags(const __be32 *addr) | |||
| 91 | return IORESOURCE_MEM; | 91 | return IORESOURCE_MEM; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | #ifdef CONFIG_PCI | 94 | #ifdef CONFIG_OF_ADDRESS_PCI |
| 95 | /* | 95 | /* |
| 96 | * PCI bus specific translator | 96 | * PCI bus specific translator |
| 97 | */ | 97 | */ |
| @@ -166,7 +166,9 @@ static int of_bus_pci_translate(__be32 *addr, u64 offset, int na) | |||
| 166 | { | 166 | { |
| 167 | return of_bus_default_translate(addr + 1, offset, na - 1); | 167 | return of_bus_default_translate(addr + 1, offset, na - 1); |
| 168 | } | 168 | } |
| 169 | #endif /* CONFIG_OF_ADDRESS_PCI */ | ||
| 169 | 170 | ||
| 171 | #ifdef CONFIG_PCI | ||
| 170 | const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, | 172 | const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, |
| 171 | unsigned int *flags) | 173 | unsigned int *flags) |
| 172 | { | 174 | { |
| @@ -356,7 +358,7 @@ static unsigned int of_bus_isa_get_flags(const __be32 *addr) | |||
| 356 | */ | 358 | */ |
| 357 | 359 | ||
| 358 | static struct of_bus of_busses[] = { | 360 | static struct of_bus of_busses[] = { |
| 359 | #ifdef CONFIG_PCI | 361 | #ifdef CONFIG_OF_ADDRESS_PCI |
| 360 | /* PCI */ | 362 | /* PCI */ |
| 361 | { | 363 | { |
| 362 | .name = "pci", | 364 | .name = "pci", |
| @@ -367,7 +369,7 @@ static struct of_bus of_busses[] = { | |||
| 367 | .translate = of_bus_pci_translate, | 369 | .translate = of_bus_pci_translate, |
| 368 | .get_flags = of_bus_pci_get_flags, | 370 | .get_flags = of_bus_pci_get_flags, |
| 369 | }, | 371 | }, |
| 370 | #endif /* CONFIG_PCI */ | 372 | #endif /* CONFIG_OF_ADDRESS_PCI */ |
| 371 | /* ISA */ | 373 | /* ISA */ |
| 372 | { | 374 | { |
| 373 | .name = "isa", | 375 | .name = "isa", |
diff --git a/drivers/of/base.c b/drivers/of/base.c index 5f81bfea5246..4557a142c752 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/of_graph.h> | 24 | #include <linux/of_graph.h> |
| 25 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
| 26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
| 27 | #include <linux/string.h> | ||
| 27 | #include <linux/proc_fs.h> | 28 | #include <linux/proc_fs.h> |
| 28 | 29 | ||
| 29 | #include "of_private.h" | 30 | #include "of_private.h" |
| @@ -36,6 +37,12 @@ struct device_node *of_chosen; | |||
| 36 | struct device_node *of_aliases; | 37 | struct device_node *of_aliases; |
| 37 | static struct device_node *of_stdout; | 38 | static struct device_node *of_stdout; |
| 38 | 39 | ||
| 40 | static struct kset *of_kset; | ||
| 41 | |||
| 42 | /* | ||
| 43 | * Used to protect the of_aliases; but also overloaded to hold off addition of | ||
| 44 | * nodes to sysfs | ||
| 45 | */ | ||
| 39 | DEFINE_MUTEX(of_aliases_mutex); | 46 | DEFINE_MUTEX(of_aliases_mutex); |
| 40 | 47 | ||
| 41 | /* use when traversing tree through the allnext, child, sibling, | 48 | /* use when traversing tree through the allnext, child, sibling, |
| @@ -93,14 +100,14 @@ int __weak of_node_to_nid(struct device_node *np) | |||
| 93 | struct device_node *of_node_get(struct device_node *node) | 100 | struct device_node *of_node_get(struct device_node *node) |
| 94 | { | 101 | { |
| 95 | if (node) | 102 | if (node) |
| 96 | kref_get(&node->kref); | 103 | kobject_get(&node->kobj); |
| 97 | return node; | 104 | return node; |
| 98 | } | 105 | } |
| 99 | EXPORT_SYMBOL(of_node_get); | 106 | EXPORT_SYMBOL(of_node_get); |
| 100 | 107 | ||
| 101 | static inline struct device_node *kref_to_device_node(struct kref *kref) | 108 | static inline struct device_node *kobj_to_device_node(struct kobject *kobj) |
| 102 | { | 109 | { |
| 103 | return container_of(kref, struct device_node, kref); | 110 | return container_of(kobj, struct device_node, kobj); |
| 104 | } | 111 | } |
| 105 | 112 | ||
| 106 | /** | 113 | /** |
| @@ -110,16 +117,15 @@ static inline struct device_node *kref_to_device_node(struct kref *kref) | |||
| 110 | * In of_node_put() this function is passed to kref_put() | 117 | * In of_node_put() this function is passed to kref_put() |
| 111 | * as the destructor. | 118 | * as the destructor. |
| 112 | */ | 119 | */ |
| 113 | static void of_node_release(struct kref *kref) | 120 | static void of_node_release(struct kobject *kobj) |
| 114 | { | 121 | { |
| 115 | struct device_node *node = kref_to_device_node(kref); | 122 | struct device_node *node = kobj_to_device_node(kobj); |
| 116 | struct property *prop = node->properties; | 123 | struct property *prop = node->properties; |
| 117 | 124 | ||
| 118 | /* We should never be releasing nodes that haven't been detached. */ | 125 | /* We should never be releasing nodes that haven't been detached. */ |
| 119 | if (!of_node_check_flag(node, OF_DETACHED)) { | 126 | if (!of_node_check_flag(node, OF_DETACHED)) { |
| 120 | pr_err("ERROR: Bad of_node_put() on %s\n", node->full_name); | 127 | pr_err("ERROR: Bad of_node_put() on %s\n", node->full_name); |
| 121 | dump_stack(); | 128 | dump_stack(); |
| 122 | kref_init(&node->kref); | ||
| 123 | return; | 129 | return; |
| 124 | } | 130 | } |
| 125 | 131 | ||
| @@ -152,11 +158,154 @@ static void of_node_release(struct kref *kref) | |||
| 152 | void of_node_put(struct device_node *node) | 158 | void of_node_put(struct device_node *node) |
| 153 | { | 159 | { |
| 154 | if (node) | 160 | if (node) |
| 155 | kref_put(&node->kref, of_node_release); | 161 | kobject_put(&node->kobj); |
| 156 | } | 162 | } |
| 157 | EXPORT_SYMBOL(of_node_put); | 163 | EXPORT_SYMBOL(of_node_put); |
| 164 | #else | ||
| 165 | static void of_node_release(struct kobject *kobj) | ||
| 166 | { | ||
| 167 | /* Without CONFIG_OF_DYNAMIC, no nodes gets freed */ | ||
| 168 | } | ||
| 158 | #endif /* CONFIG_OF_DYNAMIC */ | 169 | #endif /* CONFIG_OF_DYNAMIC */ |
| 159 | 170 | ||
| 171 | struct kobj_type of_node_ktype = { | ||
| 172 | .release = of_node_release, | ||
| 173 | }; | ||
| 174 | |||
| 175 | static ssize_t of_node_property_read(struct file *filp, struct kobject *kobj, | ||
| 176 | struct bin_attribute *bin_attr, char *buf, | ||
| 177 | loff_t offset, size_t count) | ||
| 178 | { | ||
| 179 | struct property *pp = container_of(bin_attr, struct property, attr); | ||
| 180 | return memory_read_from_buffer(buf, count, &offset, pp->value, pp->length); | ||
| 181 | } | ||
| 182 | |||
| 183 | static const char *safe_name(struct kobject *kobj, const char *orig_name) | ||
| 184 | { | ||
| 185 | const char *name = orig_name; | ||
| 186 | struct kernfs_node *kn; | ||
| 187 | int i = 0; | ||
| 188 | |||
| 189 | /* don't be a hero. After 16 tries give up */ | ||
| 190 | while (i < 16 && (kn = sysfs_get_dirent(kobj->sd, name))) { | ||
| 191 | sysfs_put(kn); | ||
| 192 | if (name != orig_name) | ||
| 193 | kfree(name); | ||
| 194 | name = kasprintf(GFP_KERNEL, "%s#%i", orig_name, ++i); | ||
| 195 | } | ||
| 196 | |||
| 197 | if (name != orig_name) | ||
| 198 | pr_warn("device-tree: Duplicate name in %s, renamed to \"%s\"\n", | ||
| 199 | kobject_name(kobj), name); | ||
| 200 | return name; | ||
| 201 | } | ||
| 202 | |||
| 203 | static int __of_add_property_sysfs(struct device_node *np, struct property *pp) | ||
| 204 | { | ||
| 205 | int rc; | ||
| 206 | |||
| 207 | /* Important: Don't leak passwords */ | ||
| 208 | bool secure = strncmp(pp->name, "security-", 9) == 0; | ||
| 209 | |||
| 210 | sysfs_bin_attr_init(&pp->attr); | ||
| 211 | pp->attr.attr.name = safe_name(&np->kobj, pp->name); | ||
| 212 | pp->attr.attr.mode = secure ? S_IRUSR : S_IRUGO; | ||
| 213 | pp->attr.size = secure ? 0 : pp->length; | ||
| 214 | pp->attr.read = of_node_property_read; | ||
| 215 | |||
| 216 | rc = sysfs_create_bin_file(&np->kobj, &pp->attr); | ||
| 217 | WARN(rc, "error adding attribute %s to node %s\n", pp->name, np->full_name); | ||
| 218 | return rc; | ||
| 219 | } | ||
| 220 | |||
| 221 | static int __of_node_add(struct device_node *np) | ||
| 222 | { | ||
| 223 | const char *name; | ||
| 224 | struct property *pp; | ||
| 225 | int rc; | ||
| 226 | |||
| 227 | np->kobj.kset = of_kset; | ||
| 228 | if (!np->parent) { | ||
| 229 | /* Nodes without parents are new top level trees */ | ||
| 230 | rc = kobject_add(&np->kobj, NULL, safe_name(&of_kset->kobj, "base")); | ||
| 231 | } else { | ||
| 232 | name = safe_name(&np->parent->kobj, kbasename(np->full_name)); | ||
| 233 | if (!name || !name[0]) | ||
| 234 | return -EINVAL; | ||
| 235 | |||
| 236 | rc = kobject_add(&np->kobj, &np->parent->kobj, "%s", name); | ||
| 237 | } | ||
| 238 | if (rc) | ||
| 239 | return rc; | ||
| 240 | |||
| 241 | for_each_property_of_node(np, pp) | ||
| 242 | __of_add_property_sysfs(np, pp); | ||
| 243 | |||
| 244 | return 0; | ||
| 245 | } | ||
| 246 | |||
| 247 | int of_node_add(struct device_node *np) | ||
| 248 | { | ||
| 249 | int rc = 0; | ||
| 250 | |||
| 251 | BUG_ON(!of_node_is_initialized(np)); | ||
| 252 | |||
| 253 | /* | ||
| 254 | * Grab the mutex here so that in a race condition between of_init() and | ||
| 255 | * of_node_add(), node addition will still be consistent. | ||
| 256 | */ | ||
| 257 | mutex_lock(&of_aliases_mutex); | ||
| 258 | if (of_kset) | ||
| 259 | rc = __of_node_add(np); | ||
| 260 | else | ||
| 261 | /* This scenario may be perfectly valid, but report it anyway */ | ||
| 262 | pr_info("of_node_add(%s) before of_init()\n", np->full_name); | ||
| 263 | mutex_unlock(&of_aliases_mutex); | ||
| 264 | return rc; | ||
| 265 | } | ||
| 266 | |||
| 267 | #if defined(CONFIG_OF_DYNAMIC) | ||
| 268 | static void of_node_remove(struct device_node *np) | ||
| 269 | { | ||
| 270 | struct property *pp; | ||
| 271 | |||
| 272 | BUG_ON(!of_node_is_initialized(np)); | ||
| 273 | |||
| 274 | /* only remove properties if on sysfs */ | ||
| 275 | if (of_node_is_attached(np)) { | ||
| 276 | for_each_property_of_node(np, pp) | ||
| 277 | sysfs_remove_bin_file(&np->kobj, &pp->attr); | ||
| 278 | kobject_del(&np->kobj); | ||
| 279 | } | ||
| 280 | |||
| 281 | /* finally remove the kobj_init ref */ | ||
| 282 | of_node_put(np); | ||
| 283 | } | ||
| 284 | #endif | ||
| 285 | |||
| 286 | static int __init of_init(void) | ||
| 287 | { | ||
| 288 | struct device_node *np; | ||
| 289 | |||
| 290 | /* Create the kset, and register existing nodes */ | ||
| 291 | mutex_lock(&of_aliases_mutex); | ||
| 292 | of_kset = kset_create_and_add("devicetree", NULL, firmware_kobj); | ||
| 293 | if (!of_kset) { | ||
| 294 | mutex_unlock(&of_aliases_mutex); | ||
| 295 | return -ENOMEM; | ||
| 296 | } | ||
| 297 | for_each_of_allnodes(np) | ||
| 298 | __of_node_add(np); | ||
| 299 | mutex_unlock(&of_aliases_mutex); | ||
| 300 | |||
| 301 | /* Symlink in /proc as required by userspace ABI */ | ||
| 302 | if (of_allnodes) | ||
| 303 | proc_symlink("device-tree", NULL, "/sys/firmware/devicetree/base"); | ||
| 304 | |||
| 305 | return 0; | ||
| 306 | } | ||
| 307 | core_initcall(of_init); | ||
| 308 | |||
| 160 | static struct property *__of_find_property(const struct device_node *np, | 309 | static struct property *__of_find_property(const struct device_node *np, |
| 161 | const char *name, int *lenp) | 310 | const char *name, int *lenp) |
| 162 | { | 311 | { |
| @@ -1531,6 +1680,10 @@ static int of_property_notify(int action, struct device_node *np, | |||
| 1531 | { | 1680 | { |
| 1532 | struct of_prop_reconfig pr; | 1681 | struct of_prop_reconfig pr; |
| 1533 | 1682 | ||
| 1683 | /* only call notifiers if the node is attached */ | ||
| 1684 | if (!of_node_is_attached(np)) | ||
| 1685 | return 0; | ||
| 1686 | |||
| 1534 | pr.dn = np; | 1687 | pr.dn = np; |
| 1535 | pr.prop = prop; | 1688 | pr.prop = prop; |
| 1536 | return of_reconfig_notify(action, &pr); | 1689 | return of_reconfig_notify(action, &pr); |
| @@ -1544,11 +1697,31 @@ static int of_property_notify(int action, struct device_node *np, | |||
| 1544 | #endif | 1697 | #endif |
| 1545 | 1698 | ||
| 1546 | /** | 1699 | /** |
| 1700 | * __of_add_property - Add a property to a node without lock operations | ||
| 1701 | */ | ||
| 1702 | static int __of_add_property(struct device_node *np, struct property *prop) | ||
| 1703 | { | ||
| 1704 | struct property **next; | ||
| 1705 | |||
| 1706 | prop->next = NULL; | ||
| 1707 | next = &np->properties; | ||
| 1708 | while (*next) { | ||
| 1709 | if (strcmp(prop->name, (*next)->name) == 0) | ||
| 1710 | /* duplicate ! don't insert it */ | ||
| 1711 | return -EEXIST; | ||
| 1712 | |||
| 1713 | next = &(*next)->next; | ||
| 1714 | } | ||
| 1715 | *next = prop; | ||
| 1716 | |||
| 1717 | return 0; | ||
| 1718 | } | ||
| 1719 | |||
| 1720 | /** | ||
| 1547 | * of_add_property - Add a property to a node | 1721 | * of_add_property - Add a property to a node |
| 1548 | */ | 1722 | */ |
| 1549 | int of_add_property(struct device_node *np, struct property *prop) | 1723 | int of_add_property(struct device_node *np, struct property *prop) |
| 1550 | { | 1724 | { |
| 1551 | struct property **next; | ||
| 1552 | unsigned long flags; | 1725 | unsigned long flags; |
| 1553 | int rc; | 1726 | int rc; |
| 1554 | 1727 | ||
| @@ -1556,27 +1729,16 @@ int of_add_property(struct device_node *np, struct property *prop) | |||
| 1556 | if (rc) | 1729 | if (rc) |
| 1557 | return rc; | 1730 | return rc; |
| 1558 | 1731 | ||
| 1559 | prop->next = NULL; | ||
| 1560 | raw_spin_lock_irqsave(&devtree_lock, flags); | 1732 | raw_spin_lock_irqsave(&devtree_lock, flags); |
| 1561 | next = &np->properties; | 1733 | rc = __of_add_property(np, prop); |
| 1562 | while (*next) { | ||
| 1563 | if (strcmp(prop->name, (*next)->name) == 0) { | ||
| 1564 | /* duplicate ! don't insert it */ | ||
| 1565 | raw_spin_unlock_irqrestore(&devtree_lock, flags); | ||
| 1566 | return -1; | ||
| 1567 | } | ||
| 1568 | next = &(*next)->next; | ||
| 1569 | } | ||
| 1570 | *next = prop; | ||
| 1571 | raw_spin_unlock_irqrestore(&devtree_lock, flags); | 1734 | raw_spin_unlock_irqrestore(&devtree_lock, flags); |
| 1735 | if (rc) | ||
| 1736 | return rc; | ||
| 1572 | 1737 | ||
| 1573 | #ifdef CONFIG_PROC_DEVICETREE | 1738 | if (of_node_is_attached(np)) |
| 1574 | /* try to add to proc as well if it was initialized */ | 1739 | __of_add_property_sysfs(np, prop); |
| 1575 | if (np->pde) | ||
| 1576 | proc_device_tree_add_prop(np->pde, prop); | ||
| 1577 | #endif /* CONFIG_PROC_DEVICETREE */ | ||
| 1578 | 1740 | ||
| 1579 | return 0; | 1741 | return rc; |
| 1580 | } | 1742 | } |
| 1581 | 1743 | ||
| 1582 | /** | 1744 | /** |
| @@ -1616,11 +1778,11 @@ int of_remove_property(struct device_node *np, struct property *prop) | |||
| 1616 | if (!found) | 1778 | if (!found) |
| 1617 | return -ENODEV; | 1779 | return -ENODEV; |
| 1618 | 1780 | ||
| 1619 | #ifdef CONFIG_PROC_DEVICETREE | 1781 | /* at early boot, bail hear and defer setup to of_init() */ |
| 1620 | /* try to remove the proc node as well */ | 1782 | if (!of_kset) |
| 1621 | if (np->pde) | 1783 | return 0; |
| 1622 | proc_device_tree_remove_prop(np->pde, prop); | 1784 | |
| 1623 | #endif /* CONFIG_PROC_DEVICETREE */ | 1785 | sysfs_remove_bin_file(&np->kobj, &prop->attr); |
| 1624 | 1786 | ||
| 1625 | return 0; | 1787 | return 0; |
| 1626 | } | 1788 | } |
| @@ -1666,16 +1828,17 @@ int of_update_property(struct device_node *np, struct property *newprop) | |||
| 1666 | next = &(*next)->next; | 1828 | next = &(*next)->next; |
| 1667 | } | 1829 | } |
| 1668 | raw_spin_unlock_irqrestore(&devtree_lock, flags); | 1830 | raw_spin_unlock_irqrestore(&devtree_lock, flags); |
| 1831 | if (rc) | ||
| 1832 | return rc; | ||
| 1833 | |||
| 1834 | /* Update the sysfs attribute */ | ||
| 1835 | if (oldprop) | ||
| 1836 | sysfs_remove_bin_file(&np->kobj, &oldprop->attr); | ||
| 1837 | __of_add_property_sysfs(np, newprop); | ||
| 1669 | 1838 | ||
| 1670 | if (!found) | 1839 | if (!found) |
| 1671 | return -ENODEV; | 1840 | return -ENODEV; |
| 1672 | 1841 | ||
| 1673 | #ifdef CONFIG_PROC_DEVICETREE | ||
| 1674 | /* try to add to proc as well if it was initialized */ | ||
| 1675 | if (np->pde) | ||
| 1676 | proc_device_tree_update_prop(np->pde, newprop, oldprop); | ||
| 1677 | #endif /* CONFIG_PROC_DEVICETREE */ | ||
| 1678 | |||
| 1679 | return 0; | 1842 | return 0; |
| 1680 | } | 1843 | } |
| 1681 | 1844 | ||
| @@ -1710,22 +1873,6 @@ int of_reconfig_notify(unsigned long action, void *p) | |||
| 1710 | return notifier_to_errno(rc); | 1873 | return notifier_to_errno(rc); |
| 1711 | } | 1874 | } |
| 1712 | 1875 | ||
| 1713 | #ifdef CONFIG_PROC_DEVICETREE | ||
| 1714 | static void of_add_proc_dt_entry(struct device_node *dn) | ||
| 1715 | { | ||
| 1716 | struct proc_dir_entry *ent; | ||
| 1717 | |||
| 1718 | ent = proc_mkdir(strrchr(dn->full_name, '/') + 1, dn->parent->pde); | ||
| 1719 | if (ent) | ||
| 1720 | proc_device_tree_add_node(dn, ent); | ||
| 1721 | } | ||
| 1722 | #else | ||
| 1723 | static void of_add_proc_dt_entry(struct device_node *dn) | ||
| 1724 | { | ||
| 1725 | return; | ||
| 1726 | } | ||
| 1727 | #endif | ||
| 1728 | |||
| 1729 | /** | 1876 | /** |
| 1730 | * of_attach_node - Plug a device node into the tree and global list. | 1877 | * of_attach_node - Plug a device node into the tree and global list. |
| 1731 | */ | 1878 | */ |
| @@ -1743,24 +1890,13 @@ int of_attach_node(struct device_node *np) | |||
| 1743 | np->allnext = of_allnodes; | 1890 | np->allnext = of_allnodes; |
| 1744 | np->parent->child = np; | 1891 | np->parent->child = np; |
| 1745 | of_allnodes = np; | 1892 | of_allnodes = np; |
| 1893 | of_node_clear_flag(np, OF_DETACHED); | ||
| 1746 | raw_spin_unlock_irqrestore(&devtree_lock, flags); | 1894 | raw_spin_unlock_irqrestore(&devtree_lock, flags); |
| 1747 | 1895 | ||
| 1748 | of_add_proc_dt_entry(np); | 1896 | of_node_add(np); |
| 1749 | return 0; | 1897 | return 0; |
| 1750 | } | 1898 | } |
| 1751 | 1899 | ||
| 1752 | #ifdef CONFIG_PROC_DEVICETREE | ||
| 1753 | static void of_remove_proc_dt_entry(struct device_node *dn) | ||
| 1754 | { | ||
| 1755 | proc_remove(dn->pde); | ||
| 1756 | } | ||
| 1757 | #else | ||
| 1758 | static void of_remove_proc_dt_entry(struct device_node *dn) | ||
| 1759 | { | ||
| 1760 | return; | ||
| 1761 | } | ||
| 1762 | #endif | ||
| 1763 | |||
| 1764 | /** | 1900 | /** |
| 1765 | * of_detach_node - "Unplug" a node from the device tree. | 1901 | * of_detach_node - "Unplug" a node from the device tree. |
| 1766 | * | 1902 | * |
| @@ -1816,7 +1952,7 @@ int of_detach_node(struct device_node *np) | |||
| 1816 | of_node_set_flag(np, OF_DETACHED); | 1952 | of_node_set_flag(np, OF_DETACHED); |
| 1817 | raw_spin_unlock_irqrestore(&devtree_lock, flags); | 1953 | raw_spin_unlock_irqrestore(&devtree_lock, flags); |
| 1818 | 1954 | ||
| 1819 | of_remove_proc_dt_entry(np); | 1955 | of_node_remove(np); |
| 1820 | return rc; | 1956 | return rc; |
| 1821 | } | 1957 | } |
| 1822 | #endif /* defined(CONFIG_OF_DYNAMIC) */ | 1958 | #endif /* defined(CONFIG_OF_DYNAMIC) */ |
| @@ -1852,9 +1988,9 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)) | |||
| 1852 | of_chosen = of_find_node_by_path("/chosen@0"); | 1988 | of_chosen = of_find_node_by_path("/chosen@0"); |
| 1853 | 1989 | ||
| 1854 | if (of_chosen) { | 1990 | if (of_chosen) { |
| 1855 | const char *name; | 1991 | const char *name = of_get_property(of_chosen, "stdout-path", NULL); |
| 1856 | 1992 | if (!name) | |
| 1857 | name = of_get_property(of_chosen, "linux,stdout-path", NULL); | 1993 | name = of_get_property(of_chosen, "linux,stdout-path", NULL); |
| 1858 | if (name) | 1994 | if (name) |
| 1859 | of_stdout = of_find_node_by_path(name); | 1995 | of_stdout = of_find_node_by_path(name); |
| 1860 | } | 1996 | } |
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 758b4f8b30b7..fa16a912a927 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c | |||
| @@ -15,6 +15,8 @@ | |||
| 15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| 16 | #include <linux/of.h> | 16 | #include <linux/of.h> |
| 17 | #include <linux/of_fdt.h> | 17 | #include <linux/of_fdt.h> |
| 18 | #include <linux/of_reserved_mem.h> | ||
| 19 | #include <linux/sizes.h> | ||
| 18 | #include <linux/string.h> | 20 | #include <linux/string.h> |
| 19 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
| 20 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
| @@ -202,6 +204,7 @@ static void * unflatten_dt_node(struct boot_param_header *blob, | |||
| 202 | __alignof__(struct device_node)); | 204 | __alignof__(struct device_node)); |
| 203 | if (allnextpp) { | 205 | if (allnextpp) { |
| 204 | char *fn; | 206 | char *fn; |
| 207 | of_node_init(np); | ||
| 205 | np->full_name = fn = ((char *)np) + sizeof(*np); | 208 | np->full_name = fn = ((char *)np) + sizeof(*np); |
| 206 | if (new_format) { | 209 | if (new_format) { |
| 207 | /* rebuild full path for new format */ | 210 | /* rebuild full path for new format */ |
| @@ -232,7 +235,6 @@ static void * unflatten_dt_node(struct boot_param_header *blob, | |||
| 232 | dad->next->sibling = np; | 235 | dad->next->sibling = np; |
| 233 | dad->next = np; | 236 | dad->next = np; |
| 234 | } | 237 | } |
| 235 | kref_init(&np->kref); | ||
| 236 | } | 238 | } |
| 237 | /* process properties */ | 239 | /* process properties */ |
| 238 | while (1) { | 240 | while (1) { |
| @@ -440,6 +442,129 @@ struct boot_param_header *initial_boot_params; | |||
| 440 | #ifdef CONFIG_OF_EARLY_FLATTREE | 442 | #ifdef CONFIG_OF_EARLY_FLATTREE |
| 441 | 443 | ||
| 442 | /** | 444 | /** |
| 445 | * res_mem_reserve_reg() - reserve all memory described in 'reg' property | ||
| 446 | */ | ||
| 447 | static int __init __reserved_mem_reserve_reg(unsigned long node, | ||
| 448 | const char *uname) | ||
| 449 | { | ||
| 450 | int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32); | ||
| 451 | phys_addr_t base, size; | ||
| 452 | unsigned long len; | ||
| 453 | __be32 *prop; | ||
| 454 | int nomap, first = 1; | ||
| 455 | |||
| 456 | prop = of_get_flat_dt_prop(node, "reg", &len); | ||
| 457 | if (!prop) | ||
| 458 | return -ENOENT; | ||
| 459 | |||
| 460 | if (len && len % t_len != 0) { | ||
| 461 | pr_err("Reserved memory: invalid reg property in '%s', skipping node.\n", | ||
| 462 | uname); | ||
| 463 | return -EINVAL; | ||
| 464 | } | ||
| 465 | |||
| 466 | nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL; | ||
| 467 | |||
| 468 | while (len >= t_len) { | ||
| 469 | base = dt_mem_next_cell(dt_root_addr_cells, &prop); | ||
| 470 | size = dt_mem_next_cell(dt_root_size_cells, &prop); | ||
| 471 | |||
| 472 | if (base && size && | ||
| 473 | early_init_dt_reserve_memory_arch(base, size, nomap) == 0) | ||
| 474 | pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %ld MiB\n", | ||
| 475 | uname, &base, (unsigned long)size / SZ_1M); | ||
| 476 | else | ||
| 477 | pr_info("Reserved memory: failed to reserve memory for node '%s': base %pa, size %ld MiB\n", | ||
| 478 | uname, &base, (unsigned long)size / SZ_1M); | ||
| 479 | |||
| 480 | len -= t_len; | ||
| 481 | if (first) { | ||
| 482 | fdt_reserved_mem_save_node(node, uname, base, size); | ||
| 483 | first = 0; | ||
| 484 | } | ||
| 485 | } | ||
| 486 | return 0; | ||
| 487 | } | ||
| 488 | |||
| 489 | /** | ||
| 490 | * __reserved_mem_check_root() - check if #size-cells, #address-cells provided | ||
| 491 | * in /reserved-memory matches the values supported by the current implementation, | ||
| 492 | * also check if ranges property has been provided | ||
| 493 | */ | ||
| 494 | static int __reserved_mem_check_root(unsigned long node) | ||
| 495 | { | ||
| 496 | __be32 *prop; | ||
| 497 | |||
| 498 | prop = of_get_flat_dt_prop(node, "#size-cells", NULL); | ||
| 499 | if (!prop || be32_to_cpup(prop) != dt_root_size_cells) | ||
| 500 | return -EINVAL; | ||
| 501 | |||
| 502 | prop = of_get_flat_dt_prop(node, "#address-cells", NULL); | ||
| 503 | if (!prop || be32_to_cpup(prop) != dt_root_addr_cells) | ||
| 504 | return -EINVAL; | ||
| 505 | |||
| 506 | prop = of_get_flat_dt_prop(node, "ranges", NULL); | ||
| 507 | if (!prop) | ||
| 508 | return -EINVAL; | ||
| 509 | return 0; | ||
| 510 | } | ||
| 511 | |||
| 512 | /** | ||
| 513 | * fdt_scan_reserved_mem() - scan a single FDT node for reserved memory | ||
| 514 | */ | ||
| 515 | static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname, | ||
| 516 | int depth, void *data) | ||
| 517 | { | ||
| 518 | static int found; | ||
| 519 | const char *status; | ||
| 520 | int err; | ||
| 521 | |||
| 522 | if (!found && depth == 1 && strcmp(uname, "reserved-memory") == 0) { | ||
| 523 | if (__reserved_mem_check_root(node) != 0) { | ||
| 524 | pr_err("Reserved memory: unsupported node format, ignoring\n"); | ||
| 525 | /* break scan */ | ||
| 526 | return 1; | ||
| 527 | } | ||
| 528 | found = 1; | ||
| 529 | /* scan next node */ | ||
| 530 | return 0; | ||
| 531 | } else if (!found) { | ||
| 532 | /* scan next node */ | ||
| 533 | return 0; | ||
| 534 | } else if (found && depth < 2) { | ||
| 535 | /* scanning of /reserved-memory has been finished */ | ||
| 536 | return 1; | ||
| 537 | } | ||
| 538 | |||
| 539 | status = of_get_flat_dt_prop(node, "status", NULL); | ||
| 540 | if (status && strcmp(status, "okay") != 0 && strcmp(status, "ok") != 0) | ||
| 541 | return 0; | ||
| 542 | |||
| 543 | err = __reserved_mem_reserve_reg(node, uname); | ||
| 544 | if (err == -ENOENT && of_get_flat_dt_prop(node, "size", NULL)) | ||
| 545 | fdt_reserved_mem_save_node(node, uname, 0, 0); | ||
| 546 | |||
| 547 | /* scan next node */ | ||
| 548 | return 0; | ||
| 549 | } | ||
| 550 | |||
| 551 | /** | ||
| 552 | * early_init_fdt_scan_reserved_mem() - create reserved memory regions | ||
| 553 | * | ||
| 554 | * This function grabs memory from early allocator for device exclusive use | ||
| 555 | * defined in device tree structures. It should be called by arch specific code | ||
| 556 | * once the early allocator (i.e. memblock) has been fully activated. | ||
| 557 | */ | ||
| 558 | void __init early_init_fdt_scan_reserved_mem(void) | ||
| 559 | { | ||
| 560 | if (!initial_boot_params) | ||
| 561 | return; | ||
| 562 | |||
| 563 | of_scan_flat_dt(__fdt_scan_reserved_mem, NULL); | ||
| 564 | fdt_init_reserved_mem(); | ||
| 565 | } | ||
| 566 | |||
| 567 | /** | ||
| 443 | * of_scan_flat_dt - scan flattened tree blob and call callback on each. | 568 | * of_scan_flat_dt - scan flattened tree blob and call callback on each. |
| 444 | * @it: callback function | 569 | * @it: callback function |
| 445 | * @data: context data pointer | 570 | * @data: context data pointer |
| @@ -856,6 +981,16 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size) | |||
| 856 | memblock_add(base, size); | 981 | memblock_add(base, size); |
| 857 | } | 982 | } |
| 858 | 983 | ||
| 984 | int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, | ||
| 985 | phys_addr_t size, bool nomap) | ||
| 986 | { | ||
| 987 | if (memblock_is_region_reserved(base, size)) | ||
| 988 | return -EBUSY; | ||
| 989 | if (nomap) | ||
| 990 | return memblock_remove(base, size); | ||
| 991 | return memblock_reserve(base, size); | ||
| 992 | } | ||
| 993 | |||
| 859 | /* | 994 | /* |
| 860 | * called from unflatten_device_tree() to bootstrap devicetree itself | 995 | * called from unflatten_device_tree() to bootstrap devicetree itself |
| 861 | * Architectures can override this definition if memblock isn't used | 996 | * Architectures can override this definition if memblock isn't used |
| @@ -864,6 +999,14 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) | |||
| 864 | { | 999 | { |
| 865 | return __va(memblock_alloc(size, align)); | 1000 | return __va(memblock_alloc(size, align)); |
| 866 | } | 1001 | } |
| 1002 | #else | ||
| 1003 | int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, | ||
| 1004 | phys_addr_t size, bool nomap) | ||
| 1005 | { | ||
| 1006 | pr_err("Reserved memory not supported, ignoring range 0x%llx - 0x%llx%s\n", | ||
| 1007 | base, size, nomap ? " (nomap)" : ""); | ||
| 1008 | return -ENOSYS; | ||
| 1009 | } | ||
| 867 | #endif | 1010 | #endif |
| 868 | 1011 | ||
| 869 | bool __init early_init_dt_scan(void *params) | 1012 | bool __init early_init_dt_scan(void *params) |
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c index a208a457558c..a3df3428dac6 100644 --- a/drivers/of/of_net.c +++ b/drivers/of/of_net.c | |||
| @@ -13,8 +13,8 @@ | |||
| 13 | 13 | ||
| 14 | /** | 14 | /** |
| 15 | * It maps 'enum phy_interface_t' found in include/linux/phy.h | 15 | * It maps 'enum phy_interface_t' found in include/linux/phy.h |
| 16 | * into the device tree binding of 'phy-mode', so that Ethernet | 16 | * into the device tree binding of 'phy-mode' or 'phy-connection-type', |
| 17 | * device driver can get phy interface from device tree. | 17 | * so that Ethernet device driver can get phy interface from device tree. |
| 18 | */ | 18 | */ |
| 19 | static const char *phy_modes[] = { | 19 | static const char *phy_modes[] = { |
| 20 | [PHY_INTERFACE_MODE_NA] = "", | 20 | [PHY_INTERFACE_MODE_NA] = "", |
| @@ -37,8 +37,9 @@ static const char *phy_modes[] = { | |||
| 37 | * of_get_phy_mode - Get phy mode for given device_node | 37 | * of_get_phy_mode - Get phy mode for given device_node |
| 38 | * @np: Pointer to the given device_node | 38 | * @np: Pointer to the given device_node |
| 39 | * | 39 | * |
| 40 | * The function gets phy interface string from property 'phy-mode', | 40 | * The function gets phy interface string from property 'phy-mode' or |
| 41 | * and return its index in phy_modes table, or errno in error case. | 41 | * 'phy-connection-type', and return its index in phy_modes table, or errno in |
| 42 | * error case. | ||
| 42 | */ | 43 | */ |
| 43 | int of_get_phy_mode(struct device_node *np) | 44 | int of_get_phy_mode(struct device_node *np) |
| 44 | { | 45 | { |
| @@ -47,6 +48,8 @@ int of_get_phy_mode(struct device_node *np) | |||
| 47 | 48 | ||
| 48 | err = of_property_read_string(np, "phy-mode", &pm); | 49 | err = of_property_read_string(np, "phy-mode", &pm); |
| 49 | if (err < 0) | 50 | if (err < 0) |
| 51 | err = of_property_read_string(np, "phy-connection-type", &pm); | ||
| 52 | if (err < 0) | ||
| 50 | return err; | 53 | return err; |
| 51 | 54 | ||
| 52 | for (i = 0; i < ARRAY_SIZE(phy_modes); i++) | 55 | for (i = 0; i < ARRAY_SIZE(phy_modes); i++) |
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c new file mode 100644 index 000000000000..daaaf935911d --- /dev/null +++ b/drivers/of/of_reserved_mem.c | |||
| @@ -0,0 +1,217 @@ | |||
| 1 | /* | ||
| 2 | * Device tree based initialization code for reserved memory. | ||
| 3 | * | ||
| 4 | * Copyright (c) 2013, The Linux Foundation. All Rights Reserved. | ||
| 5 | * Copyright (c) 2013,2014 Samsung Electronics Co., Ltd. | ||
| 6 | * http://www.samsung.com | ||
| 7 | * Author: Marek Szyprowski <m.szyprowski@samsung.com> | ||
| 8 | * Author: Josh Cartwright <joshc@codeaurora.org> | ||
| 9 | * | ||
| 10 | * This program is free software; you can redistribute it and/or | ||
| 11 | * modify it under the terms of the GNU General Public License as | ||
| 12 | * published by the Free Software Foundation; either version 2 of the | ||
| 13 | * License or (at your optional) any later version of the license. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include <linux/err.h> | ||
| 17 | #include <linux/of.h> | ||
| 18 | #include <linux/of_fdt.h> | ||
| 19 | #include <linux/of_platform.h> | ||
| 20 | #include <linux/mm.h> | ||
| 21 | #include <linux/sizes.h> | ||
| 22 | #include <linux/of_reserved_mem.h> | ||
| 23 | |||
| 24 | #define MAX_RESERVED_REGIONS 16 | ||
| 25 | static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS]; | ||
| 26 | static int reserved_mem_count; | ||
| 27 | |||
| 28 | #if defined(CONFIG_HAVE_MEMBLOCK) | ||
| 29 | #include <linux/memblock.h> | ||
| 30 | int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, | ||
| 31 | phys_addr_t align, phys_addr_t start, phys_addr_t end, bool nomap, | ||
| 32 | phys_addr_t *res_base) | ||
| 33 | { | ||
| 34 | /* | ||
| 35 | * We use __memblock_alloc_base() because memblock_alloc_base() | ||
| 36 | * panic()s on allocation failure. | ||
| 37 | */ | ||
| 38 | phys_addr_t base = __memblock_alloc_base(size, align, end); | ||
| 39 | if (!base) | ||
| 40 | return -ENOMEM; | ||
| 41 | |||
| 42 | /* | ||
| 43 | * Check if the allocated region fits in to start..end window | ||
| 44 | */ | ||
| 45 | if (base < start) { | ||
| 46 | memblock_free(base, size); | ||
| 47 | return -ENOMEM; | ||
| 48 | } | ||
| 49 | |||
| 50 | *res_base = base; | ||
| 51 | if (nomap) | ||
| 52 | return memblock_remove(base, size); | ||
| 53 | return 0; | ||
| 54 | } | ||
| 55 | #else | ||
| 56 | int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, | ||
| 57 | phys_addr_t align, phys_addr_t start, phys_addr_t end, bool nomap, | ||
| 58 | phys_addr_t *res_base) | ||
| 59 | { | ||
| 60 | pr_err("Reserved memory not supported, ignoring region 0x%llx%s\n", | ||
| 61 | size, nomap ? " (nomap)" : ""); | ||
| 62 | return -ENOSYS; | ||
| 63 | } | ||
| 64 | #endif | ||
| 65 | |||
| 66 | /** | ||
| 67 | * res_mem_save_node() - save fdt node for second pass initialization | ||
| 68 | */ | ||
| 69 | void __init fdt_reserved_mem_save_node(unsigned long node, const char *uname, | ||
| 70 | phys_addr_t base, phys_addr_t size) | ||
| 71 | { | ||
| 72 | struct reserved_mem *rmem = &reserved_mem[reserved_mem_count]; | ||
| 73 | |||
| 74 | if (reserved_mem_count == ARRAY_SIZE(reserved_mem)) { | ||
| 75 | pr_err("Reserved memory: not enough space all defined regions.\n"); | ||
| 76 | return; | ||
| 77 | } | ||
| 78 | |||
| 79 | rmem->fdt_node = node; | ||
| 80 | rmem->name = uname; | ||
| 81 | rmem->base = base; | ||
| 82 | rmem->size = size; | ||
| 83 | |||
| 84 | reserved_mem_count++; | ||
| 85 | return; | ||
| 86 | } | ||
| 87 | |||
| 88 | /** | ||
| 89 | * res_mem_alloc_size() - allocate reserved memory described by 'size', 'align' | ||
| 90 | * and 'alloc-ranges' properties | ||
| 91 | */ | ||
| 92 | static int __init __reserved_mem_alloc_size(unsigned long node, | ||
| 93 | const char *uname, phys_addr_t *res_base, phys_addr_t *res_size) | ||
| 94 | { | ||
| 95 | int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32); | ||
| 96 | phys_addr_t start = 0, end = 0; | ||
| 97 | phys_addr_t base = 0, align = 0, size; | ||
| 98 | unsigned long len; | ||
| 99 | __be32 *prop; | ||
| 100 | int nomap; | ||
| 101 | int ret; | ||
| 102 | |||
| 103 | prop = of_get_flat_dt_prop(node, "size", &len); | ||
| 104 | if (!prop) | ||
| 105 | return -EINVAL; | ||
| 106 | |||
| 107 | if (len != dt_root_size_cells * sizeof(__be32)) { | ||
| 108 | pr_err("Reserved memory: invalid size property in '%s' node.\n", | ||
| 109 | uname); | ||
| 110 | return -EINVAL; | ||
| 111 | } | ||
| 112 | size = dt_mem_next_cell(dt_root_size_cells, &prop); | ||
| 113 | |||
| 114 | nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL; | ||
| 115 | |||
| 116 | prop = of_get_flat_dt_prop(node, "alignment", &len); | ||
| 117 | if (prop) { | ||
| 118 | if (len != dt_root_addr_cells * sizeof(__be32)) { | ||
| 119 | pr_err("Reserved memory: invalid alignment property in '%s' node.\n", | ||
| 120 | uname); | ||
| 121 | return -EINVAL; | ||
| 122 | } | ||
| 123 | align = dt_mem_next_cell(dt_root_addr_cells, &prop); | ||
| 124 | } | ||
| 125 | |||
| 126 | prop = of_get_flat_dt_prop(node, "alloc-ranges", &len); | ||
| 127 | if (prop) { | ||
| 128 | |||
| 129 | if (len % t_len != 0) { | ||
| 130 | pr_err("Reserved memory: invalid alloc-ranges property in '%s', skipping node.\n", | ||
| 131 | uname); | ||
| 132 | return -EINVAL; | ||
| 133 | } | ||
| 134 | |||
| 135 | base = 0; | ||
| 136 | |||
| 137 | while (len > 0) { | ||
| 138 | start = dt_mem_next_cell(dt_root_addr_cells, &prop); | ||
| 139 | end = start + dt_mem_next_cell(dt_root_size_cells, | ||
| 140 | &prop); | ||
| 141 | |||
| 142 | ret = early_init_dt_alloc_reserved_memory_arch(size, | ||
| 143 | align, start, end, nomap, &base); | ||
| 144 | if (ret == 0) { | ||
| 145 | pr_debug("Reserved memory: allocated memory for '%s' node: base %pa, size %ld MiB\n", | ||
| 146 | uname, &base, | ||
| 147 | (unsigned long)size / SZ_1M); | ||
| 148 | break; | ||
| 149 | } | ||
| 150 | len -= t_len; | ||
| 151 | } | ||
| 152 | |||
| 153 | } else { | ||
| 154 | ret = early_init_dt_alloc_reserved_memory_arch(size, align, | ||
| 155 | 0, 0, nomap, &base); | ||
| 156 | if (ret == 0) | ||
| 157 | pr_debug("Reserved memory: allocated memory for '%s' node: base %pa, size %ld MiB\n", | ||
| 158 | uname, &base, (unsigned long)size / SZ_1M); | ||
| 159 | } | ||
| 160 | |||
| 161 | if (base == 0) { | ||
| 162 | pr_info("Reserved memory: failed to allocate memory for node '%s'\n", | ||
| 163 | uname); | ||
| 164 | return -ENOMEM; | ||
| 165 | } | ||
| 166 | |||
| 167 | *res_base = base; | ||
| 168 | *res_size = size; | ||
| 169 | |||
| 170 | return 0; | ||
| 171 | } | ||
| 172 | |||
| 173 | static const struct of_device_id __rmem_of_table_sentinel | ||
| 174 | __used __section(__reservedmem_of_table_end); | ||
| 175 | |||
| 176 | /** | ||
| 177 | * res_mem_init_node() - call region specific reserved memory init code | ||
| 178 | */ | ||
| 179 | static int __init __reserved_mem_init_node(struct reserved_mem *rmem) | ||
| 180 | { | ||
| 181 | extern const struct of_device_id __reservedmem_of_table[]; | ||
| 182 | const struct of_device_id *i; | ||
| 183 | |||
| 184 | for (i = __reservedmem_of_table; i < &__rmem_of_table_sentinel; i++) { | ||
| 185 | reservedmem_of_init_fn initfn = i->data; | ||
| 186 | const char *compat = i->compatible; | ||
| 187 | |||
| 188 | if (!of_flat_dt_is_compatible(rmem->fdt_node, compat)) | ||
| 189 | continue; | ||
| 190 | |||
| 191 | if (initfn(rmem, rmem->fdt_node, rmem->name) == 0) { | ||
| 192 | pr_info("Reserved memory: initialized node %s, compatible id %s\n", | ||
| 193 | rmem->name, compat); | ||
| 194 | return 0; | ||
| 195 | } | ||
| 196 | } | ||
| 197 | return -ENOENT; | ||
| 198 | } | ||
| 199 | |||
| 200 | /** | ||
| 201 | * fdt_init_reserved_mem - allocate and init all saved reserved memory regions | ||
| 202 | */ | ||
| 203 | void __init fdt_init_reserved_mem(void) | ||
| 204 | { | ||
| 205 | int i; | ||
| 206 | for (i = 0; i < reserved_mem_count; i++) { | ||
| 207 | struct reserved_mem *rmem = &reserved_mem[i]; | ||
| 208 | unsigned long node = rmem->fdt_node; | ||
| 209 | int err = 0; | ||
| 210 | |||
| 211 | if (rmem->size == 0) | ||
| 212 | err = __reserved_mem_alloc_size(node, rmem->name, | ||
| 213 | &rmem->base, &rmem->size); | ||
| 214 | if (err == 0) | ||
| 215 | __reserved_mem_init_node(rmem); | ||
| 216 | } | ||
| 217 | } | ||
diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c index 7b666736c168..36b4035881b0 100644 --- a/drivers/of/pdt.c +++ b/drivers/of/pdt.c | |||
| @@ -176,11 +176,10 @@ static struct device_node * __init of_pdt_create_node(phandle node, | |||
| 176 | return NULL; | 176 | return NULL; |
| 177 | 177 | ||
| 178 | dp = prom_early_alloc(sizeof(*dp)); | 178 | dp = prom_early_alloc(sizeof(*dp)); |
| 179 | of_node_init(dp); | ||
| 179 | of_pdt_incr_unique_id(dp); | 180 | of_pdt_incr_unique_id(dp); |
| 180 | dp->parent = parent; | 181 | dp->parent = parent; |
| 181 | 182 | ||
| 182 | kref_init(&dp->kref); | ||
| 183 | |||
| 184 | dp->name = of_pdt_get_one_property(node, "name"); | 183 | dp->name = of_pdt_get_one_property(node, "name"); |
| 185 | dp->type = of_pdt_get_one_property(node, "device_type"); | 184 | dp->type = of_pdt_get_one_property(node, "device_type"); |
| 186 | dp->phandle = node; | 185 | dp->phandle = node; |
diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c index 6643d1920985..ae4450070503 100644 --- a/drivers/of/selftest.c +++ b/drivers/of/selftest.c | |||
| @@ -30,6 +30,67 @@ static struct selftest_results { | |||
| 30 | } \ | 30 | } \ |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | static void __init of_selftest_dynamic(void) | ||
| 34 | { | ||
| 35 | struct device_node *np; | ||
| 36 | struct property *prop; | ||
| 37 | |||
| 38 | np = of_find_node_by_path("/testcase-data"); | ||
| 39 | if (!np) { | ||
| 40 | pr_err("missing testcase data\n"); | ||
| 41 | return; | ||
| 42 | } | ||
| 43 | |||
| 44 | /* Array of 4 properties for the purpose of testing */ | ||
| 45 | prop = kzalloc(sizeof(*prop) * 4, GFP_KERNEL); | ||
| 46 | if (!prop) { | ||
| 47 | selftest(0, "kzalloc() failed\n"); | ||
| 48 | return; | ||
| 49 | } | ||
| 50 | |||
| 51 | /* Add a new property - should pass*/ | ||
| 52 | prop->name = "new-property"; | ||
| 53 | prop->value = "new-property-data"; | ||
| 54 | prop->length = strlen(prop->value); | ||
| 55 | selftest(of_add_property(np, prop) == 0, "Adding a new property failed\n"); | ||
| 56 | |||
| 57 | /* Try to add an existing property - should fail */ | ||
| 58 | prop++; | ||
| 59 | prop->name = "new-property"; | ||
| 60 | prop->value = "new-property-data-should-fail"; | ||
| 61 | prop->length = strlen(prop->value); | ||
| 62 | selftest(of_add_property(np, prop) != 0, | ||
| 63 | "Adding an existing property should have failed\n"); | ||
| 64 | |||
| 65 | /* Try to modify an existing property - should pass */ | ||
| 66 | prop->value = "modify-property-data-should-pass"; | ||
| 67 | prop->length = strlen(prop->value); | ||
| 68 | selftest(of_update_property(np, prop) == 0, | ||
| 69 | "Updating an existing property should have passed\n"); | ||
| 70 | |||
| 71 | /* Try to modify non-existent property - should pass*/ | ||
| 72 | prop++; | ||
| 73 | prop->name = "modify-property"; | ||
| 74 | prop->value = "modify-missing-property-data-should-pass"; | ||
| 75 | prop->length = strlen(prop->value); | ||
| 76 | selftest(of_update_property(np, prop) == 0, | ||
| 77 | "Updating a missing property should have passed\n"); | ||
| 78 | |||
| 79 | /* Remove property - should pass */ | ||
| 80 | selftest(of_remove_property(np, prop) == 0, | ||
| 81 | "Removing a property should have passed\n"); | ||
| 82 | |||
| 83 | /* Adding very large property - should pass */ | ||
| 84 | prop++; | ||
| 85 | prop->name = "large-property-PAGE_SIZEx8"; | ||
| 86 | prop->length = PAGE_SIZE * 8; | ||
| 87 | prop->value = kzalloc(prop->length, GFP_KERNEL); | ||
| 88 | selftest(prop->value != NULL, "Unable to allocate large buffer\n"); | ||
| 89 | if (prop->value) | ||
| 90 | selftest(of_add_property(np, prop) == 0, | ||
| 91 | "Adding a large property should have passed\n"); | ||
| 92 | } | ||
| 93 | |||
| 33 | static void __init of_selftest_parse_phandle_with_args(void) | 94 | static void __init of_selftest_parse_phandle_with_args(void) |
| 34 | { | 95 | { |
| 35 | struct device_node *np; | 96 | struct device_node *np; |
| @@ -378,6 +439,7 @@ static int __init of_selftest(void) | |||
| 378 | of_node_put(np); | 439 | of_node_put(np); |
| 379 | 440 | ||
| 380 | pr_info("start of selftest - you will see error messages\n"); | 441 | pr_info("start of selftest - you will see error messages\n"); |
| 442 | of_selftest_dynamic(); | ||
| 381 | of_selftest_parse_phandle_with_args(); | 443 | of_selftest_parse_phandle_with_args(); |
| 382 | of_selftest_property_match_string(); | 444 | of_selftest_property_match_string(); |
| 383 | of_selftest_parse_interrupts(); | 445 | of_selftest_parse_interrupts(); |
diff --git a/drivers/of/testcase-data/tests-phandle.dtsi b/drivers/of/testcase-data/tests-phandle.dtsi index 0007d3cd7dc2..788a4c24b8f5 100644 --- a/drivers/of/testcase-data/tests-phandle.dtsi +++ b/drivers/of/testcase-data/tests-phandle.dtsi | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | 1 | ||
| 2 | / { | 2 | / { |
| 3 | testcase-data { | 3 | testcase-data { |
| 4 | security-password = "password"; | ||
| 5 | duplicate-name = "duplicate"; | ||
| 6 | duplicate-name { }; | ||
| 4 | phandle-tests { | 7 | phandle-tests { |
| 5 | provider0: provider0 { | 8 | provider0: provider0 { |
| 6 | #phandle-cells = <0>; | 9 | #phandle-cells = <0>; |
diff --git a/fs/proc/Makefile b/fs/proc/Makefile index ab30716584f5..239493ec718e 100644 --- a/fs/proc/Makefile +++ b/fs/proc/Makefile | |||
| @@ -27,6 +27,5 @@ proc-$(CONFIG_PROC_SYSCTL) += proc_sysctl.o | |||
| 27 | proc-$(CONFIG_NET) += proc_net.o | 27 | proc-$(CONFIG_NET) += proc_net.o |
| 28 | proc-$(CONFIG_PROC_KCORE) += kcore.o | 28 | proc-$(CONFIG_PROC_KCORE) += kcore.o |
| 29 | proc-$(CONFIG_PROC_VMCORE) += vmcore.o | 29 | proc-$(CONFIG_PROC_VMCORE) += vmcore.o |
| 30 | proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o | ||
| 31 | proc-$(CONFIG_PRINTK) += kmsg.o | 30 | proc-$(CONFIG_PRINTK) += kmsg.o |
| 32 | proc-$(CONFIG_PROC_PAGE_MONITOR) += page.o | 31 | proc-$(CONFIG_PROC_PAGE_MONITOR) += page.o |
diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 651d09a11dde..3ab6d14e71c5 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h | |||
| @@ -211,13 +211,6 @@ extern int proc_fill_super(struct super_block *); | |||
| 211 | extern void proc_entry_rundown(struct proc_dir_entry *); | 211 | extern void proc_entry_rundown(struct proc_dir_entry *); |
| 212 | 212 | ||
| 213 | /* | 213 | /* |
| 214 | * proc_devtree.c | ||
| 215 | */ | ||
| 216 | #ifdef CONFIG_PROC_DEVICETREE | ||
| 217 | extern void proc_device_tree_init(void); | ||
| 218 | #endif | ||
| 219 | |||
| 220 | /* | ||
| 221 | * proc_namespaces.c | 214 | * proc_namespaces.c |
| 222 | */ | 215 | */ |
| 223 | extern const struct inode_operations proc_ns_dir_inode_operations; | 216 | extern const struct inode_operations proc_ns_dir_inode_operations; |
diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c deleted file mode 100644 index c82dd5147845..000000000000 --- a/fs/proc/proc_devtree.c +++ /dev/null | |||
| @@ -1,241 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * proc_devtree.c - handles /proc/device-tree | ||
| 3 | * | ||
| 4 | * Copyright 1997 Paul Mackerras | ||
| 5 | */ | ||
| 6 | #include <linux/errno.h> | ||
| 7 | #include <linux/init.h> | ||
| 8 | #include <linux/time.h> | ||
| 9 | #include <linux/proc_fs.h> | ||
| 10 | #include <linux/seq_file.h> | ||
| 11 | #include <linux/printk.h> | ||
| 12 | #include <linux/stat.h> | ||
| 13 | #include <linux/string.h> | ||
| 14 | #include <linux/of.h> | ||
| 15 | #include <linux/export.h> | ||
| 16 | #include <linux/slab.h> | ||
| 17 | #include <asm/uaccess.h> | ||
| 18 | #include "internal.h" | ||
| 19 | |||
| 20 | static inline void set_node_proc_entry(struct device_node *np, | ||
| 21 | struct proc_dir_entry *de) | ||
| 22 | { | ||
| 23 | np->pde = de; | ||
| 24 | } | ||
| 25 | |||
| 26 | static struct proc_dir_entry *proc_device_tree; | ||
| 27 | |||
| 28 | /* | ||
| 29 | * Supply data on a read from /proc/device-tree/node/property. | ||
| 30 | */ | ||
| 31 | static int property_proc_show(struct seq_file *m, void *v) | ||
| 32 | { | ||
| 33 | struct property *pp = m->private; | ||
| 34 | |||
| 35 | seq_write(m, pp->value, pp->length); | ||
| 36 | return 0; | ||
| 37 | } | ||
| 38 | |||
| 39 | static int property_proc_open(struct inode *inode, struct file *file) | ||
| 40 | { | ||
| 41 | return single_open(file, property_proc_show, __PDE_DATA(inode)); | ||
| 42 | } | ||
| 43 | |||
| 44 | static const struct file_operations property_proc_fops = { | ||
| 45 | .owner = THIS_MODULE, | ||
| 46 | .open = property_proc_open, | ||
| 47 | .read = seq_read, | ||
| 48 | .llseek = seq_lseek, | ||
| 49 | .release = single_release, | ||
| 50 | }; | ||
| 51 | |||
| 52 | /* | ||
| 53 | * For a node with a name like "gc@10", we make symlinks called "gc" | ||
| 54 | * and "@10" to it. | ||
| 55 | */ | ||
| 56 | |||
| 57 | /* | ||
| 58 | * Add a property to a node | ||
| 59 | */ | ||
| 60 | static struct proc_dir_entry * | ||
| 61 | __proc_device_tree_add_prop(struct proc_dir_entry *de, struct property *pp, | ||
| 62 | const char *name) | ||
| 63 | { | ||
| 64 | struct proc_dir_entry *ent; | ||
| 65 | |||
| 66 | /* | ||
| 67 | * Unfortunately proc_register puts each new entry | ||
| 68 | * at the beginning of the list. So we rearrange them. | ||
| 69 | */ | ||
| 70 | ent = proc_create_data(name, | ||
| 71 | strncmp(name, "security-", 9) ? S_IRUGO : S_IRUSR, | ||
| 72 | de, &property_proc_fops, pp); | ||
| 73 | if (ent == NULL) | ||
| 74 | return NULL; | ||
| 75 | |||
| 76 | if (!strncmp(name, "security-", 9)) | ||
| 77 | proc_set_size(ent, 0); /* don't leak number of password chars */ | ||
| 78 | else | ||
| 79 | proc_set_size(ent, pp->length); | ||
| 80 | |||
| 81 | return ent; | ||
| 82 | } | ||
| 83 | |||
| 84 | |||
| 85 | void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop) | ||
| 86 | { | ||
| 87 | __proc_device_tree_add_prop(pde, prop, prop->name); | ||
| 88 | } | ||
| 89 | |||
| 90 | void proc_device_tree_remove_prop(struct proc_dir_entry *pde, | ||
| 91 | struct property *prop) | ||
| 92 | { | ||
| 93 | remove_proc_entry(prop->name, pde); | ||
| 94 | } | ||
| 95 | |||
| 96 | void proc_device_tree_update_prop(struct proc_dir_entry *pde, | ||
| 97 | struct property *newprop, | ||
| 98 | struct property *oldprop) | ||
| 99 | { | ||
| 100 | struct proc_dir_entry *ent; | ||
| 101 | |||
| 102 | if (!oldprop) { | ||
| 103 | proc_device_tree_add_prop(pde, newprop); | ||
| 104 | return; | ||
| 105 | } | ||
| 106 | |||
| 107 | for (ent = pde->subdir; ent != NULL; ent = ent->next) | ||
| 108 | if (ent->data == oldprop) | ||
| 109 | break; | ||
| 110 | if (ent == NULL) { | ||
| 111 | pr_warn("device-tree: property \"%s\" does not exist\n", | ||
| 112 | oldprop->name); | ||
| 113 | } else { | ||
| 114 | ent->data = newprop; | ||
| 115 | ent->size = newprop->length; | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | /* | ||
| 120 | * Various dodgy firmware might give us nodes and/or properties with | ||
| 121 | * conflicting names. That's generally ok, except for exporting via /proc, | ||
| 122 | * so munge names here to ensure they're unique. | ||
| 123 | */ | ||
| 124 | |||
| 125 | static int duplicate_name(struct proc_dir_entry *de, const char *name) | ||
| 126 | { | ||
| 127 | struct proc_dir_entry *ent; | ||
| 128 | int found = 0; | ||
| 129 | |||
| 130 | spin_lock(&proc_subdir_lock); | ||
| 131 | |||
| 132 | for (ent = de->subdir; ent != NULL; ent = ent->next) { | ||
| 133 | if (strcmp(ent->name, name) == 0) { | ||
| 134 | found = 1; | ||
| 135 | break; | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | spin_unlock(&proc_subdir_lock); | ||
| 140 | |||
| 141 | return found; | ||
| 142 | } | ||
| 143 | |||
| 144 | static const char *fixup_name(struct device_node *np, struct proc_dir_entry *de, | ||
| 145 | const char *name) | ||
| 146 | { | ||
| 147 | char *fixed_name; | ||
| 148 | int fixup_len = strlen(name) + 2 + 1; /* name + #x + \0 */ | ||
| 149 | int i = 1, size; | ||
| 150 | |||
| 151 | realloc: | ||
| 152 | fixed_name = kmalloc(fixup_len, GFP_KERNEL); | ||
| 153 | if (fixed_name == NULL) { | ||
| 154 | pr_err("device-tree: Out of memory trying to fixup " | ||
| 155 | "name \"%s\"\n", name); | ||
| 156 | return name; | ||
| 157 | } | ||
| 158 | |||
| 159 | retry: | ||
| 160 | size = snprintf(fixed_name, fixup_len, "%s#%d", name, i); | ||
| 161 | size++; /* account for NULL */ | ||
| 162 | |||
| 163 | if (size > fixup_len) { | ||
| 164 | /* We ran out of space, free and reallocate. */ | ||
| 165 | kfree(fixed_name); | ||
| 166 | fixup_len = size; | ||
| 167 | goto realloc; | ||
| 168 | } | ||
| 169 | |||
| 170 | if (duplicate_name(de, fixed_name)) { | ||
| 171 | /* Multiple duplicates. Retry with a different offset. */ | ||
| 172 | i++; | ||
| 173 | goto retry; | ||
| 174 | } | ||
| 175 | |||
| 176 | pr_warn("device-tree: Duplicate name in %s, renamed to \"%s\"\n", | ||
| 177 | np->full_name, fixed_name); | ||
| 178 | |||
| 179 | return fixed_name; | ||
| 180 | } | ||
| 181 | |||
| 182 | /* | ||
| 183 | * Process a node, adding entries for its children and its properties. | ||
| 184 | */ | ||
| 185 | void proc_device_tree_add_node(struct device_node *np, | ||
| 186 | struct proc_dir_entry *de) | ||
| 187 | { | ||
| 188 | struct property *pp; | ||
| 189 | struct proc_dir_entry *ent; | ||
| 190 | struct device_node *child; | ||
| 191 | const char *p; | ||
| 192 | |||
| 193 | set_node_proc_entry(np, de); | ||
| 194 | for (child = NULL; (child = of_get_next_child(np, child));) { | ||
| 195 | /* Use everything after the last slash, or the full name */ | ||
| 196 | p = kbasename(child->full_name); | ||
| 197 | |||
| 198 | if (duplicate_name(de, p)) | ||
| 199 | p = fixup_name(np, de, p); | ||
| 200 | |||
| 201 | ent = proc_mkdir(p, de); | ||
| 202 | if (ent == NULL) | ||
| 203 | break; | ||
| 204 | proc_device_tree_add_node(child, ent); | ||
| 205 | } | ||
| 206 | of_node_put(child); | ||
| 207 | |||
| 208 | for (pp = np->properties; pp != NULL; pp = pp->next) { | ||
| 209 | p = pp->name; | ||
| 210 | |||
| 211 | if (strchr(p, '/')) | ||
| 212 | continue; | ||
| 213 | |||
| 214 | if (duplicate_name(de, p)) | ||
| 215 | p = fixup_name(np, de, p); | ||
| 216 | |||
| 217 | ent = __proc_device_tree_add_prop(de, pp, p); | ||
| 218 | if (ent == NULL) | ||
| 219 | break; | ||
| 220 | } | ||
| 221 | } | ||
| 222 | |||
| 223 | /* | ||
| 224 | * Called on initialization to set up the /proc/device-tree subtree | ||
| 225 | */ | ||
| 226 | void __init proc_device_tree_init(void) | ||
| 227 | { | ||
| 228 | struct device_node *root; | ||
| 229 | |||
| 230 | proc_device_tree = proc_mkdir("device-tree", NULL); | ||
| 231 | if (proc_device_tree == NULL) | ||
| 232 | return; | ||
| 233 | root = of_find_node_by_path("/"); | ||
| 234 | if (root == NULL) { | ||
| 235 | remove_proc_entry("device-tree", NULL); | ||
| 236 | pr_debug("/proc/device-tree: can't find root\n"); | ||
| 237 | return; | ||
| 238 | } | ||
| 239 | proc_device_tree_add_node(root, proc_device_tree); | ||
| 240 | of_node_put(root); | ||
| 241 | } | ||
diff --git a/fs/proc/root.c b/fs/proc/root.c index 87dbcbef7fe4..7bbeb5257af1 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c | |||
| @@ -183,9 +183,6 @@ void __init proc_root_init(void) | |||
| 183 | proc_mkdir("openprom", NULL); | 183 | proc_mkdir("openprom", NULL); |
| 184 | #endif | 184 | #endif |
| 185 | proc_tty_init(); | 185 | proc_tty_init(); |
| 186 | #ifdef CONFIG_PROC_DEVICETREE | ||
| 187 | proc_device_tree_init(); | ||
| 188 | #endif | ||
| 189 | proc_mkdir("bus", NULL); | 186 | proc_mkdir("bus", NULL); |
| 190 | proc_sys_init(); | 187 | proc_sys_init(); |
| 191 | } | 188 | } |
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index bc2121fa9132..f10f64fcc815 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
| @@ -167,6 +167,16 @@ | |||
| 167 | #define CLK_OF_TABLES() | 167 | #define CLK_OF_TABLES() |
| 168 | #endif | 168 | #endif |
| 169 | 169 | ||
| 170 | #ifdef CONFIG_OF_RESERVED_MEM | ||
| 171 | #define RESERVEDMEM_OF_TABLES() \ | ||
| 172 | . = ALIGN(8); \ | ||
| 173 | VMLINUX_SYMBOL(__reservedmem_of_table) = .; \ | ||
| 174 | *(__reservedmem_of_table) \ | ||
| 175 | *(__reservedmem_of_table_end) | ||
| 176 | #else | ||
| 177 | #define RESERVEDMEM_OF_TABLES() | ||
| 178 | #endif | ||
| 179 | |||
| 170 | #define KERNEL_DTB() \ | 180 | #define KERNEL_DTB() \ |
| 171 | STRUCT_ALIGN(); \ | 181 | STRUCT_ALIGN(); \ |
| 172 | VMLINUX_SYMBOL(__dtb_start) = .; \ | 182 | VMLINUX_SYMBOL(__dtb_start) = .; \ |
| @@ -490,6 +500,7 @@ | |||
| 490 | TRACE_SYSCALLS() \ | 500 | TRACE_SYSCALLS() \ |
| 491 | MEM_DISCARD(init.rodata) \ | 501 | MEM_DISCARD(init.rodata) \ |
| 492 | CLK_OF_TABLES() \ | 502 | CLK_OF_TABLES() \ |
| 503 | RESERVEDMEM_OF_TABLES() \ | ||
| 493 | CLKSRC_OF_TABLES() \ | 504 | CLKSRC_OF_TABLES() \ |
| 494 | KERNEL_DTB() \ | 505 | KERNEL_DTB() \ |
| 495 | IRQCHIP_OF_MATCH_TABLE() | 506 | IRQCHIP_OF_MATCH_TABLE() |
diff --git a/include/linux/of.h b/include/linux/of.h index 83d1ac80c91e..919bf211877d 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | #include <linux/types.h> | 18 | #include <linux/types.h> |
| 19 | #include <linux/bitops.h> | 19 | #include <linux/bitops.h> |
| 20 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
| 21 | #include <linux/kref.h> | 21 | #include <linux/kobject.h> |
| 22 | #include <linux/mod_devicetable.h> | 22 | #include <linux/mod_devicetable.h> |
| 23 | #include <linux/spinlock.h> | 23 | #include <linux/spinlock.h> |
| 24 | #include <linux/topology.h> | 24 | #include <linux/topology.h> |
| @@ -37,6 +37,7 @@ struct property { | |||
| 37 | struct property *next; | 37 | struct property *next; |
| 38 | unsigned long _flags; | 38 | unsigned long _flags; |
| 39 | unsigned int unique_id; | 39 | unsigned int unique_id; |
| 40 | struct bin_attribute attr; | ||
| 40 | }; | 41 | }; |
| 41 | 42 | ||
| 42 | #if defined(CONFIG_SPARC) | 43 | #if defined(CONFIG_SPARC) |
| @@ -56,8 +57,7 @@ struct device_node { | |||
| 56 | struct device_node *sibling; | 57 | struct device_node *sibling; |
| 57 | struct device_node *next; /* next device of same type */ | 58 | struct device_node *next; /* next device of same type */ |
| 58 | struct device_node *allnext; /* next in list of all nodes */ | 59 | struct device_node *allnext; /* next in list of all nodes */ |
| 59 | struct proc_dir_entry *pde; /* this node's proc directory */ | 60 | struct kobject kobj; |
| 60 | struct kref kref; | ||
| 61 | unsigned long _flags; | 61 | unsigned long _flags; |
| 62 | void *data; | 62 | void *data; |
| 63 | #if defined(CONFIG_SPARC) | 63 | #if defined(CONFIG_SPARC) |
| @@ -67,13 +67,34 @@ struct device_node { | |||
| 67 | #endif | 67 | #endif |
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| 70 | #define MAX_PHANDLE_ARGS 8 | 70 | #define MAX_PHANDLE_ARGS 16 |
| 71 | struct of_phandle_args { | 71 | struct of_phandle_args { |
| 72 | struct device_node *np; | 72 | struct device_node *np; |
| 73 | int args_count; | 73 | int args_count; |
| 74 | uint32_t args[MAX_PHANDLE_ARGS]; | 74 | uint32_t args[MAX_PHANDLE_ARGS]; |
| 75 | }; | 75 | }; |
| 76 | 76 | ||
| 77 | extern int of_node_add(struct device_node *node); | ||
| 78 | |||
| 79 | /* initialize a node */ | ||
| 80 | extern struct kobj_type of_node_ktype; | ||
| 81 | static inline void of_node_init(struct device_node *node) | ||
| 82 | { | ||
| 83 | kobject_init(&node->kobj, &of_node_ktype); | ||
| 84 | } | ||
| 85 | |||
| 86 | /* true when node is initialized */ | ||
| 87 | static inline int of_node_is_initialized(struct device_node *node) | ||
| 88 | { | ||
| 89 | return node && node->kobj.state_initialized; | ||
| 90 | } | ||
| 91 | |||
| 92 | /* true when node is attached (i.e. present on sysfs) */ | ||
| 93 | static inline int of_node_is_attached(struct device_node *node) | ||
| 94 | { | ||
| 95 | return node && node->kobj.state_in_sysfs; | ||
| 96 | } | ||
| 97 | |||
| 77 | #ifdef CONFIG_OF_DYNAMIC | 98 | #ifdef CONFIG_OF_DYNAMIC |
| 78 | extern struct device_node *of_node_get(struct device_node *node); | 99 | extern struct device_node *of_node_get(struct device_node *node); |
| 79 | extern void of_node_put(struct device_node *node); | 100 | extern void of_node_put(struct device_node *node); |
| @@ -114,6 +135,26 @@ static inline void of_node_set_flag(struct device_node *n, unsigned long flag) | |||
| 114 | set_bit(flag, &n->_flags); | 135 | set_bit(flag, &n->_flags); |
| 115 | } | 136 | } |
| 116 | 137 | ||
| 138 | static inline void of_node_clear_flag(struct device_node *n, unsigned long flag) | ||
| 139 | { | ||
| 140 | clear_bit(flag, &n->_flags); | ||
| 141 | } | ||
| 142 | |||
| 143 | static inline int of_property_check_flag(struct property *p, unsigned long flag) | ||
| 144 | { | ||
| 145 | return test_bit(flag, &p->_flags); | ||
| 146 | } | ||
| 147 | |||
| 148 | static inline void of_property_set_flag(struct property *p, unsigned long flag) | ||
| 149 | { | ||
| 150 | set_bit(flag, &p->_flags); | ||
| 151 | } | ||
| 152 | |||
| 153 | static inline void of_property_clear_flag(struct property *p, unsigned long flag) | ||
| 154 | { | ||
| 155 | clear_bit(flag, &p->_flags); | ||
| 156 | } | ||
| 157 | |||
| 117 | extern struct device_node *of_find_all_nodes(struct device_node *prev); | 158 | extern struct device_node *of_find_all_nodes(struct device_node *prev); |
| 118 | 159 | ||
| 119 | /* | 160 | /* |
| @@ -167,6 +208,8 @@ static inline const char *of_node_full_name(const struct device_node *np) | |||
| 167 | return np ? np->full_name : "<no-node>"; | 208 | return np ? np->full_name : "<no-node>"; |
| 168 | } | 209 | } |
| 169 | 210 | ||
| 211 | #define for_each_of_allnodes(dn) \ | ||
| 212 | for (dn = of_allnodes; dn; dn = dn->allnext) | ||
| 170 | extern struct device_node *of_find_node_by_name(struct device_node *from, | 213 | extern struct device_node *of_find_node_by_name(struct device_node *from, |
| 171 | const char *name); | 214 | const char *name); |
| 172 | extern struct device_node *of_find_node_by_type(struct device_node *from, | 215 | extern struct device_node *of_find_node_by_type(struct device_node *from, |
| @@ -709,14 +752,4 @@ static inline int of_get_available_child_count(const struct device_node *np) | |||
| 709 | return num; | 752 | return num; |
| 710 | } | 753 | } |
| 711 | 754 | ||
| 712 | #if defined(CONFIG_PROC_FS) && defined(CONFIG_PROC_DEVICETREE) | ||
| 713 | extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *); | ||
| 714 | extern void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop); | ||
| 715 | extern void proc_device_tree_remove_prop(struct proc_dir_entry *pde, | ||
| 716 | struct property *prop); | ||
| 717 | extern void proc_device_tree_update_prop(struct proc_dir_entry *pde, | ||
| 718 | struct property *newprop, | ||
| 719 | struct property *oldprop); | ||
| 720 | #endif | ||
| 721 | |||
| 722 | #endif /* _LINUX_OF_H */ | 755 | #endif /* _LINUX_OF_H */ |
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 2b77058a7335..ddd7219af8ac 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h | |||
| @@ -98,7 +98,10 @@ extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, | |||
| 98 | int depth, void *data); | 98 | int depth, void *data); |
| 99 | extern int early_init_dt_scan_memory(unsigned long node, const char *uname, | 99 | extern int early_init_dt_scan_memory(unsigned long node, const char *uname, |
| 100 | int depth, void *data); | 100 | int depth, void *data); |
| 101 | extern void early_init_fdt_scan_reserved_mem(void); | ||
| 101 | extern void early_init_dt_add_memory_arch(u64 base, u64 size); | 102 | extern void early_init_dt_add_memory_arch(u64 base, u64 size); |
| 103 | extern int early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size, | ||
| 104 | bool no_map); | ||
| 102 | extern void * early_init_dt_alloc_memory_arch(u64 size, u64 align); | 105 | extern void * early_init_dt_alloc_memory_arch(u64 size, u64 align); |
| 103 | extern u64 dt_mem_next_cell(int s, __be32 **cellp); | 106 | extern u64 dt_mem_next_cell(int s, __be32 **cellp); |
| 104 | 107 | ||
| @@ -118,6 +121,7 @@ extern void unflatten_and_copy_device_tree(void); | |||
| 118 | extern void early_init_devtree(void *); | 121 | extern void early_init_devtree(void *); |
| 119 | extern void early_get_first_memblock_info(void *, phys_addr_t *); | 122 | extern void early_get_first_memblock_info(void *, phys_addr_t *); |
| 120 | #else /* CONFIG_OF_FLATTREE */ | 123 | #else /* CONFIG_OF_FLATTREE */ |
| 124 | static inline void early_init_fdt_scan_reserved_mem(void) {} | ||
| 121 | static inline const char *of_flat_dt_get_machine_name(void) { return NULL; } | 125 | static inline const char *of_flat_dt_get_machine_name(void) { return NULL; } |
| 122 | static inline void unflatten_device_tree(void) {} | 126 | static inline void unflatten_device_tree(void) {} |
| 123 | static inline void unflatten_and_copy_device_tree(void) {} | 127 | static inline void unflatten_and_copy_device_tree(void) {} |
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h new file mode 100644 index 000000000000..9b1fbb7f29fc --- /dev/null +++ b/include/linux/of_reserved_mem.h | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | #ifndef __OF_RESERVED_MEM_H | ||
| 2 | #define __OF_RESERVED_MEM_H | ||
| 3 | |||
| 4 | struct device; | ||
| 5 | struct of_phandle_args; | ||
| 6 | struct reserved_mem_ops; | ||
| 7 | |||
| 8 | struct reserved_mem { | ||
| 9 | const char *name; | ||
| 10 | unsigned long fdt_node; | ||
| 11 | const struct reserved_mem_ops *ops; | ||
| 12 | phys_addr_t base; | ||
| 13 | phys_addr_t size; | ||
| 14 | void *priv; | ||
| 15 | }; | ||
| 16 | |||
| 17 | struct reserved_mem_ops { | ||
| 18 | void (*device_init)(struct reserved_mem *rmem, | ||
| 19 | struct device *dev); | ||
| 20 | void (*device_release)(struct reserved_mem *rmem, | ||
| 21 | struct device *dev); | ||
| 22 | }; | ||
| 23 | |||
| 24 | typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem, | ||
| 25 | unsigned long node, const char *uname); | ||
| 26 | |||
| 27 | #ifdef CONFIG_OF_RESERVED_MEM | ||
| 28 | void fdt_init_reserved_mem(void); | ||
| 29 | void fdt_reserved_mem_save_node(unsigned long node, const char *uname, | ||
| 30 | phys_addr_t base, phys_addr_t size); | ||
| 31 | |||
| 32 | #define RESERVEDMEM_OF_DECLARE(name, compat, init) \ | ||
| 33 | static const struct of_device_id __reservedmem_of_table_##name \ | ||
| 34 | __used __section(__reservedmem_of_table) \ | ||
| 35 | = { .compatible = compat, \ | ||
| 36 | .data = (init == (reservedmem_of_init_fn)NULL) ? \ | ||
| 37 | init : init } | ||
| 38 | |||
| 39 | #else | ||
| 40 | static inline void fdt_init_reserved_mem(void) { } | ||
| 41 | static inline void fdt_reserved_mem_save_node(unsigned long node, | ||
| 42 | const char *uname, phys_addr_t base, phys_addr_t size) { } | ||
| 43 | |||
| 44 | #define RESERVEDMEM_OF_DECLARE(name, compat, init) \ | ||
| 45 | static const struct of_device_id __reservedmem_of_table_##name \ | ||
| 46 | __attribute__((unused)) \ | ||
| 47 | = { .compatible = compat, \ | ||
| 48 | .data = (init == (reservedmem_of_init_fn)NULL) ? \ | ||
| 49 | init : init } | ||
| 50 | |||
| 51 | #endif | ||
| 52 | |||
| 53 | #endif /* __OF_RESERVED_MEM_H */ | ||
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 79c059e70860..72105d104357 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
| @@ -274,6 +274,18 @@ $(obj)/%.dtb: $(src)/%.dts FORCE | |||
| 274 | 274 | ||
| 275 | dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) | 275 | dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) |
| 276 | 276 | ||
| 277 | # Helper targets for Installing DTBs into the boot directory | ||
| 278 | quiet_cmd_dtb_install = INSTALL $< | ||
| 279 | cmd_dtb_install = cp $< $(2) | ||
| 280 | |||
| 281 | _dtbinst_pre_: | ||
| 282 | $(Q)if [ -d $(INSTALL_DTBS_PATH).old ]; then rm -rf $(INSTALL_DTBS_PATH).old; fi | ||
| 283 | $(Q)if [ -d $(INSTALL_DTBS_PATH) ]; then mv $(INSTALL_DTBS_PATH) $(INSTALL_DTBS_PATH).old; fi | ||
| 284 | $(Q)mkdir -p $(INSTALL_DTBS_PATH) | ||
| 285 | |||
| 286 | %.dtb_dtbinst_: $(obj)/%.dtb _dtbinst_pre_ | ||
| 287 | $(call cmd,dtb_install,$(INSTALL_DTBS_PATH)) | ||
| 288 | |||
| 277 | # Bzip2 | 289 | # Bzip2 |
| 278 | # --------------------------------------------------------------------------- | 290 | # --------------------------------------------------------------------------- |
| 279 | 291 | ||
diff --git a/scripts/dtc/dtc-parser.tab.c_shipped b/scripts/dtc/dtc-parser.tab.c_shipped index ee1d8c3042fb..c8769d550cfb 100644 --- a/scripts/dtc/dtc-parser.tab.c_shipped +++ b/scripts/dtc/dtc-parser.tab.c_shipped | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | /* A Bison parser, made by GNU Bison 2.5. */ | 1 | /* A Bison parser, made by GNU Bison 2.7.12-4996. */ |
| 2 | 2 | ||
| 3 | /* Bison implementation for Yacc-like parsers in C | 3 | /* Bison implementation for Yacc-like parsers in C |
| 4 | 4 | ||
| 5 | Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. | 5 | Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. |
| 6 | 6 | ||
| 7 | This program is free software: you can redistribute it and/or modify | 7 | This program is free software: you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
| @@ -44,7 +44,7 @@ | |||
| 44 | #define YYBISON 1 | 44 | #define YYBISON 1 |
| 45 | 45 | ||
| 46 | /* Bison version. */ | 46 | /* Bison version. */ |
| 47 | #define YYBISON_VERSION "2.5" | 47 | #define YYBISON_VERSION "2.7.12-4996" |
| 48 | 48 | ||
| 49 | /* Skeleton name. */ | 49 | /* Skeleton name. */ |
| 50 | #define YYSKELETON_NAME "yacc.c" | 50 | #define YYSKELETON_NAME "yacc.c" |
| @@ -58,14 +58,11 @@ | |||
| 58 | /* Pull parsers. */ | 58 | /* Pull parsers. */ |
| 59 | #define YYPULL 1 | 59 | #define YYPULL 1 |
| 60 | 60 | ||
| 61 | /* Using locations. */ | ||
| 62 | #define YYLSP_NEEDED 0 | ||
| 63 | 61 | ||
| 64 | 62 | ||
| 65 | 63 | ||
| 66 | /* Copy the first part of user declarations. */ | 64 | /* Copy the first part of user declarations. */ |
| 67 | 65 | /* Line 371 of yacc.c */ | |
| 68 | /* Line 268 of yacc.c */ | ||
| 69 | #line 21 "dtc-parser.y" | 66 | #line 21 "dtc-parser.y" |
| 70 | 67 | ||
| 71 | #include <stdio.h> | 68 | #include <stdio.h> |
| @@ -85,14 +82,16 @@ extern int treesource_error; | |||
| 85 | static unsigned long long eval_literal(const char *s, int base, int bits); | 82 | static unsigned long long eval_literal(const char *s, int base, int bits); |
| 86 | static unsigned char eval_char_literal(const char *s); | 83 | static unsigned char eval_char_literal(const char *s); |
| 87 | 84 | ||
| 85 | /* Line 371 of yacc.c */ | ||
| 86 | #line 87 "dtc-parser.tab.c" | ||
| 88 | 87 | ||
| 89 | /* Line 268 of yacc.c */ | 88 | # ifndef YY_NULL |
| 90 | #line 91 "dtc-parser.tab.c" | 89 | # if defined __cplusplus && 201103L <= __cplusplus |
| 91 | 90 | # define YY_NULL nullptr | |
| 92 | /* Enabling traces. */ | 91 | # else |
| 93 | #ifndef YYDEBUG | 92 | # define YY_NULL 0 |
| 94 | # define YYDEBUG 0 | 93 | # endif |
| 95 | #endif | 94 | # endif |
| 96 | 95 | ||
| 97 | /* Enabling verbose error messages. */ | 96 | /* Enabling verbose error messages. */ |
| 98 | #ifdef YYERROR_VERBOSE | 97 | #ifdef YYERROR_VERBOSE |
| @@ -102,11 +101,17 @@ static unsigned char eval_char_literal(const char *s); | |||
| 102 | # define YYERROR_VERBOSE 0 | 101 | # define YYERROR_VERBOSE 0 |
| 103 | #endif | 102 | #endif |
| 104 | 103 | ||
| 105 | /* Enabling the token table. */ | 104 | /* In a future release of Bison, this section will be replaced |
| 106 | #ifndef YYTOKEN_TABLE | 105 | by #include "dtc-parser.tab.h". */ |
| 107 | # define YYTOKEN_TABLE 0 | 106 | #ifndef YY_YY_DTC_PARSER_TAB_H_INCLUDED |
| 107 | # define YY_YY_DTC_PARSER_TAB_H_INCLUDED | ||
| 108 | /* Enabling traces. */ | ||
| 109 | #ifndef YYDEBUG | ||
| 110 | # define YYDEBUG 0 | ||
| 111 | #endif | ||
| 112 | #if YYDEBUG | ||
| 113 | extern int yydebug; | ||
| 108 | #endif | 114 | #endif |
| 109 | |||
| 110 | 115 | ||
| 111 | /* Tokens. */ | 116 | /* Tokens. */ |
| 112 | #ifndef YYTOKENTYPE | 117 | #ifndef YYTOKENTYPE |
| @@ -140,12 +145,10 @@ static unsigned char eval_char_literal(const char *s); | |||
| 140 | #endif | 145 | #endif |
| 141 | 146 | ||
| 142 | 147 | ||
| 143 | |||
| 144 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED | 148 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
| 145 | typedef union YYSTYPE | 149 | typedef union YYSTYPE |
| 146 | { | 150 | { |
| 147 | 151 | /* Line 387 of yacc.c */ | |
| 148 | /* Line 293 of yacc.c */ | ||
| 149 | #line 40 "dtc-parser.y" | 152 | #line 40 "dtc-parser.y" |
| 150 | 153 | ||
| 151 | char *propnodename; | 154 | char *propnodename; |
| @@ -168,21 +171,36 @@ typedef union YYSTYPE | |||
| 168 | uint64_t integer; | 171 | uint64_t integer; |
| 169 | 172 | ||
| 170 | 173 | ||
| 171 | 174 | /* Line 387 of yacc.c */ | |
| 172 | /* Line 293 of yacc.c */ | 175 | #line 176 "dtc-parser.tab.c" |
| 173 | #line 174 "dtc-parser.tab.c" | ||
| 174 | } YYSTYPE; | 176 | } YYSTYPE; |
| 175 | # define YYSTYPE_IS_TRIVIAL 1 | 177 | # define YYSTYPE_IS_TRIVIAL 1 |
| 176 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ | 178 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 177 | # define YYSTYPE_IS_DECLARED 1 | 179 | # define YYSTYPE_IS_DECLARED 1 |
| 178 | #endif | 180 | #endif |
| 179 | 181 | ||
| 182 | extern YYSTYPE yylval; | ||
| 180 | 183 | ||
| 181 | /* Copy the second part of user declarations. */ | 184 | #ifdef YYPARSE_PARAM |
| 185 | #if defined __STDC__ || defined __cplusplus | ||
| 186 | int yyparse (void *YYPARSE_PARAM); | ||
| 187 | #else | ||
| 188 | int yyparse (); | ||
| 189 | #endif | ||
| 190 | #else /* ! YYPARSE_PARAM */ | ||
| 191 | #if defined __STDC__ || defined __cplusplus | ||
| 192 | int yyparse (void); | ||
| 193 | #else | ||
| 194 | int yyparse (); | ||
| 195 | #endif | ||
| 196 | #endif /* ! YYPARSE_PARAM */ | ||
| 182 | 197 | ||
| 198 | #endif /* !YY_YY_DTC_PARSER_TAB_H_INCLUDED */ | ||
| 183 | 199 | ||
| 184 | /* Line 343 of yacc.c */ | 200 | /* Copy the second part of user declarations. */ |
| 185 | #line 186 "dtc-parser.tab.c" | 201 | |
| 202 | /* Line 390 of yacc.c */ | ||
| 203 | #line 204 "dtc-parser.tab.c" | ||
| 186 | 204 | ||
| 187 | #ifdef short | 205 | #ifdef short |
| 188 | # undef short | 206 | # undef short |
| @@ -235,24 +253,33 @@ typedef short int yytype_int16; | |||
| 235 | # if defined YYENABLE_NLS && YYENABLE_NLS | 253 | # if defined YYENABLE_NLS && YYENABLE_NLS |
| 236 | # if ENABLE_NLS | 254 | # if ENABLE_NLS |
| 237 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ | 255 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 238 | # define YY_(msgid) dgettext ("bison-runtime", msgid) | 256 | # define YY_(Msgid) dgettext ("bison-runtime", Msgid) |
| 239 | # endif | 257 | # endif |
| 240 | # endif | 258 | # endif |
| 241 | # ifndef YY_ | 259 | # ifndef YY_ |
| 242 | # define YY_(msgid) msgid | 260 | # define YY_(Msgid) Msgid |
| 261 | # endif | ||
| 262 | #endif | ||
| 263 | |||
| 264 | #ifndef __attribute__ | ||
| 265 | /* This feature is available in gcc versions 2.5 and later. */ | ||
| 266 | # if (! defined __GNUC__ || __GNUC__ < 2 \ | ||
| 267 | || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) | ||
| 268 | # define __attribute__(Spec) /* empty */ | ||
| 243 | # endif | 269 | # endif |
| 244 | #endif | 270 | #endif |
| 245 | 271 | ||
| 246 | /* Suppress unused-variable warnings by "using" E. */ | 272 | /* Suppress unused-variable warnings by "using" E. */ |
| 247 | #if ! defined lint || defined __GNUC__ | 273 | #if ! defined lint || defined __GNUC__ |
| 248 | # define YYUSE(e) ((void) (e)) | 274 | # define YYUSE(E) ((void) (E)) |
| 249 | #else | 275 | #else |
| 250 | # define YYUSE(e) /* empty */ | 276 | # define YYUSE(E) /* empty */ |
| 251 | #endif | 277 | #endif |
| 252 | 278 | ||
| 279 | |||
| 253 | /* Identity function, used to suppress warnings about constant conditions. */ | 280 | /* Identity function, used to suppress warnings about constant conditions. */ |
| 254 | #ifndef lint | 281 | #ifndef lint |
| 255 | # define YYID(n) (n) | 282 | # define YYID(N) (N) |
| 256 | #else | 283 | #else |
| 257 | #if (defined __STDC__ || defined __C99__FUNC__ \ | 284 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 258 | || defined __cplusplus || defined _MSC_VER) | 285 | || defined __cplusplus || defined _MSC_VER) |
| @@ -288,6 +315,7 @@ YYID (yyi) | |||
| 288 | # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ | 315 | # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ |
| 289 | || defined __cplusplus || defined _MSC_VER) | 316 | || defined __cplusplus || defined _MSC_VER) |
| 290 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | 317 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 318 | /* Use EXIT_SUCCESS as a witness for stdlib.h. */ | ||
| 291 | # ifndef EXIT_SUCCESS | 319 | # ifndef EXIT_SUCCESS |
| 292 | # define EXIT_SUCCESS 0 | 320 | # define EXIT_SUCCESS 0 |
| 293 | # endif | 321 | # endif |
| @@ -379,20 +407,20 @@ union yyalloc | |||
| 379 | #endif | 407 | #endif |
| 380 | 408 | ||
| 381 | #if defined YYCOPY_NEEDED && YYCOPY_NEEDED | 409 | #if defined YYCOPY_NEEDED && YYCOPY_NEEDED |
| 382 | /* Copy COUNT objects from FROM to TO. The source and destination do | 410 | /* Copy COUNT objects from SRC to DST. The source and destination do |
| 383 | not overlap. */ | 411 | not overlap. */ |
| 384 | # ifndef YYCOPY | 412 | # ifndef YYCOPY |
| 385 | # if defined __GNUC__ && 1 < __GNUC__ | 413 | # if defined __GNUC__ && 1 < __GNUC__ |
| 386 | # define YYCOPY(To, From, Count) \ | 414 | # define YYCOPY(Dst, Src, Count) \ |
| 387 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) | 415 | __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) |
| 388 | # else | 416 | # else |
| 389 | # define YYCOPY(To, From, Count) \ | 417 | # define YYCOPY(Dst, Src, Count) \ |
| 390 | do \ | 418 | do \ |
| 391 | { \ | 419 | { \ |
| 392 | YYSIZE_T yyi; \ | 420 | YYSIZE_T yyi; \ |
| 393 | for (yyi = 0; yyi < (Count); yyi++) \ | 421 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 394 | (To)[yyi] = (From)[yyi]; \ | 422 | (Dst)[yyi] = (Src)[yyi]; \ |
| 395 | } \ | 423 | } \ |
| 396 | while (YYID (0)) | 424 | while (YYID (0)) |
| 397 | # endif | 425 | # endif |
| 398 | # endif | 426 | # endif |
| @@ -513,7 +541,7 @@ static const yytype_uint16 yyrline[] = | |||
| 513 | }; | 541 | }; |
| 514 | #endif | 542 | #endif |
| 515 | 543 | ||
| 516 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE | 544 | #if YYDEBUG || YYERROR_VERBOSE || 0 |
| 517 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. | 545 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 518 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | 546 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 519 | static const char *const yytname[] = | 547 | static const char *const yytname[] = |
| @@ -530,7 +558,7 @@ static const char *const yytname[] = | |||
| 530 | "integer_expr", "integer_trinary", "integer_or", "integer_and", | 558 | "integer_expr", "integer_trinary", "integer_or", "integer_and", |
| 531 | "integer_bitor", "integer_bitxor", "integer_bitand", "integer_eq", | 559 | "integer_bitor", "integer_bitxor", "integer_bitand", "integer_eq", |
| 532 | "integer_rela", "integer_shift", "integer_add", "integer_mul", | 560 | "integer_rela", "integer_shift", "integer_add", "integer_mul", |
| 533 | "integer_unary", "bytestring", "subnodes", "subnode", 0 | 561 | "integer_unary", "bytestring", "subnodes", "subnode", YY_NULL |
| 534 | }; | 562 | }; |
| 535 | #endif | 563 | #endif |
| 536 | 564 | ||
| @@ -655,10 +683,10 @@ static const yytype_uint8 yytable[] = | |||
| 655 | 137, 0, 73, 139 | 683 | 137, 0, 73, 139 |
| 656 | }; | 684 | }; |
| 657 | 685 | ||
| 658 | #define yypact_value_is_default(yystate) \ | 686 | #define yypact_value_is_default(Yystate) \ |
| 659 | ((yystate) == (-78)) | 687 | (!!((Yystate) == (-78))) |
| 660 | 688 | ||
| 661 | #define yytable_value_is_error(yytable_value) \ | 689 | #define yytable_value_is_error(Yytable_value) \ |
| 662 | YYID (0) | 690 | YYID (0) |
| 663 | 691 | ||
| 664 | static const yytype_int16 yycheck[] = | 692 | static const yytype_int16 yycheck[] = |
| @@ -727,62 +755,35 @@ static const yytype_uint8 yystos[] = | |||
| 727 | 755 | ||
| 728 | #define YYRECOVERING() (!!yyerrstatus) | 756 | #define YYRECOVERING() (!!yyerrstatus) |
| 729 | 757 | ||
| 730 | #define YYBACKUP(Token, Value) \ | 758 | #define YYBACKUP(Token, Value) \ |
| 731 | do \ | 759 | do \ |
| 732 | if (yychar == YYEMPTY && yylen == 1) \ | 760 | if (yychar == YYEMPTY) \ |
| 733 | { \ | 761 | { \ |
| 734 | yychar = (Token); \ | 762 | yychar = (Token); \ |
| 735 | yylval = (Value); \ | 763 | yylval = (Value); \ |
| 736 | YYPOPSTACK (1); \ | 764 | YYPOPSTACK (yylen); \ |
| 737 | goto yybackup; \ | 765 | yystate = *yyssp; \ |
| 738 | } \ | 766 | goto yybackup; \ |
| 739 | else \ | 767 | } \ |
| 740 | { \ | 768 | else \ |
| 769 | { \ | ||
| 741 | yyerror (YY_("syntax error: cannot back up")); \ | 770 | yyerror (YY_("syntax error: cannot back up")); \ |
| 742 | YYERROR; \ | 771 | YYERROR; \ |
| 743 | } \ | 772 | } \ |
| 744 | while (YYID (0)) | 773 | while (YYID (0)) |
| 745 | 774 | ||
| 746 | 775 | /* Error token number */ | |
| 747 | #define YYTERROR 1 | 776 | #define YYTERROR 1 |
| 748 | #define YYERRCODE 256 | 777 | #define YYERRCODE 256 |
| 749 | 778 | ||
| 750 | 779 | ||
| 751 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. | ||
| 752 | If N is 0, then set CURRENT to the empty location which ends | ||
| 753 | the previous symbol: RHS[0] (always defined). */ | ||
| 754 | |||
| 755 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) | ||
| 756 | #ifndef YYLLOC_DEFAULT | ||
| 757 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ | ||
| 758 | do \ | ||
| 759 | if (YYID (N)) \ | ||
| 760 | { \ | ||
| 761 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ | ||
| 762 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ | ||
| 763 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ | ||
| 764 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ | ||
| 765 | } \ | ||
| 766 | else \ | ||
| 767 | { \ | ||
| 768 | (Current).first_line = (Current).last_line = \ | ||
| 769 | YYRHSLOC (Rhs, 0).last_line; \ | ||
| 770 | (Current).first_column = (Current).last_column = \ | ||
| 771 | YYRHSLOC (Rhs, 0).last_column; \ | ||
| 772 | } \ | ||
| 773 | while (YYID (0)) | ||
| 774 | #endif | ||
| 775 | |||
| 776 | |||
| 777 | /* This macro is provided for backward compatibility. */ | 780 | /* This macro is provided for backward compatibility. */ |
| 778 | |||
| 779 | #ifndef YY_LOCATION_PRINT | 781 | #ifndef YY_LOCATION_PRINT |
| 780 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) | 782 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 781 | #endif | 783 | #endif |
| 782 | 784 | ||
| 783 | 785 | ||
| 784 | /* YYLEX -- calling `yylex' with the right arguments. */ | 786 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 785 | |||
| 786 | #ifdef YYLEX_PARAM | 787 | #ifdef YYLEX_PARAM |
| 787 | # define YYLEX yylex (YYLEX_PARAM) | 788 | # define YYLEX yylex (YYLEX_PARAM) |
| 788 | #else | 789 | #else |
| @@ -832,6 +833,8 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep) | |||
| 832 | YYSTYPE const * const yyvaluep; | 833 | YYSTYPE const * const yyvaluep; |
| 833 | #endif | 834 | #endif |
| 834 | { | 835 | { |
| 836 | FILE *yyo = yyoutput; | ||
| 837 | YYUSE (yyo); | ||
| 835 | if (!yyvaluep) | 838 | if (!yyvaluep) |
| 836 | return; | 839 | return; |
| 837 | # ifdef YYPRINT | 840 | # ifdef YYPRINT |
| @@ -840,11 +843,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep) | |||
| 840 | # else | 843 | # else |
| 841 | YYUSE (yyoutput); | 844 | YYUSE (yyoutput); |
| 842 | # endif | 845 | # endif |
| 843 | switch (yytype) | 846 | YYUSE (yytype); |
| 844 | { | ||
| 845 | default: | ||
| 846 | break; | ||
| 847 | } | ||
| 848 | } | 847 | } |
| 849 | 848 | ||
| 850 | 849 | ||
| @@ -1083,12 +1082,11 @@ static int | |||
| 1083 | yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, | 1082 | yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, |
| 1084 | yytype_int16 *yyssp, int yytoken) | 1083 | yytype_int16 *yyssp, int yytoken) |
| 1085 | { | 1084 | { |
| 1086 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); | 1085 | YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); |
| 1087 | YYSIZE_T yysize = yysize0; | 1086 | YYSIZE_T yysize = yysize0; |
| 1088 | YYSIZE_T yysize1; | ||
| 1089 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; | 1087 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; |
| 1090 | /* Internationalized format string. */ | 1088 | /* Internationalized format string. */ |
| 1091 | const char *yyformat = 0; | 1089 | const char *yyformat = YY_NULL; |
| 1092 | /* Arguments of yyformat. */ | 1090 | /* Arguments of yyformat. */ |
| 1093 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; | 1091 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 1094 | /* Number of reported tokens (one for the "unexpected", one per | 1092 | /* Number of reported tokens (one for the "unexpected", one per |
| @@ -1148,11 +1146,13 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, | |||
| 1148 | break; | 1146 | break; |
| 1149 | } | 1147 | } |
| 1150 | yyarg[yycount++] = yytname[yyx]; | 1148 | yyarg[yycount++] = yytname[yyx]; |
| 1151 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); | 1149 | { |
| 1152 | if (! (yysize <= yysize1 | 1150 | YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); |
| 1153 | && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) | 1151 | if (! (yysize <= yysize1 |
| 1154 | return 2; | 1152 | && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) |
| 1155 | yysize = yysize1; | 1153 | return 2; |
| 1154 | yysize = yysize1; | ||
| 1155 | } | ||
| 1156 | } | 1156 | } |
| 1157 | } | 1157 | } |
| 1158 | } | 1158 | } |
| @@ -1172,10 +1172,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, | |||
| 1172 | # undef YYCASE_ | 1172 | # undef YYCASE_ |
| 1173 | } | 1173 | } |
| 1174 | 1174 | ||
| 1175 | yysize1 = yysize + yystrlen (yyformat); | 1175 | { |
| 1176 | if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) | 1176 | YYSIZE_T yysize1 = yysize + yystrlen (yyformat); |
| 1177 | return 2; | 1177 | if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) |
| 1178 | yysize = yysize1; | 1178 | return 2; |
| 1179 | yysize = yysize1; | ||
| 1180 | } | ||
| 1179 | 1181 | ||
| 1180 | if (*yymsg_alloc < yysize) | 1182 | if (*yymsg_alloc < yysize) |
| 1181 | { | 1183 | { |
| @@ -1231,36 +1233,26 @@ yydestruct (yymsg, yytype, yyvaluep) | |||
| 1231 | yymsg = "Deleting"; | 1233 | yymsg = "Deleting"; |
| 1232 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); | 1234 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 1233 | 1235 | ||
| 1234 | switch (yytype) | 1236 | YYUSE (yytype); |
| 1235 | { | ||
| 1236 | |||
| 1237 | default: | ||
| 1238 | break; | ||
| 1239 | } | ||
| 1240 | } | 1237 | } |
| 1241 | 1238 | ||
| 1242 | 1239 | ||
| 1243 | /* Prevent warnings from -Wmissing-prototypes. */ | ||
| 1244 | #ifdef YYPARSE_PARAM | ||
| 1245 | #if defined __STDC__ || defined __cplusplus | ||
| 1246 | int yyparse (void *YYPARSE_PARAM); | ||
| 1247 | #else | ||
| 1248 | int yyparse (); | ||
| 1249 | #endif | ||
| 1250 | #else /* ! YYPARSE_PARAM */ | ||
| 1251 | #if defined __STDC__ || defined __cplusplus | ||
| 1252 | int yyparse (void); | ||
| 1253 | #else | ||
| 1254 | int yyparse (); | ||
| 1255 | #endif | ||
| 1256 | #endif /* ! YYPARSE_PARAM */ | ||
| 1257 | 1240 | ||
| 1258 | 1241 | ||
| 1259 | /* The lookahead symbol. */ | 1242 | /* The lookahead symbol. */ |
| 1260 | int yychar; | 1243 | int yychar; |
| 1261 | 1244 | ||
| 1245 | |||
| 1246 | #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 1247 | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 1248 | # define YY_IGNORE_MAYBE_UNINITIALIZED_END | ||
| 1249 | #endif | ||
| 1250 | #ifndef YY_INITIAL_VALUE | ||
| 1251 | # define YY_INITIAL_VALUE(Value) /* Nothing. */ | ||
| 1252 | #endif | ||
| 1253 | |||
| 1262 | /* The semantic value of the lookahead symbol. */ | 1254 | /* The semantic value of the lookahead symbol. */ |
| 1263 | YYSTYPE yylval; | 1255 | YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); |
| 1264 | 1256 | ||
| 1265 | /* Number of syntax errors so far. */ | 1257 | /* Number of syntax errors so far. */ |
| 1266 | int yynerrs; | 1258 | int yynerrs; |
| @@ -1300,7 +1292,7 @@ yyparse () | |||
| 1300 | `yyss': related to states. | 1292 | `yyss': related to states. |
| 1301 | `yyvs': related to semantic values. | 1293 | `yyvs': related to semantic values. |
| 1302 | 1294 | ||
| 1303 | Refer to the stacks thru separate pointers, to allow yyoverflow | 1295 | Refer to the stacks through separate pointers, to allow yyoverflow |
| 1304 | to reallocate them elsewhere. */ | 1296 | to reallocate them elsewhere. */ |
| 1305 | 1297 | ||
| 1306 | /* The state stack. */ | 1298 | /* The state stack. */ |
| @@ -1318,7 +1310,7 @@ yyparse () | |||
| 1318 | int yyn; | 1310 | int yyn; |
| 1319 | int yyresult; | 1311 | int yyresult; |
| 1320 | /* Lookahead token as an internal (translated) token number. */ | 1312 | /* Lookahead token as an internal (translated) token number. */ |
| 1321 | int yytoken; | 1313 | int yytoken = 0; |
| 1322 | /* The variables used to return semantic value and location from the | 1314 | /* The variables used to return semantic value and location from the |
| 1323 | action routines. */ | 1315 | action routines. */ |
| 1324 | YYSTYPE yyval; | 1316 | YYSTYPE yyval; |
| @@ -1336,9 +1328,8 @@ yyparse () | |||
| 1336 | Keep to zero when no symbol should be popped. */ | 1328 | Keep to zero when no symbol should be popped. */ |
| 1337 | int yylen = 0; | 1329 | int yylen = 0; |
| 1338 | 1330 | ||
| 1339 | yytoken = 0; | 1331 | yyssp = yyss = yyssa; |
| 1340 | yyss = yyssa; | 1332 | yyvsp = yyvs = yyvsa; |
| 1341 | yyvs = yyvsa; | ||
| 1342 | yystacksize = YYINITDEPTH; | 1333 | yystacksize = YYINITDEPTH; |
| 1343 | 1334 | ||
| 1344 | YYDPRINTF ((stderr, "Starting parse\n")); | 1335 | YYDPRINTF ((stderr, "Starting parse\n")); |
| @@ -1347,14 +1338,6 @@ yyparse () | |||
| 1347 | yyerrstatus = 0; | 1338 | yyerrstatus = 0; |
| 1348 | yynerrs = 0; | 1339 | yynerrs = 0; |
| 1349 | yychar = YYEMPTY; /* Cause a token to be read. */ | 1340 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 1350 | |||
| 1351 | /* Initialize stack pointers. | ||
| 1352 | Waste one element of value and location stack | ||
| 1353 | so that they stay on the same level as the state stack. | ||
| 1354 | The wasted elements are never initialized. */ | ||
| 1355 | yyssp = yyss; | ||
| 1356 | yyvsp = yyvs; | ||
| 1357 | |||
| 1358 | goto yysetstate; | 1341 | goto yysetstate; |
| 1359 | 1342 | ||
| 1360 | /*------------------------------------------------------------. | 1343 | /*------------------------------------------------------------. |
| @@ -1495,7 +1478,9 @@ yybackup: | |||
| 1495 | yychar = YYEMPTY; | 1478 | yychar = YYEMPTY; |
| 1496 | 1479 | ||
| 1497 | yystate = yyn; | 1480 | yystate = yyn; |
| 1481 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 1498 | *++yyvsp = yylval; | 1482 | *++yyvsp = yylval; |
| 1483 | YY_IGNORE_MAYBE_UNINITIALIZED_END | ||
| 1499 | 1484 | ||
| 1500 | goto yynewstate; | 1485 | goto yynewstate; |
| 1501 | 1486 | ||
| @@ -1532,8 +1517,7 @@ yyreduce: | |||
| 1532 | switch (yyn) | 1517 | switch (yyn) |
| 1533 | { | 1518 | { |
| 1534 | case 2: | 1519 | case 2: |
| 1535 | 1520 | /* Line 1787 of yacc.c */ | |
| 1536 | /* Line 1806 of yacc.c */ | ||
| 1537 | #line 110 "dtc-parser.y" | 1521 | #line 110 "dtc-parser.y" |
| 1538 | { | 1522 | { |
| 1539 | the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), | 1523 | the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), |
| @@ -1542,8 +1526,7 @@ yyreduce: | |||
| 1542 | break; | 1526 | break; |
| 1543 | 1527 | ||
| 1544 | case 3: | 1528 | case 3: |
| 1545 | 1529 | /* Line 1787 of yacc.c */ | |
| 1546 | /* Line 1806 of yacc.c */ | ||
| 1547 | #line 118 "dtc-parser.y" | 1530 | #line 118 "dtc-parser.y" |
| 1548 | { | 1531 | { |
| 1549 | (yyval.re) = NULL; | 1532 | (yyval.re) = NULL; |
| @@ -1551,8 +1534,7 @@ yyreduce: | |||
| 1551 | break; | 1534 | break; |
| 1552 | 1535 | ||
| 1553 | case 4: | 1536 | case 4: |
| 1554 | 1537 | /* Line 1787 of yacc.c */ | |
| 1555 | /* Line 1806 of yacc.c */ | ||
| 1556 | #line 122 "dtc-parser.y" | 1538 | #line 122 "dtc-parser.y" |
| 1557 | { | 1539 | { |
| 1558 | (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); | 1540 | (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); |
| @@ -1560,8 +1542,7 @@ yyreduce: | |||
| 1560 | break; | 1542 | break; |
| 1561 | 1543 | ||
| 1562 | case 5: | 1544 | case 5: |
| 1563 | 1545 | /* Line 1787 of yacc.c */ | |
| 1564 | /* Line 1806 of yacc.c */ | ||
| 1565 | #line 129 "dtc-parser.y" | 1546 | #line 129 "dtc-parser.y" |
| 1566 | { | 1547 | { |
| 1567 | (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].integer), (yyvsp[(3) - (4)].integer)); | 1548 | (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].integer), (yyvsp[(3) - (4)].integer)); |
| @@ -1569,8 +1550,7 @@ yyreduce: | |||
| 1569 | break; | 1550 | break; |
| 1570 | 1551 | ||
| 1571 | case 6: | 1552 | case 6: |
| 1572 | 1553 | /* Line 1787 of yacc.c */ | |
| 1573 | /* Line 1806 of yacc.c */ | ||
| 1574 | #line 133 "dtc-parser.y" | 1554 | #line 133 "dtc-parser.y" |
| 1575 | { | 1555 | { |
| 1576 | add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref)); | 1556 | add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref)); |
| @@ -1579,8 +1559,7 @@ yyreduce: | |||
| 1579 | break; | 1559 | break; |
| 1580 | 1560 | ||
| 1581 | case 7: | 1561 | case 7: |
| 1582 | 1562 | /* Line 1787 of yacc.c */ | |
| 1583 | /* Line 1806 of yacc.c */ | ||
| 1584 | #line 141 "dtc-parser.y" | 1563 | #line 141 "dtc-parser.y" |
| 1585 | { | 1564 | { |
| 1586 | (yyval.node) = name_node((yyvsp[(2) - (2)].node), ""); | 1565 | (yyval.node) = name_node((yyvsp[(2) - (2)].node), ""); |
| @@ -1588,8 +1567,7 @@ yyreduce: | |||
| 1588 | break; | 1567 | break; |
| 1589 | 1568 | ||
| 1590 | case 8: | 1569 | case 8: |
| 1591 | 1570 | /* Line 1787 of yacc.c */ | |
| 1592 | /* Line 1806 of yacc.c */ | ||
| 1593 | #line 145 "dtc-parser.y" | 1571 | #line 145 "dtc-parser.y" |
| 1594 | { | 1572 | { |
| 1595 | (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); | 1573 | (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); |
| @@ -1597,8 +1575,7 @@ yyreduce: | |||
| 1597 | break; | 1575 | break; |
| 1598 | 1576 | ||
| 1599 | case 9: | 1577 | case 9: |
| 1600 | 1578 | /* Line 1787 of yacc.c */ | |
| 1601 | /* Line 1806 of yacc.c */ | ||
| 1602 | #line 149 "dtc-parser.y" | 1579 | #line 149 "dtc-parser.y" |
| 1603 | { | 1580 | { |
| 1604 | struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref)); | 1581 | struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref)); |
| @@ -1612,8 +1589,7 @@ yyreduce: | |||
| 1612 | break; | 1589 | break; |
| 1613 | 1590 | ||
| 1614 | case 10: | 1591 | case 10: |
| 1615 | 1592 | /* Line 1787 of yacc.c */ | |
| 1616 | /* Line 1806 of yacc.c */ | ||
| 1617 | #line 159 "dtc-parser.y" | 1593 | #line 159 "dtc-parser.y" |
| 1618 | { | 1594 | { |
| 1619 | struct node *target = get_node_by_ref((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].labelref)); | 1595 | struct node *target = get_node_by_ref((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].labelref)); |
| @@ -1628,8 +1604,7 @@ yyreduce: | |||
| 1628 | break; | 1604 | break; |
| 1629 | 1605 | ||
| 1630 | case 11: | 1606 | case 11: |
| 1631 | 1607 | /* Line 1787 of yacc.c */ | |
| 1632 | /* Line 1806 of yacc.c */ | ||
| 1633 | #line 173 "dtc-parser.y" | 1608 | #line 173 "dtc-parser.y" |
| 1634 | { | 1609 | { |
| 1635 | (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); | 1610 | (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); |
| @@ -1637,8 +1612,7 @@ yyreduce: | |||
| 1637 | break; | 1612 | break; |
| 1638 | 1613 | ||
| 1639 | case 12: | 1614 | case 12: |
| 1640 | 1615 | /* Line 1787 of yacc.c */ | |
| 1641 | /* Line 1806 of yacc.c */ | ||
| 1642 | #line 180 "dtc-parser.y" | 1616 | #line 180 "dtc-parser.y" |
| 1643 | { | 1617 | { |
| 1644 | (yyval.proplist) = NULL; | 1618 | (yyval.proplist) = NULL; |
| @@ -1646,8 +1620,7 @@ yyreduce: | |||
| 1646 | break; | 1620 | break; |
| 1647 | 1621 | ||
| 1648 | case 13: | 1622 | case 13: |
| 1649 | 1623 | /* Line 1787 of yacc.c */ | |
| 1650 | /* Line 1806 of yacc.c */ | ||
| 1651 | #line 184 "dtc-parser.y" | 1624 | #line 184 "dtc-parser.y" |
| 1652 | { | 1625 | { |
| 1653 | (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); | 1626 | (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); |
| @@ -1655,8 +1628,7 @@ yyreduce: | |||
| 1655 | break; | 1628 | break; |
| 1656 | 1629 | ||
| 1657 | case 14: | 1630 | case 14: |
| 1658 | 1631 | /* Line 1787 of yacc.c */ | |
| 1659 | /* Line 1806 of yacc.c */ | ||
| 1660 | #line 191 "dtc-parser.y" | 1632 | #line 191 "dtc-parser.y" |
| 1661 | { | 1633 | { |
| 1662 | (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data)); | 1634 | (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data)); |
| @@ -1664,8 +1636,7 @@ yyreduce: | |||
| 1664 | break; | 1636 | break; |
| 1665 | 1637 | ||
| 1666 | case 15: | 1638 | case 15: |
| 1667 | 1639 | /* Line 1787 of yacc.c */ | |
| 1668 | /* Line 1806 of yacc.c */ | ||
| 1669 | #line 195 "dtc-parser.y" | 1640 | #line 195 "dtc-parser.y" |
| 1670 | { | 1641 | { |
| 1671 | (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data); | 1642 | (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data); |
| @@ -1673,8 +1644,7 @@ yyreduce: | |||
| 1673 | break; | 1644 | break; |
| 1674 | 1645 | ||
| 1675 | case 16: | 1646 | case 16: |
| 1676 | 1647 | /* Line 1787 of yacc.c */ | |
| 1677 | /* Line 1806 of yacc.c */ | ||
| 1678 | #line 199 "dtc-parser.y" | 1648 | #line 199 "dtc-parser.y" |
| 1679 | { | 1649 | { |
| 1680 | (yyval.prop) = build_property_delete((yyvsp[(2) - (3)].propnodename)); | 1650 | (yyval.prop) = build_property_delete((yyvsp[(2) - (3)].propnodename)); |
| @@ -1682,8 +1652,7 @@ yyreduce: | |||
| 1682 | break; | 1652 | break; |
| 1683 | 1653 | ||
| 1684 | case 17: | 1654 | case 17: |
| 1685 | 1655 | /* Line 1787 of yacc.c */ | |
| 1686 | /* Line 1806 of yacc.c */ | ||
| 1687 | #line 203 "dtc-parser.y" | 1656 | #line 203 "dtc-parser.y" |
| 1688 | { | 1657 | { |
| 1689 | add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref)); | 1658 | add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref)); |
| @@ -1692,8 +1661,7 @@ yyreduce: | |||
| 1692 | break; | 1661 | break; |
| 1693 | 1662 | ||
| 1694 | case 18: | 1663 | case 18: |
| 1695 | 1664 | /* Line 1787 of yacc.c */ | |
| 1696 | /* Line 1806 of yacc.c */ | ||
| 1697 | #line 211 "dtc-parser.y" | 1665 | #line 211 "dtc-parser.y" |
| 1698 | { | 1666 | { |
| 1699 | (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data)); | 1667 | (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data)); |
| @@ -1701,8 +1669,7 @@ yyreduce: | |||
| 1701 | break; | 1669 | break; |
| 1702 | 1670 | ||
| 1703 | case 19: | 1671 | case 19: |
| 1704 | 1672 | /* Line 1787 of yacc.c */ | |
| 1705 | /* Line 1806 of yacc.c */ | ||
| 1706 | #line 215 "dtc-parser.y" | 1673 | #line 215 "dtc-parser.y" |
| 1707 | { | 1674 | { |
| 1708 | (yyval.data) = data_merge((yyvsp[(1) - (3)].data), (yyvsp[(2) - (3)].array).data); | 1675 | (yyval.data) = data_merge((yyvsp[(1) - (3)].data), (yyvsp[(2) - (3)].array).data); |
| @@ -1710,8 +1677,7 @@ yyreduce: | |||
| 1710 | break; | 1677 | break; |
| 1711 | 1678 | ||
| 1712 | case 20: | 1679 | case 20: |
| 1713 | 1680 | /* Line 1787 of yacc.c */ | |
| 1714 | /* Line 1806 of yacc.c */ | ||
| 1715 | #line 219 "dtc-parser.y" | 1681 | #line 219 "dtc-parser.y" |
| 1716 | { | 1682 | { |
| 1717 | (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); | 1683 | (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); |
| @@ -1719,8 +1685,7 @@ yyreduce: | |||
| 1719 | break; | 1685 | break; |
| 1720 | 1686 | ||
| 1721 | case 21: | 1687 | case 21: |
| 1722 | 1688 | /* Line 1787 of yacc.c */ | |
| 1723 | /* Line 1806 of yacc.c */ | ||
| 1724 | #line 223 "dtc-parser.y" | 1689 | #line 223 "dtc-parser.y" |
| 1725 | { | 1690 | { |
| 1726 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref)); | 1691 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref)); |
| @@ -1728,8 +1693,7 @@ yyreduce: | |||
| 1728 | break; | 1693 | break; |
| 1729 | 1694 | ||
| 1730 | case 22: | 1695 | case 22: |
| 1731 | 1696 | /* Line 1787 of yacc.c */ | |
| 1732 | /* Line 1806 of yacc.c */ | ||
| 1733 | #line 227 "dtc-parser.y" | 1697 | #line 227 "dtc-parser.y" |
| 1734 | { | 1698 | { |
| 1735 | FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL); | 1699 | FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL); |
| @@ -1750,8 +1714,7 @@ yyreduce: | |||
| 1750 | break; | 1714 | break; |
| 1751 | 1715 | ||
| 1752 | case 23: | 1716 | case 23: |
| 1753 | 1717 | /* Line 1787 of yacc.c */ | |
| 1754 | /* Line 1806 of yacc.c */ | ||
| 1755 | #line 244 "dtc-parser.y" | 1718 | #line 244 "dtc-parser.y" |
| 1756 | { | 1719 | { |
| 1757 | FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL); | 1720 | FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL); |
| @@ -1765,8 +1728,7 @@ yyreduce: | |||
| 1765 | break; | 1728 | break; |
| 1766 | 1729 | ||
| 1767 | case 24: | 1730 | case 24: |
| 1768 | 1731 | /* Line 1787 of yacc.c */ | |
| 1769 | /* Line 1806 of yacc.c */ | ||
| 1770 | #line 254 "dtc-parser.y" | 1732 | #line 254 "dtc-parser.y" |
| 1771 | { | 1733 | { |
| 1772 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); | 1734 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); |
| @@ -1774,8 +1736,7 @@ yyreduce: | |||
| 1774 | break; | 1736 | break; |
| 1775 | 1737 | ||
| 1776 | case 25: | 1738 | case 25: |
| 1777 | 1739 | /* Line 1787 of yacc.c */ | |
| 1778 | /* Line 1806 of yacc.c */ | ||
| 1779 | #line 261 "dtc-parser.y" | 1740 | #line 261 "dtc-parser.y" |
| 1780 | { | 1741 | { |
| 1781 | (yyval.data) = empty_data; | 1742 | (yyval.data) = empty_data; |
| @@ -1783,8 +1744,7 @@ yyreduce: | |||
| 1783 | break; | 1744 | break; |
| 1784 | 1745 | ||
| 1785 | case 26: | 1746 | case 26: |
| 1786 | 1747 | /* Line 1787 of yacc.c */ | |
| 1787 | /* Line 1806 of yacc.c */ | ||
| 1788 | #line 265 "dtc-parser.y" | 1748 | #line 265 "dtc-parser.y" |
| 1789 | { | 1749 | { |
| 1790 | (yyval.data) = (yyvsp[(1) - (2)].data); | 1750 | (yyval.data) = (yyvsp[(1) - (2)].data); |
| @@ -1792,8 +1752,7 @@ yyreduce: | |||
| 1792 | break; | 1752 | break; |
| 1793 | 1753 | ||
| 1794 | case 27: | 1754 | case 27: |
| 1795 | 1755 | /* Line 1787 of yacc.c */ | |
| 1796 | /* Line 1806 of yacc.c */ | ||
| 1797 | #line 269 "dtc-parser.y" | 1756 | #line 269 "dtc-parser.y" |
| 1798 | { | 1757 | { |
| 1799 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); | 1758 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); |
| @@ -1801,8 +1760,7 @@ yyreduce: | |||
| 1801 | break; | 1760 | break; |
| 1802 | 1761 | ||
| 1803 | case 28: | 1762 | case 28: |
| 1804 | 1763 | /* Line 1787 of yacc.c */ | |
| 1805 | /* Line 1806 of yacc.c */ | ||
| 1806 | #line 276 "dtc-parser.y" | 1764 | #line 276 "dtc-parser.y" |
| 1807 | { | 1765 | { |
| 1808 | (yyval.array).data = empty_data; | 1766 | (yyval.array).data = empty_data; |
| @@ -1821,8 +1779,7 @@ yyreduce: | |||
| 1821 | break; | 1779 | break; |
| 1822 | 1780 | ||
| 1823 | case 29: | 1781 | case 29: |
| 1824 | 1782 | /* Line 1787 of yacc.c */ | |
| 1825 | /* Line 1806 of yacc.c */ | ||
| 1826 | #line 291 "dtc-parser.y" | 1783 | #line 291 "dtc-parser.y" |
| 1827 | { | 1784 | { |
| 1828 | (yyval.array).data = empty_data; | 1785 | (yyval.array).data = empty_data; |
| @@ -1831,8 +1788,7 @@ yyreduce: | |||
| 1831 | break; | 1788 | break; |
| 1832 | 1789 | ||
| 1833 | case 30: | 1790 | case 30: |
| 1834 | 1791 | /* Line 1787 of yacc.c */ | |
| 1835 | /* Line 1806 of yacc.c */ | ||
| 1836 | #line 296 "dtc-parser.y" | 1792 | #line 296 "dtc-parser.y" |
| 1837 | { | 1793 | { |
| 1838 | if ((yyvsp[(1) - (2)].array).bits < 64) { | 1794 | if ((yyvsp[(1) - (2)].array).bits < 64) { |
| @@ -1856,8 +1812,7 @@ yyreduce: | |||
| 1856 | break; | 1812 | break; |
| 1857 | 1813 | ||
| 1858 | case 31: | 1814 | case 31: |
| 1859 | 1815 | /* Line 1787 of yacc.c */ | |
| 1860 | /* Line 1806 of yacc.c */ | ||
| 1861 | #line 316 "dtc-parser.y" | 1816 | #line 316 "dtc-parser.y" |
| 1862 | { | 1817 | { |
| 1863 | uint64_t val = ~0ULL >> (64 - (yyvsp[(1) - (2)].array).bits); | 1818 | uint64_t val = ~0ULL >> (64 - (yyvsp[(1) - (2)].array).bits); |
| @@ -1875,8 +1830,7 @@ yyreduce: | |||
| 1875 | break; | 1830 | break; |
| 1876 | 1831 | ||
| 1877 | case 32: | 1832 | case 32: |
| 1878 | 1833 | /* Line 1787 of yacc.c */ | |
| 1879 | /* Line 1806 of yacc.c */ | ||
| 1880 | #line 330 "dtc-parser.y" | 1834 | #line 330 "dtc-parser.y" |
| 1881 | { | 1835 | { |
| 1882 | (yyval.array).data = data_add_marker((yyvsp[(1) - (2)].array).data, LABEL, (yyvsp[(2) - (2)].labelref)); | 1836 | (yyval.array).data = data_add_marker((yyvsp[(1) - (2)].array).data, LABEL, (yyvsp[(2) - (2)].labelref)); |
| @@ -1884,8 +1838,7 @@ yyreduce: | |||
| 1884 | break; | 1838 | break; |
| 1885 | 1839 | ||
| 1886 | case 33: | 1840 | case 33: |
| 1887 | 1841 | /* Line 1787 of yacc.c */ | |
| 1888 | /* Line 1806 of yacc.c */ | ||
| 1889 | #line 337 "dtc-parser.y" | 1842 | #line 337 "dtc-parser.y" |
| 1890 | { | 1843 | { |
| 1891 | (yyval.integer) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); | 1844 | (yyval.integer) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); |
| @@ -1893,8 +1846,7 @@ yyreduce: | |||
| 1893 | break; | 1846 | break; |
| 1894 | 1847 | ||
| 1895 | case 34: | 1848 | case 34: |
| 1896 | 1849 | /* Line 1787 of yacc.c */ | |
| 1897 | /* Line 1806 of yacc.c */ | ||
| 1898 | #line 341 "dtc-parser.y" | 1850 | #line 341 "dtc-parser.y" |
| 1899 | { | 1851 | { |
| 1900 | (yyval.integer) = eval_char_literal((yyvsp[(1) - (1)].literal)); | 1852 | (yyval.integer) = eval_char_literal((yyvsp[(1) - (1)].literal)); |
| @@ -1902,8 +1854,7 @@ yyreduce: | |||
| 1902 | break; | 1854 | break; |
| 1903 | 1855 | ||
| 1904 | case 35: | 1856 | case 35: |
| 1905 | 1857 | /* Line 1787 of yacc.c */ | |
| 1906 | /* Line 1806 of yacc.c */ | ||
| 1907 | #line 345 "dtc-parser.y" | 1858 | #line 345 "dtc-parser.y" |
| 1908 | { | 1859 | { |
| 1909 | (yyval.integer) = (yyvsp[(2) - (3)].integer); | 1860 | (yyval.integer) = (yyvsp[(2) - (3)].integer); |
| @@ -1911,162 +1862,139 @@ yyreduce: | |||
| 1911 | break; | 1862 | break; |
| 1912 | 1863 | ||
| 1913 | case 38: | 1864 | case 38: |
| 1914 | 1865 | /* Line 1787 of yacc.c */ | |
| 1915 | /* Line 1806 of yacc.c */ | ||
| 1916 | #line 356 "dtc-parser.y" | 1866 | #line 356 "dtc-parser.y" |
| 1917 | { (yyval.integer) = (yyvsp[(1) - (5)].integer) ? (yyvsp[(3) - (5)].integer) : (yyvsp[(5) - (5)].integer); } | 1867 | { (yyval.integer) = (yyvsp[(1) - (5)].integer) ? (yyvsp[(3) - (5)].integer) : (yyvsp[(5) - (5)].integer); } |
| 1918 | break; | 1868 | break; |
| 1919 | 1869 | ||
| 1920 | case 40: | 1870 | case 40: |
| 1921 | 1871 | /* Line 1787 of yacc.c */ | |
| 1922 | /* Line 1806 of yacc.c */ | ||
| 1923 | #line 361 "dtc-parser.y" | 1872 | #line 361 "dtc-parser.y" |
| 1924 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) || (yyvsp[(3) - (3)].integer); } | 1873 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) || (yyvsp[(3) - (3)].integer); } |
| 1925 | break; | 1874 | break; |
| 1926 | 1875 | ||
| 1927 | case 42: | 1876 | case 42: |
| 1928 | 1877 | /* Line 1787 of yacc.c */ | |
| 1929 | /* Line 1806 of yacc.c */ | ||
| 1930 | #line 366 "dtc-parser.y" | 1878 | #line 366 "dtc-parser.y" |
| 1931 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) && (yyvsp[(3) - (3)].integer); } | 1879 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) && (yyvsp[(3) - (3)].integer); } |
| 1932 | break; | 1880 | break; |
| 1933 | 1881 | ||
| 1934 | case 44: | 1882 | case 44: |
| 1935 | 1883 | /* Line 1787 of yacc.c */ | |
| 1936 | /* Line 1806 of yacc.c */ | ||
| 1937 | #line 371 "dtc-parser.y" | 1884 | #line 371 "dtc-parser.y" |
| 1938 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) | (yyvsp[(3) - (3)].integer); } | 1885 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) | (yyvsp[(3) - (3)].integer); } |
| 1939 | break; | 1886 | break; |
| 1940 | 1887 | ||
| 1941 | case 46: | 1888 | case 46: |
| 1942 | 1889 | /* Line 1787 of yacc.c */ | |
| 1943 | /* Line 1806 of yacc.c */ | ||
| 1944 | #line 376 "dtc-parser.y" | 1890 | #line 376 "dtc-parser.y" |
| 1945 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) ^ (yyvsp[(3) - (3)].integer); } | 1891 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) ^ (yyvsp[(3) - (3)].integer); } |
| 1946 | break; | 1892 | break; |
| 1947 | 1893 | ||
| 1948 | case 48: | 1894 | case 48: |
| 1949 | 1895 | /* Line 1787 of yacc.c */ | |
| 1950 | /* Line 1806 of yacc.c */ | ||
| 1951 | #line 381 "dtc-parser.y" | 1896 | #line 381 "dtc-parser.y" |
| 1952 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) & (yyvsp[(3) - (3)].integer); } | 1897 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) & (yyvsp[(3) - (3)].integer); } |
| 1953 | break; | 1898 | break; |
| 1954 | 1899 | ||
| 1955 | case 50: | 1900 | case 50: |
| 1956 | 1901 | /* Line 1787 of yacc.c */ | |
| 1957 | /* Line 1806 of yacc.c */ | ||
| 1958 | #line 386 "dtc-parser.y" | 1902 | #line 386 "dtc-parser.y" |
| 1959 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) == (yyvsp[(3) - (3)].integer); } | 1903 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) == (yyvsp[(3) - (3)].integer); } |
| 1960 | break; | 1904 | break; |
| 1961 | 1905 | ||
| 1962 | case 51: | 1906 | case 51: |
| 1963 | 1907 | /* Line 1787 of yacc.c */ | |
| 1964 | /* Line 1806 of yacc.c */ | ||
| 1965 | #line 387 "dtc-parser.y" | 1908 | #line 387 "dtc-parser.y" |
| 1966 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) != (yyvsp[(3) - (3)].integer); } | 1909 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) != (yyvsp[(3) - (3)].integer); } |
| 1967 | break; | 1910 | break; |
| 1968 | 1911 | ||
| 1969 | case 53: | 1912 | case 53: |
| 1970 | 1913 | /* Line 1787 of yacc.c */ | |
| 1971 | /* Line 1806 of yacc.c */ | ||
| 1972 | #line 392 "dtc-parser.y" | 1914 | #line 392 "dtc-parser.y" |
| 1973 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) < (yyvsp[(3) - (3)].integer); } | 1915 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) < (yyvsp[(3) - (3)].integer); } |
| 1974 | break; | 1916 | break; |
| 1975 | 1917 | ||
| 1976 | case 54: | 1918 | case 54: |
| 1977 | 1919 | /* Line 1787 of yacc.c */ | |
| 1978 | /* Line 1806 of yacc.c */ | ||
| 1979 | #line 393 "dtc-parser.y" | 1920 | #line 393 "dtc-parser.y" |
| 1980 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer); } | 1921 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer); } |
| 1981 | break; | 1922 | break; |
| 1982 | 1923 | ||
| 1983 | case 55: | 1924 | case 55: |
| 1984 | 1925 | /* Line 1787 of yacc.c */ | |
| 1985 | /* Line 1806 of yacc.c */ | ||
| 1986 | #line 394 "dtc-parser.y" | 1926 | #line 394 "dtc-parser.y" |
| 1987 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) <= (yyvsp[(3) - (3)].integer); } | 1927 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) <= (yyvsp[(3) - (3)].integer); } |
| 1988 | break; | 1928 | break; |
| 1989 | 1929 | ||
| 1990 | case 56: | 1930 | case 56: |
| 1991 | 1931 | /* Line 1787 of yacc.c */ | |
| 1992 | /* Line 1806 of yacc.c */ | ||
| 1993 | #line 395 "dtc-parser.y" | 1932 | #line 395 "dtc-parser.y" |
| 1994 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) >= (yyvsp[(3) - (3)].integer); } | 1933 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) >= (yyvsp[(3) - (3)].integer); } |
| 1995 | break; | 1934 | break; |
| 1996 | 1935 | ||
| 1997 | case 57: | 1936 | case 57: |
| 1998 | 1937 | /* Line 1787 of yacc.c */ | |
| 1999 | /* Line 1806 of yacc.c */ | ||
| 2000 | #line 399 "dtc-parser.y" | 1938 | #line 399 "dtc-parser.y" |
| 2001 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) << (yyvsp[(3) - (3)].integer); } | 1939 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) << (yyvsp[(3) - (3)].integer); } |
| 2002 | break; | 1940 | break; |
| 2003 | 1941 | ||
| 2004 | case 58: | 1942 | case 58: |
| 2005 | 1943 | /* Line 1787 of yacc.c */ | |
| 2006 | /* Line 1806 of yacc.c */ | ||
| 2007 | #line 400 "dtc-parser.y" | 1944 | #line 400 "dtc-parser.y" |
| 2008 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) >> (yyvsp[(3) - (3)].integer); } | 1945 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) >> (yyvsp[(3) - (3)].integer); } |
| 2009 | break; | 1946 | break; |
| 2010 | 1947 | ||
| 2011 | case 60: | 1948 | case 60: |
| 2012 | 1949 | /* Line 1787 of yacc.c */ | |
| 2013 | /* Line 1806 of yacc.c */ | ||
| 2014 | #line 405 "dtc-parser.y" | 1950 | #line 405 "dtc-parser.y" |
| 2015 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) + (yyvsp[(3) - (3)].integer); } | 1951 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) + (yyvsp[(3) - (3)].integer); } |
| 2016 | break; | 1952 | break; |
| 2017 | 1953 | ||
| 2018 | case 61: | 1954 | case 61: |
| 2019 | 1955 | /* Line 1787 of yacc.c */ | |
| 2020 | /* Line 1806 of yacc.c */ | ||
| 2021 | #line 406 "dtc-parser.y" | 1956 | #line 406 "dtc-parser.y" |
| 2022 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) - (yyvsp[(3) - (3)].integer); } | 1957 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) - (yyvsp[(3) - (3)].integer); } |
| 2023 | break; | 1958 | break; |
| 2024 | 1959 | ||
| 2025 | case 63: | 1960 | case 63: |
| 2026 | 1961 | /* Line 1787 of yacc.c */ | |
| 2027 | /* Line 1806 of yacc.c */ | ||
| 2028 | #line 411 "dtc-parser.y" | 1962 | #line 411 "dtc-parser.y" |
| 2029 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) * (yyvsp[(3) - (3)].integer); } | 1963 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) * (yyvsp[(3) - (3)].integer); } |
| 2030 | break; | 1964 | break; |
| 2031 | 1965 | ||
| 2032 | case 64: | 1966 | case 64: |
| 2033 | 1967 | /* Line 1787 of yacc.c */ | |
| 2034 | /* Line 1806 of yacc.c */ | ||
| 2035 | #line 412 "dtc-parser.y" | 1968 | #line 412 "dtc-parser.y" |
| 2036 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) / (yyvsp[(3) - (3)].integer); } | 1969 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) / (yyvsp[(3) - (3)].integer); } |
| 2037 | break; | 1970 | break; |
| 2038 | 1971 | ||
| 2039 | case 65: | 1972 | case 65: |
| 2040 | 1973 | /* Line 1787 of yacc.c */ | |
| 2041 | /* Line 1806 of yacc.c */ | ||
| 2042 | #line 413 "dtc-parser.y" | 1974 | #line 413 "dtc-parser.y" |
| 2043 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) % (yyvsp[(3) - (3)].integer); } | 1975 | { (yyval.integer) = (yyvsp[(1) - (3)].integer) % (yyvsp[(3) - (3)].integer); } |
| 2044 | break; | 1976 | break; |
| 2045 | 1977 | ||
| 2046 | case 68: | 1978 | case 68: |
| 2047 | 1979 | /* Line 1787 of yacc.c */ | |
| 2048 | /* Line 1806 of yacc.c */ | ||
| 2049 | #line 419 "dtc-parser.y" | 1980 | #line 419 "dtc-parser.y" |
| 2050 | { (yyval.integer) = -(yyvsp[(2) - (2)].integer); } | 1981 | { (yyval.integer) = -(yyvsp[(2) - (2)].integer); } |
| 2051 | break; | 1982 | break; |
| 2052 | 1983 | ||
| 2053 | case 69: | 1984 | case 69: |
| 2054 | 1985 | /* Line 1787 of yacc.c */ | |
| 2055 | /* Line 1806 of yacc.c */ | ||
| 2056 | #line 420 "dtc-parser.y" | 1986 | #line 420 "dtc-parser.y" |
| 2057 | { (yyval.integer) = ~(yyvsp[(2) - (2)].integer); } | 1987 | { (yyval.integer) = ~(yyvsp[(2) - (2)].integer); } |
| 2058 | break; | 1988 | break; |
| 2059 | 1989 | ||
| 2060 | case 70: | 1990 | case 70: |
| 2061 | 1991 | /* Line 1787 of yacc.c */ | |
| 2062 | /* Line 1806 of yacc.c */ | ||
| 2063 | #line 421 "dtc-parser.y" | 1992 | #line 421 "dtc-parser.y" |
| 2064 | { (yyval.integer) = !(yyvsp[(2) - (2)].integer); } | 1993 | { (yyval.integer) = !(yyvsp[(2) - (2)].integer); } |
| 2065 | break; | 1994 | break; |
| 2066 | 1995 | ||
| 2067 | case 71: | 1996 | case 71: |
| 2068 | 1997 | /* Line 1787 of yacc.c */ | |
| 2069 | /* Line 1806 of yacc.c */ | ||
| 2070 | #line 426 "dtc-parser.y" | 1998 | #line 426 "dtc-parser.y" |
| 2071 | { | 1999 | { |
| 2072 | (yyval.data) = empty_data; | 2000 | (yyval.data) = empty_data; |
| @@ -2074,8 +2002,7 @@ yyreduce: | |||
| 2074 | break; | 2002 | break; |
| 2075 | 2003 | ||
| 2076 | case 72: | 2004 | case 72: |
| 2077 | 2005 | /* Line 1787 of yacc.c */ | |
| 2078 | /* Line 1806 of yacc.c */ | ||
| 2079 | #line 430 "dtc-parser.y" | 2006 | #line 430 "dtc-parser.y" |
| 2080 | { | 2007 | { |
| 2081 | (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); | 2008 | (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); |
| @@ -2083,8 +2010,7 @@ yyreduce: | |||
| 2083 | break; | 2010 | break; |
| 2084 | 2011 | ||
| 2085 | case 73: | 2012 | case 73: |
| 2086 | 2013 | /* Line 1787 of yacc.c */ | |
| 2087 | /* Line 1806 of yacc.c */ | ||
| 2088 | #line 434 "dtc-parser.y" | 2014 | #line 434 "dtc-parser.y" |
| 2089 | { | 2015 | { |
| 2090 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); | 2016 | (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); |
| @@ -2092,8 +2018,7 @@ yyreduce: | |||
| 2092 | break; | 2018 | break; |
| 2093 | 2019 | ||
| 2094 | case 74: | 2020 | case 74: |
| 2095 | 2021 | /* Line 1787 of yacc.c */ | |
| 2096 | /* Line 1806 of yacc.c */ | ||
| 2097 | #line 441 "dtc-parser.y" | 2022 | #line 441 "dtc-parser.y" |
| 2098 | { | 2023 | { |
| 2099 | (yyval.nodelist) = NULL; | 2024 | (yyval.nodelist) = NULL; |
| @@ -2101,8 +2026,7 @@ yyreduce: | |||
| 2101 | break; | 2026 | break; |
| 2102 | 2027 | ||
| 2103 | case 75: | 2028 | case 75: |
| 2104 | 2029 | /* Line 1787 of yacc.c */ | |
| 2105 | /* Line 1806 of yacc.c */ | ||
| 2106 | #line 445 "dtc-parser.y" | 2030 | #line 445 "dtc-parser.y" |
| 2107 | { | 2031 | { |
| 2108 | (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); | 2032 | (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); |
| @@ -2110,8 +2034,7 @@ yyreduce: | |||
| 2110 | break; | 2034 | break; |
| 2111 | 2035 | ||
| 2112 | case 76: | 2036 | case 76: |
| 2113 | 2037 | /* Line 1787 of yacc.c */ | |
| 2114 | /* Line 1806 of yacc.c */ | ||
| 2115 | #line 449 "dtc-parser.y" | 2038 | #line 449 "dtc-parser.y" |
| 2116 | { | 2039 | { |
| 2117 | print_error("syntax error: properties must precede subnodes"); | 2040 | print_error("syntax error: properties must precede subnodes"); |
| @@ -2120,8 +2043,7 @@ yyreduce: | |||
| 2120 | break; | 2043 | break; |
| 2121 | 2044 | ||
| 2122 | case 77: | 2045 | case 77: |
| 2123 | 2046 | /* Line 1787 of yacc.c */ | |
| 2124 | /* Line 1806 of yacc.c */ | ||
| 2125 | #line 457 "dtc-parser.y" | 2047 | #line 457 "dtc-parser.y" |
| 2126 | { | 2048 | { |
| 2127 | (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename)); | 2049 | (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename)); |
| @@ -2129,8 +2051,7 @@ yyreduce: | |||
| 2129 | break; | 2051 | break; |
| 2130 | 2052 | ||
| 2131 | case 78: | 2053 | case 78: |
| 2132 | 2054 | /* Line 1787 of yacc.c */ | |
| 2133 | /* Line 1806 of yacc.c */ | ||
| 2134 | #line 461 "dtc-parser.y" | 2055 | #line 461 "dtc-parser.y" |
| 2135 | { | 2056 | { |
| 2136 | (yyval.node) = name_node(build_node_delete(), (yyvsp[(2) - (3)].propnodename)); | 2057 | (yyval.node) = name_node(build_node_delete(), (yyvsp[(2) - (3)].propnodename)); |
| @@ -2138,8 +2059,7 @@ yyreduce: | |||
| 2138 | break; | 2059 | break; |
| 2139 | 2060 | ||
| 2140 | case 79: | 2061 | case 79: |
| 2141 | 2062 | /* Line 1787 of yacc.c */ | |
| 2142 | /* Line 1806 of yacc.c */ | ||
| 2143 | #line 465 "dtc-parser.y" | 2063 | #line 465 "dtc-parser.y" |
| 2144 | { | 2064 | { |
| 2145 | add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref)); | 2065 | add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref)); |
| @@ -2148,9 +2068,8 @@ yyreduce: | |||
| 2148 | break; | 2068 | break; |
| 2149 | 2069 | ||
| 2150 | 2070 | ||
| 2151 | 2071 | /* Line 1787 of yacc.c */ | |
| 2152 | /* Line 1806 of yacc.c */ | 2072 | #line 2073 "dtc-parser.tab.c" |
| 2153 | #line 2154 "dtc-parser.tab.c" | ||
| 2154 | default: break; | 2073 | default: break; |
| 2155 | } | 2074 | } |
| 2156 | /* User semantic actions sometimes alter yychar, and that requires | 2075 | /* User semantic actions sometimes alter yychar, and that requires |
| @@ -2313,7 +2232,9 @@ yyerrlab1: | |||
| 2313 | YY_STACK_PRINT (yyss, yyssp); | 2232 | YY_STACK_PRINT (yyss, yyssp); |
| 2314 | } | 2233 | } |
| 2315 | 2234 | ||
| 2235 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 2316 | *++yyvsp = yylval; | 2236 | *++yyvsp = yylval; |
| 2237 | YY_IGNORE_MAYBE_UNINITIALIZED_END | ||
| 2317 | 2238 | ||
| 2318 | 2239 | ||
| 2319 | /* Shift the error token. */ | 2240 | /* Shift the error token. */ |
| @@ -2337,7 +2258,7 @@ yyabortlab: | |||
| 2337 | yyresult = 1; | 2258 | yyresult = 1; |
| 2338 | goto yyreturn; | 2259 | goto yyreturn; |
| 2339 | 2260 | ||
| 2340 | #if !defined(yyoverflow) || YYERROR_VERBOSE | 2261 | #if !defined yyoverflow || YYERROR_VERBOSE |
| 2341 | /*-------------------------------------------------. | 2262 | /*-------------------------------------------------. |
| 2342 | | yyexhaustedlab -- memory exhaustion comes here. | | 2263 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 2343 | `-------------------------------------------------*/ | 2264 | `-------------------------------------------------*/ |
| @@ -2379,8 +2300,7 @@ yyreturn: | |||
| 2379 | } | 2300 | } |
| 2380 | 2301 | ||
| 2381 | 2302 | ||
| 2382 | 2303 | /* Line 2050 of yacc.c */ | |
| 2383 | /* Line 2067 of yacc.c */ | ||
| 2384 | #line 471 "dtc-parser.y" | 2304 | #line 471 "dtc-parser.y" |
| 2385 | 2305 | ||
| 2386 | 2306 | ||
| @@ -2444,4 +2364,3 @@ static unsigned char eval_char_literal(const char *s) | |||
| 2444 | 2364 | ||
| 2445 | return c; | 2365 | return c; |
| 2446 | } | 2366 | } |
| 2447 | |||
diff --git a/scripts/dtc/dtc-parser.tab.h_shipped b/scripts/dtc/dtc-parser.tab.h_shipped index 25d3b88c6132..b2e7a86cd85e 100644 --- a/scripts/dtc/dtc-parser.tab.h_shipped +++ b/scripts/dtc/dtc-parser.tab.h_shipped | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | /* A Bison parser, made by GNU Bison 2.5. */ | 1 | /* A Bison parser, made by GNU Bison 2.7.12-4996. */ |
| 2 | 2 | ||
| 3 | /* Bison interface for Yacc-like parsers in C | 3 | /* Bison interface for Yacc-like parsers in C |
| 4 | 4 | ||
| 5 | Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. | 5 | Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. |
| 6 | 6 | ||
| 7 | This program is free software: you can redistribute it and/or modify | 7 | This program is free software: you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
| @@ -30,6 +30,15 @@ | |||
| 30 | This special exception was added by the Free Software Foundation in | 30 | This special exception was added by the Free Software Foundation in |
| 31 | version 2.2 of Bison. */ | 31 | version 2.2 of Bison. */ |
| 32 | 32 | ||
| 33 | #ifndef YY_YY_DTC_PARSER_TAB_H_INCLUDED | ||
| 34 | # define YY_YY_DTC_PARSER_TAB_H_INCLUDED | ||
| 35 | /* Enabling traces. */ | ||
| 36 | #ifndef YYDEBUG | ||
| 37 | # define YYDEBUG 0 | ||
| 38 | #endif | ||
| 39 | #if YYDEBUG | ||
| 40 | extern int yydebug; | ||
| 41 | #endif | ||
| 33 | 42 | ||
| 34 | /* Tokens. */ | 43 | /* Tokens. */ |
| 35 | #ifndef YYTOKENTYPE | 44 | #ifndef YYTOKENTYPE |
| @@ -63,12 +72,10 @@ | |||
| 63 | #endif | 72 | #endif |
| 64 | 73 | ||
| 65 | 74 | ||
| 66 | |||
| 67 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED | 75 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
| 68 | typedef union YYSTYPE | 76 | typedef union YYSTYPE |
| 69 | { | 77 | { |
| 70 | 78 | /* Line 2053 of yacc.c */ | |
| 71 | /* Line 2068 of yacc.c */ | ||
| 72 | #line 40 "dtc-parser.y" | 79 | #line 40 "dtc-parser.y" |
| 73 | 80 | ||
| 74 | char *propnodename; | 81 | char *propnodename; |
| @@ -91,9 +98,8 @@ typedef union YYSTYPE | |||
| 91 | uint64_t integer; | 98 | uint64_t integer; |
| 92 | 99 | ||
| 93 | 100 | ||
| 94 | 101 | /* Line 2053 of yacc.c */ | |
| 95 | /* Line 2068 of yacc.c */ | 102 | #line 103 "dtc-parser.tab.h" |
| 96 | #line 97 "dtc-parser.tab.h" | ||
| 97 | } YYSTYPE; | 103 | } YYSTYPE; |
| 98 | # define YYSTYPE_IS_TRIVIAL 1 | 104 | # define YYSTYPE_IS_TRIVIAL 1 |
| 99 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ | 105 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| @@ -102,4 +108,18 @@ typedef union YYSTYPE | |||
| 102 | 108 | ||
| 103 | extern YYSTYPE yylval; | 109 | extern YYSTYPE yylval; |
| 104 | 110 | ||
| 111 | #ifdef YYPARSE_PARAM | ||
| 112 | #if defined __STDC__ || defined __cplusplus | ||
| 113 | int yyparse (void *YYPARSE_PARAM); | ||
| 114 | #else | ||
| 115 | int yyparse (); | ||
| 116 | #endif | ||
| 117 | #else /* ! YYPARSE_PARAM */ | ||
| 118 | #if defined __STDC__ || defined __cplusplus | ||
| 119 | int yyparse (void); | ||
| 120 | #else | ||
| 121 | int yyparse (); | ||
| 122 | #endif | ||
| 123 | #endif /* ! YYPARSE_PARAM */ | ||
| 105 | 124 | ||
| 125 | #endif /* !YY_YY_DTC_PARSER_TAB_H_INCLUDED */ | ||
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c index a375683c1534..e3c96536fd9d 100644 --- a/scripts/dtc/dtc.c +++ b/scripts/dtc/dtc.c | |||
| @@ -21,8 +21,6 @@ | |||
| 21 | #include "dtc.h" | 21 | #include "dtc.h" |
| 22 | #include "srcpos.h" | 22 | #include "srcpos.h" |
| 23 | 23 | ||
| 24 | #include "version_gen.h" | ||
| 25 | |||
| 26 | /* | 24 | /* |
| 27 | * Command line options | 25 | * Command line options |
| 28 | */ | 26 | */ |
| @@ -49,55 +47,60 @@ static void fill_fullpaths(struct node *tree, const char *prefix) | |||
| 49 | fill_fullpaths(child, tree->fullpath); | 47 | fill_fullpaths(child, tree->fullpath); |
| 50 | } | 48 | } |
| 51 | 49 | ||
| 52 | static void __attribute__ ((noreturn)) usage(void) | 50 | /* Usage related data. */ |
| 53 | { | 51 | static const char usage_synopsis[] = "dtc [options] <input file>"; |
| 54 | fprintf(stderr, "Usage:\n"); | 52 | static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv"; |
| 55 | fprintf(stderr, "\tdtc [options] <input file>\n"); | 53 | static struct option const usage_long_opts[] = { |
| 56 | fprintf(stderr, "\nOptions:\n"); | 54 | {"quiet", no_argument, NULL, 'q'}, |
| 57 | fprintf(stderr, "\t-h\n"); | 55 | {"in-format", a_argument, NULL, 'I'}, |
| 58 | fprintf(stderr, "\t\tThis help text\n"); | 56 | {"out", a_argument, NULL, 'o'}, |
| 59 | fprintf(stderr, "\t-q\n"); | 57 | {"out-format", a_argument, NULL, 'O'}, |
| 60 | fprintf(stderr, "\t\tQuiet: -q suppress warnings, -qq errors, -qqq all\n"); | 58 | {"out-version", a_argument, NULL, 'V'}, |
| 61 | fprintf(stderr, "\t-I <input format>\n"); | 59 | {"out-dependency", a_argument, NULL, 'd'}, |
| 62 | fprintf(stderr, "\t\tInput formats are:\n"); | 60 | {"reserve", a_argument, NULL, 'R'}, |
| 63 | fprintf(stderr, "\t\t\tdts - device tree source text\n"); | 61 | {"space", a_argument, NULL, 'S'}, |
| 64 | fprintf(stderr, "\t\t\tdtb - device tree blob\n"); | 62 | {"pad", a_argument, NULL, 'p'}, |
| 65 | fprintf(stderr, "\t\t\tfs - /proc/device-tree style directory\n"); | 63 | {"boot-cpu", a_argument, NULL, 'b'}, |
| 66 | fprintf(stderr, "\t-o <output file>\n"); | 64 | {"force", no_argument, NULL, 'f'}, |
| 67 | fprintf(stderr, "\t-O <output format>\n"); | 65 | {"include", a_argument, NULL, 'i'}, |
| 68 | fprintf(stderr, "\t\tOutput formats are:\n"); | 66 | {"sort", no_argument, NULL, 's'}, |
| 69 | fprintf(stderr, "\t\t\tdts - device tree source text\n"); | 67 | {"phandle", a_argument, NULL, 'H'}, |
| 70 | fprintf(stderr, "\t\t\tdtb - device tree blob\n"); | 68 | {"warning", a_argument, NULL, 'W'}, |
| 71 | fprintf(stderr, "\t\t\tasm - assembler source\n"); | 69 | {"error", a_argument, NULL, 'E'}, |
| 72 | fprintf(stderr, "\t-V <output version>\n"); | 70 | {"help", no_argument, NULL, 'h'}, |
| 73 | fprintf(stderr, "\t\tBlob version to produce, defaults to %d (relevant for dtb\n\t\tand asm output only)\n", DEFAULT_FDT_VERSION); | 71 | {"version", no_argument, NULL, 'v'}, |
| 74 | fprintf(stderr, "\t-d <output dependency file>\n"); | 72 | {NULL, no_argument, NULL, 0x0}, |
| 75 | fprintf(stderr, "\t-R <number>\n"); | 73 | }; |
| 76 | fprintf(stderr, "\t\tMake space for <number> reserve map entries (relevant for \n\t\tdtb and asm output only)\n"); | 74 | static const char * const usage_opts_help[] = { |
| 77 | fprintf(stderr, "\t-S <bytes>\n"); | 75 | "\n\tQuiet: -q suppress warnings, -qq errors, -qqq all", |
| 78 | fprintf(stderr, "\t\tMake the blob at least <bytes> long (extra space)\n"); | 76 | "\n\tInput formats are:\n" |
| 79 | fprintf(stderr, "\t-p <bytes>\n"); | 77 | "\t\tdts - device tree source text\n" |
| 80 | fprintf(stderr, "\t\tAdd padding to the blob of <bytes> long (extra space)\n"); | 78 | "\t\tdtb - device tree blob\n" |
| 81 | fprintf(stderr, "\t-b <number>\n"); | 79 | "\t\tfs - /proc/device-tree style directory", |
| 82 | fprintf(stderr, "\t\tSet the physical boot cpu\n"); | 80 | "\n\tOutput file", |
| 83 | fprintf(stderr, "\t-f\n"); | 81 | "\n\tOutput formats are:\n" |
| 84 | fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n"); | 82 | "\t\tdts - device tree source text\n" |
| 85 | fprintf(stderr, "\t-i\n"); | 83 | "\t\tdtb - device tree blob\n" |
| 86 | fprintf(stderr, "\t\tAdd a path to search for include files\n"); | 84 | "\t\tasm - assembler source", |
| 87 | fprintf(stderr, "\t-s\n"); | 85 | "\n\tBlob version to produce, defaults to %d (for dtb and asm output)", //, DEFAULT_FDT_VERSION); |
| 88 | fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n"); | 86 | "\n\tOutput dependency file", |
| 89 | fprintf(stderr, "\t-v\n"); | 87 | "\n\ttMake space for <number> reserve map entries (for dtb and asm output)", |
| 90 | fprintf(stderr, "\t\tPrint DTC version and exit\n"); | 88 | "\n\tMake the blob at least <bytes> long (extra space)", |
| 91 | fprintf(stderr, "\t-H <phandle format>\n"); | 89 | "\n\tAdd padding to the blob of <bytes> long (extra space)", |
| 92 | fprintf(stderr, "\t\tphandle formats are:\n"); | 90 | "\n\tSet the physical boot cpu", |
| 93 | fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n"); | 91 | "\n\tTry to produce output even if the input tree has errors", |
| 94 | fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n"); | 92 | "\n\tAdd a path to search for include files", |
| 95 | fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n"); | 93 | "\n\tSort nodes and properties before outputting (useful for comparing trees)", |
| 96 | fprintf(stderr, "\t-W [no-]<checkname>\n"); | 94 | "\n\tValid phandle formats are:\n" |
| 97 | fprintf(stderr, "\t-E [no-]<checkname>\n"); | 95 | "\t\tlegacy - \"linux,phandle\" properties only\n" |
| 98 | fprintf(stderr, "\t\t\tenable or disable warnings and errors\n"); | 96 | "\t\tepapr - \"phandle\" properties only\n" |
| 99 | exit(3); | 97 | "\t\tboth - Both \"linux,phandle\" and \"phandle\" properties", |
| 100 | } | 98 | "\n\tEnable/disable warnings (prefix with \"no-\")", |
| 99 | "\n\tEnable/disable errors (prefix with \"no-\")", | ||
| 100 | "\n\tPrint this help and exit", | ||
| 101 | "\n\tPrint version and exit", | ||
| 102 | NULL, | ||
| 103 | }; | ||
| 101 | 104 | ||
| 102 | int main(int argc, char *argv[]) | 105 | int main(int argc, char *argv[]) |
| 103 | { | 106 | { |
| @@ -118,8 +121,7 @@ int main(int argc, char *argv[]) | |||
| 118 | minsize = 0; | 121 | minsize = 0; |
| 119 | padsize = 0; | 122 | padsize = 0; |
| 120 | 123 | ||
| 121 | while ((opt = getopt(argc, argv, "hI:O:o:V:d:R:S:p:fqb:i:vH:sW:E:")) | 124 | while ((opt = util_getopt_long()) != EOF) { |
| 122 | != EOF) { | ||
| 123 | switch (opt) { | 125 | switch (opt) { |
| 124 | case 'I': | 126 | case 'I': |
| 125 | inform = optarg; | 127 | inform = optarg; |
| @@ -158,8 +160,7 @@ int main(int argc, char *argv[]) | |||
| 158 | srcfile_add_search_path(optarg); | 160 | srcfile_add_search_path(optarg); |
| 159 | break; | 161 | break; |
| 160 | case 'v': | 162 | case 'v': |
| 161 | printf("Version: %s\n", DTC_VERSION); | 163 | util_version(); |
| 162 | exit(0); | ||
| 163 | case 'H': | 164 | case 'H': |
| 164 | if (streq(optarg, "legacy")) | 165 | if (streq(optarg, "legacy")) |
| 165 | phandle_format = PHANDLE_LEGACY; | 166 | phandle_format = PHANDLE_LEGACY; |
| @@ -185,13 +186,14 @@ int main(int argc, char *argv[]) | |||
| 185 | break; | 186 | break; |
| 186 | 187 | ||
| 187 | case 'h': | 188 | case 'h': |
| 189 | usage(NULL); | ||
| 188 | default: | 190 | default: |
| 189 | usage(); | 191 | usage("unknown option"); |
| 190 | } | 192 | } |
| 191 | } | 193 | } |
| 192 | 194 | ||
| 193 | if (argc > (optind+1)) | 195 | if (argc > (optind+1)) |
| 194 | usage(); | 196 | usage("missing files"); |
| 195 | else if (argc < (optind+1)) | 197 | else if (argc < (optind+1)) |
| 196 | arg = "-"; | 198 | arg = "-"; |
| 197 | else | 199 | else |
| @@ -201,9 +203,6 @@ int main(int argc, char *argv[]) | |||
| 201 | if (minsize && padsize) | 203 | if (minsize && padsize) |
| 202 | die("Can't set both -p and -S\n"); | 204 | die("Can't set both -p and -S\n"); |
| 203 | 205 | ||
| 204 | if (minsize) | ||
| 205 | fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n"); | ||
| 206 | |||
| 207 | if (depname) { | 206 | if (depname) { |
| 208 | depfile = fopen(depname, "w"); | 207 | depfile = fopen(depname, "w"); |
| 209 | if (!depfile) | 208 | if (!depfile) |
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h index 3e42a071070e..264a20cf66a8 100644 --- a/scripts/dtc/dtc.h +++ b/scripts/dtc/dtc.h | |||
| @@ -66,7 +66,6 @@ typedef uint32_t cell_t; | |||
| 66 | #define strneq(a, b, n) (strncmp((a), (b), (n)) == 0) | 66 | #define strneq(a, b, n) (strncmp((a), (b), (n)) == 0) |
| 67 | 67 | ||
| 68 | #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) | 68 | #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) |
| 69 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
| 70 | 69 | ||
| 71 | /* Data blobs */ | 70 | /* Data blobs */ |
| 72 | enum markertype { | 71 | enum markertype { |
diff --git a/scripts/dtc/srcpos.c b/scripts/dtc/srcpos.c index 246ab4bc0d9d..c20bc5315bc1 100644 --- a/scripts/dtc/srcpos.c +++ b/scripts/dtc/srcpos.c | |||
| @@ -297,9 +297,9 @@ srcpos_verror(struct srcpos *pos, char const *fmt, va_list va) | |||
| 297 | 297 | ||
| 298 | srcstr = srcpos_string(pos); | 298 | srcstr = srcpos_string(pos); |
| 299 | 299 | ||
| 300 | fprintf(stdout, "Error: %s ", srcstr); | 300 | fprintf(stderr, "Error: %s ", srcstr); |
| 301 | vfprintf(stdout, fmt, va); | 301 | vfprintf(stderr, fmt, va); |
| 302 | fprintf(stdout, "\n"); | 302 | fprintf(stderr, "\n"); |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | void | 305 | void |
diff --git a/scripts/dtc/update-dtc-source.sh b/scripts/dtc/update-dtc-source.sh new file mode 100755 index 000000000000..feb01ef26be4 --- /dev/null +++ b/scripts/dtc/update-dtc-source.sh | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Simple script to update the version of DTC carried by the Linux kernel | ||
| 3 | # | ||
| 4 | # This script assumes that the dtc and the linux git trees are in the | ||
| 5 | # same directory. After building dtc in the dtc directory, it copies the | ||
| 6 | # source files and generated source files into the scripts/dtc directory | ||
| 7 | # in the kernel and creates a git commit updating them to the new | ||
| 8 | # version. | ||
| 9 | # | ||
| 10 | # Usage: from the top level Linux source tree, run: | ||
| 11 | # $ ./scripts/dtc/update-dtc-source.sh | ||
| 12 | # | ||
| 13 | # The script will change into the dtc tree, build and test dtc, copy the | ||
| 14 | # relevant files into the kernel tree and create a git commit. The commit | ||
| 15 | # message will need to be modified to reflect the version of DTC being | ||
| 16 | # imported | ||
| 17 | # | ||
| 18 | # TODO: | ||
| 19 | # This script is pretty basic, but it is seldom used so a few manual tasks | ||
| 20 | # aren't a big deal. If anyone is interested in making it more robust, the | ||
| 21 | # the following would be nice: | ||
| 22 | # * Actually fail to complete if any testcase fails. | ||
| 23 | # - The dtc "make check" target needs to return a failure | ||
| 24 | # * Extract the version number from the dtc repo for the commit message | ||
| 25 | # * Build dtc in the kernel tree | ||
| 26 | # * run 'make check" on dtc built from the kernel tree | ||
| 27 | |||
| 28 | set -ev | ||
| 29 | |||
| 30 | DTC_UPSTREAM_PATH=`pwd`/../dtc | ||
| 31 | DTC_LINUX_PATH=`pwd`/scripts/dtc | ||
| 32 | |||
| 33 | DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \ | ||
| 34 | srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \ | ||
| 35 | dtc-lexer.l dtc-parser.y" | ||
| 36 | DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h" | ||
| 37 | |||
| 38 | # Build DTC | ||
| 39 | cd $DTC_UPSTREAM_PATH | ||
| 40 | make clean | ||
| 41 | make check | ||
| 42 | |||
| 43 | # Copy the files into the Linux tree | ||
| 44 | cd $DTC_LINUX_PATH | ||
| 45 | for f in $DTC_SOURCE; do | ||
| 46 | cp ${DTC_UPSTREAM_PATH}/${f} ${f} | ||
| 47 | git add ${f} | ||
| 48 | done | ||
| 49 | for f in $DTC_GENERATED; do | ||
| 50 | cp ${DTC_UPSTREAM_PATH}/$f ${f}_shipped | ||
| 51 | git add ${f}_shipped | ||
| 52 | done | ||
| 53 | |||
| 54 | git commit -e -v -m "scripts/dtc: Update to upstream version [CHANGEME]" | ||
diff --git a/scripts/dtc/util.c b/scripts/dtc/util.c index 2422c34e11df..3055c16e980d 100644 --- a/scripts/dtc/util.c +++ b/scripts/dtc/util.c | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | 34 | ||
| 35 | #include "libfdt.h" | 35 | #include "libfdt.h" |
| 36 | #include "util.h" | 36 | #include "util.h" |
| 37 | #include "version_gen.h" | ||
| 37 | 38 | ||
| 38 | char *xstrdup(const char *s) | 39 | char *xstrdup(const char *s) |
| 39 | { | 40 | { |
| @@ -72,7 +73,7 @@ char *join_path(const char *path, const char *name) | |||
| 72 | int util_is_printable_string(const void *data, int len) | 73 | int util_is_printable_string(const void *data, int len) |
| 73 | { | 74 | { |
| 74 | const char *s = data; | 75 | const char *s = data; |
| 75 | const char *ss; | 76 | const char *ss, *se; |
| 76 | 77 | ||
| 77 | /* zero length is not */ | 78 | /* zero length is not */ |
| 78 | if (len == 0) | 79 | if (len == 0) |
| @@ -82,13 +83,19 @@ int util_is_printable_string(const void *data, int len) | |||
| 82 | if (s[len - 1] != '\0') | 83 | if (s[len - 1] != '\0') |
| 83 | return 0; | 84 | return 0; |
| 84 | 85 | ||
| 85 | ss = s; | 86 | se = s + len; |
| 86 | while (*s && isprint(*s)) | ||
| 87 | s++; | ||
| 88 | 87 | ||
| 89 | /* not zero, or not done yet */ | 88 | while (s < se) { |
| 90 | if (*s != '\0' || (s + 1 - ss) < len) | 89 | ss = s; |
| 91 | return 0; | 90 | while (s < se && *s && isprint(*s)) |
| 91 | s++; | ||
| 92 | |||
| 93 | /* not zero, or not done yet */ | ||
| 94 | if (*s != '\0' || s == ss) | ||
| 95 | return 0; | ||
| 96 | |||
| 97 | s++; | ||
| 98 | } | ||
| 92 | 99 | ||
| 93 | return 1; | 100 | return 1; |
| 94 | } | 101 | } |
| @@ -191,7 +198,7 @@ char get_escape_char(const char *s, int *i) | |||
| 191 | return val; | 198 | return val; |
| 192 | } | 199 | } |
| 193 | 200 | ||
| 194 | int utilfdt_read_err(const char *filename, char **buffp) | 201 | int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len) |
| 195 | { | 202 | { |
| 196 | int fd = 0; /* assume stdin */ | 203 | int fd = 0; /* assume stdin */ |
| 197 | char *buf = NULL; | 204 | char *buf = NULL; |
| @@ -206,12 +213,12 @@ int utilfdt_read_err(const char *filename, char **buffp) | |||
| 206 | } | 213 | } |
| 207 | 214 | ||
| 208 | /* Loop until we have read everything */ | 215 | /* Loop until we have read everything */ |
| 209 | buf = malloc(bufsize); | 216 | buf = xmalloc(bufsize); |
| 210 | do { | 217 | do { |
| 211 | /* Expand the buffer to hold the next chunk */ | 218 | /* Expand the buffer to hold the next chunk */ |
| 212 | if (offset == bufsize) { | 219 | if (offset == bufsize) { |
| 213 | bufsize *= 2; | 220 | bufsize *= 2; |
| 214 | buf = realloc(buf, bufsize); | 221 | buf = xrealloc(buf, bufsize); |
| 215 | if (!buf) { | 222 | if (!buf) { |
| 216 | ret = ENOMEM; | 223 | ret = ENOMEM; |
| 217 | break; | 224 | break; |
| @@ -232,13 +239,20 @@ int utilfdt_read_err(const char *filename, char **buffp) | |||
| 232 | free(buf); | 239 | free(buf); |
| 233 | else | 240 | else |
| 234 | *buffp = buf; | 241 | *buffp = buf; |
| 242 | *len = bufsize; | ||
| 235 | return ret; | 243 | return ret; |
| 236 | } | 244 | } |
| 237 | 245 | ||
| 238 | char *utilfdt_read(const char *filename) | 246 | int utilfdt_read_err(const char *filename, char **buffp) |
| 247 | { | ||
| 248 | off_t len; | ||
| 249 | return utilfdt_read_err_len(filename, buffp, &len); | ||
| 250 | } | ||
| 251 | |||
| 252 | char *utilfdt_read_len(const char *filename, off_t *len) | ||
| 239 | { | 253 | { |
| 240 | char *buff; | 254 | char *buff; |
| 241 | int ret = utilfdt_read_err(filename, &buff); | 255 | int ret = utilfdt_read_err_len(filename, &buff, len); |
| 242 | 256 | ||
| 243 | if (ret) { | 257 | if (ret) { |
| 244 | fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename, | 258 | fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename, |
| @@ -249,6 +263,12 @@ char *utilfdt_read(const char *filename) | |||
| 249 | return buff; | 263 | return buff; |
| 250 | } | 264 | } |
| 251 | 265 | ||
| 266 | char *utilfdt_read(const char *filename) | ||
| 267 | { | ||
| 268 | off_t len; | ||
| 269 | return utilfdt_read_len(filename, &len); | ||
| 270 | } | ||
| 271 | |||
| 252 | int utilfdt_write_err(const char *filename, const void *blob) | 272 | int utilfdt_write_err(const char *filename, const void *blob) |
| 253 | { | 273 | { |
| 254 | int fd = 1; /* assume stdout */ | 274 | int fd = 1; /* assume stdout */ |
| @@ -329,3 +349,100 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size) | |||
| 329 | return -1; | 349 | return -1; |
| 330 | return 0; | 350 | return 0; |
| 331 | } | 351 | } |
| 352 | |||
| 353 | void utilfdt_print_data(const char *data, int len) | ||
| 354 | { | ||
| 355 | int i; | ||
| 356 | const char *p = data; | ||
| 357 | const char *s; | ||
| 358 | |||
| 359 | /* no data, don't print */ | ||
| 360 | if (len == 0) | ||
| 361 | return; | ||
| 362 | |||
| 363 | if (util_is_printable_string(data, len)) { | ||
| 364 | printf(" = "); | ||
| 365 | |||
| 366 | s = data; | ||
| 367 | do { | ||
| 368 | printf("\"%s\"", s); | ||
| 369 | s += strlen(s) + 1; | ||
| 370 | if (s < data + len) | ||
| 371 | printf(", "); | ||
| 372 | } while (s < data + len); | ||
| 373 | |||
| 374 | } else if ((len % 4) == 0) { | ||
| 375 | const uint32_t *cell = (const uint32_t *)data; | ||
| 376 | |||
| 377 | printf(" = <"); | ||
| 378 | for (i = 0; i < len; i += 4) | ||
| 379 | printf("0x%08x%s", fdt32_to_cpu(cell[i]), | ||
| 380 | i < (len - 4) ? " " : ""); | ||
| 381 | printf(">"); | ||
| 382 | } else { | ||
| 383 | printf(" = ["); | ||
| 384 | for (i = 0; i < len; i++) | ||
| 385 | printf("%02x%s", *p++, i < len - 1 ? " " : ""); | ||
| 386 | printf("]"); | ||
| 387 | } | ||
| 388 | } | ||
| 389 | |||
| 390 | void util_version(void) | ||
| 391 | { | ||
| 392 | printf("Version: %s\n", DTC_VERSION); | ||
| 393 | exit(0); | ||
| 394 | } | ||
| 395 | |||
| 396 | void util_usage(const char *errmsg, const char *synopsis, | ||
| 397 | const char *short_opts, struct option const long_opts[], | ||
| 398 | const char * const opts_help[]) | ||
| 399 | { | ||
| 400 | FILE *fp = errmsg ? stderr : stdout; | ||
| 401 | const char a_arg[] = "<arg>"; | ||
| 402 | size_t a_arg_len = strlen(a_arg) + 1; | ||
| 403 | size_t i; | ||
| 404 | int optlen; | ||
| 405 | |||
| 406 | fprintf(fp, | ||
| 407 | "Usage: %s\n" | ||
| 408 | "\n" | ||
| 409 | "Options: -[%s]\n", synopsis, short_opts); | ||
| 410 | |||
| 411 | /* prescan the --long opt length to auto-align */ | ||
| 412 | optlen = 0; | ||
| 413 | for (i = 0; long_opts[i].name; ++i) { | ||
| 414 | /* +1 is for space between --opt and help text */ | ||
| 415 | int l = strlen(long_opts[i].name) + 1; | ||
| 416 | if (long_opts[i].has_arg == a_argument) | ||
| 417 | l += a_arg_len; | ||
| 418 | if (optlen < l) | ||
| 419 | optlen = l; | ||
| 420 | } | ||
| 421 | |||
| 422 | for (i = 0; long_opts[i].name; ++i) { | ||
| 423 | /* helps when adding new applets or options */ | ||
| 424 | assert(opts_help[i] != NULL); | ||
| 425 | |||
| 426 | /* first output the short flag if it has one */ | ||
| 427 | if (long_opts[i].val > '~') | ||
| 428 | fprintf(fp, " "); | ||
| 429 | else | ||
| 430 | fprintf(fp, " -%c, ", long_opts[i].val); | ||
| 431 | |||
| 432 | /* then the long flag */ | ||
| 433 | if (long_opts[i].has_arg == no_argument) | ||
| 434 | fprintf(fp, "--%-*s", optlen, long_opts[i].name); | ||
| 435 | else | ||
| 436 | fprintf(fp, "--%s %s%*s", long_opts[i].name, a_arg, | ||
| 437 | (int)(optlen - strlen(long_opts[i].name) - a_arg_len), ""); | ||
| 438 | |||
| 439 | /* finally the help text */ | ||
| 440 | fprintf(fp, "%s\n", opts_help[i]); | ||
| 441 | } | ||
| 442 | |||
| 443 | if (errmsg) { | ||
| 444 | fprintf(fp, "\nError: %s\n", errmsg); | ||
| 445 | exit(EXIT_FAILURE); | ||
| 446 | } else | ||
| 447 | exit(EXIT_SUCCESS); | ||
| 448 | } | ||
diff --git a/scripts/dtc/util.h b/scripts/dtc/util.h index c8eb45d9f04b..8f40b4499359 100644 --- a/scripts/dtc/util.h +++ b/scripts/dtc/util.h | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #define _UTIL_H | 2 | #define _UTIL_H |
| 3 | 3 | ||
| 4 | #include <stdarg.h> | 4 | #include <stdarg.h> |
| 5 | #include <getopt.h> | ||
| 5 | 6 | ||
| 6 | /* | 7 | /* |
| 7 | * Copyright 2011 The Chromium Authors, All Rights Reserved. | 8 | * Copyright 2011 The Chromium Authors, All Rights Reserved. |
| @@ -23,7 +24,9 @@ | |||
| 23 | * USA | 24 | * USA |
| 24 | */ | 25 | */ |
| 25 | 26 | ||
| 26 | static inline void __attribute__((noreturn)) die(char * str, ...) | 27 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
| 28 | |||
| 29 | static inline void __attribute__((noreturn)) die(const char *str, ...) | ||
| 27 | { | 30 | { |
| 28 | va_list ap; | 31 | va_list ap; |
| 29 | 32 | ||
| @@ -57,12 +60,14 @@ extern char *xstrdup(const char *s); | |||
| 57 | extern char *join_path(const char *path, const char *name); | 60 | extern char *join_path(const char *path, const char *name); |
| 58 | 61 | ||
| 59 | /** | 62 | /** |
| 60 | * Check a string of a given length to see if it is all printable and | 63 | * Check a property of a given length to see if it is all printable and |
| 61 | * has a valid terminator. | 64 | * has a valid terminator. The property can contain either a single string, |
| 65 | * or multiple strings each of non-zero length. | ||
| 62 | * | 66 | * |
| 63 | * @param data The string to check | 67 | * @param data The string to check |
| 64 | * @param len The string length including terminator | 68 | * @param len The string length including terminator |
| 65 | * @return 1 if a valid printable string, 0 if not */ | 69 | * @return 1 if a valid printable string, 0 if not |
| 70 | */ | ||
| 66 | int util_is_printable_string(const void *data, int len); | 71 | int util_is_printable_string(const void *data, int len); |
| 67 | 72 | ||
| 68 | /* | 73 | /* |
| @@ -83,6 +88,13 @@ char get_escape_char(const char *s, int *i); | |||
| 83 | char *utilfdt_read(const char *filename); | 88 | char *utilfdt_read(const char *filename); |
| 84 | 89 | ||
| 85 | /** | 90 | /** |
| 91 | * Like utilfdt_read(), but also passes back the size of the file read. | ||
| 92 | * | ||
| 93 | * @param len If non-NULL, the amount of data we managed to read | ||
| 94 | */ | ||
| 95 | char *utilfdt_read_len(const char *filename, off_t *len); | ||
| 96 | |||
| 97 | /** | ||
| 86 | * Read a device tree file into a buffer. Does not report errors, but only | 98 | * Read a device tree file into a buffer. Does not report errors, but only |
| 87 | * returns them. The value returned can be passed to strerror() to obtain | 99 | * returns them. The value returned can be passed to strerror() to obtain |
| 88 | * an error message for the user. | 100 | * an error message for the user. |
| @@ -93,6 +105,12 @@ char *utilfdt_read(const char *filename); | |||
| 93 | */ | 105 | */ |
| 94 | int utilfdt_read_err(const char *filename, char **buffp); | 106 | int utilfdt_read_err(const char *filename, char **buffp); |
| 95 | 107 | ||
| 108 | /** | ||
| 109 | * Like utilfdt_read_err(), but also passes back the size of the file read. | ||
| 110 | * | ||
| 111 | * @param len If non-NULL, the amount of data we managed to read | ||
| 112 | */ | ||
| 113 | int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len); | ||
| 96 | 114 | ||
| 97 | /** | 115 | /** |
| 98 | * Write a device tree buffer to a file. This will report any errors on | 116 | * Write a device tree buffer to a file. This will report any errors on |
| @@ -148,6 +166,85 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size); | |||
| 148 | #define USAGE_TYPE_MSG \ | 166 | #define USAGE_TYPE_MSG \ |
| 149 | "<type>\ts=string, i=int, u=unsigned, x=hex\n" \ | 167 | "<type>\ts=string, i=int, u=unsigned, x=hex\n" \ |
| 150 | "\tOptional modifier prefix:\n" \ | 168 | "\tOptional modifier prefix:\n" \ |
| 151 | "\t\thh or b=byte, h=2 byte, l=4 byte (default)\n"; | 169 | "\t\thh or b=byte, h=2 byte, l=4 byte (default)"; |
| 170 | |||
| 171 | /** | ||
| 172 | * Print property data in a readable format to stdout | ||
| 173 | * | ||
| 174 | * Properties that look like strings will be printed as strings. Otherwise | ||
| 175 | * the data will be displayed either as cells (if len is a multiple of 4 | ||
| 176 | * bytes) or bytes. | ||
| 177 | * | ||
| 178 | * If len is 0 then this function does nothing. | ||
| 179 | * | ||
| 180 | * @param data Pointers to property data | ||
| 181 | * @param len Length of property data | ||
| 182 | */ | ||
| 183 | void utilfdt_print_data(const char *data, int len); | ||
| 184 | |||
| 185 | /** | ||
| 186 | * Show source version and exit | ||
| 187 | */ | ||
| 188 | void util_version(void) __attribute__((noreturn)); | ||
| 189 | |||
| 190 | /** | ||
| 191 | * Show usage and exit | ||
| 192 | * | ||
| 193 | * This helps standardize the output of various utils. You most likely want | ||
| 194 | * to use the usage() helper below rather than call this. | ||
| 195 | * | ||
| 196 | * @param errmsg If non-NULL, an error message to display | ||
| 197 | * @param synopsis The initial example usage text (and possible examples) | ||
| 198 | * @param short_opts The string of short options | ||
| 199 | * @param long_opts The structure of long options | ||
| 200 | * @param opts_help An array of help strings (should align with long_opts) | ||
| 201 | */ | ||
| 202 | void util_usage(const char *errmsg, const char *synopsis, | ||
| 203 | const char *short_opts, struct option const long_opts[], | ||
| 204 | const char * const opts_help[]) __attribute__((noreturn)); | ||
| 205 | |||
| 206 | /** | ||
| 207 | * Show usage and exit | ||
| 208 | * | ||
| 209 | * If you name all your usage variables with usage_xxx, then you can call this | ||
| 210 | * help macro rather than expanding all arguments yourself. | ||
| 211 | * | ||
| 212 | * @param errmsg If non-NULL, an error message to display | ||
| 213 | */ | ||
| 214 | #define usage(errmsg) \ | ||
| 215 | util_usage(errmsg, usage_synopsis, usage_short_opts, \ | ||
| 216 | usage_long_opts, usage_opts_help) | ||
| 217 | |||
| 218 | /** | ||
| 219 | * Call getopt_long() with standard options | ||
| 220 | * | ||
| 221 | * Since all util code runs getopt in the same way, provide a helper. | ||
| 222 | */ | ||
| 223 | #define util_getopt_long() getopt_long(argc, argv, usage_short_opts, \ | ||
| 224 | usage_long_opts, NULL) | ||
| 225 | |||
| 226 | /* Helper for aligning long_opts array */ | ||
| 227 | #define a_argument required_argument | ||
| 228 | |||
| 229 | /* Helper for usage_short_opts string constant */ | ||
| 230 | #define USAGE_COMMON_SHORT_OPTS "hV" | ||
| 231 | |||
| 232 | /* Helper for usage_long_opts option array */ | ||
| 233 | #define USAGE_COMMON_LONG_OPTS \ | ||
| 234 | {"help", no_argument, NULL, 'h'}, \ | ||
| 235 | {"version", no_argument, NULL, 'V'}, \ | ||
| 236 | {NULL, no_argument, NULL, 0x0} | ||
| 237 | |||
| 238 | /* Helper for usage_opts_help array */ | ||
| 239 | #define USAGE_COMMON_OPTS_HELP \ | ||
| 240 | "Print this help and exit", \ | ||
| 241 | "Print version and exit", \ | ||
| 242 | NULL | ||
| 243 | |||
| 244 | /* Helper for getopt case statements */ | ||
| 245 | #define case_USAGE_COMMON_FLAGS \ | ||
| 246 | case 'h': usage(NULL); \ | ||
| 247 | case 'V': util_version(); \ | ||
| 248 | case '?': usage("unknown option"); | ||
| 152 | 249 | ||
| 153 | #endif /* _UTIL_H */ | 250 | #endif /* _UTIL_H */ |
diff --git a/scripts/dtc/version_gen.h b/scripts/dtc/version_gen.h index 6158b867df99..54d4e904433a 100644 --- a/scripts/dtc/version_gen.h +++ b/scripts/dtc/version_gen.h | |||
| @@ -1 +1 @@ | |||
| #define DTC_VERSION "DTC 1.2.0-g37c0b6a0" | #define DTC_VERSION "DTC 1.4.0-dirty" | ||
