2 * Copyright (C) 2010-2015 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.
12 * @file mali_osk_misc.c
13 * Implementation of the OS abstraction layer for the kernel device driver
15 #include <linux/kernel.h>
16 #include <asm/uaccess.h>
17 #include <asm/cacheflush.h>
18 #include <linux/sched.h>
19 #include <linux/seq_file.h>
20 #include <linux/module.h>
23 #if !defined(CONFIG_MALI_QUIET)
24 void _mali_osk_dbgmsg(const char *fmt, ...)
31 #endif /* !defined(CONFIG_MALI_QUIET) */
33 u32 _mali_osk_snprintf(char *buf, u32 size, const char *fmt, ...)
39 res = vscnprintf(buf, (size_t)size, fmt, args);
45 void _mali_osk_ctxprintf(_mali_osk_print_ctx *print_ctx, const char *fmt, ...)
51 vscnprintf(buf, 512, fmt, args);
52 seq_printf(print_ctx, buf);
56 void _mali_osk_abort(void)
58 /* make a simple fault by dereferencing a NULL pointer */
63 void _mali_osk_break(void)
68 u32 _mali_osk_get_pid(void)
70 /* Thread group ID is the process ID on Linux */
71 return (u32)current->tgid;
74 char *_mali_osk_get_comm(void)
76 return (char *)current->comm;
80 u32 _mali_osk_get_tid(void)
82 /* pid is actually identifying the thread on Linux */
83 u32 tid = current->pid;
85 /* If the pid is 0 the core was idle. Instead of returning 0 we return a special number
86 * identifying which core we are on. */
88 tid = -(1 + raw_smp_processor_id());