xref: /netbsd-src/sys/arch/sun3/include/pte.h (revision fdecd6a253f999ae92b139670d9e15cc9df4497c)
1 /*	$NetBSD: pte.h,v 1.15 1997/06/10 19:35:56 veego 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_PTE_H
40 #define _MACHINE_PTE_H
41 
42 #define NCONTEXT 8
43 #define SEGINV 255
44 #define NPAGSEG 16
45 #define NSEGMAP 2048
46 
47 #define PG_VALID   0x80000000
48 #define PG_WRITE   0x40000000
49 #define PG_SYSTEM  0x20000000
50 #define PG_NC      0x10000000
51 #define PG_TYPE    0x0C000000
52 #define PG_REF     0x02000000
53 #define PG_MOD     0x01000000
54 
55 #define PG_SPECIAL (PG_VALID|PG_WRITE|PG_SYSTEM|PG_NC|PG_REF|PG_MOD)
56 #define PG_PERM    (PG_VALID|PG_WRITE|PG_SYSTEM|PG_NC)
57 #define	PG_MODREF  (PG_REF|PG_MOD)
58 #define PG_FRAME   0x0007FFFF
59 
60 #define PG_MOD_SHIFT 24
61 #define PG_PERM_SHIFT 28
62 
63 #define OBMEM	0
64 #define OBIO 	1
65 #define VME_D16	2
66 #define VME_D32	3
67 #define PG_TYPE_SHIFT 26
68 
69 #define PG_INVAL   0x0
70 
71 #define MAKE_PGTYPE(x) ((x) << PG_TYPE_SHIFT)
72 #define PG_PGNUM(pte) (pte & PG_FRAME)
73 #define PG_PA(pte) ((pte & PG_FRAME) <<PGSHIFT)
74 
75 #define	PGT_MASK	MAKE_PGTYPE(3)
76 #define	PGT_OBMEM	MAKE_PGTYPE(OBMEM)		/* onboard memory */
77 #define	PGT_OBIO	MAKE_PGTYPE(OBIO)		/* onboard I/O */
78 #define	PGT_VME_D16	MAKE_PGTYPE(VME_D16)	/* VMEbus 16-bit data */
79 #define	PGT_VME_D32	MAKE_PGTYPE(VME_D32)	/* VMEbus 32-bit data */
80 
81 #define VA_SEGNUM(x)	((u_int)(x) >> SEGSHIFT)
82 
83 #define VA_PTE_NUM_SHIFT  13
84 #define VA_PTE_NUM_MASK (0xF << VA_PTE_NUM_SHIFT)
85 #define VA_PTE_NUM(va) ((va & VA_PTE_NUM_MASK) >> VA_PTE_NUM_SHIFT)
86 
87 #define PA_PGNUM(pa) ((unsigned)pa >> PGSHIFT)
88 
89 #endif /* !_MACHINE_PTE_H*/
90