src/core/launch.c
src/core/queue.c
src/core/core.c
+ src/core/devices.c
src/core/sig-handler.c
src/core/log.c
src/core/device-change-handler.c
#include "device-node.h"
#include "core/queue.h"
#include "core/data.h"
+#include "core/devices.h"
#define USB_CON_PIDFILE "/var/run/.system_server.pid"
#define PM_STATE_LOG_FILE "/var/log/pm_state.log"
* Power manager Main
*
*/
-void start_pm_main(void)
+static void start_pm_main(void *data)
{
int ret, i;
unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS);
}
}
-void end_pm_main(void)
+static void end_pm_main(void *data)
{
int i;
LOGINFO("Stop power manager");
}
+const struct device_ops display_device_ops = {
+ .init = start_pm_main,
+ .exit = end_pm_main,
+};
+
/**
* @}
*/
void (*pm_exit_extention) (void); /**< extention exit function */
int check_processes(enum state_t prohibit_state);
-/*
- * Power manager Main loop
- *
- * @internal
- * @param[in] flags If the first bit of this is set, start managing without Start notification.
- * If the second bit of ths is set, use unified device manager functions.
- */
-void start_pm_main(void);
-void end_pm_main(void);
-
/**
* @}
*/
#include "core.h"
#include "device-node.h"
#include "core/common.h"
-
+#include "core/devices.h"
#define DISP_INDEX_BIT 4
#define COMBINE_DISP_CMD(cmd, prop, index) (cmd = (prop | (index << DISP_INDEX_BIT)))
static DBusMessage *e_dbus_start_cb(E_DBus_Object *obj, DBusMessage *msg)
{
- start_pm_main();
+ display_device_ops.init(NULL);
return dbus_message_new_method_return(msg);
}
static DBusMessage *e_dbus_stop_cb(E_DBus_Object *obj, DBusMessage *msg)
{
- end_pm_main();
+ display_device_ops.exit(NULL);
return dbus_message_new_method_return(msg);
}
sysman internal devel library.
%package -n libslp-pm
-Summary: power manager client
+Summary: Power manager client
Group: System/Libraries
Requires: %{name} = %{version}-%{release}
power-manager library.
%package -n libslp-pm-devel
-Summary: power manager client (devel)
+Summary: Power manager client (devel)
Group: System/Development
Requires: %{name} = %{version}-%{release}
#Requires: libslp-pm
#include "core/noti.h"
#include "core/queue.h"
#include "core/data.h"
+#include "core/devices.h"
+#include "device-node.h"
#include "display/setting.h"
#define PREDEF_LOWBAT "lowbat"
return 0;
}
-void ss_predefine_lowbat_init(void)
+static void lowbat_init(void *data)
{
+ struct ss_main_data *ad = (struct ss_main_data*)data;
+
ss_action_entry_add_internal(PREDEF_LOWBAT, lowbat_def_predefine_action,
NULL, NULL);
}
ss_lowbat_is_charge_in_now();
vconf_notify_key_changed(VCONFKEY_PM_STATE, (void *)wakeup_cb, NULL);
-
- return 0;
}
+
+const struct device_ops lowbat_device_ops = {
+ .init = lowbat_init,
+};
+++ /dev/null
-/*
- * system-server
- *
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
-*/
-
-
-#ifndef __LOWBAT_HANDLER_H__
-#define __LOWBAT_HANDLER_H__
-
-void ss_predefine_lowbat_init(void);
-#endif /* __LOWBAT_HANDLER_H__ */
#include <Ecore_File.h>
#include "core/log.h"
#include "core/launch.h"
+#include "core/devices.h"
#define CRASH_PID_MAX 7
#define CRASH_MODE_MAX 2
return 1;
}
-int ss_bs_init(void)
+static void bs_init(void *data)
{
if (make_noti_file(CRASH_NOTI_DIR, CRASH_NOTI_FILE) < 0) {
_E("make_noti_file() failed");
if (!crash_file_monitor) {
_E("ecore_file_monitor_add() failed");
launch_crash_worker(CRASH_NOTI_PATH, CRASH_POPUP_OFF);
- return -1;
+ return;
}
-
- return 0;
}
+
+const struct device_ops bs_device_ops = {
+ .init = bs_init,
+};
#ifndef _SS_COMMON_H
#define _SS_COMMON_H
+#include <unistd.h>
+
#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
FILE * open_proc_oom_adj_file(int pid, const char *mode);
#include "log.h"
#include "predefine.h"
#include "core.h"
+#include "devices.h"
enum ss_core_cmd_type {
SS_CORE_ACT_RUN,
return 0;
}
-int ss_core_init(struct ss_main_data *ad)
-{
- __pipe_stop(core_pipe[0]);
- __pipe_stop(core_pipe[1]);
-
- if (__pipe_start(ad) == -1) {
- _E("fail pipe control fd init");
- return -1;
- }
- return 0;
-}
-
static int __pipe_start(struct ss_main_data *ad)
{
if (pipe(core_pipe) < 0) {
return 0;
}
+
+static void core_init(void *data)
+{
+ struct ss_main_data *ad = (struct ss_main_data*)data;
+
+ __pipe_stop(core_pipe[0]);
+ __pipe_stop(core_pipe[1]);
+
+ if (__pipe_start(ad) == -1)
+ PRT_TRACE_ERR("fail pipe control fd init");
+}
+
+const struct device_ops core_device_ops = {
+ .init = core_init,
+};
#ifndef __CORE_H__
#define __CORE_H__
-#include "data.h"
-
int ss_core_action_run();
int ss_core_action_clear(int pid);
-int ss_core_init(struct ss_main_data *ad);
#endif /* __CORE_H__ */
#include <aul.h>
#include <bundle.h>
#include <dirent.h>
-#include "dd-deviced.h"
#include <libudev.h>
+#include "dd-deviced.h"
#include <device-node.h>
#include "queue.h"
#include "log.h"
#include "device-handler.h"
#include "noti.h"
#include "data.h"
-#include "sys_pci_noti/sys_pci_noti.h"
#include "predefine.h"
#include "display/poll.h"
+#include "devices.h"
+#include "sys_pci_noti/sys_pci_noti.h"
#define PREDEF_USBCON "usbcon"
#define PREDEF_EARJACKCON "earjack_predef_internal"
ss_launch_if_noexist("/usr/bin/sys_pci_noti", params);
}
-void ss_predefine_device_change_init(void)
+static void device_change_init(void *data)
{
ss_action_entry_add_internal(PREDEF_USBCON, usbcon_def_predefine_action, NULL, NULL);
ss_action_entry_add_internal(PREDEF_EARJACKCON, earjackcon_def_predefine_action, NULL, NULL);
ss_action_entry_add_internal(PREDEF_BATTERY_CF_OPENED, battery_def_cf_opened_actioin, NULL, NULL);
-}
-
-int ss_device_change_init(struct ss_main_data *ad)
-{
ss_action_entry_add_internal(PREDEF_DEVICE_CHANGED, changed_device_def_predefine_action, NULL, NULL);
if (uevent_control_start() == -1) {
_E("fail uevent control init");
- return -1;
+ return;
}
/* for simple noti change cb */
- ss_noti_add("device_usb_chgdet", (void *)usb_chgdet_cb, (void *)ad);
- ss_noti_add("device_ta_chgdet", (void *)ta_chgdet_cb, (void *)ad);
- ss_noti_add("device_earjack_chgdet", (void *)earjack_chgdet_cb, (void *)ad);
- ss_noti_add("device_earkey_chgdet", (void *)earkey_chgdet_cb, (void *)ad);
- ss_noti_add("device_tvout_chgdet", (void *)tvout_chgdet_cb, (void *)ad);
- ss_noti_add("device_hdmi_chgdet", (void *)hdmi_chgdet_cb, (void *)ad);
- ss_noti_add("device_keyboard_chgdet", (void *)keyboard_chgdet_cb, (void *)ad);
-
- ss_noti_add("device_usb_host_add", (void *)usb_host_add_cb, (void *)ad);
+ ss_noti_add("device_usb_chgdet", (void *)usb_chgdet_cb, data);
+ ss_noti_add("device_ta_chgdet", (void *)ta_chgdet_cb, data);
+ ss_noti_add("device_earjack_chgdet", (void *)earjack_chgdet_cb, data);
+ ss_noti_add("device_earkey_chgdet", (void *)earkey_chgdet_cb, data);
+ ss_noti_add("device_tvout_chgdet", (void *)tvout_chgdet_cb, data);
+ ss_noti_add("device_hdmi_chgdet", (void *)hdmi_chgdet_cb, data);
+ ss_noti_add("device_keyboard_chgdet", (void *)keyboard_chgdet_cb, data);
+ ss_noti_add("device_usb_host_add", (void *)usb_host_add_cb, data);
ss_noti_add("mmcblk_add", (void *)mmc_chgdet_cb, (void *)1);
ss_noti_add("mmcblk_remove", (void *)mmc_chgdet_cb, NULL);
-
ss_noti_add("unmount_ums", (void *)ums_unmount_cb, NULL);
- ss_noti_add("device_charge_chgdet", (void *)charge_cb, (void *)ad);
-
- ss_noti_add("device_pci_keyboard_add", (void *)pci_keyboard_add_cb, (void *)ad);
- ss_noti_add("device_pci_keyboard_remove", (void *)pci_keyboard_remove_cb, (void *)ad);
+ ss_noti_add("device_charge_chgdet", (void *)charge_cb, data);
+ ss_noti_add("device_pci_keyboard_add", (void *)pci_keyboard_add_cb, data);
+ ss_noti_add("device_pci_keyboard_remove", (void *)pci_keyboard_remove_cb, data);
if (vconf_notify_key_changed(VCONFKEY_SYSMAN_USB_HOST_STATUS, usb_host_chgdet_cb, NULL) < 0) {
_E("vconf key notify failed(VCONFKEY_SYSMAN_USB_HOST_STATUS)");
e_dbus_signal_handler_add(conn, NULL, "/system/uevent/xxxxx",
"system.uevent.xxxxx",
- "Change", cb_xxxxx_signaled, ad);
+ "Change", cb_xxxxx_signaled, data);
#endif /* ENABLE_EDBUS_USE */
/* set initial state for devices */
keyboard_chgdet_cb(NULL);
hdmi_chgdet_cb(NULL);
system(STORE_DEFAULT_USB_INFO);
-
- return 0;
}
+
+const struct device_ops change_device_ops = {
+ .init = device_change_init,
+};
#include "data.h"
/* MMC functions */
-int ss_mmc_init();
int ss_mmc_inserted();
int ss_mmc_removed();
int _ss_usb_storage_init(void);
/* Battery functions */
-int ss_lowbat_init(struct ss_main_data *ad);
int ss_lowbat_is_charge_in_now();
int ss_lowbat_set_charge_on(int onoff);
int ss_lowbat_monitor(void *data);
-/* Low memory functions */
-int ss_lowmem_init(struct ss_main_data *ad);
-
-/* USB functions */
-int ss_usb_init();
-
-/* TA functions */
-int ss_ta_init();
-
-/* device change init */
-int ss_device_change_init(struct ss_main_data *ad);
-
#endif /* __DEVICE_HANDLER_H__ */
--- /dev/null
+/*
+ * deviced
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdio.h>
+
+#include "log.h"
+#include "devices.h"
+#include "common.h"
+
+static const struct device_ops *devices[] = {
+ /* The below devices have init dependency with other module */
+ &edbus_device_ops,
+ &display_device_ops,
+ /* The below devices don't have any init dependency */
+ &sysnoti_device_ops,
+ ¬i_device_ops,
+ &core_device_ops,
+ &signal_device_ops,
+ &predefine_device_ops,
+ &lowmem_device_ops,
+ &lowbat_device_ops,
+ &change_device_ops,
+ &power_device_ops,
+ &bs_device_ops,
+ &process_device_ops,
+ &time_device_ops,
+ &cpu_device_ops,
+ &usb_device_ops,
+ &ta_device_ops,
+ &pmon_device_ops,
+ &mmc_device_ops,
+ &led_device_ops,
+ &vibrator_device_ops,
+};
+
+void devices_init(void *data)
+{
+ int i;
+ int size;
+ struct device_ops *dev;
+
+ size = ARRAY_SIZE(devices);
+ for(i = 0; i < size; ++i) {
+ dev = devices[i];
+ if (dev->init)
+ dev->init(data);
+ }
+}
+
+void devices_exit(void *data)
+{
+ int i;
+ int size;
+ struct device_ops *dev;
+
+ size = ARRAY_SIZE(devices);
+ for(i = 0; i < size; ++i) {
+ dev = devices[i];
+ if (dev->exit)
+ dev->exit(data);
+ }
+}
--- /dev/null
+/*
+ * deviced
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __DEVICES_H__
+#define __DEVICES_H__
+
+struct device_ops {
+ void (*init) (void *data);
+ void (*exit) (void *data);
+};
+
+void devices_init(void *data);
+void devices_exit(void *data);
+
+extern const struct device_ops edbus_device_ops;
+extern const struct device_ops display_device_ops;
+extern const struct device_ops sysnoti_device_ops;
+extern const struct device_ops noti_device_ops;
+extern const struct device_ops core_device_ops;
+extern const struct device_ops signal_device_ops;
+extern const struct device_ops predefine_device_ops;
+extern const struct device_ops lowmem_device_ops;
+extern const struct device_ops lowbat_device_ops;
+extern const struct device_ops change_device_ops;
+extern const struct device_ops power_device_ops;
+extern const struct device_ops bs_device_ops;
+extern const struct device_ops process_device_ops;
+extern const struct device_ops time_device_ops;
+extern const struct device_ops cpu_device_ops;
+extern const struct device_ops usb_device_ops;
+extern const struct device_ops ta_device_ops;
+extern const struct device_ops pmon_device_ops;
+extern const struct device_ops mmc_device_ops;
+extern const struct device_ops led_device_ops;
+extern const struct device_ops vibrator_device_ops;
+
+#endif
#include "core/data.h"
#include "core/edbus-handler.h"
#include "core/common.h"
+#include "core/devices.h"
#define EDBUS_INIT_RETRY_COUNT 5
return 0;
}
-void edbus_fini(void)
-{
- unregister_edbus_signal_handle();
- e_dbus_connection_close(edbus_conn);
- e_dbus_shutdown();
-}
-
-void edbus_init(void)
+static void edbus_init(void *data)
{
int retry = EDBUS_INIT_RETRY_COUNT;
int i, r;
return;
}
+static void edbus_exit(void *data)
+{
+ unregister_edbus_signal_handle();
+ e_dbus_connection_close(edbus_conn);
+ e_dbus_shutdown();
+}
+
+const struct device_ops edbus_device_ops = {
+ .init = edbus_init,
+ .exit = edbus_exit,
+};
#define DEVICED_PATH_DISPLAY OBJECT_PATH"/Display"
#define DEVICED_INTERFACE_DISPLAY INTERFACE_NAME".display"
-void edbus_init(void);
-void edbus_fini(void);
int register_edbus_signal_handler(char *signal_name, E_DBus_Signal_Cb cb);
E_DBus_Interface *get_edbus_interface(const char *path);
pid_t get_edbus_sender_pid(DBusMessage *msg);
#include <stdio.h>
#include <fcntl.h>
-#include <heynoti.h>
#include <sys/reboot.h>
#include "log.h"
-#include "core.h"
-#include "sig-handler.h"
-#include "device-handler.h"
-#include "proc/pmon-handler.h"
-#include "sysnoti.h"
-#include "noti.h"
-#include "queue.h"
-#include "predefine.h"
-#include "bs/bs.h"
-#include "proc/procmgr.h"
-#include "time/time-handler.h"
-#include "cpu/cpu-handler.h"
#include "data.h"
-#include "cpu/cpu-handler.h"
-#include "data.h"
-#include "led/led.h"
-#include "proc/lowmem-handler.h"
-#include "battery/lowbat-handler.h"
-#include "proc/pmon-handler.h"
-#include "proc/proc-handler.h"
-#include "time/time-handler.h"
-#include "vibrator/vibrator.h"
-#include "sysnoti.h"
+#include "devices.h"
-static void fini(struct ss_main_data *ad)
-{
-}
+#define SS_PIDFILE_PATH "/var/run/.system_server.pid"
static void init_ad(struct ss_main_data *ad)
{
}
}
-static void system_server_init(struct ss_main_data *ad)
-{
- ad->sysnoti_fd = ss_sysnoti_init();
- if (ss_noti_init() < 0)
- _E("init noti error");
-
- ss_queue_init();
- ss_core_init(ad);
- ss_signal_init();
- ss_predefine_internal_init();
- ss_predefine_lowmem_init();
- ss_predefine_lowbat_init();
- ss_predefine_device_change_init();
- ss_predefine_power_init();
- ss_process_manager_init();
- ss_time_manager_init();
- ss_cpu_handler_init();
-
- ss_lowmem_init(ad);
- ss_lowbat_init(ad);
- ss_power_init(ad);
- ss_usb_init();
- ss_ta_init();
- ss_pmon_init(ad);
- ss_device_change_init(ad);
- led_init();
- ss_mmc_init();
- ss_bs_init();
- vibrator_init();
-}
-
-#define SS_PIDFILE_PATH "/var/run/.system_server.pid"
static void sig_quit(int signo)
{
- PRT_TRACE_ERR("received SIGTERM signal %d", signo);
+ _E("received SIGTERM signal %d", signo);
}
+
static int system_main(int argc, char **argv)
{
struct ss_main_data ad;
init_ad(&ad);
- if ((ad.noti_fd = heynoti_init()) < 0) {
- _E("Hey Notification Initialize failed");
- fini(&ad);
- return 0;
- }
- if (heynoti_attach_handler(ad.noti_fd) != 0) {
- _E("fail to attach hey noti handler");
- fini(&ad);
- return 0;
- }
- edbus_init();
- system_server_init(&ad);
- start_pm_main();
+ devices_init(&ad);
signal(SIGTERM, sig_quit);
ecore_main_loop_begin();
- end_pm_main();
- fini(&ad);
- edbus_fini();
+ devices_exit(&ad);
ecore_shutdown();
-
return 0;
}
#include <heynoti.h>
#include "log.h"
+#include "data.h"
+#include "devices.h"
static int noti_fd;
return heynoti_publish(filename);
}
-int ss_noti_init()
+int ss_noti_add(const char *noti, void (*cb) (void *), void *data)
+{
+ if (noti_fd < 0)
+ return -1;
+
+ return heynoti_subscribe(noti_fd, noti, cb, data);
+}
+
+static void noti_init(void *data)
{
+ struct ss_main_data *ad = (struct ss_main_data*)data;
+
+ if ((ad->noti_fd = heynoti_init()) < 0) {
+ PRT_TRACE_ERR("Hey Notification Initialize failed");
+ return;
+ }
+ if (heynoti_attach_handler(ad->noti_fd) != 0) {
+ PRT_TRACE_ERR("fail to attach hey noti handler");
+ return;
+ }
+
noti_fd = heynoti_init();
if (noti_fd < 0) {
_E("heynoti_init error");
- return -1;
+ return;
}
if (heynoti_attach_handler(noti_fd) < 0) {
_E("heynoti_attach_handler error");
- return -1;
+ return;
}
-
- return 0;
}
-int ss_noti_add(const char *noti, void (*cb) (void *), void *data)
+static void noti_exit(void *data)
{
- if (noti_fd < 0)
- return -1;
+ struct ss_main_data *ad = (struct ss_main_data*)data;
- return heynoti_subscribe(noti_fd, noti, cb, data);
+ heynoti_close(ad->noti_fd);
+ heynoti_close(noti_fd);
}
+
+const struct device_ops noti_device_ops = {
+ .init = noti_init,
+ .exit = noti_exit,
+};
int ss_noti_getfd(void);
int ss_noti_send(char *filename);
int ss_noti_add(const char *noti, void (*cb) (void *), void *data);
-int ss_noti_init(void);
#endif /* __NOTI_H__ */
#include <fcntl.h>
#include <dirent.h>
#include <vconf.h>
-#include <ITapiModem.h>
-#include <TelPower.h>
-#include <tapi_event.h>
-#include <tapi_common.h>
+
#include <syspopup_caller.h>
#include <sys/reboot.h>
#include <sys/time.h>
#include "queue.h"
#include "device-node.h"
#include "predefine.h"
-#include "proc/procmgr.h"
-#include "vibrator/vibrator.h"
+#include "proc/proc-handler.h"
#include "core/data.h"
#include "common.h"
#include "display/poll.h"
#include "setting.h"
-#include "led/led.h"
+#include "devices.h"
+
+#define PREDEFINE_SO_DIR PREFIX"/lib/ss_predefine/"
-#define CALL_EXEC_PATH PREFIX"/bin/call"
-#define LOWMEM_EXEC_PATH PREFIX"/bin/lowmem-popup"
#define LOWBAT_EXEC_PATH PREFIX"/bin/lowbatt-popup"
-#define USBCON_EXEC_PATH PREFIX"/bin/usb-server"
-#define TVOUT_EXEC_PATH PREFIX"/bin/tvout-selector"
-#define PWROFF_EXEC_PATH PREFIX"/bin/poweroff-popup"
-#define MEMPS_EXEC_PATH PREFIX"/bin/memps"
+
#define HDMI_NOTI_EXEC_PATH PREFIX"/bin/hdmi_connection_noti"
#define LOWBAT_POPUP_NAME "lowbat-syspopup"
#define POWEROFF_POPUP_NAME "poweroff-syspopup"
dp = opendir("/proc");
if (!dp) {
- _E("open /proc");
+ PRT_TRACE_ERR("open /proc");
return -1;
}
//lowbat-popup
if (strncmp(name, LOWBAT_POPUP_NAME, strlen(LOWBAT_POPUP_NAME)) == 0) {
if (launched_poweroff == 1) {
- _E("will be foreced power off");
+ _E("will be forced power off");
internal_poweroff_def_predefine_action(0,NULL);
return 0;
}
closedir(dp);
}
-void ss_predefine_internal_init(void)
+static void predefine_init(void *data)
{
-
- /* telephony initialize */
- int ret = 0;
-
ss_action_entry_load_from_sodir();
-
}
+
+const struct device_ops predefine_device_ops = {
+ .init = predefine_init,
+};
#include <bundle.h>
int call_predefine_action(int argc, char **argv);
-void ss_predefine_internal_init(void);
void predefine_pm_change_state(unsigned int s_bits);
int predefine_control_launch(char *popup_name, bundle *b, int option);
#endif /* __PREDEFINE_H__ */
return 0;
}
-
-void ss_queue_init()
-{
-
-}
int ss_run_queue_del(struct ss_run_queue_entry *entry);
int ss_run_queue_del_bypid(int pid);
-void ss_queue_init();
-
#endif /* __QUEUE_H__ */
#include "core.h"
#include "core/edbus-handler.h"
#include "display/poll.h"
+#include "devices.h"
#define _E(format, args...) do { \
char buf[255];\
}
-static void poweroff_popup_edbus_signal_handler(void *data, DBusMessage *msg)
-{
- DBusError err;
- char *str;
- int val = 0;
-
- if (dbus_message_is_signal(msg, INTERFACE_NAME, SIGNAL_NAME_POWEROFF_POPUP) == 0) {
- _D("there is no power off popup signal");
- return;
- }
-
- dbus_error_init(&err);
-
- if (dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID) == 0) {
- _D("there is no message");
- return;
- }
-
- if (strncmp(str, PREDEF_PWROFF_POPUP, strlen(PREDEF_PWROFF_POPUP)) == 0)
- val = VCONFKEY_SYSMAN_POWER_OFF_POPUP;
- else if (strncmp(str, PREDEF_POWEROFF, strlen(PREDEF_POWEROFF)) == 0)
- val = VCONFKEY_SYSMAN_POWER_OFF_DIRECT;
- else if (strncmp(str, PREDEF_POWEROFF, strlen(PREDEF_REBOOT)) == 0)
- val = VCONFKEY_SYSMAN_POWER_OFF_RESTART;
- if (val == 0) {
- _D("not supported message : %s", str);
- return;
- }
- vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, val);
-}
-
-void ss_signal_init(void)
+static void signal_init(void *data)
{
struct sigaction sig_act;
sig_act.sa_flags = SA_SIGINFO;
sigemptyset(&sig_act.sa_mask);
sigaction(SIGPIPE, &sig_act, &sig_pipe_old_act);
- register_edbus_signal_handler(SIGNAL_NAME_POWEROFF_POPUP,
- (void *)poweroff_popup_edbus_signal_handler);
register_edbus_signal_handler(SIGNAL_NAME_LCD_CONTROL,
(void *)lcd_control_edbus_signal_handler);
-
}
+
+const struct device_ops signal_device_ops = {
+ .init = signal_init,
+};
#include "log.h"
#include "queue.h"
#include "common.h"
+#include "devices.h"
#define SYSNOTI_SOCKET_PATH "/tmp/sn"
#define RETRY_READ_COUNT 5
return fd;
}
-int ss_sysnoti_init(void)
-{
- return __sysnoti_start();
-}
-
static int __sysnoti_start(void)
{
int fd;
}
return 0;
}
+
+static void sysnoti_init(void *data)
+{
+ struct ss_main_data *ad = (struct ss_main_data*)data;
+
+ ad->sysnoti_fd = __sysnoti_start();
+}
+
+const struct device_ops sysnoti_device_ops = {
+ .init = sysnoti_init,
+};
char *argv[SYSMAN_MAXARG];
};
-int ss_sysnoti_init(void);
-
#endif /* __SYSNOTI_H__ */
#include <fcntl.h>
+#include <device-node.h>
+#include <vconf.h>
-#include "device-node.h"
#include "core/log.h"
#include "core/data.h"
-#include "vconf.h"
+#include "core/devices.h"
#define PREDEF_SET_MAX_FREQUENCY "set_max_frequency"
#define PREDEF_SET_MIN_FREQUENCY "set_min_frequency"
return 0;
}
-int ss_cpu_handler_init(void)
-{
- __set_freq_limit();
-
- ss_action_entry_add_internal(PREDEF_SET_MAX_FREQUENCY, set_max_frequency_action, NULL, NULL);
- ss_action_entry_add_internal(PREDEF_SET_MIN_FREQUENCY, set_min_frequency_action, NULL, NULL);
- ss_action_entry_add_internal(PREDEF_RELEASE_MAX_FREQUENCY, release_max_frequency_action, NULL, NULL);
- ss_action_entry_add_internal(PREDEF_RELEASE_MIN_FREQUENCY, release_min_frequency_action, NULL, NULL);
-
- vconf_notify_key_changed(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, (void *)power_saving_cb, NULL);
- vconf_notify_key_changed(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, (void *)power_saving_cpu_cb, NULL);
-
- return 0;
-}
-
static void __set_freq_limit()
{
int ret;
return 0;
}
+
+static void cpu_init(void *data)
+{
+ __set_freq_limit();
+
+ ss_action_entry_add_internal(PREDEF_SET_MAX_FREQUENCY, set_max_frequency_action, NULL, NULL);
+ ss_action_entry_add_internal(PREDEF_SET_MIN_FREQUENCY, set_min_frequency_action, NULL, NULL);
+ ss_action_entry_add_internal(PREDEF_RELEASE_MAX_FREQUENCY, release_max_frequency_action, NULL, NULL);
+ ss_action_entry_add_internal(PREDEF_RELEASE_MIN_FREQUENCY, release_min_frequency_action, NULL, NULL);
+
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, (void *)power_saving_cb, NULL);
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, (void *)power_saving_cpu_cb, NULL);
+}
+
+const struct device_ops cpu_device_ops = {
+ .init = cpu_init,
+};
#include "deviced/dd-led.h"
#include "core/log.h"
+#include "core/devices.h"
#define PREDEF_LED "led"
return 0;
}
-int led_def_predefine_action(int argc, char **argv)
+static int predefine_action(int argc, char **argv)
{
int i;
int pid;
return -1;
}
-int led_init(void)
+static void led_init(void *data)
{
- ss_action_entry_add_internal(PREDEF_LED, led_def_predefine_action, NULL, NULL);
- return 0;
+ ss_action_entry_add_internal(PREDEF_LED, predefine_action, NULL, NULL);
}
+
+const struct device_ops led_device_ops = {
+ .init = led_init,
+};
+++ /dev/null
-/*
- * deviced
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef __LED_H__
-#define __LED_H__
-
-int led_def_predefine_action(int argc, char **argv);
-int led_init(void);
-#endif
*/
+#include <stdlib.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <sys/mount.h>
#include <sys/smack.h>
#include <dirent.h>
#include <sys/statfs.h>
#include <bundle.h>
+#include <signal.h>
+
#include "core/log.h"
-#include "core/device-handler.h"
#include "core/common.h"
+#include "core/devices.h"
#define VCONFKEY_INTERNAL_PRIVATE_MMC_ID "db/private/sysman/mmc_device_id"
return 0;
}
-int ss_mmc_init(void)
+static void mmc_init(void *data)
{
ss_action_entry_add_internal(PREDEF_MOUNT_MMC, ss_mmc_inserted, NULL, NULL);
ss_action_entry_add_internal(PREDEF_UNMOUNT_MMC, ss_mmc_unmounted, NULL, NULL);
ss_action_entry_add_internal(PREDEF_CHECK_MMC_PROC, mmc_check_process_launch, NULL, NULL);
/* mmc card mount */
if (__check_mmc_fs() != 0)
- _E("fail to check mmc");
- return 0;
+ _E("failed to check mmc");
}
+
+const struct device_ops mmc_device_ops = {
+ .init = mmc_init,
+};
#include "core/predefine.h"
#include "core/data.h"
#include "core/common.h"
+#include "core/devices.h"
#include "proc/proc-handler.h"
#include "poll.h"
#include "setting.h"
return 0;
}
-void ss_predefine_power_init(void)
+static void power_init(void *data)
{
int bTelReady = 0;
+
if (vconf_get_bool(VCONFKEY_TELEPHONY_READY,&bTelReady) == 0) {
if (bTelReady == 1) {
tapi_handle = tel_init(NULL);
PRT_TRACE_ERR("Vconf notify key chaneged failed: KEY(%s)", VCONFKEY_SYSMAN_POWER_OFF_STATUS);
}
-}
-int ss_power_init(struct ss_main_data *ad)
-{
-
register_edbus_signal_handler(SIGNAL_NAME_POWEROFF_POPUP,
(void *)poweroff_popup_edbus_signal_handler);
- return 0;
}
+const struct device_ops power_device_ops = {
+ .init = power_init,
+};
#include "core/queue.h"
#include "core/predefine.h"
#include "core/data.h"
+#include "core/devices.h"
#define PREDEF_LOWMEM "lowmem"
#define OOM_MEM_ACT "oom_mem_act"
}
return 0;
}
-int ss_predefine_lowmem_init(void)
-{
- ss_action_entry_add_internal(PREDEF_LOWMEM, lowmem_def_predefine_action,
- NULL, NULL);
-}
-int ss_lowmem_init(struct ss_main_data *ad)
+static void lowmem_init(void *data)
{
+ struct ss_main_data *ad = (struct ss_main_data*)data;
char lowmem_dev_node[PATH_MAX];
+ ss_action_entry_add_internal(PREDEF_LOWMEM, lowmem_def_predefine_action,
+ NULL, NULL);
+
if (device_get_property(DEVICE_TYPE_MEMORY, PROP_MEMORY_NODE, lowmem_dev_node) < 0) {
_E("Low memory handler fd init failed");
- return -1;
+ return;
}
lowmem_fd = open(lowmem_dev_node, O_RDONLY);
if (lowmem_fd < 0) {
_E("ss_lowmem_init fd open failed");
- return -1;
+ return;
}
oom_timer = NULL;
NULL);
if (set_threshold() < 0) {
_E("Setting lowmem threshold is failed");
- return -1;
+ return;
}
-
- return 0;
}
+
+const struct device_ops lowmem_device_ops = {
+ .init = lowmem_init,
+};
+++ /dev/null
-/*
- * system-server
- *
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
-*/
-
-
-#ifndef __LOWMEM_HANDLER_H__
-#define __LOWMEM_HANDLER_H__
-
-void ss_predefine_lowmem_init(void);
-#endif /* __LOWMEM_HANDLER_H__ */
#include "core/launch.h"
#include "core/data.h"
#include "core/common.h"
+#include "core/devices.h"
#define PMON_PERMANENT_DIR "/tmp/permanent"
return 1;
}
-int ss_pmon_init(struct ss_main_data *ad)
-{
- int ret = -1;
- if (pmon_efd) {
- ecore_main_fd_handler_del(pmon_efd);
- pmon_efd = NULL;
- }
- if (__pmon_start(ad) == -1) {
- _E("fail pmon control fd init");
- return -1;
- }
- return 0;
-}
-
static int __pmon_start(struct ss_main_data *ad)
{
int pmon_fd = -1;
}
return 0;
}
+
+static void pmon_init(void *data)
+{
+ struct ss_main_data *ad = (struct ss_main_data*)data;
+ int ret = -1;
+
+ if (pmon_efd) {
+ ecore_main_fd_handler_del(pmon_efd);
+ pmon_efd = NULL;
+ }
+ if (__pmon_start(ad) == -1) {
+ PRT_TRACE_ERR("fail pmon control fd init");
+ return;
+ }
+}
+
+const struct device_ops pmon_device_ops = {
+ .init = pmon_init,
+};
#include "core/queue.h"
#include "core/log.h"
#include "core/common.h"
+#include "core/devices.h"
#define OOMADJ_SU (-17)
#define OOMADJ_INIT (-16)
return 0;
}
-int ss_process_manager_init(void)
+static void process_init(void *data)
{
ss_action_entry_add_internal(PREDEF_FOREGRD, set_foregrd_action, NULL,
NULL);
NULL);
ss_action_entry_add_internal(OOMADJ_SET, set_oomadj_action, NULL, NULL);
ss_action_entry_add_internal(PROCESS_GROUP_SET, set_process_group_action, NULL, NULL);
- return 0;
}
+
+const struct device_ops process_device_ops = {
+ .init = process_init,
+};
#ifndef __SS_PROCMGR_H__
#define __SS_PROCMGR_H__
-int ss_process_manager_init(void);
-
int get_app_oomadj(int pid, int *oomadj);
int set_app_oomadj(int pid, int new_oomadj);
#include <vconf.h>
#include <device-node.h>
-#include "device-node.h"
#include "core/log.h"
#include "core/data.h"
#include "display/poll.h"
+#include "core/devices.h"
#define RETRY 3
-int ss_ta_init()
+static void ta_init(void *data)
{
int val = -1, i = 0, pid;
vconf_set_int(VCONFKEY_SYSMAN_CHARGER_STATUS,
VCONFKEY_SYSMAN_CHARGER_DISCONNECTED);
}
- return 0;
}
+
+const struct device_ops ta_device_ops = {
+ .init = ta_init,
+};
#include <errno.h>
#include <sys/stat.h>
#include <vconf.h>
+#include <time.h>
+#include <sys/ioctl.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <sys/timerfd.h>
#include "core/data.h"
#include "core/queue.h"
#include "core/log.h"
+#include "core/devices.h"
#include "display/poll.h"
-#include <time.h>
-#include <sys/ioctl.h>
-#include <linux/rtc.h>
-#include <fcntl.h>
-#include <sys/timerfd.h>
#define PREDEF_SET_DATETIME "set_datetime"
#define PREDEF_SET_TIMEZONE "set_timezone"
return 0;
}
-int ss_time_manager_init(void)
+static void time_init(void *data)
{
ss_action_entry_add_internal(PREDEF_SET_DATETIME, set_datetime_action,
NULL, NULL);
NULL, NULL);
if (timerfd_check_start() == -1) {
_E("fail system time change detector init");
- return -1;
+ return;
}
- return 0;
}
+
+const struct device_ops time_device_ops = {
+ .init = time_init,
+};
#include <vconf.h>
#include <device-node.h>
+#include <poll.h>
#include "core/log.h"
#include "core/launch.h"
#include "core/data.h"
+#include "core/devices.h"
#include "display/poll.h"
#define USBCON_EXEC_PATH PREFIX"/bin/usb-server"
#define RETRY 3
-int ss_usb_init()
+static void usb_init(void *data)
{
int val = -1, i = 0, pid;
pid = ss_launch_if_noexist(USBCON_EXEC_PATH, NULL);
if (pid < 0) {
_E("usb appl launching failed\n");
- return -1;
+ return;
}
}
else if (val==0)
vconf_set_int(VCONFKEY_SYSMAN_USB_STATUS,VCONFKEY_SYSMAN_USB_DISCONNECTED);
}
-
- return 0;
}
+
+const struct device_ops usb_device_ops = {
+ .init = usb_init,
+};
#include "core/log.h"
#include "core/predefine.h"
#include "core/data.h"
+#include "core/devices.h"
#ifndef MERGE_BTW_APPLICATIONS
#define MERGE_BTW_APPLICATIONS
return -1;
}
-int vibrator_init(void)
+static void vibrator_init(void *data)
{
ss_action_entry_add_internal(PREDEF_HAPTIC, haptic_def_predefine_action,
NULL, NULL);
}
+
+const struct device_ops vibrator_device_ops = {
+ .init = vibrator_init,
+};