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.

  • 相关阅读:
    汽车最强大脑ECU和单片机是什么关系
    自动驾驶汽车操作系统简述
    怎样区分线性和非线性_线性与非线性的区别(线性分析、线性模型)
    ADAS最全整理
    carsim2016 与 MATLAB2018 联合仿真send to simulink后编译不成功解决方法
    基于Jenkins的.Net Core应用自动部署--学习一
    vue学习一
    sql server解析xml字段
    C# string[] 转list<long>
    C++神奇算法库——#include<algorithm>
  • 原文地址:https://www.cnblogs.com/justforfun12/p/5063518.html
Copyright © 2011-2022 走看看