1/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
2 *
3 * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
4 * Copyright (c) 2005, Keir A Fraser
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#ifndef _MINIOS_MM_H_
26#define _MINIOS_MM_H_
27
28#if defined(__i386__)
29#include <xen/arch-x86_32.h>
30#elif defined(__x86_64__)
31#include <xen/arch-x86_64.h>
32#else
33#error "Unsupported architecture"
34#endif
35
36#include <mini-os/lib.h>
37
38#include <mini-os/machine/limits.h>
39#include <mini-os/machine/mm.h>
40
41#define STACK_SIZE_PAGE_ORDER __STACK_SIZE_PAGE_ORDER
42#define STACK_SIZE __STACK_SIZE
43
44
45void init_mm(void);
46
47static __inline__ int get_order(unsigned long size)
48{
49    int order;
50    size = (size-1) >> PAGE_SHIFT;
51    for ( order = 0; size; order++ )
52        size >>= 1;
53    return order;
54}
55
56void arch_init_demand_mapping_area(unsigned long max_pfn);
57void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p);
58void arch_init_p2m(unsigned long max_pfn_p);
59
60unsigned long allocate_ondemand(unsigned long n, unsigned long alignment);
61/* map f[i*stride]+i*increment for i in 0..n-1, aligned on alignment pages */
62void *minios_map_frames_ex(const unsigned long *f, unsigned long n,
63	unsigned long stride,
64	unsigned long increment, unsigned long alignment, domid_t id,
65	int *err, unsigned long prot);
66void minios_map_frames(unsigned long addr,
67    const unsigned long *f, unsigned long n, unsigned long stride,
68	unsigned long increment, domid_t id, int *err, unsigned long prot);
69int unmap_frames(unsigned long va, unsigned long num_frames);
70unsigned long minios_alloc_contig_pages(int order, unsigned int addr_bits);
71
72int free_physical_pages(xen_pfn_t *mfns, int n);
73void fini_mm(void);
74
75unsigned long long minios_get_l1prot(void);
76
77#endif /* _MINIOS_MM_H_ */
78