97db7e981b2579589062be78ea84874b972c875b
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / gpu / mt8127 / mali / mali / linux / mali_memory_types.h
1 /*
2 * This confidential and proprietary software may be used only as
3 * authorised by a licensing agreement from ARM Limited
4 * (C) COPYRIGHT 2013 ARM Limited
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 __MALI_MEMORY_TYPES_H__
12 #define __MALI_MEMORY_TYPES_H__
13
14 #if defined(CONFIG_MALI400_UMP)
15 #include "ump_kernel_interface.h"
16 #endif
17
18 typedef u32 mali_address_t;
19
20 typedef enum mali_mem_type {
21 MALI_MEM_OS,
22 MALI_MEM_EXTERNAL,
23 MALI_MEM_DMA_BUF,
24 MALI_MEM_UMP,
25 MALI_MEM_BLOCK,
26 } mali_mem_type;
27
28 typedef struct mali_mem_os_mem {
29 struct list_head pages;
30 u32 count;
31 } mali_mem_os_mem;
32
33 typedef struct mali_mem_dma_buf {
34 #if defined(CONFIG_DMA_SHARED_BUFFER)
35 struct mali_dma_buf_attachment *attachment;
36 #endif
37 } mali_mem_dma_buf;
38
39 typedef struct mali_mem_external {
40 dma_addr_t phys;
41 u32 size;
42 } mali_mem_external;
43
44 typedef struct mali_mem_ump {
45 #if defined(CONFIG_MALI400_UMP)
46 ump_dd_handle handle;
47 #endif
48 } mali_mem_ump;
49
50 typedef struct block_allocator_allocation {
51 /* The list will be released in reverse order */
52 struct block_info *last_allocated;
53 u32 mapping_length;
54 struct block_allocator *info;
55 } block_allocator_allocation;
56
57 typedef struct mali_mem_block_mem {
58 block_allocator_allocation mem;
59 } mali_mem_block_mem;
60
61 typedef struct mali_mem_virt_mali_mapping {
62 mali_address_t addr; /* Virtual Mali address */
63 u32 properties; /* MMU Permissions + cache, must match MMU HW */
64 } mali_mem_virt_mali_mapping;
65
66 typedef struct mali_mem_virt_cpu_mapping {
67 void __user *addr;
68 u32 ref;
69 } mali_mem_virt_cpu_mapping;
70
71 #define MALI_MEM_ALLOCATION_VALID_MAGIC 0xdeda110c
72 #define MALI_MEM_ALLOCATION_FREED_MAGIC 0x10101010
73
74 typedef struct mali_mem_allocation {
75 MALI_DEBUG_CODE(u32 magic);
76 mali_mem_type type; /**< Type of memory */
77 int id; /**< ID in the descriptor map for this allocation */
78
79 u32 size; /**< Size of the allocation */
80 u32 flags; /**< Flags for this allocation */
81
82 struct mali_session_data *session; /**< Pointer to session that owns the allocation */
83
84 /* Union selected by type. */
85 union {
86 mali_mem_os_mem os_mem; /**< MALI_MEM_OS */
87 mali_mem_external ext_mem; /**< MALI_MEM_EXTERNAL */
88 mali_mem_dma_buf dma_buf; /**< MALI_MEM_DMA_BUF */
89 mali_mem_ump ump_mem; /**< MALI_MEM_UMP */
90 mali_mem_block_mem block_mem; /**< MALI_MEM_BLOCK */
91 };
92
93 mali_mem_virt_cpu_mapping cpu_mapping; /**< CPU mapping */
94 mali_mem_virt_mali_mapping mali_mapping; /**< Mali mapping */
95 } mali_mem_allocation;
96
97 #define MALI_MEM_FLAG_MALI_GUARD_PAGE (1 << 0)
98 #define MALI_MEM_FLAG_DONT_CPU_MAP (1 << 1)
99
100 #endif /* __MALI_MEMORY_TYPES__ */