xref: /csrg-svn/sys/vm/vm_param.h (revision 50912)
145748Smckusick /*
245748Smckusick  * Copyright (c) 1991 Regents of the University of California.
345748Smckusick  * All rights reserved.
445748Smckusick  *
545748Smckusick  * This code is derived from software contributed to Berkeley by
645748Smckusick  * The Mach Operating System project at Carnegie-Mellon University.
745748Smckusick  *
848493Smckusick  * %sccs.include.redist.c%
945748Smckusick  *
10*50912Smckusick  *	@(#)vm_param.h	7.4 (Berkeley) 08/28/91
1148493Smckusick  *
1248493Smckusick  *
1348493Smckusick  * Copyright (c) 1987, 1990 Carnegie-Mellon University.
1448493Smckusick  * All rights reserved.
1548493Smckusick  *
1648493Smckusick  * Authors: Avadis Tevanian, Jr., Michael Wayne Young
1748493Smckusick  *
1848493Smckusick  * Permission to use, copy, modify and distribute this software and
1948493Smckusick  * its documentation is hereby granted, provided that both the copyright
2048493Smckusick  * notice and this permission notice appear in all copies of the
2148493Smckusick  * software, derivative works or modified versions, and any portions
2248493Smckusick  * thereof, and that both notices appear in supporting documentation.
2348493Smckusick  *
2448493Smckusick  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
2548493Smckusick  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
2648493Smckusick  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
2748493Smckusick  *
2848493Smckusick  * Carnegie Mellon requests users of this software to return to
2948493Smckusick  *
3048493Smckusick  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
3148493Smckusick  *  School of Computer Science
3248493Smckusick  *  Carnegie Mellon University
3348493Smckusick  *  Pittsburgh PA 15213-3890
3448493Smckusick  *
3548493Smckusick  * any improvements or extensions that they make and grant Carnegie the
3648493Smckusick  * rights to redistribute these changes.
3745748Smckusick  */
3845748Smckusick 
3945748Smckusick /*
4045748Smckusick  *	Machine independent virtual memory parameters.
4145748Smckusick  */
4245748Smckusick 
4345748Smckusick #ifndef	_VM_PARAM_
4445748Smckusick #define	_VM_PARAM_
4545748Smckusick 
4645748Smckusick #ifdef KERNEL
4745748Smckusick #include "machine/vmparam.h"
4845748Smckusick #else
4945748Smckusick #include <machine/vmparam.h>
5045748Smckusick #endif
5145748Smckusick 
5245748Smckusick /*
5345748Smckusick  * This belongs in types.h, but breaks too many existing programs.
5445748Smckusick  */
5545748Smckusick typedef int	boolean_t;
5645748Smckusick #define	TRUE	1
5745748Smckusick #define	FALSE	0
5845748Smckusick 
5945748Smckusick /*
6045748Smckusick  *	The machine independent pages are refered to as PAGES.  A page
6145748Smckusick  *	is some number of hardware pages, depending on the target machine.
6245748Smckusick  */
6350547Smckusick #define DEFAULT_PAGE_SIZE	4096
6445748Smckusick 
6545748Smckusick /*
6645748Smckusick  *	All references to the size of a page should be done with PAGE_SIZE
6745748Smckusick  *	or PAGE_SHIFT.  The fact they are variables is hidden here so that
6845748Smckusick  *	we can easily make them constant if we so desire.
6945748Smckusick  */
70*50912Smckusick #define	PAGE_SIZE	cnt.v_page_size		/* size of page */
7150547Smckusick #define PAGE_SHIFT	page_shift		/* bits to shift for pages */
7245748Smckusick 
7345748Smckusick /*
7445748Smckusick  *	Return values from the VM routines.
7545748Smckusick  */
7645748Smckusick #define	KERN_SUCCESS		0
7745748Smckusick #define	KERN_INVALID_ADDRESS	1
7845748Smckusick #define	KERN_PROTECTION_FAILURE	2
7945748Smckusick #define	KERN_NO_SPACE		3
8045748Smckusick #define	KERN_INVALID_ARGUMENT	4
8145748Smckusick #define	KERN_FAILURE		5
8245748Smckusick #define	KERN_RESOURCE_SHORTAGE	6
8345748Smckusick #define	KERN_NOT_RECEIVER	7
8445748Smckusick #define	KERN_NO_ACCESS		8
8545748Smckusick 
8645748Smckusick #ifdef	ASSEMBLER
8745748Smckusick #else	ASSEMBLER
8845748Smckusick /*
8945748Smckusick  *	Convert addresses to pages and vice versa.
9045748Smckusick  *	No rounding is used.
9145748Smckusick  */
9245748Smckusick 
9345748Smckusick #ifdef	KERNEL
9445748Smckusick #define	atop(x)		(((unsigned)(x)) >> page_shift)
9545748Smckusick #define	ptoa(x)		((vm_offset_t)((x) << page_shift))
9645748Smckusick #endif	KERNEL
9745748Smckusick 
9845748Smckusick /*
9945748Smckusick  *	Round off or truncate to the nearest page.  These will work
10045748Smckusick  *	for either addresses or counts.  (i.e. 1 byte rounds to 1 page
10145748Smckusick  *	bytes.
10245748Smckusick  */
10345748Smckusick 
10445748Smckusick #ifdef	KERNEL
10545748Smckusick #define round_page(x)	((vm_offset_t)((((vm_offset_t)(x)) + page_mask) & ~page_mask))
10645748Smckusick #define trunc_page(x)	((vm_offset_t)(((vm_offset_t)(x)) & ~page_mask))
10745748Smckusick #else	KERNEL
10845748Smckusick #define	round_page(x)	((((vm_offset_t)(x) + (vm_page_size - 1)) / vm_page_size) * vm_page_size)
10945748Smckusick #define	trunc_page(x)	((((vm_offset_t)(x)) / vm_page_size) * vm_page_size)
11045748Smckusick #endif	KERNEL
11145748Smckusick 
11245748Smckusick #ifdef	KERNEL
113*50912Smckusick extern vm_size_t	page_mask;	/* cnt.v_page_size - 1; mask for
11445748Smckusick 						   offset within page */
11545748Smckusick extern int		page_shift;	/* shift to use for page size */
11645748Smckusick 
11745748Smckusick extern vm_size_t	mem_size;	/* size of physical memory (bytes) */
11845748Smckusick extern vm_offset_t	first_addr;	/* first physical page */
11945748Smckusick extern vm_offset_t	last_addr;	/* last physical page */
12045748Smckusick #endif	KERNEL
12145748Smckusick 
12245748Smckusick #endif	ASSEMBLER
12345748Smckusick 
12445748Smckusick #endif	_VM_PARAM_
125