diff options
author | giwoong.kim <giwoong.kim@samsung.com> | 2013-04-15 20:06:12 +0900 |
---|---|---|
committer | giwoong.kim <giwoong.kim@samsung.com> | 2013-04-16 16:49:21 +0900 |
commit | dd5e3e0b93300452caf8a5d1651f16be4ccc9c08 (patch) | |
tree | 078d344f96d69d342a8d742ae73419378f97d691 /tizen/src/maru_shm.c | |
parent | 9a38ec36a90916813fb864e8cabbdca893856927 (diff) | |
download | qemu-dd5e3e0b93300452caf8a5d1651f16be4ccc9c08.tar.gz qemu-dd5e3e0b93300452caf8a5d1651f16be4ccc9c08.tar.bz2 qemu-dd5e3e0b93300452caf8a5d1651f16be4ccc9c08.zip |
shm: The code of shared framebuffer is moved
The code of shared framebuffer is moved
from maru_vga.c into maru_shm.c
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
Diffstat (limited to 'tizen/src/maru_shm.c')
-rw-r--r-- | tizen/src/maru_shm.c | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/tizen/src/maru_shm.c b/tizen/src/maru_shm.c index dc9e9619a9..7a1577b4db 100644 --- a/tizen/src/maru_shm.c +++ b/tizen/src/maru_shm.c @@ -1,7 +1,7 @@ /* * 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> @@ -32,12 +32,23 @@ #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) @@ -50,7 +61,8 @@ void qemu_ds_shm_refresh(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); @@ -58,5 +70,51 @@ void maruskin_shm_init(uint64 swt_handle, int lcd_size_width, int lcd_size_heigh 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: "); + } } |