Blame view

arch/arm/kernel/fiq.c 3.11 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
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
  /*
   *  linux/arch/arm/kernel/fiq.c
   *
   *  Copyright (C) 1998 Russell King
   *  Copyright (C) 1998, 1999 Phil Blundell
   *
   *  FIQ support written by Philip Blundell <philb@gnu.org>, 1998.
   *
   *  FIQ support re-written by Russell King to be more generic
   *
   * We now properly support a method by which the FIQ handlers can
   * be stacked onto the vector.  We still do not support sharing
   * the FIQ vector itself.
   *
   * Operation is as follows:
   *  1. Owner A claims FIQ:
   *     - default_fiq relinquishes control.
   *  2. Owner A:
   *     - inserts code.
   *     - sets any registers,
   *     - enables FIQ.
   *  3. Owner B claims FIQ:
   *     - if owner A has a relinquish function.
   *       - disable FIQs.
   *       - saves any registers.
   *       - returns zero.
   *  4. Owner B:
   *     - inserts code.
   *     - sets any registers,
   *     - enables FIQ.
   *  5. Owner B releases FIQ:
   *     - Owner A is asked to reacquire FIQ:
   *	 - inserts code.
   *	 - restores saved registers.
   *	 - enables FIQ.
   *  6. Goto 3
   */
  #include <linux/module.h>
  #include <linux/kernel.h>
  #include <linux/init.h>
4a2581a08   Thomas Gleixner   [ARM] 3692/1: ARM...
41
  #include <linux/interrupt.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
42
43
44
45
46
47
  #include <linux/seq_file.h>
  
  #include <asm/cacheflush.h>
  #include <asm/fiq.h>
  #include <asm/irq.h>
  #include <asm/system.h>
247055aa2   Catalin Marinas   ARM: 6384/1: Remo...
48
  #include <asm/traps.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  
  static unsigned long no_fiq_insn;
  
  /* Default reacquire function
   * - we always relinquish FIQ control
   * - we always reacquire FIQ control
   */
  static int fiq_def_op(void *ref, int relinquish)
  {
  	if (!relinquish)
  		set_fiq_handler(&no_fiq_insn, sizeof(no_fiq_insn));
  
  	return 0;
  }
  
  static struct fiq_handler default_owner = {
  	.name	= "default",
  	.fiq_op = fiq_def_op,
  };
  
  static struct fiq_handler *current_fiq = &default_owner;
f13cd4170   Russell King   ARM: fix /proc/in...
70
  int show_fiq_list(struct seq_file *p, int prec)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71
72
  {
  	if (current_fiq != &default_owner)
f13cd4170   Russell King   ARM: fix /proc/in...
73
74
75
  		seq_printf(p, "%*s:              %s
  ", prec, "FIQ",
  			current_fiq->name);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
76
77
78
79
80
81
  
  	return 0;
  }
  
  void set_fiq_handler(void *start, unsigned int length)
  {
247055aa2   Catalin Marinas   ARM: 6384/1: Remo...
82
  #if defined(CONFIG_CPU_USE_DOMAINS)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
83
  	memcpy((void *)0xffff001c, start, length);
247055aa2   Catalin Marinas   ARM: 6384/1: Remo...
84
85
86
  #else
  	memcpy(vectors_page + 0x1c, start, length);
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
87
88
89
90
  	flush_icache_range(0xffff001c, 0xffff001c + length);
  	if (!vectors_high())
  		flush_icache_range(0x1c, 0x1c + length);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  int claim_fiq(struct fiq_handler *f)
  {
  	int ret = 0;
  
  	if (current_fiq) {
  		ret = -EBUSY;
  
  		if (current_fiq->fiq_op != NULL)
  			ret = current_fiq->fiq_op(current_fiq->dev_id, 1);
  	}
  
  	if (!ret) {
  		f->next = current_fiq;
  		current_fiq = f;
  	}
  
  	return ret;
  }
  
  void release_fiq(struct fiq_handler *f)
  {
  	if (current_fiq != f) {
  		printk(KERN_ERR "%s FIQ trying to release %s FIQ
  ",
  		       f->name, current_fiq->name);
  		dump_stack();
  		return;
  	}
  
  	do
  		current_fiq = current_fiq->next;
  	while (current_fiq->fiq_op(current_fiq->dev_id, 0));
  }
  
  void enable_fiq(int fiq)
  {
  	enable_irq(fiq + FIQ_START);
  }
  
  void disable_fiq(int fiq)
  {
  	disable_irq(fiq + FIQ_START);
  }
  
  EXPORT_SYMBOL(set_fiq_handler);
dc2eb928a   Dave Martin   ARM: 6938/1: fiq:...
136
137
  EXPORT_SYMBOL(__set_fiq_regs);	/* defined in fiqasm.S */
  EXPORT_SYMBOL(__get_fiq_regs);	/* defined in fiqasm.S */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
138
139
140
141
142
143
144
145
146
  EXPORT_SYMBOL(claim_fiq);
  EXPORT_SYMBOL(release_fiq);
  EXPORT_SYMBOL(enable_fiq);
  EXPORT_SYMBOL(disable_fiq);
  
  void __init init_FIQ(void)
  {
  	no_fiq_insn = *(unsigned long *)0xffff001c;
  }