1*6780e684SKyle Evans #ifndef FDT_H 2*6780e684SKyle Evans #define FDT_H 3*6780e684SKyle Evans /* 4*6780e684SKyle Evans * libfdt - Flat Device Tree manipulation 5*6780e684SKyle Evans * Copyright (C) 2006 David Gibson, IBM Corporation. 6*6780e684SKyle Evans * Copyright 2012 Kim Phillips, Freescale Semiconductor. 7*6780e684SKyle Evans * 8*6780e684SKyle Evans * libfdt is dual licensed: you can use it either under the terms of 9*6780e684SKyle Evans * the GPL, or the BSD license, at your option. 10*6780e684SKyle Evans * 11*6780e684SKyle Evans * a) This library is free software; you can redistribute it and/or 12*6780e684SKyle Evans * modify it under the terms of the GNU General Public License as 13*6780e684SKyle Evans * published by the Free Software Foundation; either version 2 of the 14*6780e684SKyle Evans * License, or (at your option) any later version. 15*6780e684SKyle Evans * 16*6780e684SKyle Evans * This library is distributed in the hope that it will be useful, 17*6780e684SKyle Evans * but WITHOUT ANY WARRANTY; without even the implied warranty of 18*6780e684SKyle Evans * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19*6780e684SKyle Evans * GNU General Public License for more details. 20*6780e684SKyle Evans * 21*6780e684SKyle Evans * You should have received a copy of the GNU General Public 22*6780e684SKyle Evans * License along with this library; if not, write to the Free 23*6780e684SKyle Evans * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 24*6780e684SKyle Evans * MA 02110-1301 USA 25*6780e684SKyle Evans * 26*6780e684SKyle Evans * Alternatively, 27*6780e684SKyle Evans * 28*6780e684SKyle Evans * b) Redistribution and use in source and binary forms, with or 29*6780e684SKyle Evans * without modification, are permitted provided that the following 30*6780e684SKyle Evans * conditions are met: 31*6780e684SKyle Evans * 32*6780e684SKyle Evans * 1. Redistributions of source code must retain the above 33*6780e684SKyle Evans * copyright notice, this list of conditions and the following 34*6780e684SKyle Evans * disclaimer. 35*6780e684SKyle Evans * 2. Redistributions in binary form must reproduce the above 36*6780e684SKyle Evans * copyright notice, this list of conditions and the following 37*6780e684SKyle Evans * disclaimer in the documentation and/or other materials 38*6780e684SKyle Evans * provided with the distribution. 39*6780e684SKyle Evans * 40*6780e684SKyle Evans * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 41*6780e684SKyle Evans * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 42*6780e684SKyle Evans * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 43*6780e684SKyle Evans * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 44*6780e684SKyle Evans * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 45*6780e684SKyle Evans * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 46*6780e684SKyle Evans * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 47*6780e684SKyle Evans * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 48*6780e684SKyle Evans * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 49*6780e684SKyle Evans * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 50*6780e684SKyle Evans * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 51*6780e684SKyle Evans * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 52*6780e684SKyle Evans * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53*6780e684SKyle Evans */ 5421fdc27aSRafal Jaworowski 5521fdc27aSRafal Jaworowski #ifndef __ASSEMBLY__ 5621fdc27aSRafal Jaworowski 5721fdc27aSRafal Jaworowski struct fdt_header { 58*6780e684SKyle Evans fdt32_t magic; /* magic word FDT_MAGIC */ 59*6780e684SKyle Evans fdt32_t totalsize; /* total size of DT block */ 60*6780e684SKyle Evans fdt32_t off_dt_struct; /* offset to structure */ 61*6780e684SKyle Evans fdt32_t off_dt_strings; /* offset to strings */ 62*6780e684SKyle Evans fdt32_t off_mem_rsvmap; /* offset to memory reserve map */ 63*6780e684SKyle Evans fdt32_t version; /* format version */ 64*6780e684SKyle Evans fdt32_t last_comp_version; /* last compatible version */ 6521fdc27aSRafal Jaworowski 6621fdc27aSRafal Jaworowski /* version 2 fields below */ 67*6780e684SKyle Evans fdt32_t boot_cpuid_phys; /* Which physical CPU id we're 6821fdc27aSRafal Jaworowski booting on */ 6921fdc27aSRafal Jaworowski /* version 3 fields below */ 70*6780e684SKyle Evans fdt32_t size_dt_strings; /* size of the strings block */ 7121fdc27aSRafal Jaworowski 7221fdc27aSRafal Jaworowski /* version 17 fields below */ 73*6780e684SKyle Evans fdt32_t size_dt_struct; /* size of the structure block */ 7421fdc27aSRafal Jaworowski }; 7521fdc27aSRafal Jaworowski 7621fdc27aSRafal Jaworowski struct fdt_reserve_entry { 77*6780e684SKyle Evans fdt64_t address; 78*6780e684SKyle Evans fdt64_t size; 7921fdc27aSRafal Jaworowski }; 8021fdc27aSRafal Jaworowski 8121fdc27aSRafal Jaworowski struct fdt_node_header { 82*6780e684SKyle Evans fdt32_t tag; 8321fdc27aSRafal Jaworowski char name[0]; 8421fdc27aSRafal Jaworowski }; 8521fdc27aSRafal Jaworowski 8621fdc27aSRafal Jaworowski struct fdt_property { 87*6780e684SKyle Evans fdt32_t tag; 88*6780e684SKyle Evans fdt32_t len; 89*6780e684SKyle Evans fdt32_t nameoff; 9021fdc27aSRafal Jaworowski char data[0]; 9121fdc27aSRafal Jaworowski }; 9221fdc27aSRafal Jaworowski 9321fdc27aSRafal Jaworowski #endif /* !__ASSEMBLY */ 9421fdc27aSRafal Jaworowski 9521fdc27aSRafal Jaworowski #define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ 96*6780e684SKyle Evans #define FDT_TAGSIZE sizeof(fdt32_t) 9721fdc27aSRafal Jaworowski 9821fdc27aSRafal Jaworowski #define FDT_BEGIN_NODE 0x1 /* Start node: full name */ 9921fdc27aSRafal Jaworowski #define FDT_END_NODE 0x2 /* End node */ 10021fdc27aSRafal Jaworowski #define FDT_PROP 0x3 /* Property: name off, 10121fdc27aSRafal Jaworowski size, content */ 10221fdc27aSRafal Jaworowski #define FDT_NOP 0x4 /* nop */ 10321fdc27aSRafal Jaworowski #define FDT_END 0x9 10421fdc27aSRafal Jaworowski 105*6780e684SKyle Evans #define FDT_V1_SIZE (7*sizeof(fdt32_t)) 106*6780e684SKyle Evans #define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t)) 107*6780e684SKyle Evans #define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t)) 10821fdc27aSRafal Jaworowski #define FDT_V16_SIZE FDT_V3_SIZE 109*6780e684SKyle Evans #define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t)) 11021fdc27aSRafal Jaworowski 111*6780e684SKyle Evans #endif /* FDT_H */ 112