xref: /openbmc/qemu/target/i386/hvf/x86_descr.h (revision c63ca4ff)
1 /*
2  * Copyright (C) 2016 Veertu Inc,
3  * Copyright (C) 2017 Google Inc,
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef HVF_X86_DESCR_H
20 #define HVF_X86_DESCR_H
21 
22 #include "x86.h"
23 
24 typedef struct vmx_segment {
25     uint16_t sel;
26     uint64_t base;
27     uint64_t limit;
28     uint64_t ar;
29 } vmx_segment;
30 
31 /* deal with vmstate descriptors */
32 void vmx_read_segment_descriptor(struct CPUState *cpu,
33                                  struct vmx_segment *desc, enum X86Seg seg);
34 void vmx_write_segment_descriptor(CPUState *cpu, struct vmx_segment *desc,
35                                   enum X86Seg seg);
36 
37 x68_segment_selector vmx_read_segment_selector(struct CPUState *cpu,
38                                                enum X86Seg seg);
39 void vmx_write_segment_selector(struct CPUState *cpu,
40                                 x68_segment_selector selector,
41                                 enum X86Seg seg);
42 
43 uint64_t vmx_read_segment_base(struct CPUState *cpu, enum X86Seg seg);
44 void vmx_write_segment_base(struct CPUState *cpu, enum X86Seg seg,
45                             uint64_t base);
46 
47 void x86_segment_descriptor_to_vmx(struct CPUState *cpu,
48                                    x68_segment_selector selector,
49                                    struct x86_segment_descriptor *desc,
50                                    struct vmx_segment *vmx_desc);
51 
52 uint32_t vmx_read_segment_limit(CPUState *cpu, enum X86Seg seg);
53 uint32_t vmx_read_segment_ar(CPUState *cpu, enum X86Seg seg);
54 void vmx_segment_to_x86_descriptor(struct CPUState *cpu,
55                                    struct vmx_segment *vmx_desc,
56                                    struct x86_segment_descriptor *desc);
57 
58 #endif
59