summaryrefslogtreecommitdiffstats
path: root/include/asm-mips/current.h
blob: 7d1547b3c21f306acbde5e2e1eac49d1ff0cbc58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef __ASM_MIPS_CURRENT_H
#define __ASM_MIPS_CURRENT_H

#ifdef __LANGUAGE_C__

static inline struct task_struct *__get_current(void)
{
	struct task_struct *__current;

	__asm__("ori\t%0,$29,%1\n\t"
	        "xori\t%0,%1"
		 :"=r" (__current)
	         :"ir" (8191UL));

	return __current;
}

#define current __get_current()

#endif /* __LANGUAGE_C__ */
#ifdef __LANGUAGE_ASSEMBLY__

/*
 * Get current task pointer
 */
#define GET_CURRENT(reg)			\
	lui	reg, %hi(kernelsp);		\
	lw	reg, %lo(kernelsp)(reg);	\
	ori	reg, 8191;			\
	xori	reg, 8191

/*
 * Special variant for use by exception handlers when the stack pointer
 * is not loaded.
 */
#define _GET_CURRENT(reg)			\
	lui	reg, %hi(kernelsp);		\
	.set	push;				\
	.set	noreorder;			\
	lw	reg, %lo(kernelsp)(reg);	\
	.set	pop;				\
	ori	reg, 8191;			\
	xori	reg, 8191


#endif

#endif /* __ASM_MIPS_CURRENT_H */