mali mess
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / gpu / mt8127 / mali / ump / common / ump_kernel_common.h
CommitLineData
6fa3eb70
S
1/*
2 * This confidential and proprietary software may be used only as
3 * authorised by a licensing agreement from ARM Limited
02af6beb 4 * (C) COPYRIGHT 2008-2015 ARM Limited
6fa3eb70
S
5 * ALL RIGHTS RESERVED
6 * The entire notice above must be reproduced on all authorised
7 * copies and copies may only be made to the extent permitted
8 * by a licensing agreement from ARM Limited.
9 */
10
11#ifndef __UMP_KERNEL_COMMON_H__
12#define __UMP_KERNEL_COMMON_H__
13
14#include "ump_kernel_types.h"
15#include "ump_kernel_interface.h"
16#include "ump_kernel_descriptor_mapping.h"
02af6beb 17#include "ump_kernel_random_mapping.h"
6fa3eb70
S
18#include "ump_kernel_memory_backend.h"
19
20
21#ifdef DEBUG
22extern int ump_debug_level;
23#define UMP_DEBUG_PRINT(args) _mali_osk_dbgmsg args
24#define UMP_DEBUG_CODE(args) args
25#define DBG_MSG(level,args) do { /* args should be in brackets */ \
26 ((level) <= ump_debug_level)?\
27 UMP_DEBUG_PRINT(("UMP<" #level ">: ")), \
28 UMP_DEBUG_PRINT(args):0; \
02af6beb 29 } while (0)
6fa3eb70
S
30
31#define DBG_MSG_IF(level,condition,args) /* args should be in brackets */ \
02af6beb 32 if((condition)&&((level) <= ump_debug_level)) {\
6fa3eb70
S
33 UMP_DEBUG_PRINT(("UMP<" #level ">: ")); \
34 UMP_DEBUG_PRINT(args); \
02af6beb 35 }
6fa3eb70
S
36
37#define DBG_MSG_ELSE(level,args) /* args should be in brackets */ \
02af6beb 38 else if((level) <= ump_debug_level) { \
6fa3eb70
S
39 UMP_DEBUG_PRINT(("UMP<" #level ">: ")); \
40 UMP_DEBUG_PRINT(args); \
02af6beb 41 }
6fa3eb70
S
42
43#define DEBUG_ASSERT_POINTER(pointer) do {if( (pointer)== NULL) MSG_ERR(("NULL pointer " #pointer)); } while(0)
44#define DEBUG_ASSERT(condition) do {if(!(condition)) MSG_ERR(("ASSERT failed: " #condition)); } while(0)
45#else /* DEBUG */
46#define UMP_DEBUG_PRINT(args) do {} while(0)
47#define UMP_DEBUG_CODE(args)
48#define DBG_MSG(level,args) do {} while(0)
49#define DBG_MSG_IF(level,condition,args) do {} while(0)
50#define DBG_MSG_ELSE(level,args) do {} while(0)
51#define DEBUG_ASSERT(condition) do {} while(0)
52#define DEBUG_ASSERT_POINTER(pointer) do {} while(0)
53#endif /* DEBUG */
54
55#define MSG_ERR(args) do{ /* args should be in brackets */ \
02af6beb
S
56 _mali_osk_dbgmsg("UMP: ERR: %s\n" ,__FILE__); \
57 _mali_osk_dbgmsg( " %s()%4d\n", __FUNCTION__, __LINE__) ; \
58 _mali_osk_dbgmsg args ; \
59 _mali_osk_dbgmsg("\n"); \
6fa3eb70
S
60 } while(0)
61
62#define MSG(args) do{ /* args should be in brackets */ \
02af6beb
S
63 _mali_osk_dbgmsg("UMP: "); \
64 _mali_osk_dbgmsg args; \
65 } while (0)
6fa3eb70
S
66
67
68
69/*
70 * This struct is used to store per session data.
71 * A session is created when someone open() the device, and
72 * closed when someone close() it or the user space application terminates.
73 */
74typedef struct ump_session_data {
75 _mali_osk_list_t list_head_session_memory_list; /**< List of ump allocations made by the process (elements are ump_session_memory_list_element) */
76 _mali_osk_list_t list_head_session_memory_mappings_list; /**< List of ump_memory_allocations mapped in */
77 int api_version;
78 _mali_osk_mutex_t *lock;
02af6beb 79 ump_descriptor_mapping *cookies_map; /**< Secure mapping of cookies from _ump_ukk_map_mem() */
6fa3eb70
S
80 int cache_operations_ongoing;
81 int has_pending_level1_cache_flush;
82} ump_session_data;
83
84
85
86/*
87 * This struct is used to track the UMP memory references a session has.
88 * We need to track this in order to be able to clean up after user space processes
89 * which don't do it themself (e.g. due to a crash or premature termination).
90 */
91typedef struct ump_session_memory_list_element {
02af6beb 92 struct ump_dd_mem *mem;
6fa3eb70
S
93 _mali_osk_list_t list;
94} ump_session_memory_list_element;
95
96
97
98/*
99 * Device specific data, created when device driver is loaded, and then kept as the global variable device.
100 */
101typedef struct ump_dev {
02af6beb
S
102 ump_random_mapping *secure_id_map;
103 ump_memory_backend *backend;
6fa3eb70
S
104} ump_dev;
105
106
107
108extern int ump_debug_level;
109extern struct ump_dev device;
110
111_mali_osk_errcode_t ump_kernel_constructor(void);
112void ump_kernel_destructor(void);
02af6beb 113int map_errcode(_mali_osk_errcode_t err);
6fa3eb70
S
114
115/**
116 * variables from user space cannot be dereferenced from kernel space; tagging them
117 * with __user allows the GCC compiler to generate a warning. Other compilers may
118 * not support this so we define it here as an empty macro if the compiler doesn't
119 * define it.
120 */
121#ifndef __user
122#define __user
123#endif
124
125#endif /* __UMP_KERNEL_COMMON_H__ */