4 * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
7 * DoHyung Hong <don.hong@samsung.com>
8 * SeokYeon Hwang <syeon.hwang@samsung.com>
9 * Hyunjun Son <hj79.son@samsung.com>
10 * SangJin Kim <sangjin3.kim@samsung.com>
11 * MunKyu Im <munkyu.im@samsung.com>
12 * KiTae Kim <kt920.kim@samsung.com>
13 * JinHyung Jo <jinhyung.jo@samsung.com>
14 * SungMin Ha <sungmin82.ha@samsung.com>
15 * JiHye Kim <jihye1128.kim@samsung.com>
16 * GiWoong Kim <giwoong.kim@samsung.com>
17 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
18 * DongKyun Yun <dk77.yun@samsung.com>
20 * This program is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License
22 * as published by the Free Software Foundation; either version 2
23 * of the License, or (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
40 #include "configuration.h"
44 //DEFAULT_DEBUG_CHANNEL(tizen);
45 MULTI_DEBUG_CHANNEL(tizen, configuration);
47 #define EMUL_PIXELFORMAT_YUV422P 1
48 #define EMUL_PIXELFORMAT_YUV420P 2
50 #define RESOLUTION_COUNT 4
51 #define BUTTON_TYPE_COUNT 4
54 * *** config *** (target_path)
56 * If emulator.conf exists & target name is created by user, check platform config and so (set ld config and script path)
57 * Else if emulator.conf exist & target is create by installer, read emulator.conf, nothing do by platform.conf
58 * Else if emulator.conf no exist
59 * release type of platform exist ->
60 * release type of platform no exist -> default X2 -> create popup -> by select, change configuration & systeminfo
62 * A. configuration (char *)
63 * init (configuration.c init_structure - alloc) int init_configuration();
64 * copy (sprintf, strcpy, pointer, strdup); -> sprintf
65 * reload (by target path & skin path) (sprintf, strcpy, pointer, strdup) -> sprintf
66 * destroy (configuration.c destroy_structure - free) destroy_structure(); -> remove
68 * B. systeminfo (platform_type - char *)
78 * @brief set information to default init configuration structure
79 * @param status: CONF_INIT_MODE, CONF_DEFAULT_MODE, CONF_EXIST_STARTUP_MODE
84 int fill_configuration(int status)
86 int default_telnet_port = 1200;
87 const gchar *data_path = get_data_path();
89 /* 1. startup option parsing */
91 /* 1.3 target setting */
93 if (strlen(startup_option.disk) > 0) {
94 configuration.qemu_configuration.diskimg_type = 1;
95 if(strcmp(SYSTEMINFO.virtual_target_name, "default") == 0)
96 strcpy(configuration.qemu_configuration.diskimg_path, startup_option.disk);
101 snprintf(configuration.qemu_configuration.diskimg_path, MAXBUF, "%s/coronado-simulator.img",data_path);
103 snprintf(configuration.qemu_configuration.diskimg_path, MAXBUF, "%s/protector-simulator.img",data_path);
107 /* 2. CONF_INIT_MODE / CONF_EXIST_STARTUP_MODE*/
109 if (status == CONF_INIT_MODE) {
111 configuration.always_on_top = 0;
112 /* 2.1 emulator config initial */
114 configuration.enable_shell = 1;
116 configuration.enable_shell = 0;
118 configuration.enable_telephony_emulator = 0;
119 configuration.enable_gpsd = 0;
120 configuration.enable_compass = 0;
122 configuration.main_x = 100;
123 configuration.main_y = 100;
125 /* 2.2 qemu config initial */
127 configuration.qemu_configuration.use_host_http_proxy = 1;
128 configuration.qemu_configuration.use_host_dns_server = 1;
129 // snprintf(configuration.qemu_configuration.sdcard_path, MAXBUF, "%s/sdcard.img",data_path);
131 // configuration.qemu_configuration.sdcard_type = 0;
132 configuration.qemu_configuration.telnet_type = 1;
136 while(check_port(LOCALHOST, default_telnet_port) == 0 )
137 default_telnet_port += 3;
139 snprintf(configuration.qemu_configuration.telnet_port, MAXBUF, "%d", default_telnet_port);
141 /* serial console command ==> start */
142 configuration.qemu_configuration.serial_console_command_type = 0;
143 snprintf(configuration.qemu_configuration.serial_console_command, MAXBUF, "/usr/bin/putty -telnet -P %s localhost",configuration.qemu_configuration.telnet_port);
145 // configuration.qemu_configuration.snapshot_saved = 0;
150 else if (status == CONF_EXIST_STARTUP_MODE) {
154 INFO( "Configuration Structure fill error !\n");
161 * @brief get config value list from emulator.conf file
162 * @param filename: configuration file path, group: EMULATOR_GROUP, field: RUNAPP_RECENT_LIST_KEY, CONFIGURATION
163 * @return fail(0), success(value)
166 PROGRAMNAME *get_config_value_list(gchar *filepath, const gchar *group, const gchar *field)
169 GError *error = NULL;
170 gchar **value = NULL;
174 static PROGRAMNAME runapp_info[5];
176 keyfile = g_key_file_new();
178 if (!g_key_file_load_from_file(keyfile, filepath, G_KEY_FILE_KEEP_COMMENTS, &error)) {
179 INFO("loading key file form %s is failed\n", filepath );
180 g_error("%s", error->message);
184 value = g_key_file_get_string_list(keyfile, group, field, &length, &error);
186 if ( value != NULL) {
187 for (i = 0; i < (length / 2); i++) {
188 runapp_info[i].nDate = atoi(*(value + (i * 2)));
189 g_strlcpy(runapp_info[i].arName, *(value + (i * 2) + 1), sizeof runapp_info[i].arName);
194 g_key_file_free(keyfile);
200 * @brief create configuration file if it doesn't exist and each field of configuration file sets default value
201 * @param filename : configuration file path (ex: /opt/xo-sim/conf/emulator.conf, emulator0.conf)
205 int create_config_file(gchar* filepath)
207 FILE *fp = g_fopen(filepath, "w+");
210 g_fprintf (fp, "[%s]\n", COMMON_GROUP);
211 g_fprintf (fp, "%s=\n",ALWAYS_ON_TOP_KEY);
213 g_fprintf (fp, "\n[%s]\n", EMULATOR_GROUP);
214 g_fprintf (fp, "%s=\n",TERMINAL_TYPE_KEY );
215 g_fprintf (fp, "%s=\n", ENABLE_SHELL_KEY);
216 g_fprintf (fp, "%s=\n", ENABLE_TELEPHONY_EMULATOR_KEY);
217 g_fprintf (fp, "%s=\n", ENABLE_GPSD_KEY);
218 g_fprintf (fp, "%s=\n", ENABLE_COMPASS_KEY);
219 g_fprintf (fp, "%s=\n", CMD_TYPE_KEY);
221 g_fprintf (fp, "%s=\n", MAIN_X_KEY);
222 g_fprintf (fp, "%s=\n", MAIN_Y_KEY);
223 g_fprintf (fp, "%s=\n", SCALE_KEY);
225 g_fprintf (fp, "\n[%s]\n", QEMU_GROUP);
226 g_fprintf (fp, "%s=\n", HTTP_PROXY_KEY);
227 g_fprintf (fp, "%s=\n", DNS_SERVER_KEY);
228 g_fprintf (fp, "%s=\n", TELNET_TYPE_KEY);
229 g_fprintf (fp, "%s=\n", TELNET_PORT_KEY);
230 g_fprintf (fp, "%s=\n", TELNET_CONSOLE_COMMAND_TYPE_KEY);
231 g_fprintf (fp, "%s=\n", TELNET_CONSOLE_COMMAND_KEY);
232 // g_fprintf (fp, "%s=\n", SDCARD_TYPE_KEY);
233 // g_fprintf (fp, "%s=\n", SDCARD_PATH_KEY);
234 // g_fprintf (fp, "%s=\n", DISK_TYPE_KEY);
235 // g_fprintf (fp, "%s=\n", DISK_PATH_KEY);
236 g_fprintf (fp, "%s=1\n", SAVEVM_KEY);
237 // g_fprintf (fp, "%s=\n", SNAPSHOT_SAVED_KEY);
238 // g_fprintf (fp, "%s=\n", SNAPSHOT_SAVED_DATE_KEY);
243 ERR( "Can't open file path. (%s)\n", filepath);
247 g_chmod(filepath, 0666);
254 * @brief write configuration structure value in conf file (emulator.conf)
255 * @param filename : configuration file path (ex: /opt/xo-sim/conf/emulator.conf), CONFIGURATION
259 int write_config_file(gchar *filepath, CONFIGURATION *pconfiguration)
261 set_config_type(filepath, COMMON_GROUP, ALWAYS_ON_TOP_KEY, pconfiguration->always_on_top);
262 set_config_type(filepath, EMULATOR_GROUP, ENABLE_SHELL_KEY, pconfiguration->enable_shell);
263 set_config_type(filepath, EMULATOR_GROUP, ENABLE_TELEPHONY_EMULATOR_KEY, pconfiguration->enable_telephony_emulator);
264 set_config_type(filepath, EMULATOR_GROUP, ENABLE_GPSD_KEY, pconfiguration->enable_gpsd);
265 set_config_type(filepath, EMULATOR_GROUP, ENABLE_COMPASS_KEY, pconfiguration->enable_compass);
266 set_config_type(filepath, EMULATOR_GROUP, CMD_TYPE_KEY, pconfiguration->cmd_type);
267 set_config_type(filepath, EMULATOR_GROUP, MAIN_X_KEY, pconfiguration->main_x);
268 set_config_type(filepath, EMULATOR_GROUP, MAIN_Y_KEY, pconfiguration->main_y);
269 set_config_type(filepath, EMULATOR_GROUP, SCALE_KEY, pconfiguration->scale);
271 /* QEMU option (09.05.26)*/
273 set_config_type(filepath, QEMU_GROUP, HTTP_PROXY_KEY, pconfiguration->qemu_configuration.use_host_http_proxy);
274 set_config_type(filepath, QEMU_GROUP, DNS_SERVER_KEY, pconfiguration->qemu_configuration.use_host_dns_server);
275 set_config_type(filepath, QEMU_GROUP, TELNET_TYPE_KEY, pconfiguration->qemu_configuration.telnet_type);
276 set_config_value(filepath, QEMU_GROUP, TELNET_PORT_KEY, pconfiguration->qemu_configuration.telnet_port);
278 set_config_type(filepath, QEMU_GROUP, TELNET_CONSOLE_COMMAND_TYPE_KEY, pconfiguration->qemu_configuration.serial_console_command_type);
279 set_config_value(filepath, QEMU_GROUP, TELNET_CONSOLE_COMMAND_KEY, pconfiguration->qemu_configuration.serial_console_command);
281 // set_config_type(filepath, QEMU_GROUP, SDCARD_TYPE_KEY, pconfiguration->qemu_configuration.sdcard_type);
282 // set_config_value(filepath, QEMU_GROUP, SDCARD_PATH_KEY, pconfiguration->qemu_configuration.sdcard_path);
283 set_config_type(filepath, QEMU_GROUP, SAVEVM_KEY, pconfiguration->qemu_configuration.save_emulator_state);
284 // set_config_type(filepath, QEMU_GROUP, SNAPSHOT_SAVED_KEY, pconfiguration->qemu_configuration.snapshot_saved);
285 // set_config_value(filepath, QEMU_GROUP, SNAPSHOT_SAVED_DATE_KEY, pconfiguration->qemu_configuration.snapshot_saved_date);
292 * @brief read conf value and save in configuration structure from config file (emulator.conf)
293 * @param filename : configuration file path, CONFIGURATION
294 * @return fail(-1), success(0)
297 int read_config_file(gchar *filepath, CONFIGURATION *pconfiguration)
302 pconfiguration->always_on_top = get_config_type(filepath, COMMON_GROUP, ALWAYS_ON_TOP_KEY);
304 pconfiguration->qemu_configuration.use_host_http_proxy = get_config_type(filepath, QEMU_GROUP, HTTP_PROXY_KEY);
305 pconfiguration->qemu_configuration.use_host_dns_server = get_config_type(filepath, QEMU_GROUP, DNS_SERVER_KEY);
307 /* option menu config parsed */
308 gchar *sdb_path = get_sdb_path();
309 if (access(sdb_path, 0) == 0) {
310 pconfiguration->enable_shell = get_config_type(filepath, EMULATOR_GROUP, ENABLE_SHELL_KEY);
314 pconfiguration->enable_telephony_emulator = get_config_type(filepath, EMULATOR_GROUP, ENABLE_TELEPHONY_EMULATOR_KEY);
315 pconfiguration->enable_gpsd = get_config_type(filepath, EMULATOR_GROUP, ENABLE_GPSD_KEY);
316 pconfiguration->enable_compass = get_config_type(filepath, EMULATOR_GROUP, ENABLE_COMPASS_KEY);
317 pconfiguration->cmd_type = get_config_type(filepath, EMULATOR_GROUP, CMD_TYPE_KEY);
319 pconfiguration->main_x = get_config_type(filepath, EMULATOR_GROUP, MAIN_X_KEY);
320 pconfiguration->main_y = get_config_type(filepath, EMULATOR_GROUP, MAIN_Y_KEY);
321 pconfiguration->scale = get_config_type(filepath, EMULATOR_GROUP, SCALE_KEY);
324 buf = get_config_value(filepath, QEMU_GROUP, TELNET_PORT_KEY);
326 telnet_port = atoi(buf);
328 while(check_port(LOCALHOST, telnet_port) == 0)
331 snprintf(pconfiguration->qemu_configuration.telnet_port, MAXBUF, "%d", telnet_port);
335 pconfiguration->qemu_configuration.telnet_type = get_config_type(filepath, QEMU_GROUP, TELNET_TYPE_KEY);
337 pconfiguration->qemu_configuration.serial_console_command_type = get_config_type(filepath, QEMU_GROUP, TELNET_CONSOLE_COMMAND_TYPE_KEY);
339 buf = get_config_value(filepath, QEMU_GROUP, TELNET_CONSOLE_COMMAND_KEY);
342 snprintf(pconfiguration->qemu_configuration.serial_console_command, MAXBUF, "%s", buf);
346 /* pconfiguration->qemu_configuration.sdcard_type = get_config_type(filepath, QEMU_GROUP, SDCARD_TYPE_KEY);
348 buf = get_config_value(filepath, QEMU_GROUP, SDCARD_PATH_KEY);
350 snprintf(pconfiguration->qemu_configuration.sdcard_path, MAXBUF, "%s", buf);
353 pconfiguration->qemu_configuration.save_emulator_state = get_config_type(filepath, QEMU_GROUP, SAVEVM_KEY);
355 /* pconfiguration->qemu_configuration.snapshot_saved = get_config_type(filepath, QEMU_GROUP, SNAPSHOT_SAVED_KEY);
357 buf = get_config_value(filepath, QEMU_GROUP, SNAPSHOT_SAVED_DATE_KEY);
359 snprintf(pconfiguration->qemu_configuration.snapshot_saved_date, MAXBUF, "%s", buf);
366 int read_virtual_target_info_file(gchar *virtual_target_name, VIRTUALTARGETINFO *pvirtual_target_info)
369 int info_file_status;
370 char *virtual_target_path;
374 virtual_target_path = get_virtual_target_path(virtual_target_name);
375 info_file = g_strdup_printf("%sconfig.ini", virtual_target_path);
376 info_file_status = is_exist_file(info_file);
378 if(info_file_status == -1 || info_file_status == FILE_NOT_EXISTS)
380 ERR( "target info file not exists : %s\n", virtual_target_name);
384 snprintf(pvirtual_target_info->virtual_target_name, MAXBUF, "%s", virtual_target_name);
386 buf = get_config_value(info_file, HARDWARE_GROUP, RESOLUTION_KEY);
387 snprintf(pvirtual_target_info->resolution, MAXBUF, "%s", buf);
390 pvirtual_target_info->button_type = get_config_type(info_file, HARDWARE_GROUP, BUTTON_TYPE_KEY);
392 pvirtual_target_info->sdcard_type = get_config_type(info_file, HARDWARE_GROUP, SDCARD_TYPE_KEY);
393 if(pvirtual_target_info->sdcard_type == 0)
395 memset(pvirtual_target_info->sdcard_path, 0x00, MAXBUF);
399 buf = get_config_value(info_file, HARDWARE_GROUP, SDCARD_PATH_KEY);
400 snprintf(pvirtual_target_info->sdcard_path, MAXBUF, "%s", buf);
404 pvirtual_target_info->ram_size = get_config_type(info_file, HARDWARE_GROUP, RAM_SIZE_KEY);
406 buf = get_config_value(info_file, HARDWARE_GROUP, DISK_PATH_KEY);
407 // buf = get_virtual_target_path(virtual_target_name);
408 if(!buf && strlen(startup_option.disk) > 0)
409 buf = startup_option.disk;
410 snprintf(pvirtual_target_info->diskimg_path, MAXBUF, "%s", buf);
413 pvirtual_target_info->snapshot_saved = get_config_type(info_file, ETC_GROUP, SNAPSHOT_SAVED_KEY);
414 if(pvirtual_target_info->snapshot_saved == 0)
416 memset(pvirtual_target_info->snapshot_saved_date, 0x00, MAXBUF);
420 buf = get_config_value(info_file, ETC_GROUP, SNAPSHOT_SAVED_DATE_KEY);
421 snprintf(pvirtual_target_info->snapshot_saved_date, MAXBUF, "%s", buf);
425 /* get DPI info from config.ini */
426 buf = get_config_value(info_file, HARDWARE_GROUP, DPI_KEY);
427 snprintf(pvirtual_target_info->dpi, MAXBUF, "%s", buf);
428 //fprintf(stderr, "DPI = %s\n", pvirtual_target_info->dpi);
430 g_free(virtual_target_path);
437 /* sanity check on target path */
438 int is_valid_target(const gchar *path)
440 if (g_file_test(path, G_FILE_TEST_IS_DIR | G_FILE_TEST_EXISTS) == FALSE) {
441 ERR( "target file: %s is not exist.\n", path);
450 * @brief check about skin
451 * @param filename : skin path (ex: /opt/xo-sim/skins/320x320/320x320_1FB.dbi)
452 * @return 0 fail, 1 success
455 int is_valid_skin (gchar *file)
460 if ((g_file_test(file, G_FILE_TEST_EXISTS) != FALSE) && g_str_has_suffix (file, ".dbi"))
468 * @brief get emulator config filepath for status
469 * @return exist normal(1), not exist(0), error(-1)
473 int is_valid_targetlist_file()
476 gchar *targetlist_filepath = NULL;
478 targetlist_filepath = get_targetlist_filepath();
480 status = is_exist_file(targetlist_filepath);
483 sprintf(SYSTEMINFO.conf_file, "%s", targetlist_filepath);
486 g_free(targetlist_filepath);
493 * @brief load emulator.conf and create config_window for conf file status
494 * @param SYSTEMINFO(SYSTEMINFO.conf_file)
495 * @return fail(-1), success(0)
498 int load_targetlistig_file(SYSINFO *pSYSTEMINFO)
502 char *virtual_target_path;
505 int target_list_status = is_valid_target_list_file(pSYSTEMINFO);
506 if(target_list_status == -1 || target_list_status == FILE_NOT_EXISTS)
508 ERR( "load target list file error\n");
512 int virtual_target_info_status = read_virtual_target_info_file(startup_option.vtm, &virtual_target_info);
513 if(virtual_target_info_status == -1)
515 ERR( "load target info file error\n");
520 snprintf(pSYSTEMINFO->virtual_target_name, MAXBUF, "%s", startup_option.vtm);
521 // virtual_target_path = get_virtual_target_path(startup_option.vtm);
522 virtual_target_path = get_virtual_target_path(startup_option.vtm);
523 info_file = g_strdup_printf("%sconfig.ini", virtual_target_path);
524 snprintf(pSYSTEMINFO->virtual_target_info_file, MAXPATH, "%s", info_file);
527 g_free(virtual_target_path);
530 status = is_valid_targetlist_file();
535 fill_configuration(CONF_EXIST_STARTUP_MODE);
537 result = read_config_file(SYSTEMINFO.virtual_target_info_file, &configuration);
539 // if (result == -1) {
540 // fill_configuration(CONF_INIT_MODE);
544 case FILE_NOT_EXISTS :
545 // fill_configuration(CONF_INIT_MODE);
546 // if ((strlen(configuration.target_path) < 2))
547 // create_config_file(SYSTEMINFO.virtual_target_info_file);
548 ERR( "load emulator config file \n");
553 ERR( "Emulator config file not exists!\n");
558 // write_config_file(SYSTEMINFO.virtual_target_info_file, &configuration);
559 startup_option_config_done = 1;
566 * @brief load conf file
568 * @return success 0, fail -1
571 int load_config_file(SYSINFO *pSYSTEMINFO)
573 // INFO( "default_target = %s \n", configuration.target_path);
575 /* 2. emulator config file load (emulator.conf) */
577 if (load_targetlistig_file(pSYSTEMINFO) == -1) {
578 ERR( "load emulator.conf file error!!\n");
586 int determine_skin(VIRTUALTARGETINFO *pvirtual_target_info, CONFIGURATION *pconfiguration)
589 int resolution_found = 0;
592 char *resolution[RESOLUTION_COUNT] = {"320x480", "480x800", "600x1024", "720x1280"};
593 char *button_types[BUTTON_TYPE_COUNT] = {"","","not_use_","3keys_"};
595 for(i = 0; i < RESOLUTION_COUNT; i++)
597 if(strcmp(pvirtual_target_info->resolution, resolution[i]) == 0)
599 resolution_found = 1;
604 if(resolution_found == 0)
606 ERR( "unknown resolution\n");
610 button_type = pvirtual_target_info->button_type;
611 if (button_type !=0 && button_type != 1 && button_type != 3)
613 ERR( "unknown button type : %d\n", button_type);
617 skin = g_strdup(resolution[i]);
619 snprintf(pconfiguration->skin_path, MAXBUF, "%s/emul_%s%s/default.dbi", get_skin_path(), button_types[button_type], skin);
621 if(is_valid_skin(pconfiguration->skin_path) == 0)
623 ERR( "skin file is invalid\n");
634 * @brief callback when ok button clicked in option window
639 void qemu_option_set_to_config(arglist *al)
641 gboolean userdata_exist = FALSE;
643 const gchar *exec_path = get_exec_path();
645 int width = (int)(PHONE.mode[UISTATE.current_mode].lcd_list[0].lcd_region.w);
646 int height = (int)(PHONE.mode[UISTATE.current_mode].lcd_list[0].lcd_region.h);
647 int bpp = (int)(PHONE.mode[UISTATE.current_mode].lcd_list[0].bitsperpixel);
649 /* input kernel append*/
651 char kernel_kappend[MAXBUF] = {0, };
652 char fb1_format[MAXBUF] = {0, };
654 if (PHONE.mode[UISTATE.current_mode].lcd_list[1].bitsperpixel == 16)
655 sprintf(fb1_format, "rgb16");
656 else if (PHONE.mode[UISTATE.current_mode].lcd_list[1].bitsperpixel == 24)
657 sprintf(fb1_format, "rgb24");
658 else if(PHONE.mode[UISTATE.current_mode].lcd_list[1].nonstd == EMUL_PIXELFORMAT_YUV420P)
659 sprintf(fb1_format, "yuv420");
660 else if(PHONE.mode[UISTATE.current_mode].lcd_list[1].nonstd == EMUL_PIXELFORMAT_YUV422P)
661 sprintf(fb1_format, "yuv422");
665 if (qemu_arch_is_arm()){
666 /* duallcd command line is used in hw/s5pc1xx.c to change the board revision */
667 if(PHONE.dual_display == 1)
668 strcpy(kernel_kappend, "console=ttySAC2,115200n8 duallcd mem=80M mem=256M@0x40000000 mem=128@0x50000000 mtdparts=tizen-onenand:1m(bootloader),256k(params),2816k(config),8m(csa),7m(kernel),1m(log),12m(modem),60m(qboot),-(UBI) ");
670 strcpy(kernel_kappend, "console=ttySAC2,115200n8 mem=80M mem=256M@0x40000000 mem=128@0x50000000 mtdparts=tizen-onenand:1m(bootloader),256k(params),2816k(config),8m(csa),7m(kernel),1m(log),12m(modem),60m(qboot),-(UBI) ");
673 strcpy(kernel_kappend, "console=ttyS0 ");
677 if (!qemu_arch_is_arm()) {
678 if (strlen(fb1_format) > 0) /* Using Overlay */
679 sprintf(&kernel_kappend[strlen(kernel_kappend)],
680 "video=uvesafb:ywrap,overlay:%s,%dx%d-%d@60 ", fb1_format, width, height, bpp);
682 sprintf(&kernel_kappend[strlen(kernel_kappend)],
683 "video=uvesafb:ywrap,%dx%d-%d@60 ", width, height, bpp);
686 char proxy[MIDBUF] ={0}, hostip[MIDBUF] = {0}, dns1[MIDBUF] = {0}, dns2[MIDBUF] = {0};
689 if (configuration.qemu_configuration.use_host_http_proxy == 1)
690 sprintf(&kernel_kappend[strlen(kernel_kappend)], "proxy=%s ", proxy);
692 gethostDNS(dns1, dns2);
693 if (configuration.qemu_configuration.use_host_dns_server == 1) {
694 if (strlen(dns1)) sprintf(&kernel_kappend[strlen(kernel_kappend)], "dns1=%s ", dns1);
695 if (strlen(dns2)) sprintf(&kernel_kappend[strlen(kernel_kappend)], "dns2=%s ", dns2);
698 // handover Host IP address to kernel side
702 sprintf(&kernel_kappend[strlen(kernel_kappend)], "openglip=%s ", hostip);
706 sprintf(&kernel_kappend[strlen(kernel_kappend)], "sdb_port=%d ", get_sdb_base_port());
709 if (strlen(virtual_target_info.dpi))
710 sprintf(&kernel_kappend[strlen(kernel_kappend)], "dpi=%s ", virtual_target_info.dpi);
713 * for QEMU user mode networking (with -net user),
714 * our ip is 10.0.2.16, and the gateway is 10.0.2.2
715 * These address are hardcoded in QEMU
717 * For NFS to work /etc/exports should contain something like:
719 * /scratchbox/users/mike/targets 127.0.0.1(rw,all_squash,insecure,async,insecure_locks)
723 #define GUEST_IP_ADDRESS "10.0.2.16"
724 #define HOST_QEMU_ADDRESS "10.0.2.2"
725 #define BOOT_DRIVE "c"
726 #define KERNEL_LOGFILE_NAME "logs/emulator.klog"
729 if(!configuration.qemu_configuration.diskimg_type) {
730 sprintf(&kernel_kappend[strlen(kernel_kappend)], "root=/dev/nfs rw ");
731 sprintf(&kernel_kappend[strlen(kernel_kappend)], "nfsroot=" HOST_QEMU_ADDRESS ":%s,udp,port=%d,v3 ",
732 configuration.target_path, startup_option.mountPort);
736 if(qemu_arch_is_arm())
737 strcat(kernel_kappend, "root=/dev/hda ");
740 strcat(kernel_kappend, "root=/dev/vda rw ");
742 strcat(kernel_kappend, "root=/dev/hda rw ");
746 /* user mode networking */
748 if (qemu_arch_is_arm())
749 sprintf(&kernel_kappend[strlen(kernel_kappend)], "ip=" GUEST_IP_ADDRESS "::" HOST_QEMU_ADDRESS ":255.255.255.0::usb0:none ");
751 sprintf(&kernel_kappend[strlen(kernel_kappend)], "ip=" GUEST_IP_ADDRESS "::" HOST_QEMU_ADDRESS ":255.255.255.0::eth0:none ");
753 sprintf(&kernel_kappend[strlen(kernel_kappend)], "%d", startup_option.run_level);
755 append_argvlist(al, "%s", exec_path);
756 if (qemu_arch_is_arm()) {
757 if(configuration.qemu_configuration.diskimg_type) {
758 append_argvlist(al, "-hda");
759 append_argvlist(al, "%s", virtual_target_info.diskimg_path);
765 if(configuration.qemu_configuration.diskimg_type) {
766 append_argvlist(al, "-drive");
768 append_argvlist(al, "file=%s,if=virtio", virtual_target_info.diskimg_path);
770 append_argvlist(al, "file=%s", virtual_target_info.diskimg_path);
772 gchar userdata_buf[MAXBUF] = {0, };
773 char *target_name = basename(configuration.target_path);
774 snprintf(userdata_buf, MAXBUF, "%s/opt/%s-userdata.img", configuration.target_path, target_name);
775 if (is_exist_file(userdata_buf) == 1) {
776 append_argvlist(al, "-hdb");
777 append_argvlist(al, "%s", userdata_buf);
778 userdata_exist = TRUE;
783 append_argvlist(al, "-boot");
784 append_argvlist(al, "%s", BOOT_DRIVE);
786 /* snapshot boot set -loadvm snapshot option */
787 if(configuration.qemu_configuration.save_emulator_state) {
788 append_argvlist(al,"-loadvm");
789 append_argvlist(al,"snapshot");
792 append_argvlist(al, "-append");
793 append_argvlist(al, "%s", kernel_kappend);
795 if (!startup_option.no_dump) {
796 gchar kernel_log_path[MAXBUF] = {0, };
797 strcpy(kernel_log_path, get_virtual_target_path(startup_option.vtm));
798 strcat(kernel_log_path, KERNEL_LOGFILE_NAME);
799 append_argvlist(al, "-serial");
800 append_argvlist(al, "file:%s", kernel_log_path);
804 // else if (configuration.qemu_configuration.telnet_type == 1) {
805 append_argvlist(al, "-serial");
806 append_argvlist(al, "telnet:localhost:%s,server,nowait,ipv4",
807 configuration.qemu_configuration.telnet_port);
810 if (!qemu_arch_is_arm()) {
811 if(virtual_target_info.sdcard_type != 0) {
813 append_argvlist(al, "-drive");
814 append_argvlist(al, "file=%s,if=virtio", virtual_target_info.sdcard_path);
817 append_argvlist(al, "-hdc");
819 append_argvlist(al, "-hdb");
820 append_argvlist(al, "%s", virtual_target_info.sdcard_path);
825 append_argvlist(al, "-m");
826 append_argvlist(al, "%d", virtual_target_info.ram_size);
829 printf("startup option : \n\n");
830 printf("target : %s\n", startup_option.target);
831 printf("disk : %s\n", startup_option.disk);
832 printf("skin : %s\n", startup_option.skin);
833 printf("loglevel : %d\n", startup_option.log_level);
834 printf("runlevel : %d\n", startup_option.run_level);
835 printf("target_log : %d\n", startup_option.target_log);
836 printf("mountport : %d\n", startup_option.mountPort);
837 printf("sshport : %d\n", startup_option.ssh_port);
838 printf("telnetport : %d\n", startup_option.telnet_port);
839 printf("configuration : \n\n");
840 printf("shell %d, telephony %d, gpsd %d, compass %d, cmd_type %d, ",configuration.enable_shell
841 , configuration.enable_telephony_emulator, configuration.enable_gpsd, configuration.enable_compass
842 , configuration.cmd_type);
843 printf("mount_port %d, target_path : %s\n", configuration.mount_port, configuration.target_path);
844 printf("qemu configuration : \n\n");
845 printf("proxy %d, dns %d, telnetport %s, telnettype %d, sdcardtype %d\n",
846 configuration.qemu_configuration.use_host_http_proxy, configuration.qemu_configuration.use_host_dns_server,
847 configuration.qemu_configuration.telnet_port, configuration.qemu_configuration.telnet_type, configuration.qemu_configuration.sdcard_type);
848 printf("sdcardpath : %s, diskimg_type %d, diskimg_path %s\n",
849 configuration.qemu_configuration.sdcard_path, configuration.qemu_configuration.diskimg_type,
850 configuration.qemu_configuration.diskimg_path);
851 printf("console cmdtype %d, console cmd %s\n", configuration.qemu_configuration.serial_console_command_type,
852 configuration.qemu_configuration.serial_console_command);
853 printf("save state %d, saved %d, saved date %s\n\n", configuration.qemu_configuration.save_simulator_state,
854 configuration.qemu_configuration.snapshot_saved,
855 configuration.qemu_configuration.snapshot_saved_date);
860 const char *get_target_path(void)
862 return configuration.target_path;