顯示具有 linux_irq 標籤的文章。 顯示所有文章
顯示具有 linux_irq 標籤的文章。 顯示所有文章

2010年12月29日 星期三

Linux interrupt flow and data structure overview

__irq_usr or __irq_svc in arcn\arm\kernl\entry-armv.S
->
irq_handler in .macro    irq_handler in arcn\arm\kernl\entry-armv.S
->asm_do_IRQ()->
generic_handle_irq()->generic_handle_irq_desc()->
desc->handle_irq(irq, desc)->handle_IRQ_event()->
action->handler(irq, action->dev_id);

struct irqaction {
    irq_handler_t handler;
    unsigned long flags;
    const char *name;
    void *dev_id;
    struct irqaction *next;
    int irq;
    struct proc_dir_entry *dir;
    irq_handler_t thread_fn;
    struct task_struct *thread;
    unsigned long thread_flags;
};

data structure

interrupt flow

2010年12月27日 星期一

modify irq_desc

\include\linux\irq.h
## provide extern IRQ handler interface of irq_desc
## provide extern Handling irq action chains of irq_desc
struct irq_desc {};
extern struct irq_desc irq_desc[NR_IRQS];
extern void handle_simple_irq(unsigned int irq, struct irq_desc *desc);
static inline void set_irq_handler(unsigned int irq, irq_flow_handler_t handle);
set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip, irq_flow_handler_t handle);
set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip, irq_flow_handler_t handle, const char *name);
extern int set_irq_chip(unsigned int irq, struct irq_chip *chip);
extern int set_irq_data(unsigned int irq, void *data);
extern int set_irq_chip_data(unsigned int irq, void *data);
extern int setup_irq(unsigned int irq, struct irqaction *new);
extern void remove_irq(unsigned int irq, struct irqaction *act);


\include\linux\irqnr.h
extern struct irq_desc *irq_to_desc(unsigned int irq);
 
\kernel\irq\chip.c

## irq_handler (handle_irq of irq_desc)
## irq chip (chip of irq_desc)
## irq handler flow function (handle_irq of irq_desc)
int set_irq_chip(unsigned int irq, struct irq_chip *chip);
__set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,const char *name);
void set_irq_probe(unsigned int irq);
int set_irq_type(unsigned int irq, unsigned int type);
int set_irq_data(unsigned int irq, void *data);
static inline void mask_ack_irq(struct irq_desc *desc, int irq);
static inline void mask_irq(struct irq_desc *desc, int irq);
static inline void unmask_irq(struct irq_desc *desc, int irq);


void handle_simple_irq(unsigned int irq, struct irq_desc *desc);
void handle_level_irq(unsigned int irq, struct irq_desc *desc);



\kernel\irq\handle.c
## interrupt action flow
## __do_IRQ flow
irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action);
unsigned int __do_IRQ(unsigned int irq);


\kernel\irq\irqdesc.c in v2.6.37
struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {initial data};
// do action->handler(irq, action->dev_id);
struct irq_desc *irq_to_desc(unsigned int irq);
struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node);

kernel\irq\manage.c
## provide operation interface irq_desc
## add/remove irqaction list of irq_desc table
setup_irq(unsigned int irq, struct irqaction* act);
void remove_irq(unsigned int irq, struct irqaction *act);
void disable_irq(unsigned int irq);
void enable_irq(unsigned int irq);

include\linux\interrupt.h
static inline int __must_check
request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
        const char *name, void *dev)
{
    return request_threaded_irq(irq, handler, NULL, flags, name, dev);
}

2010年12月23日 星期四

ADD/REMOVE IRQaction list of irq_desc

kernel/irq/manage.c
## add/remove irqaction list of irq_desc table
setup_irq(unsigned int irq, struct irqaction* act);
__setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new);

 void remove_irq(unsigned int irq, struct irqaction *act);
static struct irqaction *__free_irq(unsigned int irq, void *dev_id);