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

5
Last change on this file since 707ecbe was 707ecbe, checked in by Sebastian Huber <sebastian.huber@…>, on 10/07/15 at 11:53:15

bsp/qoriq: Add BMan and QMan Portals

  • Property mode set to 100644
File size: 3.7 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_DEV(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        .mas7 = QORIQ_MMU_DEVICE_MAS7 \
72}
73
74#define ENTRY_DEV_CACHED(b, s) { \
75        .begin = (uint32_t) b, \
76        .size = (uint32_t) s, \
77        .mas2 = ENTRY_RW_MAS2, \
78        .mas3 = FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SW, \
79        .mas7 = QORIQ_MMU_DEVICE_MAS7 \
80}
81
82static const entry DATA config [] = {
83        #if defined(QORIQ_INTERCOM_AREA_BEGIN) && defined(QORIQ_INTERCOM_AREA_SIZE)
84                {
85                        .begin = QORIQ_INTERCOM_AREA_BEGIN,
86                        .size = QORIQ_INTERCOM_AREA_SIZE,
87                        .mas2 = FSL_EIS_MAS2_M,
88                        .mas3 = FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SW
89                },
90        #endif
91        ENTRY_X(bsp_section_start_begin, bsp_section_start_size),
92        ENTRY_R(bsp_section_fast_text_load_begin, bsp_section_fast_text_size),
93        ENTRY_X(bsp_section_fast_text_begin, bsp_section_fast_text_size),
94        ENTRY_X(bsp_section_text_begin, bsp_section_text_size),
95        ENTRY_R(bsp_section_rodata_load_begin, bsp_section_rodata_size),
96        ENTRY_R(bsp_section_rodata_begin, bsp_section_rodata_size),
97        ENTRY_R(bsp_section_fast_data_load_begin, bsp_section_fast_data_size),
98        ENTRY_RW(bsp_section_fast_data_begin, bsp_section_fast_data_size),
99        ENTRY_R(bsp_section_data_load_begin, bsp_section_data_size),
100        ENTRY_RW(bsp_section_data_begin, bsp_section_data_size),
101        ENTRY_RW(bsp_section_sbss_begin, bsp_section_sbss_size),
102        ENTRY_RW(bsp_section_bss_begin, bsp_section_bss_size),
103        ENTRY_RW(bsp_section_rwextra_begin, bsp_section_rwextra_size),
104        ENTRY_RW(bsp_section_work_begin, bsp_section_work_size),
105        ENTRY_RW(bsp_section_stack_begin, bsp_section_stack_size),
106#if QORIQ_CHIP_IS_T_VARIANT(QORIQ_CHIP_VARIANT)
107        /* BMan Portals */
108        ENTRY_DEV_CACHED(0xf4000000, 0x01000000),
109        ENTRY_DEV(0xf5000000, 0x01000000),
110        /* QMan Portals */
111        ENTRY_DEV_CACHED(0xf6000000, 0x01000000),
112        ENTRY_DEV(0xf7000000, 0x01000000),
113#endif
114        ENTRY_DEV(&qoriq, sizeof(qoriq))
115};
116
117void TEXT qoriq_mmu_config(int first_tlb, int scratch_tlb)
118{
119        qoriq_mmu_context context;
120        int i = 0;
121
122        qoriq_mmu_context_init(&context);
123
124        for (i = 0; i < QORIQ_TLB1_ENTRY_COUNT; ++i) {
125                if (i != scratch_tlb) {
126                        qoriq_tlb1_invalidate(i);
127                }
128        }
129
130        for (i = 0; i < (int) (sizeof(config) / sizeof(config [0])); ++i) {
131                const entry *cur = &config [i];
132                if (cur->size > 0) {
133                        qoriq_mmu_add(
134                                &context,
135                                cur->begin,
136                                cur->begin + cur->size - 1,
137                                0,
138                                cur->mas2,
139                                cur->mas3,
140                                cur->mas7
141                        );
142                }
143        }
144
145        qoriq_mmu_partition(&context, (3 * QORIQ_TLB1_ENTRY_COUNT) / 4);
146        qoriq_mmu_write_to_tlb1(&context, first_tlb);
147}
Note: See TracBrowser for help on using the repository browser.