import OT_8063_20170412 mali driver
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / gpu / mt8127 / mali / mali / linux / mali_osk_misc.c
CommitLineData
6fa3eb70
S
1/*
2 * This confidential and proprietary software may be used only as
3 * authorised by a licensing agreement from ARM Limited
bdc132d7 4 * (C) COPYRIGHT 2008-2015 ARM Limited
6fa3eb70
S
5 * ALL RIGHTS RESERVED
6 * The entire notice above must be reproduced on all authorised
7 * copies and copies may only be made to the extent permitted
8 * by a licensing agreement from ARM Limited.
9 */
10
11/**
12 * @file mali_osk_misc.c
13 * Implementation of the OS abstraction layer for the kernel device driver
14 */
15#include <linux/kernel.h>
16#include <asm/uaccess.h>
17#include <asm/cacheflush.h>
18#include <linux/sched.h>
bdc132d7 19#include <linux/seq_file.h>
6fa3eb70
S
20#include <linux/module.h>
21#include "mali_osk.h"
6fa3eb70 22
bdc132d7 23extern void dump_clk_state(void);
6fa3eb70 24
bdc132d7
S
25#if !defined(CONFIG_MALI_QUIET)
26void _mali_osk_dbgmsg(const char *fmt, ...)
6fa3eb70
S
27{
28 va_list args;
29 va_start(args, fmt);
30 vprintk(fmt, args);
31 va_end(args);
32}
bdc132d7 33#endif /* !defined(CONFIG_MALI_QUIET) */
6fa3eb70 34
bdc132d7 35u32 _mali_osk_snprintf(char *buf, u32 size, const char *fmt, ...)
6fa3eb70
S
36{
37 int res;
38 va_list args;
39 va_start(args, fmt);
40
41 res = vscnprintf(buf, (size_t)size, fmt, args);
42
43 va_end(args);
44 return res;
45}
46
bdc132d7
S
47void _mali_osk_ctxprintf(_mali_osk_print_ctx *print_ctx, const char *fmt, ...)
48{
49 va_list args;
50 char buf[512];
51
52 va_start(args, fmt);
53 vscnprintf(buf, 512, fmt, args);
54 seq_printf(print_ctx, buf);
55 va_end(args);
56}
6fa3eb70
S
57
58void _mali_osk_abort(void)
59{
6fa3eb70
S
60 /* make a simple fault by dereferencing a NULL pointer */
61 dump_stack();
bdc132d7 62 *(int *)0 = 0;
6fa3eb70
S
63}
64
65void _mali_osk_break(void)
66{
bdc132d7 67 dump_clk_state();
6fa3eb70
S
68 _mali_osk_abort();
69}
70
71u32 _mali_osk_get_pid(void)
72{
73 /* Thread group ID is the process ID on Linux */
74 return (u32)current->tgid;
75}
76
bdc132d7
S
77char *_mali_osk_get_comm(void)
78{
79 return (char *)current->comm;
80}
81
82
6fa3eb70
S
83u32 _mali_osk_get_tid(void)
84{
85 /* pid is actually identifying the thread on Linux */
86 u32 tid = current->pid;
87
88 /* If the pid is 0 the core was idle. Instead of returning 0 we return a special number
89 * identifying which core we are on. */
90 if (0 == tid) {
91 tid = -(1 + raw_smp_processor_id());
92 }
93
94 return tid;
95}