2 * linux/arch/arm26/kernel/fiq.c
4 * Copyright (C) 1998 Russell King
5 * Copyright (C) 1998, 1999 Phil Blundell
6 * Copyright (C) 2003 Ian Molton
8 * FIQ support written by Philip Blundell <philb@gnu.org>, 1998.
10 * FIQ support re-written by Russell King to be more generic
12 * We now properly support a method by which the FIQ handlers can
13 * be stacked onto the vector. We still do not support sharing
14 * the FIQ vector itself.
16 * Operation is as follows:
17 * 1. Owner A claims FIQ:
18 * - default_fiq relinquishes control.
21 * - sets any registers,
23 * 3. Owner B claims FIQ:
24 * - if owner A has a relinquish function.
26 * - saves any registers.
30 * - sets any registers,
32 * 5. Owner B releases FIQ:
33 * - Owner A is asked to reacquire FIQ:
35 * - restores saved registers.
39 #include <linux/config.h>
40 #include <linux/module.h>
42 #include <linux/mman.h>
43 #include <linux/init.h>
44 #include <linux/seq_file.h>
49 #include <asm/pgalloc.h>
50 #include <asm/system.h>
51 #include <asm/uaccess.h>
53 #define FIQ_VECTOR (vectors_base() + 0x1c)
55 static unsigned long no_fiq_insn;
57 #define unprotect_page_0()
58 #define protect_page_0()
60 /* Default reacquire function
61 * - we always relinquish FIQ control
62 * - we always reacquire FIQ control
64 static int fiq_def_op(void *ref, int relinquish)
68 *(unsigned long *)FIQ_VECTOR = no_fiq_insn;
75 static struct fiq_handler default_owner = {
80 static struct fiq_handler *current_fiq = &default_owner;
82 int show_fiq_list(struct seq_file *p, void *v)
84 if (current_fiq != &default_owner)
85 seq_printf(p, "FIQ: %s\n", current_fiq->name);
90 void set_fiq_handler(void *start, unsigned int length)
94 memcpy((void *)FIQ_VECTOR, start, length);
100 * Taking an interrupt in FIQ mode is death, so both these functions
101 * disable irqs for the duration.
103 void set_fiq_regs(struct pt_regs *regs)
105 register unsigned long tmp, tmp2;
108 "bic %1, %0, #0x3 \n"
110 "teqp %1, #0 @ select FIQ mode \n"
112 "ldmia %2, {r8 - r14} \n"
113 "teqp %0, #0 @ return to SVC mode \n"
115 : "=&r" (tmp), "=&r" (tmp2)
116 : "r" (®s->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | MODE_FIQ26)
117 /* These registers aren't modified by the above code in a way
118 visible to the compiler, but we mark them as clobbers anyway
119 so that GCC won't put any of the input or output operands in
121 : "r8", "r9", "r10", "r11", "r12", "r13", "r14");
124 void get_fiq_regs(struct pt_regs *regs)
126 register unsigned long tmp, tmp2;
129 "bic %1, %0, #0x3 \n"
131 "teqp %1, #0 @ select FIQ mode \n"
133 "stmia %2, {r8 - r14} \n"
134 "teqp %0, #0 @ return to SVC mode \n"
136 : "=&r" (tmp), "=&r" (tmp2)
137 : "r" (®s->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | MODE_FIQ26)
138 /* These registers aren't modified by the above code in a way
139 visible to the compiler, but we mark them as clobbers anyway
140 so that GCC won't put any of the input or output operands in
142 : "r8", "r9", "r10", "r11", "r12", "r13", "r14");
145 int claim_fiq(struct fiq_handler *f)
152 if (current_fiq->fiq_op != NULL)
153 ret = current_fiq->fiq_op(current_fiq->dev_id, 1);
157 f->next = current_fiq;
164 void release_fiq(struct fiq_handler *f)
166 if (current_fiq != f) {
167 printk(KERN_ERR "%s FIQ trying to release %s FIQ\n",
168 f->name, current_fiq->name);
169 #ifdef CONFIG_DEBUG_ERRORS
176 current_fiq = current_fiq->next;
177 while (current_fiq->fiq_op(current_fiq->dev_id, 0));
180 void enable_fiq(int fiq)
182 enable_irq(fiq + FIQ_START);
185 void disable_fiq(int fiq)
187 disable_irq(fiq + FIQ_START);
190 EXPORT_SYMBOL(set_fiq_handler);
191 EXPORT_SYMBOL(set_fiq_regs);
192 EXPORT_SYMBOL(get_fiq_regs);
193 EXPORT_SYMBOL(claim_fiq);
194 EXPORT_SYMBOL(release_fiq);
195 EXPORT_SYMBOL(enable_fiq);
196 EXPORT_SYMBOL(disable_fiq);
198 void __init init_FIQ(void)
200 no_fiq_insn = *(unsigned long *)FIQ_VECTOR;