3 * (C) COPYRIGHT 2008-2011 ARM Limited. All rights reserved.
5 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
8 * A copy of the licence is included with the program, and can also be obtained from Free Software
9 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * Implementation of the OS abstraction layer for the kernel device driver
20 #ifndef _OSK_ARCH_CREDENTIALS_H_
21 #define _OSK_ARCH_CREDENTIALS_H_
24 #error "Include mali_osk.h directly"
27 #include <linux/cred.h>
29 OSK_STATIC_INLINE mali_bool osk_is_privileged(void)
31 mali_bool is_privileged = MALI_FALSE;
33 /* Check if the caller is root */
34 if (current_euid() == 0)
36 is_privileged = MALI_TRUE;
42 OSK_STATIC_INLINE mali_bool osk_is_policy_realtime(void)
44 int policy = current->policy;
46 if (policy == SCHED_FIFO || policy == SCHED_RR)
54 OSK_STATIC_INLINE void osk_get_process_priority(osk_process_priority *prio)
56 /* Note that we return the current process priority.
57 * If called from a kernel thread the priority returned
58 * will be the kernel thread priority and not the user
59 * process that is currently submitting jobs to the scheduler.
63 if(osk_is_policy_realtime())
65 prio->is_realtime = MALI_TRUE;
66 /* NOTE: realtime range was in the range 0..99 (lowest to highest) so we invert
67 * the priority and scale to -20..0 to normalize the result with the NICE range
69 prio->priority = (((MAX_RT_PRIO-1) - current->rt_priority) / 5) - 20;
70 /* Realtime range returned:
71 * -20 - highest priority
77 prio->is_realtime = MALI_FALSE;
78 prio->priority = (current->static_prio - MAX_RT_PRIO) - 20;
79 /* NICE range returned:
80 * -20 - highest priority
81 * +19 - lowest priority
86 #endif /* _OSK_ARCH_CREDENTIALS_H_ */