From: Kitae Kim Date: Thu, 9 Aug 2012 04:11:20 +0000 (+0900) Subject: [Title] source clean-up for qemu coding style. X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1528^2~16^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0bcb37002d1c7774fbceb23b11f4c130ff9d3f1d;p=sdk%2Femulator%2Fqemu.git [Title] source clean-up for qemu coding style. [Type] [Module] emulator [Priority] [CQ#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index acf3dcac89..2ad5cce069 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -1,9 +1,9 @@ -/* +/* * Emulator * * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: + * Contact: * SeokYeon Hwang * HyunJun Son * MunKyu Im @@ -22,7 +22,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. * * Contributors: * - S-Core Co., Ltd @@ -56,7 +57,7 @@ #include #include #include -#include +#include #include #endif @@ -71,17 +72,18 @@ MULTI_DEBUG_CHANNEL(qemu, main); #define LOGS_SUFFIX "/logs/" #define LOGFILE "emulator.log" #define MIDBUF 128 -int tizen_base_port = 0; -char tizen_target_path[MAXLEN] = {0, }; -char logpath[MAXLEN] = { 0, }; +int tizen_base_port; +char tizen_target_path[MAXLEN]; +char logpath[MAXLEN]; -static int skin_argc = 0; -static char** skin_argv = NULL; -static int qemu_argc = 0; -static char** qemu_argv = NULL; +static int skin_argc; +static char **skin_argv; +static int qemu_argc; +static char **qemu_argv; + +void maru_display_fini(void); -extern void maru_display_fini(void); void exit_emulator(void) { mloop_ev_stop(); @@ -100,31 +102,31 @@ void check_shdmem(void) int val; struct shmid_ds shm_info; - for(port=26100;port < 26200; port += 10) - { - if ( -1 != ( shm_id = shmget( (key_t)port, 0, 0))) - { - if((void *)-1 == (shm_addr = shmat(shm_id, (void *)0, 0))) - { - ERR( "error occured at shmat()\n"); + for (port = 26100; port < 26200; port += 10) { + shm_id = shmget((key_t)port, 0, 0); + if (shm_id != -1) { + shm_addr = shmat(shm_id, (void *)0, 0); + if ((void *)-1 == shm_addr) { + ERR("error occured at shmat()\n"); break; } val = shmctl(shm_id, IPC_STAT, &shm_info); - if(val != -1) - { - INFO( "count of process that use shared memory : %d\n", shm_info.shm_nattch); - if(shm_info.shm_nattch > 0 && strcmp(tizen_target_path, (char*)shm_addr) == 0) - { - if(check_port_bind_listen(port+1) > 0){ + if (val != -1) { + INFO("count of process that use shared memory : %d\n", + shm_info.shm_nattch); + if ((shm_info.shm_nattch > 0) && + strcmp(tizen_target_path, (char *)shm_addr) == 0) { + if (check_port_bind_listen(port + 1) > 0) { shmdt(shm_addr); continue; } shmdt(shm_addr); - maru_register_exit_msg(MARU_EXIT_UNKNOWN, (char*)"Can not execute this VM.\nThe same name is running now."); + maru_register_exit_msg(MARU_EXIT_UNKNOWN, + (char *)"Can not execute this VM.\n \ + The same name is running now."); exit(0); - } - else{ + } else { shmdt(shm_addr); } } @@ -133,126 +135,110 @@ void check_shdmem(void) #elif defined(CONFIG_WIN32) u_int port; - char* base_port = NULL; - char* pBuf; + char *base_port = NULL; + char *pBuf; HANDLE hMapFile; - for(port=26100;port < 26200; port += 10) - { + 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) - { + 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) - { + } 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); } - if(strcmp(pBuf, tizen_target_path) == 0) - { - maru_register_exit_msg(MARU_EXIT_UNKNOWN, "Can not execute this VM.\nThe same name is running now."); + if (strcmp(pBuf, tizen_target_path) == 0) { + maru_register_exit_msg(MARU_EXIT_UNKNOWN, + "Can not execute this VM.\nThe same name is running now."); UnmapViewOfFile(pBuf); CloseHandle(hMapFile); free(base_port); exit(0); - } - else + } else { UnmapViewOfFile(pBuf); + } } CloseHandle(hMapFile); free(base_port); } #elif defined(CONFIG_DARWIN) - //TODO: + /* TODO: */ #endif } void make_shdmem(void) { #if defined(CONFIG_LINUX) - int shmid; - char *shared_memory; - shmid = shmget((key_t)tizen_base_port, MAXLEN, 0666|IPC_CREAT); - if (shmid == -1) - { - ERR("shmget failed\n"); - return; - } - shared_memory = shmat(shmid, (char*)0x00, 0); - if (shared_memory == (void *)-1) - { - ERR("shmat failed\n"); - return; - } - sprintf(shared_memory, "%s", tizen_target_path); - INFO( "shared memory key: %d value: %s\n", tizen_base_port, (char*)shared_memory); + int shmid; + char *shared_memory; + + shmid = shmget((key_t)tizen_base_port, MAXLEN, 0666|IPC_CREAT); + if (shmid == -1) { + ERR("shmget failed\n"); + return; + } + + shared_memory = shmat(shmid, (char *)0x00, 0); + if (shared_memory == (void *)-1) { + ERR("shmat failed\n"); + return; + } + sprintf(shared_memory, "%s", tizen_target_path); + INFO("shared memory key: %d value: %s\n", + tizen_base_port, (char *)shared_memory); #elif defined(CONFIG_WIN32) - HANDLE hMapFile; - char* pBuf; - char* port_in_use; - char *shared_memory; - shared_memory = g_strdup_printf("%s", tizen_target_path); - port_in_use = g_strdup_printf("%d", tizen_base_port); + HANDLE hMapFile; + char *pBuf; + char *port_in_use; + char *shared_memory; + + shared_memory = g_strdup_printf("%s", tizen_target_path); + 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; + 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; } - 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; + pBuf = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 50); + + if (pBuf == NULL) { + ERR("Could not map view of file (%d).\n", GetLastError()); + CloseHandle(hMapFile); + return; } - - CopyMemory((PVOID)pBuf, shared_memory, strlen(shared_memory)); - free(port_in_use); - free(shared_memory); + + CopyMemory((PVOID)pBuf, shared_memory, strlen(shared_memory)); + free(port_in_use); + free(shared_memory); #elif defined(CONFIG_DARWIN) - //TODO: + /* TODO: */ #endif - return; + return; } - - -static void construct_main_window(int skin_argc, char* skin_argv[], int qemu_argc, char* qemu_argv[] ) +static void construct_main_window(int skin_argc, char *skin_argv[], + int qemu_argc, char *qemu_argv[]) { INFO("construct main window\n"); - start_skin_server( skin_argc, skin_argv, qemu_argc, qemu_argv ); + start_skin_server(skin_argc, skin_argv, qemu_argc, qemu_argv); - if (get_emul_skin_enable() == 1) { //this line is check for debugging, etc.. - if ( 0 > start_skin_client(skin_argc, skin_argv) ) { + /* the next line checks for debugging and etc.. */ + if (get_emul_skin_enable() == 1) { + if (0 > start_skin_client(skin_argc, skin_argv)) { maru_register_exit_msg(MARU_EXIT_SKIN_SERVER_FAILED, NULL); - exit( -1 ); + exit(-1); } } @@ -260,26 +246,23 @@ static void construct_main_window(int skin_argc, char* skin_argv[], int qemu_arg set_emul_num_lock_state(0); } -static void parse_options(int argc, char* argv[], int* skin_argc, char*** skin_argv, int* qemu_argc, char*** qemu_argv) +static void parse_options(int argc, char *argv[], int *skin_argc, + char ***skin_argv, int *qemu_argc, char ***qemu_argv) { int i; int j; -// FIXME !!! -// TODO: - - for(i = 1; i < argc; ++i) - { - if(strncmp(argv[i], "--skin-args", 11) == 0) - { + /* TODO: */ + + for (i = 1; i < argc; ++i) { + if (strncmp(argv[i], "--skin-args", 11) == 0) { *skin_argv = &(argv[i + 1]); break; } } - for(j = i; j < argc; ++j) - { - if(strncmp(argv[j], "--qemu-args", 11) == 0) - { + + for (j = i; j < argc; ++j) { + if (strncmp(argv[j], "--qemu-args", 11) == 0) { *skin_argc = j - i - 1; *qemu_argc = argc - j - i + 1; @@ -290,42 +273,42 @@ static void parse_options(int argc, char* argv[], int* skin_argc, char*** skin_a } } -static void get_bin_dir( char* exec_argv ) { +static void get_bin_dir(char *exec_argv) +{ - if ( !exec_argv ) { + if (!exec_argv) { return; } - char* data = strdup( exec_argv ); - if ( !data ) { - fprintf( stderr, "Fail to strdup for paring a binary directory.\n" ); + char *data = strdup(exec_argv); + if (!data) { + fprintf(stderr, "Fail to strdup for paring a binary directory.\n"); return; } - char* p = NULL; + char *p = NULL; #ifdef _WIN32 - p = strrchr( data, '\\' ); - if ( !p ) { - p = strrchr( data, '/' ); + p = strrchr(data, '\\'); + if (!p) { + p = strrchr(data, '/'); } #else - p = strrchr( data, '/' ); + p = strrchr(data, '/'); #endif - if ( !p ) { - free( data ); + if (!p) { + free(data); return; } - strncpy( bin_dir, data, strlen( data ) - strlen( p ) ); + strncpy(bin_dir, data, strlen(data) - strlen(p)); - free( data ); + free(data); } -void set_image_and_log_path(char* qemu_argv) +void set_image_and_log_path(char *qemu_argv) { - int i; - int j = 0; + int i, j = 0; int name_len = 0; int prefix_len = 0; int suffix_len = 0; @@ -335,58 +318,59 @@ void set_image_and_log_path(char* qemu_argv) prefix_len = strlen(IMAGE_PATH_PREFIX); suffix_len = strlen(IMAGE_PATH_SUFFIX); max = name_len - suffix_len; - for(i = prefix_len , j = 0; i < max; i++) - { + for (i = prefix_len , j = 0; i < max; i++) { path[j++] = qemu_argv[i]; } path[j] = '\0'; - if(!g_path_is_absolute(path)) + if (!g_path_is_absolute(path)) { strcpy(tizen_target_path, g_get_current_dir()); - else + } else { strcpy(tizen_target_path, g_path_get_dirname(path)); + } strcpy(logpath, tizen_target_path); strcat(logpath, LOGS_SUFFIX); #ifdef CONFIG_WIN32 - if(access(g_win32_locale_filename_from_utf8(logpath), R_OK) != 0) { - g_mkdir(g_win32_locale_filename_from_utf8(logpath), 0755); + if (access(g_win32_locale_filename_from_utf8(logpath), R_OK) != 0) { + g_mkdir(g_win32_locale_filename_from_utf8(logpath), 0755); } #else - if(access(logpath, R_OK) != 0) { - g_mkdir(logpath, 0755); + if (access(logpath, R_OK) != 0) { + g_mkdir(logpath, 0755); } #endif - strcat(logpath, LOGFILE); + strcat(logpath, LOGFILE); set_log_path(logpath); } void redir_output(void) { - FILE *fp; + FILE *fp; - fp = freopen(logpath, "a+", stdout); - if(fp ==NULL) - fprintf(stderr, "log file open error\n"); - fp = freopen(logpath, "a+", stderr); - if(fp ==NULL) - fprintf(stderr, "log file open error\n"); + fp = freopen(logpath, "a+", stdout); + if (fp == NULL) { + fprintf(stderr, "log file open error\n"); + } - setvbuf(stdout, NULL, _IOLBF, BUFSIZ); - setvbuf(stderr, NULL, _IOLBF, BUFSIZ); + fp = freopen(logpath, "a+", stderr); + if (fp == NULL) { + fprintf(stderr, "log file open error\n"); + } + setvbuf(stdout, NULL, _IOLBF, BUFSIZ); + setvbuf(stderr, NULL, _IOLBF, BUFSIZ); } -void extract_info(int qemu_argc, char** qemu_argv) +void extract_info(int qemu_argc, char **qemu_argv) { int i; - for(i = 0; i < qemu_argc; ++i) - { - if(strstr(qemu_argv[i], IMAGE_PATH_PREFIX) != NULL) { + for (i = 0; i < qemu_argc; ++i) { + if (strstr(qemu_argv[i], IMAGE_PATH_PREFIX) != NULL) { set_image_and_log_path(qemu_argv[i]); break; } } - + tizen_base_port = get_sdb_base_port(); } @@ -413,7 +397,9 @@ static void system_info(void) #ifdef CONFIG_SDL /* Gets the version of the dynamically linked SDL library */ INFO("* Host sdl version : (%d, %d, %d)\n", - SDL_Linked_Version()->major, SDL_Linked_Version()->minor, SDL_Linked_Version()->patch); + SDL_Linked_Version()->major, + SDL_Linked_Version()->minor, + SDL_Linked_Version()->patch); #endif #if defined(CONFIG_WIN32) @@ -423,8 +409,10 @@ static void system_info(void) osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx(&osvi)) { - INFO("* MajorVersion : %d, MinorVersion : %d, BuildNumber : %d, PlatformId : %d, CSDVersion : %s\n", - osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber, osvi.dwPlatformId, osvi.szCSDVersion); + INFO("* MajorVersion : %d, MinorVersion : %d, BuildNumber : %d, \ + PlatformId : %d, CSDVersion : %s\n", osvi.dwMajorVersion, + osvi.dwMinorVersion, osvi.dwBuildNumber, + osvi.dwPlatformId, osvi.szCSDVersion); } /* Retrieves information about the current system */ @@ -432,24 +420,29 @@ static void system_info(void) ZeroMemory(&sysi, sizeof(SYSTEM_INFO)); GetSystemInfo(&sysi); - INFO("* Processor type : %d, Number of processors : %d\n", sysi.dwProcessorType, sysi.dwNumberOfProcessors); + INFO("* Processor type : %d, Number of processors : %d\n", + sysi.dwProcessorType, sysi.dwNumberOfProcessors); MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); INFO("* Total Ram : %llu kB, Free: %lld kB\n", - memInfo.ullTotalPhys / DIV, memInfo.ullAvailPhys / DIV); + memInfo.ullTotalPhys / DIV, memInfo.ullAvailPhys / DIV); #elif defined(CONFIG_LINUX) /* depends on building */ INFO("* Qemu build machine linux kernel version : (%d, %d, %d)\n", - LINUX_VERSION_CODE >> 16, (LINUX_VERSION_CODE >> 8) & 0xff, LINUX_VERSION_CODE & 0xff); + LINUX_VERSION_CODE >> 16, + (LINUX_VERSION_CODE >> 8) & 0xff, + LINUX_VERSION_CODE & 0xff); /* depends on launching */ struct utsname host_uname_buf; if (uname(&host_uname_buf) == 0) { - INFO("* Host machine uname : %s %s %s %s %s\n", host_uname_buf.sysname, host_uname_buf.nodename, - host_uname_buf.release, host_uname_buf.version, host_uname_buf.machine); + INFO("* Host machine uname : %s %s %s %s %s\n", + host_uname_buf.sysname, host_uname_buf.nodename, + host_uname_buf.release, host_uname_buf.version, + host_uname_buf.machine); } struct sysinfo sys_info; @@ -464,10 +457,11 @@ static void system_info(void) char lscmd[MAXLEN] = "lspci >> "; strcat(lscmd, logpath); int i = system(lscmd); - INFO("system function command : %s, system function returned value : %d\n", lscmd, i); + INFO("system function command : %s, \ + system function returned value : %d\n", lscmd, i); #elif defined(CONFIG_DARWIN) - //TODO: + /* TODO: */ #endif INFO("\n"); @@ -482,24 +476,23 @@ void prepare_maru(void) construct_main_window(skin_argc, skin_argv, qemu_argc, qemu_argv); int guest_server_port = tizen_base_port + SDB_UDP_SENSOR_INDEX; - start_guest_server( guest_server_port ); + start_guest_server(guest_server_port); mloop_ev_init(); } -int qemu_main(int argc, char** argv, char** envp); +int qemu_main(int argc, char **argv, char **envp); -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { parse_options(argc, argv, &skin_argc, &skin_argv, &qemu_argc, &qemu_argv); - get_bin_dir( qemu_argv[0] ); + get_bin_dir(qemu_argv[0]); socket_init(); extract_info(qemu_argc, qemu_argv); INFO("Emulator start !!!\n"); - atexit(maru_atexit); - + check_shdmem(); make_shdmem(); sdb_setup(); @@ -507,25 +500,24 @@ int main(int argc, char* argv[]) system_info(); INFO("Prepare running...\n"); - redir_output(); // Redirect stdout, stderr after debug_ch is initialized... + /* Redirect stdout and stderr after debug_ch is initialized. */ + redir_output(); int i; - fprintf(stdout, "qemu args : ==========================================\n"); - for(i = 0; i < qemu_argc; ++i) - { + fprintf(stdout, "qemu args : =========================================\n"); + for (i = 0; i < qemu_argc; ++i) { fprintf(stdout, "%s ", qemu_argv[i]); } fprintf(stdout, "\n"); - fprintf(stdout, "======================================================\n"); + fprintf(stdout, "=====================================================\n"); - fprintf(stdout, "skin args : ==========================================\n"); - for(i = 0; i < skin_argc; ++i) - { + fprintf(stdout, "skin args : =========================================\n"); + for (i = 0; i < skin_argc; ++i) { fprintf(stdout, "%s ", skin_argv[i]); } fprintf(stdout, "\n"); - fprintf(stdout, "======================================================\n"); + fprintf(stdout, "=====================================================\n"); INFO("qemu main start!\n"); qemu_main(qemu_argc, qemu_argv, NULL); diff --git a/tizen/src/hw/maru_codec.c b/tizen/src/hw/maru_codec.c index 49ae2c26fd..6c3ec0d641 100644 --- a/tizen/src/hw/maru_codec.c +++ b/tizen/src/hw/maru_codec.c @@ -21,7 +21,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. * * Contributors: * - S-Core Co., Ltd @@ -39,7 +40,8 @@ */ #define MARU_CODEC_MMAP_MEM_SIZE (16 * 1024 * 1024) #define MARU_CODEC_MMAP_COUNT (4) -#define MARU_CODEC_MEM_SIZE (MARU_CODEC_MMAP_COUNT * MARU_CODEC_MMAP_MEM_SIZE) +#define MARU_CODEC_MEM_SIZE \ + (MARU_CODEC_MMAP_COUNT * MARU_CODEC_MMAP_MEM_SIZE) #define MARU_CODEC_REG_SIZE (256) #define MARU_ROUND_UP_16(num) (((num) + 15) & ~15) @@ -358,8 +360,6 @@ void qemu_get_codec_ver(SVCodecState *s) offset = s->codecParam.mmapOffset; ctxIndex = s->codecParam.ctxIndex; - printf("offset:%d\n", offset); - memset(codec_ver, 0, 32); pstrcpy(codec_ver, sizeof(codec_ver), MARU_CODEC_VERSION); @@ -915,7 +915,7 @@ int qemu_avcodec_encode_video(SVCodecState *s, int ctxIndex) ERR("[%s] failed to get input buffer\n", __func__); return ret; } - ret = avpicture_fill((AVPicture*)pict, inputBuf, avctx->pix_fmt, + ret = avpicture_fill((AVPicture *)pict, inputBuf, avctx->pix_fmt, avctx->width, avctx->height); if (ret < 0) { ERR("after avpicture_fill, ret:%d\n", ret); @@ -944,7 +944,7 @@ int qemu_avcodec_encode_video(SVCodecState *s, int ctxIndex) return ret; } -/* +/* * int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, * int *frame_size_ptr, AVPacket *avpkt) */ @@ -1063,7 +1063,7 @@ int qemu_avcodec_encode_audio(SVCodecState *s, int ctxIndex) */ void qemu_av_picture_copy(SVCodecState *s, int ctxIndex) { - AVCodecContext* avctx; + AVCodecContext *avctx; AVPicture dst; AVPicture *src; int numBytes; @@ -1086,7 +1086,7 @@ void qemu_av_picture_copy(SVCodecState *s, int ctxIndex) numBytes = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); - if (numBytes < 0 ) { + if (numBytes < 0) { ERR("[%s] failed to get size of pixel format:%d\n", __func__, avctx->pix_fmt); } @@ -1364,6 +1364,8 @@ uint64_t codec_read(void *opaque, target_phys_addr_t addr, unsigned size) switch (addr) { case CODEC_QUERY_STATE: ret = s->thread_state; + s->thread_state = 0; + TRACE("thread state: %d\n", s->thread_state); qemu_irq_lower(s->dev.irq[0]); break; default: @@ -1385,10 +1387,6 @@ void codec_write(void *opaque, target_phys_addr_t addr, case CODEC_API_INDEX: ret = codec_operate(value, s->codecParam.ctxIndex, s); break; - case CODEC_QUERY_STATE: - s->thread_state = value; - TRACE("worker thread s: %d\n", s->thread_state); - break; case CODEC_CONTEXT_INDEX: s->codecParam.ctxIndex = value; TRACE("Context Index: %d\n", s->codecParam.ctxIndex); @@ -1487,7 +1485,7 @@ int codec_init(PCIBus *bus) static PCIDeviceInfo codec_info = { .qdev.name = MARU_CODEC_DEV_NAME, .qdev.desc = "Virtual Codec device for Tizen emulator", - .qdev.size = sizeof (SVCodecState), + .qdev.size = sizeof(SVCodecState), .init = codec_initfn, .exit = codec_exitfn, .vendor_id = PCI_VENDOR_ID_TIZEN, diff --git a/tizen/src/hw/maru_codec.h b/tizen/src/hw/maru_codec.h index 4787fb30fe..9b8155fa04 100644 --- a/tizen/src/hw/maru_codec.h +++ b/tizen/src/hw/maru_codec.h @@ -20,7 +20,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. * * Contributors: * - S-Core Co., Ltd @@ -125,9 +126,12 @@ int encode_codec(SVCodecState *s); * Codec Device Functions */ int codec_init(PCIBus *bus); -uint64_t codec_read(void *opaque, target_phys_addr_t addr, unsigned size); -void codec_write (void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size); -int codec_operate(uint32_t apiIndex, uint32_t ctxIndex, SVCodecState *state); +uint64_t codec_read(void *opaque, target_phys_addr_t addr, + unsigned size); +void codec_write(void *opaque, target_phys_addr_t addr, + uint64_t value, unsigned size); +int codec_operate(uint32_t apiIndex, uint32_t ctxIndex, + SVCodecState *state); /* * Codec Helper Functions diff --git a/tizen/src/maru_common.h b/tizen/src/maru_common.h index 17ceb29f85..373e474ea5 100644 --- a/tizen/src/maru_common.h +++ b/tizen/src/maru_common.h @@ -3,7 +3,7 @@ * * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: + * Contact: * SeokYeon Hwang * HyunJun Son * MunKyu Im @@ -22,7 +22,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. * * Contributors: * - S-Core Co., Ltd diff --git a/tizen/src/maru_err_table.c b/tizen/src/maru_err_table.c index c862b2331c..5ff08c4e7a 100644 --- a/tizen/src/maru_err_table.c +++ b/tizen/src/maru_err_table.c @@ -3,7 +3,7 @@ * * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: + * Contact: * SeokYeon Hwang * GiWoong Kim * YeongKyoon Lee @@ -20,7 +20,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. * * Contributors: * - S-Core Co., Ltd @@ -41,20 +42,22 @@ /* This table must match the enum definition */ static char _maru_string_table[][JAVA_MAX_COMMAND_LENGTH] = { - /* 0 */ "", //MARU_EXIT_UNKNOWN - /* 1 */ "Failed to allocate memory in qemu.", //MARU_EXIT_MEMORY_EXCEPTION - /* 2 */ "Failed to load a kernel file the following path. Check if the file is corrupted or missing.\n\n", //MARU_EXIT_KERNEL_FILE_EXCEPTION - /* 3 */ "Failed to load a bios file the following path. Check if the file is corrupted or missing.\n\n", //MARU_EXIT_BIOS_FILE_EXCEPTION + /* 0 */ "", + /* 1 */ "Failed to allocate memory in qemu.", + /* 2 */ "Failed to load a kernel file the following path.\ +Check if the file is corrupted or missing.\n\n", + /* 3 */ "Failed to load a bios file the following path.\ +Check if the file is corrupted or missing.\n\n", /* 4 */ "Skin process cannot be initialized. Skin server is not ready.", /* add here.. */ - "" //MARU_EXIT_NORMAL + "" }; static int maru_exit_status = MARU_EXIT_NORMAL; static char maru_exit_msg[JAVA_MAX_COMMAND_LENGTH] = { 0, }; -void maru_register_exit_msg(int maru_exit_index, char* additional_msg) +void maru_register_exit_msg(int maru_exit_index, char *additional_msg) { int len = 0; @@ -66,19 +69,22 @@ void maru_register_exit_msg(int maru_exit_index, char* additional_msg) if (maru_exit_status != MARU_EXIT_UNKNOWN) { if (additional_msg != NULL) { - len = strlen(_maru_string_table[maru_exit_status]) + strlen(additional_msg) + 1; + len = strlen(_maru_string_table[maru_exit_status]) + + strlen(additional_msg) + 1; if (len > JAVA_MAX_COMMAND_LENGTH) { len = JAVA_MAX_COMMAND_LENGTH; } - snprintf(maru_exit_msg, len, "%s%s", _maru_string_table[maru_exit_status], additional_msg); + snprintf(maru_exit_msg, len, "%s%s", + _maru_string_table[maru_exit_status], additional_msg); } else { len = strlen(_maru_string_table[maru_exit_status]) + 1; if (len > JAVA_MAX_COMMAND_LENGTH) { len = JAVA_MAX_COMMAND_LENGTH; } - snprintf(maru_exit_msg, len, "%s", _maru_string_table[maru_exit_status]); + snprintf(maru_exit_msg, len, + "%s", _maru_string_table[maru_exit_status]); } } else if (additional_msg != NULL) { len = strlen(additional_msg); @@ -99,105 +105,97 @@ void maru_atexit(void) } } -char* maru_convert_path(char *msg, const char *path) +char *maru_convert_path(char *msg, const char *path) { - char* current_path = NULL; - char* err_msg = NULL; + char *current_path = NULL; + char *err_msg = NULL; #ifdef _WIN32 - char* dos_err_msg = NULL; -#endif - int total_len = 0; - int msg_len = 0; - int cur_path_len = 0; - int path_len = 0; - int res = -1; - - res = (int)g_path_is_absolute(path); - path_len = (strlen(path) + 1); - if (msg) { - msg_len = strlen(msg) + 1; - } - - if (!res) { - current_path = (char*)g_get_current_dir(); - cur_path_len = strlen(current_path) + strlen("/") + 1; - total_len += cur_path_len; - } - total_len += (path_len + msg_len); - - err_msg = g_malloc0(total_len * sizeof(char)); -#if 0 - if (!err_msg) { - fprintf(stderr, "failed to allocate memory\n"); - if (current_path) { - g_free(current_path); - } - return NULL; - } + char *dos_err_msg = NULL; #endif + int total_len = 0; + int msg_len = 0; + int cur_path_len = 0; + int path_len = 0; + int res = -1; + + res = (int)g_path_is_absolute(path); + path_len = (strlen(path) + 1); + if (msg) { + msg_len = strlen(msg) + 1; + } + + if (!res) { + current_path = (char *)g_get_current_dir(); + cur_path_len = strlen(current_path) + strlen("/") + 1; + total_len += cur_path_len; + } + total_len += (path_len + msg_len); - if (msg) { - snprintf(err_msg, msg_len, "%s", msg); - total_len = msg_len - 1; - } else { - total_len = 0; - } + err_msg = g_malloc0(total_len * sizeof(char)); - if (!res) { - snprintf(err_msg + total_len, cur_path_len, "%s%s", current_path, "/"); - total_len += (cur_path_len - 1); - } - snprintf(err_msg + total_len, path_len, "%s", path); + if (msg) { + snprintf(err_msg, msg_len, "%s", msg); + total_len = msg_len - 1; + } else { + total_len = 0; + } + + if (!res) { + snprintf(err_msg + total_len, cur_path_len, "%s%s", current_path, "/"); + total_len += (cur_path_len - 1); + } + snprintf(err_msg + total_len, path_len, "%s", path); #ifdef _WIN32 - { - int i; - - dos_err_msg = g_strdup(err_msg); - if (!dos_err_msg) { - printf(stderr, "failed to duplicate an error message from %p\n", err_msg); - if (current_path) { - g_free(current_path); - } - g_free(err_msg); - return NULL; - } - - for (i = (total_len - 1); dos_err_msg[i]; i++) { - if (dos_err_msg[i] == '/') { - dos_err_msg[i] = '\\'; - } - } - pstrcpy(err_msg, sizeof(err_msg), dos_err_msg); - g_free(dos_err_msg); - } + { + int i; + + dos_err_msg = g_strdup(err_msg); + if (!dos_err_msg) { + printf(stderr, + "failed to duplicate an error message from %p\n", err_msg); + if (current_path) { + g_free(current_path); + } + g_free(err_msg); + return NULL; + } + + for (i = (total_len - 1); dos_err_msg[i]; i++) { + if (dos_err_msg[i] == '/') { + dos_err_msg[i] = '\\'; + } + } + pstrcpy(err_msg, sizeof(err_msg), dos_err_msg); + g_free(dos_err_msg); + } #endif - if (current_path) { - g_free(current_path); - } + if (current_path) { + g_free(current_path); + } - return err_msg; + return err_msg; } -// for pirnt 'backtrace' +/* Print 'backtrace' */ #ifdef _WIN32 struct frame_layout { - void* pNext; - void* pReturnAddr; + void *pNext; + void *pReturnAddr; }; -static char * aqua_get_filename_from_path(char * path_buf){ - char * ret_slash; - char * ret_rslash; +static char *aqua_get_filename_from_path(char *path_buf) +{ + char *ret_slash; + char *ret_rslash; ret_slash = strrchr(path_buf, '/'); ret_rslash = strrchr(path_buf, '\\'); - if(ret_slash || ret_rslash){ - if(ret_slash > ret_rslash){ + if (ret_slash || ret_rslash) { + if (ret_slash > ret_rslash) { return ret_slash + 1; - } - else{ + } else{ return ret_rslash + 1; } } @@ -208,44 +206,42 @@ static char * aqua_get_filename_from_path(char * path_buf){ static HMODULE aqua_get_module_handle(DWORD dwAddress) { - MEMORY_BASIC_INFORMATION Buffer; - return VirtualQuery((LPCVOID) dwAddress, &Buffer, sizeof(Buffer)) ? (HMODULE) Buffer.AllocationBase : (HMODULE) 0; + MEMORY_BASIC_INFORMATION Buffer; + return VirtualQuery((LPCVOID) dwAddress, &Buffer, sizeof(Buffer)) + ? (HMODULE) Buffer.AllocationBase : (HMODULE) 0; } #endif -void maru_dump_backtrace(void* ptr, int depth) +void maru_dump_backtrace(void *ptr, int depth) { #ifdef _WIN32 - int nCount; - void* pTopFrame; - struct frame_layout currentFrame; - struct frame_layout * pCurrentFrame; + int nCount; + void *pTopFrame; + struct frame_layout currentFrame; + struct frame_layout *pCurrentFrame; char module_buf[1024]; HMODULE hModule; PCONTEXT pContext = ptr; - if(!pContext){ - __asm__ __volatile__ ( - "movl %%ebp, %0" - : "=m" (pTopFrame) - ); + if (!pContext) { + __asm__ __volatile__ ("movl %%ebp, %0" : "=m" (pTopFrame)); } else { - pTopFrame = (void*)((PCONTEXT)pContext)->Ebp; + pTopFrame = (void *)((PCONTEXT)pContext)->Ebp; } nCount = 0; - currentFrame.pNext = ((struct frame_layout*)pTopFrame)->pNext; - currentFrame.pReturnAddr = ((struct frame_layout*)pTopFrame)->pReturnAddr; - pCurrentFrame = (struct frame_layout*)pTopFrame; + currentFrame.pNext = ((struct frame_layout *)pTopFrame)->pNext; + currentFrame.pReturnAddr = ((struct frame_layout *)pTopFrame)->pReturnAddr; + pCurrentFrame = (struct frame_layout *)pTopFrame; - fprintf(stderr, "\nBacktrace Dump Start : \n"); - if(pContext){ + fprintf(stderr, "\nBacktrace Dump Start :\n"); + if (pContext) { fprintf(stderr, "[%02d]Addr = 0x%p", nCount, ((PCONTEXT)pContext)->Eip); memset(module_buf, 0, sizeof(module_buf)); hModule = aqua_get_module_handle((DWORD)((PCONTEXT)pContext)->Eip); - if(hModule){ - if(!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))){ + if (hModule) { + if (!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))) { memset(module_buf, 0, sizeof(module_buf)); } } @@ -253,52 +249,54 @@ void maru_dump_backtrace(void* ptr, int depth) nCount++; } - while (1){ - if ((void*)pCurrentFrame < pTopFrame || (void*)pCurrentFrame >= (void*)0xC0000000){ - break; + while (1) { + if (((void *)pCurrentFrame < pTopFrame) + || ((void *)pCurrentFrame >= (void *)0xC0000000)) { + break; } fprintf(stderr, "[%02d]Addr = 0x%p", nCount, currentFrame.pReturnAddr); memset(module_buf, 0, sizeof(module_buf)); hModule = aqua_get_module_handle((DWORD)currentFrame.pReturnAddr); - if(hModule){ - if(!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))){ + if (hModule) { + if (!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))) { memset(module_buf, 0, sizeof(module_buf)); } } fprintf(stderr, " : %s\n", aqua_get_filename_from_path(module_buf)); - if(!ReadProcessMemory(GetCurrentProcess(), currentFrame.pNext, (void*)¤tFrame, sizeof(struct frame_layout), NULL)){ + if (!ReadProcessMemory(GetCurrentProcess(), currentFrame.pNext, + (void *)¤tFrame, sizeof(struct frame_layout), NULL)) { break; } pCurrentFrame = (struct frame_layout *)pCurrentFrame->pNext; - if(depth){ - if(!--depth){ + if (depth) { + if (!--depth) { break; } } nCount++; } #else - int i, ndepth; - void* trace[1024]; - char** symbols; + int i, ndepth; + void *trace[1024]; + char **symbols; - fprintf(stderr, "\n Backtrace Dump Start : \n"); + fprintf(stderr, "\n Backtrace Dump Start :\n"); - ndepth = backtrace(trace, 1024); - fprintf(stderr, "Backtrace depth is %d. \n", ndepth); + ndepth = backtrace(trace, 1024); + fprintf(stderr, "Backtrace depth is %d.\n", ndepth); - symbols = backtrace_symbols(trace, ndepth); - if (symbols == NULL) { - fprintf(stderr, "'backtrace_symbols()' return error"); - return; - } + symbols = backtrace_symbols(trace, ndepth); + if (symbols == NULL) { + fprintf(stderr, "'backtrace_symbols()' return error"); + return; + } - for (i = 0; i < ndepth; i++) { - fprintf(stderr,"%s\n", symbols[i]); - } - free(symbols); + for (i = 0; i < ndepth; i++) { + fprintf(stderr, "%s\n", symbols[i]); + } + free(symbols); #endif } diff --git a/tizen/src/maru_err_table.h b/tizen/src/maru_err_table.h index 491bd01584..6d127bbbaa 100644 --- a/tizen/src/maru_err_table.h +++ b/tizen/src/maru_err_table.h @@ -3,7 +3,7 @@ * * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: + * Contact: * SeokYeon Hwang * GiWoong Kim * YeongKyoon Lee @@ -20,7 +20,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. * * Contributors: * - S-Core Co., Ltd @@ -35,8 +36,8 @@ /* TODO: define macro for fair of definition */ - -enum { //This enum must match the table definition +/* This enum must match the table definition */ +enum { /* 0 */ MARU_EXIT_UNKNOWN = 0, /* 1 */ MARU_EXIT_MEMORY_EXCEPTION, /* 2 */ MARU_EXIT_KERNEL_FILE_EXCEPTION, @@ -47,9 +48,9 @@ enum { //This enum must match the table definition }; -void maru_register_exit_msg(int maru_exit_status, char* additional_msg); +void maru_register_exit_msg(int maru_exit_status, char *additional_msg); void maru_atexit(void); -char* maru_convert_path(char *msg, const char *path); -void maru_dump_backtrace(void* ptr, int depth); +char *maru_convert_path(char *msg, const char *path); +void maru_dump_backtrace(void *ptr, int depth); #endif /* __EMUL_ERR_TABLE_H__ */