Path: blob/master/scripts/dtc/libfdt/libfdt_internal.h
10818 views
#ifndef _LIBFDT_INTERNAL_H1#define _LIBFDT_INTERNAL_H2/*3* libfdt - Flat Device Tree manipulation4* Copyright (C) 2006 David Gibson, IBM Corporation.5*6* libfdt is dual licensed: you can use it either under the terms of7* the GPL, or the BSD license, at your option.8*9* a) This library is free software; you can redistribute it and/or10* modify it under the terms of the GNU General Public License as11* published by the Free Software Foundation; either version 2 of the12* License, or (at your option) any later version.13*14* This library is distributed in the hope that it will be useful,15* but WITHOUT ANY WARRANTY; without even the implied warranty of16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17* GNU General Public License for more details.18*19* You should have received a copy of the GNU General Public20* License along with this library; if not, write to the Free21* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,22* MA 02110-1301 USA23*24* Alternatively,25*26* b) Redistribution and use in source and binary forms, with or27* without modification, are permitted provided that the following28* conditions are met:29*30* 1. Redistributions of source code must retain the above31* copyright notice, this list of conditions and the following32* disclaimer.33* 2. Redistributions in binary form must reproduce the above34* copyright notice, this list of conditions and the following35* disclaimer in the documentation and/or other materials36* provided with the distribution.37*38* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND39* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,40* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF41* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE42* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR43* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,44* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT45* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;46* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)47* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN48* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR49* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,50* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.51*/52#include <fdt.h>5354#define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))55#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))5657#define FDT_CHECK_HEADER(fdt) \58{ \59int err; \60if ((err = fdt_check_header(fdt)) != 0) \61return err; \62}6364uint32_t _fdt_next_tag(const void *fdt, int startoffset, int *nextoffset);65int _fdt_check_node_offset(const void *fdt, int offset);66const char *_fdt_find_string(const char *strtab, int tabsize, const char *s);67int _fdt_node_end_offset(void *fdt, int nodeoffset);6869static inline const void *_fdt_offset_ptr(const void *fdt, int offset)70{71return (const char *)fdt + fdt_off_dt_struct(fdt) + offset;72}7374static inline void *_fdt_offset_ptr_w(void *fdt, int offset)75{76return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset);77}7879static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n)80{81const struct fdt_reserve_entry *rsv_table =82(const struct fdt_reserve_entry *)83((const char *)fdt + fdt_off_mem_rsvmap(fdt));8485return rsv_table + n;86}87static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n)88{89return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n);90}9192#define FDT_SW_MAGIC (~FDT_MAGIC)9394#endif /* _LIBFDT_INTERNAL_H */959697