/* hvm_fep_inl_test $Revision: 1.13 $ * * gcc -g -Wall -m64 -O6 -o hvm_fep_inl_test64 hvm_fep_inl_test.c * */ #include #include #include #include #include #include #include #include #define __USE_GNU #include #include #include /* Local types */ typedef short unsigned uint16_t; typedef int unsigned uint32_t; typedef long long unsigned uint64_t; /* File vars */ static int debug = 0x380000; static int qemu_port = 0x3f1; /* VmWare stuff. */ #define VMWARE_PORT32xin(cmd, eax, ebx, ecx, edx) \ __asm__(".byte 0xf,0xb,0x78,0x65,0x6e\n\tinl (%%dx)" : \ "=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) : \ "0"(VMWARE_HYPERVISOR_MAGIC), \ "1"(VMWARE_PORT_CMD_##cmd), \ "2"(qemu_port), "3"(ebx) : \ "memory"); /* Start of Kernel copy. * 2.6.18-194.32.1.el5 */ #define VMWARE_HYPERVISOR_MAGIC 0x564D5868 #define VMWARE_PORT_CMD_GETVERSION 10 static inline int vmware_platform32xin(void) { uint32_t eax, ebx, ecx, edx; ebx = UINT_MAX; VMWARE_PORT32xin(GETVERSION, eax, ebx, ecx, edx); if ( debug ) { fprintf(stderr, "hvm_fep_inl_test: ver32xin ax=%08x?%08x bx=%08x?%08x\n", eax, VMWARE_HYPERVISOR_MAGIC, ebx, UINT_MAX); fprintf(stderr, "hvm_fep_inl_test: ver32xin cx=%08x?%08x dx=%08x?%08x\n", ecx, VMWARE_PORT_CMD_GETVERSION, edx, qemu_port); if ( eax != UINT_MAX && !(eax & 0x80000000) && ebx == VMWARE_HYPERVISOR_MAGIC ) fprintf(stderr, "hvm_fep_inl_test: VmWare32xin Version %d.%d\n", eax, ecx); } return eax != UINT_MAX && !(eax & 0x80000000) && ebx == VMWARE_HYPERVISOR_MAGIC; } int main(int argc, char **argv) { char *version = "$Revision: 1.13 $"; int verLen = strlen(version); int rc; if ( argc > 2 ) { qemu_port = strtol(argv[2], NULL, 0); fprintf(stderr, "hvm_fep_inl_test%.*s: %d qemu_port=0x%x(%d)\n", verLen - 12, version + 10, argc, qemu_port, qemu_port); } if ( argc > 1 ) { debug = strtol(argv[1], NULL, 0); fprintf(stderr, "hvm_fep_inl_test%.*s: %d debug=0x%x(%d)\n", verLen - 12, version + 10, argc, debug, debug); } if ( debug & 0x700000 ) { rc = iopl((debug & 0x700000) >> 20); if ( rc ) fprintf(stderr, "Failed to call iopl(%d) errno=%d(%s)\n", (debug & 0x700000) >> 20, errno, strerror(errno)); else fprintf(stdout, "Call iopl(%d)\n", (debug & 0x700000) >> 20); } if ( debug & 0x80000 ) { int good = vmware_platform32xin(); fprintf(stderr, "hvm_fep_inl_test: vmware_platform32xin() good=%d\n", good); } return 0; } /* * Local variables: * mode: C * c-file-style: "BSD" * c-basic-offset: 4 * indent-tabs-mode: nil * End: */