[Title]apply multi emulator instance (for windows)
authormunkyu.im <munkyu.im@samsung.com>
Thu, 15 Dec 2011 10:02:20 +0000 (19:02 +0900)
committermunkyu.im <munkyu.im@samsung.com>
Thu, 15 Dec 2011 10:02:20 +0000 (19:02 +0900)
[Type]Enhancement
[Module]
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/src/emul_debug.bat [new file with mode: 0644]
tizen/src/emul_debug.sh
tizen/src/emulator.c
tizen/src/emulsignal.c
tizen/src/vtm.c

diff --git a/tizen/src/emul_debug.bat b/tizen/src/emul_debug.bat
new file mode 100644 (file)
index 0000000..c26d461
--- /dev/null
@@ -0,0 +1 @@
+gdb --args emulator-x86.exe --vtm default -- -net nic,model=virtio -usb -usbdevice wacom-tablet -vga tizen -bios bios.bin -L ..\x86\data\pc-bios -kernel ..\x86\data\kernel-img\bzImage -usbdevice keyboard -rtc base=utc -net user -redir tcp:1202:10.0.2.16:22
index dee8959..6d621ef 100755 (executable)
@@ -1,5 +1,4 @@
 #!/bin/sh
 CURDIR=`pwd`
-
-$CURDIR/emulator-x86 --vtm default \
+gdb --args $CURDIR/emulator-x86 --vtm default \
  -- -net nic,model=virtio -usb -usbdevice wacom-tablet -vga tizen -bios bios.bin -L $CURDIR/../x86/data/pc-bios -kernel $CURDIR/../x86/data/kernel-img/bzImage -usbdevice keyboard -rtc base=utc -net user --enable-kvm -redir tcp:1202:10.0.2.16:22
index 5d084a1..1a00e5f 100755 (executable)
@@ -66,7 +66,9 @@
 #include <pthread.h>
 #ifndef _WIN32
 #include <sys/ipc.h>  
-#include <sys/shm.h> 
+#include <sys/shm.h>
+#else
+#include <windows.h>
 #endif
 
 #include "opengl_server.h"
@@ -888,6 +890,42 @@ int init_shdmem()
 
        //      shmctl(shmid, IPC_RMID, 0);
        //      shmdt(shared_memory);
+#else
+       tizen_base_port = get_sdb_base_port();
+       HANDLE hMapFile;
+       char* pBuf;
+       char* port_in_use;
+       char *shared_memory;
+       shared_memory = g_strdup_printf("%s", startup_option.vtm);
+       port_in_use =  g_strdup_printf("%d", tizen_base_port);
+    hMapFile = CreateFileMapping(
+                 INVALID_HANDLE_VALUE,    // use paging file
+                 NULL,                    // default security
+                 PAGE_READWRITE,          // read/write access
+                 0,                       // maximum object size (high-order DWORD)
+                 50,                // maximum object size (low-order DWORD)
+                 port_in_use);                 // name of mapping object
+    if (hMapFile == NULL)
+    {
+               ERR("Could not create file mapping object (%d).\n", GetLastError());
+               return -1;
+    }
+    pBuf = MapViewOfFile(hMapFile,   // handle to map object
+                        FILE_MAP_ALL_ACCESS, // read/write permission
+                        0,
+                        0,
+                        50);
+
+    if (pBuf == NULL)
+    {
+               ERR("Could not map view of file (%d).\n", GetLastError());
+               CloseHandle(hMapFile);
+               return -1;
+    }
+       
+       CopyMemory((PVOID)pBuf, shared_memory, strlen(shared_memory));
+       free(port_in_use);
+       free(shared_memory);
 #endif
        return 0;
 }
index 3df7ab9..393cf11 100644 (file)
@@ -120,6 +120,12 @@ void destroy_emulator(void)
                ERR( "fail to remove shared memory\n");
        else
                INFO( "succedd to remove shared memory\n");
+#else
+       char *port_in_use;
+       port_in_use = g_strdup_printf("%d", tizen_base_port);
+       HANDLE hMapFile = OpenFileMapping(FILE_MAP_READ, TRUE, port_in_use);
+       if(hMapFile)
+               CloseHandle(hMapFile);
 #endif
        return;
 }
index 6e83984..f5b6463 100644 (file)
@@ -371,6 +371,76 @@ int check_shdmem(char *target_name, int type)
                }
        }
 
+#else /* _WIN32*/
+       u_int port;
+       char* base_port = NULL;
+       char* pBuf;
+       HANDLE hMapFile;
+       for(port=26100;port < 26200; port += 10)
+       {
+               base_port = g_strdup_printf("%d", port);
+               hMapFile = OpenFileMapping(
+                 FILE_MAP_READ,
+                                TRUE,
+                 base_port);          
+               if(hMapFile == NULL)
+               {
+                       INFO("port %s is not used.\n", base_port);
+                       continue;
+               }
+               else
+               {
+                        pBuf = (char*)MapViewOfFile(hMapFile,
+                        FILE_MAP_READ,
+                        0,
+                        0,
+                        50);
+                       if (pBuf == NULL)
+                       {
+                               ERR("Could not map view of file (%d).\n", GetLastError());
+                               CloseHandle(hMapFile);
+                               return -1;
+                       }
+
+                       if(strcmp(pBuf, target_name) == 0)
+                       {
+                               if(check_port_bind_listen(port+1) > 0)
+                               {
+                                       UnmapViewOfFile(pBuf);
+                                       CloseHandle(hMapFile);
+                                       continue;
+                               }
+                               
+                               switch(type)
+                               {
+                               case CREATE_MODE:
+                                       show_message("Warning", "Can not activate this target!\nVirtual target with the same name is running now!");
+                                       break;
+                               case DELETE_MODE:
+                                       show_message("Warning", "Can not delete this target!\nVirtual target with the same name is running now!");
+                                       break;
+                               case MODIFY_MODE:
+                                       show_message("Warning", "Can not modify this target!\nVirtual target with the same name is running now!");
+                                       break;
+                               case RESET_MODE:
+                                       show_message("Warning", "Can not reset this target!\nVirtual target with the same name is running now!");
+                                       break;
+                               default:
+                                       ERR("wrong type passed\n");
+                               }
+                               
+                               UnmapViewOfFile(pBuf);
+                               CloseHandle(hMapFile);
+                               free(base_port);
+                               return -1;
+                       }
+                       else
+                               UnmapViewOfFile(pBuf);
+               }
+
+               CloseHandle(hMapFile);
+               free(base_port);
+       }
 #endif
        return 0;