direct-io.hg

view tools/libxc/xc_private.h @ 2821:724449a888fe

bitkeeper revision 1.1159.1.332 (41874e954CLIDA2J3phVFD2RnzVTpA)

Clean up public XenLinux header files. Now accessible from userspace as
#include <xen/linux...>
Got rid of the linux-xen-sparse symlink as it's no longer needed.
author kaf24@freefall.cl.cam.ac.uk
date Tue Nov 02 09:08:37 2004 +0000 (2004-11-02)
parents 3f929065a1d1
children 2419f5c72fe5 6096356005ba 657d51f27c5b 5cc6d3dc47d0 2fa2e30bcbde ac7313eb3788 0dc3b8b8c298
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 #include <xen/linux/privcmd.h>
21 #define _PAGE_PRESENT 0x001
22 #define _PAGE_RW 0x002
23 #define _PAGE_USER 0x004
24 #define _PAGE_PWT 0x008
25 #define _PAGE_PCD 0x010
26 #define _PAGE_ACCESSED 0x020
27 #define _PAGE_DIRTY 0x040
28 #define _PAGE_PAT 0x080
29 #define _PAGE_PSE 0x080
30 #define _PAGE_GLOBAL 0x100
33 #define L1_PAGETABLE_SHIFT 12
34 #define L2_PAGETABLE_SHIFT 22
36 #define ENTRIES_PER_L1_PAGETABLE 1024
37 #define ENTRIES_PER_L2_PAGETABLE 1024
39 #define PAGE_SHIFT L1_PAGETABLE_SHIFT
40 #define PAGE_SIZE (1UL << PAGE_SHIFT)
41 #define PAGE_MASK (~(PAGE_SIZE-1))
43 typedef unsigned long l1_pgentry_t;
44 typedef unsigned long l2_pgentry_t;
46 #define l1_table_offset(_a) \
47 (((_a) >> L1_PAGETABLE_SHIFT) & (ENTRIES_PER_L1_PAGETABLE - 1))
48 #define l2_table_offset(_a) \
49 ((_a) >> L2_PAGETABLE_SHIFT)
51 #define ERROR(_m, _a...) \
52 fprintf(stderr, "ERROR: " _m "\n" , ## _a )
54 #define PERROR(_m, _a...) \
55 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \
56 errno, strerror(errno))
58 static inline int do_privcmd(int xc_handle,
59 unsigned int cmd,
60 unsigned long data)
61 {
62 return ioctl(xc_handle, cmd, data);
63 }
65 static inline int do_xen_hypercall(int xc_handle,
66 privcmd_hypercall_t *hypercall)
67 {
68 return do_privcmd(xc_handle,
69 IOCTL_PRIVCMD_HYPERCALL,
70 (unsigned long)hypercall);
71 }
73 static inline int do_dom0_op(int xc_handle, dom0_op_t *op)
74 {
75 int ret = -1;
76 privcmd_hypercall_t hypercall;
78 op->interface_version = DOM0_INTERFACE_VERSION;
80 hypercall.op = __HYPERVISOR_dom0_op;
81 hypercall.arg[0] = (unsigned long)op;
83 if ( mlock(op, sizeof(*op)) != 0 )
84 {
85 PERROR("Could not lock memory for Xen hypercall");
86 goto out1;
87 }
89 if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
90 {
91 if ( errno == EACCES )
92 fprintf(stderr, "Dom0 operation failed -- need to"
93 " rebuild the user-space tool set?\n");
94 goto out2;
95 }
97 out2: (void)munlock(op, sizeof(*op));
98 out1: return ret;
99 }
101 static inline int do_dom_mem_op(int xc_handle,
102 unsigned int memop,
103 unsigned int *extent_list,
104 unsigned int nr_extents,
105 unsigned int extent_order,
106 domid_t domid)
107 {
108 privcmd_hypercall_t hypercall;
109 long ret = -EINVAL;
111 hypercall.op = __HYPERVISOR_dom_mem_op;
112 hypercall.arg[0] = (unsigned long)memop;
113 hypercall.arg[1] = (unsigned long)extent_list;
114 hypercall.arg[2] = (unsigned long)nr_extents;
115 hypercall.arg[3] = (unsigned long)extent_order;
116 hypercall.arg[4] = (unsigned long)domid;
118 if ( mlock(extent_list, nr_extents*sizeof(unsigned long)) != 0 )
119 {
120 PERROR("Could not lock memory for Xen hypercall");
121 goto out1;
122 }
124 if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
125 {
126 fprintf(stderr, "Dom_mem operation failed (rc=%ld errno=%d)-- need to"
127 " rebuild the user-space tool set?\n",ret,errno);
128 goto out2;
129 }
131 out2: (void)munlock(extent_list, nr_extents*sizeof(unsigned long));
132 out1: return ret;
133 }
136 /*
137 * PFN mapping.
138 */
139 int get_pfn_type_batch(int xc_handle, u32 dom, int num, unsigned long *arr);
140 unsigned long csum_page (void * page);
142 /*
143 * MMU updates.
144 */
145 #define MAX_MMU_UPDATES 1024
146 typedef struct {
147 mmu_update_t updates[MAX_MMU_UPDATES];
148 int idx;
149 domid_t subject;
150 } mmu_t;
151 mmu_t *init_mmu_updates(int xc_handle, domid_t dom);
152 int add_mmu_update(int xc_handle, mmu_t *mmu,
153 unsigned long ptr, unsigned long val);
154 int finish_mmu_updates(int xc_handle, mmu_t *mmu);
157 /*
158 * ioctl-based mfn mapping interface
159 */
161 /*
162 typedef struct privcmd_mmap_entry {
163 unsigned long va;
164 unsigned long mfn;
165 unsigned long npages;
166 } privcmd_mmap_entry_t;
168 typedef struct privcmd_mmap {
169 int num;
170 domid_t dom;
171 privcmd_mmap_entry_t *entry;
172 } privcmd_mmap_t;
173 */
175 #define mfn_mapper_queue_size 128
177 typedef struct mfn_mapper {
178 int xc_handle;
179 int size;
180 int prot;
181 int error;
182 int max_queue_size;
183 void * addr;
184 privcmd_mmap_t ioctl;
186 } mfn_mapper_t;
188 #include "xc_io.h"
190 unsigned long xc_get_m2p_start_mfn ( int xc_handle );
192 #endif /* __XC_PRIVATE_H__ */