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