aboutsummaryrefslogtreecommitdiff
path: root/target/i386/hax/hax-i386.h
blob: efbb3462389b6e590eb285fa94642ff04afa947b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * QEMU HAXM support
 *
 * Copyright (c) 2011 Intel Corporation
 *  Written by:
 *  Jiang Yunhong<yunhong.jiang@intel.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 *
 */

#ifndef HAX_I386_H
#define HAX_I386_H

#include "cpu.h"
#include "sysemu/hax.h"

#ifdef CONFIG_POSIX
typedef int hax_fd;
#endif

#ifdef CONFIG_WIN32
typedef HANDLE hax_fd;
#endif

extern struct hax_state hax_global;
struct hax_vcpu_state {
    hax_fd fd;
    int vcpu_id;
    struct hax_tunnel *tunnel;
    unsigned char *iobuf;
};

struct hax_state {
    hax_fd fd; /* the global hax device interface */
    uint32_t version;
    struct hax_vm *vm;
    uint64_t mem_quota;
    bool supports_64bit_ramblock;
};

#define HAX_MAX_VCPU 0x10

struct hax_vm {
    hax_fd fd;
    int id;
    int numvcpus;
    struct hax_vcpu_state **vcpus;
};

#ifdef NEED_CPU_H
/* Functions exported to host specific mode */
hax_fd hax_vcpu_get_fd(CPUArchState *env);
int valid_hax_tunnel_size(uint16_t size);

/* Host specific functions */
int hax_mod_version(struct hax_state *hax, struct hax_module_version *version);
int hax_inject_interrupt(CPUArchState *env, int vector);
struct hax_vm *hax_vm_create(struct hax_state *hax, int max_cpus);
int hax_vcpu_run(struct hax_vcpu_state *vcpu);
int hax_vcpu_create(int id);
void hax_kick_vcpu_thread(CPUState *cpu);

int hax_sync_vcpu_state(CPUArchState *env, struct vcpu_state_t *state,
                        int set);
int hax_sync_msr(CPUArchState *env, struct hax_msr_data *msrs, int set);
int hax_sync_fpu(CPUArchState *env, struct fx_layout *fl, int set);
#endif

int hax_vm_destroy(struct hax_vm *vm);
int hax_capability(struct hax_state *hax, struct hax_capabilityinfo *cap);
int hax_notify_qemu_version(hax_fd vm_fd, struct hax_qemu_version *qversion);
int hax_set_ram(uint64_t start_pa, uint32_t size, uint64_t host_va, int flags);

/* Common host function */
int hax_host_create_vm(struct hax_state *hax, int *vm_id);
hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id);
int hax_host_create_vcpu(hax_fd vm_fd, int vcpuid);
hax_fd hax_host_open_vcpu(int vmid, int vcpuid);
int hax_host_setup_vcpu_channel(struct hax_vcpu_state *vcpu);
hax_fd hax_mod_open(void);
void hax_memory_init(void);


#ifdef CONFIG_POSIX
#include "hax-posix.h"
#endif

#ifdef CONFIG_WIN32
#include "hax-windows.h"
#endif

#include "hax-interface.h"

#endif