2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 * Copyright (C) Samsung Electronics, 2016
18 * 2016 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
23 #include <linux/module.h>
24 #include <linux/string.h>
25 #include <linux/uaccess.h>
26 #include <linux/kallsyms.h>
27 #include "kp_module.h"
30 static asmlinkage long (*olog_sys_write)(unsigned int, const char __user *, size_t);
32 static long write_to_stdout(const char *buf, size_t len)
36 mm_segment_t fs = get_fs();
38 ret = olog_sys_write(1, buf, len);
44 static int olog_init(void)
46 olog_sys_write = (void *)kallsyms_lookup_name("sys_write");
47 if (olog_sys_write == NULL) {
48 pr_err("ERR: not found 'sys_write' symbol\n");
55 void olog(const char *fmt, ...)
61 vsnprintf(buf, sizeof(buf), fmt, args);
65 write_to_stdout(buf, strlen(buf));
71 static void print_mod_info(void)
73 struct module *mod = THIS_MODULE;
75 printk("### MOD_INFO:\n");
76 printk(" core: %p..%p\n", mod->module_init, mod->module_init + mod->init_text_size);
77 printk(" init: %p..%p\n", mod->module_core, mod->module_core + mod->core_text_size);
82 /* TODO: move declare to header */
83 int kp_tests_run(void);
85 static int __init tests_init(void)
95 olog("### Begin tests ###\n");
97 olog("### End tests ###\n");
102 static void __exit tests_exit(void)
106 module_init(tests_init);
107 module_exit(tests_exit);
109 MODULE_LICENSE("GPL");