#include "qemu_socket.h"
#include "build_info.h"
#include "maru_err_table.h"
-#include <glib.h>
#include <glib/gstdio.h>
+#include "qemu-config.h"
#if defined(CONFIG_WIN32)
#include <windows.h>
#endif
#include "mloop_event.h"
+#include "hw/maru_camera_common.h"
+#include "hw/gloffscreen_test.h"
MULTI_DEBUG_CHANNEL(qemu, main);
#define LOGFILE "emulator.log"
#define LCD_WIDTH_PREFIX "width="
#define LCD_HEIGHT_PREFIX "height="
+
#define MIDBUF 128
int tizen_base_port;
char tizen_target_img_path[MAXLEN];
char logpath[MAXLEN];
+int enable_gl = 0;
+int enable_yagl = 0;
+
+int is_webcam_enabled;
+
+#define LEN_MARU_KERNEL_CMDLINE 512
+gchar maru_kernel_cmdline[LEN_MARU_KERNEL_CMDLINE];
+
static int _skin_argc;
static char **_skin_argv;
static int _qemu_argc;
ERR("shmat failed\n");
return;
}
- sprintf(shared_memory, "%d", get_sdb_base_port() + 2);
+ sprintf(shared_memory, "%d", tizen_base_port + 2);
INFO("shared memory key: %d, value: %s\n", SHMKEY, (char *)shared_memory);
shmdt(shared_memory);
#endif
} else {
strcpy(tizen_target_path, g_path_get_dirname(path));
}
+
strcpy(tizen_target_img_path, path);
free(path);
+
strcpy(logpath, tizen_target_path);
strcat(logpath, LOGS_SUFFIX);
#ifdef CONFIG_WIN32
sys_info.freeram * (unsigned long long)sys_info.mem_unit / DIV);
}
- /* get linux distribution */
+ /* get linux distribution information */
INFO("* Linux distribution infomation :\n");
char lsb_release_cmd[MAXLEN] = "lsb_release -d -r -c >> ";
strcat(lsb_release_cmd, logpath);
INFO("\n");
}
+typedef struct {
+ const char *device_name;
+ int found;
+} device_opt_finding_t;
+
+static int find_device_opt (QemuOpts *opts, void *opaque)
+{
+ device_opt_finding_t *devp = (device_opt_finding_t *) opaque;
+ if (devp->found == 1) {
+ return 0;
+ }
+
+ const char *str = qemu_opt_get (opts, "driver");
+ if (strcmp (str, devp->device_name) == 0) {
+ devp->found = 1;
+ }
+ return 0;
+}
+
+#define DEFAULT_QEMU_DNS_IP "10.0.2.3"
+static void prepare_basic_features(void)
+{
+ char http_proxy[MIDBUF] ={0}, https_proxy[MIDBUF] = {0,},
+ ftp_proxy[MIDBUF] = {0,}, socks_proxy[MIDBUF] = {0,},
+ dns1[MIDBUF] = {0}, dns2[MIDBUF] = {0};
+
+ tizen_base_port = get_sdb_base_port();
+
+ gethostproxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
+ gethostDNS(dns1, dns2);
+
+ check_shdmem();
+ socket_init();
+ make_shdmem();
+
+ sdb_setup();
+
+ gchar * const tmp_str = g_strdup_printf(" sdb_port=%d,"
+ " http_proxy=%s https_proxy=%s ftp_proxy=%s socks_proxy=%s"
+ " dns1=%s", tizen_base_port,
+ http_proxy, https_proxy, ftp_proxy, socks_proxy,
+ dns1, dns2);
+
+ g_strlcat(maru_kernel_cmdline, tmp_str, LEN_MARU_KERNEL_CMDLINE);
+
+ g_free(tmp_str);
+}
+
+#define VIRTIOGL_DEV_NAME "virtio-gl-pci"
+#ifdef CONFIG_GL_BACKEND
+static void prepare_opengl_acceleration(void)
+{
+ int capability_check_gl = 0;
+
+ if (enable_gl && enable_yagl) {
+ ERR("Error: only one openGL passthrough device can be used at one time!\n");
+ exit(1);
+ }
+
+
+ if (enable_gl || enable_yagl) {
+ capability_check_gl = gl_acceleration_capability_check();
+
+ if (capability_check_gl != 0) {
+ enable_gl = enable_yagl = 0;
+ WARN("Warn: GL acceleration was disabled due to the fail of GL check!\n");
+ }
+ }
+ if (enable_gl) {
+ device_opt_finding_t devp = {VIRTIOGL_DEV_NAME, 0};
+ qemu_opts_foreach(qemu_find_opts("device"), find_device_opt, &devp, 0);
+ if (devp.found == 0) {
+ if (!qemu_opts_parse(qemu_find_opts("device"), VIRTIOGL_DEV_NAME, 1)) {
+ exit(1);
+ }
+ }
+ }
+
+ gchar * const tmp_str = g_strdup_printf(" gles=%d yagl=%d", enable_gl, enable_yagl);
+
+ g_strlcat(maru_kernel_cmdline, tmp_str, LEN_MARU_KERNEL_CMDLINE);
+
+ g_free(tmp_str);
+}
+#endif
+
+#define MARUCAM_DEV_NAME "maru_camera_pci"
+#define WEBCAM_INFO_IGNORE 0x00
+#define WEBCAM_INFO_WRITE 0x04
+static void prepare_host_webcam(void)
+{
+ is_webcam_enabled = marucam_device_check(WEBCAM_INFO_WRITE);
+
+ if (!is_webcam_enabled) {
+ INFO("[Webcam] <WARNING> Webcam support was disabled "
+ "due to the fail of webcam capability check!\n");
+ }
+ else {
+ device_opt_finding_t devp = {MARUCAM_DEV_NAME, 0};
+ qemu_opts_foreach(qemu_find_opts("device"), find_device_opt, &devp, 0);
+ if (devp.found == 0) {
+ if (!qemu_opts_parse(qemu_find_opts("device"), MARUCAM_DEV_NAME, 1)) {
+ INFO("Failed to initialize the marucam device.\n");
+ exit(1);
+ }
+ }
+ INFO("[Webcam] Webcam support was enabled.\n");
+ }
+
+ gchar * const tmp_str = g_strdup_printf(" enable_cam=%d", is_webcam_enabled);
+
+ g_strlcat(maru_kernel_cmdline, tmp_str, LEN_MARU_KERNEL_CMDLINE);
+
+ g_free(tmp_str);
+}
+
+const gchar * prepare_maru_devices(const gchar *kernel_cmdline)
+{
+ INFO("Prepare maru specified kernel command line\n");
+
+ g_strlcpy(maru_kernel_cmdline, kernel_cmdline, LEN_MARU_KERNEL_CMDLINE);
+
+ // Prepare basic features
+ prepare_basic_features();
+
+ // Prepare GL acceleration
+#ifdef CONFIG_GL_BACKEND
+ prepare_opengl_acceleration();
+#endif
+
+ // Prepare host webcam
+ prepare_host_webcam();
+
+ INFO("kernel command : %s\n", maru_kernel_cmdline);
+
+ return maru_kernel_cmdline;
+}
+
+int maru_device_check(QemuOpts *opts)
+{
+#if defined(CONFIG_GL_BACKEND)
+ // virtio-gl pci device
+ if (!enable_gl) {
+ // ignore virtio-gl-pci device, even if users set it in option.
+ const char *driver = qemu_opt_get(opts, "driver");
+ if (driver && (strcmp (driver, VIRTIOGL_DEV_NAME) == 0)) {
+ return -1;
+ }
+ }
+#endif
+ if (!is_webcam_enabled) {
+ const char *driver = qemu_opt_get(opts, "driver");
+ if (driver && (strcmp (driver, MARUCAM_DEV_NAME) == 0)) {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
void prepare_maru(void)
{
INFO("Prepare maru specified feature\n");
/**
* @file emulator.h
- * @brief - header of file these are config struecture and defines in emulator
+ * @brief - header file for emulator.c
*/
#ifndef __EMULATOR_H__
#define __EMULATOR_H__
+#include "maru_common.h"
+
#define MAXLEN 512
#define MAXPACKETLEN 60
#define SHMKEY 26099
void prepare_maru(void);
void check_shdmem(void);
void make_shdmem(void);
+
+const gchar * prepare_maru_devices(const gchar * kernel_cmdline);
+// FIXME: Necessary declaration of functions but produces error difficult to solve now
+//int maru_device_check(QemuOpts *opts);
#endif /* __EMULATOR_H__ */
* THE SOFTWARE.
*/
-#include "gloffscreen.h"
+#include "gloffscreen_test.h"
#include <stdlib.h>
#include <stdio.h>
--- /dev/null
+/*
+ * Offscreen OpenGL abstraction layer
+ *
+ * Copyright (c) 2010 Intel Corporation
+ * Written by:
+ * Gordon Williams <gordon.williams@collabora.co.uk>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef __GLOFFSCREEN_TEST_H__
+#define __GLOFFSCREEN_TEST_H__
+
+#include "gloffscreen.h"
+
+int gl_acceleration_capability_check(void);
+
+#endif /* __GLOFFSCREEN_TEST_H__ */
*/
/**
- * @file emulator.h
- * @brief - header of file these are config structures and defines in emulator
+ * @file maru_common.h
+ * @brief - header file that covers maru common features
*/
#ifndef __MARU_COMMON_H__
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
+#include <glib.h>
// W/A for preserve larger continuous heap for RAM.
extern void *preallocated_ptr;
#define MAX_VIRTIO_CONSOLES 1
#ifdef CONFIG_MARU
-#define MARUCAM_DEV_NAME "maru_camera_pci"
int skin_disabled = 0;
+//virtio-gl
+extern int enable_gl;
+extern int enable_yagl;
#endif
static const char *data_dir;
int boot_splash_filedata_size;
uint8_t qemu_extra_params_fw[2];
-//virtio-gl
-#define VIRTIOGL_DEV_NAME "virtio-gl-pci"
-#if defined(CONFIG_MARU)
-extern int gl_acceleration_capability_check(void);
-int enable_gl = 0;
-int enable_yagl = 0;
-int capability_check_gl = 0;
-#endif
-#if defined(CONFIG_MARU)
-#define WEBCAM_INFO_IGNORE 0x00
-#define WEBCAM_INFO_WRITE 0x04
-extern int marucam_device_check(int log_flag);
-int is_webcam_enabled = 0;
-#endif
-
typedef struct FWBootEntry FWBootEntry;
{
DeviceState *dev;
-#ifdef CONFIG_GL_BACKEND
-#if defined(CONFIG_MARU)
- // virtio-gl pci device
- if (!enable_gl) {
- // ignore virtio-gl-pci device, even if users set it in option.
- const char *driver = qemu_opt_get(opts, "driver");
- if (driver && (strcmp (driver, VIRTIOGL_DEV_NAME) == 0)) {
- return 0;
- }
- }
-#endif
-#endif
-#if defined(CONFIG_MARU)
- if (!is_webcam_enabled) {
- const char *driver = qemu_opt_get(opts, "driver");
- if (driver && (strcmp (driver, MARUCAM_DEV_NAME) == 0)) {
- return 0;
- }
+#ifdef CONFIG_MARU
+ if(maru_device_check(opts) == -1) {
+ return 0;
}
#endif
free(mem);
}
-// virtio-gl pci device lookup
-typedef struct {
- const char *device_name;
- int found;
-} device_opt_finding_t;
-
-static int find_device_opt (QemuOpts *opts, void *opaque)
-{
- device_opt_finding_t *devp = (device_opt_finding_t *) opaque;
- if (devp->found == 1) {
- return 0;
- }
-
- const char *str = qemu_opt_get (opts, "driver");
- if (strcmp (str, devp->device_name) == 0) {
- devp->found = 1;
- }
- return 0;
-}
-
-int use_qemu_display = 0; //0:use tizen qemu sdl, 1:use original qemu sdl
-
int qemu_init_main_loop(void)
{
return main_loop_init();
}
#ifdef CONFIG_MARU
+int use_qemu_display = 0; //0:use tizen qemu sdl, 1:use original qemu sdl
// W/A for preserve larger continuous heap for RAM.
void *preallocated_ptr = 0;
#endif
const char *icount_option = NULL;
const char *initrd_filename;
const char *kernel_filename, *kernel_cmdline;
- char* tmp_cmdline = NULL;
char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */
DisplayState *ds;
DisplayChangeListener *dcl;
const char *trace_events = NULL;
const char *trace_file = NULL;
-#ifdef CONFIG_MARU
- #define MIDBUF 128
- char http_proxy[MIDBUF] ={0},https_proxy[MIDBUF] = {0,},
- ftp_proxy[MIDBUF] = {0,}, socks_proxy[MIDBUF] = {0,},
- dns1[MIDBUF] = {0}, dns2[MIDBUF] = {0};
-#endif
-
atexit(qemu_run_exit_notifiers);
error_set_progname(argv[0]);
qemu_opts_set(qemu_find_opts("machine"), 0, "initrd", optarg);
break;
case QEMU_OPTION_append:
-#ifdef CONFIG_MARU
- gethostproxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
- gethostDNS(dns1, dns2);
-
- check_shdmem();
- socket_init();
- tizen_base_port = get_sdb_base_port();
- make_shdmem();
-
- sdb_setup();
-
- tmp_cmdline = g_strdup_printf("%s sdb_port=%d,"
- " http_proxy=%s https_proxy=%s ftp_proxy=%s socks_proxy=%s"
- " dns1=%s dns2=%s", optarg, tizen_base_port,
- http_proxy, https_proxy, ftp_proxy, socks_proxy,
- dns1, dns2);
- qemu_opts_set(qemu_find_opts("machine"), 0, "append",
- tmp_cmdline);
-#if 0
- fprintf(stdout, "kernel command: =========================================\n");
- fprintf(stdout, "%s\n", tmp_cmdline);
- fprintf(stdout, "kernel command: =========================================\n");
-#endif
-#else
qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg);
-#endif
break;
case QEMU_OPTION_dtb:
qemu_opts_set(qemu_find_opts("machine"), 0, "dtb", optarg);
exit(0);
}
-#if defined(CONFIG_MARU)
- if (enable_gl && enable_yagl) {
- fprintf (stderr, "Error: only one openGL passthrough device can be used at one time!\n");
- exit(1);
- }
-
- if (enable_gl || enable_yagl) {
- capability_check_gl = gl_acceleration_capability_check();
-
- if (capability_check_gl != 0) {
- enable_gl = enable_yagl = 0;
- fprintf (stderr, "Warn: GL acceleration was disabled due to the fail of GL check!\n");
- }
-
- // To check host gl driver capability and notify to guest.
- gchar *tmp = tmp_cmdline;
- tmp_cmdline = g_strdup_printf("%s gles=%d yagl=%d", tmp, enable_gl, enable_yagl);
- qemu_opts_set(qemu_find_opts("machine"), 0, "append", tmp_cmdline);
- fprintf(stdout, "kernel command: =========================================\n");
- fprintf(stdout, "%s\n", tmp_cmdline);
- fprintf(stdout, "kernel command: =========================================\n");
- g_free(tmp);
-
- if (enable_gl) {
- device_opt_finding_t devp = {VIRTIOGL_DEV_NAME, 0};
- qemu_opts_foreach(qemu_find_opts("device"), find_device_opt, &devp, 0);
- if (devp.found == 0) {
- if (!qemu_opts_parse(qemu_find_opts("device"), VIRTIOGL_DEV_NAME, 1)) {
- exit(1);
- }
- }
- }
- }
-#endif
-
/* Open the logfile at this point, if necessary. We can't open the logfile
* when encountering either of the logging options (-d or -D) because the
* other one may be encountered later on the command line, changing the
kernel_cmdline = "";
}
-#if defined(CONFIG_MARU)
- is_webcam_enabled = marucam_device_check(WEBCAM_INFO_WRITE);
- if (!is_webcam_enabled) {
- fprintf (stderr, "[Webcam] <WARNING> Webcam support was disabled "
- "due to the fail of webcam capability check!\n");
- }
-
- gchar const *tmp_cam_kcmd = kernel_cmdline;
- kernel_cmdline = g_strdup_printf("%s enable_cam=%d", tmp_cam_kcmd, is_webcam_enabled);
-// g_free(tmp_cam_kcmd);
-
- if (is_webcam_enabled) {
- device_opt_finding_t devp = {MARUCAM_DEV_NAME, 0};
- qemu_opts_foreach(qemu_find_opts("device"), find_device_opt, &devp, 0);
- if (devp.found == 0) {
- if (!qemu_opts_parse(qemu_find_opts("device"), MARUCAM_DEV_NAME, 1)) {
- fprintf(stderr, "Failed to initialize the marucam device.\n");
- exit(1);
- }
- }
- fprintf(stdout, "[Webcam] Webcam support was enabled.\n");
- }
-#endif
-
linux_boot = (kernel_filename != NULL);
if (!linux_boot && *kernel_cmdline != '\0') {
qdev_machine_init();
- machine->init(ram_size, boot_devices,
- kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
#ifdef CONFIG_MARU
- g_free((gchar *)tmp_cmdline);
+ // return variable points different address from input variable.
+ kernel_cmdline = prepare_maru_devices(kernel_cmdline);
#endif
+ machine->init(ram_size, boot_devices,
+ kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
+
cpu_synchronize_all_post_init();
set_numa_modes();