|
|
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: #ifndef _OSKIT_PAGE_H_
39: #define _OSKIT_PAGE_H_ /* Preempt identical oskit definitions. */
40: #endif
41:
42: #include <mach/machine/vm_param.h>
43: #include <mach/machine/vm_types.h>
44:
45: /*
46: * The machine independent pages are refered to as PAGES. A page
47: * is some number of hardware pages, depending on the target machine.
48: *
49: * All references to the size of a page should be done
50: * with PAGE_SIZE, PAGE_SHIFT, or PAGE_MASK.
51: * They may be implemented as either constants or variables,
52: * depending on more-specific code.
53: * If they're variables, they had better be initialized
54: * by the time system-independent code starts getting called.
55: *
56: * Regardless whether it is implemented with a constant or a variable,
57: * the PAGE_SIZE is assumed to be a power of two throughout the
58: * virtual memory system implementation.
59: *
60: * More-specific code must at least provide PAGE_SHIFT;
61: * we can calculate the others if necessary.
62: * (However, if PAGE_SHIFT really refers to a variable,
63: * PAGE_SIZE and PAGE_MASK should also be variables
64: * so their values don't have to be constantly recomputed.)
65: */
66: #ifndef PAGE_SHIFT
67: #error mach/machine/vm_param.h needs to define PAGE_SHIFT.
68: #endif
69:
70: #ifndef PAGE_SIZE
71: #define PAGE_SIZE (1 << PAGE_SHIFT)
72: #endif
73:
74: #ifndef PAGE_MASK
75: #define PAGE_MASK (PAGE_SIZE-1)
76: #endif
77:
78: /*
79: * Convert addresses to pages and vice versa.
80: * No rounding is used.
81: */
82:
83: #undef atop
84: #define atop(x) (((vm_size_t)(x)) >> PAGE_SHIFT)
85: #undef ptoa
86: #define ptoa(x) ((vm_offset_t)((x) << PAGE_SHIFT))
87:
88: /*
89: * Round off or truncate to the nearest page. These will work
90: * for either addresses or counts. (i.e. 1 byte rounds to 1 page
91: * bytes.
92: */
93:
94: #undef round_page
95: #define round_page(x) ((vm_offset_t)((((vm_offset_t)(x)) + PAGE_MASK) & ~PAGE_MASK))
96: #undef trunc_page
97: #define trunc_page(x) ((vm_offset_t)(((vm_offset_t)(x)) & ~PAGE_MASK))
98:
99: /*
100: * Determine whether an address is page-aligned, or a count is
101: * an exact page multiple.
102: */
103:
104: #undef page_aligned
105: #define page_aligned(x) ((((vm_offset_t) (x)) & PAGE_MASK) == 0)
106:
107: #endif /* _MACH_VM_PARAM_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.