~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/ipxe/src/arch/x86/include/ipxe/vmware.h

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _IPXE_VMWARE_H
 
2
#define _IPXE_VMWARE_H
 
3
 
 
4
/** @file
 
5
 *
 
6
 * VMware backdoor mechanism
 
7
 *
 
8
 */
 
9
 
 
10
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
11
 
 
12
#include <stdint.h>
 
13
 
 
14
/** VMware backdoor I/O port */
 
15
#define VMW_PORT 0x5658
 
16
 
 
17
/** VMware backdoor magic value */
 
18
#define VMW_MAGIC 0x564d5868 /* "VMXh" */
 
19
 
 
20
/** VMware backdoor magic instruction */
 
21
#define VMW_BACKDOOR "inl %%dx, %%eax"
 
22
 
 
23
/** Get VMware version */
 
24
#define VMW_CMD_GET_VERSION 0x0a
 
25
 
 
26
/** Issue GuestRPC command */
 
27
#define VMW_CMD_GUESTRPC 0x1e
 
28
 
 
29
/**
 
30
 * Get VMware version
 
31
 *
 
32
 * @ret version         VMware version(?)
 
33
 * @ret magic           VMware magic number, if present
 
34
 * @ret product_type    VMware product type
 
35
 */
 
36
static inline __attribute__ (( always_inline )) void
 
37
vmware_cmd_get_version ( uint32_t *version, uint32_t *magic,
 
38
                         uint32_t *product_type ) {
 
39
        uint32_t discard_d;
 
40
 
 
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 ),
 
47
                                 "3" ( VMW_PORT ) );
 
48
}
 
49
 
 
50
/**
 
51
 * Issue GuestRPC command
 
52
 *
 
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
 
59
 */
 
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 ) {
 
63
        uint32_t discard_a;
 
64
        uint32_t status;
 
65
        uint32_t edx;
 
66
 
 
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 );
 
75
 
 
76
        return status;
 
77
}
 
78
 
 
79
extern int vmware_present ( void );
 
80
 
 
81
#endif /* _IPXE_VMWARE_H */