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