xref: /onnv-gate/usr/src/uts/common/vm/seg_kpm.h (revision 12004:93f274d4a367)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*12004Sjiang.liu@intel.com  * Common Development and Distribution License (the "License").
6*12004Sjiang.liu@intel.com  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
220Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_VM_SEG_KPM_H
270Sstevel@tonic-gate #define	_VM_SEG_KPM_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef	__cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate /*
340Sstevel@tonic-gate  * Kernel Physical Mapping (segkpm) segment driver.
350Sstevel@tonic-gate  */
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #include <vm/kpm.h>
380Sstevel@tonic-gate 
390Sstevel@tonic-gate struct segkpm_data {
400Sstevel@tonic-gate 	ushort_t *skd_va_select; /* page_create_va kpm vaddr bin count */
410Sstevel@tonic-gate 	short    skd_nvcolors;   /* VAC colors to deal with */
420Sstevel@tonic-gate 	uchar_t  skd_prot;
430Sstevel@tonic-gate };
440Sstevel@tonic-gate 
450Sstevel@tonic-gate /*
460Sstevel@tonic-gate  * segkpm create needs some platform knowledge
470Sstevel@tonic-gate  */
480Sstevel@tonic-gate struct segkpm_crargs {
490Sstevel@tonic-gate 	uint_t	prot;
500Sstevel@tonic-gate 	short	nvcolors;	/* VAC # virtual colors, 0 for PAC. */
510Sstevel@tonic-gate };
520Sstevel@tonic-gate 
530Sstevel@tonic-gate extern struct seg *segkpm;
540Sstevel@tonic-gate extern u_offset_t kpm_pgoff;
550Sstevel@tonic-gate extern size_t	kpm_pgsz;
560Sstevel@tonic-gate extern uint_t	kpm_pgshft;
570Sstevel@tonic-gate extern uint_t	kpmp2pshft;
580Sstevel@tonic-gate extern pgcnt_t	kpmpnpgs;
590Sstevel@tonic-gate 
600Sstevel@tonic-gate /* kpm controls */
610Sstevel@tonic-gate extern int	kpm_enable;
620Sstevel@tonic-gate extern int	kpm_smallpages;
630Sstevel@tonic-gate extern int	segmap_kpm;
640Sstevel@tonic-gate 
650Sstevel@tonic-gate /*
660Sstevel@tonic-gate  * kpm_page_t macros:
670Sstevel@tonic-gate  * . bytes (b) to kpm pages (kpmp)
680Sstevel@tonic-gate  * . pages (p) to kpm pages (kpmp), and back (with and without roundup)
690Sstevel@tonic-gate  * . kpm page offset in bytes
700Sstevel@tonic-gate  * . pages (p) modulo kpm pages (kpmp)
710Sstevel@tonic-gate  */
720Sstevel@tonic-gate #define	btokpmp(x)	((x) >> kpm_pgshft)
730Sstevel@tonic-gate #define	btokpmpr(x)	(((x) + kpm_pgoff) >> kpm_pgshft)
740Sstevel@tonic-gate #define	ptokpmp(x)	((x) >> kpmp2pshft)
750Sstevel@tonic-gate #define	ptokpmpr(x)	(((x) + (kpmpnpgs - 1)) >> kpmp2pshft)
760Sstevel@tonic-gate #define	kpmptop(x)	((x) << kpmp2pshft)
770Sstevel@tonic-gate #define	kpmpageoff(x)	((x) & kpm_pgoff)
780Sstevel@tonic-gate #define	pmodkpmp(x)	((x) & (kpmpnpgs - 1))
790Sstevel@tonic-gate 
800Sstevel@tonic-gate #ifdef	SEGKPM_SUPPORT
810Sstevel@tonic-gate 
820Sstevel@tonic-gate #define	IS_KPM_ADDR(addr) \
830Sstevel@tonic-gate 	((addr) >= segkpm->s_base && (addr) < (segkpm->s_base + segkpm->s_size))
840Sstevel@tonic-gate 
85*12004Sjiang.liu@intel.com #ifdef	__x86
86*12004Sjiang.liu@intel.com /* x86 systems use neither kpm_page_t nor kpm_spage_t when supporting kpm. */
87*12004Sjiang.liu@intel.com #define	KPMPAGE_T_SZ	(0)
88*12004Sjiang.liu@intel.com #else	/* __x86 */
890Sstevel@tonic-gate #define	KPMPAGE_T_SZ \
900Sstevel@tonic-gate 	((kpm_smallpages == 0) ? sizeof (kpm_page_t) : sizeof (kpm_spage_t))
91*12004Sjiang.liu@intel.com #endif	/* __x86 */
920Sstevel@tonic-gate 
930Sstevel@tonic-gate #else	/* SEGKPM_SUPPORT */
940Sstevel@tonic-gate 
950Sstevel@tonic-gate #define	IS_KPM_ADDR(addr) (segkpm != NULL)
960Sstevel@tonic-gate #define	KPMPAGE_T_SZ	(0)
970Sstevel@tonic-gate 
980Sstevel@tonic-gate #endif	/* SEGKPM_SUPPORT */
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate #ifdef _KERNEL
1010Sstevel@tonic-gate /*
1020Sstevel@tonic-gate  * Public seg_kpm segment operations.
1030Sstevel@tonic-gate  */
1040Sstevel@tonic-gate extern int		segkpm_create(struct seg *, void *);
1050Sstevel@tonic-gate extern faultcode_t	segkpm_fault(struct hat *, struct seg *, caddr_t,
1060Sstevel@tonic-gate 				size_t, enum fault_type, enum seg_rw);
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate /*
1090Sstevel@tonic-gate  * Public seg_kpm interfaces.
1100Sstevel@tonic-gate  */
1110Sstevel@tonic-gate extern caddr_t	segkpm_create_va(u_offset_t);
1120Sstevel@tonic-gate extern void	segkpm_mapout_validkpme(struct kpme *);
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate #endif	/* _KERNEL */
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate #ifdef	__cplusplus
1170Sstevel@tonic-gate }
1180Sstevel@tonic-gate #endif
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate #endif	/* _VM_SEG_KPM_H */
121