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