xref: /titanic_51/usr/src/uts/common/vm/seg_kpm.h (revision 45818ee124adeaaf947698996b4f4c722afc6d1f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_VM_SEG_KPM_H
27 #define	_VM_SEG_KPM_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * Kernel Physical Mapping (segkpm) segment driver.
35  */
36 
37 #include <vm/kpm.h>
38 
39 struct segkpm_data {
40 	ushort_t *skd_va_select; /* page_create_va kpm vaddr bin count */
41 	short    skd_nvcolors;   /* VAC colors to deal with */
42 	uchar_t  skd_prot;
43 };
44 
45 /*
46  * segkpm create needs some platform knowledge
47  */
48 struct segkpm_crargs {
49 	uint_t	prot;
50 	short	nvcolors;	/* VAC # virtual colors, 0 for PAC. */
51 };
52 
53 extern struct seg *segkpm;
54 extern u_offset_t kpm_pgoff;
55 extern size_t	kpm_pgsz;
56 extern uint_t	kpm_pgshft;
57 extern uint_t	kpmp2pshft;
58 extern pgcnt_t	kpmpnpgs;
59 
60 /* kpm controls */
61 extern int	kpm_enable;
62 extern int	kpm_smallpages;
63 extern int	segmap_kpm;
64 
65 /*
66  * kpm_page_t macros:
67  * . bytes (b) to kpm pages (kpmp)
68  * . pages (p) to kpm pages (kpmp), and back (with and without roundup)
69  * . kpm page offset in bytes
70  * . pages (p) modulo kpm pages (kpmp)
71  */
72 #define	btokpmp(x)	((x) >> kpm_pgshft)
73 #define	btokpmpr(x)	(((x) + kpm_pgoff) >> kpm_pgshft)
74 #define	ptokpmp(x)	((x) >> kpmp2pshft)
75 #define	ptokpmpr(x)	(((x) + (kpmpnpgs - 1)) >> kpmp2pshft)
76 #define	kpmptop(x)	((x) << kpmp2pshft)
77 #define	kpmpageoff(x)	((x) & kpm_pgoff)
78 #define	pmodkpmp(x)	((x) & (kpmpnpgs - 1))
79 
80 #ifdef	SEGKPM_SUPPORT
81 
82 #define	IS_KPM_ADDR(addr) \
83 	((addr) >= segkpm->s_base && (addr) < (segkpm->s_base + segkpm->s_size))
84 
85 #ifdef	__x86
86 /* x86 systems use neither kpm_page_t nor kpm_spage_t when supporting kpm. */
87 #define	KPMPAGE_T_SZ	(0)
88 #else	/* __x86 */
89 #define	KPMPAGE_T_SZ \
90 	((kpm_smallpages == 0) ? sizeof (kpm_page_t) : sizeof (kpm_spage_t))
91 #endif	/* __x86 */
92 
93 #else	/* SEGKPM_SUPPORT */
94 
95 #define	IS_KPM_ADDR(addr) (segkpm != NULL)
96 #define	KPMPAGE_T_SZ	(0)
97 
98 #endif	/* SEGKPM_SUPPORT */
99 
100 #ifdef _KERNEL
101 /*
102  * Public seg_kpm segment operations.
103  */
104 extern int		segkpm_create(struct seg *, void *);
105 extern faultcode_t	segkpm_fault(struct hat *, struct seg *, caddr_t,
106 				size_t, enum fault_type, enum seg_rw);
107 
108 /*
109  * Public seg_kpm interfaces.
110  */
111 extern caddr_t	segkpm_create_va(u_offset_t);
112 extern void	segkpm_mapout_validkpme(struct kpme *);
113 
114 #endif	/* _KERNEL */
115 
116 #ifdef	__cplusplus
117 }
118 #endif
119 
120 #endif	/* _VM_SEG_KPM_H */
121