|
|
1.1 root 1: /*
2: * Mach Operating System
3: * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
4: * All Rights Reserved.
5: *
6: * Permission to use, copy, modify and distribute this software and its
7: * documentation is hereby granted, provided that both the copyright
8: * notice and this permission notice appear in all copies of the
9: * software, derivative works or modified versions, and any portions
10: * thereof, and that both notices appear in supporting documentation.
11: *
12: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15: *
16: * Carnegie Mellon requests users of this software to return to
17: *
18: * Software Distribution Coordinator or [email protected]
19: * School of Computer Science
20: * Carnegie Mellon University
21: * Pittsburgh PA 15213-3890
22: *
23: * any improvements or extensions that they make and grant Carnegie Mellon
24: * the rights to redistribute these changes.
25: */
26: /*
27: * File: mach/vm_param.h
28: * Author: Avadis Tevanian, Jr., Michael Wayne Young
29: * Date: 1985
30: *
31: * Machine independent virtual memory parameters.
32: *
33: */
34:
35: #ifndef _MACH_VM_PARAM_H_
36: #define _MACH_VM_PARAM_H_
37:
38: #include <mach/machine/vm_param.h>
39: #include <mach/machine/vm_types.h>
40:
41: /*
42: * The machine independent pages are refered to as PAGES. A page
43: * is some number of hardware pages, depending on the target machine.
44: *
45: * All references to the size of a page should be done
46: * with PAGE_SIZE, PAGE_SHIFT, or PAGE_MASK.
47: * They may be implemented as either constants or variables,
48: * depending on more-specific code.
49: * If they're variables, they had better be initialized
50: * by the time system-independent code starts getting called.
51: *
52: * Regardless whether it is implemented with a constant or a variable,
53: * the PAGE_SIZE is assumed to be a power of two throughout the
54: * virtual memory system implementation.
55: *
56: * More-specific code must at least provide PAGE_SHIFT;
57: * we can calculate the others if necessary.
58: * (However, if PAGE_SHIFT really refers to a variable,
59: * PAGE_SIZE and PAGE_MASK should also be variables
60: * so their values don't have to be constantly recomputed.)
61: */
62: #ifndef PAGE_SHIFT
63: #error mach/machine/vm_param.h needs to define PAGE_SHIFT.
64: #endif
65:
66: #ifndef PAGE_SIZE
67: #define PAGE_SIZE (1 << PAGE_SHIFT)
68: #endif
69:
70: #ifndef PAGE_MASK
71: #define PAGE_MASK (PAGE_SIZE-1)
72: #endif
73:
74: /*
75: * Convert addresses to pages and vice versa.
76: * No rounding is used.
77: */
78:
79: #define atop(x) (((vm_size_t)(x)) >> PAGE_SHIFT)
80: #define ptoa(x) ((vm_offset_t)((x) << PAGE_SHIFT))
81:
82: /*
83: * Round off or truncate to the nearest page. These will work
84: * for either addresses or counts. (i.e. 1 byte rounds to 1 page
85: * bytes.
86: */
87:
88: #define round_page(x) ((vm_offset_t)((((vm_offset_t)(x)) + PAGE_MASK) & ~PAGE_MASK))
89: #define trunc_page(x) ((vm_offset_t)(((vm_offset_t)(x)) & ~PAGE_MASK))
90:
91: /*
92: * Determine whether an address is page-aligned, or a count is
93: * an exact page multiple.
94: */
95:
96: #define page_aligned(x) ((((vm_offset_t) (x)) & PAGE_MASK) == 0)
97:
98: #endif /* _MACH_VM_PARAM_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.