retprobe/ \
preload/ \
fbiprobe/ \
- wsp/ \
nsp/ \
task_ctx/ \
got_patcher/
loader/swap_loader.ko
preload/swap_preload.ko
fbiprobe/swap_fbiprobe.ko
- wsp/swap_wsp.ko
nsp/swap_nsp.ko
task_ctx/swap_taskctx.ko
got_patcher/swap_gtp.ko"
+++ /dev/null
-EXTRA_CFLAGS := $(extra_cflags)
-
-obj-m := swap_wsp.o
-swap_wsp-y := wsp_module.o \
- wsp_msg.o \
- wsp_debugfs.o \
- wsp.o \
- wsp_res.o
+++ /dev/null
-/*
- * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
- * @section LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * @section COPYRIGHT
- *
- * Copyright (C) Samsung Electronics, 2015
- *
- * @section DESCRIPTION
- *
- * Web startup profiling
- */
-
-#include <linux/string.h>
-#include <us_manager/sspt/sspt.h>
-#include <us_manager/probes/probe_info_new.h>
-#include "wsp.h"
-#include "wsp_res.h"
-#include "wsp_msg.h"
-
-struct wsp_probe {
- const char *name;
- struct probe_new probe;
-};
-
-struct wsp_bin {
- const char *name;
- unsigned long cnt;
- struct wsp_probe *probe_array;
-};
-
-static char *webapp_path;
-static char *chromium_path;
-
-#define WSP_PROBE_MAKE(_name_, _offset_, _desc_) \
-{ \
- .name = (_name_), \
- .probe.offset = (_offset_), \
- .probe.desc = (_desc_) \
-}
-
-/*
- * res_request
- */
-/* blink::ResourceLoader.m_request.m_url */
-#define URL_OFFSET 84
-/* base::String.m_impl.m_ptr */
-#define URL_LEN_OFFSET 4
-#define URL_DATA_OFFSET 12
-
-static char *path_get_from_object(unsigned long ptr)
-{
- char *path;
- unsigned long url, len, ret;
-
- get_user(url, (unsigned long __user *)(ptr + URL_OFFSET));
- get_user(len, (unsigned long __user *)(url + URL_LEN_OFFSET));
- path = kzalloc(len + 1, GFP_KERNEL);
- if (!path)
- return NULL;
-
- ret = copy_from_user(path,
- (const void __user *)(url + URL_DATA_OFFSET),
- len);
- if (ret) {
- kfree(path);
- path = NULL;
- } else {
- path[len] = '\0';
- }
-
- return path;
-}
-
-static int res_request_handle(struct uprobe *p, struct pt_regs *regs)
-{
- unsigned long ptr;
- char *path;
-
- ptr = (unsigned long)swap_get_uarg(regs, 0);
- path = path_get_from_object(ptr);
- if (path) {
- int id = wsp_resource_data_add(ptr, path);
- if (id >= 0)
- wsp_msg(WSP_RES_LOAD_BEGIN, id, path);
- }
-
- kfree(path);
-
- return 0;
-}
-
-static struct probe_desc res_request = MAKE_UPROBE(res_request_handle);
-
-/*
- * res_finish
- */
-static int res_finish_ehandle(struct uretprobe_instance *ri,
- struct pt_regs *regs)
-{
- int id;
- unsigned long ptr = (unsigned long)swap_get_uarg(regs, 0);
-
- id = wsp_resource_data_id(ptr);
- if (id >= 0) {
- *(unsigned long *)ri->data = ptr;
- wsp_msg(WSP_RES_PROC_BEGIN, id, NULL);
- }
-
- return 0;
-}
-
-static int res_finish_rhandle(struct uretprobe_instance *ri,
- struct pt_regs *regs)
-{
- int id;
- unsigned long ptr;
-
- ptr = *(unsigned long *)ri->data;
- id = wsp_resource_data_id(ptr);
- if (id >= 0) {
- wsp_msg(WSP_RES_PROC_END, id, NULL);
- wsp_msg(WSP_RES_LOAD_END, id, NULL);
- wsp_resource_data_del(ptr);
- }
-
- return 0;
-}
-
-static struct probe_desc res_finish =
- MAKE_URPROBE(res_finish_ehandle, res_finish_rhandle,
- sizeof(unsigned long));
-
-/*
- * redraw
- */
-static int redraw_eh(struct uretprobe_instance *ri, struct pt_regs *regs)
-{
- wsp_msg(WSP_DRAW_BEGIN, 0, NULL);
-
- return 0;
-}
-
-static int redraw_rh(struct uretprobe_instance *ri, struct pt_regs *regs)
-{
- wsp_msg(WSP_DRAW_END, 0, NULL);
-
- return 0;
-}
-
-static struct probe_desc redraw = MAKE_URPROBE(redraw_eh, redraw_rh, 0);
-
-/* blink::ResourceLoader::start() */
-#define RES_REQ "_ZN5blink14ResourceLoader5startEv"
-/* blink::ResourceLoader::didFinishLoading(WebURLLoader*, double , int64_t) */
-#define RES_FINISH "_ZN5blink14ResourceLoader16didFinishLoadingEPNS_12WebURLLoaderEdx"
-
-/* content::RenderWidget::DidCommitAndDrawCompositorFrame */
-#define REDRAW "_ZN7content23CompositorOutputSurface11SwapBuffersEPN2cc15CompositorFrameE"
-
-static struct wsp_probe __probe_array[] = {
- /* res */
- WSP_PROBE_MAKE(RES_REQ, 0, &res_request),
- WSP_PROBE_MAKE(RES_FINISH, 0, &res_finish),
-
- /* redraw */
- WSP_PROBE_MAKE(REDRAW, 0, &redraw),
-};
-
-static struct wsp_bin chromium_bin = {
- .name = NULL,
- .probe_array = __probe_array,
- .cnt = ARRAY_SIZE(__probe_array)
-};
-
-/* check chromium_bin array on init address */
-static bool wsp_is_addr_init(void)
-{
- int i;
-
- for (i = 0; i < chromium_bin.cnt; ++i)
- if (chromium_bin.probe_array[i].probe.offset == 0)
- return false;
-
- return true;
-}
-
-static int wsp_bin_register(struct pf_group *pfg, struct wsp_bin *bin)
-{
- int i, ret;
- struct dentry *dentry;
-
- dentry = dentry_by_path(bin->name);
- if (!dentry) {
- pr_err("dentry not found (path='%s'\n", bin->name);
- return -EINVAL;
- }
-
- for (i = 0; i < bin->cnt; ++i) {
- struct wsp_probe *p = &bin->probe_array[i];
-
- ret = pin_register(&p->probe, pfg, dentry);
- if (ret) {
- pr_err("failed to register WSP probe (%lx:%d)\n",
- p->probe.offset, ret);
- return ret;
- }
- }
-
- return 0;
-}
-
-static void wsp_bin_unregister(struct pf_group *pfg, struct wsp_bin *bin)
-{
- int i;
- struct dentry *dentry;
-
- dentry = dentry_by_path(bin->name);
- if (!dentry) {
- pr_err("dentry not found (path='%s'\n", bin->name);
- return;
- }
-
- for (i = 0; i < bin->cnt; ++i) {
- struct wsp_probe *p = &bin->probe_array[i];
-
- pin_unregister(&p->probe, pfg);
- }
-}
-
-static char *do_set_path(char *path, size_t len)
-{
- char *p;
-
- p = kmalloc(len, GFP_KERNEL);
- if (!p)
- return NULL;
-
- strncpy(p, path, len);
- return p;
-}
-
-static void do_free_path(char **dest)
-{
- kfree(*dest);
- *dest = NULL;
-}
-
-static struct pf_group *g_pfg;
-
-static int wsp_app_register(void)
-{
- struct dentry *dentry;
-
- if (!webapp_path || !chromium_path) {
- pr_err("WSP: some required paths are not set!\n");
- return -EINVAL;
- }
-
- chromium_bin.name = chromium_path;
-
- dentry = dentry_by_path(webapp_path);
- if (!dentry) {
- pr_err("dentry not found (path='%s'\n", webapp_path);
- return -EINVAL;
- }
-
- g_pfg = get_pf_group_by_dentry(dentry, (void *)dentry);
- if (!g_pfg) {
- pr_err("WSP: g_pfg is NULL (by dentry=%p)\n", dentry);
- return -ENOMEM;
- }
-
- return wsp_bin_register(g_pfg, &chromium_bin);
-}
-
-static void wsp_app_unregister(void)
-{
- if (!chromium_bin.name) {
- pr_err("WSP: chromium path is not initialized\n");
- return;
- }
-
- wsp_bin_unregister(g_pfg, &chromium_bin);
- put_pf_group(g_pfg);
-}
-
-static int do_wsp_on(void)
-{
- int ret;
-
- ret = wsp_res_init();
- if (ret)
- return ret;
-
- ret = wsp_app_register();
- if (ret)
- wsp_res_exit();
-
- return ret;
-}
-
-static int do_wsp_off(void)
-{
- wsp_app_unregister();
- wsp_res_exit();
-
- return 0;
-}
-
-static enum wsp_mode g_mode = WSP_OFF;
-static DEFINE_MUTEX(g_mode_mutex);
-
-int wsp_set_addr(const char *name, unsigned long offset)
-{
- int i, ret = 0;
-
- if (mutex_trylock(&g_mode_mutex) == 0)
- return -EBUSY;
-
- for (i = 0; i < chromium_bin.cnt; ++i) {
- if (!strcmp(name, chromium_bin.probe_array[i].name)) {
- chromium_bin.probe_array[i].probe.offset = offset;
- goto unlock;
- }
- }
-
- ret = -EINVAL;
-
-unlock:
- mutex_unlock(&g_mode_mutex);
- return ret;
-}
-
-int wsp_set_mode(enum wsp_mode mode)
-{
- int ret = -EINVAL;
-
- if (g_mode == mode)
- return -EBUSY;
-
- mutex_lock(&g_mode_mutex);
- switch (mode) {
- case WSP_ON:
- ret = wsp_is_addr_init() ? do_wsp_on() : -EPERM;
- break;
- case WSP_OFF:
- ret = do_wsp_off();
- break;
- }
-
- if (!ret)
- g_mode = mode;
-
- mutex_unlock(&g_mode_mutex);
- return ret;
-}
-
-enum wsp_mode wsp_get_mode(void)
-{
- return g_mode;
-}
-
-void wsp_set_webapp_path(char *path, size_t len)
-{
- do_free_path(&webapp_path);
- webapp_path = do_set_path(path, len);
-}
-
-void wsp_set_chromium_path(char *path, size_t len)
-{
- do_free_path(&chromium_path);
- chromium_path = do_set_path(path, len);
-}
-
-int wsp_init(void)
-{
- return 0;
-}
-
-void wsp_exit(void)
-{
- wsp_set_mode(WSP_OFF);
- do_free_path(&webapp_path);
- do_free_path(&chromium_path);
-}
+++ /dev/null
-#ifndef _WSP_H
-#define _WSP_H
-
-/*
- * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
- * @section LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * @section COPYRIGHT
- *
- * Copyright (C) Samsung Electronics, 2015
- *
- * @section DESCRIPTION
- *
- * Web startup profiling
- */
-
-enum wsp_mode {
- WSP_ON,
- WSP_OFF
-};
-
-int wsp_set_addr(const char *name, unsigned long offset);
-
-int wsp_set_mode(enum wsp_mode mode);
-enum wsp_mode wsp_get_mode(void);
-
-void wsp_set_webapp_path(char *path, size_t len);
-void wsp_set_chromium_path(char *path, size_t len);
-
-int wsp_init(void);
-void wsp_exit(void);
-
-#endif /* _WSP_H */
+++ /dev/null
-/*
- * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
- * @section LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * @section COPYRIGHT
- *
- * Copyright (C) Samsung Electronics, 2015
- *
- * @section DESCRIPTION
- *
- * Web startup profiling
- */
-
-#include <linux/slab.h>
-#include <linux/debugfs.h>
-#include <linux/uaccess.h>
-#include <master/swap_debugfs.h>
-#include "wsp.h"
-#include "wsp_debugfs.h"
-
-static int do_write_cmd(const char *buf, size_t count)
-{
- int n, ret = 0;
- char *name;
- unsigned long offset;
-
- name = kmalloc(count, GFP_KERNEL);
- if (!name)
- return -ENOMEM;
-
- n = sscanf(buf, "%lx %1024s", &offset, name);
- if (n != 2) {
- ret = -EINVAL;
- goto free_name;
- }
-
- ret = wsp_set_addr(name, offset);
-
-free_name:
- kfree(name);
- return ret;
-}
-
-/* ============================================================================
- * === DEBUGFS FOR CMD ===
- * ============================================================================
- */
-static ssize_t write_cmd(struct file *file, const char __user *user_buf,
- size_t count, loff_t *ppos)
-{
- enum { max_count = 1024 };
- int ret;
- char *buf;
-
- if (count > max_count)
- return -ENOMEM;
-
- buf = kmalloc(count + 1, GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
- if (copy_from_user(buf, user_buf, count)) {
- ret = -EFAULT;
- goto free_buf;
- }
-
- buf[count] = '\0';
- ret = do_write_cmd(buf, count);
-
-free_buf:
- kfree(buf);
- return ret ? ret : count;
-}
-
-static const struct file_operations fops_cmd = {
- .write = write_cmd,
- .llseek = default_llseek,
-};
-
-/* ============================================================================
- * === DEBUGFS FOR ENABLE ===
- * ============================================================================
- */
-static ssize_t read_enabled(struct file *file, char __user *user_buf,
- size_t count, loff_t *ppos)
-{
- char buf[2];
-
- buf[0] = wsp_get_mode() == WSP_OFF ? '0' : '1';
- buf[1] = '\n';
-
- return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
-}
-
-static ssize_t write_enabled(struct file *file, const char __user *user_buf,
- size_t count, loff_t *ppos)
-{
- int ret = 0;
- char buf[32];
- size_t buf_size;
-
- buf_size = min(count, (sizeof(buf) - 1));
- if (copy_from_user(buf, user_buf, buf_size))
- return -EFAULT;
-
- buf[buf_size] = '\0';
- switch (buf[0]) {
- case '1':
- ret = wsp_set_mode(WSP_ON);
- break;
- case '0':
- ret = wsp_set_mode(WSP_OFF);
- break;
- default:
- return -EINVAL;
- }
-
- if (ret)
- return ret;
-
- return count;
-}
-
-static const struct file_operations fops_enabled = {
- .read = read_enabled,
- .write = write_enabled,
- .llseek = default_llseek,
-};
-
-/* ============================================================================
- * === DEBUGFS FOR WEBAPP_PATH ===
- * ============================================================================
- */
-static ssize_t write_webapp_path(struct file *file,
- const char __user *user_buf,
- size_t len, loff_t *ppos)
-{
- ssize_t ret;
- char *path;
-
- path = kmalloc(len, GFP_KERNEL);
- if (!path) {
- ret = -ENOMEM;
- goto write_webapp_path_failed;
- }
-
- if (copy_from_user(path, user_buf, len)) {
- ret = -EINVAL;
- goto write_webapp_path_failed;
- }
-
- path[len - 1] = '\0';
- wsp_set_webapp_path(path, len);
-
- ret = len;
-
-write_webapp_path_failed:
- kfree(path);
-
- return ret;
-}
-
-static const struct file_operations fops_webapp_path = {
- .write = write_webapp_path
-};
-
-/* ============================================================================
- * === DEBUGFS FOR EWEBKIT_PATH ===
- * ============================================================================
- */
-static ssize_t write_ewebkit_path(struct file *file,
- const char __user *user_buf,
- size_t len, loff_t *ppos)
-{
- ssize_t ret;
- char *path;
-
- path = kmalloc(len, GFP_KERNEL);
- if (!path) {
- ret = -ENOMEM;
- goto write_ewebkit_path_failed;
- }
-
- if (copy_from_user(path, user_buf, len)) {
- ret = -EINVAL;
- goto write_ewebkit_path_failed;
- }
-
- path[len - 1] = '\0';
-
- wsp_set_chromium_path(path, len);
-
- ret = len;
-
-write_ewebkit_path_failed:
- kfree(path);
-
- return ret;
-}
-
-static const struct file_operations fops_ewebkit_path = {
- .write = write_ewebkit_path
-};
-
-static struct dentry *wsp_dir;
-
-void wsp_debugfs_exit(void)
-{
- debugfs_remove_recursive(wsp_dir);
- wsp_dir = NULL;
-}
-
-int wsp_debugfs_init(void)
-{
- struct dentry *dentry;
-
- dentry = swap_debugfs_getdir();
- if (!dentry)
- return -ENOENT;
-
- wsp_dir = swap_debugfs_create_dir("wsp", dentry);
- if (!wsp_dir)
- return -ENOMEM;
-
- dentry = swap_debugfs_create_file("enabled", 0600, wsp_dir, NULL,
- &fops_enabled);
- if (!dentry)
- goto fail;
-
- dentry = swap_debugfs_create_file("cmd", 0600, wsp_dir, NULL,
- &fops_cmd);
- if (!dentry)
- goto fail;
-
- dentry = swap_debugfs_create_file("webapp_path", 0600, wsp_dir, NULL,
- &fops_webapp_path);
- if (!dentry)
- goto fail;
-
- dentry = swap_debugfs_create_file("ewebkit_path", 0600, wsp_dir, NULL,
- &fops_ewebkit_path);
- if (!dentry)
- goto fail;
-
- return 0;
-
-fail:
- wsp_debugfs_exit();
- return -ENOMEM;
-}
+++ /dev/null
-#ifndef _WSP_DEBUGFS_H
-#define _WSP_DEBUGFS_H
-
-/*
- * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
- * @section LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * @section COPYRIGHT
- *
- * Copyright (C) Samsung Electronics, 2015
- *
- * @section DESCRIPTION
- *
- * Web startup profiling
- */
-
-int wsp_debugfs_init(void);
-void wsp_debugfs_exit(void);
-
-#endif /* _WSP_DEBUGFS_H */
+++ /dev/null
-/*
- * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
- * @section LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * @section COPYRIGHT
- *
- * Copyright (C) Samsung Electronics, 2015
- *
- * @section DESCRIPTION
- *
- * Web startup profiling
- */
-
-#include <master/swap_initializer.h>
-#include "wsp.h"
-#include "wsp_debugfs.h"
-
-SWAP_LIGHT_INIT_MODULE(NULL, wsp_init, wsp_exit,
- wsp_debugfs_init, wsp_debugfs_exit);
-
-MODULE_LICENSE("GPL");
+++ /dev/null
-/*
- * wsp/wsp_msg.c
- * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
- * @section LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * @section COPYRIGHT
- *
- * Copyright (C) Samsung Electronics, 2015
- *
- * @section DESCRIPTION
- *
- * Web startup profiling
- */
-
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <writer/swap_msg.h>
-#include "wsp_msg.h"
-
-/*
- * MSG_WSP (payload):
- * +-------------+----------+----------+
- * | name | type | length |
- * +-------------+----------+----------+
- * | PID | int | 4 |
- * | wsp_id | int | 4 |
- * | wsp_payload | variable | variable |
- * +-------------+----------+----------+
-
- * wsp_id:
- * - WSP_RES_LOAD_BEGIN = 0x0001
- * - WSP_RES_LOAD_END = 0x0002
- * - WSP_RES_PROC_BEGIN = 0x0003
- * - WSP_RES_PROC_END = 0x0004
- * - WSP_DRAW_BEGIN = 0x0005
- * - WSP_DRAW_END = 0x0006
- *
- * wsp_payload:
- *
- * 1. WSP_RES_LOAD_BEGIN:
- * +--------+--------+----------+
- * | name | type | length |
- * +--------+--------+----------+
- * | res_id | int | 4 |
- * | path | string | variable |
- * +--------+--------+----------+
- *
- * 2. WSP_RES_LOAD_END, WSP_RES_PROC_BEGIN, WSP_RES_PROC_END:
- * +--------+--------+----------+
- * | name | type | length |
- * +--------+--------+----------+
- * | res_id | int | 4 |
- * +--------+--------+----------+
- *
- * 3. WSP_DRAW_BEGIN, WSP_DRAW_END:
- * no wsp_payload
- */
-
-static int pack_wsp_msg(void *data, size_t size, enum wsp_id id,
- u32 res_id, const char *path)
-{
- size_t len;
- const size_t old_size = size;
-
- /* write PID */
- *(u32 *)data = (u32)current->tgid;
- data += 4;
- size -= 4;
-
- /* write wsp_id */
- *(u32 *)data = (u32)id;
- data += 4;
- size -= 4;
-
- /* pack wsp_payload */
- switch (id) {
- case WSP_RES_LOAD_BEGIN:
- len = strlen(path) + 1;
- if (size < len + 4)
- return -ENOMEM;
-
- /* '+ 4' - skip space for res_id */
- memcpy(data + 4, path, len);
- size -= len;
- case WSP_RES_LOAD_END:
- case WSP_RES_PROC_BEGIN:
- case WSP_RES_PROC_END:
- /* write res_id */
- *(u32 *)data = res_id;
- size -= 4;
- break;
-
- case WSP_DRAW_BEGIN:
- case WSP_DRAW_END:
- break;
-
- default:
- pr_err("unknown wsp_id: id=%u\n", (unsigned int)id);
- return -EINVAL;
- }
-
- return old_size - size;
-}
-
-void wsp_msg(enum wsp_id id, u32 res_id, const char *path)
-{
- int ret;
- void *data;
- size_t size;
- struct swap_msg *m;
-
- m = swap_msg_get(MSG_WSP);
- data = swap_msg_payload(m);
- size = swap_msg_size(m);
- ret = pack_wsp_msg(data, size, id, res_id, path);
- if (ret < 0) {
- pr_err("error MSG_WSP packing, ret=%d\n", ret);
- goto put_msg;
- }
-
- swap_msg_flush(m, ret);
-
-put_msg:
- swap_msg_put(m);
-}
+++ /dev/null
-#ifndef _WSP_MSG_H
-#define _WSP_MSG_H
-
-/*
- * wsp/wsp_msg.h
- * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
- * @section LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * @section COPYRIGHT
- *
- * Copyright (C) Samsung Electronics, 2015
- *
- * @section DESCRIPTION
- *
- * Web startup profiling
- */
-
-#include <linux/types.h>
-
-enum wsp_id {
- WSP_RES_LOAD_BEGIN = 0x0001,
- WSP_RES_LOAD_END = 0x0002,
- WSP_RES_PROC_BEGIN = 0x0003,
- WSP_RES_PROC_END = 0x0004,
- WSP_DRAW_BEGIN = 0x0005,
- WSP_DRAW_END = 0x0006
-};
-
-void wsp_msg(enum wsp_id id, u32 res_id, const char *path);
-
-#endif /* _WSP_MSG_H */
+++ /dev/null
-/*
- * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
- * @section LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * @section COPYRIGHT
- *
- * Copyright (C) Samsung Electronics, 2015
- *
- * @section DESCRIPTION
- *
- * Web startup profiling
- */
-
-#include <linux/slab.h>
-#include <linux/atomic.h>
-#include <kprobe/swap_kprobes_deps.h>
-#include "wsp_res.h"
-
-static atomic_t __resource_id = ATOMIC_INIT(0);
-
-static inline int __wsp_resource_id(void)
-{
- return atomic_inc_return(&__resource_id);
-}
-
-struct wsp_resource_data {
- struct list_head list;
- int id;
- unsigned long addr;
- char *path;
-};
-
-static LIST_HEAD(__resources_list);
-static DEFINE_MUTEX(__resources_mutex);
-
-static struct wsp_resource_data *wsp_resource_data_alloc(void)
-{
- struct wsp_resource_data *p;
-
- p = kzalloc(sizeof(*p), GFP_KERNEL);
- if (!p)
- return NULL;
-
- INIT_LIST_HEAD(&p->list);
-
- return p;
-}
-
-static void wsp_resource_data_free(struct wsp_resource_data *p)
-{
- if (!p)
- return;
-
- kfree(p->path);
- kfree(p);
-}
-
-static struct wsp_resource_data *wsp_resource_data_find(unsigned long addr)
-{
- struct wsp_resource_data *p;
-
- list_for_each_entry(p, &__resources_list, list)
- if (p->addr == addr)
- return p;
-
- return NULL;
-}
-
-int wsp_resource_data_id(unsigned long addr)
-{
- int ret = -1;
- struct wsp_resource_data *p;
-
- mutex_lock(&__resources_mutex);
- p = wsp_resource_data_find(addr);
- if (p)
- ret = p->id;
- mutex_unlock(&__resources_mutex);
-
- return ret;
-}
-
-int wsp_resource_data_add(unsigned long addr, char *path)
-{
- int ret = -1;
- struct wsp_resource_data *p;
-
- mutex_lock(&__resources_mutex);
- p = wsp_resource_data_find(addr);
- if (p) {
- ret = p->id;
- goto out;
- }
- p = wsp_resource_data_alloc();
- if (p) {
- p->id = __wsp_resource_id();
- p->addr = addr;
- p->path = kstrndup(path, PATH_MAX, GFP_KERNEL);
- if (!p->path) {
- kfree(p);
- ret = -ENOMEM;
- goto out;
- }
-
- list_add_tail(&p->list, &__resources_list);
- ret = p->id;
- }
-
-out:
- mutex_unlock(&__resources_mutex);
-
- return ret;
-}
-
-void wsp_resource_data_del(unsigned long addr)
-{
- struct wsp_resource_data *p;
-
- mutex_lock(&__resources_mutex);
- p = wsp_resource_data_find(addr);
- if (p) {
- list_del(&p->list);
- wsp_resource_data_free(p);
- }
-
- mutex_unlock(&__resources_mutex);
-}
-
-/* ============================================================================
- * = init/exit() =
- * ============================================================================
- */
-int wsp_res_init(void)
-{
- return 0;
-}
-
-void wsp_res_exit(void)
-{
- struct wsp_resource_data *p, *tmp;
-
- mutex_lock(&__resources_mutex);
- list_for_each_entry_safe(p, tmp, &__resources_list, list) {
- list_del(&p->list);
- wsp_resource_data_free(p);
- }
- mutex_unlock(&__resources_mutex);
-}
+++ /dev/null
-#ifndef _WSP_TDATA_H
-#define _WSP_TDATA_H
-
-/*
- * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
- * @section LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * @section COPYRIGHT
- *
- * Copyright (C) Samsung Electronics, 2015
- *
- * @section DESCRIPTION
- *
- * Web startup profiling
- */
-
-#include <linux/types.h>
-
-int wsp_resource_data_add(unsigned long addr, char *path);
-void wsp_resource_data_del(unsigned long addr);
-int wsp_resource_data_id(unsigned long addr);
-
-int wsp_res_init(void);
-void wsp_res_exit(void);
-
-#endif /* _WSP_TDATA_H */