1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup QorIQMMU |
---|
5 | * |
---|
6 | * @brief MMU implementation. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2011-2013 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.com/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 | |
---|
31 | typedef struct { |
---|
32 | uint32_t begin; |
---|
33 | uint32_t size; |
---|
34 | uint32_t mas2; |
---|
35 | uint32_t mas3; |
---|
36 | } entry; |
---|
37 | |
---|
38 | #define ENTRY_X(b, s) { \ |
---|
39 | .begin = (uint32_t) b, \ |
---|
40 | .size = (uint32_t) s, \ |
---|
41 | .mas2 = 0, \ |
---|
42 | .mas3 = FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SX \ |
---|
43 | } |
---|
44 | |
---|
45 | #define ENTRY_R(b, s) { \ |
---|
46 | .begin = (uint32_t) b, \ |
---|
47 | .size = (uint32_t) s, \ |
---|
48 | .mas2 = 0, \ |
---|
49 | .mas3 = FSL_EIS_MAS3_SR \ |
---|
50 | } |
---|
51 | |
---|
52 | #ifdef RTEMS_SMP |
---|
53 | #define ENTRY_RW_MAS2 FSL_EIS_MAS2_M |
---|
54 | #else |
---|
55 | #define ENTRY_RW_MAS2 0 |
---|
56 | #endif |
---|
57 | |
---|
58 | #define ENTRY_RW(b, s) { \ |
---|
59 | .begin = (uint32_t) b, \ |
---|
60 | .size = (uint32_t) s, \ |
---|
61 | .mas2 = ENTRY_RW_MAS2, \ |
---|
62 | .mas3 = FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SW \ |
---|
63 | } |
---|
64 | |
---|
65 | #define ENTRY_DEV(b, s) { \ |
---|
66 | .begin = (uint32_t) b, \ |
---|
67 | .size = (uint32_t) s, \ |
---|
68 | .mas2 = FSL_EIS_MAS2_I | FSL_EIS_MAS2_G, \ |
---|
69 | .mas3 = FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SW \ |
---|
70 | } |
---|
71 | |
---|
72 | static const entry DATA config [] = { |
---|
73 | #if defined(QORIQ_INTERCOM_AREA_BEGIN) && defined(QORIQ_INTERCOM_AREA_SIZE) |
---|
74 | { |
---|
75 | .begin = QORIQ_INTERCOM_AREA_BEGIN, |
---|
76 | .size = QORIQ_INTERCOM_AREA_SIZE, |
---|
77 | .mas2 = FSL_EIS_MAS2_M, |
---|
78 | .mas3 = FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SW |
---|
79 | }, |
---|
80 | #endif |
---|
81 | ENTRY_X(bsp_section_start_begin, bsp_section_start_size), |
---|
82 | ENTRY_R(bsp_section_fast_text_load_begin, bsp_section_fast_text_size), |
---|
83 | ENTRY_X(bsp_section_fast_text_begin, bsp_section_fast_text_size), |
---|
84 | ENTRY_X(bsp_section_text_begin, bsp_section_text_size), |
---|
85 | ENTRY_R(bsp_section_rodata_load_begin, bsp_section_rodata_size), |
---|
86 | ENTRY_R(bsp_section_rodata_begin, bsp_section_rodata_size), |
---|
87 | ENTRY_R(bsp_section_sdata2_load_begin, bsp_section_sdata2_size), |
---|
88 | ENTRY_R(bsp_section_sdata2_begin, bsp_section_sdata2_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_R(bsp_section_sdata_load_begin, bsp_section_sdata_size), |
---|
94 | ENTRY_RW(bsp_section_sdata_begin, bsp_section_sdata_size), |
---|
95 | ENTRY_RW(bsp_section_sbss_begin, bsp_section_sbss_size), |
---|
96 | ENTRY_RW(bsp_section_bss_begin, bsp_section_bss_size), |
---|
97 | ENTRY_RW(bsp_section_rwextra_begin, bsp_section_rwextra_size), |
---|
98 | ENTRY_RW(bsp_section_work_begin, bsp_section_work_size), |
---|
99 | ENTRY_RW(bsp_section_stack_begin, bsp_section_stack_size), |
---|
100 | ENTRY_DEV(&qoriq, sizeof(qoriq)) |
---|
101 | }; |
---|
102 | |
---|
103 | void TEXT qoriq_mmu_config(int first_tlb, int scratch_tlb) |
---|
104 | { |
---|
105 | qoriq_mmu_context context; |
---|
106 | int i = 0; |
---|
107 | |
---|
108 | qoriq_mmu_context_init(&context); |
---|
109 | |
---|
110 | for (i = 0; i < 16; ++i) { |
---|
111 | if (i != scratch_tlb) { |
---|
112 | qoriq_tlb1_invalidate(i); |
---|
113 | } |
---|
114 | } |
---|
115 | |
---|
116 | for (i = 0; i < (int) (sizeof(config) / sizeof(config [0])); ++i) { |
---|
117 | const entry *cur = &config [i]; |
---|
118 | if (cur->size > 0) { |
---|
119 | qoriq_mmu_add( |
---|
120 | &context, |
---|
121 | cur->begin, |
---|
122 | cur->begin + cur->size - 1, |
---|
123 | 0, |
---|
124 | cur->mas2, |
---|
125 | cur->mas3 |
---|
126 | ); |
---|
127 | } |
---|
128 | } |
---|
129 | |
---|
130 | qoriq_mmu_partition(&context, 8); |
---|
131 | qoriq_mmu_write_to_tlb1(&context, first_tlb); |
---|
132 | } |
---|