qemu: build_info ffmpeg_install check_hax
cd ../../ && $(MAKE)
+
qemu_clean:
cd ../../ && $(MAKE) clean
qemu_distclean:
check_hax:
ifdef CONFIG_WIN32
- $(CC) -o check-hax.exe check_hax.c
-else
-
+ $(CC) -o check-hax.exe check_hax.c
+endif
+ifdef CONFIG_DARWIN
+ $(CC) -o check-hax check_hax.c
endif
-
skin_client:
ant -buildfile skin/client/build.xml make-jar
clean: ffmpeg_clean qemu_clean
ifdef CONFIG_WIN32
rm -f check-hax.exe
-else
-
+endif
+ifdef CONFIG_DARWIN
+ rm -f check-hax
endif
distclean: ffmpeg_distclean qemu_distclean
cp skin/client/emulator-skin.jar $(EMUL_DIR)/bin
ifdef CONFIG_WIN32
cp check-hax.exe $(EMUL_DIR)/bin
-else
-
+endif
+ifdef CONFIG_DARWIN
+ cp check-hax $(EMUL_DIR)/bin
endif
ifndef CONFIG_DARWIN
*
*/
-#include <stdint.h>
#include <stdio.h>
+
+#ifdef _WIN32
+#include <stdint.h>
#include <errno.h>
#include <windows.h>
#include <winioctl.h>
+#endif
+
+#ifdef __APPLE__
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#endif
+
+
-#define HAX_DEVICE_TYPE 0x4000
-#define HAX_IOCTL_CAPABILITY CTL_CODE(HAX_DEVICE_TYPE, 0x910, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_MAX_VCPU 0x10
#define HAX_CAP_STATUS_NOTWORKING 0x0
#define HAX_CAP_MEMQUOTA 0x2
+#ifdef __APPLE__
+#define HAX_IOCTL_CAPABILITY _IOR(0, 0x23, struct hax_capabilityinfo)
+typedef int hax_fd;
+#endif
+
+#ifdef _WIN32
+#define HAX_DEVICE_TYPE 0x4000
+#define HAX_IOCTL_CAPABILITY CTL_CODE(HAX_DEVICE_TYPE, 0x910, METHOD_BUFFERED, FILE_ANY_ACCESS)
typedef HANDLE hax_fd;
+#endif
struct hax_vm {
hax_fd fd;
uint32_t pad;
uint64_t mem_quota;
};
-
+#ifdef _WIN32
static inline int hax_invalid_fd( hax_fd fd ) {
return ( fd == INVALID_HANDLE_VALUE );
}
+#endif
+#ifdef __APPLE__
+static inline int hax_invalid_fd(hax_fd fd)
+{
+ return fd <= 0;
+}
+#endif
+
static hax_fd hax_mod_open( void );
static int hax_open_device( hax_fd *fd );
return 0;
}
-
-static hax_fd hax_mod_open( void ) {
- int ret;
- hax_fd fd;
-
- ret = hax_open_device( &fd );
- if ( ret != 0 ) {
- fprintf( stderr, "Open HAX device failed\n" );
- }
-
- return fd;
-}
-
+#ifdef _WIN32
static int hax_open_device( hax_fd *fd ) {
uint32_t errNum = 0;
HANDLE hDevice;
return 0;
}
+static hax_fd hax_mod_open( void ) {
+ int ret;
+ hax_fd fd;
+
+ ret = hax_open_device( &fd );
+ if ( ret != 0 ) {
+ fprintf( stderr, "Open HAX device failed\n" );
+ }
+
+ return fd;
+}
+#else
+static hax_fd hax_mod_open(void)
+{
+ int fd = open("/dev/HAX", O_RDWR);
+
+ if (fd == -1)
+ {
+ fprintf(stderr, "hahFailed to open the hax module\n");
+ //return -errno;
+ }
+
+ return fd;
+}
+
+#endif
+
static int hax_get_capability( struct hax_state *hax ) {
int ret;
struct hax_capabilityinfo capinfo, *cap = &capinfo;
*/
return 0;
}
-
+#ifdef _WIN32
static int hax_capability( struct hax_state *hax, struct hax_capabilityinfo *cap ) {
int ret;
HANDLE hDevice = hax->fd; //handle to hax module
return 0;
}
+#endif
+
+#ifdef __APPLE__
+int hax_capability(struct hax_state *hax, struct hax_capabilityinfo *cap)
+{
+ int ret;
+
+ ret = ioctl(hax->fd, HAX_IOCTL_CAPABILITY, cap);
+ if (ret == -1)
+ {
+ fprintf(stderr, "Failed to get HAX capability\n");
+ return -errno;
+ }
+
+ return 0;
+}
+#endif
int main(int argc, char* argv[]) {
return check_hax();