6
* VMware backdoor mechanism
10
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
14
/** VMware backdoor I/O port */
15
#define VMW_PORT 0x5658
17
/** VMware backdoor magic value */
18
#define VMW_MAGIC 0x564d5868 /* "VMXh" */
20
/** VMware backdoor magic instruction */
21
#define VMW_BACKDOOR "inl %%dx, %%eax"
23
/** Get VMware version */
24
#define VMW_CMD_GET_VERSION 0x0a
26
/** Issue GuestRPC command */
27
#define VMW_CMD_GUESTRPC 0x1e
32
* @ret version VMware version(?)
33
* @ret magic VMware magic number, if present
34
* @ret product_type VMware product type
36
static inline __attribute__ (( always_inline )) void
37
vmware_cmd_get_version ( uint32_t *version, uint32_t *magic,
38
uint32_t *product_type ) {
41
/* Perform backdoor call */
42
__asm__ __volatile__ ( VMW_BACKDOOR
43
: "=a" ( *version ), "=b" ( *magic ),
44
"=c" ( *product_type ), "=d" ( discard_d )
45
: "0" ( VMW_MAGIC ), "1" ( 0 ),
46
"2" ( VMW_CMD_GET_VERSION ),
51
* Issue GuestRPC command
53
* @v channel Channel number
54
* @v subcommand GuestRPC subcommand
55
* @v parameter Subcommand-specific parameter
56
* @ret edxhi Subcommand-specific result
57
* @ret ebx Subcommand-specific result
58
* @ret status Command status
60
static inline __attribute__ (( always_inline )) uint32_t
61
vmware_cmd_guestrpc ( int channel, uint16_t subcommand, uint32_t parameter,
62
uint16_t *edxhi, uint32_t *ebx ) {
67
/* Perform backdoor call */
68
__asm__ __volatile__ ( VMW_BACKDOOR
69
: "=a" ( discard_a ), "=b" ( *ebx ),
70
"=c" ( status ), "=d" ( edx )
71
: "0" ( VMW_MAGIC ), "1" ( parameter ),
72
"2" ( VMW_CMD_GUESTRPC | ( subcommand << 16 )),
73
"3" ( VMW_PORT | ( channel << 16 ) ) );
74
*edxhi = ( edx >> 16 );
79
extern int vmware_present ( void );
81
#endif /* _IPXE_VMWARE_H */