image: android-dt: add dt_for_each_entry() to iterate over all dt entry of DT image
Change-Id: I4db1e1da0d55701798bb8c296dd58e26592ef3c8 Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
parent
c673757f56
commit
bcd21a1f01
|
@ -155,3 +155,20 @@ void android_dt_print_contents(ulong hdr_addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get dt entry count of DT image structure.
|
||||||
|
*
|
||||||
|
* @param hdr_addr Start address of DT image
|
||||||
|
*/
|
||||||
|
int android_dt_get_count(ulong hdr_addr)
|
||||||
|
{
|
||||||
|
const struct dt_table_header *hdr;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
hdr = map_sysmem(hdr_addr, sizeof(*hdr));
|
||||||
|
count = fdt32_to_cpu(hdr->dt_entry_count);
|
||||||
|
unmap_sysmem(hdr);
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
|
@ -13,9 +13,36 @@
|
||||||
bool android_dt_check_header(ulong hdr_addr);
|
bool android_dt_check_header(ulong hdr_addr);
|
||||||
bool android_dt_get_fdt_by_index(ulong hdr_addr, u32 index, ulong *addr,
|
bool android_dt_get_fdt_by_index(ulong hdr_addr, u32 index, ulong *addr,
|
||||||
u32 *size);
|
u32 *size);
|
||||||
|
int android_dt_get_count(ulong hdr_addr);
|
||||||
|
|
||||||
#if !defined(CONFIG_SPL_BUILD)
|
#if !defined(CONFIG_SPL_BUILD)
|
||||||
void android_dt_print_contents(ulong hdr_addr);
|
void android_dt_print_contents(ulong hdr_addr);
|
||||||
#endif
|
#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 */
|
#endif /* IMAGE_ANDROID_DT_H */
|
||||||
|
|
Loading…
Reference in New Issue