2 * @file writer/kernel_operations.h
3 * @author Alexander Aksenov <a.aksenov@samsung.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * Copyright (C) Samsung Electronics, 2013
25 * @section DESCRIPTION
27 * Writer kernel operations.
30 /* Kernel functions wrap */
32 #ifndef __KERNEL_OPERATIONS_H__
33 #define __KERNEL_OPERATIONS_H__
35 #include <linux/kernel.h>
36 #include <asm/ptrace.h>
40 /** Prints debug message.*/
41 #define print_debug(msg, args...) \
42 printk(KERN_DEBUG "SWAP_WRITER DEBUG : " msg, ##args)
43 /** Prints info message.*/
44 #define print_msg(msg, args...) \
45 printk(KERN_INFO "SWAP_WRITER : " msg, ##args)
46 /** Prints warning message.*/
47 #define print_warn(msg, args...) \
48 printk(KERN_WARNING "SWAP_WRITER WARNING : " msg, ##args)
49 /** Prints error message.*/
50 #define print_err(msg, args...) \
51 printk(KERN_ERR "SWAP_WRITER ERROR : " msg, ##args)
52 /** Prints critical error message.*/
53 #define print_crit(msg, args...) \
54 printk(KERN_CRIT "SWAP_WRITER CRITICAL : " msg, ##args)
56 /* ARCH-DEPENDED OPERATIONS */
59 /* Regs manipulations */
60 #if defined(CONFIG_ARM)
62 #define get_regs_ip(regs) (regs->ARM_pc) /**< Get pc reg. */
63 #define get_regs_ret_func(regs) (regs->ARM_lr) /**< Get lr reg. */
64 #define get_regs_ret_val(regs) (regs->ARM_r0) /**< Get ret val. */
65 #define get_regs_stack_ptr(regs) (regs->ARM_sp) /**< Get stack pointer. */
67 #elif defined(CONFIG_X86_32)
69 #define get_regs_ip(regs) (regs->ip - 1) /**< Get ip. */
70 #define get_regs_ret_val(regs) (regs->ax) /**< Get ret val. */
71 #define get_regs_stack_ptr(regs) (regs->sp) /**< Get stack pointer. */
73 static inline u32 get_regs_ret_func(struct pt_regs *regs)
77 if (user_mode(regs)) {
79 if (get_user(addr, sp))
80 printk(KERN_INFO "failed to dereference a pointer, sp=%p, "
81 "pc=%lx\n", sp, get_regs_ip(regs));
83 sp = (u32 *)kernel_stack_pointer(regs);
90 #endif /* CONFIG_arch */
92 int get_args(unsigned long args[], int cnt, struct pt_regs *regs);
94 /* Returns shared kernel memory area name if it is found, otherwise - NULL */
95 const char *get_shared_kmem(struct mm_struct *mm, unsigned long *start,
98 #endif /* __KERNEL_OPERATIONS_H__ */