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.


added memory region generated page tables, and removed all the ugliness that was...
[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 typedef unsigned long addr_t;
9
10
11 typedef struct mem_region {
12  addr_t addr;
13   uint_t num_pages;
14
15   struct mem_region * next;
16   struct mem_region * prev;
17 } mem_region_t;
18
19
20 typedef struct vmm_mem_list {
21   uint_t num_pages;
22   bool long_mode;
23
24   uint_t num_regions;
25   mem_region_t * head;
26   //  mem_region_t * tail;
27 } vmm_mem_list_t;
28
29
30
31 /** Memory layout **/
32 /* Describes the layout of memory for the guest */
33 /* We use this to build the guest page tables */
34
35 typedef enum region_type {GUEST, UNMAPPED, SHARED} region_type_t;
36
37
38 typedef struct layout_region {
39   addr_t addr;
40   uint_t num_pages;
41
42   region_type_t type;
43
44   addr_t host_addr;
45
46   struct layout_region * next;
47   struct layout_region * prev;
48 } layout_region_t;
49
50
51 typedef struct vmm_mem_layout {
52   uint_t num_pages;
53   uint_t num_regions;
54  
55   uint_t num_guest_pages;
56
57   layout_region_t * head;
58 } vmm_mem_layout_t;
59
60
61 /*** FOR THE LOVE OF GOD WRITE SOME UNIT TESTS FOR THIS THING ***/
62
63 void init_mem_list(vmm_mem_list_t * list);
64 void free_mem_list(vmm_mem_list_t * list);
65
66 int add_mem_list_pages(vmm_mem_list_t * list, addr_t addr, uint_t num_pages);
67 int remove_mem_list_pages(vmm_mem_list_t * list, addr_t addr, uint_t num_pages);
68
69 mem_region_t * get_mem_list_cursor(vmm_mem_list_t * list, addr_t addr);
70
71 addr_t get_mem_list_addr(vmm_mem_list_t * list, uint_t index);
72
73 void print_mem_list(vmm_mem_list_t * list);
74
75
76 void init_mem_layout(vmm_mem_layout_t * layout);
77 void free_mem_layout(vmm_mem_layout_t * layout);
78
79 layout_region_t * get_layout_cursor(vmm_mem_layout_t * layout, addr_t addr);
80
81 int add_mem_range(vmm_mem_layout_t * layout, layout_region_t * region);
82 int add_shared_mem_range(vmm_mem_layout_t * layout, addr_t addr, uint_t num_pages, addr_t host_addr);
83 int add_unmapped_mem_range(vmm_mem_layout_t * layout, addr_t addr, uint_t num_pages);
84 int add_guest_mem_range(vmm_mem_layout_t * layout, addr_t addr, uint_t num_pages);
85
86
87 addr_t get_mem_layout_addr(vmm_mem_layout_t * list, uint_t index);
88
89 void print_mem_layout(vmm_mem_layout_t * layout);
90
91
92
93
94
95 #endif