ia64/xen-unstable

view tools/libxc/xg_private.h @ 7238:971e7c7411b3

Raise an exception if an error appears on the pipes to our children, and make
sure that the child's pipes are closed even under that exception. Move the
handling of POLLHUP to the end of the loop, so that we guarantee to read any
remaining data from the child if POLLHUP and POLLIN appear at the same time.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Thu Oct 06 10:13:11 2005 +0100 (2005-10-06)
parents ef9591d03fdd
children 93e27f7ca8a8 61b3b357d827
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 #define L1_PAGETABLE_SHIFT_PAE 12
32 #define L2_PAGETABLE_SHIFT_PAE 21
33 #define L3_PAGETABLE_SHIFT_PAE 30
35 #if defined(__i386__)
36 #define L1_PAGETABLE_SHIFT 12
37 #define L2_PAGETABLE_SHIFT 22
38 #elif defined(__x86_64__)
39 #define L1_PAGETABLE_SHIFT 12
40 #define L2_PAGETABLE_SHIFT 21
41 #define L3_PAGETABLE_SHIFT 30
42 #define L4_PAGETABLE_SHIFT 39
43 #endif
45 #define L1_PAGETABLE_ENTRIES_PAE 512
46 #define L2_PAGETABLE_ENTRIES_PAE 512
47 #define L3_PAGETABLE_ENTRIES_PAE 4
49 #if defined(__i386__)
50 #define L1_PAGETABLE_ENTRIES 1024
51 #define L2_PAGETABLE_ENTRIES 1024
52 #elif defined(__x86_64__)
53 #define L1_PAGETABLE_ENTRIES 512
54 #define L2_PAGETABLE_ENTRIES 512
55 #define L3_PAGETABLE_ENTRIES 512
56 #define L4_PAGETABLE_ENTRIES 512
57 #endif
59 #define PAGE_SHIFT XC_PAGE_SHIFT
60 #define PAGE_SIZE (1UL << PAGE_SHIFT)
61 #define PAGE_MASK (~(PAGE_SIZE-1))
63 typedef u32 l1_pgentry_32_t;
64 typedef u32 l2_pgentry_32_t;
65 typedef u64 l1_pgentry_64_t;
66 typedef u64 l2_pgentry_64_t;
67 typedef u64 l3_pgentry_64_t;
68 typedef unsigned long l1_pgentry_t;
69 typedef unsigned long l2_pgentry_t;
70 #if defined(__x86_64__)
71 typedef unsigned long l3_pgentry_t;
72 typedef unsigned long l4_pgentry_t;
73 #endif
75 #define l1_table_offset_pae(_a) \
76 (((_a) >> L1_PAGETABLE_SHIFT_PAE) & (L1_PAGETABLE_ENTRIES_PAE - 1))
77 #define l2_table_offset_pae(_a) \
78 (((_a) >> L2_PAGETABLE_SHIFT_PAE) & (L2_PAGETABLE_ENTRIES_PAE - 1))
79 #define l3_table_offset_pae(_a) \
80 (((_a) >> L3_PAGETABLE_SHIFT_PAE) & (L3_PAGETABLE_ENTRIES_PAE - 1))
82 #if defined(__i386__)
83 #define l1_table_offset(_a) \
84 (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1))
85 #define l2_table_offset(_a) \
86 ((_a) >> L2_PAGETABLE_SHIFT)
87 #elif defined(__x86_64__)
88 #define l1_table_offset(_a) \
89 (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1))
90 #define l2_table_offset(_a) \
91 (((_a) >> L2_PAGETABLE_SHIFT) & (L2_PAGETABLE_ENTRIES - 1))
92 #define l3_table_offset(_a) \
93 (((_a) >> L3_PAGETABLE_SHIFT) & (L3_PAGETABLE_ENTRIES - 1))
94 #define l4_table_offset(_a) \
95 (((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1))
96 #endif
98 #define ERROR(_m, _a...) \
99 do { \
100 int __saved_errno = errno; \
101 fprintf(stderr, "ERROR: " _m "\n" , ## _a ); \
102 errno = __saved_errno; \
103 } while (0)
106 #define PERROR(_m, _a...) \
107 do { \
108 int __saved_errno = errno; \
109 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \
110 __saved_errno, strerror(__saved_errno)); \
111 errno = __saved_errno; \
112 } while (0)
115 struct domain_setup_info
116 {
117 unsigned long v_start;
118 unsigned long v_end;
119 unsigned long v_kernstart;
120 unsigned long v_kernend;
121 unsigned long v_kernentry;
123 unsigned int load_symtab;
124 unsigned int pae_kernel;
125 unsigned long symtab_addr;
126 unsigned long symtab_len;
127 };
129 typedef int (*parseimagefunc)(char *image, unsigned long image_size,
130 struct domain_setup_info *dsi);
131 typedef int (*loadimagefunc)(char *image, unsigned long image_size, int xch,
132 u32 dom, unsigned long *parray,
133 struct domain_setup_info *dsi);
135 struct load_funcs
136 {
137 parseimagefunc parseimage;
138 loadimagefunc loadimage;
139 };
141 #define mfn_mapper_queue_size 128
143 typedef struct mfn_mapper {
144 int xc_handle;
145 int size;
146 int prot;
147 int error;
148 int max_queue_size;
149 void * addr;
150 privcmd_mmap_t ioctl;
152 } mfn_mapper_t;
154 unsigned long xc_get_m2p_start_mfn (int xc_handle);
156 int xc_copy_to_domain_page(int xc_handle, u32 domid,
157 unsigned long dst_pfn, void *src_page);
159 unsigned long xc_get_filesz(int fd);
161 void xc_map_memcpy(unsigned long dst, char *src, unsigned long size,
162 int xch, u32 dom, unsigned long *parray,
163 unsigned long vstart);
165 int pin_table(int xc_handle, unsigned int type, unsigned long mfn,
166 domid_t dom);
168 /* image loading */
169 int probe_elf(char *image, unsigned long image_size, struct load_funcs *funcs);
170 int probe_bin(char *image, unsigned long image_size, struct load_funcs *funcs);
171 int probe_aout9(char *image, unsigned long image_size, struct load_funcs *funcs);
173 #endif