xref: /netbsd-src/sys/arch/sun3/include/pmap.h (revision ae1bfcddc410612bc8c58b807e1830becb69a24c)
1 /*
2  * Copyright (c) 1993 Adam Glass
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *	This product includes software developed by Adam Glass.
16  * 4. The name of the Author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  * $Header: /cvsroot/src/sys/arch/sun3/include/pmap.h,v 1.7 1994/04/24 20:10:18 glass Exp $
32  */
33 
34 #ifndef	_PMAP_MACHINE_
35 #define	_PMAP_MACHINE_
36 
37 #include <sys/queue.h>
38 
39 /*
40  * Pmap stuff
41  * [some ideas borrowed from torek, but no code]
42  */
43 
44 struct context_state {
45 	TAILQ_ENTRY(context_state) context_link;
46 	int            context_num;
47 	struct pmap   *context_upmap;
48 };
49 
50 typedef struct context_state *context_t;
51 
52 struct pmap {
53 	int	                pm_refcount;	/* pmap reference count */
54 	simple_lock_data_t      pm_lock;	/* lock on pmap */
55 	struct pmap_statistics	pm_stats;	/* pmap statistics */
56 	context_t               pm_context;     /* context if any */
57 	int                     pm_version;
58 	unsigned char           *pm_segmap;
59 };
60 
61 typedef struct pmap *pmap_t;
62 
63 extern pmap_t kernel_pmap;
64 
65 #define PMEGQ_FREE     0
66 #define PMEGQ_INACTIVE 1
67 #define PMEGQ_ACTIVE   2
68 #define PMEGQ_NONE     3
69 
70 struct pmeg_state {
71 	TAILQ_ENTRY(pmeg_state) pmeg_link;
72 	int            pmeg_index;
73 	pmap_t         pmeg_owner;
74 	int            pmeg_owner_version;
75 	vm_offset_t    pmeg_va;
76 	int            pmeg_wired_count;
77 	int            pmeg_reserved;
78 	int            pmeg_vpages;
79 	int            pmeg_qstate;
80 };
81 
82 typedef struct pmeg_state *pmeg_t;
83 
84 #define PMAP_ACTIVATE(pmap, pcbp, iscurproc) \
85       pmap_activate(pmap, pcbp)
86 #define PMAP_DEACTIVATE(pmap, pcbp) \
87       pmap_deactivate(pmap, pcbp)
88 
89 #define	pmap_kernel()			(kernel_pmap)
90 
91 /* like the sparc port, use the lower bits of a pa which must be page
92  *  aligned anyway to pass memtype, caching information.
93  */
94 #define PMAP_MMEM      0x0
95 #define PMAP_OBIO      0x1
96 #define PMAP_VME16D    0x2
97 #define PMAP_VME32D    0x3
98 #define PMAP_MEMMASK   0x3
99 #define PMAP_NC        0x4
100 #define PMAP_SPECMASK  0x7
101 
102 extern vm_offset_t virtual_avail, virtual_end;
103 extern vm_offset_t avail_start, avail_end;
104 
105 #endif	_PMAP_MACHINE_
106