aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/asm-ia64/vmx_vpd.h
blob: 78149ba31f21cbde1d60341eaf9b1b0bbfeccf36 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
/*
 * vmx.h: prototype for generial vmx related interface
 * Copyright (c) 2004, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307 USA.
 *
 *      Kun Tian (Kevin Tian) (kevin.tian@intel.com)
 */

#ifndef _VPD_H_
#define _VPD_H_

#ifndef __ASSEMBLY__

#include <asm/vtm.h>
#include <asm/vmx_platform.h>

#define VPD_SHIFT	17	/* 128K requirement */
#define VPD_SIZE	(1 << VPD_SHIFT)
typedef union {
	unsigned long value;
	struct {
		int 	a_int:1;
		int 	a_from_int_cr:1;
		int	a_to_int_cr:1;
		int	a_from_psr:1;
		int	a_from_cpuid:1;
		int	a_cover:1;
		int	a_bsw:1;
		long	reserved:57;
	};
} vac_t;

typedef union {
	unsigned long value;
	struct {
		int 	d_vmsw:1;
		int 	d_extint:1;
		int	d_ibr_dbr:1;
		int	d_pmc:1;
		int	d_to_pmd:1;
		int	d_itm:1;
		long	reserved:58;
	};
} vdc_t;

typedef struct {
	unsigned long	dcr;		// CR0
	unsigned long	itm;
	unsigned long	iva;
	unsigned long	rsv1[5];
	unsigned long	pta;		// CR8
	unsigned long	rsv2[7];
	unsigned long	ipsr;		// CR16
	unsigned long	isr;
	unsigned long	rsv3;
	unsigned long	iip;
	unsigned long	ifa;
	unsigned long	itir;
	unsigned long	iipa;
	unsigned long	ifs;
	unsigned long	iim;		// CR24
	unsigned long	iha;
	unsigned long	rsv4[38];
	unsigned long	lid;		// CR64
	unsigned long	ivr;
	unsigned long	tpr;
	unsigned long	eoi;
	unsigned long	irr[4];
	unsigned long	itv;		// CR72
	unsigned long	pmv;
	unsigned long	cmcv;
	unsigned long	rsv5[5];
	unsigned long	lrr0;		// CR80
	unsigned long	lrr1;
	unsigned long	rsv6[46];
} cr_t;

typedef struct vpd {
	vac_t			vac;
	vdc_t			vdc;
	unsigned long		virt_env_vaddr;
	unsigned long		reserved1[29];
	unsigned long		vhpi;
	unsigned long		reserved2[95];
	unsigned long		vgr[16];
	unsigned long		vbgr[16];
	unsigned long		vnat;
	unsigned long		vbnat;
	unsigned long		vcpuid[5];
	unsigned long		reserved3[11];
	unsigned long		vpsr;
	unsigned long		vpr;
	unsigned long		reserved4[76];
	unsigned long		vcr[128];
	unsigned long		reserved5[128];
	unsigned long		reserved6[3456];
	unsigned long		vmm_avail[128];
	unsigned long		reserved7[4096];
} vpd_t;

void vmx_enter_scheduler(void);

//FIXME: Map for LID to vcpu, Eddie
#define	MAX_NUM_LPS		(1UL<<16)
extern struct vcpu	*lid_edt[MAX_NUM_LPS];

struct arch_vmx_struct {
//    struct virutal_platform_def     vmx_platform;
	vpd_t       *vpd;
	vtime_t	    vtm;
    unsigned long   vrr[8];
    unsigned long   mrr5;
    unsigned long   mrr6;
    unsigned long   mrr7;
    unsigned long   mpta;
    unsigned long   rfi_pfs;
    unsigned long   rfi_iip;
    unsigned long   rfi_ipsr;
    unsigned long   rfi_ifs;
	unsigned long	in_service[4];	// vLsapic inservice IRQ bits
	struct virutal_platform_def     vmx_platform;
	unsigned long   flags;
};

#define vmx_schedule_tail(next)         \
    (next)->thread.arch_vmx.arch_vmx_schedule_tail((next))

#define VMX_DOMAIN(d)   d->arch.arch_vmx.flags

#define ARCH_VMX_VMCS_LOADED    0       /* VMCS has been loaded and active */
#define ARCH_VMX_VMCS_LAUNCH    1       /* Needs VMCS launch */
#define ARCH_VMX_VMCS_RESUME    2       /* Needs VMCS resume */
#define ARCH_VMX_IO_WAIT        3       /* Waiting for I/O completion */


#define VMX_DEBUG 1
#if VMX_DEBUG
#define DBG_LEVEL_0     (1 << 0)
#define DBG_LEVEL_1     (1 << 1)
#define DBG_LEVEL_2     (1 << 2)
#define DBG_LEVEL_3     (1 << 3)
#define DBG_LEVEL_IO    (1 << 4)
#define DBG_LEVEL_VMMU  (1 << 5)

extern unsigned int opt_vmx_debug_level;
#define VMX_DBG_LOG(level, _f, _a...)           \
    if ((level) & opt_vmx_debug_level)          \
        printk("[VMX]" _f "\n", ## _a )
#else
#define VMX_DBG_LOG(level, _f, _a...)
#endif

#define  __vmx_bug(regs)                                        \
    do {                                                        \
        printk("__vmx_bug at %s:%d\n", __FILE__, __LINE__);     \
        show_registers(regs);                                   \
        domain_crash();                                         \
    } while (0)

#endif //__ASSEMBLY__


// VPD field offset
#define VPD_VAC_START_OFFSET		0
#define VPD_VDC_START_OFFSET		8
#define VPD_VHPI_START_OFFSET		256
#define VPD_VGR_START_OFFSET		1024
#define VPD_VBGR_START_OFFSET		1152
#define VPD_VNAT_START_OFFSET		1280
#define VPD_VBNAT_START_OFFSET		1288
#define VPD_VCPUID_START_OFFSET		1296
#define VPD_VPSR_START_OFFSET		1424
#define VPD_VPR_START_OFFSET		1432
#define VPD_VRSE_CFLE_START_OFFSET	1440
#define VPD_VCR_START_OFFSET		2048
#define VPD_VRR_START_OFFSET		3072
#define VPD_VMM_VAIL_START_OFFSET	31744


#endif /* _VPD_H_ */