xref: /freebsd/sys/powerpc/include/pmap.h (revision 1b6c76a2fe091c74f08427e6c870851025a9cf67)
1 /*-
2  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
3  * Copyright (C) 1995, 1996 TooLs GmbH.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *	This product includes software developed by TooLs GmbH.
17  * 4. The name of TooLs GmbH may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  *	$NetBSD: pmap.h,v 1.17 2000/03/30 16:18:24 jdolecek Exp $
32  * $FreeBSD$
33  */
34 
35 #ifndef	_MACHINE_PMAP_H_
36 #define	_MACHINE_PMAP_H_
37 
38 #include <machine/pte.h>
39 
40 /*
41  * Segment registers
42  */
43 #ifndef	LOCORE
44 typedef u_int sr_t;
45 #endif	/* LOCORE */
46 #define	SR_TYPE		0x80000000
47 #define	SR_SUKEY	0x40000000
48 #define	SR_PRKEY	0x20000000
49 #define	SR_VSID		0x00ffffff
50 
51 #ifndef LOCORE
52 
53 struct pv_entry {
54         struct pv_entry	*pv_next;	/* Linked list of mappings */
55         int		pv_idx;		/* Index into ptable */
56         vm_offset_t	pv_va;		/* virtual address of mapping */
57 };
58 
59 struct md_page {
60 	int	pv_list_count;
61 	int	pv_flags;
62 	TAILQ_HEAD(,pv_entry)	pv_list;
63 };
64 
65 /*
66  * Pmap stuff
67  */
68 struct pmap {
69 	sr_t pm_sr[16];		/* segments used in this pmap */
70 	int pm_refs;		/* ref count */
71 	struct pmap_statistics pm_stats;	/* pmap statistics */
72 };
73 
74 typedef	struct pmap *pmap_t;
75 
76 typedef struct pv_entry *pv_entry_t;
77 
78 #ifdef	_KERNEL
79 
80 #define pmap_clear_modify(pg)		(ptemodify((pg), PTE_CHG, 0))
81 #define	pmap_clear_reference(pg)	(ptemodify((pg), PTE_REF, 0))
82 #define	pmap_is_modified(pg)		(ptebits((pg), PTE_CHG))
83 #define	pmap_is_referenced(pg)		(ptebits((pg), PTE_REF))
84 #define	pmap_unwire(pm, va)
85 
86 #define	pmap_phys_address(x)		(x)
87 
88 #define	pmap_resident_count(pmap)	((pmap)->pm_stats.resident_count)
89 
90 extern pmap_t		kernel_pmap;
91 
92 extern vm_offset_t	avail_end;
93 extern vm_offset_t	avail_start;
94 extern vm_offset_t	phys_avail[];
95 extern vm_offset_t	virtual_avail;
96 extern vm_offset_t	virtual_end;
97 
98 void pmap_bootstrap __P((u_int kernelstart, u_int kernelend));
99 vm_offset_t pmap_steal_memory __P((vm_size_t));
100 boolean_t ptemodify __P((struct vm_page *, u_int, u_int));
101 int ptebits __P((struct vm_page *, int));
102 
103 #if 0
104 #define PMAP_NEED_PROCWR
105 void pmap_procwr __P((struct proc *, vaddr_t, size_t));
106 #endif
107 
108 /*
109  * Alternate mapping hooks for pool pages.  Avoids thrashing the TLB.
110  *
111  * Note: This won't work if we have more memory than can be direct-mapped
112  * VA==PA all at once.  But pmap_copy_page() and pmap_zero_page() will have
113  * this problem, too.
114  */
115 #define	PMAP_MAP_POOLPAGE(pa)	(pa)
116 #define	PMAP_UNMAP_POOLPAGE(pa)	(pa)
117 
118 #define	vtophys(va)	pmap_kextract(((vm_offset_t) (va)))
119 
120 extern	pte_t	PTmap[];
121 
122 #define	vtopte(x)	(PTmap + powerpc_btop(x))
123 
124 static __inline vm_offset_t
125 pmap_kextract(vm_offset_t va)
126 {
127 	/* XXX: coming soon... */
128 	return (0);
129 }
130 
131 #endif	/* _KERNEL */
132 #endif	/* LOCORE */
133 
134 #endif	/* _MACHINE_PMAP_H_ */
135