ia64/xen-unstable

view tools/libxc/xg_private.h @ 6435:b4b3f6be5226

merge?
author cl349@firebug.cl.cam.ac.uk
date Thu Aug 25 17:27:49 2005 +0000 (2005-08-25)
parents 0610add7c3fe fdfd511768a3
children 8799d14bef77 9312a3e8a6f8
line source
1 #ifndef XG_PRIVATE_H
2 #define XG_PRIVATE_H
4 #include <errno.h>
5 #include <fcntl.h>
6 #include <stdio.h>
7 #include <string.h>
8 #include <sys/mman.h>
9 #include <sys/types.h>
10 #include <sys/stat.h>
12 #include "xenctrl.h"
14 #include <xen/linux/privcmd.h>
16 char *xc_read_kernel_image(const char *filename, unsigned long *size);
17 unsigned long csum_page (void * page);
19 #define _PAGE_PRESENT 0x001
20 #define _PAGE_RW 0x002
21 #define _PAGE_USER 0x004
22 #define _PAGE_PWT 0x008
23 #define _PAGE_PCD 0x010
24 #define _PAGE_ACCESSED 0x020
25 #define _PAGE_DIRTY 0x040
26 #define _PAGE_PAT 0x080
27 #define _PAGE_PSE 0x080
28 #define _PAGE_GLOBAL 0x100
30 #if defined(__i386__)
31 #define L1_PAGETABLE_SHIFT 12
32 #define L2_PAGETABLE_SHIFT 22
33 #define L1_PAGETABLE_SHIFT_PAE 12
34 #define L2_PAGETABLE_SHIFT_PAE 21
35 #define L3_PAGETABLE_SHIFT_PAE 30
36 #elif defined(__x86_64__)
37 #define L1_PAGETABLE_SHIFT 12
38 #define L2_PAGETABLE_SHIFT 21
39 #define L3_PAGETABLE_SHIFT 30
40 #define L4_PAGETABLE_SHIFT 39
41 #endif
43 #if defined(__i386__)
44 #define ENTRIES_PER_L1_PAGETABLE 1024
45 #define ENTRIES_PER_L2_PAGETABLE 1024
46 #define L1_PAGETABLE_ENTRIES_PAE 512
47 #define L2_PAGETABLE_ENTRIES_PAE 512
48 #define L3_PAGETABLE_ENTRIES_PAE 4
49 #elif defined(__x86_64__)
50 #define L1_PAGETABLE_ENTRIES 512
51 #define L2_PAGETABLE_ENTRIES 512
52 #define L3_PAGETABLE_ENTRIES 512
53 #define L4_PAGETABLE_ENTRIES 512
54 #endif
56 #define PAGE_SHIFT XC_PAGE_SHIFT
57 #define PAGE_SIZE (1UL << PAGE_SHIFT)
58 #define PAGE_MASK (~(PAGE_SIZE-1))
60 typedef u32 l1_pgentry_32_t;
61 typedef u32 l2_pgentry_32_t;
62 typedef u64 l1_pgentry_64_t;
63 typedef u64 l2_pgentry_64_t;
64 typedef u64 l3_pgentry_64_t;
65 typedef unsigned long l1_pgentry_t;
66 typedef unsigned long l2_pgentry_t;
67 #if defined(__x86_64__)
68 typedef unsigned long l3_pgentry_t;
69 typedef unsigned long l4_pgentry_t;
70 #endif
72 #if defined(__i386__)
73 #define l1_table_offset(_a) \
74 (((_a) >> L1_PAGETABLE_SHIFT) & (ENTRIES_PER_L1_PAGETABLE - 1))
75 #define l2_table_offset(_a) \
76 ((_a) >> L2_PAGETABLE_SHIFT)
77 #define l1_table_offset_pae(_a) \
78 (((_a) >> L1_PAGETABLE_SHIFT_PAE) & (L1_PAGETABLE_ENTRIES_PAE - 1))
79 #define l2_table_offset_pae(_a) \
80 (((_a) >> L2_PAGETABLE_SHIFT_PAE) & (L2_PAGETABLE_ENTRIES_PAE - 1))
81 #define l3_table_offset_pae(_a) \
82 (((_a) >> L3_PAGETABLE_SHIFT_PAE) & (L3_PAGETABLE_ENTRIES_PAE - 1))
83 #elif defined(__x86_64__)
84 #define l1_table_offset(_a) \
85 (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1))
86 #define l2_table_offset(_a) \
87 (((_a) >> L2_PAGETABLE_SHIFT) & (L2_PAGETABLE_ENTRIES - 1))
88 #define l3_table_offset(_a) \
89 (((_a) >> L3_PAGETABLE_SHIFT) & (L3_PAGETABLE_ENTRIES - 1))
90 #define l4_table_offset(_a) \
91 (((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1))
92 #endif
94 #define ERROR(_m, _a...) \
95 do { \
96 int __saved_errno = errno; \
97 fprintf(stderr, "ERROR: " _m "\n" , ## _a ); \
98 errno = __saved_errno; \
99 } while (0)
102 #define PERROR(_m, _a...) \
103 do { \
104 int __saved_errno = errno; \
105 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \
106 __saved_errno, strerror(__saved_errno)); \
107 errno = __saved_errno; \
108 } while (0)
111 struct domain_setup_info
112 {
113 unsigned long v_start;
114 unsigned long v_end;
115 unsigned long v_kernstart;
116 unsigned long v_kernend;
117 unsigned long v_kernentry;
119 unsigned int load_symtab;
120 unsigned int pae_kernel;
121 unsigned long symtab_addr;
122 unsigned long symtab_len;
123 };
125 typedef int (*parseimagefunc)(char *image, unsigned long image_size,
126 struct domain_setup_info *dsi);
127 typedef int (*loadimagefunc)(char *image, unsigned long image_size, int xch,
128 u32 dom, unsigned long *parray,
129 struct domain_setup_info *dsi);
131 struct load_funcs
132 {
133 parseimagefunc parseimage;
134 loadimagefunc loadimage;
135 };
137 #define mfn_mapper_queue_size 128
139 typedef struct mfn_mapper {
140 int xc_handle;
141 int size;
142 int prot;
143 int error;
144 int max_queue_size;
145 void * addr;
146 privcmd_mmap_t ioctl;
148 } mfn_mapper_t;
150 unsigned long xc_get_m2p_start_mfn (int xc_handle);
152 int xc_copy_to_domain_page(int xc_handle, u32 domid,
153 unsigned long dst_pfn, void *src_page);
155 unsigned long xc_get_filesz(int fd);
157 void xc_map_memcpy(unsigned long dst, char *src, unsigned long size,
158 int xch, u32 dom, unsigned long *parray,
159 unsigned long vstart);
161 int pin_table(int xc_handle, unsigned int type, unsigned long mfn,
162 domid_t dom);
164 /* image loading */
165 int probe_elf(char *image, unsigned long image_size, struct load_funcs *funcs);
166 int probe_bin(char *image, unsigned long image_size, struct load_funcs *funcs);
167 int probe_aout9(char *image, unsigned long image_size, struct load_funcs *funcs);
169 #endif