summaryrefstree
path: root/kernel/drivers/misc/tzdev/tz_mem.h
blob: 5b3fcaa1aed547d10ca4b6ebe44cb418883f74f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * Copyright (C) 2012-2017, Samsung Electronics Co., Ltd.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * 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.
 */

#ifndef __TZ_MEM_H__
#define __TZ_MEM_H__

#include <linux/mm.h>
#include <linux/pid.h>

#include <tz_cred.h>

typedef void (*tzdev_mem_free_func_t)(void *);

struct tzdev_mem_reg {
	struct pid *pid;
	unsigned long nr_pages;
	struct page **pages;
	tzdev_mem_free_func_t free_func;
	void *free_data;
	unsigned int in_release;
	struct tz_cred cred;
};

int tzdev_mem_init(void);
void tzdev_mem_fini(void);

int tzdev_mem_register_user(void *ptr, unsigned long size, unsigned int write);
int tzdev_mem_release_user(unsigned int id);

int tzdev_mem_register(void *ptr, unsigned long size, unsigned int write,
		tzdev_mem_free_func_t free_func, void *free_data);
int tzdev_mem_release(unsigned int id);
int tzdev_get_user_pages(struct task_struct *task, struct mm_struct *mm,
		unsigned long start, unsigned long nr_pages, int write,
		int force, struct page **pages, struct vm_area_struct **vmas);
int tzdev_migrate_pages(struct task_struct *task, struct mm_struct *mm,
		unsigned long start, unsigned long nr_pages, int write,
		int force, struct page **pages);
void tzdev_put_user_pages(struct page **pages, unsigned long nr_pages);
void tzdev_decrease_pinned_vm(struct mm_struct *mm, unsigned long nr_pages);
void tzdev_mem_release_panic_handler(void);

#endif /* __TZ_MEM_H__ */