3 * modules/writer/kernel_operations_arm.c
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Copyright (C) Samsung Electronics, 2013
21 * 2013 Alexander Aksenov <a.aksenov@samsung.com>: SWAP Writer module kernel
26 #include <asm/ptrace.h>
27 #include <asm/uaccess.h>
29 #include <linux/kernel.h>
31 #include <generated/autoconf.h>
33 #include "kernel_operations.h"
36 /* ======================= ARGS ========================== */
38 int get_args(unsigned long args[], int cnt, struct pt_regs *regs)
40 /* All args, except first 4, are passed on the stack */
41 enum { stack_args = 4 };
44 args_in_regs = cnt < 3 ? cnt : 3;
46 /* Get first 4 args from registers */
47 switch (args_in_regs) {
49 args[3] = regs->ARM_r3;
51 args[2] = regs->ARM_r2;
53 args[1] = regs->ARM_r1;
55 args[0] = regs->ARM_r0;
58 /* Get other args from stack */
59 for (i = stack_args; i < cnt; ++i) {
60 unsigned long *args_in_sp = (unsigned long *)regs->ARM_sp +
62 if (get_user(args[i], args_in_sp))
63 printk("failed to dereference a pointer, addr=%p\n",
71 /* ================== KERNEL SHARED MEM ===================== */
73 /* CONFIG_VECTORS_BASE used to handle both MMU and non-MMU cases.
74 * According to docs (Documentation/arm/memory.txt) all vector addresses
75 * are fixed and vectors are always equal to one page, so,
76 * end = start + PAGE_SIZE
79 const char *get_shared_kmem(struct mm_struct *mm, unsigned long *start,
82 *start = CONFIG_VECTORS_BASE;
83 *end = CONFIG_VECTORS_BASE + PAGE_SIZE;