2 * Copyright (c) 2005-2006, Kohsuke Ohtani
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the author nor the names of any co-contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 struct region
*prev
; /* Region list sorted by address */
39 struct region
*sh_prev
; /* Link for all shared region */
40 struct region
*sh_next
;
41 u_long addr
; /* Base address */
42 size_t size
; /* Size */
43 u_int flags
; /* Flag */
45 u_long phys
; /* Physical address */
53 struct region head
; /* List head of regions */
54 int ref_count
; /* Reference count */
55 pgd_t pgd
; /* Page directory */
57 typedef struct vm_map
*vm_map_t
;
62 #define REG_READ 0x00000001
63 #define REG_WRITE 0x00000002
64 #define REG_EXEC 0x00000004
65 #define REG_SHARED 0x00000008
66 #define REG_MAPPED 0x00000010
67 #define REG_FREE 0x80000000
72 #define ATTR_READ 0x01
73 #define ATTR_WRITE 0x02
74 #define ATTR_EXEC 0x04
76 extern void vm_init(void);
77 extern int vm_allocate(task_t task
, void **addr
, size_t size
, int anywhere
);
78 extern int __vm_allocate(task_t task
, void **addr
, size_t size
,
79 int anywhere
, int pagemap
);
80 extern int vm_free(task_t task
, void *addr
);
81 extern int vm_attribute(task_t task
, void *addr
, int attr
);
82 extern int vm_map(task_t target
, void *addr
, size_t size
, void **alloc
);
83 extern vm_map_t
vm_fork(vm_map_t map
);
84 extern vm_map_t
vm_create(void);
85 extern int vm_reference(vm_map_t map
);
86 extern void vm_terminate(vm_map_t map
);
87 extern void *vm_translate(void *addr
, size_t size
);
88 extern int vm_access(void *addr
, size_t size
, int type
);