xref: /netbsd-src/sys/dev/vmt/vmtreg.h (revision 0b42d22ad020a799c366e18ca3a25bfccc9d4b88)
1 /* $NetBSD: vmtreg.h,v 1.1 2020/10/27 08:57:11 ryo Exp $ */
2 /* NetBSD: vmt.c,v 1.15 2016/11/10 03:32:04 ozaki-r Exp */
3 /* $OpenBSD: vmt.c,v 1.11 2011/01/27 21:29:25 dtucker Exp $ */
4 
5 /*
6  * Copyright (c) 2007 David Crawshaw <david@zentus.com>
7  * Copyright (c) 2008 David Gwynne <dlg@openbsd.org>
8  *
9  * Permission to use, copy, modify, and distribute this software for any
10  * purpose with or without fee is hereby granted, provided that the above
11  * copyright notice and this permission notice appear in all copies.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20  */
21 
22 #ifndef _DEV_VMT_VMTREG_H_
23 #define _DEV_VMT_VMTREG_H_
24 
25 /* OS name to report to host */
26 #ifdef __i386__
27 #define VM_OS_NAME	"other"
28 #else
29 #define VM_OS_NAME	"other-64"
30 #endif
31 
32 /* "The" magic number, always occupies the EAX register. */
33 #define VM_MAGIC			0x564D5868
34 
35 /* Port numbers, passed on EDX.LOW . */
36 #define VM_PORT_CMD			0x5658
37 #define VM_PORT_RPC			0x5659
38 
39 /* Commands, passed on ECX.LOW. */
40 #define VM_CMD_GET_SPEED		0x01
41 #define VM_CMD_APM			0x02
42 #define VM_CMD_GET_MOUSEPOS		0x04
43 #define VM_CMD_SET_MOUSEPOS		0x05
44 #define VM_CMD_GET_CLIPBOARD_LEN	0x06
45 #define VM_CMD_GET_CLIPBOARD		0x07
46 #define VM_CMD_SET_CLIPBOARD_LEN	0x08
47 #define VM_CMD_SET_CLIPBOARD		0x09
48 #define VM_CMD_GET_VERSION		0x0a
49 #define  VM_VERSION_UNMANAGED			0x7fffffff
50 #define VM_CMD_GET_DEVINFO		0x0b
51 #define VM_CMD_DEV_ADDREMOVE		0x0c
52 #define VM_CMD_GET_GUI_OPTIONS		0x0d
53 #define VM_CMD_SET_GUI_OPTIONS		0x0e
54 #define VM_CMD_GET_SCREEN_SIZE		0x0f
55 #define VM_CMD_GET_HWVER		0x11
56 #define VM_CMD_POPUP_OSNOTFOUND		0x12
57 #define VM_CMD_GET_BIOS_UUID		0x13
58 #define VM_CMD_GET_MEM_SIZE		0x14
59 /*#define VM_CMD_GET_TIME		0x17 */	/* deprecated */
60 #define VM_CMD_RPC			0x1e
61 #define VM_CMD_GET_HZ			0x2d
62 #define VM_CMD_GET_TIME_FULL		0x2e
63 #define VM_CMD_GET_VCPU_INFO		0x44
64 #define  VCPUINFO_LEGACY_X2APIC			__BIT(3)
65 #define  VCPUINFO_VCPU_RESERVED			__BIT(31)
66 
67 /* RPC sub-commands, passed on ECX.HIGH. */
68 #define VM_RPC_OPEN			0x00
69 #define VM_RPC_SET_LENGTH		0x01
70 #define VM_RPC_SET_DATA			0x02
71 #define VM_RPC_GET_LENGTH		0x03
72 #define VM_RPC_GET_DATA			0x04
73 #define VM_RPC_GET_END			0x05
74 #define VM_RPC_CLOSE			0x06
75 
76 /* RPC magic numbers, passed on EBX. */
77 #define VM_RPC_OPEN_RPCI	0x49435052UL /* with VM_RPC_OPEN. */
78 #define VM_RPC_OPEN_TCLO	0x4F4C4354UL /* with VP_RPC_OPEN. */
79 #define VM_RPC_ENH_DATA		0x00010000UL /* with enhanced RPC data calls. */
80 
81 #define VM_RPC_FLAG_COOKIE	0x80000000UL
82 
83 /* RPC reply flags */
84 #define VM_RPC_REPLY_SUCCESS	0x0001
85 #define VM_RPC_REPLY_DORECV	0x0002		/* incoming message available */
86 #define VM_RPC_REPLY_CLOSED	0x0004		/* RPC channel is closed */
87 #define VM_RPC_REPLY_UNSENT	0x0008		/* incoming message was removed? */
88 #define VM_RPC_REPLY_CHECKPOINT	0x0010		/* checkpoint occurred -> retry */
89 #define VM_RPC_REPLY_POWEROFF	0x0020		/* underlying device is powering off */
90 #define VM_RPC_REPLY_TIMEOUT	0x0040
91 #define VM_RPC_REPLY_HB		0x0080		/* high-bandwidth tx/rx available */
92 
93 /* VM state change IDs */
94 #define VM_STATE_CHANGE_HALT	1
95 #define VM_STATE_CHANGE_REBOOT	2
96 #define VM_STATE_CHANGE_POWERON 3
97 #define VM_STATE_CHANGE_RESUME  4
98 #define VM_STATE_CHANGE_SUSPEND 5
99 
100 /* VM guest info keys */
101 #define VM_GUEST_INFO_DNS_NAME		1
102 #define VM_GUEST_INFO_IP_ADDRESS	2
103 #define VM_GUEST_INFO_DISK_FREE_SPACE	3
104 #define VM_GUEST_INFO_BUILD_NUMBER	4
105 #define VM_GUEST_INFO_OS_NAME_FULL	5
106 #define VM_GUEST_INFO_OS_NAME		6
107 #define VM_GUEST_INFO_UPTIME		7
108 #define VM_GUEST_INFO_MEMORY		8
109 #define VM_GUEST_INFO_IP_ADDRESS_V2	9
110 
111 /* RPC responses */
112 #define VM_RPC_REPLY_OK			"OK "
113 #define VM_RPC_RESET_REPLY		"OK ATR toolbox"
114 #define VM_RPC_REPLY_ERROR		"ERROR Unknown command"
115 #define VM_RPC_REPLY_ERROR_IP_ADDR	"ERROR Unable to find guest IP address"
116 
117 #endif /* _DEV_VMT_VMTREG_H_ */
118