Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 * Copyright (c) 1994-1997 The University of Utah and the Flux Group.
3
 * All rights reserved.
4
 *
5
 * This file is part of the Flux OSKit.  The OSKit is free software, also known
6
 * as "open source;" you can redistribute it and/or modify it under the terms
7
 * of the GNU General Public License (GPL), version 2, as published by the Free
8
 * Software Foundation (FSF).  To explore alternate licensing terms, contact
9
 * the University of Utah at csl-dist@cs.utah.edu or +1-801-585-3271.
10
 *
11
 * The OSKit is distributed in the hope that it will be useful, but WITHOUT ANY
12
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE.  See the GPL for more details.  You should have
14
 * received a copy of the GPL along with the OSKit; see the file COPYING.  If
15
 * not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA.
16
 */
17
 
18
/*
19
 * Mach Operating System
20
 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University.
21
 * All Rights Reserved.
22
 *
23
 * Permission to use, copy, modify and distribute this software and its
24
 * documentation is hereby granted, provided that both the copyright
25
 * notice and this permission notice appear in all copies of the
26
 * software, derivative works or modified versions, and any portions
27
 * thereof, and that both notices appear in supporting documentation.
28
 *
29
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
30
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
31
 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
32
 *
33
 * Carnegie Mellon requests users of this software to return to
34
 *
35
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
36
 *  School of Computer Science
37
 *  Carnegie Mellon University
38
 *  Pittsburgh PA 15213-3890
39
 *
40
 * any improvements or extensions that they make and grant Carnegie Mellon
41
 * the rights to redistribute these changes.
42
 */
43
/*
44
 *      File:   oskit/page.h
45
 *      Author: Avadis Tevanian, Jr., Michael Wayne Young
46
 *
47
 *      Machine independent virtual memory parameters.
48
 *      In this file, the term "page" refers to the _minimum_ page size
49
 *      supported by the hardware architecture, and is always a power of two.
50
 *      Some architectures and OS environments support optional
51
 *      larger page sizes as well, and/or unaligned "block mappings".
52
 */
53
#ifndef __KERNEL_MEM_PAGE_H__
54
#define __KERNEL_MEM_PAGE_H__
55
 
56
/* was in machine/page.h */
57
#define PAGE_SHIFT      12
58
 
59
#ifndef PAGE_SIZE
60
#define PAGE_SIZE (1 << PAGE_SHIFT)
61
#endif
62
 
63
#ifndef PAGE_MASK
64
#define PAGE_MASK (PAGE_SIZE-1)
65
#endif
66
 
67
/*
68
 *      Convert addresses to pages and vice versa.
69
 *      No rounding is used.
70
 */
71
 
72
#define atop(x)         (((oskit_size_t)(x)) >> PAGE_SHIFT)
73
#define ptoa(x)         ((oskit_addr_t)((x) << PAGE_SHIFT))
74
 
75
/*
76
 *      Round off or truncate to the nearest page.  These will work
77
 *      for either addresses or counts.  (i.e. 1 byte rounds to 1 page
78
 *      bytes.
79
 */
80
 
81
#define round_page(x)   ((oskit_addr_t)((((oskit_addr_t)(x)) + PAGE_MASK) & ~PAGE_MASK))
82
#define trunc_page(x)   ((oskit_addr_t)(((oskit_addr_t)(x)) & ~PAGE_MASK))
83
 
84
/*
85
 *      Determine whether an address is page-aligned, or a count is
86
 *      an exact page multiple.
87
 */
88
 
89
#define page_aligned(x) ((((oskit_addr_t) (x)) & PAGE_MASK) == 0)
90
 
91
#endif  /* _OSKIT_PAGE_H_ */