diff options
author | Chih-Min Chao <chihmin.chao@sifive.com> | 2020-04-23 01:07:14 -0700 |
---|---|---|
committer | Chih-Min Chao <chihmin.chao@sifive.com> | 2020-04-26 22:08:46 -0700 |
commit | 6cb10a7fc49f9068411c617f88e05d1af7f1ef5b (patch) | |
tree | 28fc3d259f313dc3439a1ad63ae0474fc2a598b5 /fdt/libfdt_internal.h | |
parent | 9a919d0866fb5dda4d02e7d49278ff190c311493 (diff) | |
download | riscv-isa-sim-6cb10a7fc49f9068411c617f88e05d1af7f1ef5b.zip riscv-isa-sim-6cb10a7fc49f9068411c617f88e05d1af7f1ef5b.tar.gz riscv-isa-sim-6cb10a7fc49f9068411c617f88e05d1af7f1ef5b.tar.bz2 |
fdt: import fdt library from OpenSBI
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Diffstat (limited to 'fdt/libfdt_internal.h')
-rw-r--r-- | fdt/libfdt_internal.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/fdt/libfdt_internal.h b/fdt/libfdt_internal.h new file mode 100644 index 0000000..741eeb3 --- /dev/null +++ b/fdt/libfdt_internal.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */ +#ifndef LIBFDT_INTERNAL_H +#define LIBFDT_INTERNAL_H +/* + * libfdt - Flat Device Tree manipulation + * Copyright (C) 2006 David Gibson, IBM Corporation. + */ +#include <fdt.h> + +#define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) +#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE)) + +int fdt_ro_probe_(const void *fdt); +#define FDT_RO_PROBE(fdt) \ + { \ + int totalsize_; \ + if ((totalsize_ = fdt_ro_probe_(fdt)) < 0) \ + return totalsize_; \ + } + +int fdt_check_node_offset_(const void *fdt, int offset); +int fdt_check_prop_offset_(const void *fdt, int offset); +const char *fdt_find_string_(const char *strtab, int tabsize, const char *s); +int fdt_node_end_offset_(void *fdt, int nodeoffset); + +static inline const void *fdt_offset_ptr_(const void *fdt, int offset) +{ + return (const char *)fdt + fdt_off_dt_struct(fdt) + offset; +} + +static inline void *fdt_offset_ptr_w_(void *fdt, int offset) +{ + return (void *)(uintptr_t)fdt_offset_ptr_(fdt, offset); +} + +static inline const struct fdt_reserve_entry *fdt_mem_rsv_(const void *fdt, int n) +{ + const struct fdt_reserve_entry *rsv_table = + (const struct fdt_reserve_entry *) + ((const char *)fdt + fdt_off_mem_rsvmap(fdt)); + + return rsv_table + n; +} +static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n) +{ + return (void *)(uintptr_t)fdt_mem_rsv_(fdt, n); +} + +#define FDT_SW_MAGIC (~FDT_MAGIC) + +#endif /* LIBFDT_INTERNAL_H */ |