1 / 57

Chapter 9

Chapter 9. Exception and Interrupt Handling. Presented by: Group#10. Ahmad Ibrahim Fayed. Ahmad Mohamed Abd el- Fadeel . Akram Ahmad Mohamed. Hassan Mohamed. Agenda. Exception handling. Interrupts. Interrupt handling schemes. Agenda. Exception handling. Interrupts.

tekli
Download Presentation

Chapter 9

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 9 Exception and Interrupt Handling

  2. Presented by: Group#10 • Ahmad Ibrahim Fayed. • Ahmad Mohamed Abd el-Fadeel. • Akram Ahmad Mohamed. • Hassan Mohamed.

  3. Agenda • Exception handling. • Interrupts. • Interrupt handling schemes.

  4. Agenda • Exception handling. • Interrupts. • Interrupt handling schemes.

  5. Exception handling • What is the exception? Any event that can halt the normal sequential execution of instructions. • Most exceptions have an associated software called exceptionhandler. • Handler is a software routine that executes when an exception occurs.

  6. ARM exceptions and modes • What are the actions made by the processor when an exception occurred? • saves the cpsr to the spsr of the exception mode. • saves the pc to the lr of the exception mode. • sets the cpsr to the exception mode. • sets pc to the address of the exception handler.

  7. ARM exceptions and modes • ARM processor has seven different exceptions: • Data abort. • Fast interrupt request(FIQ). • Interrupt request(IRQ). • Prefetch abort. • Software interrupt(SWI). • Reset. • Undefined instruction.

  8. ARM exceptions and modes

  9. Vector table • What is the vector table? It is a table of addresses that the ARM core branches to when an exception is raised ,commonly contain branch instructions of one of the following forms: • B <address> • LDR pc, [pc, #offset] • LDR pc, [pc, #-0xff0] • MOV pc, #immediate

  10. Vector table

  11. Vector table

  12. Exception priorities

  13. (1)Reset exception • The Reset exception is the highest priority exception and is always taken whenever it is signaled. • The reset handler initializes the system, including setting up memory and caches. • The reset handler must set up the stack pointers for all processor modes.

  14. (2)Data abort exception • Data Abort exceptions occur when the memory controller or MMU indicates that an invalid memory address has been accessed. • When the current code attempts to read or write to memory without the correct access permissions. • An FIQ exception can be raised within a Data Abort handler since FIQ exceptions are not disabled.

  15. (3)Fast Interrupt Request (FIQ) • FIQ exception occurs when an external peripheral sets the FIQ pin to nFIQ. • An FIQ exception is the highest priority interrupt. • The core disables both IRQ and FIQ exceptions on entry into the FIQ handler.

  16. (4)Interrupt Request (IRQ) • IRQ exception occurs when an external peripheral sets the IRQ pin to nIRQ. • An IRQ exception is the second-highest priority interrupt. • The IRQ handler will be entered if neither an FIQ exception nor Data Abort exception occurs.

  17. (5)Prefetch Abort exception • A Prefetch Abort exception occurs when an attempt to fetch an instruction results in a memory fault. • This exception is raised when the instruction is in the execute stage of the pipeline.

  18. (6)Software Interrupt (SWI) • SWI exception occurs when the SWI instruction is executed. • The cpsr will be set to supervisor mode. • If the system uses nested SWI calls, the link register r14 and spsr must be stored away before branching to the nested SWI.

  19. (7)Undefined Instruction exception • Undefined Instruction exception occurs when an instruction not in the ARM or Thumb instruction set reaches the execute stage of the pipeline. • Both the SWI instruction and Undefined Instruction have the same level of priority, since the instruction being executed cannot both be an SWI instruction and an undefined instruction.

  20. Link registers offsets

  21. Link registers offsets

  22. Link registers offsets • Note ^ symbol !

  23. Agenda • Exception handling. • Interrupts. • Interrupt handling schemes.

  24. Agenda • Exception handling. • Interrupts. • Interrupt handling schemes.

  25. Interrupts • Types of interrupts in ARM: • FIQ(high priority and less latency). • IRQ(less priority and high latency). • SWI(call privileged OS routines).

  26. Interrupt latency • Interrupt latency is the interval of time from an external interrupt request signal being raised to the first fetch of an instruction of a specific interrupt service routine (ISR). • How to decrease the interrupt latency? • Using a nested interrupt handler. • Using prioritization.

  27. Nested interrupt handler

  28. IRQ and FIQ exceptions • The processor enters a mood dependant on the interrupt • The previous mode’s cpsr is saved into the spsr of the new interrupt request mode. • The pc is saved in the lr of the new interrupt request mode. • Interrupt/s are disabled—either the IRQ or both IRQ and FIQ exceptions are disabled in the cpsr. This immediately stops another interrupt request of the same type being raised. • The processor branches to a specific entry in the vector table.

  29. IRQ

  30. FIQ

  31. Enabling IRQ and FIQ

  32. Disabling IRQ and FIQ

  33. Interrupt stack design • As every mood contain a dedicated register containing the stack pointer, it’s clear that we can reserve a stack for each mood of the ARM processor. • To design any stack we need to know two things: • Its location. • Its size(depends upon the type of handler, nested or nonnested). • We can avoid stack overflow by two methods: • Using memory protection. • Calling stack check function at start of each routine.

  34. Interrupt stack design

  35. Interrupt stack implementation

  36. Interrupt stack implementation

  37. Interrupt stack implementation

  38. Interrupt stack implementation

  39. Agenda • Exception handling. • Interrupts. • Interrupt handling schemes.

  40. Agenda • Exception handling. • Interrupts. • Interrupt handling schemes.

  41. Non-nested Interrupt Handler • The interrupts are disabled until control is returned back to the interrupted task or process. • Can only service a single interrupt at a time. • Handlers of this form are not suitable for complex embedded systems that service multiple interrupts with differing priority levels. • High interrupt latency.

  42. Non-nested Interrupt Handler Advantages: Easy to implement and debug Disadvantages: Can’t be used to handle complex embedded systems with multiple priority interrupts.

  43. Nested Interrupt Handler - Allows for another interrupt to occur within the currently called handler. - This is achieved by re-enabling the interrupts before the handler has fully serviced the current interrupt. - For a real-time system this feature increases the complexity of the system but also improves its performance. - Protecting the context restoration from interruption, so that the next interrupt will not fill the stack (cause stack overflow) or corrupt any of the registers.

  44. Nested Interrupt Handler Advantages: Can enable interrupts before the servicing of an individual interrupt is complete reducing interrupt latency. Disadvantages: Does not handle prioritization of interrupts, so lower priority interrupts can block higher priority interrupts.

  45. Reentrant Interrupt Handler • - Handles multiple interrupts where interrupts are filtered by priority. • - Interrupts are re-enabled early on in the reentrant interrupt handler, which can reduce interrupt latency. • Should swap into SVC or system mode in order not to overwrite the return address (this will happen if any interrupt service routine performs a BL subroutine call instruction). • If interrupts are re-enabled before processing is complete and the interrupt source is not disabled, an interrupt will be immediately regenerated, leading to an infinite interrupt sequence.

  46. Reentrant Interrupt Handler Advantages: Handles interrupts with differing priorities. Disadvantages: Tends to be more complex.

  47. Prioritized Simple Interrupt Handler - Low interrupt latency. - Both the non-nested interrupt handler and the nested interrupt handler service interrupts on a first-come-first-served basis.

  48. Prioritized Simple Interrupt Handler Advantages: Deterministic interrupt latency since the priority level is identified first and then the service is called after the lower-priority interrupts are masked. Disadvantages: The time taken to get to a low-priority service routine is the same as for a high-priority routine.

  49. Prioritized Standard Interrupt Handler - Low interrupt latency. - The prioritization simple interrupt handler tests all the interrupt to establish the highest priority. - An alternative approach is to jump early when the highest priority interrupt has been identified to a routine that will handle the masking of the lower priority interrupts and then jump again via a jump table to the appropriate ISR. - Handles higher-priority interrupts in a shorter time than lower-priority interrupts.

  50. Prioritized Standard Interrupt Handler Advantages: Higher-priority interrupts treated with greater urgency with no duplication of code to set external interrupt masks. Disadvantages: There is a time penalty since this handler requires two jumps, resulting in the pipeline being flushed each time a jump occurs.

More Related