ia64/xen-unstable

view tools/libxc/xc_private.h @ 2391:61f948e59214

bitkeeper revision 1.1159.53.25 (4133b18fZ5FTt-fwTtgweJYFwIKErw)

Remove redundant multicall_op from libxc.
author kaf24@freefall.cl.cam.ac.uk
date Mon Aug 30 23:00:31 2004 +0000 (2004-08-30)
parents 9afec5bc14ae
children 631de0f7529b
line source
2 #ifndef __XC_PRIVATE_H__
3 #define __XC_PRIVATE_H__
5 #include <unistd.h>
6 #include <stdio.h>
7 #include <errno.h>
8 #include <fcntl.h>
9 #include <sys/mman.h>
10 #include <sys/types.h>
11 #include <sys/stat.h>
12 #include <stdlib.h>
13 #include <sys/ioctl.h>
14 #include <errno.h>
15 #include <string.h>
17 #include "xc.h"
19 /* from xen/include/hypervisor-ifs */
20 #include <hypervisor-if.h>
21 #include <dom0_ops.h>
22 #include <event_channel.h>
23 #include <sched_ctl.h>
24 #include <io/domain_controller.h>
26 #include <asm-xen/proc_cmd.h>
29 #define _PAGE_PRESENT 0x001
30 #define _PAGE_RW 0x002
31 #define _PAGE_USER 0x004
32 #define _PAGE_PWT 0x008
33 #define _PAGE_PCD 0x010
34 #define _PAGE_ACCESSED 0x020
35 #define _PAGE_DIRTY 0x040
36 #define _PAGE_PAT 0x080
37 #define _PAGE_PSE 0x080
38 #define _PAGE_GLOBAL 0x100
41 #define L1_PAGETABLE_SHIFT 12
42 #define L2_PAGETABLE_SHIFT 22
44 #define ENTRIES_PER_L1_PAGETABLE 1024
45 #define ENTRIES_PER_L2_PAGETABLE 1024
47 #define PAGE_SHIFT L1_PAGETABLE_SHIFT
48 #define PAGE_SIZE (1UL << PAGE_SHIFT)
49 #define PAGE_MASK (~(PAGE_SIZE-1))
51 typedef unsigned long l1_pgentry_t;
52 typedef unsigned long l2_pgentry_t;
54 #define l1_table_offset(_a) \
55 (((_a) >> L1_PAGETABLE_SHIFT) & (ENTRIES_PER_L1_PAGETABLE - 1))
56 #define l2_table_offset(_a) \
57 ((_a) >> L2_PAGETABLE_SHIFT)
59 #define ERROR(_m, _a...) \
60 fprintf(stderr, "ERROR: " _m "\n" , ## _a )
62 #define PERROR(_m, _a...) \
63 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \
64 errno, strerror(errno))
66 static inline int do_privcmd(int xc_handle,
67 unsigned int cmd,
68 unsigned long data)
69 {
70 return ioctl(xc_handle, cmd, data);
71 }
73 static inline int do_xen_hypercall(int xc_handle,
74 privcmd_hypercall_t *hypercall)
75 {
76 return do_privcmd(xc_handle,
77 IOCTL_PRIVCMD_HYPERCALL,
78 (unsigned long)hypercall);
79 }
81 static inline int do_dom0_op(int xc_handle, dom0_op_t *op)
82 {
83 int ret = -1;
84 privcmd_hypercall_t hypercall;
86 op->interface_version = DOM0_INTERFACE_VERSION;
88 hypercall.op = __HYPERVISOR_dom0_op;
89 hypercall.arg[0] = (unsigned long)op;
91 if ( mlock(op, sizeof(*op)) != 0 )
92 {
93 PERROR("Could not lock memory for Xen hypercall");
94 goto out1;
95 }
97 if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
98 {
99 if ( errno == EACCES )
100 fprintf(stderr, "Dom0 operation failed -- need to"
101 " rebuild the user-space tool set?\n");
102 goto out2;
103 }
105 out2: (void)munlock(op, sizeof(*op));
106 out1: return ret;
107 }
109 static inline int do_dom_mem_op(int xc_handle,
110 unsigned int memop,
111 unsigned int *extent_list,
112 unsigned int nr_extents,
113 unsigned int extent_order,
114 domid_t domid)
115 {
116 privcmd_hypercall_t hypercall;
117 long ret = -EINVAL;
119 hypercall.op = __HYPERVISOR_dom_mem_op;
120 hypercall.arg[0] = (unsigned long)memop;
121 hypercall.arg[1] = (unsigned long)extent_list;
122 hypercall.arg[2] = (unsigned long)nr_extents;
123 hypercall.arg[3] = (unsigned long)extent_order;
124 hypercall.arg[4] = (unsigned long)domid;
126 if ( mlock(extent_list, nr_extents*sizeof(unsigned long)) != 0 )
127 {
128 PERROR("Could not lock memory for Xen hypercall");
129 goto out1;
130 }
132 if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
133 {
134 fprintf(stderr, "Dom_mem operation failed (rc=%ld errno=%d)-- need to"
135 " rebuild the user-space tool set?\n",ret,errno);
136 goto out2;
137 }
139 out2: (void)munlock(extent_list, nr_extents*sizeof(unsigned long));
140 out1: return ret;
141 }
144 /*
145 * PFN mapping.
146 */
147 void *init_pfn_mapper(domid_t domid);
148 int close_pfn_mapper(void *pm_handle);
149 void *map_pfn_writeable(void *pm_handle, unsigned long pfn);
150 void *map_pfn_readonly(void *pm_handle, unsigned long pfn);
151 void unmap_pfn(void *pm_handle, void *vaddr);
152 int get_pfn_type_batch(int xc_handle, u32 dom, int num, unsigned long *arr);
153 unsigned long csum_page (void * page);
155 /*
156 * MMU updates.
157 */
158 #define MAX_MMU_UPDATES 1024
159 typedef struct {
160 mmu_update_t updates[MAX_MMU_UPDATES];
161 int idx;
162 domid_t subject;
163 } mmu_t;
164 mmu_t *init_mmu_updates(int xc_handle, domid_t dom);
165 int add_mmu_update(int xc_handle, mmu_t *mmu,
166 unsigned long ptr, unsigned long val);
167 int finish_mmu_updates(int xc_handle, mmu_t *mmu);
170 /*
171 * ioctl-based mfn mapping interface
172 */
174 /*
175 typedef struct privcmd_mmap_entry {
176 unsigned long va;
177 unsigned long mfn;
178 unsigned long npages;
179 } privcmd_mmap_entry_t;
181 typedef struct privcmd_mmap {
182 int num;
183 domid_t dom;
184 privcmd_mmap_entry_t *entry;
185 } privcmd_mmap_t;
186 */
188 #define mfn_mapper_queue_size 128
190 typedef struct mfn_mapper {
191 int xc_handle;
192 int size;
193 int prot;
194 int error;
195 int max_queue_size;
196 void * addr;
197 privcmd_mmap_t ioctl;
199 } mfn_mapper_t;
201 long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid );
203 #include "xc_io.h"
205 int xc_domain_getfullinfo(int xc_handle,
206 u32 domid,
207 dom0_op_t *op,
208 full_execution_context_t *ctxt );
210 unsigned long xc_get_m2p_start_mfn ( int xc_handle );
212 #endif /* __XC_PRIVATE_H__ */