summaryrefslogtreecommitdiffstats
path: root/include/asm-arm/proc-armv/assembler.h
blob: 128dd198209bd60d1e79d6adf4f4b8c06d79457f (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * linux/asm-arm/proc-armv/assembler.h
 *
 * Copyright (C) 1996 Russell King
 *
 * This file contains arm architecture specific defines
 * for the different processors
 */
#ifndef __ASSEMBLY__
#error "Only include this from assembly code"
#endif

#define MODE_USR	USR_MODE
#define MODE_FIQ	FIQ_MODE
#define MODE_IRQ	IRQ_MODE
#define MODE_SVC	SVC_MODE

#define DEFAULT_FIQ	MODE_FIQ

/*
 * LOADREGS - ldm with PC in register list (eg, ldmfd sp!, {pc})
 * RETINSTR - return instruction (eg, mov pc, lr)
 */
#ifdef __STDC__
#define LOADREGS(cond, base, reglist...)\
	ldm##cond	base,reglist

#define RETINSTR(instr, regs...)\
	instr	regs
#else
#define LOADREGS(cond, base, reglist...)\
	ldm/**/cond	base,reglist

#define RETINSTR(instr, regs...)\
	instr		regs
#endif

/*
 * No nop required after mode change
 */
#define MODENOP

/*
 * Change to `mode'
 */
#define MODE(savereg,tmpreg,mode) \
	mrs	savereg, cpsr; \
	bic	tmpreg, savereg, $0x1f; \
	orr	tmpreg, tmpreg, $mode; \
	msr	cpsr, tmpreg

/*
 * Restore mode
 */
#define RESTOREMODE(savereg) \
	msr	cpsr, savereg

/*
 * save interrupt state (uses stack)
 */	
#define SAVEIRQS(tmpreg)\
	mrs	tmpreg, cpsr; \
	str	tmpreg, [sp, $-4]!

/*
 * restore interrupt state (uses stack)
 */
#define RESTOREIRQS(tmpreg)\
	ldr	tmpreg, [sp], $4; \
	msr	cpsr, tmpreg

/*
 * disable IRQs
 */
#define DISABLEIRQS(tmpreg)\
	mrs	tmpreg , cpsr; \
	orr	tmpreg , tmpreg , $I_BIT; \
	msr	cpsr, tmpreg

/*
 * enable IRQs
 */
#define ENABLEIRQS(tmpreg)\
	mrs	tmpreg , cpsr; \
	bic	tmpreg , tmpreg , $I_BIT; \
	msr	cpsr, tmpreg