#define MAXLEN 512
#define MAXPACKETLEN 60
-#define SHMKEY 26099
+//#define SHMKEY 26099
extern gchar bin_path[];
extern gchar log_path[];
const gchar * get_log_path(void);
const gchar * prepare_maru_devices(const gchar * kernel_cmdline);
int maru_device_check(QemuOpts *opts);
+
#endif /* __EMULATOR_H__ */
* Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
+ * JinHyung Jo <jinhyung.jo@samsung.com>
* GiWoong Kim <giwoong.kim@samsung.com>
* YeongKyoon Lee <yeongkyoon.lee@samsung.com>
* HyunJun Son
#include "maru_vga_int.h"
#include "maru_brightness.h"
#include "maru_overlay.h"
-#include "maru_display.h"
#include "emul_state.h"
#include "debug_ch.h"
#include <pthread.h>
-#ifdef CONFIG_USE_SHM
-#include "emulator.h"
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include "maru_err_table.h"
-#include "emul_state.h"
-#endif
-
-#ifdef CONFIG_USE_SHM
-void *shared_memory = (void*) 0;
-int skin_shmid;
-#endif
-
-
MULTI_DEBUG_CHANNEL(qemu, maru_vga);
-extern pthread_mutex_t mutex_screenshot;
-extern pthread_cond_t cond_screenshot;
//#define DEBUG_VGA
//#define DEBUG_VGA_MEM
d += linesize;
}
-//TODO: maru_shm
-#ifdef CONFIG_USE_SHM
- /* for display updating */
- memcpy(shared_memory, s->ds->surface->data,
- s->ds->surface->linesize * s->ds->surface->height);
-#endif
-
-//TODO: maru_sdl
-#ifndef CONFIG_USE_SHM
- /* for screenshot */
- pthread_mutex_lock(&mutex_screenshot);
-
- MaruScreenshot* maru_screenshot = get_maru_screenshot();
- if (maru_screenshot) {
- maru_screenshot->isReady = 1;
-
- if (maru_screenshot->request_screenshot == 1) {
- memcpy(maru_screenshot->pixel_data, s->ds->surface->data,
- s->ds->surface->linesize * s->ds->surface->height);
- maru_screenshot->request_screenshot = 0;
-
- pthread_cond_signal(&cond_screenshot);
- }
- }
-
- pthread_mutex_unlock(&mutex_screenshot);
-#endif
-
if (y_start >= 0) {
/* flush to display */
dpy_update(s->ds, 0, y_start,
break;
}
vga_dirty_log_start(s);
-
-#ifdef CONFIG_USE_SHM
- /* base + 1 = sdb port */
- /* base + 2 = shared memory key */
- int mykey = get_emul_vm_base_port() + 2;
-
- INFO("shared memory key: %d, vga ram_size : %d\n", mykey, s->vram_size);
-
- skin_shmid = shmget((key_t)mykey, (size_t)s->vram_size, 0666 | IPC_CREAT);
- if (skin_shmid == -1) {
- ERR("shmget failed\n");
- perror("maru_vga: ");
- maru_register_exit_msg(MARU_EXIT_UNKNOWN,
- (char*) "Cannot launch this VM.\n"
- "Shared memory is not enough.");
- exit(0);
- }
-
- shared_memory = shmat(skin_shmid, (void*)0, 0);
- if (shared_memory == (void *)-1) {
- ERR("shmat failed\n");
- perror("maru_vga: ");
- exit(1);
- }
-
- memset(shared_memory, 0x00, (size_t)s->vram_size);
- printf("Memory attached at %X\n", (int)shared_memory);
-#endif
-
}
-#ifdef CONFIG_USE_SHM
void maru_vga_common_fini(void)
{
- if (shmdt(shared_memory) == -1) {
- ERR("shmdt failed\n");
- perror("maru_vga: ");
- }
-
- if (shmctl(skin_shmid, IPC_RMID, 0) == -1) {
- ERR("shmctl failed\n");
- perror("maru_vga: ");
- }
+ /* do nothing */
}
-#endif
static const MemoryRegionPortio vga_portio_list[] = {
{ 0x04, 2, 1, .read = vga_ioport_read, .write = vga_ioport_write }, /* 3b4 */
#define MARU_VGA_INT_H_
void maru_vga_common_init(VGACommonState *s);
+void maru_vga_common_fini(void);
+
void maru_vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1,
int poffset, int w,
#ifndef CONFIG_USE_SHM
maruskin_sdl_quit();
#else
-#if defined(TARGET_I386)
- maru_vga_common_fini();
-#endif
+ maruskin_shm_quit();
#endif
}
-void maruskin_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize)
+void maruskin_init(uint64 swt_handle,
+ int lcd_size_width, int lcd_size_height, bool is_resize)
{
#ifndef CONFIG_USE_SHM
maruskin_sdl_init(swt_handle, lcd_size_width, lcd_size_height, is_resize);
#include <math.h>
#include "console.h"
#include "maru_sdl.h"
+#include "maru_display.h"
#include "emul_state.h"
#include "SDL_gfx/SDL_rotozoom.h"
#include "maru_sdl_rotozoom.h"
static int sdl_thread_initialized;
#endif
+extern pthread_mutex_t mutex_screenshot;
+extern pthread_cond_t cond_screenshot;
+
#define SDL_FLAGS (SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL | SDL_NOFRAME)
#define SDL_BPP 32
#else
qemu_update();
#endif
+
+ /* for screenshot */
+ pthread_mutex_lock(&mutex_screenshot);
+
+ MaruScreenshot* maru_screenshot = get_maru_screenshot();
+ if (maru_screenshot) {
+ maru_screenshot->isReady = 1;
+
+ if (maru_screenshot->request_screenshot == 1) {
+ memcpy(maru_screenshot->pixel_data, ds->surface->data,
+ ds->surface->linesize * ds->surface->height);
+ maru_screenshot->request_screenshot = 0;
+
+ pthread_cond_signal(&cond_screenshot);
+ }
+ }
+
+ pthread_mutex_unlock(&mutex_screenshot);
}
void qemu_ds_sdl_resize(DisplayState *ds)
/*
* Shared memory
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
#include "emul_state.h"
#include "debug_ch.h"
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include "maru_err_table.h"
+
MULTI_DEBUG_CHANNEL(tizen, maru_shm);
+void *shared_memory = (void*) 0;
+int skin_shmid;
+
void qemu_ds_shm_update(DisplayState *ds, int x, int y, int w, int h)
{
- //TODO:
+ if (shared_memory != NULL) {
+ memcpy(shared_memory, ds->surface->data,
+ ds->surface->linesize * ds->surface->height);
+ }
}
void qemu_ds_shm_resize(DisplayState *ds)
vga_hw_update();
}
-void maruskin_shm_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize)
+void maruskin_shm_init(uint64 swt_handle,
+ int lcd_size_width, int lcd_size_height, bool is_resize)
{
INFO("maru shm initialization = %d\n", is_resize);
set_emul_lcd_size(lcd_size_width, lcd_size_height);
set_emul_sdl_bpp(32);
}
+
+ /* byte */
+ int shm_size =
+ get_emul_lcd_width() * get_emul_lcd_height() * 4;
+
+ /* base + 1 = sdb port */
+ /* base + 2 = shared memory key */
+ int mykey = get_emul_vm_base_port() + 2;
+
+ INFO("shared memory key: %d, vga ram_size : %d\n", mykey, shm_size);
+
+ /* make a shared framebuffer */
+ skin_shmid = shmget((key_t)mykey, (size_t)shm_size, 0666 | IPC_CREAT);
+ if (skin_shmid == -1) {
+ ERR("shmget failed\n");
+ perror("maru_vga: ");
+
+ maru_register_exit_msg(MARU_EXIT_UNKNOWN,
+ (char*) "Cannot launch this VM.\n"
+ "Shared memory is not enough.");
+ exit(0);
+ }
+
+ shared_memory = shmat(skin_shmid, (void*)0, 0);
+ if (shared_memory == (void *)-1) {
+ ERR("shmat failed\n");
+ perror("maru_vga: ");
+ exit(1);
+ }
+
+ /* default screen */
+ memset(shared_memory, 0x00, (size_t)shm_size);
+ printf("Memory attached at %X\n", (int)shared_memory);
+}
+
+void maruskin_shm_quit(void)
+{
+ if (shmdt(shared_memory) == -1) {
+ ERR("shmdt failed\n");
+ perror("maru_vga: ");
+ }
+
+ if (shmctl(skin_shmid, IPC_RMID, 0) == -1) {
+ ERR("shmctl failed\n");
+ perror("maru_vga: ");
+ }
}
/*
* Shared memory
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
void qemu_ds_shm_update(DisplayState *ds, int x, int y, int w, int h);
void qemu_ds_shm_resize(DisplayState *ds);
void qemu_ds_shm_refresh(DisplayState *ds);
-void maruskin_shm_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize);
+
+void maruskin_shm_init(uint64 swt_handle,
+ int lcd_size_width, int lcd_size_height, bool is_resize);
+void maruskin_shm_quit(void);
#endif /* MARU_SHM_H_ */
JNIEXPORT jint JNICALL Java_org_tizen_emulator_skin_EmulatorShmSkin_shmget
(JNIEnv *env, jobject obj, jint shmkey, jint vga_ram_size)
{
- fprintf(stdout, "share.c: shared memory key = %d\n", shmkey);
+ fprintf(stdout, "share.c: shared memory key = %d, size=%d\n", shmkey, vga_ram_size);
fflush(stdout);
shmid = shmget((key_t)shmkey, (size_t)vga_ram_size, 0666 | IPC_CREAT);
/* initialize shared memory */
int result = shmget(shmkey,
currentState.getCurrentResolutionWidth() *
- currentState.getCurrentResolutionHeight());
+ currentState.getCurrentResolutionHeight() * 4);
logger.info("shmget native function returned " + result);
/* update lcd thread */