1 /******************************************************************************
2  * tools/xenpaging/xenpaging.h
3  *
4  * Xen domain paging.
5  *
6  * Copyright (c) 2009 Citrix Systems, Inc. (Patrick Colp)
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 
23 #ifndef __XEN_PAGING2_H__
24 #define __XEN_PAGING2_H__
25 
26 
27 #include <xenevtchn.h>
28 #define XC_WANT_COMPAT_MAP_FOREIGN_API
29 #include <xenctrl.h>
30 #include <xc_private.h>
31 #include <xen/event_channel.h>
32 #include <xen/vm_event.h>
33 
34 #define XENPAGING_PAGEIN_QUEUE_SIZE 64
35 
36 struct vm_event {
37     domid_t domain_id;
38     xenevtchn_handle *xce_handle;
39     int port;
40     vm_event_back_ring_t back_ring;
41     uint32_t evtchn_port;
42     void *ring_page;
43 };
44 
45 struct xenpaging {
46     xc_interface *xc_handle;
47     struct xs_handle *xs_handle;
48 
49     unsigned long *bitmap;
50 
51     unsigned long *slot_to_gfn;
52     int *gfn_to_slot;
53 
54     void *paging_buffer;
55 
56     struct vm_event vm_event;
57     int fd;
58     /* number of pages for which data structures were allocated */
59     int max_pages;
60     int num_paged_out;
61     int target_tot_pages;
62     int policy_mru_size;
63     int use_poll_timeout;
64     int debug;
65     int stack_count;
66     int *free_slot_stack;
67     unsigned long pagein_queue[XENPAGING_PAGEIN_QUEUE_SIZE];
68 };
69 
70 extern void create_page_in_thread(struct xenpaging *paging);
71 extern void page_in_trigger(void);
72 
73 #endif // __XEN_PAGING_H__
74 
75 
76 /*
77  * Local variables:
78  * mode: C
79  * c-file-style: "BSD"
80  * c-basic-offset: 4
81  * tab-width: 4
82  * indent-tabs-mode: nil
83  * End:
84  */
85