source: rtems/c/src/lib/libbsp/powerpc/qoriq/startup/mmu-config.c @ 53c99b8

5
Last change on this file since 53c99b8 was 53c99b8, checked in by Sebastian Huber <sebastian.huber@…>, on 10/28/15 at 09:18:05

bsps: Generalize .nocacheheap to .nocachenoload

Add ability to place data in a non-loadable cache-inhibited area.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup QorIQMMU
5 *
6 * @brief MMU implementation.
7 */
8
9/*
10 * Copyright (c) 2011-2015 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#include <bsp.h>
24#include <bsp/mmu.h>
25#include <bsp/linker-symbols.h>
26#include <bsp/qoriq.h>
27
28#define TEXT __attribute__((section(".bsp_start_text")))
29#define DATA __attribute__((section(".bsp_start_data")))
30
31typedef struct {
32        uint32_t begin;
33        uint32_t size;
34        uint32_t mas2;
35        uint32_t mas3;
36        uint32_t mas7;
37} entry;
38
39#define ENTRY_X(b, s) { \
40        .begin = (uint32_t) b, \
41        .size = (uint32_t) s, \
42        .mas2 = 0, \
43        .mas3 = FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SX \
44}
45
46#define ENTRY_R(b, s) { \
47        .begin = (uint32_t) b, \
48        .size = (uint32_t) s, \
49        .mas2 = 0, \
50        .mas3 = FSL_EIS_MAS3_SR \
51}
52
53#ifdef RTEMS_SMP
54  #define ENTRY_RW_MAS2 FSL_EIS_MAS2_M
55#else
56  #define ENTRY_RW_MAS2 0
57#endif
58
59#define ENTRY_RW(b, s) { \
60        .begin = (uint32_t) b, \
61        .size = (uint32_t) s, \
62        .mas2 = ENTRY_RW_MAS2, \
63        .mas3 = FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SW \
64}
65
66#define ENTRY_IO(b, s) { \
67        .begin = (uint32_t) b, \
68        .size = (uint32_t) s, \
69        .mas2 = FSL_EIS_MAS2_I | FSL_EIS_MAS2_G, \
70        .mas3 = FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SW \
71}
72
73#define ENTRY_DEV(b, s) { \
74        .begin = (uint32_t) b, \
75        .size = (uint32_t) s, \
76        .mas2 = FSL_EIS_MAS2_I | FSL_EIS_MAS2_G, \
77        .mas3 = FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SW, \
78        .mas7 = QORIQ_MMU_DEVICE_MAS7 \
79}
80
81#define ENTRY_DEV_CACHED(b, s) { \
82        .begin = (uint32_t) b, \
83        .size = (uint32_t) s, \
84        .mas2 = ENTRY_RW_MAS2, \
85        .mas3 = FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SW, \
86        .mas7 = QORIQ_MMU_DEVICE_MAS7 \
87}
88
89static const entry DATA config [] = {
90        #if defined(QORIQ_INTERCOM_AREA_BEGIN) && defined(QORIQ_INTERCOM_AREA_SIZE)
91                {
92                        .begin = QORIQ_INTERCOM_AREA_BEGIN,
93                        .size = QORIQ_INTERCOM_AREA_SIZE,
94                        .mas2 = FSL_EIS_MAS2_M,
95                        .mas3 = FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SW
96                },
97        #endif
98        ENTRY_X(bsp_section_start_begin, bsp_section_start_size),
99        ENTRY_R(bsp_section_fast_text_load_begin, bsp_section_fast_text_size),
100        ENTRY_X(bsp_section_fast_text_begin, bsp_section_fast_text_size),
101        ENTRY_X(bsp_section_text_begin, bsp_section_text_size),
102        ENTRY_R(bsp_section_rodata_load_begin, bsp_section_rodata_size),
103        ENTRY_R(bsp_section_rodata_begin, bsp_section_rodata_size),
104        ENTRY_R(bsp_section_fast_data_load_begin, bsp_section_fast_data_size),
105        ENTRY_RW(bsp_section_fast_data_begin, bsp_section_fast_data_size),
106        ENTRY_R(bsp_section_data_load_begin, bsp_section_data_size),
107        ENTRY_RW(bsp_section_data_begin, bsp_section_data_size),
108        ENTRY_RW(bsp_section_sbss_begin, bsp_section_sbss_size),
109        ENTRY_RW(bsp_section_bss_begin, bsp_section_bss_size),
110        ENTRY_RW(bsp_section_rwextra_begin, bsp_section_rwextra_size),
111        ENTRY_RW(bsp_section_work_begin, bsp_section_work_size),
112        ENTRY_RW(bsp_section_stack_begin, bsp_section_stack_size),
113        ENTRY_IO(bsp_section_nocache_begin, bsp_section_nocache_size),
114        ENTRY_IO(bsp_section_nocachenoload_begin, bsp_section_nocachenoload_size),
115#if QORIQ_CHIP_IS_T_VARIANT(QORIQ_CHIP_VARIANT)
116        /* BMan Portals */
117        ENTRY_DEV_CACHED(0xf4000000, 0x01000000),
118        ENTRY_DEV(0xf5000000, 0x01000000),
119        /* QMan Portals */
120        ENTRY_DEV_CACHED(0xf6000000, 0x01000000),
121        ENTRY_DEV(0xf7000000, 0x01000000),
122#endif
123        ENTRY_DEV(&qoriq, sizeof(qoriq))
124};
125
126void TEXT qoriq_mmu_config(int first_tlb, int scratch_tlb)
127{
128        qoriq_mmu_context context;
129        int i = 0;
130
131        qoriq_mmu_context_init(&context);
132
133        for (i = 0; i < QORIQ_TLB1_ENTRY_COUNT; ++i) {
134                if (i != scratch_tlb) {
135                        qoriq_tlb1_invalidate(i);
136                }
137        }
138
139        for (i = 0; i < (int) (sizeof(config) / sizeof(config [0])); ++i) {
140                const entry *cur = &config [i];
141                if (cur->size > 0) {
142                        qoriq_mmu_add(
143                                &context,
144                                cur->begin,
145                                cur->begin + cur->size - 1,
146                                0,
147                                cur->mas2,
148                                cur->mas3,
149                                cur->mas7
150                        );
151                }
152        }
153
154        qoriq_mmu_partition(&context, (3 * QORIQ_TLB1_ENTRY_COUNT) / 4);
155        qoriq_mmu_write_to_tlb1(&context, first_tlb);
156}
Note: See TracBrowser for help on using the repository browser.