hax: apply hax for Mac
authormunkyu.im <munkyu.im@samsung.com>
Wed, 19 Sep 2012 13:26:49 +0000 (22:26 +0900)
committermunkyu.im <munkyu.im@samsung.com>
Wed, 19 Sep 2012 13:26:49 +0000 (22:26 +0900)
add checking hax protocol and hax driver sources

Makefile.target
tizen/emulator_configure.sh
tizen/src/Makefile
tizen/src/Makefile.tizen
tizen/src/check_hax.c

index b19e96effd84ebca9e71e08e1204093186f2d94a..14573b62e3b93553ea36e33dd07039ae2652c552 100755 (executable)
@@ -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
index da085fcb64b00d82df35b39bf6258cac3046a00a..622a00cbde09107f0cdc84cfffbf2c94cd387fb9 100755 (executable)
@@ -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
index c3e3203b439f342263178952dfd826f34fe203f6..e3a13eef58e6abed3fa445b8ba3c7d4d2fc6e994 100755 (executable)
@@ -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
index 42e129f3e6c7520ae53257e9033ad4f81f270071..d4596c91d72a2e3441abbde1f03230b51eefee63 100755 (executable)
@@ -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
index 2ca1de30ce5ca5d0096e0ccecd93c4b3acfe848e..3c87b742c3ba7cb364e247876ca763cb6e6c2120 100644 (file)
  *
  */
 
-#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;
@@ -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();