xref: /netbsd-src/sys/arch/sun3/include/pte3.h (revision d710132b4b8ce7f7cccaaf660cb16aa16b4077a0)
1 /*	$NetBSD: pte3.h,v 1.16 1998/02/05 04:57:00 gwr Exp $	*/
2 
3 /*-
4  * Copyright (c) 1996 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Adam Glass and Gordon W. Ross.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef _MACHINE_PTE3_H
40 #define _MACHINE_PTE3_H
41 
42 #define NCONTEXT 8
43 #define NPMEG	256
44 #define SEGINV	(NPMEG-1)
45 #define NPAGSEG 16
46 #define NSEGMAP 2048
47 
48 #define PG_VALID   0x80000000
49 #define PG_WRITE   0x40000000
50 #define PG_SYSTEM  0x20000000
51 #define PG_NC      0x10000000
52 #define PG_TYPE    0x0C000000
53 #define PG_REF     0x02000000
54 #define PG_MOD     0x01000000
55 
56 #define PG_SPECIAL (PG_VALID|PG_WRITE|PG_SYSTEM|PG_NC|PG_REF|PG_MOD)
57 #define PG_PERM    (PG_VALID|PG_WRITE|PG_SYSTEM|PG_NC)
58 #define	PG_MODREF  (PG_REF|PG_MOD)
59 #define PG_FRAME   0x0007FFFF
60 
61 #define PG_MOD_SHIFT 24
62 #define PG_PERM_SHIFT 28
63 
64 #define OBMEM	0
65 #define OBIO 	1
66 #define VME_D16	2
67 #define VME_D32	3
68 #define PG_TYPE_SHIFT 26
69 
70 #define PG_INVAL   0x0
71 
72 #define MAKE_PGTYPE(x) ((x) << PG_TYPE_SHIFT)
73 #define PG_PFNUM(pte) (pte & PG_FRAME)
74 #define PG_PA(pte) (PG_PFNUM(pte) << PGSHIFT)
75 
76 #define	PGT_MASK	MAKE_PGTYPE(3)
77 #define	PGT_OBMEM	MAKE_PGTYPE(OBMEM)		/* onboard memory */
78 #define	PGT_OBIO	MAKE_PGTYPE(OBIO)		/* onboard I/O */
79 #define	PGT_VME_D16	MAKE_PGTYPE(VME_D16)	/* VMEbus 16-bit data */
80 #define	PGT_VME_D32	MAKE_PGTYPE(VME_D32)	/* VMEbus 32-bit data */
81 
82 #define VA_SEGNUM(x)	((u_int)(x) >> SEGSHIFT)
83 
84 #define VA_PTE_NUM_SHIFT  13
85 #define VA_PTE_NUM_MASK (0xF << VA_PTE_NUM_SHIFT)
86 #define VA_PTE_NUM(va) ((va & VA_PTE_NUM_MASK) >> VA_PTE_NUM_SHIFT)
87 
88 #define PA_PGNUM(pa) ((unsigned)pa >> PGSHIFT)
89 
90 #endif /* _MACHINE_PTE3_H */
91