libfdt_internal.h revision 328459
1193323Sed#ifndef LIBFDT_INTERNAL_H 2193323Sed#define LIBFDT_INTERNAL_H 3193323Sed/* 4193323Sed * libfdt - Flat Device Tree manipulation 5193323Sed * Copyright (C) 2006 David Gibson, IBM Corporation. 6193323Sed * 7249423Sdim * libfdt is dual licensed: you can use it either under the terms of 8193323Sed * the GPL, or the BSD license, at your option. 9193323Sed * 10193323Sed * a) This library is free software; you can redistribute it and/or 11193323Sed * modify it under the terms of the GNU General Public License as 12193323Sed * published by the Free Software Foundation; either version 2 of the 13193323Sed * License, or (at your option) any later version. 14193323Sed * 15193323Sed * This library is distributed in the hope that it will be useful, 16193323Sed * but WITHOUT ANY WARRANTY; without even the implied warranty of 17193323Sed * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18193323Sed * GNU General Public License for more details. 19193323Sed * 20193323Sed * You should have received a copy of the GNU General Public 21193323Sed * License along with this library; if not, write to the Free 22193323Sed * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 23193323Sed * MA 02110-1301 USA 24193323Sed * 25193323Sed * Alternatively, 26193323Sed * 27193323Sed * b) Redistribution and use in source and binary forms, with or 28193323Sed * without modification, are permitted provided that the following 29193323Sed * conditions are met: 30193323Sed * 31193323Sed * 1. Redistributions of source code must retain the above 32193323Sed * copyright notice, this list of conditions and the following 33193323Sed * disclaimer. 34193323Sed * 2. Redistributions in binary form must reproduce the above 35193323Sed * copyright notice, this list of conditions and the following 36193323Sed * disclaimer in the documentation and/or other materials 37193323Sed * provided with the distribution. 38193323Sed * 39193323Sed * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 40193323Sed * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 41193323Sed * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 42193323Sed * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 43193323Sed * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 44193323Sed * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45193323Sed * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 46193323Sed * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 47193323Sed * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48193323Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 49193323Sed * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 50193323Sed * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 51193323Sed * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 52193323Sed */ 53193323Sed#include <fdt.h> 54193323Sed 55193323Sed#define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) 56193323Sed#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE)) 57193323Sed 58193323Sed#define FDT_CHECK_HEADER(fdt) \ 59193323Sed { \ 60193323Sed int err_; \ 61193323Sed if ((err_ = fdt_check_header(fdt)) != 0) \ 62193323Sed return err_; \ 63193323Sed } 64193323Sed 65193323Sedint fdt_check_node_offset_(const void *fdt, int offset); 66193323Sedint fdt_check_prop_offset_(const void *fdt, int offset); 67193323Sedconst char *fdt_find_string_(const char *strtab, int tabsize, const char *s); 68198090Srdivackyint fdt_node_end_offset_(void *fdt, int nodeoffset); 69234353Sdim 70249423Sdimstatic inline const void *fdt_offset_ptr_(const void *fdt, int offset) 71{ 72 return (const char *)fdt + fdt_off_dt_struct(fdt) + offset; 73} 74 75static inline void *fdt_offset_ptr_w_(void *fdt, int offset) 76{ 77 return (void *)(uintptr_t)fdt_offset_ptr_(fdt, offset); 78} 79 80static inline const struct fdt_reserve_entry *fdt_mem_rsv_(const void *fdt, int n) 81{ 82 const struct fdt_reserve_entry *rsv_table = 83 (const struct fdt_reserve_entry *) 84 ((const char *)fdt + fdt_off_mem_rsvmap(fdt)); 85 86 return rsv_table + n; 87} 88static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n) 89{ 90 return (void *)(uintptr_t)fdt_mem_rsv_(fdt, n); 91} 92 93#define FDT_SW_MAGIC (~FDT_MAGIC) 94 95#endif /* LIBFDT_INTERNAL_H */ 96