2 * VMI interface definition
4 * Copyright (C) 2005, VMware, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Maintained by: Zachary Amsden zach@vmware.com
24 #include <linux/types.h>
27 *---------------------------------------------------------------------
31 *---------------------------------------------------------------------
33 #define VMI_SIGNATURE 0x696d5663 /* "cVmi" */
35 #define PCI_VENDOR_ID_VMWARE 0x15AD
36 #define PCI_DEVICE_ID_VMWARE_VMI 0x0801
39 * We use two version numbers for compatibility, with the major
40 * number signifying interface breakages, and the minor number
41 * interface extensions.
43 #define VMI_API_REV_MAJOR 3
44 #define VMI_API_REV_MINOR 0
46 #define VMI_CALL_CPUID 0
47 #define VMI_CALL_WRMSR 1
48 #define VMI_CALL_RDMSR 2
49 #define VMI_CALL_SetGDT 3
50 #define VMI_CALL_SetLDT 4
51 #define VMI_CALL_SetIDT 5
52 #define VMI_CALL_SetTR 6
53 #define VMI_CALL_GetGDT 7
54 #define VMI_CALL_GetLDT 8
55 #define VMI_CALL_GetIDT 9
56 #define VMI_CALL_GetTR 10
57 #define VMI_CALL_WriteGDTEntry 11
58 #define VMI_CALL_WriteLDTEntry 12
59 #define VMI_CALL_WriteIDTEntry 13
60 #define VMI_CALL_UpdateKernelStack 14
61 #define VMI_CALL_SetCR0 15
62 #define VMI_CALL_SetCR2 16
63 #define VMI_CALL_SetCR3 17
64 #define VMI_CALL_SetCR4 18
65 #define VMI_CALL_GetCR0 19
66 #define VMI_CALL_GetCR2 20
67 #define VMI_CALL_GetCR3 21
68 #define VMI_CALL_GetCR4 22
69 #define VMI_CALL_WBINVD 23
70 #define VMI_CALL_SetDR 24
71 #define VMI_CALL_GetDR 25
72 #define VMI_CALL_RDPMC 26
73 #define VMI_CALL_RDTSC 27
74 #define VMI_CALL_CLTS 28
75 #define VMI_CALL_EnableInterrupts 29
76 #define VMI_CALL_DisableInterrupts 30
77 #define VMI_CALL_GetInterruptMask 31
78 #define VMI_CALL_SetInterruptMask 32
79 #define VMI_CALL_IRET 33
80 #define VMI_CALL_SYSEXIT 34
81 #define VMI_CALL_Halt 35
82 #define VMI_CALL_Reboot 36
83 #define VMI_CALL_Shutdown 37
84 #define VMI_CALL_SetPxE 38
85 #define VMI_CALL_SetPxELong 39
86 #define VMI_CALL_UpdatePxE 40
87 #define VMI_CALL_UpdatePxELong 41
88 #define VMI_CALL_MachineToPhysical 42
89 #define VMI_CALL_PhysicalToMachine 43
90 #define VMI_CALL_AllocatePage 44
91 #define VMI_CALL_ReleasePage 45
92 #define VMI_CALL_InvalPage 46
93 #define VMI_CALL_FlushTLB 47
94 #define VMI_CALL_SetLinearMapping 48
96 #define VMI_CALL_SetIOPLMask 61
97 #define VMI_CALL_SetInitialAPState 62
98 #define VMI_CALL_APICWrite 63
99 #define VMI_CALL_APICRead 64
100 #define VMI_CALL_IODelay 65
101 #define VMI_CALL_SetLazyMode 73
104 *---------------------------------------------------------------------
106 * MMU operation flags
108 *---------------------------------------------------------------------
111 /* Flags used by VMI_{Allocate|Release}Page call */
112 #define VMI_PAGE_PAE 0x10 /* Allocate PAE shadow */
113 #define VMI_PAGE_CLONE 0x20 /* Clone from another shadow */
114 #define VMI_PAGE_ZEROED 0x40 /* Page is pre-zeroed */
117 /* Flags shared by Allocate|Release Page and PTE updates */
118 #define VMI_PAGE_PT 0x01
119 #define VMI_PAGE_PD 0x02
120 #define VMI_PAGE_PDP 0x04
121 #define VMI_PAGE_PML4 0x08
123 #define VMI_PAGE_NORMAL 0x00 /* for debugging */
125 /* Flags used by PTE updates */
126 #define VMI_PAGE_CURRENT_AS 0x10 /* implies VMI_PAGE_VA_MASK is valid */
127 #define VMI_PAGE_DEFER 0x20 /* may queue update until TLB inval */
128 #define VMI_PAGE_VA_MASK 0xfffff000
130 #ifdef CONFIG_X86_PAE
131 #define VMI_PAGE_L1 (VMI_PAGE_PT | VMI_PAGE_PAE | VMI_PAGE_ZEROED)
132 #define VMI_PAGE_L2 (VMI_PAGE_PD | VMI_PAGE_PAE | VMI_PAGE_ZEROED)
134 #define VMI_PAGE_L1 (VMI_PAGE_PT | VMI_PAGE_ZEROED)
135 #define VMI_PAGE_L2 (VMI_PAGE_PD | VMI_PAGE_ZEROED)
138 /* Flags used by VMI_FlushTLB call */
139 #define VMI_FLUSH_TLB 0x01
140 #define VMI_FLUSH_GLOBAL 0x02
143 *---------------------------------------------------------------------
145 * VMI relocation definitions for ROM call get_reloc
147 *---------------------------------------------------------------------
150 /* VMI Relocation types */
151 #define VMI_RELOCATION_NONE 0
152 #define VMI_RELOCATION_CALL_REL 1
153 #define VMI_RELOCATION_JUMP_REL 2
154 #define VMI_RELOCATION_NOP 3
157 struct vmi_relocation_info {
160 unsigned char reserved[3];
166 *---------------------------------------------------------------------
168 * Generic ROM structures and definitions
170 *---------------------------------------------------------------------
176 u16 rom_signature; /* option ROM signature */
177 u8 rom_length; /* ROM length in 512 byte chunks */
178 u8 rom_entry[4]; /* 16-bit code entry point */
179 u8 rom_pad0; /* 4-byte align pad */
180 u32 vrom_signature; /* VROM identification signature */
181 u8 api_version_min;/* Minor version of API */
182 u8 api_version_maj;/* Major version of API */
183 u8 jump_slots; /* Number of jump slots */
184 u8 reserved1; /* Reserved for expansion */
185 u32 virtual_top; /* Hypervisor virtual address start */
186 u16 reserved2; /* Reserved for expansion */
187 u16 license_offs; /* Offset to License string */
188 u16 pci_header_offs;/* Offset to PCI OPROM header */
189 u16 pnp_header_offs;/* Offset to PnP OPROM header */
190 u32 rom_pad3; /* PnP reserverd / VMI reserved */
191 u8 reserved[96]; /* Reserved for headers */
192 char vmi_init[8]; /* VMI_Init jump point */
193 char get_reloc[8]; /* VMI_GetRelocationInfo jump point */
194 } __attribute__((packed));
203 unsigned short manufacturer_offset;
204 unsigned short product_offset;
205 } __attribute__((packed));
218 char rom_version_min;
219 char rom_version_maj;
223 } __attribute__((packed));
225 /* Function prototypes for bootstrapping */
226 extern void vmi_init(void);
227 extern void vmi_bringup(void);
228 extern void vmi_apply_boot_page_allocations(void);
230 /* State needed to start an application processor in an SMP system. */
231 struct vmi_ap_state {