OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [xscale/] [cores/] [current/] [include/] [hal_mm.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_MM_H
2
#define CYGONCE_HAL_MM_H
3
 
4
//=============================================================================
5
//
6
//      hal_mm.h
7
//
8
//      Intel XScale MM common definitions 
9
//
10
//=============================================================================
11
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
12
// -------------------------------------------                              
13
// This file is part of eCos, the Embedded Configurable Operating System.   
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under    
17
// the terms of the GNU General Public License as published by the Free     
18
// Software Foundation; either version 2 or (at your option) any later      
19
// version.                                                                 
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT      
22
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
24
// for more details.                                                        
25
//
26
// You should have received a copy of the GNU General Public License        
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
29
//
30
// As a special exception, if other files instantiate templates or use      
31
// macros or inline functions from this file, or you compile this file      
32
// and link it with other works to produce a work based on this file,       
33
// this file does not by itself cause the resulting work to be covered by   
34
// the GNU General Public License. However the source code for this file    
35
// must still be made available in accordance with section (3) of the GNU   
36
// General Public License v2.                                               
37
//
38
// This exception does not invalidate any other reasons why a work based    
39
// on this file might be covered by the GNU General Public License.         
40
// -------------------------------------------                              
41
// ####ECOSGPLCOPYRIGHTEND####                                              
42
//=============================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):    msalter
46
// Contributors: gthomas
47
// Date:         2001-12-03
48
// Purpose:      Intel XScale MM common definitions
49
// Description:  The macros defined here provide common definitions for
50
//               memory management initialization.
51
// Usage:
52
//               #include <cyg/hal/hal_mm.h>
53
//               ...
54
//              
55
//
56
//####DESCRIPTIONEND####
57
//
58
//=============================================================================
59
 
60
#define PTE_SECTION_FLASH    ((3 << 10) | (1 << 3) | 2)
61
#define PTE_SECTION_RAM      ((1 << 12) | (3 << 10) | (1 << 3) | (1 << 2) | 2)
62
#define PTE_SECTION_UNCACHED ((3 << 10) | 2)
63
 
64
#ifdef __ASSEMBLER__
65
 
66
// form a first-level section entry
67
.macro FL_SECTION_ENTRY base,x,ap,p,d,c,b
68
.word (\base << 20) | (\x << 12) | (\ap << 10) | (\p << 9) |\
69
      (\d << 5) | (\c << 3) | (\b << 2) | 2
70
.endm
71
 
72
// form a first-level page table entry
73
.macro FL_PT_ENTRY base,p,d
74
// I wanted to use logical operations here, but since I am using symbols later 
75
// to fill in the parameters, I had to use addition to force the assembler to
76
// do it right
77
.word \base + (\p << 9) + (\d << 5) + 1
78
.endm
79
 
80
// form a second level small page entry
81
.macro SL_SMPAGE_ENTRY base,ap3,ap2,ap1,ap0,c,b
82
.word (\base << 12) | (\ap3 << 10) | (\ap2 << 8) | (\ap1 << 6) |\
83
      (\ap0 << 4) | (\c << 3) | (\b << 2) | 2
84
.endm
85
 
86
// form a second level extended small page entry
87
.macro SL_XSMPAGE_ENTRY base,x,ap,c,b
88
.word (\base << 12) | (\x << 6) | (\ap << 4) | (\c << 3) | (\b << 2) | 3
89
.endm
90
 
91
.macro XSCALE_MMU_SECTION abase vbase size cache buff access x p
92
        ldr     r0, =(0x4000 + (\vbase << 2))
93
        ldr     r1, =(0x4000 + (\vbase << 2) + (\size << 2))
94
        ldr     r2, =((\abase << 20) + (\x << 12) + (\access << 10) + (\p << 9) + (\cache << 3) + (\buff << 2) + 2)
95
     981:
96
        str     r2, [r0], #4
97
        add     r2, r2, #(1 << 20)
98
        cmp     r0, r1
99
        bne     981b
100
.endm
101
 
102
#else
103
 
104
// -------------------------------------------------------------------------
105
// MMU initialization:
106
// 
107
// These structures are laid down in memory to define the translation
108
// table.
109
// 
110
 
111
/*
112
 * XScale Translation Table Base Bit Masks
113
 */
114
#define ARM_TRANSLATION_TABLE_MASK               0xFFFFC000
115
 
116
/*
117
 * XScale Domain Access Control Bit Masks
118
 */
119
#define ARM_ACCESS_TYPE_NO_ACCESS(domain_num)    (0x0 << (domain_num)*2)
120
#define ARM_ACCESS_TYPE_CLIENT(domain_num)       (0x1 << (domain_num)*2)
121
#define ARM_ACCESS_TYPE_MANAGER(domain_num)      (0x3 << (domain_num)*2)
122
 
123
struct ARM_MMU_FIRST_LEVEL_FAULT {
124
    unsigned int id : 2;
125
    unsigned int sbz : 30;
126
};
127
#define ARM_MMU_FIRST_LEVEL_FAULT_ID 0x0
128
 
129
struct ARM_MMU_FIRST_LEVEL_PAGE_TABLE {
130
    unsigned int id : 2;
131
    unsigned int imp : 2;
132
    unsigned int domain : 4;
133
    unsigned int p : 1;
134
    unsigned int base_address : 23;
135
};
136
#define ARM_MMU_FIRST_LEVEL_PAGE_TABLE_ID 0x1
137
 
138
struct ARM_MMU_FIRST_LEVEL_SECTION {
139
    unsigned int id : 2;
140
    unsigned int b : 1;
141
    unsigned int c : 1;
142
    unsigned int imp : 1;
143
    unsigned int domain : 4;
144
    unsigned int p : 1;
145
    unsigned int ap : 2;
146
    unsigned int x : 1;
147
    unsigned int tex : 7;
148
    unsigned int base_address : 12;
149
};
150
#define ARM_MMU_FIRST_LEVEL_SECTION_ID 0x2
151
 
152
struct ARM_MMU_FIRST_LEVEL_RESERVED {
153
    unsigned int id : 2;
154
    unsigned int sbz : 30;
155
};
156
#define ARM_MMU_FIRST_LEVEL_RESERVED_ID 0x3
157
 
158
#define ARM_MMU_FIRST_LEVEL_DESCRIPTOR_ADDRESS(ttb_base, table_index) \
159
   (unsigned long *)((unsigned long)(ttb_base) + ((table_index) << 2))
160
 
161
#define ARM_FIRST_LEVEL_PAGE_TABLE_SIZE 0x4000
162
 
163
#define ARM_MMU_SECTION(ttb_base, actual_base, virtual_base,              \
164
                        cacheable, bufferable, perm, xbit, pbit)          \
165
    CYG_MACRO_START                                                       \
166
        register union ARM_MMU_FIRST_LEVEL_DESCRIPTOR desc;               \
167
                                                                          \
168
        desc.word = 0;                                                    \
169
        desc.section.id = ARM_MMU_FIRST_LEVEL_SECTION_ID;                 \
170
        desc.section.domain = 0;                                          \
171
        desc.section.c = (cacheable);                                     \
172
        desc.section.b = (bufferable);                                    \
173
        desc.section.ap = (perm);                                         \
174
        desc.section.base_address = (actual_base);                        \
175
        desc.section.x = (xbit);                                          \
176
        desc.section.p = (pbit);                                          \
177
        *ARM_MMU_FIRST_LEVEL_DESCRIPTOR_ADDRESS(ttb_base, (virtual_base)) \
178
                            = desc.word;                                  \
179
    CYG_MACRO_END
180
 
181
#define X_ARM_MMU_SECTION(abase,vbase,size,cache,buff,access)       \
182
    { int i; int j = abase; int k = vbase;                          \
183
      for (i = size; i > 0 ; i--,j++,k++)                           \
184
      {                                                             \
185
        ARM_MMU_SECTION(ttb_base, j, k, cache, buff, access, 0, 0); \
186
      }                                                             \
187
    }
188
 
189
 
190
#define XSCALE_MMU_SECTION(abase,vbase,size,cache,buff,access, x, p)  \
191
    { int i; int j = abase; int k = vbase;                            \
192
      for (i = size; i > 0 ; i--,j++,k++)                             \
193
      {                                                               \
194
        ARM_MMU_SECTION(ttb_base, j, k, cache, buff, access, x, p);   \
195
      }                                                               \
196
      }
197
 
198
union ARM_MMU_FIRST_LEVEL_DESCRIPTOR {
199
    unsigned long word;
200
    struct ARM_MMU_FIRST_LEVEL_FAULT fault;
201
    struct ARM_MMU_FIRST_LEVEL_PAGE_TABLE page_table;
202
    struct ARM_MMU_FIRST_LEVEL_SECTION section;
203
    struct ARM_MMU_FIRST_LEVEL_RESERVED reserved;
204
};
205
 
206
#define ARM_UNCACHEABLE                         0
207
#define ARM_CACHEABLE                           1
208
#define ARM_UNBUFFERABLE                        0
209
#define ARM_BUFFERABLE                          1
210
 
211
#define ARM_ACCESS_PERM_NONE_NONE               0
212
#define ARM_ACCESS_PERM_RO_NONE                 0
213
#define ARM_ACCESS_PERM_RO_RO                   0
214
#define ARM_ACCESS_PERM_RW_NONE                 1
215
#define ARM_ACCESS_PERM_RW_RO                   2
216
#define ARM_ACCESS_PERM_RW_RW                   3
217
 
218
/*
219
 * Initialization for the Domain Access Control Register
220
 */
221
#define ARM_ACCESS_DACR_DEFAULT      (          \
222
        ARM_ACCESS_TYPE_MANAGER(0)    |         \
223
        ARM_ACCESS_TYPE_NO_ACCESS(1)  |         \
224
        ARM_ACCESS_TYPE_NO_ACCESS(2)  |         \
225
        ARM_ACCESS_TYPE_NO_ACCESS(3)  |         \
226
        ARM_ACCESS_TYPE_NO_ACCESS(4)  |         \
227
        ARM_ACCESS_TYPE_NO_ACCESS(5)  |         \
228
        ARM_ACCESS_TYPE_NO_ACCESS(6)  |         \
229
        ARM_ACCESS_TYPE_NO_ACCESS(7)  |         \
230
        ARM_ACCESS_TYPE_NO_ACCESS(8)  |         \
231
        ARM_ACCESS_TYPE_NO_ACCESS(9)  |         \
232
        ARM_ACCESS_TYPE_NO_ACCESS(10) |         \
233
        ARM_ACCESS_TYPE_NO_ACCESS(11) |         \
234
        ARM_ACCESS_TYPE_NO_ACCESS(12) |         \
235
        ARM_ACCESS_TYPE_NO_ACCESS(13) |         \
236
        ARM_ACCESS_TYPE_NO_ACCESS(14) |         \
237
        ARM_ACCESS_TYPE_NO_ACCESS(15)  )
238
 
239
#endif // ifdef __ASSEMBLER__
240
 
241
// ------------------------------------------------------------------------
242
// XScale extras.
243
#define MMU_Control_BTB 0x800
244
 
245
 
246
#endif // ifndef CYGONCE_HAL_MM_H
247
// End of hal_mm.h
248
 
249
 
250
 
251
 
252
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.