linux kernel 工程师
全部博文(99)
分类: LINUX
2014-02-05 17:53:49
在x86里面irq的入口函数是 do_irq()
在arm里面irq的入口函数是 asm_do_irq()
CONFIG_IRQ_FORCED_THREADING ? 什么用途?
------------------------------
#define PREEMPT_BITS 8
#define SOFTIRQ_BITS 8
#define NMI_BITS 1
#define MAX_HARDIRQ_BITS 10
#define PREEMPT_SHIFT 0
#define SOFTIRQ_SHIFT 8
#define HARDIRQ_SHIFT 16
#define NMI_SHIFT 26
#define __IRQ_MASK(x) ((1UL << (x))-1)
#define PREEMPT_MASK (__IRQ_MASK(PREEMPT_BITS) << PREEMPT_SHIFT) --------> 0x000000ff
#define SOFTIRQ_MASK (__IRQ_MASK(SOFTIRQ_BITS) << SOFTIRQ_SHIFT) --------> 0x0000ff00
#define HARDIRQ_MASK (__IRQ_MASK(HARDIRQ_BITS) << HARDIRQ_SHIFT) --------> 0x03ff0000
#define NMI_MASK (__IRQ_MASK(NMI_BITS) << NMI_SHIFT) ------>0x04000000
#define PREEMPT_OFFSET (1UL <<0)
#define SOFTIRQ_OFFSET (1UL << 8)
#define HARDIRQ_OFFSET (1UL << 16)
#define NMI_OFFSET (1UL << 26)
#define hardirq_count() (preempt_count() & HARDIRQ_MASK)
#define softirq_count() (preempt_count() & SOFTIRQ_MASK)
#define irq_count() (preempt_count() & (HARDIRQ_MASK | SOFTIRQ_MASK \
| NMI_MASK)) /* 软中断/硬中断/NMI上任何bit有指示, 都会体现到in_interrupt() */
/*
* Are we doing bottom half or hardware interrupt processing?
* Are we in a softirq context? Interrupt context?
* in_softirq - Are we currently processing softirq or have bh disabled?
* in_serving_softirq - Are we currently processing softirq?
*/
#define in_irq() (hardirq_count())
#define in_softirq() (softirq_count())
#define in_interrupt() (irq_count()) /* */
#define in_serving_softirq() (softirq_count() & SOFTIRQ_OFFSET)
/*
* Are we in NMI context?
*/
#define in_nmi() (preempt_count() & NMI_MASK)
--NMI-------------hardirq-----------------------softirq--------------preempt--------
-----27--26--------------------------16--15------------------8--7---------------------0
| | | |
----------------------------------------------------------------------------------------
#define SOFTIRQ_DISABLE_OFFSET (2 * SOFTIRQ_OFFSET)
=(1UL << 9)=512 使用bit 9作为softirq是否关闭的标志,因为softirq是不可嵌套的,所以softirq的计数使用一个bit, 即bit8就可以了。 bit8指示计数, bit9指示softirq是否关闭
softirq使用个两个bit是不是就足够了?
hardirq是否也是不可嵌套的?如果不可嵌套,那么是否一个bit就够了。 关闭硬中断, 不依赖于hardirq_count,通过设置 硬件寄存器实现硬中断的关闭和打开。