Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:39

0001 /*
0002  * SPDX-License-Identifier: BSD-2-Clause
0003  *
0004  * Copyright (C) 2019 DornerWorks
0005  * Written by Jeff Kubascik <jeff.kubascik@dornerworks.com>
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0026  * POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #define ARM_CP15_TEXT_SECTION BSP_START_TEXT_SECTION
0030 
0031 #include <bsp.h>
0032 #include <bsp/start.h>
0033 #include <bsp/arm-cp15-start.h>
0034 #include <bsp/arm-a9mpcore-start.h>
0035 
0036 BSP_START_DATA_SECTION static const arm_cp15_start_section_config
0037 xen_bsp_mmu_config_table[] = {
0038   ARMV7_CP15_START_DEFAULT_SECTIONS,
0039   {
0040     .begin = BSP_ARM_GIC_DIST_BASE,
0041     .end = BSP_ARM_GIC_DIST_BASE + BSP_ARM_GIC_DIST_LENGTH,
0042     .flags = ARMV7_MMU_DEVICE
0043   }, {
0044     .begin = BSP_ARM_GIC_CPUIF_BASE,
0045     .end = BSP_ARM_GIC_CPUIF_BASE + BSP_ARM_GIC_CPUIF_LENGTH,
0046     .flags = ARMV7_MMU_DEVICE
0047   }, {
0048     .begin = BSP_XEN_VPL011_BASE,
0049     .end = BSP_XEN_VPL011_BASE + BSP_XEN_VPL011_LENGTH,
0050     .flags = ARMV7_MMU_DEVICE
0051   }
0052 };
0053 
0054 /*
0055  * Make weak and let the user override.
0056  */
0057 BSP_START_TEXT_SECTION void bsp_xen_setup_mmu_and_cache(void) __attribute__ ((weak));
0058 
0059 BSP_START_TEXT_SECTION void bsp_xen_setup_mmu_and_cache(void)
0060 {
0061   uint32_t ctrl = arm_cp15_start_setup_mmu_and_cache(
0062     ARM_CP15_CTRL_TRE | ARM_CP15_CTRL_A,
0063     ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
0064   );
0065 
0066   arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
0067     ctrl,
0068     (uint32_t *) bsp_translation_table_base,
0069     ARM_MMU_DEFAULT_CLIENT_DOMAIN,
0070     &xen_bsp_mmu_config_table[0],
0071     RTEMS_ARRAY_SIZE(xen_bsp_mmu_config_table)
0072   );
0073 }