Linux Interrupt Service Program __linux

Source: Internet
Author: User

1. Several important data structures:

1.struct Irq_desc;
Represents an interrupt number of 31struct Irq_desc;

32typedef void (*irq_flow_handler_t) (unsigned int IRQ, struct irq_desc *desc); 175struct Irq_desc {176 unsigned int IRQ;//Interrupt number 177 struct timer_rand_state *timer_rand_state; 1
unsigned int *kstat_irqs;
179#ifdef config_intr_remap 180 struct Irq_2_iommu *irq_2_iommu; 181#endif irq_flow_handler_t Handle_irq; The interrupt number corresponds to the public handler 183 struct irq_chip *chip;
Interrupt Controller 184 struct MSI_DESC *msi_desc; 185 void *handler_data; 
HANDLE_IRQ the parameters of the public handler 186 void *chip_data; 187 struct Irqaction *action; The interrupt handler list that has been registered on the interrupt Line 188 unsigned int status;
The state of the disconnection at this time 189 190 unsigned int depth;
191 unsigned int wake_depth;
unsigned int irq_count; 1unsigned long last_unhandled;
194 unsigned int irqs_unhandled;
195 raw_spinlock_t lock;
196#ifdef CONFIG_SMP 197 cpumask_var_t Affinity;
198 const struct CPUMASK *affinity_hint;
199 unsigned int node;
200#ifdef CONFIG_GENERIC_PENDING_IRQ 201 cpumask_var_t Pending_mask;
202#endif 203#endif 204 atomic_t threads_active;
205 wait_queue_head_t wait_for_threads;
206#ifdef config_proc_fs 207 struct proc_dir_entry *dir; 208#ENDIF 209 const Char *name;
Break Line name 210} < Total interrupt number group > 216#ifndef config_sparse_irq 217extern struct Irq_desc Irq_desc[nr_irqs]; 218#endif///////////////////////////////////////////2.struct irqaction;

Represents an interrupt handler, 98typedef irqreturn_t (*irq_handler_t) (int, void *);   113struct irqaction {114 irq_handler_t handler;//Interrupt handler unsigned long flags;    Some flags when the interruption occurred 116    const char *name;  Interrupt program name 117 void *dev_id; Equipment logo 118 struct irqaction *next;  The next interrupt handler on the interrupt line 119 an int IRQ;
Interrupt number struct Proc_dir_entry *dir;
121 irq_handler_t THREAD_FN;
122 struct task_struct *thread;
123 unsigned long thread_flags;

124}; 3.struct irq_chip; Represents an interrupt controller 111struct irq_chip {112 const char *name;//Interrupt Controller name 113 unsigned int (*startup) (Unsigne d int IRQ); Start a break line 114 void (*shutdown) (unsigned int IRQ); Closes a break line (*enable) (unsigned int IRQ); Allow a break line interrupt 116 void (*disable) (unsigned int IRQ);
Disables the interruption of a break line 117 118 void (*ack) (unsigned int IRQ);
119 void (*mask) (unsigned int IRQ);
A void (*mask_ack) (unsigned int IRQ);
121 void (*unmask) (unsigned int IRQ);
122 void (*EOI) (unsigned int IRQ);   123 124     void (*end) (unsigned int IRQ); *set_affinity int (unsigned int IRQ, 126 const struct CPUMA
SK *dest);
127 int (*retrigger) (unsigned int IRQ);
128 int (*set_type) (unsigned int IRQ, unsigned int flow_type);
129 int (*set_wake) (unsigned int IRQ, unsigned int on);
130 131 void (*bus_lock) (unsigned int IRQ);
132 void (*bus_sync_unlock) (unsigned int IRQ); 134/* Currently used only by UML, might disappear one day.*/135#ifdef, Config_irq_release_method vo
ID (*release) (unsigned int IRQ, void *dev_id);
137#ENDIF 138/* 139 * For compatibility,->typename was copied into->name.
140 * would disappear.
The *typename is a const char; 143};

2. Relationship between the above three structures:

3. The execution process when the interruption occurs:

1. The keyboard produces an interrupt, which sends the signal (interrupt number) to the interrupt Controller 2 via the interrupt line

. The interrupt controller sends the interrupt number to the processor, and the processor stops the current work

3. The processor calls Common_interrup this public interrupt handler, The environment that holds the current execution process, presumably some register values, is saved to the stack of the process

4. The processor invokes the DO_IRQ () function, which invokes the public handler in the struct IRQ_DESC structure that is part of the interrupt line, that is Handle_ The function that the IRQ field points to

5.handle_irq eventually calls the Hand_irq_event function shown in the above picture, which calls the handler on the break line in turn, calling struct irq_ The action field in the DESC structure points to a handler on the interrupt handler list on the interrupt line
6. After the interrupt handler is executed, call the RET_FROM_INTR () function in the picture above, which returns to the onsite environment before the interrupt

This article quotes from http://edsionte.com/techblog/archives/1618

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.