ia64/xen-unstable

view tools/libxc/xg_private.h @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents 3233e7ecfa9f
children 06d84bf87159
line source
1 #ifndef XG_PRIVATE_H
2 #define XG_PRIVATE_H
4 #include <unistd.h>
5 #include <errno.h>
6 #include <fcntl.h>
7 #include <stdio.h>
8 #include <string.h>
9 #include <sys/mman.h>
10 #include <sys/types.h>
11 #include <sys/stat.h>
13 #include "xenctrl.h"
15 #include <xen/linux/privcmd.h>
17 char *xc_read_kernel_image(const char *filename, unsigned long *size);
18 unsigned long csum_page (void * page);
20 #define _PAGE_PRESENT 0x001
21 #define _PAGE_RW 0x002
22 #define _PAGE_USER 0x004
23 #define _PAGE_PWT 0x008
24 #define _PAGE_PCD 0x010
25 #define _PAGE_ACCESSED 0x020
26 #define _PAGE_DIRTY 0x040
27 #define _PAGE_PAT 0x080
28 #define _PAGE_PSE 0x080
29 #define _PAGE_GLOBAL 0x100
31 #if defined(__i386__)
32 #define L1_PAGETABLE_SHIFT 12
33 #define L2_PAGETABLE_SHIFT 22
34 #define L1_PAGETABLE_SHIFT_PAE 12
35 #define L2_PAGETABLE_SHIFT_PAE 21
36 #define L3_PAGETABLE_SHIFT_PAE 30
37 #elif defined(__x86_64__)
38 #define L1_PAGETABLE_SHIFT 12
39 #define L2_PAGETABLE_SHIFT 21
40 #define L3_PAGETABLE_SHIFT 30
41 #define L4_PAGETABLE_SHIFT 39
42 #endif
44 #if defined(__i386__)
45 #define ENTRIES_PER_L1_PAGETABLE 1024
46 #define ENTRIES_PER_L2_PAGETABLE 1024
47 #define L1_PAGETABLE_ENTRIES_PAE 512
48 #define L2_PAGETABLE_ENTRIES_PAE 512
49 #define L3_PAGETABLE_ENTRIES_PAE 4
50 #elif defined(__x86_64__)
51 #define L1_PAGETABLE_ENTRIES 512
52 #define L2_PAGETABLE_ENTRIES 512
53 #define L3_PAGETABLE_ENTRIES 512
54 #define L4_PAGETABLE_ENTRIES 512
55 #endif
57 #define PAGE_SHIFT XC_PAGE_SHIFT
58 #define PAGE_SIZE (1UL << PAGE_SHIFT)
59 #define PAGE_MASK (~(PAGE_SIZE-1))
61 typedef u32 l1_pgentry_32_t;
62 typedef u32 l2_pgentry_32_t;
63 typedef u64 l1_pgentry_64_t;
64 typedef u64 l2_pgentry_64_t;
65 typedef u64 l3_pgentry_64_t;
66 typedef unsigned long l1_pgentry_t;
67 typedef unsigned long l2_pgentry_t;
68 #if defined(__x86_64__)
69 typedef unsigned long l3_pgentry_t;
70 typedef unsigned long l4_pgentry_t;
71 #endif
73 #if defined(__i386__)
74 #define l1_table_offset(_a) \
75 (((_a) >> L1_PAGETABLE_SHIFT) & (ENTRIES_PER_L1_PAGETABLE - 1))
76 #define l2_table_offset(_a) \
77 ((_a) >> L2_PAGETABLE_SHIFT)
78 #define l1_table_offset_pae(_a) \
79 (((_a) >> L1_PAGETABLE_SHIFT_PAE) & (L1_PAGETABLE_ENTRIES_PAE - 1))
80 #define l2_table_offset_pae(_a) \
81 (((_a) >> L2_PAGETABLE_SHIFT_PAE) & (L2_PAGETABLE_ENTRIES_PAE - 1))
82 #define l3_table_offset_pae(_a) \
83 (((_a) >> L3_PAGETABLE_SHIFT_PAE) & (L3_PAGETABLE_ENTRIES_PAE - 1))
84 #elif defined(__x86_64__)
85 #define l1_table_offset(_a) \
86 (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1))
87 #define l2_table_offset(_a) \
88 (((_a) >> L2_PAGETABLE_SHIFT) & (L2_PAGETABLE_ENTRIES - 1))
89 #define l3_table_offset(_a) \
90 (((_a) >> L3_PAGETABLE_SHIFT) & (L3_PAGETABLE_ENTRIES - 1))
91 #define l4_table_offset(_a) \
92 (((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1))
93 #endif
95 #define ERROR(_m, _a...) \
96 do { \
97 int __saved_errno = errno; \
98 fprintf(stderr, "ERROR: " _m "\n" , ## _a ); \
99 errno = __saved_errno; \
100 } while (0)
103 #define PERROR(_m, _a...) \
104 do { \
105 int __saved_errno = errno; \
106 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \
107 __saved_errno, strerror(__saved_errno)); \
108 errno = __saved_errno; \
109 } while (0)
112 struct domain_setup_info
113 {
114 unsigned long v_start;
115 unsigned long v_end;
116 unsigned long v_kernstart;
117 unsigned long v_kernend;
118 unsigned long v_kernentry;
120 unsigned int load_symtab;
121 unsigned int pae_kernel;
122 unsigned long symtab_addr;
123 unsigned long symtab_len;
124 };
126 typedef int (*parseimagefunc)(char *image, unsigned long image_size,
127 struct domain_setup_info *dsi);
128 typedef int (*loadimagefunc)(char *image, unsigned long image_size, int xch,
129 u32 dom, unsigned long *parray,
130 struct domain_setup_info *dsi);
132 struct load_funcs
133 {
134 parseimagefunc parseimage;
135 loadimagefunc loadimage;
136 };
138 #define mfn_mapper_queue_size 128
140 typedef struct mfn_mapper {
141 int xc_handle;
142 int size;
143 int prot;
144 int error;
145 int max_queue_size;
146 void * addr;
147 privcmd_mmap_t ioctl;
149 } mfn_mapper_t;
151 unsigned long xc_get_m2p_start_mfn (int xc_handle);
153 int xc_copy_to_domain_page(int xc_handle, u32 domid,
154 unsigned long dst_pfn, void *src_page);
156 unsigned long xc_get_filesz(int fd);
158 void xc_map_memcpy(unsigned long dst, char *src, unsigned long size,
159 int xch, u32 dom, unsigned long *parray,
160 unsigned long vstart);
162 int pin_table(int xc_handle, unsigned int type, unsigned long mfn,
163 domid_t dom);
165 /* image loading */
166 int probe_elf(char *image, unsigned long image_size, struct load_funcs *funcs);
167 int probe_bin(char *image, unsigned long image_size, struct load_funcs *funcs);
168 int probe_aout9(char *image, unsigned long image_size, struct load_funcs *funcs);
170 #endif