linux 运行处理者

如同前面建议的, 当内核收到一个中断, 所有的注册的处理者被调用. 一个共享的处理者 必须能够在它需要的处理的中断和其他设备产生的中断之间区分.

使用 shared=1 选项来加载 short 安装了下列处理者来代替缺省的:

irqreturn_t short_sh_interrupt(int irq, void *dev_id, struct pt_regs *regs)

{

int value, written; struct timeval tv;

/* If it wasn't short, return immediately */ value = inb(short_base);

if (!(value & 0x80))

return IRQ_NONE;

/* clear the interrupting bit */ outb(value & 0x7F, short_base);

/* the rest is unchanged */ do_gettimeofday(&tv);

written = sprintf((char *)short_head,"%08u.%06u ",

(int)(tv.tv_sec % 100000000), (int)(tv.tv_usec)); short_incr_bp(&short_head, written); wake_up_interruptible(&short_queue); /* awake any reading process */ return IRQ_HANDLED;

}

这里应该有个解释. 因为并口没有"中断挂起"位来检查, 处理者使用 ACK 位作此目的. 如果这个位是高, 正报告的中断是给 short, 并且这个处理者清除这个位.

处理者通过并口数据端口的清零来复位这个位 -- short 假设管脚 9 和 10 连在一起. 如果其他一个和 short 共享这个 IRQ 的设备产生一个中断, short 看到它的线仍然非激 活并且什么不作.

当然, 一个功能齐全的驱动可能将工作划分位前和后半部, 但是容易添加并且不会有任何 影响实现共享的代码. 一个真实驱动还可能使用 dev_id 参数来决定, 在很多可能的中, 哪个设备在中断.

注意, 如果你使用打印机(代替跳线)来测试使用 short 的中断管理, 这个共享的处理者 不象所说的一样工作,因为打印机协议不允许共享, 并且驱动不知道是否这个中断是来自 打印机.

原文地址:https://www.cnblogs.com/fanweisheng/p/11142336.html