Original URL: http://book.51cto.com/art/201311/418637.htm
14.5.6 disable and activate the disconnection
Several macros discussed in the previous section can only disable and activate all interrupts on the processor. In some cases, however, you only need to disable or activate a specific medium break. This requires the use of some of the functions discussed in this section. The functions for prohibiting and activating specific interrupt lines are as follows:
- void Disable_irq (unsigned int IRQ);
- void Disable_irq_nosync (unsigned int IRQ);
- void Enable_irq (unsigned int IRQ);
- void Synchronize_irq (unsigned int IRQ);
The DISABLE_IRQ and Disable_irq_nosync functions are used to prohibit interrupts specified on the controller, which means that the specified interrupt (IRQ) is forbidden to pass to all processors in the system. The difference between these two functions is that the DISABLE_IRQ function returns only after all the handlers that are currently executing are completed, and the Disable_irq_nosync function returns immediately (regardless of whether or not a handler is currently running out).
The ENABLE_IRQ function is used to activate a specified medium break on the interrupt controller. The SYNCHRONIZE_IRQ function is used to wait for all handlers on a particular interrupt line to finish executing. If a handler on a particular interrupt line has not finished executing, the SYNCHRONIZE_IRQ function will always block. In fact, the DISABLE_IRQ function is implemented by Disable_irq_nosync and SYNCHRONIZE_IRQ functions together. The Disable_irq_nosync function is called first to prohibit a particular medium line break. Then according to irqdesc.action determine whether there are handlers on the interrupt line executing. Irqdesc.action is a pointer to the first item in the linked list that points to the handler pointer on the interrupt line. If Irqdesc.action is 0, indicating that the list is empty, it also indicates that the handlers on the interrupt line have been executed. The code for the DISABLE_IRQ function is as follows:
- void Disable_irq (unsigned int IRQ)
- {
- struct Irqdesc *desc = Irq_desc + IRQ;
- Disable_irq_nosync (IRQ);
- if (desc->action)
- SYNCHRONIZE_IRQ (IRQ);
- }
"Turn" 14.5.6 disable and activate the disconnection