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

4.115
Last change on this file since f2e6c3e was f2e6c3e, checked in by Sebastian Huber <sebastian.huber@…>, on 01/13/15 at 10:38:18

bsp/qoriq: Add T2080RDB and T4240RDB variants

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