ia64/xen-unstable

view tools/libxc/xg_private.h @ 8964:8946b6dcd49e

Fix x86_64 Xen build.

event_callback_cs and failsafe_callback_cs are x86_32 only.

Signed-off-by: Ian Campbell <Ian.Campbell@XenSource.com>
author Ian.Campbell@xensource.com
date Wed Feb 22 17:26:39 2006 +0000 (2006-02-22)
parents 71914b64b577
children 899532500ada
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"
14 #include "xenguest.h"
16 #include <xen/linux/privcmd.h>
17 #include <xen/memory.h>
19 /* valgrind cannot see when a hypercall has filled in some values. For this
20 reason, we must zero the dom0_op_t instance before a call, if using
21 valgrind. */
22 #ifdef VALGRIND
23 #define DECLARE_DOM0_OP dom0_op_t op = { 0 }
24 #else
25 #define DECLARE_DOM0_OP dom0_op_t op
26 #endif
29 char *xc_read_kernel_image(const char *filename, unsigned long *size);
30 unsigned long csum_page (void * page);
32 #define _PAGE_PRESENT 0x001
33 #define _PAGE_RW 0x002
34 #define _PAGE_USER 0x004
35 #define _PAGE_PWT 0x008
36 #define _PAGE_PCD 0x010
37 #define _PAGE_ACCESSED 0x020
38 #define _PAGE_DIRTY 0x040
39 #define _PAGE_PAT 0x080
40 #define _PAGE_PSE 0x080
41 #define _PAGE_GLOBAL 0x100
43 #define L1_PAGETABLE_SHIFT_PAE 12
44 #define L2_PAGETABLE_SHIFT_PAE 21
45 #define L3_PAGETABLE_SHIFT_PAE 30
47 #if defined(__i386__)
48 #define L1_PAGETABLE_SHIFT 12
49 #define L2_PAGETABLE_SHIFT 22
50 #elif defined(__x86_64__)
51 #define L1_PAGETABLE_SHIFT 12
52 #define L2_PAGETABLE_SHIFT 21
53 #define L3_PAGETABLE_SHIFT 30
54 #define L4_PAGETABLE_SHIFT 39
55 #endif
57 #define L1_PAGETABLE_ENTRIES_PAE 512
58 #define L2_PAGETABLE_ENTRIES_PAE 512
59 #define L3_PAGETABLE_ENTRIES_PAE 4
61 #if defined(__i386__)
62 #define L1_PAGETABLE_ENTRIES 1024
63 #define L2_PAGETABLE_ENTRIES 1024
64 #elif defined(__x86_64__)
65 #define L1_PAGETABLE_ENTRIES 512
66 #define L2_PAGETABLE_ENTRIES 512
67 #define L3_PAGETABLE_ENTRIES 512
68 #define L4_PAGETABLE_ENTRIES 512
69 #endif
71 #define PAGE_SHIFT XC_PAGE_SHIFT
72 #define PAGE_SIZE (1UL << PAGE_SHIFT)
73 #define PAGE_MASK (~(PAGE_SIZE-1))
75 typedef uint32_t l1_pgentry_32_t;
76 typedef uint32_t l2_pgentry_32_t;
77 typedef uint64_t l1_pgentry_64_t;
78 typedef uint64_t l2_pgentry_64_t;
79 typedef uint64_t l3_pgentry_64_t;
80 typedef unsigned long l1_pgentry_t;
81 typedef unsigned long l2_pgentry_t;
82 #if defined(__x86_64__)
83 typedef unsigned long l3_pgentry_t;
84 typedef unsigned long l4_pgentry_t;
85 #endif
87 #define l1_table_offset_pae(_a) \
88 (((_a) >> L1_PAGETABLE_SHIFT_PAE) & (L1_PAGETABLE_ENTRIES_PAE - 1))
89 #define l2_table_offset_pae(_a) \
90 (((_a) >> L2_PAGETABLE_SHIFT_PAE) & (L2_PAGETABLE_ENTRIES_PAE - 1))
91 #define l3_table_offset_pae(_a) \
92 (((_a) >> L3_PAGETABLE_SHIFT_PAE) & (L3_PAGETABLE_ENTRIES_PAE - 1))
94 #if defined(__i386__)
95 #define l1_table_offset(_a) \
96 (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1))
97 #define l2_table_offset(_a) \
98 ((_a) >> L2_PAGETABLE_SHIFT)
99 #elif defined(__x86_64__)
100 #define l1_table_offset(_a) \
101 (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1))
102 #define l2_table_offset(_a) \
103 (((_a) >> L2_PAGETABLE_SHIFT) & (L2_PAGETABLE_ENTRIES - 1))
104 #define l3_table_offset(_a) \
105 (((_a) >> L3_PAGETABLE_SHIFT) & (L3_PAGETABLE_ENTRIES - 1))
106 #define l4_table_offset(_a) \
107 (((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1))
108 #endif
110 #define ERROR(_m, _a...) \
111 do { \
112 int __saved_errno = errno; \
113 fprintf(stderr, "ERROR: " _m "\n" , ## _a ); \
114 errno = __saved_errno; \
115 } while (0)
118 #define PERROR(_m, _a...) \
119 do { \
120 int __saved_errno = errno; \
121 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \
122 __saved_errno, strerror(__saved_errno)); \
123 errno = __saved_errno; \
124 } while (0)
127 struct domain_setup_info
128 {
129 unsigned long v_start;
130 unsigned long v_end;
131 unsigned long v_kernstart;
132 unsigned long v_kernend;
133 unsigned long v_kernentry;
135 unsigned int load_symtab;
136 unsigned int pae_kernel;
137 unsigned long symtab_addr;
138 unsigned long symtab_len;
140 /* __xen_guest info string for convenient loader parsing. */
141 char *xen_guest_string;
142 };
144 typedef int (*parseimagefunc)(char *image, unsigned long image_size,
145 struct domain_setup_info *dsi);
146 typedef int (*loadimagefunc)(char *image, unsigned long image_size, int xch,
147 uint32_t dom, unsigned long *parray,
148 struct domain_setup_info *dsi);
150 struct load_funcs
151 {
152 parseimagefunc parseimage;
153 loadimagefunc loadimage;
154 };
156 #define mfn_mapper_queue_size 128
158 typedef struct mfn_mapper {
159 int xc_handle;
160 int size;
161 int prot;
162 int error;
163 int max_queue_size;
164 void * addr;
165 privcmd_mmap_t ioctl;
167 } mfn_mapper_t;
169 int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
170 unsigned long dst_pfn, void *src_page);
172 unsigned long xc_get_filesz(int fd);
174 void xc_map_memcpy(unsigned long dst, char *src, unsigned long size,
175 int xch, uint32_t dom, unsigned long *parray,
176 unsigned long vstart);
178 int pin_table(int xc_handle, unsigned int type, unsigned long mfn,
179 domid_t dom);
181 /* image loading */
182 int probe_elf(char *image, unsigned long image_size, struct load_funcs *funcs);
183 int probe_bin(char *image, unsigned long image_size, struct load_funcs *funcs);
184 int probe_aout9(char *image, unsigned long image_size, struct load_funcs *funcs);
186 #endif