diff options
author | Evgeny Voevodin <e.voevodin@samsung.com> | 2012-10-08 12:51:19 +0400 |
---|---|---|
committer | Evgeny Voevodin <e.voevodin@samsung.com> | 2012-10-08 12:52:30 +0400 |
commit | 13e8ce69ba370140c8f9d925f7824af4bd4e7e9c (patch) | |
tree | cac46659d727fecd80bc482c644760e8e29f5165 | |
parent | 38cf5ee1b5a34c883f565f09b9c0a641e7dbd375 (diff) | |
parent | 631384da4211a4a47a5ac8eeb38daf41d98e4db1 (diff) | |
download | qemu-13e8ce69ba370140c8f9d925f7824af4bd4e7e9c.tar.gz qemu-13e8ce69ba370140c8f9d925f7824af4bd4e7e9c.tar.bz2 qemu-13e8ce69ba370140c8f9d925f7824af4bd4e7e9c.zip |
Merge remote-tracking branch 'score/develop' into tizen-arm
28 files changed, 985 insertions, 181 deletions
diff --git a/Makefile.target b/Makefile.target index 8f52874d31..03d1bfe9a0 100755 --- a/Makefile.target +++ b/Makefile.target @@ -210,6 +210,11 @@ obj-i386-$(CONFIG_XEN) += xen_platform.o xen_apic.o # HAX support obj-$(CONFIG_HAX) += hax-all.o hax-windows.o obj-$(CONFIG_NO_HAX) += hax-stub.o +ifdef CONFIG_DARWIN +obj-$(CONFIG_HAX) += \ + hax-all.o \ + hax-darwin.o +endif # Inter-VM PCI shared memory CONFIG_IVSHMEM = diff --git a/audio/winwaveaudio.c b/audio/winwaveaudio.c index 3d6f8f70a4..72babbf184 100644 --- a/audio/winwaveaudio.c +++ b/audio/winwaveaudio.c @@ -72,7 +72,7 @@ static void winwave_log_mmresult (MMRESULT mr) break; case MMSYSERR_NOMEM: - str = "Unable to allocate or locl memory"; + str = "Unable to allocate or lock memory"; break; case WAVERR_SYNC: @@ -349,33 +349,16 @@ static int winwave_ctl_out (HWVoiceOut *hw, int cmd, ...) else { hw->poll_mode = 0; } -#if defined(CONFIG_MARU) - wave->paused = 0; -#else - if (wave->paused) { - mr = waveOutRestart (wave->hwo); - if (mr != MMSYSERR_NOERROR) { - winwave_logerr (mr, "waveOutRestart"); - } - wave->paused = 0; - } -#endif + wave->paused = 0; } return 0; case VOICE_DISABLE: if (!wave->paused) { -#if defined(CONFIG_MARU) - mr = waveOutReset (wave->hwo); + mr = waveOutReset (wave->hwo); if (mr != MMSYSERR_NOERROR) { winwave_logerr (mr, "waveOutReset"); } -#else - mr = waveOutPause (wave->hwo); - if (mr != MMSYSERR_NOERROR) { - winwave_logerr (mr, "waveOutPause"); - } -#endif else { wave->paused = 1; } @@ -195,7 +195,7 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state) /* if mouse event is wheelup ,wheeldown or move then go to ps2 mouse event(index == 0) */ if((buttons_state > 3 && entry->index == 0)) { - INFO("input device: %s, event: %d\n", entry->qemu_put_mouse_event_name, buttons_state); + //INFO("input device: %s, event: %d\n", entry->qemu_put_mouse_event_name, buttons_state); buttons_state = 0; mouse_event = entry->qemu_put_mouse_event; mouse_event_opaque = entry->qemu_put_mouse_event_opaque; @@ -207,7 +207,7 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state) entry = QTAILQ_FIRST(&mouse_handlers); mouse_event = entry->qemu_put_mouse_event; mouse_event_opaque = entry->qemu_put_mouse_event_opaque; - INFO("input device: %s, event: %d\n", entry->qemu_put_mouse_event_name, buttons_state); + //INFO("input device: %s, event: %d\n", entry->qemu_put_mouse_event_name, buttons_state); } #else entry = QTAILQ_FIRST(&mouse_handlers); diff --git a/target-i386/hax-darwin.c b/target-i386/hax-darwin.c new file mode 100644 index 0000000000..c083034ac6 --- /dev/null +++ b/target-i386/hax-darwin.c @@ -0,0 +1,301 @@ +/* HAX module interface - darwin version */ +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> +#include <sys/ioctl.h> + +#include "target-i386/hax-i386.h" + +static char* qemu_strdup(const char *str) +{ + char *ptr; + size_t len = strlen(str); + ptr = qemu_vmalloc(len + 1); + memcpy(ptr, str, len+1); + return ptr; +} + + +hax_fd hax_mod_open(void) +{ + int fd = open("/dev/HAX", O_RDWR); + + if (fd == -1) + { + dprint("hahFailed to open the hax module\n"); + //return -errno; + } + + return fd; +} + +int hax_populate_ram(uint64_t va, uint32_t size) +{ + int ret; + struct hax_alloc_ram_info info; + + if (!hax_global.vm || !hax_global.vm->fd) + { + dprint("Allocate memory before vm create?\n"); + return -EINVAL; + } + + info.size = size; + info.va = va; + ret = ioctl(hax_global.vm->fd, HAX_VM_IOCTL_ALLOC_RAM, &info); + if (ret < 0) + { + dprint("Failed to allocate %x memory\n", size); + return ret; + } + return 0; +} + +int hax_set_phys_mem(target_phys_addr_t start_addr, ram_addr_t size, ram_addr_t phys_offset) +{ + struct hax_set_ram_info info, *pinfo = &info; + int ret; + ram_addr_t flags = phys_offset & ~TARGET_PAGE_MASK; + + /* We only care for the RAM and ROM */ + if (flags >= IO_MEM_UNASSIGNED) + return 0; + + if ( (start_addr & ~TARGET_PAGE_MASK) || (size & ~TARGET_PAGE_MASK)) + { + dprint("set_phys_mem %x %lx requires page aligned addr and size\n", start_addr, size); + exit(1); + return -1; + } + + info.pa_start = start_addr; + info.size = size; + info.va = (uint64_t)qemu_get_ram_ptr(phys_offset); + info.flags = (flags & IO_MEM_ROM) ? 1 : 0; + + ret = ioctl(hax_global.vm->fd, HAX_VM_IOCTL_SET_RAM, pinfo); + if (ret < 0) + { + dprint("has set phys mem failed\n"); + exit(1); + } + return ret; +} + +int hax_capability(struct hax_state *hax, struct hax_capabilityinfo *cap) +{ + int ret; + + ret = ioctl(hax->fd, HAX_IOCTL_CAPABILITY, cap); + if (ret == -1) + { + dprint("Failed to get HAX capability\n"); + return -errno; + } + + return 0; +} + +int hax_mod_version(struct hax_state *hax, struct hax_module_version *version) +{ + int ret; + + ret = ioctl(hax->fd, HAX_IOCTL_VERSION, version); + if (ret == -1) + { + dprint("Failed to get HAX version\n"); + return -errno; + } + + return 0; +} + +static char *hax_vm_devfs_string(int vm_id) +{ + char *name; + + if (vm_id > MAX_VM_ID) + { + dprint("Too big VM id\n"); + return NULL; + } + + name = qemu_strdup("/dev/hax_vm/vmxx"); + if (!name) + return NULL; + sprintf(name, "/dev/hax_vm/vm%02d", vm_id); + + return name; +} + +static char *hax_vcpu_devfs_string(int vm_id, int vcpu_id) +{ + char *name; + + if (vm_id > MAX_VM_ID || vcpu_id > MAX_VCPU_ID) + { + dprint("Too big vm id %x or vcpu id %x\n", vm_id, vcpu_id); + return NULL; + } + + name = qemu_strdup("/dev/hax_vmxx/vcpuxx"); + if (!name) + return NULL; + + sprintf(name, "/dev/hax_vm%02d/vcpu%02d", vm_id, vcpu_id); + + return name; +} + +int hax_host_create_vm(struct hax_state *hax, int *vmid) +{ + int ret; + int vm_id = 0; + + if (hax_invalid_fd(hax->fd)) + return -EINVAL; + + if (hax->vm) + return 0; + + ret = ioctl(hax->fd, HAX_IOCTL_CREATE_VM, &vm_id); + *vmid = vm_id; + return ret; +} + +hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id) +{ + hax_fd fd; + char *vm_name = NULL; + + vm_name = hax_vm_devfs_string(vm_id); + if (!vm_name) + return -1; + + fd = open(vm_name, O_RDWR); + qemu_vfree(vm_name); + + return fd; +} + +/* Simply assume the size should be bigger than the hax_tunnel, + * since the hax_tunnel can be extended later with compatibility considered + */ +int hax_host_create_vcpu(hax_fd vm_fd, int vcpuid) +{ + int ret; + + ret = ioctl(vm_fd, HAX_VM_IOCTL_VCPU_CREATE, &vcpuid); + if (ret < 0) + dprint("Failed to create vcpu %x\n", vcpuid); + + return ret; +} + +hax_fd hax_host_open_vcpu(int vmid, int vcpuid) +{ + char *devfs_path = NULL; + hax_fd fd; + + devfs_path = hax_vcpu_devfs_string(vmid, vcpuid); + if (!devfs_path) + { + dprint("Failed to get the devfs\n"); + return -EINVAL; + } + + fd = open(devfs_path, O_RDWR); + qemu_vfree(devfs_path); + if (fd < 0) + dprint("Failed to open the vcpu devfs\n"); + return fd; +} + +int hax_host_setup_vcpu_channel(struct hax_vcpu_state *vcpu) +{ + int ret; + struct hax_tunnel_info info; + + ret = ioctl(vcpu->fd, HAX_VCPU_IOCTL_SETUP_TUNNEL, &info); + if (ret) + { + dprint("Failed to setup the hax tunnel\n"); + return ret; + } + + if (!valid_hax_tunnel_size(info.size)) + { + dprint("Invalid hax tunnel size %x\n", info.size); + ret = -EINVAL; + return ret; + } + + vcpu->tunnel = (struct hax_tunnel *)(info.va); + vcpu->iobuf = (unsigned char *)(info.io_va); + return 0; +} + +int hax_vcpu_run(struct hax_vcpu_state* vcpu) +{ + int ret; + + ret = ioctl(vcpu->fd, HAX_VCPU_IOCTL_RUN, NULL); + return ret; +} + +int hax_sync_fpu(CPUState *env, struct fx_layout *fl, int set) +{ + int ret, fd; + + fd = hax_vcpu_get_fd(env); + if (fd <= 0) + return -1; + + if (set) + ret = ioctl(fd, HAX_VCPU_IOCTL_SET_FPU, fl); + else + ret = ioctl(fd, HAX_VCPU_IOCTL_GET_FPU, fl); + return ret; +} + +int hax_sync_msr(CPUState *env, struct hax_msr_data *msrs, int set) +{ + int ret, fd; + + fd = hax_vcpu_get_fd(env); + if (fd <= 0) + return -1; + if (set) + ret = ioctl(fd, HAX_VCPU_IOCTL_SET_MSRS, msrs); + else + ret = ioctl(fd, HAX_VCPU_IOCTL_GET_MSRS, msrs); + return ret; +} + +int hax_sync_vcpu_state(CPUState *env, struct vcpu_state_t *state, int set) +{ + int ret, fd; + + fd = hax_vcpu_get_fd(env); + if (fd <= 0) + return -1; + + if (set) + ret = ioctl(fd, HAX_VCPU_SET_REGS, state); + else + ret = ioctl(fd, HAX_VCPU_GET_REGS, state); + return ret; +} + +int hax_inject_interrupt(CPUState *env, int vector) +{ + int ret, fd; + + fd = hax_vcpu_get_fd(env); + if (fd <= 0) + return -1; + + ret = ioctl(fd, HAX_VCPU_IOCTL_INTERRUPT, &vector); + return ret; +} diff --git a/target-i386/hax-darwin.h b/target-i386/hax-darwin.h new file mode 100644 index 0000000000..594a616289 --- /dev/null +++ b/target-i386/hax-darwin.h @@ -0,0 +1,48 @@ +#ifndef __HAX_UNIX_H +#define __HAX_UNIX_H + +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/mman.h> +#include <stdarg.h> + +#define HAX_INVALID_FD (-1) +static inline int hax_invalid_fd(hax_fd fd) +{ + return fd <= 0; +} + +static inline void hax_mod_close(struct hax_state *hax) +{ + close(hax->fd); +} + +static inline void hax_close_fd(hax_fd fd) +{ + close(fd); +} + +/* HAX model level ioctl */ +#define HAX_IOCTL_VERSION _IOWR(0, 0x20, struct hax_module_version) +#define HAX_IOCTL_CREATE_VM _IOWR(0, 0x21, int) +#define HAX_IOCTL_DESTROY_VM _IOW(0, 0x22, int) +#define HAX_IOCTL_CAPABILITY _IOR(0, 0x23, struct hax_capabilityinfo) + +#define HAX_VM_IOCTL_VCPU_CREATE _IOR(0, 0x80, int) +#define HAX_VM_IOCTL_ALLOC_RAM _IOWR(0, 0x81, struct hax_alloc_ram_info) +#define HAX_VM_IOCTL_SET_RAM _IOWR(0, 0x82, struct hax_set_ram_info) +#define HAX_VM_IOCTL_VCPU_DESTROY _IOR(0, 0x83, int) + +#define HAX_VCPU_IOCTL_RUN _IO(0, 0xc0) +#define HAX_VCPU_IOCTL_SET_MSRS _IOWR(0, 0xc1, struct hax_msr_data) +#define HAX_VCPU_IOCTL_GET_MSRS _IOWR(0, 0xc2, struct hax_msr_data) + +#define HAX_VCPU_IOCTL_SET_FPU _IOW(0, 0xc3, struct fx_layout) +#define HAX_VCPU_IOCTL_GET_FPU _IOR(0, 0xc4, struct fx_layout) + +#define HAX_VCPU_IOCTL_SETUP_TUNNEL _IOWR(0, 0xc5, struct hax_tunnel_info) +#define HAX_VCPU_IOCTL_INTERRUPT _IOWR(0, 0xc6, uint32_t) +#define HAX_VCPU_SET_REGS _IOWR(0, 0xc7, struct vcpu_state_t) +#define HAX_VCPU_GET_REGS _IOWR(0, 0xc8, struct vcpu_state_t) + +#endif /* __HAX_UNIX_H */ diff --git a/tizen/emulator_configure.sh b/tizen/emulator_configure.sh index 0692357c45..a98eabd83a 100755 --- a/tizen/emulator_configure.sh +++ b/tizen/emulator_configure.sh @@ -69,6 +69,7 @@ echo "##### QEMU configure for emulator" --enable-mixemu \ --audio-card-list=ac97 \ --enable-maru \ + --enable-hax \ --disable-vnc \ --disable-sdl $1 ;; diff --git a/tizen/src/Makefile b/tizen/src/Makefile index 23d4c69512..7bbc5a7c32 100755 --- a/tizen/src/Makefile +++ b/tizen/src/Makefile @@ -19,7 +19,6 @@ endif endif all: qemu skin_client - qemu: build_info ffmpeg_install check_hax cd ../../ && $(MAKE) qemu_clean: @@ -28,12 +27,13 @@ qemu_distclean: cd ../../ && $(MAKE) distclean check_hax: + @echo "build 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 @@ -57,8 +57,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 @@ -117,8 +118,15 @@ endif cp skin/client/emulator-skin.jar $(EMUL_DIR)/bin ifdef CONFIG_WIN32 cp check-hax.exe $(EMUL_DIR)/bin +endif +ifdef CONFIG_DARWIN + cp check-hax $(EMUL_DIR)/bin +endif +ifdef CONFIG_LINUX + cp -pPr ../distrib/initscript/tizen-kvm $(EMUL_DIR)/etc + cp -pPr ../distrib/initscript/45-tizen-kvm.rules $(EMUL_DIR)/etc else - + endif ifndef CONFIG_DARWIN @@ -131,6 +139,7 @@ else cp -pPR ../license $(EMUL_DIR) cp skin/client/lib/swt.jar $(EMUL_DIR)/bin/swt.jar cp -pPR skin/client/skins $(EMUL_DIR) + cp -pPR skin/client/native_src/libshared.dylib $(EMUL_DIR)/bin endif # for dibs system... @@ -196,15 +205,21 @@ ifdef CONFIG_WIN32 else endif +ifdef CONFIG_LINUX + echo "Copying tizen-kvm to $(EMUL_DIR)/etc" + cp -pPr ../distrib/initscript/tizen-kvm $(EMUL_DIR)/etc + cp -pPr ../distrib/initscript/45-tizen-kvm.rules $(EMUL_DIR)/etc +else + +endif ifndef CONFIG_DARWIN cp ../../qemu-img $(EMUL_DIR)/bin cp -dpr ../license $(EMUL_DIR) - cp skin/client/lib/swt.jar $(EMUL_DIR)/bin/swt.jar cp -dpr skin/client/skins $(EMUL_DIR) else cp ../../qemu-img $(EMUL_DIR)/bin cp -pPR ../license $(EMUL_DIR) - cp skin/client/lib/swt.jar $(EMUL_DIR)/bin/swt.jar cp -pPR skin/client/skins $(EMUL_DIR) + cp -pPR skin/client/native_src/libshared.dylib $(EMUL_DIR)/bin endif diff --git a/tizen/src/Makefile.tizen b/tizen/src/Makefile.tizen index 7f00bbee8a..6c69d10a84 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 ifndef CONFIG_DEBUG_EXEC CFLAGS += -g -O2 else 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 <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 @@ -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(); diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index 0de58557c3..6bc4a88579 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -124,12 +124,12 @@ int get_emul_max_touch_point(void) void set_emul_win_scale(double scale_factor) { if (scale_factor < 0.0 || scale_factor > 1.0) { - INFO("scale_factor is out of range = %lf\n", scale_factor); + INFO("scale_factor is out of range = %f\n", scale_factor); scale_factor = 1.0; } _emul_state.scale_factor = scale_factor; - INFO("emulator window scale_factor = %lf\n", _emul_state.scale_factor); + INFO("emulator window scale_factor = %f\n", _emul_state.scale_factor); } double get_emul_win_scale(void) diff --git a/tizen/src/hw/maru_camera_linux_pci.c b/tizen/src/hw/maru_camera_linux_pci.c index 1fa375b014..3fe8118228 100644 --- a/tizen/src/hw/maru_camera_linux_pci.c +++ b/tizen/src/hw/maru_camera_linux_pci.c @@ -257,6 +257,17 @@ static int is_stream_paused(MaruCamState *state) return (st == _MC_THREAD_PAUSED);
}
+static void __raise_err_intr(MaruCamState *state)
+{
+ qemu_mutex_lock(&state->thread_mutex);
+ if (state->streamon == _MC_THREAD_STREAMON) {
+ state->req_frame = 0; /* clear request */
+ state->isr = 0x08; /* set a error flag of rasing a interrupt */
+ qemu_bh_schedule(state->tx_bh);
+ }
+ qemu_mutex_unlock(&state->thread_mutex);
+}
+
static int __v4l2_grab(MaruCamState *state)
{
fd_set fds;
@@ -271,10 +282,11 @@ static int __v4l2_grab(MaruCamState *state) tv.tv_usec = 500000;
ret = select(v4l2_fd + 1, &fds, NULL, NULL, &tv);
- if ( ret < 0) {
- if (errno == EINTR)
+ if (ret < 0) {
+ if (errno == EAGAIN || errno == EINTR)
return 0;
- ERR("select : %s\n", strerror(errno));
+ ERR("failed to select : %s\n", strerror(errno));
+ __raise_err_intr(state);
return -1;
}
if (!ret) {
@@ -283,7 +295,8 @@ static int __v4l2_grab(MaruCamState *state) }
if (!v4l2_fd || (v4l2_fd == -1)) {
- WARN("file descriptor is closed or not opened \n");
+ ERR("file descriptor is closed or not opened \n");
+ __raise_err_intr(state);
return -1;
}
@@ -299,21 +312,22 @@ static int __v4l2_grab(MaruCamState *state) qemu_mutex_unlock(&state->thread_mutex);
ret = v4l2_read(v4l2_fd, buf, state->buf_size);
- if ( ret < 0) {
+ if (ret < 0) {
switch (errno) {
- case EINVAL:
- case ENOMEM:
- ERR("v4l2_read failed : %s\n", strerror(errno));
- return -1;
case EAGAIN:
case EIO:
case EINTR:
- default:
if (convert_trial-- == -1) {
- ERR("Try count for v4l2_read is exceeded\n");
+ ERR("Try count for v4l2_read is exceeded: %s\n",
+ strerror(errno));
+ __raise_err_intr(state);
return -1;
}
return 0;
+ default:
+ ERR("v4l2_read failed : %s\n", strerror(errno));
+ __raise_err_intr(state);
+ return -1;
}
}
@@ -518,14 +532,16 @@ void marucam_device_stop_preview(MaruCamState* state) req.tv_sec = 0;
req.tv_nsec = 50000000;
- qemu_mutex_lock(&state->thread_mutex);
- state->streamon = _MC_THREAD_STREAMOFF;
- state->buf_size = 0;
- qemu_mutex_unlock(&state->thread_mutex);
+ if (is_streamon(state)) {
+ qemu_mutex_lock(&state->thread_mutex);
+ state->streamon = _MC_THREAD_STREAMOFF;
+ state->buf_size = 0;
+ qemu_mutex_unlock(&state->thread_mutex);
- /* nanosleep until thread is paused */
- while (!is_stream_paused(state))
- nanosleep(&req, NULL);
+ /* nanosleep until thread is paused */
+ while (!is_stream_paused(state))
+ nanosleep(&req, NULL);
+ }
INFO("Stopping preview\n");
}
diff --git a/tizen/src/hw/maru_virtio_touchscreen.c b/tizen/src/hw/maru_virtio_touchscreen.c index f79e34e684..1c59b3d0c9 100644 --- a/tizen/src/hw/maru_virtio_touchscreen.c +++ b/tizen/src/hw/maru_virtio_touchscreen.c @@ -31,116 +31,241 @@ #include "console.h" #include "maru_virtio_touchscreen.h" #include "maru_device_ids.h" +#include "mloop_event.h" #include "debug_ch.h" MULTI_DEBUG_CHANNEL(qemu, touchscreen); #define DEVICE_NAME "virtio-touchscreen" -#define MAX_TOUCH_EVENT_CNT 128 - -/* This structure must match the kernel definitions */ -typedef struct EmulTouchEvent { - uint16_t x, y, z; - uint8_t state; -} EmulTouchEvent; +/* + * touch event queue + */ typedef struct TouchEventEntry { - int index; + unsigned int index; EmulTouchEvent touch; QTAILQ_ENTRY(TouchEventEntry) node; } TouchEventEntry; +/* the maximum number of touch event that can be put into a queue */ +#define MAX_TOUCH_EVENT_CNT 64 + static TouchEventEntry _events_buf[MAX_TOUCH_EVENT_CNT]; static QTAILQ_HEAD(, TouchEventEntry) events_queue = QTAILQ_HEAD_INITIALIZER(events_queue); -static unsigned int ringbuf_cnt; // _events_buf -static unsigned int queue_cnt; // events_queue +static unsigned int event_ringbuf_cnt; /* _events_buf */ +static unsigned int event_queue_cnt; /* events_queue */ +/* + * VirtQueueElement queue + */ +typedef struct ElementEntry { + unsigned int index; + unsigned int sg_index; + VirtQueueElement elem; -typedef struct TouchscreenState -{ - VirtIODevice vdev; - VirtQueue *vq; + QTAILQ_ENTRY(ElementEntry) node; +} ElementEntry; - DeviceState *qdev; - QEMUPutMouseEntry *eh_entry; -} TouchscreenState; -TouchscreenState *ts; +static ElementEntry _elem_buf[10]; +static QTAILQ_HEAD(, ElementEntry) elem_queue = + QTAILQ_HEAD_INITIALIZER(elem_queue); + +static unsigned int elem_ringbuf_cnt; +static unsigned int elem_queue_cnt; -// lock for between communication thread and IO thread -//static pthread_mutex_t event_mutex = PTHREAD_MUTEX_INITIALIZER; +TouchscreenState *ts; + +/* lock for between communication thread and IO thread */ +static pthread_mutex_t event_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t elem_mutex = PTHREAD_MUTEX_INITIALIZER; void virtio_touchscreen_event(void *opaque, int x, int y, int z, int buttons_state) { TouchEventEntry *entry = NULL; - TouchscreenState *ts = opaque; - VirtQueueElement elem; - //pthread_mutex_lock(&event_mutex); + if (unlikely(event_queue_cnt >= MAX_TOUCH_EVENT_CNT)) { + INFO("full touch event queue, lose event\n", event_queue_cnt); -#if 0 - if (queue_cnt >= MAX_TOUCH_EVENT_CNT) { - pthread_mutex_unlock(&event_mutex); - INFO("full touch event queue, lose event\n", queue_cnt); + mloop_evcmd_touch(); return; } -#endif - entry = &(_events_buf[ringbuf_cnt % MAX_TOUCH_EVENT_CNT]); - ringbuf_cnt++; + entry = &(_events_buf[event_ringbuf_cnt % MAX_TOUCH_EVENT_CNT]); + event_ringbuf_cnt++; /* mouse event is copied into the queue */ - entry->index = ++queue_cnt; // 1 ~ entry->touch.x = x; entry->touch.y = y; entry->touch.z = z; entry->touch.state = buttons_state; - //QTAILQ_INSERT_TAIL(&events_queue, entry, node); + pthread_mutex_lock(&event_mutex); + + entry->index = ++event_queue_cnt; // 1 ~ - /* virtio */ - virtqueue_pop(ts->vq, &elem); - memcpy(elem.in_sg[0].iov_base, &(entry->touch), sizeof(EmulTouchEvent)); - virtqueue_push(ts->vq, &elem, 0); - virtio_notify(&(ts->vdev), ts->vq); + QTAILQ_INSERT_TAIL(&events_queue, entry, node); - //pthread_mutex_unlock(&event_mutex); + pthread_mutex_unlock(&event_mutex); - INFO("touch event (%d) : x=%d, y=%d, z=%d, state=%d\n", + /* call maru_virtio_touchscreen_notify */ + mloop_evcmd_touch(); + + TRACE("touch event (%d) : x=%d, y=%d, z=%d, state=%d\n", entry->index, entry->touch.x, entry->touch.y, entry->touch.z, entry->touch.state); } static void maru_virtio_touchscreen_handle(VirtIODevice *vdev, VirtQueue *vq) { +#if 0 /* not used yet */ if (ts->eh_entry == NULL) { + void *vbuf = NULL; VirtQueueElement elem; int max_trkid = 0; virtqueue_pop(ts->vq, &elem); - memcpy(&max_trkid, elem.in_sg[0].iov_base, sizeof(int)); + vbuf = elem.in_sg[0].iov_base; + memcpy(&max_trkid, vbuf, sizeof(max_trkid)); if (max_trkid > 0) { INFO("virtio touchscreen's maximum of tracking id = %d\n", max_trkid); /* register a event handler */ - ts->eh_entry = qemu_add_mouse_event_handler(virtio_touchscreen_event, ts, 1, "QEMU Virtio Touchscreen"); + ts->eh_entry = qemu_add_mouse_event_handler( + virtio_touchscreen_event, ts, 1, "QEMU Virtio Touchscreen"); qemu_activate_mouse_event_handler(ts->eh_entry); + //TODO: virtqueue_push(ts->vq, &elem, 0); virtio_notify(&(ts->vdev), ts->vq); } else { INFO("virtio touchscreen is not added to qemu mouse event handler\n"); } } +#endif + + int sg_index = 0; + ElementEntry *elem_entry = NULL; + + if (unlikely(virtio_queue_empty(ts->vq))) { + TRACE("virtqueue is empty\n"); + return; + } + + while (true) { + elem_entry = &(_elem_buf[elem_ringbuf_cnt % 10]); + elem_ringbuf_cnt++; + + sg_index = virtqueue_pop(ts->vq, &elem_entry->elem); + if (sg_index == 0) { + elem_ringbuf_cnt--; + break; + } else if (sg_index < 0) { + ERR("virtqueue is broken\n"); + elem_ringbuf_cnt--; + return; + } + + pthread_mutex_lock(&elem_mutex); + + elem_entry->index = ++elem_queue_cnt; + elem_entry->sg_index = (unsigned int)sg_index; + + /* save VirtQueueElement */ + QTAILQ_INSERT_TAIL(&elem_queue, elem_entry, node); + + if (ts->waitBuf == true) { + ts->waitBuf = false; + mloop_evcmd_touch(); // call maru_virtio_touchscreen_notify + } + + pthread_mutex_unlock(&elem_mutex); + } +} + +void maru_virtio_touchscreen_notify(void) +{ + ElementEntry *elem_entry = NULL; + unsigned int ii = 0; + + TRACE("maru_virtio_touchscreen_notify\n"); + + if (unlikely(!virtio_queue_ready(ts->vq))) { + ERR("virtio queue is not ready\n"); + return; + } + + while (true) { + if (event_queue_cnt == 0) { + TRACE("no event\n"); + break; + } else if (elem_queue_cnt == 0) { + TRACE("no buffer\n"); + + pthread_mutex_lock(&elem_mutex); + /* maybe next time */ + ts->waitBuf = true; + pthread_mutex_unlock(&elem_mutex); + break; + } + + elem_entry = QTAILQ_FIRST(&elem_queue); + + if (elem_entry->sg_index > 0) { + TouchEventEntry *event_entry = NULL; + VirtQueueElement *elem = NULL; + void *vbuf = NULL; + + elem = &elem_entry->elem; + vbuf = elem->in_sg[elem_entry->sg_index - 1].iov_base; + + /* get touch event from host queue */ + event_entry = QTAILQ_FIRST(&events_queue); + + TRACE("touch(%d) : x=%d, y=%d, z=%d, state=%d | \ + event_queue_cnt=%d, elem.index=%d, elem.in_num=%d, sg_index=%d\n", + event_entry->index, event_entry->touch.x, event_entry->touch.y, + event_entry->touch.z, event_entry->touch.state, + event_queue_cnt, elem->index, elem->in_num, elem_entry->sg_index); + /* copy event into virtio buffer */ + memcpy(vbuf, &(event_entry->touch), sizeof(event_entry->touch)); + + pthread_mutex_lock(&event_mutex); + + /* remove host event */ + QTAILQ_REMOVE(&events_queue, event_entry, node); + event_queue_cnt--; + + pthread_mutex_unlock(&event_mutex); + + /* put buffer into virtio queue */ + virtqueue_fill(ts->vq, elem, sizeof(EmulTouchEvent), ii++); + } + + pthread_mutex_lock(&elem_mutex); + + QTAILQ_REMOVE(&elem_queue, elem_entry, node); + elem_queue_cnt--; + + pthread_mutex_unlock(&elem_mutex); + } + + if (ii != 0) { + /* signal other side */ + virtqueue_flush(ts->vq, ii); + /* notify to guest */ + virtio_notify(&(ts->vdev), ts->vq); + } } -static uint32_t virtio_touchscreen_get_features(VirtIODevice *vdev, uint32_t request_features) +static uint32_t virtio_touchscreen_get_features( + VirtIODevice *vdev, uint32_t request_features) { // TODO: return request_features; @@ -159,12 +284,23 @@ VirtIODevice *maru_virtio_touchscreen_init(DeviceState *dev) } ts->vdev.get_features = virtio_touchscreen_get_features; - ts->vq = virtio_add_queue(&ts->vdev, 128, maru_virtio_touchscreen_handle); + ts->vq = virtio_add_queue(&ts->vdev, 64, maru_virtio_touchscreen_handle); ts->qdev = dev; - /* reset the event counter */ - queue_cnt = ringbuf_cnt = 0; + /* reset the counters */ + event_queue_cnt = event_ringbuf_cnt = 0; + elem_queue_cnt = elem_ringbuf_cnt = 0; + + ts->waitBuf = false; + +#if 1 + /* register a event handler */ + ts->eh_entry = qemu_add_mouse_event_handler( + virtio_touchscreen_event, ts, 1, "QEMU Virtio Touchscreen"); + qemu_activate_mouse_event_handler(ts->eh_entry); + INFO("virtio touchscreen is added to qemu mouse event handler\n"); +#endif return &(ts->vdev); } diff --git a/tizen/src/hw/maru_virtio_touchscreen.h b/tizen/src/hw/maru_virtio_touchscreen.h index 3a2c12307a..f54d733c71 100644 --- a/tizen/src/hw/maru_virtio_touchscreen.h +++ b/tizen/src/hw/maru_virtio_touchscreen.h @@ -32,7 +32,26 @@ #include "virtio.h" -void virtio_touchscreen_event(void *opaque, int x, int y, int z, int buttons_state); +typedef struct TouchscreenState +{ + VirtIODevice vdev; + /* simply a queue into which buffers are posted + by the guest for consumption by the host */ + VirtQueue *vq; + bool waitBuf; + + DeviceState *qdev; + QEMUPutMouseEntry *eh_entry; +} TouchscreenState; + +/* This structure must match the kernel definitions */ +typedef struct EmulTouchEvent { + uint16_t x, y, z; + uint8_t state; +} EmulTouchEvent; +void virtio_touchscreen_event(void *opaque, int x, int y, int z, int buttons_state); +void maru_virtio_touchscreen_notify(void); + #endif /* MARU_TOUCHSCREEN_H_ */ diff --git a/tizen/src/mloop_event.c b/tizen/src/mloop_event.c index 3d4570e2b9..aadb33a97b 100644 --- a/tizen/src/mloop_event.c +++ b/tizen/src/mloop_event.c @@ -67,9 +67,11 @@ struct mloop_evpack { #define MLOOP_EVTYPE_USB_DEL 2 #define MLOOP_EVTYPE_INTR_UP 3 #define MLOOP_EVTYPE_INTR_DOWN 4 -#define MLLOP_EVTYPE_HWKEY 5 +#define MLOOP_EVTYPE_HWKEY 5 +#define MLOOP_EVTYPE_TOUCH 6 -static struct mloop_evsock mloop = {-1,0,0}; + +static struct mloop_evsock mloop = {-1, 0, 0}; static int mloop_evsock_create(struct mloop_evsock *ev) { @@ -241,8 +243,8 @@ static void mloop_evhandle_intr_down(long data) static void mloop_evhandle_hwkey(struct mloop_evpack* pack) { - int event_type; - int keycode; + int event_type = 0; + int keycode = 0; memcpy(&event_type, pack->data, sizeof(int)); memcpy(&keycode, pack->data + sizeof(int), sizeof(int)); @@ -260,6 +262,11 @@ static void mloop_evhandle_hwkey(struct mloop_evpack* pack) } } +static void mloop_evhandle_touch(struct mloop_evpack* pack) +{ + maru_virtio_touchscreen_notify(); +} + static void mloop_evcb_recv(struct mloop_evsock *ev) { struct mloop_evpack pack; @@ -297,9 +304,12 @@ static void mloop_evcb_recv(struct mloop_evsock *ev) case MLOOP_EVTYPE_INTR_DOWN: mloop_evhandle_intr_down(ntohl(*(long*)&pack.data[0])); break; - case MLLOP_EVTYPE_HWKEY: + case MLOOP_EVTYPE_HWKEY: mloop_evhandle_hwkey(&pack); break; + case MLOOP_EVTYPE_TOUCH: + mloop_evhandle_touch(&pack); + break; default: break; } @@ -387,7 +397,7 @@ void mloop_evcmd_hwkey(int event_type, int keycode) { struct mloop_evpack pack; - pack.type = htons(MLLOP_EVTYPE_HWKEY); + pack.type = htons(MLOOP_EVTYPE_HWKEY); pack.size = htons(5 + 8); //TODO: ? memcpy(pack.data, &event_type, sizeof(int)); @@ -397,3 +407,13 @@ void mloop_evcmd_hwkey(int event_type, int keycode) mloop_evsock_send(&mloop, &pack); } +void mloop_evcmd_touch(void) +{ + struct mloop_evpack pack; + memset(&pack, 0, sizeof(struct mloop_evpack)); + + pack.type = htons(MLOOP_EVTYPE_TOUCH); + pack.size = htons(5); + mloop_evsock_send(&mloop, &pack); +} + diff --git a/tizen/src/mloop_event.h b/tizen/src/mloop_event.h index ce0ff3ec39..7fb8434110 100644 --- a/tizen/src/mloop_event.h +++ b/tizen/src/mloop_event.h @@ -47,6 +47,7 @@ void mloop_evcmd_raise_intr(void *irq); void mloop_evcmd_lower_intr(void *irq); void mloop_evcmd_hwkey(int event_type, int keycode); +void mloop_evcmd_touch(void); #ifdef __cplusplus } diff --git a/tizen/src/option.c b/tizen/src/option.c index e84329b429..bef4bd0b73 100644 --- a/tizen/src/option.c +++ b/tizen/src/option.c @@ -37,7 +37,7 @@ #include "option.h" #include "emulator.h" #include "maru_common.h" -#ifndef _WIN32 +#if defined (CONFIG_LINUX) #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> @@ -45,11 +45,14 @@ #include <unistd.h> #include <netinet/in.h> #include <net/if.h> -#else +#elif defined (CONFIG_WIN32) #include <windows.h> #include <winsock2.h> #include <iphlpapi.h> #include <winreg.h> +#elif defined (CONFIG_DARWIN) +#include <SystemConfiguration/SystemConfiguration.h> +CFDictionaryRef proxySettings; #endif #include <curl/curl.h> @@ -149,6 +152,30 @@ int gethostDNS(char *dns1, char *dns2) return 0; } +#if defined (CONFIG_DARWIN) +static char *cfstring_to_cstring(CFStringRef str) { + if (str == NULL) { + return NULL; + } + + CFIndex length = CFStringGetLength(str); + CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8); + char *buffer = (char *)malloc(maxSize); + if (CFStringGetCString(str, buffer, maxSize, kCFStringEncodingUTF8)) + return buffer; + return NULL; +} + +static int cfnumber_to_int(CFNumberRef num) { + if (!num) + return 0; + + int value; + CFNumberGetValue(num, kCFNumberIntType, &value); + return value; +} +#endif + static size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) { size_t written; @@ -181,7 +208,89 @@ static void download_url(char *url) return; } -void remove_string(char *src, char *dst, const char *toremove) +#if defined (CONFIG_DARWIN) +static void getmacproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) +{ + char *hostname; + int port; + CFNumberRef isEnable; + CFStringRef proxyHostname; + CFNumberRef proxyPort; + CFDictionaryRef proxySettings; + proxySettings = SCDynamicStoreCopyProxies(NULL); + + isEnable = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPEnable); + if (cfnumber_to_int(isEnable)) { + // Get proxy hostname + proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPProxy); + hostname = cfstring_to_cstring(proxyHostname); + // Get proxy port + proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPPort); + port = cfnumber_to_int(proxyPort); + // Save hostname & port + sprintf(http_proxy, "%s:%d", hostname, port); + + free(hostname); + //CFRelease(proxySettings); + } else { + INFO("http proxy is null\n"); + } + + isEnable = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSEnable); + if (cfnumber_to_int(isEnable)) { + // Get proxy hostname + proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSProxy); + hostname = cfstring_to_cstring(proxyHostname); + // Get proxy port + proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSPort); + port = cfnumber_to_int(proxyPort); + // Save hostname & port + sprintf(https_proxy, "%s:%d", hostname, port); + + free(hostname); + //CFRelease(proxySettings); + } else { + INFO("https proxy is null\n"); + } + + isEnable = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPEnable); + if (cfnumber_to_int(isEnable)) { + // Get proxy hostname + proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPProxy); + hostname = cfstring_to_cstring(proxyHostname); + // Get proxy port + proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPPort); + port = cfnumber_to_int(proxyPort); + // Save hostname & port + sprintf(ftp_proxy, "%s:%d", hostname, port); + + free(hostname); + //CFRelease(proxySettings); + } else { + INFO("ftp proxy is null\n"); + } + + isEnable = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSEnable); + if (cfnumber_to_int(isEnable)) { + // Get proxy hostname + proxyHostname = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSProxy); + hostname = cfstring_to_cstring(proxyHostname); + // Get proxy port + proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSPort); + port = cfnumber_to_int(proxyPort); + // Save hostname & port + sprintf(socks_proxy, "%s:%d", hostname, port); + + free(hostname); + } else { + INFO("socks proxy is null\n"); + } + CFRelease(proxySettings); +} +#endif + +#if defined (CONFIG_WIN32) +static void remove_string(char *src, char *dst, const char *toremove) { int len = strlen(toremove); int i, j; @@ -194,8 +303,10 @@ void remove_string(char *src, char *dst, const char *toremove) dst[j] = '\0'; } +#endif -void getlinuxproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) +#if defined (CONFIG_LINUX) +static void getlinuxproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) { char buf[MAXLEN]; FILE *output; @@ -248,19 +359,16 @@ void getlinuxproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *s pclose(output); INFO("socks_proxy : %s\n", socks_proxy); } +#endif -static void getautoproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) +static int getautoproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy) { char type[MAXLEN]; char proxy[MAXLEN]; char line[MAXLEN]; FILE *fp_pacfile; - char *out; - char *err; char *p = NULL; - out = g_malloc0(MAXLEN); - err = g_malloc0(MAXLEN); #if defined(CONFIG_LINUX) FILE *output; char buf[MAXLEN]; @@ -273,6 +381,15 @@ static void getautoproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, c #elif defined(CONFIG_WIN32) INFO("pac address: %s\n", (char*)url); download_url((char*)url); +#elif defined(CONFIG_DARWIN) + CFStringRef pacURL = (CFStringRef)CFDictionaryGetValue(proxySettings, + kSCPropNetProxiesProxyAutoConfigURLString); + if (pacURL) { + char url[MAXLEN] = {}; + CFStringGetCString(pacURL, url, sizeof url, kCFStringEncodingASCII); + INFO("pac address: %s\n", (char*)url); + download_url(url); + } #endif fp_pacfile = fopen(pactempfile, "r"); if(fp_pacfile != NULL) { @@ -308,10 +425,11 @@ static void getautoproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, c } else { ERR("fail to get pacfile fp\n"); + return -1; } remove(pactempfile); - return ; + return 0; } @@ -469,10 +587,21 @@ int gethostproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *soc } } else { - ERR("proxy is null\n"); + INFO("proxy is null\n"); return 0; } RegCloseKey(hKey); +#elif defined (CONFIG_DARWIN) + int ret; + proxySettings = SCDynamicStoreCopyProxies(NULL); + if(proxySettings) { + INFO("AUTO PROXY MODE\n"); + ret = getautoproxy(http_proxy, https_proxy, ftp_proxy, socks_proxy); + if(strlen(http_proxy) == 0 && ret < 0) { + INFO("MANUAL PROXY MODE\n"); + getmacproxy(http_proxy, https_proxy, ftp_proxy, socks_proxy); + } + } #endif return 0; } diff --git a/tizen/src/option.h b/tizen/src/option.h index 3f050f8924..128cacf3b6 100644 --- a/tizen/src/option.h +++ b/tizen/src/option.h @@ -45,7 +45,5 @@ int gethostDNS(char *dns1, char *dns2); int gethostproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy); -void getlinuxproxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy); -void remove_string(char *src, char *dst, const char *toremove); #endif diff --git a/tizen/src/skin/client/build.xml b/tizen/src/skin/client/build.xml index 47fa89330a..f3856a5ab9 100644 --- a/tizen/src/skin/client/build.xml +++ b/tizen/src/skin/client/build.xml @@ -89,7 +89,7 @@ <arg line="-c" /> <arg line="Share.c" /> <arg line="-o" /> - <arg line="libshare.so" /> + <arg line="libshared.so" /> <arg line="-I${env.JAVA_JNI_H_INCLUDE_PATH}" /> <arg line="-I${env.JAVA_JNI_H_INCLUDE_PATH}/linux" /> <arg line="-fPIC" /> @@ -105,12 +105,17 @@ <class name="org.tizen.emulator.skin.EmulatorShmSkin" /> </javah> <exec dir="native_src" executable="gcc" failifexecutionfails="false"> - <arg line="-dynamiclib" /> + <arg line="-c" /> <arg line="Share.c" /> <arg line="-o" /> - <arg line="libshare.dylib" /> + <arg line="Share.o" /> <arg line="-I${env.JAVA_JNI_H_INCLUDE_PATH}" /> - <arg line="-fPIC" /> + </exec> + <exec dir="native_src" executable="gcc" failifexecutionfails="false"> + <arg line="-dynamiclib" /> + <arg line="Share.o" /> + <arg line="-o" /> + <arg line="libshared.dylib" /> </exec> <delete> <fileset dir="native_src" includes="**/*.h" /> diff --git a/tizen/src/skin/client/native_src/make_so_linux.sh b/tizen/src/skin/client/native_src/make_so_linux.sh index 05ccdf7c96..7e4bc6bb1e 100755 --- a/tizen/src/skin/client/native_src/make_so_linux.sh +++ b/tizen/src/skin/client/native_src/make_so_linux.sh @@ -1,6 +1,7 @@ #!/bin/bash -javah -classpath ../bin/:../lib/swt/gtk-linux/swt.jar -jni org.tizen.emulator.skin.EmulatorSkin +javah -classpath ../bin/:../lib/swt.jar -jni org.tizen.emulator.skin.EmulatorSkin rm ./org_tizen_emulator_skin_EmulatorSkin_PollFBThread.h rm ./org_tizen_emulator_skin_EmulatorSkin_SkinReopenPolicy.h +#TODO: jdk path gcc -c Share.c -o Share.o -I /usr/lib/jvm/jdk1.7.0_04/include -I /usr/lib/jvm/jdk1.7.0_04/include/linux gcc -shared Share.o -o libshared.so -fPIC diff --git a/tizen/src/skin/client/native_src/make_so_mac.sh b/tizen/src/skin/client/native_src/make_so_mac.sh index 6f718d5a34..edf2910e04 100755 --- a/tizen/src/skin/client/native_src/make_so_mac.sh +++ b/tizen/src/skin/client/native_src/make_so_mac.sh @@ -1,6 +1,7 @@ #!/bin/bash -javah -classpath ../emulator-skin.jar:../lib/swt/cocoa-macosx64/swt.jar -jni org.tizen.emulator.skin.EmulatorSkin +javah -classpath ../emulator-skin.jar:../lib/swt.jar -jni org.tizen.emulator.skin.EmulatorSkin rm ./org_tizen_emulator_skin_EmulatorSkin_PollFBThread.h rm ./org_tizen_emulator_skin_EmulatorSkin_SkinReopenPolicy.h +#TODO: jdk path gcc -c Share.c -o Share.o -I/System/Library/Frameworks/JavaVM.framework/Headers gcc -dynamiclib Share.o -o libshared.dylib diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index 64ee4e1a57..67cea530f6 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -61,6 +61,7 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Canvas; @@ -125,11 +126,17 @@ public class EmulatorSkin { } } + public native int getPixels(int[] array); public static final String GTK_OS_CLASS = "org.eclipse.swt.internal.gtk.OS"; public static final String WIN32_OS_CLASS = "org.eclipse.swt.internal.win32.OS"; public static final String COCOA_OS_CLASS = "org.eclipse.swt.internal.cocoa.OS"; + public final static int RED_MASK = 0x00FF0000; + public final static int GREEN_MASK = 0x0000FF00; + public final static int BLUE_MASK = 0x000000FF; + public final static int COLOR_DEPTH = 32; + private Logger logger = SkinLogger.getSkinLogger( EmulatorSkin.class ).getLogger(); protected EmulatorConfig config; @@ -166,6 +173,7 @@ public class EmulatorSkin { private SocketCommunicator communicator; private long windowHandleId; + private PaletteData paletteData; private Listener shellCloseListener; private PaintListener shellPaintListener; private MouseTrackListener shellMouseTrackListener; @@ -191,6 +199,7 @@ public class EmulatorSkin { this.config = config; this.isDefaultHoverColor = true; this.isOnTop = isOnTop; + this.paletteData = new PaletteData(RED_MASK, GREEN_MASK, BLUE_MASK); int style = SWT.NO_TRIM; this.shell = new Shell( Display.getDefault(), style ); @@ -200,6 +209,9 @@ public class EmulatorSkin { public void setCommunicator( SocketCommunicator communicator ) { this.communicator = communicator; } + public PaletteData getPalette() { + return paletteData; + } public long compose() { @@ -2002,6 +2014,19 @@ public class EmulatorSkin { } }); + final MenuItem guestdumpItem = new MenuItem(menu, SWT.PUSH); + guestdumpItem.setText("&Guest Memory Dump"); + + guestdumpItem.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + logger.info("Guest memory dump menu is selected"); + + communicator.setRamdumpFlag(true); + communicator.sendToQEMU(SendCommand.GUEST_DUMP, null); + } + }); + return menu; } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java index 12ef4269ca..b937e8563b 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java @@ -73,7 +73,7 @@ public class EmulatorSkinMain { static { /* shared memory */ if (SwtUtil.isMacPlatform()) { - System.loadLibrary("share"); + System.loadLibrary("shared"); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java index 79405c57d4..4817f9e3fd 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java @@ -206,6 +206,7 @@ public interface ICommunicator extends Runnable { SCREEN_SHOT( (short)16 ), DETAIL_INFO( (short)17 ), RAM_DUMP( (short)18 ), + GUEST_DUMP( (short)19 ), RESPONSE_HEART_BEAT( (short)900 ), CLOSE( (short)998 ), diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java index 06a43ae453..98f0543f06 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java @@ -51,7 +51,6 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.ImageLoader; -import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; @@ -67,9 +66,7 @@ import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.ToolItem; import org.tizen.emulator.skin.EmulatorSkin; import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo; -import org.tizen.emulator.skin.comm.ICommunicator.SendCommand; import org.tizen.emulator.skin.comm.sock.SocketCommunicator; -import org.tizen.emulator.skin.comm.sock.SocketCommunicator.DataTranfer; import org.tizen.emulator.skin.config.EmulatorConfig; import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants; import org.tizen.emulator.skin.exception.ScreenShotException; @@ -78,24 +75,17 @@ import org.tizen.emulator.skin.image.ImageRegistry.IconName; import org.tizen.emulator.skin.log.SkinLogger; import org.tizen.emulator.skin.util.IOUtil; import org.tizen.emulator.skin.util.SkinUtil; -import org.tizen.emulator.skin.util.StringUtil; import org.tizen.emulator.skin.util.SwtUtil; +import org.tizen.emulator.skin.util.StringUtil; public class ScreenShotDialog { public final static String DEFAULT_FILE_EXTENSION = "png"; - - public static final int RED_MASK = 0x0000FF00; - public static final int GREEN_MASK = 0x00FF0000; - public static final int BLUE_MASK = 0xFF000000; - public static final int COLOR_DEPTH = 32; - - public static final int CANVAS_MARGIN = 30; - public static final int TOOLITEM_COOLTIME = 200; + public final static int CANVAS_MARGIN = 30; + public final static int TOOLITEM_COOLTIME = 200; private Logger logger = SkinLogger.getSkinLogger( ScreenShotDialog.class ).getLogger(); - private PaletteData paletteData; private Image image; private Canvas imageCanvas; private Shell shell; @@ -170,7 +160,7 @@ public class ScreenShotDialog { if ( null != image && !image.isDisposed() ) { //e.gc.drawImage( image, CANVAS_MARGIN, CANVAS_MARGIN ); Rectangle r = image.getBounds(); - //logger.info("r.width: " +r.width +", r.height " + r.height); + logger.info("r.width: " +r.width +", r.height " + r.height); e.gc.drawImage(image, 0, 0, r.width, r.height, CANVAS_MARGIN, CANVAS_MARGIN, (int)(r.width * scaleLevel * 1/100), (int)(r.height * scaleLevel * 1/100)); } @@ -178,8 +168,6 @@ public class ScreenShotDialog { } } ); - paletteData = new PaletteData( RED_MASK, GREEN_MASK, BLUE_MASK ); - scrollComposite.setContent( imageCanvas ); try { @@ -272,7 +260,7 @@ public class ScreenShotDialog { private void capture() throws ScreenShotException { - DataTranfer dataTranfer = communicator.sendToQEMU( SendCommand.SCREEN_SHOT, null, true ); + /* DataTranfer dataTranfer = communicator.sendToQEMU( SendCommand.SCREEN_SHOT, null, true ); byte[] receivedData = communicator.getReceivedData( dataTranfer ); if ( null != receivedData ) { @@ -294,10 +282,30 @@ public class ScreenShotDialog { } else { throw new ScreenShotException( "Fail to get image data." ); + }*/ + + int width = config.getArgInt(ArgsConstants.RESOLUTION_WIDTH); + int height = config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT); + + int[] array = new int[width * height]; + int result = emulatorSkin.getPixels(array); //from shared memory + //logger.info("getPixels navtive function returned " + result); + + ImageData imageData = new ImageData(width, height, EmulatorSkin.COLOR_DEPTH, emulatorSkin.getPalette()); + for (int i = 0; i < height; i++) { + imageData.setPixels(0, i, width, array, i * width); } + RotationInfo rotation = getCurrentRotation(); + imageData = rotateImageData(imageData, rotation); + + if (image != null) { + image.dispose(); + } + image = new Image(Display.getDefault(), imageData); + imageCanvas.redraw(); } - + private double getScaleLevel() { return scaleLevel; } @@ -502,8 +510,7 @@ public class ScreenShotDialog { if ( SwtUtil.isWindowsPlatform() ) { // change RGB mask ImageData imageData = image.getImageData(); - PaletteData paletteData = new PaletteData( BLUE_MASK, GREEN_MASK, RED_MASK ); - data = new ImageData( imageData.width, imageData.height, imageData.depth, paletteData, + data = new ImageData( imageData.width, imageData.height, imageData.depth, emulatorSkin.getPalette(), imageData.bytesPerLine, imageData.data ); } else { data = image.getImageData(); @@ -738,4 +745,4 @@ public class ScreenShotDialog { return shell; } -}
\ No newline at end of file +} diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java index e38812aa38..00c5feb548 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java @@ -72,7 +72,7 @@ public class SkinUtil { String vmPath = config.getArg( ArgsConstants.VM_PATH ); String regex = ""; - if ( SwtUtil.isWindowsPlatform() ) { + if (SwtUtil.isWindowsPlatform()) { regex = "\\" + File.separator; } else { regex = File.separator; @@ -101,7 +101,7 @@ public class SkinUtil { String sdbPath = null; if (SwtUtil.isWindowsPlatform()) { - sdbPath = ".\\..\\..\\sdb-run.bat"; + sdbPath = ".\\..\\..\\ansicon.exe"; } else { sdbPath = "./../../sdb"; } diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 9a58e6a357..e41b1f9639 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -75,7 +75,7 @@ static void send_to_emuld(const char* request_type, int request_size, const char void start_display(uint64 handle_id, int lcd_size_width, int lcd_size_height, double scale_factor, short rotation_type) { - INFO("start_display handle_id:%ld, lcd size:%dx%d, scale_factor:%lf, rotation_type:%d\n", + INFO("start_display handle_id:%ld, lcd size:%dx%d, scale_factor:%f, rotation_type:%d\n", (long)handle_id, lcd_size_width, lcd_size_height, scale_factor, rotation_type); set_emul_win_scale(scale_factor); @@ -465,6 +465,12 @@ void ram_dump(void) { notify_ramdump_complete(); } +void guestmemory_dump(void) { + INFO("guest memory dump!\n"); + + //TODO: +} + void request_close( void ) { INFO( "request_close\n" ); diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index 32d3a9abdf..4f48085bb6 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -103,6 +103,7 @@ enum { RECV_SCREEN_SHOT = 16, RECV_DETAIL_INFO = 17, RECV_RAM_DUMP = 18, + RECV_GUESTMEMORY_DUMP = 19, RECV_RESPONSE_HEART_BEAT = 900, RECV_CLOSE = 998, RECV_RESPONSE_SHUTDOWN = 999, @@ -783,6 +784,13 @@ static void* run_skin_server( void* args ) { ram_dump(); break; } + case RECV_GUESTMEMORY_DUMP: { + log_cnt += sprintf(log_buf + log_cnt, "RECV_GUESTMEMORY_DUMP ==\n"); + TRACE(log_buf); + + guestmemory_dump(); + break; + } case RECV_RESPONSE_HEART_BEAT: { log_cnt += sprintf( log_buf + log_cnt, "RECV_RESPONSE_HEART_BEAT ==\n" ); // TRACE( log_buf ); @@ -3782,16 +3782,15 @@ int main(int argc, char **argv, char **envp) if (using_spice) display_remote++; if (display_type == DT_DEFAULT && !display_remote) { -#if defined(CONFIG_MARU) - /* maru display */ - display_type = DT_MARU; -#elif defined(CONFIG_SDL) || defined(CONFIG_COCOA) +#if defined(CONFIG_SDL) || defined(CONFIG_COCOA) display_type = DT_SDL; #elif defined(CONFIG_VNC) vnc_display = "localhost:0,to=99"; show_vnc_port = 1; +#elif defined(CONFIG_MARU) && defined (__APPLE__) + display_type = DT_MARU; #else - display_type = DT_NONE; + display_type = DT_NONE; #endif } @@ -3807,25 +3806,38 @@ int main(int argc, char **argv, char **envp) #endif #if defined(CONFIG_SDL) case DT_SDL: - sdl_display_init(ds, full_screen, no_frame); +#if defined(CONFIG_MARU) + /* use tizen qemu sdl */ + maru_display_init(ds); + + if (skin_disabled == 1) { + //do not start skin client process + set_emul_skin_enable(0); + } else { + set_emul_skin_enable(1); + } +#else + sdl_display_init(ds, full_screen, no_frame); +#endif break; #elif defined(CONFIG_COCOA) case DT_SDL: cocoa_display_init(ds, full_screen); break; #endif -#if defined(CONFIG_MARU) +#if defined(CONFIG_MARU) && defined(__APPLE__) case DT_MARU: - maru_display_init(ds); - if (skin_disabled == 1) { - set_emul_skin_enable(0); - } else { - set_emul_skin_enable(1); - } - break; + maru_display_init(ds); + if (skin_disabled == 1) { + //do not start skin client process + set_emul_skin_enable(0); + } else { + set_emul_skin_enable(1); + } + break; #endif default: - break; + break; } /* must be after terminal init, SDL library changes signal handlers */ |