interrupt.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. /* interrupt.h */
  2. #ifndef _LINUX_INTERRUPT_H
  3. #define _LINUX_INTERRUPT_H
  4. #include <linux/kernel.h>
  5. #include <linux/linkage.h>
  6. #include <linux/bitops.h>
  7. #include <linux/preempt.h>
  8. #include <linux/cpumask.h>
  9. #include <linux/irqreturn.h>
  10. #include <linux/irqnr.h>
  11. #include <linux/hardirq.h>
  12. #include <linux/irqflags.h>
  13. #include <linux/smp.h>
  14. #include <linux/percpu.h>
  15. #include <linux/hrtimer.h>
  16. #include <asm/atomic.h>
  17. #include <asm/ptrace.h>
  18. #include <asm/system.h>
  19. #include <trace/events/irq.h>
  20. /*
  21. * These correspond to the IORESOURCE_IRQ_* defines in
  22. * linux/ioport.h to select the interrupt line behaviour. When
  23. * requesting an interrupt without specifying a IRQF_TRIGGER, the
  24. * setting should be assumed to be "as already configured", which
  25. * may be as per machine or firmware initialisation.
  26. */
  27. #define IRQF_TRIGGER_NONE 0x00000000
  28. #define IRQF_TRIGGER_RISING 0x00000001
  29. #define IRQF_TRIGGER_FALLING 0x00000002
  30. #define IRQF_TRIGGER_HIGH 0x00000004
  31. #define IRQF_TRIGGER_LOW 0x00000008
  32. #define IRQF_TRIGGER_MASK (IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW | \
  33. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)
  34. #define IRQF_TRIGGER_PROBE 0x00000010
  35. /*
  36. * These flags used only by the kernel as part of the
  37. * irq handling routines.
  38. *
  39. * IRQF_DISABLED - keep irqs disabled when calling the action handler.
  40. * DEPRECATED. This flag is a NOOP and scheduled to be removed
  41. * IRQF_SAMPLE_RANDOM - irq is used to feed the random generator
  42. * IRQF_SHARED - allow sharing the irq among several devices
  43. * IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur
  44. * IRQF_TIMER - Flag to mark this interrupt as timer interrupt
  45. * IRQF_PERCPU - Interrupt is per cpu
  46. * IRQF_NOBALANCING - Flag to exclude this interrupt from irq balancing
  47. * IRQF_IRQPOLL - Interrupt is used for polling (only the interrupt that is
  48. * registered first in an shared interrupt is considered for
  49. * performance reasons)
  50. * IRQF_ONESHOT - Interrupt is not reenabled after the hardirq handler finished.
  51. * Used by threaded interrupts which need to keep the
  52. * irq line disabled until the threaded handler has been run.
  53. * IRQF_NO_SUSPEND - Do not disable this IRQ during suspend
  54. *
  55. */
  56. #define IRQF_DISABLED 0x00000020
  57. #define IRQF_SAMPLE_RANDOM 0x00000040
  58. #define IRQF_SHARED 0x00000080
  59. #define IRQF_PROBE_SHARED 0x00000100
  60. #define __IRQF_TIMER 0x00000200
  61. #define IRQF_PERCPU 0x00000400
  62. #define IRQF_NOBALANCING 0x00000800
  63. #define IRQF_IRQPOLL 0x00001000
  64. #define IRQF_ONESHOT 0x00002000
  65. #define IRQF_NO_SUSPEND 0x00004000
  66. #define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND)
  67. /*
  68. * Bits used by threaded handlers:
  69. * IRQTF_RUNTHREAD - signals that the interrupt handler thread should run
  70. * IRQTF_DIED - handler thread died
  71. * IRQTF_WARNED - warning "IRQ_WAKE_THREAD w/o thread_fn" has been printed
  72. * IRQTF_AFFINITY - irq thread is requested to adjust affinity
  73. */
  74. enum {
  75. IRQTF_RUNTHREAD,
  76. IRQTF_DIED,
  77. IRQTF_WARNED,
  78. IRQTF_AFFINITY,
  79. };
  80. /*
  81. * These values can be returned by request_any_context_irq() and
  82. * describe the context the interrupt will be run in.
  83. *
  84. * IRQC_IS_HARDIRQ - interrupt runs in hardirq context
  85. * IRQC_IS_NESTED - interrupt runs in a nested threaded context
  86. */
  87. enum {
  88. IRQC_IS_HARDIRQ = 0,
  89. IRQC_IS_NESTED,
  90. };
  91. typedef irqreturn_t (*irq_handler_t)(int, void *);
  92. /**
  93. * struct irqaction - per interrupt action descriptor
  94. * @handler: interrupt handler function
  95. * @flags: flags (see IRQF_* above)
  96. * @name: name of the device
  97. * @dev_id: cookie to identify the device
  98. * @next: pointer to the next irqaction for shared interrupts
  99. * @irq: interrupt number
  100. * @dir: pointer to the proc/irq/NN/name entry
  101. * @thread_fn: interupt handler function for threaded interrupts
  102. * @thread: thread pointer for threaded interrupts
  103. * @thread_flags: flags related to @thread
  104. */
  105. struct irqaction {
  106. irq_handler_t handler;
  107. unsigned long flags;
  108. const char *name;
  109. void *dev_id;
  110. struct irqaction *next;
  111. int irq;
  112. struct proc_dir_entry *dir;
  113. irq_handler_t thread_fn;
  114. struct task_struct *thread;
  115. unsigned long thread_flags;
  116. };
  117. extern irqreturn_t no_action(int cpl, void *dev_id);
  118. #ifdef CONFIG_GENERIC_HARDIRQS
  119. extern int __must_check
  120. request_threaded_irq(unsigned int irq, irq_handler_t handler,
  121. irq_handler_t thread_fn,
  122. unsigned long flags, const char *name, void *dev);
  123. static inline int __must_check
  124. request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
  125. const char *name, void *dev)
  126. {
  127. return request_threaded_irq(irq, handler, NULL, flags, name, dev);
  128. }
  129. extern int __must_check
  130. request_any_context_irq(unsigned int irq, irq_handler_t handler,
  131. unsigned long flags, const char *name, void *dev_id);
  132. extern void exit_irq_thread(void);
  133. #else
  134. extern int __must_check
  135. request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
  136. const char *name, void *dev);
  137. /*
  138. * Special function to avoid ifdeffery in kernel/irq/devres.c which
  139. * gets magically built by GENERIC_HARDIRQS=n architectures (sparc,
  140. * m68k). I really love these $@%#!* obvious Makefile references:
  141. * ../../../kernel/irq/devres.o
  142. */
  143. static inline int __must_check
  144. request_threaded_irq(unsigned int irq, irq_handler_t handler,
  145. irq_handler_t thread_fn,
  146. unsigned long flags, const char *name, void *dev)
  147. {
  148. return request_irq(irq, handler, flags, name, dev);
  149. }
  150. static inline int __must_check
  151. request_any_context_irq(unsigned int irq, irq_handler_t handler,
  152. unsigned long flags, const char *name, void *dev_id)
  153. {
  154. return request_irq(irq, handler, flags, name, dev_id);
  155. }
  156. static inline void exit_irq_thread(void) { }
  157. #endif
  158. extern void free_irq(unsigned int, void *);
  159. struct device;
  160. extern int __must_check
  161. devm_request_threaded_irq(struct device *dev, unsigned int irq,
  162. irq_handler_t handler, irq_handler_t thread_fn,
  163. unsigned long irqflags, const char *devname,
  164. void *dev_id);
  165. static inline int __must_check
  166. devm_request_irq(struct device *dev, unsigned int irq, irq_handler_t handler,
  167. unsigned long irqflags, const char *devname, void *dev_id)
  168. {
  169. return devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
  170. devname, dev_id);
  171. }
  172. extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
  173. /*
  174. * On lockdep we dont want to enable hardirqs in hardirq
  175. * context. Use local_irq_enable_in_hardirq() to annotate
  176. * kernel code that has to do this nevertheless (pretty much
  177. * the only valid case is for old/broken hardware that is
  178. * insanely slow).
  179. *
  180. * NOTE: in theory this might break fragile code that relies
  181. * on hardirq delivery - in practice we dont seem to have such
  182. * places left. So the only effect should be slightly increased
  183. * irqs-off latencies.
  184. */
  185. #ifdef CONFIG_LOCKDEP
  186. # define local_irq_enable_in_hardirq() do { } while (0)
  187. #else
  188. # define local_irq_enable_in_hardirq() local_irq_enable()
  189. #endif
  190. extern void disable_irq_nosync(unsigned int irq);
  191. extern void disable_irq(unsigned int irq);
  192. extern void enable_irq(unsigned int irq);
  193. /* The following three functions are for the core kernel use only. */
  194. #ifdef CONFIG_GENERIC_HARDIRQS
  195. extern void suspend_device_irqs(void);
  196. extern void resume_device_irqs(void);
  197. #ifdef CONFIG_PM_SLEEP
  198. extern int check_wakeup_irqs(void);
  199. #else
  200. static inline int check_wakeup_irqs(void) { return 0; }
  201. #endif
  202. #else
  203. static inline void suspend_device_irqs(void) { };
  204. static inline void resume_device_irqs(void) { };
  205. static inline int check_wakeup_irqs(void) { return 0; }
  206. #endif
  207. #if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS)
  208. extern cpumask_var_t irq_default_affinity;
  209. extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask);
  210. extern int irq_can_set_affinity(unsigned int irq);
  211. extern int irq_select_affinity(unsigned int irq);
  212. extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m);
  213. #else /* CONFIG_SMP */
  214. static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)
  215. {
  216. return -EINVAL;
  217. }
  218. static inline int irq_can_set_affinity(unsigned int irq)
  219. {
  220. return 0;
  221. }
  222. static inline int irq_select_affinity(unsigned int irq) { return 0; }
  223. static inline int irq_set_affinity_hint(unsigned int irq,
  224. const struct cpumask *m)
  225. {
  226. return -EINVAL;
  227. }
  228. #endif /* CONFIG_SMP && CONFIG_GENERIC_HARDIRQS */
  229. #ifdef CONFIG_GENERIC_HARDIRQS
  230. /*
  231. * Special lockdep variants of irq disabling/enabling.
  232. * These should be used for locking constructs that
  233. * know that a particular irq context which is disabled,
  234. * and which is the only irq-context user of a lock,
  235. * that it's safe to take the lock in the irq-disabled
  236. * section without disabling hardirqs.
  237. *
  238. * On !CONFIG_LOCKDEP they are equivalent to the normal
  239. * irq disable/enable methods.
  240. */
  241. static inline void disable_irq_nosync_lockdep(unsigned int irq)
  242. {
  243. disable_irq_nosync(irq);
  244. #ifdef CONFIG_LOCKDEP
  245. local_irq_disable();
  246. #endif
  247. }
  248. static inline void disable_irq_nosync_lockdep_irqsave(unsigned int irq, unsigned long *flags)
  249. {
  250. disable_irq_nosync(irq);
  251. #ifdef CONFIG_LOCKDEP
  252. local_irq_save(*flags);
  253. #endif
  254. }
  255. static inline void disable_irq_lockdep(unsigned int irq)
  256. {
  257. disable_irq(irq);
  258. #ifdef CONFIG_LOCKDEP
  259. local_irq_disable();
  260. #endif
  261. }
  262. static inline void enable_irq_lockdep(unsigned int irq)
  263. {
  264. #ifdef CONFIG_LOCKDEP
  265. local_irq_enable();
  266. #endif
  267. enable_irq(irq);
  268. }
  269. static inline void enable_irq_lockdep_irqrestore(unsigned int irq, unsigned long *flags)
  270. {
  271. #ifdef CONFIG_LOCKDEP
  272. local_irq_restore(*flags);
  273. #endif
  274. enable_irq(irq);
  275. }
  276. /* IRQ wakeup (PM) control: */
  277. extern int set_irq_wake(unsigned int irq, unsigned int on);
  278. static inline int enable_irq_wake(unsigned int irq)
  279. {
  280. return set_irq_wake(irq, 1);
  281. }
  282. static inline int disable_irq_wake(unsigned int irq)
  283. {
  284. return set_irq_wake(irq, 0);
  285. }
  286. #else /* !CONFIG_GENERIC_HARDIRQS */
  287. /*
  288. * NOTE: non-genirq architectures, if they want to support the lock
  289. * validator need to define the methods below in their asm/irq.h
  290. * files, under an #ifdef CONFIG_LOCKDEP section.
  291. */
  292. #ifndef CONFIG_LOCKDEP
  293. # define disable_irq_nosync_lockdep(irq) disable_irq_nosync(irq)
  294. # define disable_irq_nosync_lockdep_irqsave(irq, flags) \
  295. disable_irq_nosync(irq)
  296. # define disable_irq_lockdep(irq) disable_irq(irq)
  297. # define enable_irq_lockdep(irq) enable_irq(irq)
  298. # define enable_irq_lockdep_irqrestore(irq, flags) \
  299. enable_irq(irq)
  300. # endif
  301. static inline int enable_irq_wake(unsigned int irq)
  302. {
  303. return 0;
  304. }
  305. static inline int disable_irq_wake(unsigned int irq)
  306. {
  307. return 0;
  308. }
  309. #endif /* CONFIG_GENERIC_HARDIRQS */
  310. #ifndef __ARCH_SET_SOFTIRQ_PENDING
  311. #define set_softirq_pending(x) (local_softirq_pending() = (x))
  312. #define or_softirq_pending(x) (local_softirq_pending() |= (x))
  313. #endif
  314. /* Some architectures might implement lazy enabling/disabling of
  315. * interrupts. In some cases, such as stop_machine, we might want
  316. * to ensure that after a local_irq_disable(), interrupts have
  317. * really been disabled in hardware. Such architectures need to
  318. * implement the following hook.
  319. */
  320. #ifndef hard_irq_disable
  321. #define hard_irq_disable() do { } while(0)
  322. #endif
  323. /* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
  324. frequency threaded job scheduling. For almost all the purposes
  325. tasklets are more than enough. F.e. all serial device BHs et
  326. al. should be converted to tasklets, not to softirqs.
  327. */
  328. enum
  329. {
  330. HI_SOFTIRQ=0,
  331. TIMER_SOFTIRQ,
  332. NET_TX_SOFTIRQ,
  333. NET_RX_SOFTIRQ,
  334. BLOCK_SOFTIRQ,
  335. BLOCK_IOPOLL_SOFTIRQ,
  336. TASKLET_SOFTIRQ,
  337. SCHED_SOFTIRQ,
  338. HRTIMER_SOFTIRQ,
  339. RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */
  340. NR_SOFTIRQS
  341. };
  342. /* map softirq index to softirq name. update 'softirq_to_name' in
  343. * kernel/softirq.c when adding a new softirq.
  344. */
  345. extern char *softirq_to_name[NR_SOFTIRQS];
  346. /* softirq mask and active fields moved to irq_cpustat_t in
  347. * asm/hardirq.h to get better cache usage. KAO
  348. */
  349. struct softirq_action
  350. {
  351. void (*action)(struct softirq_action *);
  352. };
  353. asmlinkage void do_softirq(void);
  354. asmlinkage void __do_softirq(void);
  355. extern void open_softirq(int nr, void (*action)(struct softirq_action *));
  356. extern void softirq_init(void);
  357. static inline void __raise_softirq_irqoff(unsigned int nr)
  358. {
  359. trace_softirq_raise(nr);
  360. or_softirq_pending(1UL << nr);
  361. }
  362. extern void raise_softirq_irqoff(unsigned int nr);
  363. extern void raise_softirq(unsigned int nr);
  364. extern void wakeup_softirqd(void);
  365. /* This is the worklist that queues up per-cpu softirq work.
  366. *
  367. * send_remote_sendirq() adds work to these lists, and
  368. * the softirq handler itself dequeues from them. The queues
  369. * are protected by disabling local cpu interrupts and they must
  370. * only be accessed by the local cpu that they are for.
  371. */
  372. DECLARE_PER_CPU(struct list_head [NR_SOFTIRQS], softirq_work_list);
  373. /* Try to send a softirq to a remote cpu. If this cannot be done, the
  374. * work will be queued to the local cpu.
  375. */
  376. extern void send_remote_softirq(struct call_single_data *cp, int cpu, int softirq);
  377. /* Like send_remote_softirq(), but the caller must disable local cpu interrupts
  378. * and compute the current cpu, passed in as 'this_cpu'.
  379. */
  380. extern void __send_remote_softirq(struct call_single_data *cp, int cpu,
  381. int this_cpu, int softirq);
  382. /* Tasklets --- multithreaded analogue of BHs.
  383. Main feature differing them of generic softirqs: tasklet
  384. is running only on one CPU simultaneously.
  385. Main feature differing them of BHs: different tasklets
  386. may be run simultaneously on different CPUs.
  387. Properties:
  388. * If tasklet_schedule() is called, then tasklet is guaranteed
  389. to be executed on some cpu at least once after this.
  390. * If the tasklet is already scheduled, but its excecution is still not
  391. started, it will be executed only once.
  392. * If this tasklet is already running on another CPU (or schedule is called
  393. from tasklet itself), it is rescheduled for later.
  394. * Tasklet is strictly serialized wrt itself, but not
  395. wrt another tasklets. If client needs some intertask synchronization,
  396. he makes it with spinlocks.
  397. */
  398. struct tasklet_struct
  399. {
  400. struct tasklet_struct *next;
  401. unsigned long state;
  402. atomic_t count;
  403. void (*func)(unsigned long);
  404. unsigned long data;
  405. };
  406. #define DECLARE_TASKLET(name, func, data) \
  407. struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
  408. #define DECLARE_TASKLET_DISABLED(name, func, data) \
  409. struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
  410. enum
  411. {
  412. TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
  413. TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
  414. };
  415. #ifdef CONFIG_SMP
  416. static inline int tasklet_trylock(struct tasklet_struct *t)
  417. {
  418. return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
  419. }
  420. static inline void tasklet_unlock(struct tasklet_struct *t)
  421. {
  422. smp_mb__before_clear_bit();
  423. clear_bit(TASKLET_STATE_RUN, &(t)->state);
  424. }
  425. static inline void tasklet_unlock_wait(struct tasklet_struct *t)
  426. {
  427. while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
  428. }
  429. #else
  430. #define tasklet_trylock(t) 1
  431. #define tasklet_unlock_wait(t) do { } while (0)
  432. #define tasklet_unlock(t) do { } while (0)
  433. #endif
  434. extern void __tasklet_schedule(struct tasklet_struct *t);
  435. static inline void tasklet_schedule(struct tasklet_struct *t)
  436. {
  437. if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
  438. __tasklet_schedule(t);
  439. }
  440. extern void __tasklet_hi_schedule(struct tasklet_struct *t);
  441. static inline void tasklet_hi_schedule(struct tasklet_struct *t)
  442. {
  443. if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
  444. __tasklet_hi_schedule(t);
  445. }
  446. extern void __tasklet_hi_schedule_first(struct tasklet_struct *t);
  447. /*
  448. * This version avoids touching any other tasklets. Needed for kmemcheck
  449. * in order not to take any page faults while enqueueing this tasklet;
  450. * consider VERY carefully whether you really need this or
  451. * tasklet_hi_schedule()...
  452. */
  453. static inline void tasklet_hi_schedule_first(struct tasklet_struct *t)
  454. {
  455. if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
  456. __tasklet_hi_schedule_first(t);
  457. }
  458. static inline void tasklet_disable_nosync(struct tasklet_struct *t)
  459. {
  460. atomic_inc(&t->count);
  461. smp_mb__after_atomic_inc();
  462. }
  463. static inline void tasklet_disable(struct tasklet_struct *t)
  464. {
  465. tasklet_disable_nosync(t);
  466. tasklet_unlock_wait(t);
  467. smp_mb();
  468. }
  469. static inline void tasklet_enable(struct tasklet_struct *t)
  470. {
  471. smp_mb__before_atomic_dec();
  472. atomic_dec(&t->count);
  473. }
  474. static inline void tasklet_hi_enable(struct tasklet_struct *t)
  475. {
  476. smp_mb__before_atomic_dec();
  477. atomic_dec(&t->count);
  478. }
  479. extern void tasklet_kill(struct tasklet_struct *t);
  480. extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
  481. extern void tasklet_init(struct tasklet_struct *t,
  482. void (*func)(unsigned long), unsigned long data);
  483. struct tasklet_hrtimer {
  484. struct hrtimer timer;
  485. struct tasklet_struct tasklet;
  486. enum hrtimer_restart (*function)(struct hrtimer *);
  487. };
  488. extern void
  489. tasklet_hrtimer_init(struct tasklet_hrtimer *ttimer,
  490. enum hrtimer_restart (*function)(struct hrtimer *),
  491. clockid_t which_clock, enum hrtimer_mode mode);
  492. static inline
  493. int tasklet_hrtimer_start(struct tasklet_hrtimer *ttimer, ktime_t time,
  494. const enum hrtimer_mode mode)
  495. {
  496. return hrtimer_start(&ttimer->timer, time, mode);
  497. }
  498. static inline
  499. void tasklet_hrtimer_cancel(struct tasklet_hrtimer *ttimer)
  500. {
  501. hrtimer_cancel(&ttimer->timer);
  502. tasklet_kill(&ttimer->tasklet);
  503. }
  504. /*
  505. * Autoprobing for irqs:
  506. *
  507. * probe_irq_on() and probe_irq_off() provide robust primitives
  508. * for accurate IRQ probing during kernel initialization. They are
  509. * reasonably simple to use, are not "fooled" by spurious interrupts,
  510. * and, unlike other attempts at IRQ probing, they do not get hung on
  511. * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
  512. *
  513. * For reasonably foolproof probing, use them as follows:
  514. *
  515. * 1. clear and/or mask the device's internal interrupt.
  516. * 2. sti();
  517. * 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
  518. * 4. enable the device and cause it to trigger an interrupt.
  519. * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
  520. * 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
  521. * 7. service the device to clear its pending interrupt.
  522. * 8. loop again if paranoia is required.
  523. *
  524. * probe_irq_on() returns a mask of allocated irq's.
  525. *
  526. * probe_irq_off() takes the mask as a parameter,
  527. * and returns the irq number which occurred,
  528. * or zero if none occurred, or a negative irq number
  529. * if more than one irq occurred.
  530. */
  531. #if defined(CONFIG_GENERIC_HARDIRQS) && !defined(CONFIG_GENERIC_IRQ_PROBE)
  532. static inline unsigned long probe_irq_on(void)
  533. {
  534. return 0;
  535. }
  536. static inline int probe_irq_off(unsigned long val)
  537. {
  538. return 0;
  539. }
  540. static inline unsigned int probe_irq_mask(unsigned long val)
  541. {
  542. return 0;
  543. }
  544. #else
  545. extern unsigned long probe_irq_on(void); /* returns 0 on failure */
  546. extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
  547. extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
  548. #endif
  549. #ifdef CONFIG_PROC_FS
  550. /* Initialize /proc/irq/ */
  551. extern void init_irq_proc(void);
  552. #else
  553. static inline void init_irq_proc(void)
  554. {
  555. }
  556. #endif
  557. struct seq_file;
  558. int show_interrupts(struct seq_file *p, void *v);
  559. struct irq_desc;
  560. extern int early_irq_init(void);
  561. extern int arch_probe_nr_irqs(void);
  562. extern int arch_early_irq_init(void);
  563. extern int arch_init_chip_data(struct irq_desc *desc, int node);
  564. #endif