Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


*** empty log message ***
[palacios.git] / palacios / include / geekos / vmm_mem.h
1 #ifndef __VMM_MEM_H
2 #define __VMM_MEM_H
3
4
5 #include <geekos/ktypes.h>
6
7
8 /*
9  * The mem list is TEMPORARY, simply to lock down which pages are assigned to the VM
10  * We will remove it and use the host page allocation mechanism in the future
11  */
12
13
14 typedef unsigned long addr_t;
15
16
17 typedef struct mem_region {
18   addr_t addr;
19   uint_t num_pages;
20
21   struct mem_region * next;
22   struct mem_region * prev;
23 } mem_region_t;
24
25
26 typedef struct vmm_mem_list {
27   uint_t num_pages;
28   bool long_mode;
29
30   uint_t num_regions;
31   mem_region_t * head;
32   //  mem_region_t * tail;
33 } vmm_mem_list_t;
34
35
36
37 /** Memory layout **/
38 /* Describes the layout of memory for the guest */
39 /* We use this to build the guest page tables */
40
41 typedef enum region_type {GUEST, UNMAPPED, SHARED} region_type_t;
42
43
44 typedef struct layout_region {
45   addr_t start;
46   addr_t end;
47
48   region_type_t type;
49
50   addr_t host_addr;
51
52   struct layout_region * next;
53   struct layout_region * prev;
54 } layout_region_t;
55
56
57 typedef struct vmm_mem_layout {
58   uint_t num_pages;
59   uint_t num_regions;
60
61   layout_region_t * head;
62 } vmm_mem_layout_t;
63
64
65 /*** FOR THE LOVE OF GOD WRITE SOME UNIT TESTS FOR THIS THING ***/
66
67 void init_mem_list(vmm_mem_list_t * list);
68 void free_mem_list(vmm_mem_list_t * list);
69
70 int add_mem_list_pages(vmm_mem_list_t * list, addr_t addr, uint_t num_pages);
71 int remove_mem_list_pages(vmm_mem_list_t * list, addr_t addr, uint_t num_pages);
72
73 mem_region_t * get_mem_list_cursor(vmm_mem_list_t * list, addr_t addr);
74
75 addr_t get_mem_list_addr(vmm_mem_list_t * list, uint_t index);
76
77 void print_mem_list(vmm_mem_list_t * list);
78
79
80 void init_mem_layout(vmm_mem_layout_t * layout);
81 void free_mem_layout(vmm_mem_layout_t * layout);
82
83
84 int add_mem_range(vmm_mem_layout_t * layout, layout_region_t * region);
85 int add_shared_mem_range(vmm_mem_layout_t * layout, addr_t start, addr_t end, addr_t host_addr);
86 int add_unmapped_mem_range(vmm_mem_layout_t * layout, addr_t start, addr_t end);
87 int add_guest_mem_range(vmm_mem_layout_t * layout, addr_t start, addr_t end);
88
89
90 addr_t get_mem_layout_addr(vmm_mem_layout_t * layout, uint_t index);
91 layout_region_t * get_mem_layout_region(vmm_mem_layout_t * layout, addr_t addr);
92
93 void print_mem_layout(vmm_mem_layout_t * layout);
94
95
96
97
98
99 #endif