source: EcnlProtoTool/trunk/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/mmu_Renesas_RZ_A1.c@ 270

Last change on this file since 270 was 270, checked in by coas-nagasima, 7 years ago

mruby版ECNLプロトタイピング・ツールを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 10.0 KB
Line 
1/**************************************************************************//**
2 * @file mmu_Renesas_RZ_A1.c
3 * @brief MMU Startup File for
4 * mmu_Renesas_RZ_A1 Device Series
5 * @version V1.01
6 * @date 2 Aug 2013
7 *
8 * @note
9 *
10 ******************************************************************************/
11/* Copyright (c) 2011 - 2013 ARM LIMITED
12
13 All rights reserved.
14 Redistribution and use in source and binary forms, with or without
15 modification, are permitted provided that the following conditions are met:
16 - Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
18 - Redistributions in binary form must reproduce the above copyright
19 notice, this list of conditions and the following disclaimer in the
20 documentation and/or other materials provided with the distribution.
21 - Neither the name of ARM nor the names of its contributors may be used
22 to endorse or promote products derived from this software without
23 specific prior written permission.
24 *
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
29 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 POSSIBILITY OF SUCH DAMAGE.
36 ---------------------------------------------------------------------------*/
37
38
39#define Renesas_RZ_A1_SPI_MIO_BASE (0x3fe00000UL) /*!< (SPI_MIO ) Base Address */
40#define Renesas_RZ_A1_BSC_BASE (0x3ff00000UL) /*!< (BSC ) Base Address */
41#define Renesas_RZ_A1_PERIPH_BASE0 (0xe8000000UL) /*!< (PERIPH0 ) Base Address */
42#define Renesas_RZ_A1_PERIPH_BASE1 (0xfcf00000UL) /*!< (PERIPH1 ) Base Address */
43// L1 Cache info and restrictions about architecture of the caches (CCSIR register):
44// Write-Through support *not* available
45// Write-Back support available.
46// Read allocation support available.
47// Write allocation support available.
48
49//Note: You should use the Shareable attribute carefully.
50//For cores without coherency logic (such as SCU) marking a region as shareable forces the processor to not cache that region regardless the inner cache settings.
51//CA9-RTX uses LDREX/STREX instructions relying on Local monitors. Local monitors will be used only when the region gets cached, regions that are not cached will use the Global Monitor.
52//Some A9 implementations does not include Global Monitors, so wrongly setting the attribute Shareable may cause STREX to fail.
53
54//Recall: When the Shareable attribute is applied to a memory region that is not Write-Back, Normal memory, data held in this region is treated as Non-cacheable.
55//When SMP bit = 0, Inner WB/WA Cacheable Shareable attributes are treated as Non-cacheable.
56//When SMP bit = 1, Inner WB/WA Cacheable Shareable attributes are treated as Cacheable.
57
58
59//Following MMU configuration is expected
60//SCTLR.AFE == 1 (Simplified access permissions model - AP[2:1] define access permissions, AP[0] is an access flag)
61//SCTLR.TRE == 0 (TEX remap disabled, so memory type and attributes are described directly by bits in the descriptor)
62//Domain 0 is always the Client domain
63//Descriptors place all memory in domain 0
64//There are no restrictions by privilege level (PL0 can access all memory)
65
66#include <stdint.h>
67#include "MBRZA1H.h"
68
69//Import symbols from linker
70extern uint32_t Image$$VECTORS$$Base;
71extern uint32_t Image$$RO_DATA$$Base;
72extern uint32_t Image$$RW_DATA$$Base;
73extern uint32_t Image$$ZI_DATA$$Base;
74extern uint32_t Image$$TTB$$ZI$$Base;
75#if defined( __CC_ARM )
76#else
77extern uint32_t Image$$RW_DATA_NC$$Base;
78extern uint32_t Image$$ZI_DATA_NC$$Base;
79#endif
80
81extern uint32_t Image$$VECTORS$$Limit;
82extern uint32_t Image$$RO_DATA$$Limit;
83extern uint32_t Image$$RW_DATA$$Limit;
84extern uint32_t Image$$ZI_DATA$$Limit;
85#if defined( __CC_ARM )
86#else
87extern uint32_t Image$$RW_DATA_NC$$Limit;
88extern uint32_t Image$$ZI_DATA_NC$$Limit;
89#endif
90
91#define VECTORS_SIZE (((uint32_t)&Image$$VECTORS$$Limit >> 20) - ((uint32_t)&Image$$VECTORS$$Base >> 20) + 1)
92#define RO_DATA_SIZE (((uint32_t)&Image$$RO_DATA$$Limit >> 20) - ((uint32_t)&Image$$RO_DATA$$Base >> 20) + 1)
93#define RW_DATA_SIZE (((uint32_t)&Image$$RW_DATA$$Limit >> 20) - ((uint32_t)&Image$$RW_DATA$$Base >> 20) + 1)
94#define ZI_DATA_SIZE (((uint32_t)&Image$$ZI_DATA$$Limit >> 20) - ((uint32_t)&Image$$ZI_DATA$$Base >> 20) + 1)
95#if defined( __CC_ARM )
96#else
97#define RW_DATA_NC_SIZE (((uint32_t)&Image$$RW_DATA_NC$$Limit >> 20) - ((uint32_t)&Image$$RW_DATA_NC$$Base >> 20) + 1)
98#define ZI_DATA_NC_SIZE (((uint32_t)&Image$$ZI_DATA_NC$$Limit >> 20) - ((uint32_t)&Image$$ZI_DATA_NC$$Base >> 20) + 1)
99#endif
100
101static uint32_t Sect_Normal; //outer & inner wb/wa, non-shareable, executable, rw, domain 0, base addr 0
102static uint32_t Sect_Normal_NC; //non-shareable, non-executable, rw, domain 0, base addr 0
103static uint32_t Sect_Normal_Cod; //outer & inner wb/wa, non-shareable, executable, ro, domain 0, base addr 0
104static uint32_t Sect_Normal_RO; //as Sect_Normal_Cod, but not executable
105static uint32_t Sect_Normal_RW; //as Sect_Normal_Cod, but writeable and not executable
106static uint32_t Sect_Device_RO; //device, non-shareable, non-executable, ro, domain 0, base addr 0
107static uint32_t Sect_Device_RW; //as Sect_Device_RO, but writeable
108
109/* Define global descriptors */
110static uint32_t Page_L1_4k = 0x0; //generic
111static uint32_t Page_L1_64k = 0x0; //generic
112static uint32_t Page_4k_Device_RW; //Shared device, not executable, rw, domain 0
113static uint32_t Page_64k_Device_RW; //Shared device, not executable, rw, domain 0
114
115void create_translation_table(void)
116{
117 mmu_region_attributes_Type region;
118
119 /*
120 * Generate descriptors. Refer to MBRZA1H.h to get information about attributes
121 *
122 */
123 //Create descriptors for Vectors, RO, RW, ZI sections
124 section_normal(Sect_Normal, region);
125 section_normal_cod(Sect_Normal_Cod, region);
126 section_normal_ro(Sect_Normal_RO, region);
127 section_normal_rw(Sect_Normal_RW, region);
128 //Create descriptors for peripherals
129 section_device_ro(Sect_Device_RO, region);
130 section_device_rw(Sect_Device_RW, region);
131 section_normal_nc(Sect_Normal_NC, region);
132 //Create descriptors for 64k pages
133 page64k_device_rw(Page_L1_64k, Page_64k_Device_RW, region);
134 //Create descriptors for 4k pages
135 page4k_device_rw(Page_L1_4k, Page_4k_Device_RW, region);
136
137 /*
138 * Define MMU flat-map regions and attributes
139 *
140 */
141
142 //Create 4GB of faulting entries
143 __TTSection (&Image$$TTB$$ZI$$Base, 0, 4096, DESCRIPTOR_FAULT);
144
145 // R7S72100 memory map.
146 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_NORFLASH_BASE0 , 64, Sect_Normal_RO);
147 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_NORFLASH_BASE1 , 64, Sect_Normal_RO);
148 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_SDRAM_BASE0 , 64, Sect_Normal_RW);
149 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_SDRAM_BASE1 , 64, Sect_Normal_RW);
150 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_USER_AREA0 , 64, Sect_Normal_RW);
151 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_USER_AREA1 , 64, Sect_Normal_RW);
152 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_SPI_IO0 , 64, Sect_Normal_RO);
153 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_SPI_IO1 , 64, Sect_Normal_RO);
154 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_ONCHIP_SRAM_BASE , 10, Sect_Normal_RW);
155 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_SPI_MIO_BASE , 1, Sect_Device_RW);
156 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_BSC_BASE , 1, Sect_Device_RW);
157 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_PERIPH_BASE0 , 3, Sect_Device_RW);
158 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_PERIPH_BASE1 , 49, Sect_Device_RW);
159
160 //Define Image
161 __TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$RO_DATA$$Base, RO_DATA_SIZE, Sect_Normal_RO);
162 __TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$VECTORS$$Base, VECTORS_SIZE, Sect_Normal_Cod);
163 __TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$RW_DATA$$Base, RW_DATA_SIZE, Sect_Normal_RW);
164 __TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$ZI_DATA$$Base, ZI_DATA_SIZE, Sect_Normal_RW);
165#if defined( __CC_ARM )
166 __TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_ONCHIP_SRAM_NC_BASE, 10, Sect_Normal_NC);
167#else
168 __TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$RW_DATA_NC$$Base, RW_DATA_NC_SIZE, Sect_Normal_NC);
169 __TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$ZI_DATA_NC$$Base, ZI_DATA_NC_SIZE, Sect_Normal_NC);
170#endif
171
172 /* Set location of level 1 page table
173 ; 31:14 - Translation table base addr (31:14-TTBCR.N, TTBCR.N is 0 out of reset)
174 ; 13:7 - 0x0
175 ; 6 - IRGN[0] 0x0 (Inner WB WA)
176 ; 5 - NOS 0x0 (Non-shared)
177 ; 4:3 - RGN 0x1 (Outer WB WA)
178 ; 2 - IMP 0x0 (Implementation Defined)
179 ; 1 - S 0x0 (Non-shared)
180 ; 0 - IRGN[1] 0x1 (Inner WB WA) */
181 __set_TTBR0(((uint32_t)&Image$$TTB$$ZI$$Base) | 9);
182
183 /* Set up domain access control register
184 ; We set domain 0 to Client and all other domains to No Access.
185 ; All translation table entries specify domain 0 */
186 __set_DACR(1);
187}
188
189
190/*----------------------------------------------------------------------------
191 * end of file
192 *---------------------------------------------------------------------------*/
Note: See TracBrowser for help on using the repository browser.