aboutsummaryrefslogtreecommitdiffstats
path: root/security/tf_driver/tf_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'security/tf_driver/tf_util.h')
-rw-r--r--security/tf_driver/tf_util.h122
1 files changed, 122 insertions, 0 deletions
diff --git a/security/tf_driver/tf_util.h b/security/tf_driver/tf_util.h
new file mode 100644
index 00000000000..14bc78952d8
--- /dev/null
+++ b/security/tf_driver/tf_util.h
@@ -0,0 +1,122 @@
1/**
2 * Copyright (c) 2011 Trusted Logic S.A.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17 * MA 02111-1307 USA
18 */
19
20#ifndef __TF_UTIL_H__
21#define __TF_UTIL_H__
22
23#include <linux/spinlock.h>
24#include <linux/errno.h>
25#include <linux/init.h>
26#include <linux/module.h>
27#include <linux/mm.h>
28#include <linux/crypto.h>
29#include <linux/mount.h>
30#include <linux/pagemap.h>
31#include <linux/vmalloc.h>
32#include <asm/byteorder.h>
33
34#include "tf_protocol.h"
35#include "tf_defs.h"
36
37/*----------------------------------------------------------------------------
38 * Debug printing routines
39 *----------------------------------------------------------------------------*/
40
41#ifdef CONFIG_TF_DRIVER_DEBUG_SUPPORT
42extern unsigned tf_debug_level;
43
44void address_cache_property(unsigned long va);
45
46#define dprintk(args...) ((void)(tf_debug_level >= 6 ? printk(args) : 0))
47#define dpr_info(args...) ((void)(tf_debug_level >= 3 ? pr_info(args) : 0))
48#define dpr_err(args...) ((void)(tf_debug_level >= 1 ? pr_err(args) : 0))
49#define INFO(fmt, args...) \
50 (void)dprintk(KERN_INFO "%s: " fmt "\n", __func__, ## args)
51#define WARNING(fmt, args...) \
52 (tf_debug_level >= 3 ? \
53 printk(KERN_WARNING "%s: " fmt "\n", __func__, ## args) : \
54 (void)0)
55#define ERROR(fmt, args...) \
56 (tf_debug_level >= 1 ? \
57 printk(KERN_ERR "%s: " fmt "\n", __func__, ## args) : \
58 (void)0)
59void tf_trace_array(const char *fun, const char *msg,
60 const void *ptr, size_t len);
61#define TF_TRACE_ARRAY(ptr, len) \
62 (tf_debug_level >= 7 ? \
63 tf_trace_array(__func__, #ptr "/" #len, ptr, len) : \
64 0)
65
66void tf_dump_l1_shared_buffer(struct tf_l1_shared_buffer *buffer);
67
68void tf_dump_command(union tf_command *command);
69
70void tf_dump_answer(union tf_answer *answer);
71
72#else /* defined(CONFIG_TF_DRIVER_DEBUG_SUPPORT) */
73
74#define dprintk(args...) do { ; } while (0)
75#define dpr_info(args...) do { ; } while (0)
76#define dpr_err(args...) do { ; } while (0)
77#define INFO(fmt, args...) ((void)0)
78#define WARNING(fmt, args...) ((void)0)
79#define ERROR(fmt, args...) ((void)0)
80#define TF_TRACE_ARRAY(ptr, len) ((void)(ptr), (void)(len))
81#define tf_dump_l1_shared_buffer(buffer) ((void) 0)
82#define tf_dump_command(command) ((void) 0)
83#define tf_dump_answer(answer) ((void) 0)
84
85#endif /* defined(CONFIG_TF_DRIVER_DEBUG_SUPPORT) */
86
87#define SHA1_DIGEST_SIZE 20
88
89/*----------------------------------------------------------------------------
90 * Process identification
91 *----------------------------------------------------------------------------*/
92
93int tf_get_current_process_hash(void *hash);
94
95#ifndef CONFIG_ANDROID
96int tf_hash_application_path_and_data(char *buffer, void *data, u32 data_len);
97#endif /* !CONFIG_ANDROID */
98
99/*----------------------------------------------------------------------------
100 * Statistic computation
101 *----------------------------------------------------------------------------*/
102
103void *internal_kmalloc(size_t size, int priority);
104void internal_kfree(void *ptr);
105void internal_vunmap(void *ptr);
106void *internal_vmalloc(size_t size);
107void internal_vfree(void *ptr);
108unsigned long internal_get_zeroed_page(int priority);
109void internal_free_page(unsigned long addr);
110int internal_get_user_pages(
111 struct task_struct *tsk,
112 struct mm_struct *mm,
113 unsigned long start,
114 int len,
115 int write,
116 int force,
117 struct page **pages,
118 struct vm_area_struct **vmas);
119void internal_get_page(struct page *page);
120void internal_page_cache_release(struct page *page);
121#endif /* __TF_UTIL_H__ */
122