Annotation of sys/arch/m88k/include/mmu.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: mmu.h,v 1.8 2006/05/21 20:55:43 miod Exp $ */
2:
3: /*
4: * This file bears almost no resemblance to the original m68k file,
5: * so the following copyright notice is questionable, but we are
6: * nice people.
7: */
8:
9: /*
10: * Copyright (c) 1988 University of Utah.
11: * Copyright (c) 1982, 1986, 1990, 1993
12: * The Regents of the University of California. All rights reserved.
13: *
14: * This code is derived from software contributed to Berkeley by
15: * the Systems Programming Group of the University of Utah Computer
16: * Science Department.
17: *
18: * Redistribution and use in source and binary forms, with or without
19: * modification, are permitted provided that the following conditions
20: * are met:
21: * 1. Redistributions of source code must retain the above copyright
22: * notice, this list of conditions and the following disclaimer.
23: * 2. Redistributions in binary form must reproduce the above copyright
24: * notice, this list of conditions and the following disclaimer in the
25: * documentation and/or other materials provided with the distribution.
26: * 3. Neither the name of the University nor the names of its contributors
27: * may be used to endorse or promote products derived from this software
28: * without specific prior written permission.
29: *
30: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
31: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
34: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40: * SUCH DAMAGE.
41: *
42: * from: Utah $Hdr: pte.h 1.13 92/01/20$
43: *
44: * @(#)pte.h 8.1 (Berkeley) 6/10/93
45: */
46:
47: #ifndef _MACHINE_MMU_H_
48: #define _MACHINE_MMU_H_
49:
50: /*
51: * Parameters which determine the 'geometry' of the m88K page tables in memory.
52: */
53:
54: #define SDT_BITS 10 /* M88K segment table size bits */
55: #define PDT_BITS 10 /* M88K page table size bits */
56: #define PG_BITS PAGE_SHIFT /* M88K hardware page size bits */
57:
58: /*
59: * Common fields for APR, SDT and PTE
60: */
61:
62: /* address frame */
63: #define PG_FRAME 0xfffff000
64: #define PG_SHIFT PG_BITS
65: #define PG_PFNUM(x) (((x) & PG_FRAME) >> PG_SHIFT)
66:
67: /* cache control bits */
68: #define CACHE_DFL 0x00000000
69: #define CACHE_INH 0x00000040 /* cache inhibit */
70: #define CACHE_GLOBAL 0x00000080 /* global scope */
71: #define CACHE_WT 0x00000200 /* write through */
72:
73: #define CACHE_MASK (CACHE_INH | CACHE_GLOBAL | CACHE_WT)
74:
75: /*
76: * Area descriptors
77: */
78:
79: typedef u_int32_t apr_t;
80:
81: #define APR_V 0x00000001 /* valid bit */
82:
83: /*
84: * 88200 PATC (TLB)
85: */
86:
87: #define PATC_ENTRIES 56
88:
89: /*
90: * BATC entries
91: */
92:
93: #define BATC_V 0x00000001
94: #define BATC_PROT 0x00000002
95: #define BATC_INH 0x00000004
96: #define BATC_GLOBAL 0x00000008
97: #define BATC_WT 0x00000010
98: #define BATC_SO 0x00000020
99:
100:
101: /*
102: * Segment table entries
103: */
104:
105: typedef u_int32_t sdt_entry_t;
106:
107: #define SG_V 0x00000001
108: #define SG_NV 0x00000000
109: #define SG_PROT 0x00000004
110: #define SG_RO 0x00000004
111: #define SG_RW 0x00000000
112: #define SG_SO 0x00000100
113:
114: #define SDT_VALID(sdt) (*(sdt) & SG_V)
115: #define SDT_SUP(sdt) (*(sdt) & SG_SO)
116: #define SDT_WP(sdt) (*(sdt) & SG_PROT)
117:
118: /*
119: * Page table entries
120: */
121:
122: typedef u_int32_t pt_entry_t;
123:
124: #define PG_V 0x00000001
125: #define PG_NV 0x00000000
126: #define PG_PROT 0x00000004
127: #define PG_U 0x00000008
128: #define PG_M 0x00000010
129: #define PG_M_U 0x00000018
130: #define PG_RO 0x00000004
131: #define PG_RW 0x00000000
132: #define PG_SO 0x00000100
133: #define PG_W 0x00000020 /* XXX unused but reserved field */
134: #define PG_U0 0x00000400 /* U0 bit for M88110 */
135: #define PG_U1 0x00000800 /* U1 bit for M88110 */
136:
137: #define PDT_VALID(pte) (*(pte) & PG_V)
138: #define PDT_SUP(pte) (*(pte) & PG_SO)
139: #define PDT_WP(pte) (*(pte) & PG_PROT)
140:
141: /*
142: * Indirect descriptors (mc81110)
143: */
144:
145: typedef u_int32_t pt_ind_entry_t;
146:
147: /* validity bits */
148: #define IND_V 0x00000001
149: #define IND_NV 0x00000000
150: #define IND_MASKED 0x00000002
151: #define IND_UNMASKED 0x00000003
152: #define IND_MASK 0x00000003
153:
154: #define IND_FRAME 0xfffffffc
155: #define IND_SHIFT 2
156:
157: #define IND_PDA(x) ((x) & IND_FRAME >> IND_SHIFT)
158:
159: /*
160: * Number of entries in a page table.
161: */
162:
163: #define SDT_ENTRIES (1<<(SDT_BITS))
164: #define PDT_ENTRIES (1<<(PDT_BITS))
165:
166: /*
167: * Size in bytes of a single page table.
168: */
169:
170: #define SDT_SIZE (sizeof(sdt_entry_t) * SDT_ENTRIES)
171: #define PDT_SIZE (sizeof(pt_entry_t) * PDT_ENTRIES)
172:
173: /*
174: * Shifts and masks
175: */
176:
177: #define SDT_SHIFT (PDT_BITS + PG_BITS)
178: #define PDT_SHIFT (PG_BITS)
179:
180: #define SDT_MASK (((1 << SDT_BITS) - 1) << SDT_SHIFT)
181: #define PDT_MASK (((1 << PDT_BITS) - 1) << PDT_SHIFT)
182:
183: #define SDTIDX(va) (((va) & SDT_MASK) >> SDT_SHIFT)
184: #define PDTIDX(va) (((va) & PDT_MASK) >> PDT_SHIFT)
185:
186: /*
187: * Parameters and macros for BATC
188: */
189:
190: /* number of bits to BATC shift (log2(BATC_BLKBYTES)) */
191: #define BATC_BLKSHIFT 19
192: /* 'block' size of a BATC entry mapping */
193: #define BATC_BLKBYTES (1 << BATC_BLKSHIFT)
194: /* BATC block mask */
195: #define BATC_BLKMASK (BATC_BLKBYTES-1)
196: /* number of BATC entries */
197: #define BATC_MAX 8
198:
199: /* physical and logical block address */
200: #define BATC_PSHIFT 6
201: #define BATC_VSHIFT (BATC_PSHIFT + (32 - BATC_BLKSHIFT))
202:
203: #define BATC_BLK_ALIGNED(x) ((x & BATC_BLKMASK) == 0)
204:
205: #define M88K_BTOBLK(x) (x >> BATC_BLKSHIFT)
206:
207: static pt_entry_t invalidate_pte(pt_entry_t *);
208: static __inline__ pt_entry_t
209: invalidate_pte(pt_entry_t *pte)
210: {
211: pt_entry_t oldpte;
212:
213: oldpte = PG_NV;
214: __asm__ __volatile__
215: ("xmem %0, %2, r0" : "=r"(oldpte) : "0"(oldpte), "r"(pte));
216: __asm__ __volatile__ ("tb1 0, r0, 0");
217: return oldpte;
218: }
219:
220: #endif /* __MACHINE_MMU_H__ */
CVSweb