zoukankan      html  css  js  c++  java
  • LKD: Chapter 7 Interrupts and Interrupt Handlers

      Recently I realized my English is still far from good. So in order to improve my English, I must not only read in English, but also think and write in English. I know I'm gonna make a lot of mistake in using English, but everything has a process so I just need to keep practiing my English.

      I use 2.6.34 instead of 2.6.32 as the book describes.

      There're two similar concepts:

    Exceptions: synchronous interrupts generated by the processor.

    Interrupts: asynchronous interrupts generated by hardware.

      In this chapter, we focus on the interrupts.

      Interrupt handlers are running in interrupt context, which cannot block.

      The processing of interrupts is split into two parts, or halves: 

    Top Half(interrupt handler): time-critical

    Bottom Half: deferred work.

    Resgitering an Interrupt Handler(P116):  

    /*     <linux/interrupt.h>     */
    int request_irq ( unsigned int irq,      /* interrupt number */
                      irq_handler_t handler,   /* function pointer to the actual interrupt handler */
               unsigned long flags,    /* can be either zero or a bit mask */
               const char *name,      /* an ASCII text representation of the device */
               void *dev)          /* used for shared interrupt lines */

      The third parameter, flags: IRQF_DISABLED, IRQF_SAMPLE_RANDOM, IRQF_TIMER, IRQF_SHARED.

    Freeing an Interrupt Handler:

    void free_irq (unsigned int irq, void *dev)

      A call to free_irq() must be made from process context.

    Writing an Interrupt Handler:

      The following is a declaration of an interrupt handler:

    static irqreturn_t intr_handler ( int irq, void *dev)

      An interrupt handler return two special value:

    IRQ_NONE: when the interrupt handler detects an interrupt for which its device was not the originator.

    IRQ_HANDLED: the interrupt handler was correctly invoked, and its device did indeed cause the interrupt.

  • 相关阅读:
    CSS
    网络通信
    模块与包
    python异常处理
    python基础考试一整理
    面向对象最后进阶
    面向对象-反射和__getattr__系列
    property、staticmethod和classmethod
    多态和封装
    scala构造器实战
  • 原文地址:https://www.cnblogs.com/justforfun12/p/5063518.html
Copyright © 2011-2022 走看看