Chapter 2 driver interrupt handling in Windows CE

Source: Internet
Author: User

From: http://blog.csdn.net/guly699/archive/2009/10/19/4696722.aspx

 

First, I would like to introduce some of the commonly usedConcept

1. IRQ (interrupt request), physical interrupt request

2. sysintr, logical interrupt

3. ISR (interrupt service routine), service interruption routine

4. Ist (interrupt service thread), interrupt service thread

Interrupt handling

General interrupt handling process:

1. When an interruption occurs, the microprocessor jumps to the interrupt processing module of the system for processing;

2. The Interrupt Processing Module prohibits all other interruptions with the same priority and lower priority in the microprocessor, and then calls the appropriate ISR to process this physical interrupt request (IRQ );

3. ISR returns a logical interrupt to the interrupt processing module in the form of an interrupt identification space, and usually shields the drive interruption of the board-level equipment;

4. the interruption being executed is always blocked by the hardware, so that you can wait for the appropriate signal to trigger the IST event. In addition, the interrupt handler re-opens all the microprocessors;

5. The corresponding process of ist should be set in advance, provide services to the hardware according to the process, and then complete the interrupt processing;

6. The ist calls the interruptdone () function before the interrupt event processing is completed. This function tells the operating system that the interrupt processing has been completed and does not need to be blocked. In the system, after this function is executed, the oeminterrupdone () function in oal is called to declare that the interrupt processing has been completed.

Service Interruption

The interrupt service consists of kernel-mode interrupt service routine (ISR) and user-mode interrupt service thread (IST ). In wince, ISR is responsible for register protection and restoration, So C code can be used to implement an ISR.

Generally, ISR is enough to complete the following five items. It should not be too complex and have too many functions on ISR;

1. ISR can read data from the device to the software buffer when data is lost or overwritten by another one;

2. Clear the interruption conditions in the ISR device;

3. ISR returns a logical interrupt number sysintr to the kernel;

4. the kernel sets an interrupt event to cancel the request to respond to the ISR ist;

5. The scheduler schedules the response to the IST to complete the corresponding interrupt processing.

Interrupt shielding

Interruption shielding can invalidate all operations during an interruption, which will cause the operating system to ignore the interruption signal.

Nested interrupt handling

To prevent the failure and delay of high-priority interrupt, the Win CE kernel introduces the nested interrupt mechanism.

Shared interrupt handling

To process shared interruptions with Win CE, follow these steps:

1. An interruption that establishes a relationship with the ISR program in oeminit must call the nkcallintchain () kernel function. This function is used to check the list of installed ISRs and send an interruption signal.

2. if the first ISR decides that its associated device has declared an interrupt, it will perform necessary preparation work. After the process is completed, the ISR will return a logical interrupt number for the device. If this ISR does not determine the next operation, the ISR will return sysintr_nop.

3. if the ISR determines that its related device has not been declared interrupted, it will return to sysintr_chain, which will lead to the occurrence of the next isr in the nkcallintchain access chain. The sequence of Isr installation is very important, because it involves the issue of implicit priority.

Interrupt handling process analysis

The following eight steps are required to complete interrupt handling:

1. If the capture Exception Code of the kernel receives a hardware interrupt, the kernel will then identify an exception and operate on the corresponding hardware interrupt. Otherwise, go to step 2.

2. the interrupt manager notifies ISR to disable the specified interrupt until the interrupt processing is complete and then enable the interrupt. However, other interruptions are still available during this process.

3. The exception manager calls ISR to determine how to handle the interrupt.

4. After the kernel receives the return value of ISR, it will know what the interrupt is doing.

Return Value description

The sysintr_nop kernel does not respond.

Sysint_resched: the operating system timed out and the kernel rescheduled ist.

After the sysintr_xxx (logical interrupt number) kernel triggers the interrupt source ISR, the IST will be awakened and started to work. Then, the IST creates an event waiting for the interruption signal to arrive.

5. When the IST is awakened, it performs all the work required for interrupt processing, such as moving data to a buffer or using a feasible method to solve the data.

6. If necessary, ist calls various I/O functions to access the hardware to complete related operations on it.

7. When the IST completes the interrupt processing, it will call the interruptdone () function to notify the kernel.

8. The kernel calls the oeminterruptdone () function in oal to declare that all interrupt processing has been completed. OAL notifies the hardware to re-open the interrupt.

Configure, register, and revoke an interrupt handler

When a device driver is loaded, follow these steps.

1. Register ISR in the kernel

2. Define physical interrupt ing (IRQ) as logical interrupt

Service interruption routine

Interrupt service thread

Interrupt notification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.