ia64/xen-unstable

view extras/mini-os/h/mm.h @ 4072:ee7313088070

bitkeeper revision 1.1159.258.38 (4230628bX3yukmWYtNDh925BckMoHQ)

Merge ssh://xenbk@gandalf.hpl.hp.com//var/bk/xen-2.0-testing.bk
into tetris.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-2.0-testing.bk
author iap10@tetris.cl.cam.ac.uk
date Thu Mar 10 15:06:51 2005 +0000 (2005-03-10)
parents aadd0dc51c45
children 9877b62b4f26 2d4c4c4574f2
line source
1 /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
2 ****************************************************************************
3 * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
4 ****************************************************************************
5 *
6 * File: mm.h
7 * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk)
8 * Changes:
9 *
10 * Date: Aug 2003
11 *
12 * Environment:
13 * Description:
14 *
15 ****************************************************************************
16 * $Id: h-insert.h,v 1.4 2002/11/08 16:03:55 rn Exp $
17 ****************************************************************************
18 * Permission is hereby granted, free of charge, to any person obtaining a copy
19 * of this software and associated documentation files (the "Software"), to
20 * deal in the Software without restriction, including without limitation the
21 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
22 * sell copies of the Software, and to permit persons to whom the Software is
23 * furnished to do so, subject to the following conditions:
24 *
25 * The above copyright notice and this permission notice shall be included in
26 * all copies or substantial portions of the Software.
27 *
28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
33 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
34 * DEALINGS IN THE SOFTWARE.
35 */
37 #ifndef _MM_H_
38 #define _MM_H_
40 #define PAGE_SHIFT 12
41 #define PAGE_SIZE (1UL << PAGE_SHIFT)
42 #define PAGE_MASK (~(PAGE_SIZE-1))
44 #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
45 #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
46 #define PFN_PHYS(x) ((x) << PAGE_SHIFT)
48 /* to align the pointer to the (next) page boundary */
49 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
51 extern unsigned long *phys_to_machine_mapping;
52 #define pfn_to_mfn(_pfn) (phys_to_machine_mapping[(_pfn)])
53 #define mfn_to_pfn(_mfn) (machine_to_phys_mapping[(_mfn)])
54 static __inline__ unsigned long phys_to_machine(unsigned long phys)
55 {
56 unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT);
57 machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
58 return machine;
59 }
60 static __inline__ unsigned long machine_to_phys(unsigned long machine)
61 {
62 unsigned long phys = mfn_to_pfn(machine >> PAGE_SHIFT);
63 phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
64 return phys;
65 }
67 #define VIRT_START 0xC0000000UL
69 #define to_phys(x) ((unsigned long)(x)-VIRT_START)
70 #define to_virt(x) ((void *)((unsigned long)(x)+VIRT_START))
72 void init_mm(void);
73 unsigned long alloc_pages(int order);
75 #endif /* _MM_H_ */