aboutsummaryrefslogtreecommitdiff
path: root/core/fdt.c
AgeCommit message (Collapse)AuthorFilesLines
2019-07-26SPDX-ify all skiboot codeStewart Smith1-13/+4
Use Software Package Data Exchange (SPDX) to indicate license for each file that is unique to skiboot. At the same time, ensure the (C) who and years are correct. See https://spdx.org/ Signed-off-by: Stewart Smith <stewart@linux.ibm.com> [oliver: Added a few missing files] Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
2019-05-20device-tree: speed up fdt building on slow simulatorsNicholas Piggin1-1/+5
Trade size for speed and avoid de-duplicating strings in the fdt. This costs about 2kB in fdt size, and saves about 8 million instructions (almost half of all instructions) booting skiboot in mambo. This was tracked down by Michael Neuling <mikey@neuling.org>. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-05-15fdt: check more errorsNicholas Piggin1-2/+6
This catches a few more error cases in fdt building. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-12-10Change ifdef around dump_fdt() to shut up static analysisStewart Smith1-2/+2
This is a dumb warning from a certain static analysis tool that a function has no effect when the ifdef that would make it have an effect isn't defined and we replace it with a no-op impl. Putting the #ifdef around the call just so I don't have to discount this damn static analysis false positive every time I go and look at the results. Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2017-06-27dt: Add helper function for last_phandle updatesMadhavan Srinivasan1-4/+4
Add helper functions for "last_phandle" access/update and modify functions to use helper functions. Acked-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-06-15core/fdt: Always add a reserve mapOliver O'Halloran1-0/+3
Currently we skip adding the reserved ranges block to the generated FDT blob if we are excluding the root node. This can result in a DTB that dtc will barf on because the reserved memory ranges overlap with the start of the dt_struct block. As an example: $ fdtdump broken.dtb -d /dts-v1/; // magic: 0xd00dfeed // totalsize: 0x7f3 (2035) // off_dt_struct: 0x30 <----\ // off_dt_strings: 0x7b8 | this is bad! // off_mem_rsvmap: 0x30 <----/ // version: 17 // last_comp_version: 16 // boot_cpuid_phys: 0x0 // size_dt_strings: 0x3b // size_dt_struct: 0x788 /memreserve/ 0x100000000 0x300000004; /memreserve/ 0x3300000001 0x169626d2c; /memreserve/ 0x706369652d736c6f 0x7473000000000003; *continues* With this patch: $ fdtdump working.dtb -d /dts-v1/; // magic: 0xd00dfeed // totalsize: 0x803 (2051) // off_dt_struct: 0x40 // off_dt_strings: 0x7c8 // off_mem_rsvmap: 0x30 // version: 17 // last_comp_version: 16 // boot_cpuid_phys: 0x0 // size_dt_strings: 0x3b // size_dt_struct: 0x788 // 0040: tag: 0x00000001 (FDT_BEGIN_NODE) / { // 0048: tag: 0x00000003 (FDT_PROP) // 07fb: string: phandle // 0054: value phandle = <0x00000001>; *continues* Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-17Use additional checks in skiboot for pointersBalbir Singh1-0/+3
The checks validate pointers sent in using opal_addr_valid() in opal_call API's provided via the console, cpu, fdt, flash, i2c, interrupts, nvram, opal-msg, opal, opal-pci, xscom and cec modules Signed-off-by: Balbir Singh <bsingharora@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-20Stop adding legacy linux, phandle to device tree, just add phandleStewart Smith1-5/+0
Since the very first commit of a skeleton powernv platform in Linux, the kernel has been able to deal with phandle rather than linux,phandle. Thus, every kernel in the real world that has a hope of even getting to a twinkle in the eye of booting knows about phandle. So, we don't need to add linux,phandle along with phandle as it's just redundantly redundant. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-14core/fdt: Introduce opal_get_device_tree()Gavin Shan1-0/+40
This introduces OPAL API opal_get_device_tree() to get the device sub-tree. It's going to be used in PCI hot add path. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-14core/fdt: Allow to exclude root nodeGavin Shan1-11/+18
The root node is excluded in the device sub-tree created during PCI hot add time. This adds one extra argument @exclusive to flatten_dt_node(), __create_dtb() and create_dtb() to indicate the root node should be excluded or not. The changes are going to be used by PCI hot add path and it's not affecting anything at present. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-14core/fdt: Introduce __create_dtb()Gavin Shan1-20/+24
There is shared logic to flatten the whole device tree (used when loading kernel) or device sub-tree (used by PCI hot add). This introduces helper function __create_dtb() for the shared logic. No functional changes introduced. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-14core/fdt: Allow to specify FDT blobGavin Shan1-20/+20
There is a static variable @fdt pointing the FDT blob. The memory block is allocated by skiboot. After the device tree is flattened, it's passed to kernel when it's loaded. It works fine. The FDT blob for device sub-tree because of PCI hot add is allocated by kernel, using a static @fdt to dereferencing the FDT blob isn't correct any more. This adds @fdt argument to various functions to specify the target FDT blob memory block. As a result, the file scoped static variable @fdt is removed. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-14core/fdt: Introduce flatten_dt_properties()Gavin Shan1-14/+13
We need unflatten the child nodes of the specified one during PCI hot add time. After it, the FDT blob is transferred to kernel and unflattened there. A device sub-tree is represented by the FDT blob and it excludes the specified (root) node. This introduces helper function flatten_dt_properties() to flatten the properties of the specified node. In the path to create the device sub-tree, the root's properties is skipped in subsequent patch. In the mean time, the node tag is created in flatten_dt_node() so that the function is self-contained. No functional changes introduced. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-14core/fdt: Improve debugging functionalityGavin Shan1-19/+20
This improves the debugging functionality in fdt.c. No functional changes introduced: * Replace printf() with prlog(). * Introduce FDT_DBG() which is enabled on DEBUG_FDT. * Move #ifdef before dump_fdt() for better extendability. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-03-31core/fdt: Adjust parameter for dt_{property, begin_node}Gavin Shan1-9/+9
This passes property and device node as parameter to dt_property() and dt_begin_node separately so that we don't have to pass the individual fields of those two structs to the functions. No logical changes introduced. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-11-18Remove useless global include memory.hBenjamin Herrenschmidt1-1/+0
It only exposed one function that is local to the hdat stuff Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-07-02Initial commit of Open Source releaseBenjamin Herrenschmidt1-0/+208
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>