diff options
Diffstat (limited to 'arch/arm/cpu/mmu-common.c')
-rw-r--r-- | arch/arm/cpu/mmu-common.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/arch/arm/cpu/mmu-common.c b/arch/arm/cpu/mmu-common.c index 5cc5138cfa..aeaf6c269d 100644 --- a/arch/arm/cpu/mmu-common.c +++ b/arch/arm/cpu/mmu-common.c @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0-only + #define pr_fmt(fmt) "mmu: " fmt @@ -7,17 +9,17 @@ #include <dma.h> #include <mmu.h> #include <asm/system.h> +#include <asm/barebox-arm.h> #include <memory.h> -#include "mmu.h" +#include <zero_page.h> +#include "mmu-common.h" +#include <efi/efi-mode.h> -void dma_sync_single_for_cpu(dma_addr_t address, size_t size, - enum dma_data_direction dir) +void arch_sync_dma_for_cpu(void *vaddr, size_t size, + enum dma_data_direction dir) { - /* - * FIXME: This function needs a device argument to support non 1:1 mappings - */ if (dir != DMA_TO_DEVICE) - dma_inv_range((void *)address, size); + dma_inv_range(vaddr, size); } void *dma_alloc_map(size_t size, dma_addr_t *dma_handle, unsigned flags) @@ -32,7 +34,7 @@ void *dma_alloc_map(size_t size, dma_addr_t *dma_handle, unsigned flags) memset(ret, 0, size); dma_flush_range(ret, size); - arch_remap_range(ret, size, flags); + remap_range(ret, size, flags); return ret; } @@ -49,21 +51,44 @@ void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle) void dma_free_coherent(void *mem, dma_addr_t dma_handle, size_t size) { size = PAGE_ALIGN(size); - arch_remap_range(mem, size, MAP_CACHED); + remap_range(mem, size, MAP_CACHED); free(mem); } +void zero_page_access(void) +{ + remap_range(0x0, PAGE_SIZE, MAP_CACHED); +} + +void zero_page_faulting(void) +{ + remap_range(0x0, PAGE_SIZE, MAP_FAULT); +} + static int mmu_init(void) { - if (list_empty(&memory_banks)) + if (efi_is_payload()) + return 0; + + if (list_empty(&memory_banks)) { + resource_size_t start; + int ret; + /* * If you see this it means you have no memory registered. * This can be done either with arm_add_mem_device() in an * initcall prior to mmu_initcall or via devicetree in the * memory node. */ - panic("MMU: No memory bank found! Cannot continue\n"); + pr_emerg("No memory bank registered. Limping along with initial memory\n"); + + start = arm_mem_membase_get(); + ret = barebox_add_memory_bank("initmem", start, + arm_mem_endmem_get() - start); + if (ret) + panic(""); + } __mmu_init(get_cr() & CR_M); |