riscv: support standalone applications on RV64I systems
[oweals/u-boot.git] / cmd / elf.c
index 22cba58c68c07426988f5557bc8e21569d7d7858..7bad1f80d42f9b23fec595871dc3cb1794bee55c 100644 (file)
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -115,7 +115,10 @@ static unsigned long load_elf64_image_shdr(unsigned long addr)
                        memcpy((void *)(uintptr_t)shdr->sh_addr,
                               (const void *)image, shdr->sh_size);
                }
-               flush_cache((ulong)shdr->sh_addr, shdr->sh_size);
+               flush_cache(rounddown(shdr->sh_addr, ARCH_DMA_MINALIGN),
+                           roundup((shdr->sh_addr + shdr->sh_size),
+                                    ARCH_DMA_MINALIGN) -
+                                   rounddown(shdr->sh_addr, ARCH_DMA_MINALIGN));
        }
 
        if (ehdr->e_machine == EM_PPC64 && (ehdr->e_flags &
@@ -216,7 +219,10 @@ static unsigned long load_elf_image_shdr(unsigned long addr)
                        memcpy((void *)(uintptr_t)shdr->sh_addr,
                               (const void *)image, shdr->sh_size);
                }
-               flush_cache(shdr->sh_addr, shdr->sh_size);
+               flush_cache(rounddown(shdr->sh_addr, ARCH_DMA_MINALIGN),
+                           roundup((shdr->sh_addr + shdr->sh_size),
+                                   ARCH_DMA_MINALIGN) -
+                           rounddown(shdr->sh_addr, ARCH_DMA_MINALIGN));
        }
 
        return ehdr->e_entry;