David Gibson | 3da0f9a | 2006-11-27 16:21:28 +1100 | [diff] [blame] | 1 | #ifndef _LIBFDT_INTERNAL_H |
| 2 | #define _LIBFDT_INTERNAL_H |
| 3 | /* |
| 4 | * libfdt - Flat Device Tree manipulation |
| 5 | * Copyright (C) 2006 David Gibson, IBM Corporation. |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public License |
| 9 | * as published by the Free Software Foundation; either version 2.1 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | #include <fdt.h> |
| 22 | |
| 23 | #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) |
| 24 | #define PALIGN(p, a) ((void *)ALIGN((unsigned long)(p), (a))) |
| 25 | |
| 26 | #define memeq(p, q, n) (memcmp((p), (q), (n)) == 0) |
| 27 | #define streq(p, q) (strcmp((p), (q)) == 0) |
| 28 | |
David Gibson | 73d6092 | 2006-12-15 15:12:47 +1100 | [diff] [blame^] | 29 | int _fdt_check_header(const void *fdt); |
| 30 | uint32_t _fdt_next_tag(const void *fdt, int startoffset, int *nextoffset); |
David Gibson | aeddfe2 | 2006-12-01 15:11:58 +1100 | [diff] [blame] | 31 | const char *_fdt_find_string(const char *strtab, int tabsize, const char *s); |
David Gibson | 73d6092 | 2006-12-15 15:12:47 +1100 | [diff] [blame^] | 32 | int _fdt_node_end_offset(void *fdt, int nodeoffset); |
David Gibson | 3da0f9a | 2006-11-27 16:21:28 +1100 | [diff] [blame] | 33 | |
David Gibson | 568b569 | 2006-12-12 15:46:14 +1100 | [diff] [blame] | 34 | static inline void *_fdt_offset_ptr(const struct fdt_header *fdt, int offset) |
| 35 | { |
| 36 | return (void *)fdt + fdt_off_dt_struct(fdt) + offset; |
| 37 | } |
| 38 | |
David Gibson | 3da0f9a | 2006-11-27 16:21:28 +1100 | [diff] [blame] | 39 | #define OFFSET_ERROR(code) -(code) |
David Gibson | 1a765f5 | 2006-12-07 15:24:26 +1100 | [diff] [blame] | 40 | #define PTR_ERROR(code) (void *)(-(long)(code)) |
David Gibson | 3da0f9a | 2006-11-27 16:21:28 +1100 | [diff] [blame] | 41 | |
David Gibson | 063693a | 2006-11-29 16:45:46 +1100 | [diff] [blame] | 42 | #define SW_MAGIC (~FDT_MAGIC) |
David Gibson | 3da0f9a | 2006-11-27 16:21:28 +1100 | [diff] [blame] | 43 | |
| 44 | #endif /* _LIBFDT_INTERNAL_H */ |