mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
libfdt: Internally perform potentially unaligned loads
Commits6dcb8ba4
"libfdt: Add helpers for accessing unaligned words" introduced changes to support unaligned reads for ARM platforms and11738cf01f
"libfdt: Don't use memcpy to handle unaligned reads on ARM" improved the performance of these helpers. On further discussion, while there are potential cases where we could be used on platforms that do not fixup unaligned reads for us, making this choice the default is very expensive in terms of binary size and access time. To address this, introduce and use new fdt{32,64}_ld_ functions that call fdt{32,64}_to_cpu() as was done prior to the above mentioned commits. Leave the existing load functions as unaligned-safe and include comments in both cases. Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Tom Rini <trini@konsulko.com> Message-Id: <20201211022736.31657-1-trini@konsulko.com> Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
bab85e48a6
commit
a7c4040993
3 changed files with 32 additions and 15 deletions
|
@ -46,6 +46,25 @@ static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n)
|
|||
return (void *)(uintptr_t)fdt_mem_rsv_(fdt, n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal helpers to access tructural elements of the device tree blob
|
||||
* (rather than for exaple reading integers from within property values). We
|
||||
* assume that we are either given a naturally aligned address for the platform
|
||||
* or if we are not, we are on a platform where unaligned memory reads will be
|
||||
* handled in a graceful manner. If this is not the case there are _unaligned
|
||||
* versions of these functions that follow and can be used.
|
||||
*
|
||||
*/
|
||||
static inline uint32_t fdt32_ld_(const fdt32_t *p)
|
||||
{
|
||||
return fdt32_to_cpu(*p);
|
||||
}
|
||||
|
||||
static inline uint64_t fdt64_ld_(const fdt64_t *p)
|
||||
{
|
||||
return fdt64_to_cpu(*p);
|
||||
}
|
||||
|
||||
#define FDT_SW_MAGIC (~FDT_MAGIC)
|
||||
|
||||
/**********************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue