You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vmware.h 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef _IPXE_VMWARE_H
  2. #define _IPXE_VMWARE_H
  3. /** @file
  4. *
  5. * VMware backdoor mechanism
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. /** VMware backdoor I/O port */
  11. #define VMW_PORT 0x5658
  12. /** VMware backdoor magic value */
  13. #define VMW_MAGIC 0x564d5868 /* "VMXh" */
  14. /** VMware backdoor magic instruction */
  15. #define VMW_BACKDOOR "inl %%dx, %%eax"
  16. /** Get VMware version */
  17. #define VMW_CMD_GET_VERSION 0x0a
  18. /** Issue GuestRPC command */
  19. #define VMW_CMD_GUESTRPC 0x1e
  20. /**
  21. * Get VMware version
  22. *
  23. * @ret version VMware version(?)
  24. * @ret magic VMware magic number, if present
  25. * @ret product_type VMware product type
  26. */
  27. static inline __attribute__ (( always_inline )) void
  28. vmware_cmd_get_version ( uint32_t *version, uint32_t *magic,
  29. uint32_t *product_type ) {
  30. uint32_t discard_d;
  31. /* Perform backdoor call */
  32. __asm__ __volatile__ ( VMW_BACKDOOR
  33. : "=a" ( *version ), "=b" ( *magic ),
  34. "=c" ( *product_type ), "=d" ( discard_d )
  35. : "0" ( VMW_MAGIC ), "1" ( 0 ),
  36. "2" ( VMW_CMD_GET_VERSION ),
  37. "3" ( VMW_PORT ) );
  38. }
  39. /**
  40. * Issue GuestRPC command
  41. *
  42. * @v channel Channel number
  43. * @v subcommand GuestRPC subcommand
  44. * @v parameter Subcommand-specific parameter
  45. * @ret edxhi Subcommand-specific result
  46. * @ret ebx Subcommand-specific result
  47. * @ret status Command status
  48. */
  49. static inline __attribute__ (( always_inline )) uint32_t
  50. vmware_cmd_guestrpc ( int channel, uint16_t subcommand, uint32_t parameter,
  51. uint16_t *edxhi, uint32_t *ebx ) {
  52. uint32_t discard_a;
  53. uint32_t status;
  54. uint32_t edx;
  55. /* Perform backdoor call */
  56. __asm__ __volatile__ ( VMW_BACKDOOR
  57. : "=a" ( discard_a ), "=b" ( *ebx ),
  58. "=c" ( status ), "=d" ( edx )
  59. : "0" ( VMW_MAGIC ), "1" ( parameter ),
  60. "2" ( VMW_CMD_GUESTRPC | ( subcommand << 16 )),
  61. "3" ( VMW_PORT | ( channel << 16 ) ) );
  62. *edxhi = ( edx >> 16 );
  63. return status;
  64. }
  65. extern int vmware_present ( void );
  66. #endif /* _IPXE_VMWARE_H */