pte3x.h revision 1.1 1 /* $NetBSD: pte3x.h,v 1.1 1997/01/14 20:57:05 gwr Exp $ */
2
3 /*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jeremy Cooper.
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 #include <machine/mc68851.h>
43
44 #define OBMEM 0
45 #define OBIO 1
46 #define VME_D16 2
47 #define VME_D32 3
48 #define PG_TYPE_SHIFT 26
49
50 #define MAKE_PGTYPE(x) ((x) << PG_TYPE_SHIFT)
51 #define PG_PGNUM(pte) (pte & PG_FRAME)
52 #define PG_PA(pte) ((pte & PG_FRAME) <<PGSHIFT)
53
54 #define PGT_MASK MAKE_PGTYPE(3)
55 #define PGT_OBMEM MAKE_PGTYPE(OBMEM) /* onboard memory */
56 #define PGT_OBIO MAKE_PGTYPE(OBIO) /* onboard I/O */
57 #define PGT_VME_D16 MAKE_PGTYPE(VME_D16) /* VMEbus 16-bit data */
58 #define PGT_VME_D32 MAKE_PGTYPE(VME_D32) /* VMEbus 32-bit data */
59
60 #define VA_SEGNUM(x) ((u_int)(x) >> SEGSHIFT)
61
62 #define VA_PTE_NUM_SHIFT 13
63 #define VA_PTE_NUM_MASK (0xF << VA_PTE_NUM_SHIFT)
64 #define VA_PTE_NUM(va) ((va & VA_PTE_NUM_MASK) >> VA_PTE_NUM_SHIFT)
65
66 #define PA_PGNUM(pa) ((unsigned)pa >> PGSHIFT)
67
68 /*
69 * Mach derived conversion macros
70 */
71 #define sun3x_round_seg(x) ((((unsigned)(x)) + SEGOFSET) & ~SEGOFSET)
72 #define sun3x_trunc_seg(x) ((unsigned)(x) & ~SEGOFSET)
73 #define sun3x_btos(x) ((unsigned)(x) >> SEGSHIFT)
74 #define sun3x_stob(x) ((unsigned)(x) << SEGSHIFT)
75
76 #define sun3x_round_page(x) ((((unsigned)(x)) + PGOFSET) & ~PGOFSET)
77 #define sun3x_trunc_page(x) ((unsigned)(x) & ~PGOFSET)
78 #define sun3x_btop(x) ((unsigned)(x) >> PGSHIFT)
79 #define sun3x_ptob(x) ((unsigned)(x) << PGSHIFT)
80
81 /* XXX - Not sure about these. Use pmap_enter_kernel() instead? */
82 #if 1 /* XXX */
83 /* defined in pmap.c */
84 vm_offset_t get_pte __P((vm_offset_t va));
85 void set_pte __P((vm_offset_t, vm_offset_t));
86 #endif /* XXX */
87
88 #endif /* !_MACHINE_PTE_H*/
89