1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
/* $NetBSD: mc68851.h,v 1.6 2008/04/28 20:23:38 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jeremy Cooper.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This file contains the machine-independent definitions
* related to the Motorola MC68851 Memory Management Unit (MMU).
* Things that depend on the contents of the Translation Control
* (TC) register are in <machine/pte.h>.
*/
#ifndef _SUN3X_MC68851_H
#define _SUN3X_MC68851_H
/**************************** MMU STRUCTURES ****************************
* MMU structures define the format of data used by the MC68851. *
************************************************************************
** MC68851 Root Pointer
* All address translations begin with the examination of the value
* in the MC68851 Root Pointer register. It describes the base address
* (in physical memory) of the root table to be used as well as any limits
* to the address range it supports. Its structure is identical to a Long
* Format Table Descriptor (described below.)
*/
struct mmu_rootptr {
u_long rp_attr; /* Lower/Upper Limit and access flags */
u_long rp_addr; /* Physical Base Address */
};
typedef struct mmu_rootptr mmu_rootptr_t;
/** MC68851 Long Format Table Descriptor
* The root table for a sun3x pmap is a 128 element array of 'long format
* table descriptors'. The structure of a long format table descriptor is:
*
* 63 48
* +---+---.---.---.---.---.---.---.---.---.---.---.---.---.---.---+
* |L/U| LIMIT |
* +---+---.---+---.---.---+---+---+---+---+---+---+---+---+---.---+
* | RAL | WAL |SG | S | 0 | 0 | 0 | 0 | U |WP |DT (10)|
* +---.---.---+---.---.---+---+---+---+---+---+---+---+---+---.---+
* | TABLE PHYSICAL ADDRESS (BITS 31-16) |
* +---.---.---.---.---.---.---.---.---.---.---.---+---.---.---.---+
* | TABLE PHYSICAL ADDRESS (15-4) | UNUSED |
* +---.---.---.---.---.---.---.---.---.---.---.---+---.---.---.---+
* 15 0
*
* Note: keep the unused bits set to zero so that no masking of the
* base address is needed.
*/
struct mmu_long_dte_struct { /* 'dte' stands for 'descriptor table entry' */
union {
struct {
char lu_flag:1; /* Lower/Upper Limit flag */
int limit:15; /* Table Size limit */
char ral:3; /* Read Access Level */
char wal:3; /* Write Access Level */
char sg:1; /* Shared Globally flag */
char supv:1; /* Supervisor Only flag */
char rsvd:4; /* Reserved (All zeros) */
char u:1; /* Used flag */
char wp:1; /* Write Protect flag */
char dt:2; /* Descriptor Type */
/* Bit masks for fields above */
#define MMU_LONG_DTE_LU 0x80000000
#define MMU_LONG_DTE_LIMIT 0x7fff0000
#define MMU_LONG_DTE_RAL 0x0000e000
#define MMU_LONG_DTE_WAL 0x00001c00
#define MMU_LONG_DTE_SG 0x00000200
#define MMU_LONG_DTE_SUPV 0x00000100
#define MMU_LONG_DTE_USED 0x00000008
#define MMU_LONG_DTE_WP 0x00000004
#define MMU_LONG_DTE_DT 0x00000003
} attr_struct;
u_long raw; /* struct above, addressable as a long */
} attr;
union {
struct {
int base_addr:28; /* Physical base address
char unused:4; * of the table pointed to
* by this entry.
*/
/* Bit masks for fields above */
#define MMU_LONG_DTE_BASEADDR 0xfffffff0
} addr_struct;
u_long raw; /* struct above, addressable as a long */
} addr;
};
typedef struct mmu_long_dte_struct mmu_long_dte_t;
typedef struct mmu_long_dte_struct *mmu_long_dtbl_t;
/** MC68851 Long Format Page Descriptor
* Although not likely to be used in this implementation, a level
* 'A' table may contain long format PAGE descriptors. A long format
* page descriptor is the same size as a long format table descriptor.
* Its discriminating feature to the MMU is its descriptor field: 01.
* 63 48
* +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---+
* | UNUSED |
* +---.---.---+---.---.---+---+---+---+---+---+---+---+---+---.---+
* | RAL | WAL |SG | S | G |CI | L | M | U |WP |DT (01)|
* +---.---.---+---.---.---+---+---+---+---+---+---+---+---+---.---+
* | TABLE PHYSICAL ADDRESS (BITS 31-16) |
* +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---+
* |TABLE PHYS. ADDRESS (15-8) | UNUSED |
* +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---+
* 15 0
*/
struct mmu_long_pte_struct { /* 'pte' stands for 'page table entry' */
union {
struct {
int unused:16; /* Unused */
char ral:3; /* Read Access Level */
char wal:3; /* Write Access Level */
char sg:1; /* Shared Globally flag */
char supv:1; /* Supervisor Only flag */
char g:1; /* Gate allowed */
char ci:1; /* Cache inhibit */
char l:1; /* Lock entry */
char m:1; /* Modified flag */
char u:1; /* Used flag */
char wp:1; /* Write Protect flag */
char dt:2; /* Descriptor Type */
/* Bit masks for fields above */
#define MMU_LONG_PTE_RAL 0x0000e000
#define MMU_LONG_PTE_WAL 0x00001c00
#define MMU_LONG_PTE_SG 0x00000200
#define MMU_LONG_PTE_SUPV 0x00000100
#define MMU_LONG_PTE_GATE 0x00000080
#define MMU_LONG_PTE_CI 0x00000040
#define MMU_LONG_PTE_LOCK 0x00000020
#define MMU_LONG_PTE_M 0x00000010
#define MMU_LONG_PTE_USED 0x00000008
#define MMU_LONG_PTE_WP 0x00000004
#define MMU_LONG_PTE_DT 0x00000003
} attr_struct;
u_long raw; /* struct above, addressable as a long */
} attr;
union {
struct {
long base_addr:24; /* Physical base address
char unused:8; * of page this entry
* points to.
*/
/* Bit masks for fields above */
#define MMU_LONG_PTE_BASEADDR 0xffffff00
} addr_struct;
u_long raw; /* struct above, addressable as a long */
} addr;
};
typedef struct mmu_long_pte_struct mmu_long_pte_t;
typedef struct mmu_long_pte_struct *mmu_long_ptbl_t;
/* Every entry in the level A table (except for the page entries
* described above) points to a level B table. Level B tables are
* arrays of 'short format' table descriptors. Their structure
* is smaller than an A table descriptor and is as follows:
*
* 31 16
* +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---+
* | TABLE PHYSICAL BASE ADDRESS (BITS 31-16) |
* +---.---.---.---.---.---.---.---.---.---.---.---+---+---+---.---+
* | TABLE PHYSICAL BASE ADDRESS (15-4) | U |WP |DT (10)|
* +---.---.---.---.---.---.---.---.---.---.---.---+---+---+---.---+
* 15 0
*/
struct mmu_short_dte_struct { /* 'dte' stands for 'descriptor table entry' */
union {
struct {
long base_addr:28;
char u:1;
char wp:1;
char dt:2;
#define MMU_SHORT_DTE_BASEADDR 0xfffffff0
#define MMU_SHORT_DTE_USED 0x00000008
#define MMU_SHORT_DTE_WP 0x00000004
#define MMU_SHORT_DTE_DT 0x00000003
} attr_struct;
u_long raw;
} attr;
};
typedef struct mmu_short_dte_struct mmu_short_dte_t;
typedef struct mmu_short_dte_struct *mmu_short_dtbl_t;
/* Every entry in a level B table points to a level C table. Level C tables
* contain arrays of short format page 'entry' descriptors. A short format
* page 'entry' is the same size as a short format page 'table'
* descriptor (a B table entry). Thus B and C tables can be allocated
* interchangeably from the same pool. However, we will keep them separate.
*
* The descriptor type (DT) field of a Page Table Entry (PTE) is '01'. This
* indicates to the MMU that the address contained in the PTE's 'base
* address' field is the base address for a physical page in memory to which
* the VA should be mapped, and not a base address for a yet another
* descriptor table, thus ending the table walk.
*
* 31 16
* +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---+
* | TABLE PHYSICAL BASE ADDRESS (BITS 31-16) |
* +---.---.---.---.---.---.---.---+---+---+---+---+---+---+---.---+
* |TABLE PHYS. BASE ADDRESS (15-8)| G |CI | L | M | U |WP |DT (10)|
* +---.---.---.---.---.---.---.---+---+---+---+---+---+---+---.---+
* 15 0
*/
struct mmu_short_pte_struct { /* 'pte' stands for 'page table entry' */
union {
struct {
long base_addr:24;
char g:1;
char ci:1;
char l:1;
char m:1;
char u:1;
char wp:1;
char dt:2;
#define MMU_SHORT_PTE_BASEADDR 0xffffff00
#define MMU_SHORT_PTE_UN2 0x00000080
#define MMU_SHORT_PTE_CI 0x00000040
#define MMU_SHORT_PTE_UN1 0x00000020
#define MMU_SHORT_PTE_M 0x00000010
#define MMU_SHORT_PTE_USED 0x00000008
#define MMU_SHORT_PTE_WP 0x00000004
#define MMU_SHORT_PTE_DT 0x00000003
} attr_struct;
u_long raw;
} attr;
};
typedef struct mmu_short_pte_struct mmu_short_pte_t;
typedef struct mmu_short_pte_struct *mmu_short_ptbl_t;
/* These are bit masks and other values that are common to all types of
* descriptors.
*/
/* Page table descriptors have a 'Descriptor Type' field describing the
* format of the tables they point to. It is two bits wide and is one of:
*/
#define MMU_DT_INVALID 0x0 /* Invalid descriptor entry */
#define MMU_DT_PAGE 0x1 /* Descriptor describes a page entry */
#define MMU_DT_SHORT 0x2 /* describes a short format table */
#define MMU_DT_LONG 0x3 /* describes a long format table */
#define MMU_DT_MASK 0x00000003 /* Bit location of the DT field */
/* Various macros for manipulating and setting MMU descriptor
* characteristics.
*/
/* returns true if a descriptor is valid. */
#define MMU_VALID_DT(dte) ((dte).attr.raw & MMU_DT_MASK)
/* returns true if a descriptor is invalid */
#define MMU_INVALID_DT(dte) (!((dte).attr.raw & MMU_DT_MASK))
/* returns true if a descriptor has been referenced */
#define MMU_PTE_USED(pte) ((pte).attr.raw & MMU_SHORT_PTE_USED)
/* returns true if a descriptor has been modified */
#define MMU_PTE_MODIFIED(pte) ((pte).attr.raw & MMU_SHORT_PTE_M)
/* extracts the physical address from a pte */
#define MMU_PTE_PA(pte) ((pte).attr.raw & MMU_SHORT_PTE_BASEADDR)
/* extracts the physical address from a dte */
#define MMU_DTE_PA(dte) ((dte).attr.raw & MMU_SHORT_DTE_BASEADDR)
#endif /* _SUN3X_MC68851_H */
|