root / prex-0.9.0 / sys / include / vm.h @ 03e9c04a
History | View | Annotate | Download (3.11 KB)
1 | 03e9c04a | Brad Neuman | /*-
|
---|---|---|---|
2 | * Copyright (c) 2005-2009, Kohsuke Ohtani
|
||
3 | * All rights reserved.
|
||
4 | *
|
||
5 | * Redistribution and use in source and binary forms, with or without
|
||
6 | * modification, are permitted provided that the following conditions
|
||
7 | * are met:
|
||
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.
|
||
16 | *
|
||
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
|
||
27 | * SUCH DAMAGE.
|
||
28 | */
|
||
29 | |||
30 | #ifndef _VM_H
|
||
31 | #define _VM_H
|
||
32 | |||
33 | #include <types.h> |
||
34 | #include <sys/cdefs.h> |
||
35 | #include <sys/sysinfo.h> |
||
36 | #include <sys/bootinfo.h> |
||
37 | |||
38 | /*
|
||
39 | * One structure per allocated segment.
|
||
40 | */
|
||
41 | struct seg {
|
||
42 | struct seg *prev; /* segment list sorted by address */ |
||
43 | struct seg *next;
|
||
44 | struct seg *sh_prev; /* link for all shared segments */ |
||
45 | struct seg *sh_next;
|
||
46 | vaddr_t addr; /* base address */
|
||
47 | size_t size; /* size */
|
||
48 | int flags; /* SEG_* flag */ |
||
49 | paddr_t phys; /* physical address */
|
||
50 | }; |
||
51 | |||
52 | /* Flags for segment */
|
||
53 | #define SEG_READ 0x00000001 |
||
54 | #define SEG_WRITE 0x00000002 |
||
55 | #define SEG_EXEC 0x00000004 |
||
56 | #define SEG_SHARED 0x00000008 |
||
57 | #define SEG_MAPPED 0x00000010 |
||
58 | #define SEG_FREE 0x00000080 |
||
59 | |||
60 | /* Attribute for vm_attribute() */
|
||
61 | #define PROT_NONE 0x0 /* pages cannot be accessed */ |
||
62 | #define PROT_READ 0x1 /* pages can be read */ |
||
63 | #define PROT_WRITE 0x2 /* pages can be written */ |
||
64 | #define PROT_EXEC 0x4 /* pages can be executed */ |
||
65 | |||
66 | /*
|
||
67 | * VM mapping per one task.
|
||
68 | */
|
||
69 | struct vm_map {
|
||
70 | struct seg head; /* list head of segements */ |
||
71 | int refcnt; /* reference count */ |
||
72 | pgd_t pgd; /* page directory */
|
||
73 | size_t total; /* total used size */
|
||
74 | }; |
||
75 | |||
76 | __BEGIN_DECLS |
||
77 | int vm_allocate(task_t, void **, size_t, int); |
||
78 | int vm_free(task_t, void *); |
||
79 | int vm_attribute(task_t, void *, int); |
||
80 | int vm_map(task_t, void *, size_t, void **); |
||
81 | vm_map_t vm_dup(vm_map_t); |
||
82 | vm_map_t vm_create(void);
|
||
83 | int vm_reference(vm_map_t);
|
||
84 | void vm_terminate(vm_map_t);
|
||
85 | void vm_switch(vm_map_t);
|
||
86 | int vm_load(vm_map_t, struct module *, void **); |
||
87 | paddr_t vm_translate(vaddr_t, size_t); |
||
88 | int vm_info(struct vminfo *); |
||
89 | void vm_init(void); |
||
90 | __END_DECLS |
||
91 | |||
92 | #endif /* !_VM_H */ |