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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [arm/] [xscale/] [cores/] [v2_0/] [include/] [hal_mm.h] - Blame information for rev 174

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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