Replace tabs by 8 spaces. No code change, by Herve Poussineau.
[qemu/dscho.git] / kqemu.h
blob892e335935d090e6efc6edee57c91c6510d1b51b
1 /*
2 * KQEMU header
3 *
4 * Copyright (c) 2004-2006 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
24 #ifndef KQEMU_H
25 #define KQEMU_H
27 #define KQEMU_VERSION 0x010300
29 struct kqemu_segment_cache {
30 uint32_t selector;
31 unsigned long base;
32 uint32_t limit;
33 uint32_t flags;
36 struct kqemu_cpu_state {
37 #ifdef __x86_64__
38 unsigned long regs[16];
39 #else
40 unsigned long regs[8];
41 #endif
42 unsigned long eip;
43 unsigned long eflags;
45 uint32_t dummy0, dummy1, dumm2, dummy3, dummy4;
47 struct kqemu_segment_cache segs[6]; /* selector values */
48 struct kqemu_segment_cache ldt;
49 struct kqemu_segment_cache tr;
50 struct kqemu_segment_cache gdt; /* only base and limit are used */
51 struct kqemu_segment_cache idt; /* only base and limit are used */
53 unsigned long cr0;
54 unsigned long dummy5;
55 unsigned long cr2;
56 unsigned long cr3;
57 unsigned long cr4;
58 uint32_t a20_mask;
60 /* sysenter registers */
61 uint32_t sysenter_cs;
62 uint32_t sysenter_esp;
63 uint32_t sysenter_eip;
64 uint64_t efer __attribute__((aligned(8)));
65 uint64_t star;
66 #ifdef __x86_64__
67 unsigned long lstar;
68 unsigned long cstar;
69 unsigned long fmask;
70 unsigned long kernelgsbase;
71 #endif
72 uint64_t tsc_offset;
74 unsigned long dr0;
75 unsigned long dr1;
76 unsigned long dr2;
77 unsigned long dr3;
78 unsigned long dr6;
79 unsigned long dr7;
81 uint8_t cpl;
82 uint8_t user_only;
84 uint32_t error_code; /* error_code when exiting with an exception */
85 unsigned long next_eip; /* next eip value when exiting with an interrupt */
86 unsigned int nb_pages_to_flush; /* number of pages to flush,
87 KQEMU_FLUSH_ALL means full flush */
88 #define KQEMU_MAX_PAGES_TO_FLUSH 512
89 #define KQEMU_FLUSH_ALL (KQEMU_MAX_PAGES_TO_FLUSH + 1)
91 long retval;
93 /* number of ram_dirty entries to update */
94 unsigned int nb_ram_pages_to_update;
95 #define KQEMU_MAX_RAM_PAGES_TO_UPDATE 512
96 #define KQEMU_RAM_PAGES_UPDATE_ALL (KQEMU_MAX_RAM_PAGES_TO_UPDATE + 1)
98 #define KQEMU_MAX_MODIFIED_RAM_PAGES 512
99 unsigned int nb_modified_ram_pages;
102 struct kqemu_init {
103 uint8_t *ram_base; /* must be page aligned */
104 unsigned long ram_size; /* must be multiple of 4 KB */
105 uint8_t *ram_dirty; /* must be page aligned */
106 uint32_t **phys_to_ram_map; /* must be page aligned */
107 unsigned long *pages_to_flush; /* must be page aligned */
108 unsigned long *ram_pages_to_update; /* must be page aligned */
109 unsigned long *modified_ram_pages; /* must be page aligned */
112 #define KQEMU_RET_ABORT (-1)
113 #define KQEMU_RET_EXCEPTION 0x0000 /* 8 low order bit are the exception */
114 #define KQEMU_RET_INT 0x0100 /* 8 low order bit are the interrupt */
115 #define KQEMU_RET_SOFTMMU 0x0200 /* emulation needed (I/O or
116 unsupported INSN) */
117 #define KQEMU_RET_INTR 0x0201 /* interrupted by a signal */
118 #define KQEMU_RET_SYSCALL 0x0300 /* syscall insn */
120 #ifdef _WIN32
121 #define KQEMU_EXEC CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
122 #define KQEMU_INIT CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_BUFFERED, FILE_WRITE_ACCESS)
123 #define KQEMU_GET_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, 3, METHOD_BUFFERED, FILE_READ_ACCESS)
124 #define KQEMU_MODIFY_RAM_PAGES CTL_CODE(FILE_DEVICE_UNKNOWN, 4, METHOD_BUFFERED, FILE_WRITE_ACCESS)
125 #else
126 #define KQEMU_EXEC _IOWR('q', 1, struct kqemu_cpu_state)
127 #define KQEMU_INIT _IOW('q', 2, struct kqemu_init)
128 #define KQEMU_GET_VERSION _IOR('q', 3, int)
129 #define KQEMU_MODIFY_RAM_PAGES _IOW('q', 4, int)
130 #endif
132 #endif /* KQEMU_H */