2 * Copyright (C) 2011-2012 ARM Limited. All rights reserved.
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.
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.
11 #ifndef __MALI_MEMORY_H__
12 #define __MALI_MEMORY_H__
15 #include "mali_session.h"
17 /** @brief Initialize Mali memory subsystem
19 * Allocate and initialize internal data structures. Must be called before
20 * allocating Mali memory.
22 * @return On success _MALI_OSK_ERR_OK, othervise some error code describing the error.
24 _mali_osk_errcode_t mali_memory_initialize(void);
26 /** @brief Terminate Mali memory system
28 * Clean up and release internal data structures.
30 void mali_memory_terminate(void);
32 /** @brief Start new Mali memory session
34 * Allocate and prepare session specific memory allocation data data. The
35 * session page directory, lock, and descriptor map is set up.
37 * @param mali_session_data pointer to the session data structure
39 _mali_osk_errcode_t mali_memory_session_begin(struct mali_session_data *mali_session_data);
41 /** @brief Close a Mali memory session
43 * Release session specific memory allocation related data.
45 * @param mali_session_data pointer to the session data structure
47 void mali_memory_session_end(struct mali_session_data *mali_session_data);
49 /** @brief Allocate a page table page
51 * Allocate a page for use as a page directory or page table. The page is
52 * mapped into kernel space.
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
58 _mali_osk_errcode_t mali_mmu_get_table_page(u32 *table_page, mali_io_address *mapping);
60 /** @brief Release a page table page
62 * Release a page table page allocated through \a mali_mmu_get_table_page
64 * @param pa the GPU address of the page to release
66 void mali_mmu_release_table_page(u32 pa);
69 /** @brief Parse resource and prepare the OS memory allocator
71 * @param size Maximum size to allocate for Mali GPU.
72 * @return _MALI_OSK_ERR_OK on success, otherwise failure.
74 _mali_osk_errcode_t mali_memory_core_resource_os_memory(u32 size);
76 /** @brief Parse resource and prepare the dedicated memory allocator
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.
82 _mali_osk_errcode_t mali_memory_core_resource_dedicated_memory(u32 start, u32 size);
84 mali_allocation_engine mali_mem_get_memory_engine(void);
86 #endif /* __MALI_MEMORY_H__ */