diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/aarch64/cache_helpers.S | 48 | ||||
-rw-r--r-- | lib/aarch64/misc_helpers.S | 195 | ||||
-rw-r--r-- | lib/aarch64/sysreg_helpers.S | 782 | ||||
-rw-r--r-- | lib/aarch64/tlb_helpers.S | 73 | ||||
-rw-r--r-- | lib/aarch64/xlat_tables.c | 56 |
5 files changed, 54 insertions, 1100 deletions
diff --git a/lib/aarch64/cache_helpers.S b/lib/aarch64/cache_helpers.S index a5b918c3..1c805504 100644 --- a/lib/aarch64/cache_helpers.S +++ b/lib/aarch64/cache_helpers.S @@ -31,59 +31,11 @@ #include <arch.h> #include <asm_macros.S> - .globl dcisw - .globl dccisw - .globl dccsw - .globl dccvac - .globl dcivac - .globl dccivac - .globl dccvau - .globl dczva .globl flush_dcache_range .globl inv_dcache_range .globl dcsw_op_louis .globl dcsw_op_all -func dcisw - dc isw, x0 - ret - - -func dccisw - dc cisw, x0 - ret - - -func dccsw - dc csw, x0 - ret - - -func dccvac - dc cvac, x0 - ret - - -func dcivac - dc ivac, x0 - ret - - -func dccivac - dc civac, x0 - ret - - -func dccvau - dc cvau, x0 - ret - - -func dczva - dc zva, x0 - ret - - /* ------------------------------------------ * Clean+Invalidate from base address till * size. 'x0' = addr, 'x1' = size diff --git a/lib/aarch64/misc_helpers.S b/lib/aarch64/misc_helpers.S index e7ee015f..439ca285 100644 --- a/lib/aarch64/misc_helpers.S +++ b/lib/aarch64/misc_helpers.S @@ -31,44 +31,8 @@ #include <arch.h> #include <asm_macros.S> - .globl enable_irq - .globl disable_irq - - .globl enable_fiq - .globl disable_fiq - - .globl enable_serror - .globl disable_serror - - .globl enable_debug_exceptions - .globl disable_debug_exceptions - - .globl read_daif - .globl write_daif - - .globl read_spsr_el1 - .globl read_spsr_el2 - .globl read_spsr_el3 - - .globl write_spsr_el1 - .globl write_spsr_el2 - .globl write_spsr_el3 - - .globl read_elr_el1 - .globl read_elr_el2 - .globl read_elr_el3 - - .globl write_elr_el1 - .globl write_elr_el2 - .globl write_elr_el3 - .globl get_afflvl_shift .globl mpidr_mask_lower_afflvls - .globl dsb - .globl isb - .globl sev - .globl wfe - .globl wfi .globl eret .globl smc @@ -78,6 +42,10 @@ .globl disable_mmu_el3 .globl disable_mmu_icache_el3 +#if SUPPORT_VFP + .globl enable_vfp +#endif + func get_afflvl_shift cmp x0, #3 @@ -95,144 +63,6 @@ func mpidr_mask_lower_afflvls lsl x0, x0, x2 ret - /* ----------------------------------------------------- - * Asynchronous exception manipulation accessors - * ----------------------------------------------------- - */ -func enable_irq - msr daifclr, #DAIF_IRQ_BIT - ret - - -func enable_fiq - msr daifclr, #DAIF_FIQ_BIT - ret - - -func enable_serror - msr daifclr, #DAIF_ABT_BIT - ret - - -func enable_debug_exceptions - msr daifclr, #DAIF_DBG_BIT - ret - - -func disable_irq - msr daifset, #DAIF_IRQ_BIT - ret - - -func disable_fiq - msr daifset, #DAIF_FIQ_BIT - ret - - -func disable_serror - msr daifset, #DAIF_ABT_BIT - ret - - -func disable_debug_exceptions - msr daifset, #DAIF_DBG_BIT - ret - - -func read_daif - mrs x0, daif - ret - - -func write_daif - msr daif, x0 - ret - - -func read_spsr_el1 - mrs x0, spsr_el1 - ret - - -func read_spsr_el2 - mrs x0, spsr_el2 - ret - - -func read_spsr_el3 - mrs x0, spsr_el3 - ret - - -func write_spsr_el1 - msr spsr_el1, x0 - ret - - -func write_spsr_el2 - msr spsr_el2, x0 - ret - - -func write_spsr_el3 - msr spsr_el3, x0 - ret - - -func read_elr_el1 - mrs x0, elr_el1 - ret - - -func read_elr_el2 - mrs x0, elr_el2 - ret - - -func read_elr_el3 - mrs x0, elr_el3 - ret - - -func write_elr_el1 - msr elr_el1, x0 - ret - - -func write_elr_el2 - msr elr_el2, x0 - ret - - -func write_elr_el3 - msr elr_el3, x0 - ret - - -func dsb - dsb sy - ret - - -func isb - isb - ret - - -func sev - sev - ret - - -func wfe - wfe - ret - - -func wfi - wfi - ret - func eret eret @@ -315,3 +145,20 @@ func disable_mmu_icache_el3 mov x1, #(SCTLR_M_BIT | SCTLR_C_BIT | SCTLR_I_BIT) b do_disable_mmu + +/* --------------------------------------------------------------------------- + * Enable the use of VFP at EL3 + * --------------------------------------------------------------------------- + */ +#if SUPPORT_VFP +func enable_vfp + mrs x0, cpacr_el1 + orr x0, x0, #CPACR_VFP_BITS + msr cpacr_el1, x0 + mrs x0, cptr_el3 + mov x1, #AARCH64_CPTR_TFP + bic x0, x0, x1 + msr cptr_el3, x0 + isb + ret +#endif diff --git a/lib/aarch64/sysreg_helpers.S b/lib/aarch64/sysreg_helpers.S deleted file mode 100644 index 925e93e3..00000000 --- a/lib/aarch64/sysreg_helpers.S +++ /dev/null @@ -1,782 +0,0 @@ -/* - * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include <arch.h> -#include <asm_macros.S> - - .globl read_vbar_el1 - .globl read_vbar_el2 - .globl read_vbar_el3 - .globl write_vbar_el1 - .globl write_vbar_el2 - .globl write_vbar_el3 - - .globl read_sctlr_el1 - .globl read_sctlr_el2 - .globl read_sctlr_el3 - .globl write_sctlr_el1 - .globl write_sctlr_el2 - .globl write_sctlr_el3 - - .globl read_actlr_el1 - .globl read_actlr_el2 - .globl read_actlr_el3 - .globl write_actlr_el1 - .globl write_actlr_el2 - .globl write_actlr_el3 - - .globl read_esr_el1 - .globl read_esr_el2 - .globl read_esr_el3 - .globl write_esr_el1 - .globl write_esr_el2 - .globl write_esr_el3 - - .globl read_afsr0_el1 - .globl read_afsr0_el2 - .globl read_afsr0_el3 - .globl write_afsr0_el1 - .globl write_afsr0_el2 - .globl write_afsr0_el3 - - .globl read_afsr1_el1 - .globl read_afsr1_el2 - .globl read_afsr1_el3 - .globl write_afsr1_el1 - .globl write_afsr1_el2 - .globl write_afsr1_el3 - - .globl read_far_el1 - .globl read_far_el2 - .globl read_far_el3 - .globl write_far_el1 - .globl write_far_el2 - .globl write_far_el3 - - .globl read_mair_el1 - .globl read_mair_el2 - .globl read_mair_el3 - .globl write_mair_el1 - .globl write_mair_el2 - .globl write_mair_el3 - - .globl read_amair_el1 - .globl read_amair_el2 - .globl read_amair_el3 - .globl write_amair_el1 - .globl write_amair_el2 - .globl write_amair_el3 - - .globl read_rvbar_el1 - .globl read_rvbar_el2 - .globl read_rvbar_el3 - - .globl read_rmr_el1 - .globl read_rmr_el2 - .globl read_rmr_el3 - .globl write_rmr_el1 - .globl write_rmr_el2 - .globl write_rmr_el3 - - .globl read_tcr_el1 - .globl read_tcr_el2 - .globl read_tcr_el3 - .globl write_tcr_el1 - .globl write_tcr_el2 - .globl write_tcr_el3 - - .globl read_cptr_el2 - .globl read_cptr_el3 - .globl write_cptr_el2 - .globl write_cptr_el3 - - .globl read_ttbr0_el1 - .globl read_ttbr0_el2 - .globl read_ttbr0_el3 - .globl write_ttbr0_el1 - .globl write_ttbr0_el2 - .globl write_ttbr0_el3 - - .globl read_ttbr1_el1 - .globl write_ttbr1_el1 - - .globl read_cpacr - .globl write_cpacr - - .globl read_cntfrq - .globl write_cntfrq - - .globl read_cpuectlr - .globl write_cpuectlr - - .globl read_cnthctl_el2 - .globl write_cnthctl_el2 - - .globl read_cntfrq_el0 - .globl write_cntfrq_el0 - - .globl read_cntps_ctl_el1 - .globl write_cntps_ctl_el1 - - .globl read_cntps_cval_el1 - .globl write_cntps_cval_el1 - - .globl read_cntps_tval_el1 - .globl write_cntps_tval_el1 - - .globl read_scr - .globl write_scr - - .globl read_hcr - .globl write_hcr - - .globl read_midr - .globl read_mpidr - - .globl read_cntpct_el0 - .globl read_current_el - .globl read_id_pfr1_el1 - .globl read_id_aa64pfr0_el1 - - .globl write_tpidr_el3 - .globl read_tpidr_el3 - -#if SUPPORT_VFP - .globl enable_vfp -#endif - - -func read_current_el - mrs x0, CurrentEl - ret - - -func read_id_pfr1_el1 - mrs x0, id_pfr1_el1 - ret - - -func read_id_aa64pfr0_el1 - mrs x0, id_aa64pfr0_el1 - ret - - - /* ----------------------------------------------------- - * VBAR accessors - * ----------------------------------------------------- - */ -func read_vbar_el1 - mrs x0, vbar_el1 - ret - - -func read_vbar_el2 - mrs x0, vbar_el2 - ret - - -func read_vbar_el3 - mrs x0, vbar_el3 - ret - - -func write_vbar_el1 - msr vbar_el1, x0 - ret - - -func write_vbar_el2 - msr vbar_el2, x0 - ret - - -func write_vbar_el3 - msr vbar_el3, x0 - ret - - - /* ----------------------------------------------------- - * AFSR0 accessors - * ----------------------------------------------------- - */ -func read_afsr0_el1 - mrs x0, afsr0_el1 - ret - - -func read_afsr0_el2 - mrs x0, afsr0_el2 - ret - - -func read_afsr0_el3 - mrs x0, afsr0_el3 - ret - - -func write_afsr0_el1 - msr afsr0_el1, x0 - ret - - -func write_afsr0_el2 - msr afsr0_el2, x0 - ret - - -func write_afsr0_el3 - msr afsr0_el3, x0 - ret - - - /* ----------------------------------------------------- - * FAR accessors - * ----------------------------------------------------- - */ -func read_far_el1 - mrs x0, far_el1 - ret - - -func read_far_el2 - mrs x0, far_el2 - ret - - -func read_far_el3 - mrs x0, far_el3 - ret - - -func write_far_el1 - msr far_el1, x0 - ret - - -func write_far_el2 - msr far_el2, x0 - ret - - -func write_far_el3 - msr far_el3, x0 - ret - - - /* ----------------------------------------------------- - * MAIR accessors - * ----------------------------------------------------- - */ -func read_mair_el1 - mrs x0, mair_el1 - ret - - -func read_mair_el2 - mrs x0, mair_el2 - ret - - -func read_mair_el3 - mrs x0, mair_el3 - ret - - -func write_mair_el1 - msr mair_el1, x0 - ret - - -func write_mair_el2 - msr mair_el2, x0 - ret - - -func write_mair_el3 - msr mair_el3, x0 - ret - - - /* ----------------------------------------------------- - * AMAIR accessors - * ----------------------------------------------------- - */ -func read_amair_el1 - mrs x0, amair_el1 - ret - - -func read_amair_el2 - mrs x0, amair_el2 - ret - - -func read_amair_el3 - mrs x0, amair_el3 - ret - - -func write_amair_el1 - msr amair_el1, x0 - ret - - -func write_amair_el2 - msr amair_el2, x0 - ret - - -func write_amair_el3 - msr amair_el3, x0 - ret - - - /* ----------------------------------------------------- - * RVBAR accessors - * ----------------------------------------------------- - */ -func read_rvbar_el1 - mrs x0, rvbar_el1 - ret - - -func read_rvbar_el2 - mrs x0, rvbar_el2 - ret - - -func read_rvbar_el3 - mrs x0, rvbar_el3 - ret - - - /* ----------------------------------------------------- - * RMR accessors - * ----------------------------------------------------- - */ -func read_rmr_el1 - mrs x0, rmr_el1 - ret - - -func read_rmr_el2 - mrs x0, rmr_el2 - ret - - -func read_rmr_el3 - mrs x0, rmr_el3 - ret - - -func write_rmr_el1 - msr rmr_el1, x0 - ret - - -func write_rmr_el2 - msr rmr_el2, x0 - ret - - -func write_rmr_el3 - msr rmr_el3, x0 - ret - - - /* ----------------------------------------------------- - * AFSR1 accessors - * ----------------------------------------------------- - */ -func read_afsr1_el1 - mrs x0, afsr1_el1 - ret - - -func read_afsr1_el2 - mrs x0, afsr1_el2 - ret - - -func read_afsr1_el3 - mrs x0, afsr1_el3 - ret - - -func write_afsr1_el1 - msr afsr1_el1, x0 - ret - - -func write_afsr1_el2 - msr afsr1_el2, x0 - ret - - -func write_afsr1_el3 - msr afsr1_el3, x0 - ret - - - /* ----------------------------------------------------- - * SCTLR accessors - * ----------------------------------------------------- - */ -func read_sctlr_el1 - mrs x0, sctlr_el1 - ret - - -func read_sctlr_el2 - mrs x0, sctlr_el2 - ret - - -func read_sctlr_el3 - mrs x0, sctlr_el3 - ret - - -func write_sctlr_el1 - msr sctlr_el1, x0 - ret - - -func write_sctlr_el2 - msr sctlr_el2, x0 - ret - - -func write_sctlr_el3 - msr sctlr_el3, x0 - ret - - - /* ----------------------------------------------------- - * ACTLR accessors - * ----------------------------------------------------- - */ -func read_actlr_el1 - mrs x0, actlr_el1 - ret - - -func read_actlr_el2 - mrs x0, actlr_el2 - ret - - -func read_actlr_el3 - mrs x0, actlr_el3 - ret - - -func write_actlr_el1 - msr actlr_el1, x0 - ret - - -func write_actlr_el2 - msr actlr_el2, x0 - ret - - -func write_actlr_el3 - msr actlr_el3, x0 - ret - - - /* ----------------------------------------------------- - * ESR accessors - * ----------------------------------------------------- - */ -func read_esr_el1 - mrs x0, esr_el1 - ret - - -func read_esr_el2 - mrs x0, esr_el2 - ret - - -func read_esr_el3 - mrs x0, esr_el3 - ret - - -func write_esr_el1 - msr esr_el1, x0 - ret - - -func write_esr_el2 - msr esr_el2, x0 - ret - - -func write_esr_el3 - msr esr_el3, x0 - ret - - - /* ----------------------------------------------------- - * TCR accessors - * ----------------------------------------------------- - */ -func read_tcr_el1 - mrs x0, tcr_el1 - ret - - -func read_tcr_el2 - mrs x0, tcr_el2 - ret - - -func read_tcr_el3 - mrs x0, tcr_el3 - ret - - -func write_tcr_el1 - msr tcr_el1, x0 - ret - - -func write_tcr_el2 - msr tcr_el2, x0 - ret - - -func write_tcr_el3 - msr tcr_el3, x0 - ret - - - /* ----------------------------------------------------- - * CPTR accessors - * ----------------------------------------------------- - */ -func read_cptr_el2 - mrs x0, cptr_el2 - ret - - -func read_cptr_el3 - mrs x0, cptr_el3 - ret - - -func write_cptr_el2 - msr cptr_el2, x0 - ret - - -func write_cptr_el3 - msr cptr_el3, x0 - ret - - - /* ----------------------------------------------------- - * TTBR0 accessors - * ----------------------------------------------------- - */ -func read_ttbr0_el1 - mrs x0, ttbr0_el1 - ret - - -func read_ttbr0_el2 - mrs x0, ttbr0_el2 - ret - - -func read_ttbr0_el3 - mrs x0, ttbr0_el3 - ret - - -func write_ttbr0_el1 - msr ttbr0_el1, x0 - ret - - -func write_ttbr0_el2 - msr ttbr0_el2, x0 - ret - - -func write_ttbr0_el3 - msr ttbr0_el3, x0 - ret - - - /* ----------------------------------------------------- - * TTBR1 accessors - * ----------------------------------------------------- - */ -func read_ttbr1_el1 - mrs x0, ttbr1_el1 - ret - - -func write_ttbr1_el1 - msr ttbr1_el1, x0 - ret - - -func read_hcr - mrs x0, hcr_el2 - ret - - -func write_hcr - msr hcr_el2, x0 - ret - - -func read_cpacr - mrs x0, cpacr_el1 - ret - - -func write_cpacr - msr cpacr_el1, x0 - ret - - -func read_cntfrq_el0 - mrs x0, cntfrq_el0 - ret - - -func write_cntfrq_el0 - msr cntfrq_el0, x0 - ret - -func read_cntps_ctl_el1 - mrs x0, cntps_ctl_el1 - ret - -func write_cntps_ctl_el1 - msr cntps_ctl_el1, x0 - ret - -func read_cntps_cval_el1 - mrs x0, cntps_cval_el1 - ret - -func write_cntps_cval_el1 - msr cntps_cval_el1, x0 - ret - -func read_cntps_tval_el1 - mrs x0, cntps_tval_el1 - ret - -func write_cntps_tval_el1 - msr cntps_tval_el1, x0 - ret - -func read_cntpct_el0 - mrs x0, cntpct_el0 - ret - -func read_cpuectlr - mrs x0, CPUECTLR_EL1 - ret - - -func write_cpuectlr - msr CPUECTLR_EL1, x0 - ret - - -func read_cnthctl_el2 - mrs x0, cnthctl_el2 - ret - - -func write_cnthctl_el2 - msr cnthctl_el2, x0 - ret - - -func read_cntfrq - mrs x0, cntfrq_el0 - ret - - -func write_cntfrq - msr cntfrq_el0, x0 - ret - - -func write_scr - msr scr_el3, x0 - ret - - -func read_scr - mrs x0, scr_el3 - ret - - -func read_midr - mrs x0, midr_el1 - ret - - -func read_mpidr - mrs x0, mpidr_el1 - ret - -func write_tpidr_el3 - msr tpidr_el3, x0 - ret - -func read_tpidr_el3 - mrs x0, tpidr_el3 - ret - -#if SUPPORT_VFP -func enable_vfp - mrs x0, cpacr_el1 - orr x0, x0, #CPACR_VFP_BITS - msr cpacr_el1, x0 - mrs x0, cptr_el3 - mov x1, #AARCH64_CPTR_TFP - bic x0, x0, x1 - msr cptr_el3, x0 - isb - ret - -#endif diff --git a/lib/aarch64/tlb_helpers.S b/lib/aarch64/tlb_helpers.S deleted file mode 100644 index 8dfae12e..00000000 --- a/lib/aarch64/tlb_helpers.S +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include <asm_macros.S> - - .globl tlbialle1 - .globl tlbialle1is - .globl tlbialle2 - .globl tlbialle2is - .globl tlbialle3 - .globl tlbialle3is - .globl tlbivmalle1 - - -func tlbialle1 - tlbi alle1 - ret - - -func tlbialle1is - tlbi alle1is - ret - - -func tlbialle2 - tlbi alle2 - ret - - -func tlbialle2is - tlbi alle2is - ret - - -func tlbialle3 - tlbi alle3 - ret - - -func tlbialle3is - tlbi alle3is - ret - -func tlbivmalle1 - tlbi vmalle1 - ret diff --git a/lib/aarch64/xlat_tables.c b/lib/aarch64/xlat_tables.c index 29b81dbd..1b99cc85 100644 --- a/lib/aarch64/xlat_tables.c +++ b/lib/aarch64/xlat_tables.c @@ -72,26 +72,29 @@ static void print_mmap(void) debug_print("mmap:\n"); mmap_region_t *mm = mmap; while (mm->size) { - debug_print(" %010lx %10lx %x\n", mm->base, mm->size, mm->attr); + debug_print(" %010lx %010lx %10lx %x\n", mm->base_va, + mm->base_pa, mm->size, mm->attr); ++mm; }; debug_print("\n"); #endif } -void mmap_add_region(unsigned long base, unsigned long size, unsigned attr) +void mmap_add_region(unsigned long base_pa, unsigned long base_va, + unsigned long size, unsigned attr) { mmap_region_t *mm = mmap; mmap_region_t *mm_last = mm + sizeof(mmap) / sizeof(mmap[0]) - 1; - assert(IS_PAGE_ALIGNED(base)); + assert(IS_PAGE_ALIGNED(base_pa)); + assert(IS_PAGE_ALIGNED(base_va)); assert(IS_PAGE_ALIGNED(size)); if (!size) return; /* Find correct place in mmap to insert new region */ - while (mm->base < base && mm->size) + while (mm->base_va < base_va && mm->size) ++mm; /* Make room for new region by moving other regions up by one place */ @@ -100,7 +103,8 @@ void mmap_add_region(unsigned long base, unsigned long size, unsigned attr) /* Check we haven't lost the empty sentinal from the end of the array */ assert(mm_last->size == 0); - mm->base = base; + mm->base_pa = base_pa; + mm->base_va = base_va; mm->size = size; mm->attr = attr; } @@ -108,15 +112,15 @@ void mmap_add_region(unsigned long base, unsigned long size, unsigned attr) void mmap_add(const mmap_region_t *mm) { while (mm->size) { - mmap_add_region(mm->base, mm->size, mm->attr); + mmap_add_region(mm->base_pa, mm->base_va, mm->size, mm->attr); ++mm; } } -static unsigned long mmap_desc(unsigned attr, unsigned long addr, +static unsigned long mmap_desc(unsigned attr, unsigned long addr_pa, unsigned level) { - unsigned long desc = addr; + unsigned long desc = addr_pa; desc |= level == 3 ? TABLE_DESC : BLOCK_DESC; @@ -142,7 +146,7 @@ static unsigned long mmap_desc(unsigned attr, unsigned long addr, return desc; } -static int mmap_region_attr(mmap_region_t *mm, unsigned long base, +static int mmap_region_attr(mmap_region_t *mm, unsigned long base_va, unsigned long size) { int attr = mm->attr; @@ -153,10 +157,10 @@ static int mmap_region_attr(mmap_region_t *mm, unsigned long base, if (!mm->size) return attr; /* Reached end of list */ - if (mm->base >= base + size) + if (mm->base_va >= base_va + size) return attr; /* Next region is after area so end */ - if (mm->base + mm->size <= base) + if (mm->base_va + mm->size <= base_va) continue; /* Next region has already been overtaken */ if ((mm->attr & attr) == attr) @@ -164,12 +168,14 @@ static int mmap_region_attr(mmap_region_t *mm, unsigned long base, attr &= mm->attr; - if (mm->base > base || mm->base + mm->size < base + size) + if (mm->base_va > base_va || + mm->base_va + mm->size < base_va + size) return -1; /* Region doesn't fully cover our area */ } } -static mmap_region_t *init_xlation_table(mmap_region_t *mm, unsigned long base, +static mmap_region_t *init_xlation_table(mmap_region_t *mm, + unsigned long base_va, unsigned long *table, unsigned level) { unsigned level_size_shift = L1_XLAT_ADDRESS_SHIFT - (level - 1) * @@ -184,23 +190,26 @@ static mmap_region_t *init_xlation_table(mmap_region_t *mm, unsigned long base, do { unsigned long desc = UNSET_DESC; - if (mm->base + mm->size <= base) { + if (mm->base_va + mm->size <= base_va) { /* Area now after the region so skip it */ ++mm; continue; } - debug_print(" %010lx %8lx " + 6 - 2 * level, base, level_size); + debug_print(" %010lx %8lx " + 6 - 2 * level, base_va, + level_size); - if (mm->base >= base + level_size) { + if (mm->base_va >= base_va + level_size) { /* Next region is after area so nothing to map yet */ desc = INVALID_DESC; - } else if (mm->base <= base && - mm->base + mm->size >= base + level_size) { + } else if (mm->base_va <= base_va && mm->base_va + mm->size >= + base_va + level_size) { /* Next region covers all of area */ - int attr = mmap_region_attr(mm, base, level_size); + int attr = mmap_region_attr(mm, base_va, level_size); if (attr >= 0) - desc = mmap_desc(attr, base, level); + desc = mmap_desc(attr, + base_va - mm->base_va + mm->base_pa, + level); } /* else Next region only partially covers area, so need */ @@ -211,14 +220,15 @@ static mmap_region_t *init_xlation_table(mmap_region_t *mm, unsigned long base, desc = TABLE_DESC | (unsigned long)new_table; /* Recurse to fill in new table */ - mm = init_xlation_table(mm, base, new_table, level+1); + mm = init_xlation_table(mm, base_va, + new_table, level+1); } debug_print("\n"); *table++ = desc; - base += level_size; - } while (mm->size && (base & level_index_mask)); + base_va += level_size; + } while (mm->size && (base_va & level_index_mask)); return mm; } |