2 * linux/arch/arm/kernel/fiq.c
4 * Copyright (C) 1998 Russell King
5 * Copyright (C) 1998, 1999 Phil Blundell
7 * FIQ support written by Philip Blundell <philb@gnu.org>, 1998.
9 * FIQ support re-written by Russell King to be more generic
11 * We now properly support a method by which the FIQ handlers can
12 * be stacked onto the vector. We still do not support sharing
13 * the FIQ vector itself.
15 * Operation is as follows:
16 * 1. Owner A claims FIQ:
17 * - default_fiq relinquishes control.
20 * - sets any registers,
22 * 3. Owner B claims FIQ:
23 * - if owner A has a relinquish function.
25 * - saves any registers.
29 * - sets any registers,
31 * 5. Owner B releases FIQ:
32 * - Owner A is asked to reacquire FIQ:
34 * - restores saved registers.
38 #include <linux/module.h>
39 #include <linux/kernel.h>
40 #include <linux/init.h>
41 #include <linux/seq_file.h>
43 #include <asm/cacheflush.h>
46 #include <asm/system.h>
47 #include <asm/uaccess.h>
49 #define FIQ_VECTOR (vectors_base() + 0x1c)
51 static unsigned long no_fiq_insn
;
53 static inline void unprotect_page_0(void)
55 modify_domain(DOMAIN_USER
, DOMAIN_MANAGER
);
58 static inline void protect_page_0(void)
60 modify_domain(DOMAIN_USER
, DOMAIN_CLIENT
);
63 /* Default reacquire function
64 * - we always relinquish FIQ control
65 * - we always reacquire FIQ control
67 static int fiq_def_op(void *ref
, int relinquish
)
71 *(unsigned long *)FIQ_VECTOR
= no_fiq_insn
;
73 flush_icache_range(FIQ_VECTOR
, FIQ_VECTOR
+ 4);
79 static struct fiq_handler default_owner
= {
84 static struct fiq_handler
*current_fiq
= &default_owner
;
86 int show_fiq_list(struct seq_file
*p
, void *v
)
88 if (current_fiq
!= &default_owner
)
89 seq_printf(p
, "FIQ: %s\n", current_fiq
->name
);
94 void set_fiq_handler(void *start
, unsigned int length
)
98 memcpy((void *)FIQ_VECTOR
, start
, length
);
101 flush_icache_range(FIQ_VECTOR
, FIQ_VECTOR
+ length
);
105 * Taking an interrupt in FIQ mode is death, so both these functions
106 * disable irqs for the duration.
108 void set_fiq_regs(struct pt_regs
*regs
)
110 register unsigned long tmp
, tmp2
;
114 msr cpsr_c, %1 @ select FIQ mode\n\
116 ldmia %2, {r8 - r14}\n\
117 msr cpsr_c, %0 @ return to SVC mode\n\
119 : "=&r" (tmp
), "=&r" (tmp2
)
120 : "r" (®s
->ARM_r8
), "I" (PSR_I_BIT
| PSR_F_BIT
| FIQ_MODE
)
121 /* These registers aren't modified by the above code in a way
122 visible to the compiler, but we mark them as clobbers anyway
123 so that GCC won't put any of the input or output operands in
125 : "r8", "r9", "r10", "r11", "r12", "r13", "r14");
128 void get_fiq_regs(struct pt_regs
*regs
)
130 register unsigned long tmp
, tmp2
;
134 msr cpsr_c, %1 @ select FIQ mode\n\
136 stmia %2, {r8 - r14}\n\
137 msr cpsr_c, %0 @ return to SVC mode\n\
139 : "=&r" (tmp
), "=&r" (tmp2
)
140 : "r" (®s
->ARM_r8
), "I" (PSR_I_BIT
| PSR_F_BIT
| FIQ_MODE
)
141 /* These registers aren't modified by the above code in a way
142 visible to the compiler, but we mark them as clobbers anyway
143 so that GCC won't put any of the input or output operands in
145 : "r8", "r9", "r10", "r11", "r12", "r13", "r14");
148 int claim_fiq(struct fiq_handler
*f
)
155 if (current_fiq
->fiq_op
!= NULL
)
156 ret
= current_fiq
->fiq_op(current_fiq
->dev_id
, 1);
160 f
->next
= current_fiq
;
167 void release_fiq(struct fiq_handler
*f
)
169 if (current_fiq
!= f
) {
170 printk(KERN_ERR
"%s FIQ trying to release %s FIQ\n",
171 f
->name
, current_fiq
->name
);
177 current_fiq
= current_fiq
->next
;
178 while (current_fiq
->fiq_op(current_fiq
->dev_id
, 0));
181 void enable_fiq(int fiq
)
183 enable_irq(fiq
+ FIQ_START
);
186 void disable_fiq(int fiq
)
188 disable_irq(fiq
+ FIQ_START
);
191 EXPORT_SYMBOL(set_fiq_handler
);
192 EXPORT_SYMBOL(set_fiq_regs
);
193 EXPORT_SYMBOL(get_fiq_regs
);
194 EXPORT_SYMBOL(claim_fiq
);
195 EXPORT_SYMBOL(release_fiq
);
196 EXPORT_SYMBOL(enable_fiq
);
197 EXPORT_SYMBOL(disable_fiq
);
199 void __init
init_FIQ(void)
201 no_fiq_insn
= *(unsigned long *)FIQ_VECTOR
;