Some shutdown/exit funtions use "exit_notifier" instead of exit_emulator().
Remove some unnecessary header inclusion.
Change-Id: I78617d439f1c133ba8332e6fca8622a6b4289c71
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
#include "config.h"
#include "qapi/qmp/qint.h"
+#include "emulator.h"
#include "sdb.h"
#include "ecs.h"
#include "guest_server.h"
return NULL;
}
-int stop_ecs(void) {
+static int stop_ecs(void) {
INFO("ecs is closing.\n");
if (NULL != current_ecs) {
current_ecs->ecs_running = 0;
return 0;
}
+static void ecs_notify_exit(Notifier *notifier, void *data) {
+ stop_ecs();
+}
+static Notifier ecs_exit = { .notify = ecs_notify_exit };
+
int start_ecs(void) {
pthread_t thread_id;
ERR("pthread creation failed.\n");
return -1;
}
+
+ emulator_add_exit_notifier(&ecs_exit);
+
return 0;
}
}nfc_msg_info;
int start_ecs(void);
-int stop_ecs(void);
ECS_Client *find_client(unsigned char id, unsigned char type);
bool handle_protobuf_msg(ECS_Client* cli, char* data, const int len);
#include "emulator_options.h"
#include "check_gl.h"
#include "maru_err_table.h"
-#include "maru_display.h"
#include "mloop_event.h"
#include "osutil.h"
#include "sdb.h"
#include "skin/maruskin_server.h"
#include "debug_ch.h"
#include "ecs/ecs.h"
-#include "tethering/app_tethering.h"
#ifdef CONFIG_SDL
#include <SDL.h>
return log_path;
}
+void emulator_add_exit_notifier(Notifier *notify)
+{
+ qemu_add_exit_notifier(notify);
+}
+
void exit_emulator(void)
{
INFO("exit emulator!\n");
- mloop_ev_stop();
- shutdown_skin_server();
- shutdown_guest_server();
- stop_ecs();
- disconnect_tethering_app();
-
#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN)
if (shmctl(g_shmid, IPC_RMID, 0) == -1) {
ERR("shmctl failed\n");
perror("emulator.c: ");
}
#endif
-
- maru_display_fini();
}
static void construct_main_window(int skin_argc, char *skin_argv[],
#include "maru_common.h"
#include "qapi/qmp/qlist.h"
#include "qemu/option.h"
+#include "sysemu/sysemu.h"
#define MAXLEN 512
#define MAXPACKETLEN 60
extern gchar bin_path[];
extern gchar log_path[];
-void exit_emulator(void);
char *get_bin_path(void);
const gchar * prepare_maru(const gchar * const kernel_cmdline);
void start_skin(void);
const gchar * get_log_path(void);
int maru_device_check(QemuOpts *opts);
+void exit_emulator(void);
+void emulator_add_exit_notifier(Notifier *notify);
+
#endif /* __EMULATOR_H__ */
return NULL;
}
+static void shutdown_guest_server(void)
+{
+ INFO("shutdown_guest_server.\n");
+
+ close_server();
+}
+
+static void guest_server_notify_exit(Notifier *notifier, void *data) {
+ shutdown_guest_server();
+}
+static Notifier guest_server_exit = { .notify = guest_server_notify_exit };
+
void start_guest_server(int server_port)
{
QemuThread thread_id;
svr_port = server_port;
qemu_thread_create(&thread_id, "guest_server", run_guest_server, NULL, QEMU_THREAD_DETACHED);
INFO("created guest server thread\n");
-}
-
-void shutdown_guest_server(void)
-{
- INFO("shutdown_guest_server.\n");
- close_server();
+ emulator_add_exit_notifier(&guest_server_exit);
}
#include <pthread.h>
void start_guest_server( int server_port );
-void shutdown_guest_server( void );
#define STATE_RUNNING 0
#define STATE_SUSPEND 1
*/
+#include "emulator.h"
#include "maru_common.h"
#include "maru_display.h"
#include "debug_ch.h"
MaruScreenShot* screenshot = NULL;
+static void maru_display_fini(void)
+{
+ INFO("fini qemu display\n");
+
+ g_free(screenshot);
+
+#ifndef CONFIG_USE_SHM
+ maru_sdl_quit();
+#else
+ maru_shm_quit();
+#endif
+}
+
+static void maru_display_notify_exit(Notifier *notifier, void *data) {
+ maru_display_fini();
+}
+static Notifier maru_display_exit = { .notify = maru_display_notify_exit };
+
//TODO: interface
void maru_display_init(DisplayState *ds)
{
screenshot->pixels = NULL;
screenshot->request = false;
screenshot->ready = false;
-}
-
-void maru_display_fini(void)
-{
- INFO("fini qemu display\n");
-
- g_free(screenshot);
-#ifndef CONFIG_USE_SHM
- maru_sdl_quit();
-#else
- maru_shm_quit();
-#endif
+ emulator_add_exit_notifier(&maru_display_exit);
}
void maru_display_resize(void)
} MaruScreenShot;
void maru_display_init(DisplayState *ds);
-void maru_display_fini(void);
void maru_display_resize(void);
void maru_display_update(void);
void maru_display_invalidate(bool on);
}
}
+static void mloop_ev_stop(void)
+{
+ qemu_set_fd_handler(mloop.sockno, NULL, NULL, NULL);
+ mloop_evsock_remove(&mloop);
+}
+
+static void mloop_ev_notify_exit(Notifier *notifier, void *data) {
+ mloop_ev_stop();
+}
+static Notifier mloop_ev_exit = { .notify = mloop_ev_notify_exit };
+
void mloop_ev_init(void)
{
int ret = mloop_evsock_create(&mloop);
if (ret == 0) {
qemu_set_fd_handler(mloop.sockno, (IOHandler *)mloop_evcb_recv, NULL, &mloop);
}
-}
-void mloop_ev_stop(void)
-{
- qemu_set_fd_handler(mloop.sockno, NULL, NULL, NULL);
- mloop_evsock_remove(&mloop);
+ emulator_add_exit_notifier(&mloop_ev_exit);
}
void mloop_evcmd_raise_intr(void *irq)
#endif
void mloop_ev_init(void);
-void mloop_ev_stop(void);
void mloop_evcmd_usbkbd(int on);
void mloop_evcmd_usbdisk(char *img);
#include <pthread.h>
+#include "emulator.h"
#include "maru_common.h"
#include "maruskin_server.h"
#include "maruskin_operation.h"
static int start_heart_beat(void);
static void stop_heart_beat(void);
-
-int start_skin_server(int argc, char** argv,
- int qemu_argc, char** qemu_argv)
-{
- skin_argc = argc;
- skin_argv = argv;
-
- parse_skinconfig_prop();
-
- /* arguments have higher priority than '.skinconfig.properties' */
- parse_skin_args();
-
- INFO("ignore_heartbeat : %d\n", ignore_heartbeat);
-
- qmu_argc = qemu_argc;
- qmu_argv = qemu_argv;
-
- qemu_mutex_init(&mutex_send_data);
- qemu_mutex_init(&mutex_recv_heartbeat_count);
- qemu_mutex_init(&mutex_draw_display);
-
- QemuThread qemu_thread;
- qemu_thread_create(&qemu_thread, "skin-server", run_skin_server,
- NULL, QEMU_THREAD_DETACHED);
-
- return 1;
-}
-
-void shutdown_skin_server(void)
+static void shutdown_skin_server(void)
{
INFO("shutdown_skin_server\n");
qemu_mutex_destroy(&mutex_draw_display);
}
+static void skin_server_notify_exit(Notifier *notifier, void *data) {
+ shutdown_skin_server();
+}
+static Notifier skin_server_exit = { .notify = skin_server_notify_exit };
+
+int start_skin_server(int argc, char** argv,
+ int qemu_argc, char** qemu_argv)
+{
+ skin_argc = argc;
+ skin_argv = argv;
+
+ parse_skinconfig_prop();
+
+ /* arguments have higher priority than '.skinconfig.properties' */
+ parse_skin_args();
+
+ INFO("ignore_heartbeat : %d\n", ignore_heartbeat);
+
+ qmu_argc = qemu_argc;
+ qmu_argv = qemu_argv;
+
+ QemuThread qemu_thread;
+
+ qemu_thread_create(&qemu_thread, "skin-server", run_skin_server,
+ NULL, QEMU_THREAD_DETACHED);
+
+ emulator_add_exit_notifier(&skin_server_exit);
+
+ return 1;
+}
+
void notify_draw_frame(void)
{
#if 0
#define MARUSKIN_SERVER_H_
int start_skin_server(int argc, char** argv, int qemu_argc, char** qemu_argv);
-void shutdown_skin_server(void);
void notify_draw_frame(void);
void notify_draw_blank_guide(void);
#include "qemu/sockets.h"
#include "ui/console.h"
+#include "emulator.h"
#include "emul_state.h"
#include "app_tethering.h"
#include "../ecs/ecs_tethering.h"
send_tethering_touch_status_ecp();
}
+int disconnect_tethering_app(void)
+{
+ int sock = 0;
+
+ INFO("disconnect app from ecp\n");
+
+ sock = tethering_sock;
+ if (sock < 0) {
+ ERR("tethering socket is terminated or not ready\n");
+ } else {
+ destroy_tethering_io_handler(sock);
+#if 0
+ if (get_tethering_app_state()) {
+ send_emul_state_msg();
+ }
+#endif
+ end_tethering_socket(sock);
+ }
+
+ return 0;
+}
+
+static void tethering_notify_exit(Notifier *notifier, void *data) {
+ disconnect_tethering_app();
+}
+static Notifier tethering_exit = { .notify = tethering_notify_exit };
+
int connect_tethering_app(const char *ipaddress, int port)
{
int sock = 0, ret = 0;
ret = register_tethering_io_handler(sock);
send_handshake_req_msg();
- return ret;
-}
-
-int disconnect_tethering_app(void)
-{
- int sock = 0;
+ emulator_add_exit_notifier(&tethering_exit);
- INFO("disconnect app from ecp\n");
-
- sock = tethering_sock;
- if (sock < 0) {
- ERR("tethering socket is terminated or not ready\n");
- } else {
- destroy_tethering_io_handler(sock);
-#if 0
- if (get_tethering_app_state()) {
- send_emul_state_msg();
- }
-#endif
- end_tethering_socket(sock);
- }
-
- return 0;
+ return ret;
}