tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / mali / common / mali_memory.h
1 /*
2  * Copyright (C) 2011-2012 ARM Limited. All rights reserved.
3  *
4  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6  *
7  * A copy of the licence is included with the program, and can also be obtained from Free Software
8  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9  */
10
11 #ifndef __MALI_MEMORY_H__
12 #define __MALI_MEMORY_H__
13
14 #include "mali_osk.h"
15 #include "mali_session.h"
16
17 /** @brief Initialize Mali memory subsystem
18  *
19  * Allocate and initialize internal data structures. Must be called before
20  * allocating Mali memory.
21  *
22  * @return On success _MALI_OSK_ERR_OK, othervise some error code describing the error.
23  */
24 _mali_osk_errcode_t mali_memory_initialize(void);
25
26 /** @brief Terminate Mali memory system
27  *
28  * Clean up and release internal data structures.
29  */
30 void mali_memory_terminate(void);
31
32 /** @brief Start new Mali memory session
33  *
34  * Allocate and prepare session specific memory allocation data data. The
35  * session page directory, lock, and descriptor map is set up.
36  *
37  * @param mali_session_data pointer to the session data structure
38  */
39 _mali_osk_errcode_t mali_memory_session_begin(struct mali_session_data *mali_session_data);
40
41 /** @brief Close a Mali memory session
42  *
43  * Release session specific memory allocation related data.
44  *
45  * @param mali_session_data pointer to the session data structure
46  */
47 void mali_memory_session_end(struct mali_session_data *mali_session_data);
48
49 /** @brief Allocate a page table page
50  *
51  * Allocate a page for use as a page directory or page table. The page is
52  * mapped into kernel space.
53  *
54  * @return _MALI_OSK_ERR_OK on success, othervise an error code
55  * @param table_page GPU pointer to the allocated page
56  * @param mapping CPU pointer to the mapping of the allocated page
57  */
58 _mali_osk_errcode_t mali_mmu_get_table_page(u32 *table_page, mali_io_address *mapping);
59
60 /** @brief Release a page table page
61  *
62  * Release a page table page allocated through \a mali_mmu_get_table_page
63  *
64  * @param pa the GPU address of the page to release
65  */
66 void mali_mmu_release_table_page(u32 pa);
67
68
69 /** @brief Parse resource and prepare the OS memory allocator
70  *
71  * @param size Maximum size to allocate for Mali GPU.
72  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
73  */
74 _mali_osk_errcode_t mali_memory_core_resource_os_memory(u32 size);
75
76 /** @brief Parse resource and prepare the dedicated memory allocator
77  *
78  * @param start Physical start address of dedicated Mali GPU memory.
79  * @param size Size of dedicated Mali GPU memory.
80  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
81  */
82 _mali_osk_errcode_t mali_memory_core_resource_dedicated_memory(u32 start, u32 size);
83
84 mali_allocation_engine mali_mem_get_memory_engine(void);
85
86 #endif /* __MALI_MEMORY_H__ */