xref: /xnu-8796.141.3/tools/tests/testkext/testvmx.cpp (revision 1b191cb58250d0705d8a51287127505aa4bc0789)
1*1b191cb5SApple OSS Distributions /*
2*1b191cb5SApple OSS Distributions  *  testvmx.cpp
3*1b191cb5SApple OSS Distributions  *  testkext
4*1b191cb5SApple OSS Distributions  *
5*1b191cb5SApple OSS Distributions  */
6*1b191cb5SApple OSS Distributions 
7*1b191cb5SApple OSS Distributions #include "testvmx.h"
8*1b191cb5SApple OSS Distributions 
9*1b191cb5SApple OSS Distributions #if !(defined(__i386__) || defined(__x86_64__))
10*1b191cb5SApple OSS Distributions #error VMX only supported on i386/x86_64
11*1b191cb5SApple OSS Distributions #endif
12*1b191cb5SApple OSS Distributions 
13*1b191cb5SApple OSS Distributions #include <mach/boolean.h>
14*1b191cb5SApple OSS Distributions #include <i386/vmx.h>
15*1b191cb5SApple OSS Distributions 
16*1b191cb5SApple OSS Distributions 
17*1b191cb5SApple OSS Distributions #define super IOService
18*1b191cb5SApple OSS Distributions OSDefineMetaClassAndStructors(testvmx, super);
19*1b191cb5SApple OSS Distributions 
20*1b191cb5SApple OSS Distributions bool
start(IOService * provider)21*1b191cb5SApple OSS Distributions testvmx::start( IOService * provider )
22*1b191cb5SApple OSS Distributions {
23*1b191cb5SApple OSS Distributions 	int ret;
24*1b191cb5SApple OSS Distributions 
25*1b191cb5SApple OSS Distributions 	IOLog("%s\n", __PRETTY_FUNCTION__);
26*1b191cb5SApple OSS Distributions 
27*1b191cb5SApple OSS Distributions 	if (!super::start(provider)) {
28*1b191cb5SApple OSS Distributions 		return false;
29*1b191cb5SApple OSS Distributions 	}
30*1b191cb5SApple OSS Distributions 
31*1b191cb5SApple OSS Distributions 	IOLog("Attempting host_vmxon\n");
32*1b191cb5SApple OSS Distributions 	ret = host_vmxon(FALSE);
33*1b191cb5SApple OSS Distributions 	IOLog("host_vmxon: %d\n", ret);
34*1b191cb5SApple OSS Distributions 
35*1b191cb5SApple OSS Distributions 	return true;
36*1b191cb5SApple OSS Distributions }
37*1b191cb5SApple OSS Distributions 
38*1b191cb5SApple OSS Distributions void
stop(IOService * provider)39*1b191cb5SApple OSS Distributions testvmx::stop( IOService * provider )
40*1b191cb5SApple OSS Distributions {
41*1b191cb5SApple OSS Distributions 	IOLog("%s\n", __PRETTY_FUNCTION__);
42*1b191cb5SApple OSS Distributions 
43*1b191cb5SApple OSS Distributions 	super::stop(provider);
44*1b191cb5SApple OSS Distributions 
45*1b191cb5SApple OSS Distributions 	IOLog("Attempting host_vmxoff\n");
46*1b191cb5SApple OSS Distributions 	host_vmxoff();
47*1b191cb5SApple OSS Distributions 	IOLog("host_vmxoff called\n");
48*1b191cb5SApple OSS Distributions }
49