hc
2024-05-09 b9d5c334faa47a75f1f28e72d203fc0334e8471d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * (C) Copyright 2018 Linaro Ltd.
 * Sam Protsenko <semen.protsenko@linaro.org>
 *
 * SPDX-License-Identifier:    GPL-2.0+
 */
 
#ifndef IMAGE_ANDROID_DT_H
#define IMAGE_ANDROID_DT_H
 
#include <linux/types.h>
 
bool android_dt_check_header(ulong hdr_addr);
bool android_dt_get_fdt_by_index(ulong hdr_addr, u32 index, ulong *addr,
                u32 *size);
int android_dt_get_count(ulong hdr_addr);
 
#if !defined(CONFIG_SPL_BUILD)
void android_dt_print_contents(ulong hdr_addr);
#endif
 
/**
 * dt_for_each_entry() - iterate over all dt entry of DT image
 *
 * @entry:   struct dt_table_entry pointing to entry address
 * @hdr:     struct dt_table_header pointing to hdr address
 * @idx:     temporary index variant
 *
 * This is a wrapper around a for loop and is used like so:
 *
 *    struct dt_table_header *hdr;
 *    struct dt_table_entry *entry;
 *    int index;
 *
 *    ......
 *
 *    dt_for_each_entry(entry, hdr, index) {
 *        Use entry
 *        ...
 *    }
 *
 */
#define dt_for_each_entry(entry, hdr, idx) \
   for (idx = 0, android_dt_get_fdt_by_index((ulong)hdr, idx, (ulong *)&entry, NULL); \
        idx < android_dt_get_count((ulong)hdr); \
        idx++, android_dt_get_fdt_by_index((ulong)hdr, idx, (ulong *)&entry, NULL))
 
#endif /* IMAGE_ANDROID_DT_H */