From: munkyu.im Date: Wed, 19 Sep 2012 13:26:49 +0000 (+0900) Subject: hax: apply hax for Mac X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1438 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1227fdf1c8d7fa7899adc48c93a760a75c4101e1;p=sdk%2Femulator%2Fqemu.git hax: apply hax for Mac add checking hax protocol and hax driver sources --- diff --git a/Makefile.target b/Makefile.target index b19e96effd..14573b62e3 100755 --- a/Makefile.target +++ b/Makefile.target @@ -228,6 +228,11 @@ obj-$(CONFIG_HAX) += \ hax-all.o \ hax-windows.o endif +ifdef CONFIG_DARWIN +obj-$(CONFIG_HAX) += \ + hax-all.o \ + hax-darwin.o +endif endif # Inter-VM PCI shared memory diff --git a/tizen/emulator_configure.sh b/tizen/emulator_configure.sh index da085fcb64..622a00cbde 100755 --- a/tizen/emulator_configure.sh +++ b/tizen/emulator_configure.sh @@ -75,6 +75,7 @@ echo "##### QEMU configure for emulator" --enable-mixemu \ --audio-card-list=ac97 \ --enable-maru \ + --enable-hax \ --disable-vnc \ --disable-sdl \ --disable-gl diff --git a/tizen/src/Makefile b/tizen/src/Makefile index c3e3203b43..e3a13eef58 100755 --- a/tizen/src/Makefile +++ b/tizen/src/Makefile @@ -12,6 +12,7 @@ all: qemu skin_client qemu: build_info ffmpeg_install check_hax cd ../../ && $(MAKE) + qemu_clean: cd ../../ && $(MAKE) clean qemu_distclean: @@ -19,11 +20,11 @@ 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 @@ -47,8 +48,9 @@ ffmpeg_distclean: 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 @@ -61,8 +63,9 @@ install: all 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 diff --git a/tizen/src/Makefile.tizen b/tizen/src/Makefile.tizen index 42e129f3e6..d4596c91d7 100755 --- a/tizen/src/Makefile.tizen +++ b/tizen/src/Makefile.tizen @@ -9,6 +9,9 @@ QEMU_CFLAGS += -I$(SRC_PATH)/tizen/distrib/libav/$(ARCH)/include QEMU_CFLAGS += -L$(SRC_PATH)/tizen/distrib/libav/$(ARCH)/lib QEMU_CFLAGS += $(SDL_CFLAGS) QEMU_CFLAGS += $(GLIB_CFLAGS) +ifdef CONFIG_DARWIN +QEMU_CFLAGS += -framework Foundation -framework SystemConfiguration +endif CFLAGS += -g -O2 ifdef CONFIG_WIN32 diff --git a/tizen/src/check_hax.c b/tizen/src/check_hax.c index 2ca1de30ce..3c87b742c3 100644 --- a/tizen/src/check_hax.c +++ b/tizen/src/check_hax.c @@ -27,14 +27,28 @@ * */ -#include #include + +#ifdef _WIN32 +#include #include #include #include +#endif + +#ifdef __APPLE__ +#include +#include +#include +#include +#include +#include +#include +#include +#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 @@ -44,7 +58,16 @@ #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; @@ -73,10 +96,18 @@ struct hax_capabilityinfo { 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 ); @@ -105,19 +136,7 @@ static int check_hax( void ) { 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; @@ -140,6 +159,33 @@ 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; +} +#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; @@ -166,7 +212,7 @@ static int hax_get_capability( struct hax_state *hax ) { */ 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 @@ -190,6 +236,23 @@ static int hax_capability( struct hax_state *hax, struct hax_capabilityinfo *cap 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();