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/module.h>
41 #include <linux/mman.h>
42 #include <linux/init.h>
43 #include <linux/seq_file.h>
48 #include <asm/pgalloc.h>
49 #include <asm/system.h>
50 #include <asm/uaccess.h>
52 #define FIQ_VECTOR (vectors_base() + 0x1c)
54 static unsigned long no_fiq_insn;
56 #define unprotect_page_0()
57 #define protect_page_0()
59 /* Default reacquire function
60 * - we always relinquish FIQ control
61 * - we always reacquire FIQ control
63 static int fiq_def_op(void *ref, int relinquish)
67 *(unsigned long *)FIQ_VECTOR = no_fiq_insn;
74 static struct fiq_handler default_owner = {
79 static struct fiq_handler *current_fiq = &default_owner;
81 int show_fiq_list(struct seq_file *p, void *v)
83 if (current_fiq != &default_owner)
84 seq_printf(p, "FIQ: %s\n", current_fiq->name);
89 void set_fiq_handler(void *start, unsigned int length)
93 memcpy((void *)FIQ_VECTOR, start, length);
99 * Taking an interrupt in FIQ mode is death, so both these functions
100 * disable irqs for the duration.
102 void set_fiq_regs(struct pt_regs *regs)
104 register unsigned long tmp, tmp2;
107 "bic %1, %0, #0x3 \n"
109 "teqp %1, #0 @ select FIQ mode \n"
111 "ldmia %2, {r8 - r14} \n"
112 "teqp %0, #0 @ return to SVC mode \n"
114 : "=&r" (tmp), "=&r" (tmp2)
115 : "r" (®s->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | MODE_FIQ26)
116 /* These registers aren't modified by the above code in a way
117 visible to the compiler, but we mark them as clobbers anyway
118 so that GCC won't put any of the input or output operands in
120 : "r8", "r9", "r10", "r11", "r12", "r13", "r14");
123 void get_fiq_regs(struct pt_regs *regs)
125 register unsigned long tmp, tmp2;
128 "bic %1, %0, #0x3 \n"
130 "teqp %1, #0 @ select FIQ mode \n"
132 "stmia %2, {r8 - r14} \n"
133 "teqp %0, #0 @ return to SVC mode \n"
135 : "=&r" (tmp), "=&r" (tmp2)
136 : "r" (®s->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | MODE_FIQ26)
137 /* These registers aren't modified by the above code in a way
138 visible to the compiler, but we mark them as clobbers anyway
139 so that GCC won't put any of the input or output operands in
141 : "r8", "r9", "r10", "r11", "r12", "r13", "r14");
144 int claim_fiq(struct fiq_handler *f)
151 if (current_fiq->fiq_op != NULL)
152 ret = current_fiq->fiq_op(current_fiq->dev_id, 1);
156 f->next = current_fiq;
163 void release_fiq(struct fiq_handler *f)
165 if (current_fiq != f) {
166 printk(KERN_ERR "%s FIQ trying to release %s FIQ\n",
167 f->name, current_fiq->name);
168 #ifdef CONFIG_DEBUG_ERRORS
175 current_fiq = current_fiq->next;
176 while (current_fiq->fiq_op(current_fiq->dev_id, 0));
179 void enable_fiq(int fiq)
181 enable_irq(fiq + FIQ_START);
184 void disable_fiq(int fiq)
186 disable_irq(fiq + FIQ_START);
189 EXPORT_SYMBOL(set_fiq_handler);
190 EXPORT_SYMBOL(set_fiq_regs);
191 EXPORT_SYMBOL(get_fiq_regs);
192 EXPORT_SYMBOL(claim_fiq);
193 EXPORT_SYMBOL(release_fiq);
194 EXPORT_SYMBOL(enable_fiq);
195 EXPORT_SYMBOL(disable_fiq);
197 void __init init_FIQ(void)
199 no_fiq_insn = *(unsigned long *)FIQ_VECTOR;