Commit | Line | Data |
---|---|---|
175f072e | 1 | /* |
175f072e KM |
2 | * Copyright (c) 1991 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
5 | * This code is derived from software contributed to Berkeley by | |
6 | * The Mach Operating System project at Carnegie-Mellon University. | |
7 | * | |
0e24ad83 | 8 | * %sccs.include.redist.c% |
175f072e | 9 | * |
9e46e59c | 10 | * @(#)vm_param.h 7.5 (Berkeley) %G% |
0e24ad83 KM |
11 | * |
12 | * | |
13 | * Copyright (c) 1987, 1990 Carnegie-Mellon University. | |
14 | * All rights reserved. | |
15 | * | |
16 | * Authors: Avadis Tevanian, Jr., Michael Wayne Young | |
17 | * | |
18 | * Permission to use, copy, modify and distribute this software and | |
19 | * its documentation is hereby granted, provided that both the copyright | |
20 | * notice and this permission notice appear in all copies of the | |
21 | * software, derivative works or modified versions, and any portions | |
22 | * thereof, and that both notices appear in supporting documentation. | |
23 | * | |
24 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
25 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND | |
26 | * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
27 | * | |
28 | * Carnegie Mellon requests users of this software to return to | |
29 | * | |
30 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
31 | * School of Computer Science | |
32 | * Carnegie Mellon University | |
33 | * Pittsburgh PA 15213-3890 | |
34 | * | |
35 | * any improvements or extensions that they make and grant Carnegie the | |
36 | * rights to redistribute these changes. | |
175f072e KM |
37 | */ |
38 | ||
39 | /* | |
40 | * Machine independent virtual memory parameters. | |
41 | */ | |
42 | ||
43 | #ifndef _VM_PARAM_ | |
44 | #define _VM_PARAM_ | |
45 | ||
46 | #ifdef KERNEL | |
47 | #include "machine/vmparam.h" | |
48 | #else | |
49 | #include <machine/vmparam.h> | |
50 | #endif | |
51 | ||
52 | /* | |
53 | * This belongs in types.h, but breaks too many existing programs. | |
54 | */ | |
55 | typedef int boolean_t; | |
56 | #define TRUE 1 | |
57 | #define FALSE 0 | |
58 | ||
59 | /* | |
60 | * The machine independent pages are refered to as PAGES. A page | |
61 | * is some number of hardware pages, depending on the target machine. | |
62 | */ | |
c34d10ef | 63 | #define DEFAULT_PAGE_SIZE 4096 |
175f072e KM |
64 | |
65 | /* | |
66 | * All references to the size of a page should be done with PAGE_SIZE | |
67 | * or PAGE_SHIFT. The fact they are variables is hidden here so that | |
68 | * we can easily make them constant if we so desire. | |
69 | */ | |
f92ce83a | 70 | #define PAGE_SIZE cnt.v_page_size /* size of page */ |
9e46e59c | 71 | #define PAGE_MASK page_mask /* size of page - 1 */ |
c34d10ef | 72 | #define PAGE_SHIFT page_shift /* bits to shift for pages */ |
9e46e59c KM |
73 | #ifdef KERNEL |
74 | extern vm_size_t page_mask; | |
75 | extern int page_shift; | |
76 | #endif | |
77 | ||
175f072e KM |
78 | |
79 | /* | |
80 | * Return values from the VM routines. | |
81 | */ | |
82 | #define KERN_SUCCESS 0 | |
83 | #define KERN_INVALID_ADDRESS 1 | |
84 | #define KERN_PROTECTION_FAILURE 2 | |
85 | #define KERN_NO_SPACE 3 | |
86 | #define KERN_INVALID_ARGUMENT 4 | |
87 | #define KERN_FAILURE 5 | |
88 | #define KERN_RESOURCE_SHORTAGE 6 | |
89 | #define KERN_NOT_RECEIVER 7 | |
90 | #define KERN_NO_ACCESS 8 | |
91 | ||
92 | #ifdef ASSEMBLER | |
93 | #else ASSEMBLER | |
94 | /* | |
95 | * Convert addresses to pages and vice versa. | |
96 | * No rounding is used. | |
97 | */ | |
98 | ||
99 | #ifdef KERNEL | |
9e46e59c KM |
100 | #define atop(x) (((unsigned)(x)) >> PAGE_SHIFT) |
101 | #define ptoa(x) ((vm_offset_t)((x) << PAGE_SHIFT)) | |
175f072e KM |
102 | #endif KERNEL |
103 | ||
104 | /* | |
105 | * Round off or truncate to the nearest page. These will work | |
106 | * for either addresses or counts. (i.e. 1 byte rounds to 1 page | |
107 | * bytes. | |
108 | */ | |
109 | ||
110 | #ifdef KERNEL | |
9e46e59c KM |
111 | #define round_page(x) \ |
112 | ((vm_offset_t)((((vm_offset_t)(x)) + PAGE_MASK) & ~PAGE_MASK)) | |
113 | #define trunc_page(x) \ | |
114 | ((vm_offset_t)(((vm_offset_t)(x)) & ~PAGE_MASK)) | |
115 | #define num_pages(x) \ | |
116 | ((vm_offset_t)((((vm_offset_t)(x)) + PAGE_MASK) >> PAGE_SHIFT)) | |
175f072e | 117 | #else KERNEL |
9e46e59c KM |
118 | #define round_page(x) \ |
119 | ((((vm_offset_t)(x) + (vm_page_size - 1)) / vm_page_size) * vm_page_size) | |
120 | #define trunc_page(x) \ | |
121 | ((((vm_offset_t)(x)) / vm_page_size) * vm_page_size) | |
175f072e KM |
122 | #endif KERNEL |
123 | ||
124 | #ifdef KERNEL | |
175f072e KM |
125 | extern vm_size_t mem_size; /* size of physical memory (bytes) */ |
126 | extern vm_offset_t first_addr; /* first physical page */ | |
127 | extern vm_offset_t last_addr; /* last physical page */ | |
128 | #endif KERNEL | |
129 | ||
130 | #endif ASSEMBLER | |
131 | ||
132 | #endif _VM_PARAM_ |