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_SESSION_H__
12 #define __MALI_SESSION_H__
14 #include "mali_mmu_page_directory.h"
15 #include "mali_kernel_descriptor_mapping.h"
17 #include "mali_osk_list.h"
19 struct mali_session_data
21 _mali_osk_notification_queue_t * ioctl_queue;
25 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
26 _mali_osk_list_t pending_jobs;
27 _mali_osk_lock_t *pending_jobs_lock;
31 _mali_osk_lock_t *memory_lock; /**< Lock protecting the vm manipulation */
32 mali_descriptor_mapping * descriptor_mapping; /**< Mapping between userspace descriptors and our pointers */
33 _mali_osk_list_t memory_head; /**< Track all the memory allocated in this session, for freeing on abnormal termination */
35 struct mali_page_directory *page_directory; /**< MMU page directory for this session */
37 _MALI_OSK_LIST_HEAD(link); /**< Link for list of all sessions */
39 _MALI_OSK_LIST_HEAD(job_list); /**< List of all jobs on this session */
42 _mali_osk_errcode_t mali_session_initialize(void);
43 void mali_session_terminate(void);
45 /* List of all sessions. Actual list head in mali_kernel_core.c */
46 extern _mali_osk_list_t mali_sessions;
47 /* Lock to protect modification and access to the mali_sessions list */
48 extern _mali_osk_lock_t *mali_sessions_lock;
50 MALI_STATIC_INLINE void mali_session_lock(void)
52 _mali_osk_lock_wait(mali_sessions_lock, _MALI_OSK_LOCKMODE_RW);
55 MALI_STATIC_INLINE void mali_session_unlock(void)
57 _mali_osk_lock_signal(mali_sessions_lock, _MALI_OSK_LOCKMODE_RW);
60 void mali_session_add(struct mali_session_data *session);
61 void mali_session_remove(struct mali_session_data *session);
62 #define MALI_SESSION_FOREACH(session, tmp, link) \
63 _MALI_OSK_LIST_FOREACHENTRY(session, tmp, &mali_sessions, struct mali_session_data, link)
65 MALI_STATIC_INLINE struct mali_page_directory *mali_session_get_page_directory(struct mali_session_data *session)
67 return session->page_directory;
70 MALI_STATIC_INLINE void mali_session_send_notification(struct mali_session_data *session, _mali_osk_notification_t *object)
72 _mali_osk_notification_queue_send(session->ioctl_queue, object);
75 #endif /* __MALI_SESSION_H__ */