GB2461851A - Processor, which stores interrupt enable flags in a location used for other functions - Google Patents
Processor, which stores interrupt enable flags in a location used for other functions Download PDFInfo
- Publication number
- GB2461851A GB2461851A GB0812665A GB0812665A GB2461851A GB 2461851 A GB2461851 A GB 2461851A GB 0812665 A GB0812665 A GB 0812665A GB 0812665 A GB0812665 A GB 0812665A GB 2461851 A GB2461851 A GB 2461851A
- Authority
- GB
- United Kingdom
- Prior art keywords
- processor
- memory location
- interrupt
- value
- register
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Withdrawn
Links
- 230000006870 function Effects 0.000 title description 3
- 230000015654 memory Effects 0.000 claims description 106
- 238000012545 processing Methods 0.000 claims description 24
- 238000000034 method Methods 0.000 claims description 12
- 238000004590 computer program Methods 0.000 claims description 11
- 230000001960 triggered effect Effects 0.000 claims description 7
- 230000009471 action Effects 0.000 claims description 6
- 230000001360 synchronised effect Effects 0.000 claims description 3
- 239000013598 vector Substances 0.000 description 7
- 238000011084 recovery Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 101000882217 Homo sapiens Protein FAM50A Proteins 0.000 description 4
- 102100038926 Protein FAM50A Human genes 0.000 description 4
- 239000004065 semiconductor Substances 0.000 description 4
- 102100027716 RanBP-type and C3HC4-type zinc finger-containing protein 1 Human genes 0.000 description 3
- 101001088179 Homo sapiens DNA-directed RNA polymerases I, II, and III subunit RPABC1 Proteins 0.000 description 2
- 101001081220 Homo sapiens RanBP-type and C3HC4-type zinc finger-containing protein 1 Proteins 0.000 description 2
- 238000007726 management method Methods 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 101000807820 Homo sapiens V-type proton ATPase subunit S1 Proteins 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 239000003795 chemical substances by application Substances 0.000 description 1
- 239000000470 constituent Substances 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 229910052710 silicon Inorganic materials 0.000 description 1
- 239000010703 silicon Substances 0.000 description 1
- 230000003936 working memory Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/14—Handling requests for interconnection or transfer
- G06F13/20—Handling requests for interconnection or transfer for access to input/output bus
- G06F13/24—Handling requests for interconnection or transfer for access to input/output bus using interrupt
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4812—Task transfer initiation or dispatching by interrupt, e.g. masked
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Microcomputers (AREA)
- Executing Machine-Instructions (AREA)
Abstract
When a processor is interrupted, it stores its interrupt enable flags l in a location C which is used to store other values at other times. At the end of the interrupt, the interrupt enable flags are restored. When not in an interrupt, the location may be used to store a carry or overflow flag. Both the location and the interrupt flags may be stored in the same processor status register 134-1. The flags may be copied to the location in a single clock cycle. The interrupt enable flags may also be pushed onto the stack when the processor is interrupted.
Description
Interrupt Processing The present invention relates to a data processing apparatus and in particular to a method of data processing.
There is a great deal of interest in high-performance microprocessors or processors which are often implemented as part of a semiconductor device, for example, as part of an ASIC (Application-Specific Integrated Circuit) or SoC (System on Chip). There are ongoing requirements to provide such processors with increasingly advanced features, increased speed and reduced power consumption -all at minimal cost.
The present invention aims to present a way in which the processing of interrupts by a processor core may be improved without requiring major revisions to the processor architecture.
According to one aspect of the invention, there is provided a data processing apparatus comprising: a processor; a first memory location, the processor being adapted to control whether the operation of the processor may be interrupted in dependence on a value stored in the first memory location; and a second memory location, the processor being adapted a) to store a value in the second memory location following an event that is related to the value stored in the first memory location, and b) otherwise to store a value in the second memory location that is not related to the value stored in the first memory location.
Using a second memory location in this way can preserve information regarding the interrupt configuration of the processor prior to the operation of the processor being interrupted, even if the interrupt configuration of the processor is subsequently changed as a consequence of the processor being interrupted. Storing this information in a memory location that is not exclusively dedicated for this purpose is computationally efficient.
The term "memory" as used herein preferably includes any kind of data storage accessible by the processor, including, for example, processor registers, on-and off-chip cache memory, and main memory (as would typically be accessed by the processor via a memory bus). Unless the context otherwise requires, memory may be read-only or may be readable and writable. The term "memory location" preferably refers to a storage location of any appropriate size within such a memory.
As used herein, the term "related" preferably connotes a value in the second memory location that has a predictable, preferably one to one or unambiguous correspondence with the value in the first memory location, and the term "unrelated" preferably connotes a value that has no such predictable correspondence.
Preferably, the event may be an interrupt or an exception (and the term "interrupt", as used herein, may include an exception). More preferably, the interrupt is an external, asynchronous event triggered by some action outside the processor; and more preferably, the exception is an internal, synchronous event triggered by some action inside the processor. Interrupts may comprise external hardware events, for example, a timer reaching its terminal count, or a serial port receiving a character. Exceptions may comprise a reset (HardReset, SoftReset), service (System Call, Single Step, Break) or error.
Preferably, the value stored in the second memory location is logically related to the value stored in the first memory location. More preferably, the value stored in the second memory location is a copy of the value stored in the first memory location. The values may be a single bit in size. Alternatively, the values may be multiple bits in size.
Preferably, the processor further comprises means for storing a value in the first memory location in dependence on the value stored in the second memory location. This can allow, for example, for the interrupt configuration of the processor to be restored to a previous state, if required.
A processor designer is faced with the conflicting requirements of having the processor in a state in which its operation may be interrupted (interrupts enabled) in order to allow for an urgent event to be processed, and requiring the processor to be in a state in which its operation may not be interrupted (interrupts disabled) if, for example, it is already processing a more urgent event. It is therefore advantageous, for example, to allow for the processor to rapidly revert to a previous interrupt state whenever it is possible to do so.
Preferably, the second memory location is primarily used for storing said unrelated value, and is only temporarily used for storing said related value (following an interrupt related to the value stored in the first memory location). This can allow for the advantages of the invention to be realised without requiring a dedicated memory location to have been allocated in the processor. The unrelated value might, for example, be related to a control and/or status aspect of the processor, or might indeed be related to any other aspect of the processor.
Preferably, the second memory location is not a general purpose memory location, as these are used for the normal operands for the majority of tasks of the instruction set of the processor.
Preferably, the means for storing a value in the first memory location in dependence on the value stored in the second memory location is adapted to store said value in the first memory location before the value stored in the second memory location is altered by the processor. Hence, preferably, the second memory location is not a memory location which may be frequently used by the processor as this would be more likely to have the value stored in it altered before the value in the first memory location can be stored in dependence on it.
Preferably, the second memory location is primarily used for storing an unrelated value which is used by arithmetic instructions. For example, the unrelated value may be used primarily to represent a carry bit or, alternatively, an overflow bit. This is preferable to using a second memory location which is primarily used for storing an unrelated value such as the negative bit or the zero bit which is used by logic instructions, as these are more commonly used than arithmetic instructions and therefore the related value stored in the second memory location is more likely to be altered before the value in the first memory location can be stored in dependence on it.
Preferably, the first and second memory locations are locations within registers of the processor. The apparatus can be adapted to copy the value between register locations using a single processor instruction, preferably within a single clock cycle. This allows for fast restoration of the interrupt configuration of the processor to its previous value.
Preferably, the first register location and the second register location are both located in the same register; the copying process may be faster when the first register location and the second register location are both located in the same register. This register may be a special register. The register may store a plurality of values related to control and/or status aspects of the processor.
Alternatively, the first register location and the second register location may be located in different registers.
Preferably, the apparatus further comprises means for servicing an event, such as an interrupt or an exception. Servicing an interrupt or an exception may comprise the processor running program code specific to that interrupt or exception, say an appropriate interrupt or exception handler. Preferably, the apparatus is adapted to store said value in the first memory location in dependence on said value stored in the second memory location within less than eight, preferably less than three, more preferably less than two, operations.
Preferably, there are at least two types of interrupts. Preferably, the value stored in the first memory location controls whether the operation of the processor may be interrupted by a first type of interrupt. These may be maskable interrupts.
Preferably, there is a hierarchy of maskable interrupts. The hierarchy may be determined by the priority value associated with each maskable interrupt. The operation of the means for servicing an event, wherein the event is a maskable interrupt, may be interrupted by a maskable interrupt of higher priority.
Preferably, the processor further comprises means for storing a value in the first memory location following an interrupt. Preferably, the value stored determines that the operation of the processor may not be interrupted.
Preferably, the value stored in the first memory location does not control whether the processor may be interrupted by a second type of interrupt. These may be non-maskable interrupts. The operation of the means for servicing an event, for example a maskable interrupt, is adapted such that it may be interrupted by further non-maskable interrupts.
Preferably, the operation of the means for servicing an event, such as an interrupt (or exception), is adapted such that it may only be interrupted once the servicing of the interrupt has progressed to a safe state.
Preferably, the apparatus is adapted to enable or disable interrupts in dependence on the value stored in the first memory location. The first memory location may be a bit within a special register (an interrupt bit). Preferably, setting the bit to one enables interrupts; preferably, setting the bit to zero disables interrupts.
Preferably, the apparatus is adapted, upon the occurrence of an event, such as an interrupt (or exception), to set the bit to zero.
Preferably, the apparatus further comprises computer memory. Preferably, the processor is adapted to access said memory by means of a linear data structure such as a stack.
Preferably, the apparatus is adapted such that when the processor operation is interrupted the value stored in the first register location is also copied onto the stack. This may be done by a hardware context push operation. This may involve copying onto the stack the entire contents of the register which includes the first register location.
Hence, the apparatus is adapted to store, when the operation of the processor is interrupted, the value which controls whether the operation of the processor may be interrupted by a first type of interrupt in at least two memory locations. At least one of these locations may be in a register. At least one of these locations may be on the stack.
According to another aspect of the invention, there is provided a method of data processing, comprising: operating a processor, wherein the operation of the processor may be interrupted in dependence on a value stored in the first memory location; storing, in a first memory location, a value by which means the processor determines whether the operation of the processor may be interrupted; and storing, in a second memory location, a) after an interrupt, a value that is related to the value stored in the first memory location, and b) otherwise storing a value in the second memory location that is not related to the value stored in the first memory location.
The invention also provides a computer program and a computer program product comprising software code adapted, when executed on a data processing apparatus, to perform any of the methods described herein, including any or all of their component steps.
The invention also provides a computer program and a computer program product comprising software code which, when executed on a data processing apparatus, comprises any of the apparatus features described herein.
The invention also provides a computer program and a computer program product having an operating system which supports a computer program for carrying out any of the methods described herein and/or for embodying any of the apparatus features described herein.
The invention also provides a computer readable medium having stored thereon the computer program as aforesaid.
The invention also provides a signal carrying the computer program as aforesaid, and a method of transmitting such a signal.
The invention extends to methods and/or apparatus substantially as herein described with reference to the accompanying drawings.
Any feature in one aspect of the invention may be applied to other aspects of the invention, in any appropriate combination. In particular, method aspects may be applied to apparatus aspects, and vice versa.
Furthermore, features implemented in hardware may be implemented in software, and vice versa. Any reference to software and hardware features herein should be construed accordingly.
The following documents are hereby incorporated by reference: GB2294137, GB2294138, GB0509738.1, GB0706918.0 and W09609583. Also incorporated by reference are the GB Patent Applications filed the same day and having the following Agent references: P32696, P32697 and P32698. Any feature in any of these documents may be combined with any feature described herein in any appropriate combination.
The invention will now be described, purely by way of example, with reference to the accompanying drawings, in which: Figure 1 is a schematic of a processor implemented within an ASIC (application specific integrated circuit) semiconductor device; Figure 2 is a schematic block diagram of the hardware architecture of the processor; Figure 3 is a further schematic block diagram of the hardware architecture of the processor; Figure 4 is a schematic showing various registers of the processor; Figure 5 is a state diagram showing the operating modes of the processor in more detail; Figure 6 shows in detail some of the operations performed by the processor when servicing events, such as interrupts and exceptions; and Figure 7 is a flow diagram showing the processing of interrupts by the processor.
Oveiview Figure 1 shows a data processing apparatus 1 implemented in the form of an ASIC (application specific integrated circuit) semiconductor device, comprising a central processing unit or processor 10, for running user programs, connected via a data bus 12 to analogue circuitry 14 and digital circuitry 16, and also to random-access memory (RAM) 18 and read-only memory (ROM) 20.
Processor 10 may be, for example, one of the XAP range of processors as supplied by Cambridge Consultants Ltd, Cambridge, England, such as the XAP5, which is a 16-bit RISC processor with von Neumann architecture, the 16-bit XAP4 or the 32-bit XAP3.
Further details relating to these processors and their associated instruction sets can be found in GB 2427722, WO 2006/120470 and PCT/GB2007/001323, which are incorporated herein by reference. The processor 10 may be described to those skilled in the art as an IP-core using a hardware description language such as Verilog or VHDL in RTL (register transfer level) code.
The processor 10 further comprises a memory management unit 22 (MMU), for interfacing with the RAM 18, ROM 20, custom analogue circuits 14, and custom digital circuits 16; a serial interface (SIF) 24, to facilitate debugging and/or control of the processor 10; and an interrupt vector controller (IVC) 26, for handling interrupts (external asynchronous events), including both maskable interrupts and non-maskable interrupts.
Analogue circuitry 14 and digital circuitry 16 are custom built for specific applications; likewise, the MMU 22 and IVC 26 may be customised as required. The processor core 11 is intended to be fixed and unchanged from one ASIC to another. RAM 18 and ROM 20 may comprise on-chip or off-chip memory.
Persons skilled in the art will appreciate that the data processing unit 1 may be implemented, for example, in a semiconductor material such as silicon, for example, CMOS, and be suitable for ASIC or FPGA applications.
Architecture Processor 10 uses a load-store architecture, as will be familiar to those skilled in the art of processor design.
Figure 2 shows a block diagram of the hardware architecture of the processor core 11 in more detail. Processor core 11 can be seen to comprise an arithmetic logic unit (ALU) 100, serial interface unit (SIF) 24, interrupt and exception controller 27 and a bank of registers 120. The ALU 100 is connected to an address generator unit 160. The processor 10 is also provided with an instruction fetch unit 150 and an instruction decode unit 152. A plurality of data input and output lines are shown, both between the constituent units of the processor 10 and to/from the processor itself, as will be familiar to those skilled in the art. For example, in Figure 2, the data lines and opcodes (op) use the following notation: Rd destination register Rs primary source register Rt secondary source register Rx index register Ra base address register Memory management unit (MMU) and interrupt vector controller (IVC) Figure 3 shows the interconnection between the processor core 11, the MMU 22 and the IVC 26 in more detail. As can be seen from Figure 3, the processor 10 may be packaged together with the IVC and the MMU, which are implemented as part of an ASIC or FPGA.
The MMU 22 is used to interface with various memories connected to the processor 10, for example, RAM, ROM and FLASH. The IVC 26 is used to prioritise interrupt sources and provide interrupt numbers and priority levels for the interrupts to the processor 10. -10-
Registers Processor 10 includes a small amount of on-chip storage in the form of registers, which provides fast-accessible working memory for the processor.
Figure 3 shows some of the registers used by the processor 10. These comprise several different types according to function, including: * general purpose registers 130 -used for the normal operands for the majority of tasks of the instruction set * address registers 132 -used to hold memory addresses * special registers 134-used, for example, to indicate processor status * breakpoint registers 136-used in debugging As shown, one possible example comprises eight 16-bit general purpose registers 130 (R0-R7); four 24-bit address registers 132; and several 16-bit "special" registers 134.
Examples of address registers include the program counter register (PC), which normally points to the next instruction to be executed; vector pointer register (VP), for pointing to the base of a vector table, the vector table containing a set of pointers (vectors) to software interrupt/exception handlers; and at least one stack pointer (SP), for providing access to a stack.
An "operational flags" or FLAGS special register may also be provided for storing various flags and fields, for example, "carry" (C), "mode" (M) and "interrupt" (I) flags. A "state" (S) field in the FLAGS register is also provided for recording the execution progress of an instruction, to allow interrupts and exceptions to be processed during execution of certain instructions, as explained in more detail below. Figure 4 illustrates the FLAGS register, showing the bit ranges of various fields, including, for example, the "state" fieid S at bit positions [11:7].
Figure 4 shows various registers of the processor in more detail. Of particular note for the purposes of this embodiment is the "operational flags" or FLAGS special register 134-1, which is shown in detail in Figure 3b), with the "carry" (C), "mode" (M) and "interrupt" (I) register locations highlighted. In the assembly code used to program the -11 -processor, these register locations are referred to as %flags[cJ, %flags[m] and %flags[i] respectively.
stacks Temporary working storage for the processor 10 is provided by means of conventional stacks, as will be familiar to those skilled in the art, which are last-in first-out (LIFO) data structures, wherein register values may be pushed' onto, and subsequently popped' off, the stacks. A stack pointer register (SP) is used to refer to locations in the stack, preferably the most recent item pushed onto the stack. In one example, the processor 10 is provided with two stack pointer registers, one (SP1) which points to Stackl, used when the processor is in a User or Trusted mode, the other (SPO) which points to StackO, used when the processor is in a Supervisor or Interrupt mode. Additionally, in this embodiment, StackO is also used when the processor is in a recovery state used to handle errors arising in Supervisor or Interrupt mode, and in a non-maskable interrupt state for handling non-maskable interrupts (e.g. hardware errors).
* modes Figure 5 shows the different operating modes of the processor 10. These are indicated by the value stored in the %FLAGS[m] register location. The modes comprise a user mode [m=3], for running user code; and three privileged modes: trusted [m2], supervisor [m0], and interrupt [m1]. The privileged modes allow system or services code to be run at a privileged access level, allowing enhanced access to the processor operations, whereas user code runs at a lower access level wherein certain processor operations are restricted.
Processor 10 can also operate in one of two states: * Recovery state -which uses short, fast handlers to recover from errors that occurred in Supervisor mode * NMI state -which uses short, fast handlers to recover from hardware errors The transfer of the processor 10 from one mode to another is governed by the requirement for code to be run with a predetermined level of access, and also according -12-to the servicing of interrupts.
interrupts An interrupt is a special (external, asynchronous) event triggered by some action outside the processor 10, such as external hardware events e.g. a timer reaching its terminal count, or a serial port receiving a character. Interrupts can occur in any mode. Interrupts may be contrasted with exceptions, which are special (internal, synchronous) events triggered by some action inside the processor 10, such as a reset (HardReset, SoftReset), service (System Call, Single Step, Break) or error.
The interface between the processor 10 and interrupts is via Interrupt Vector Controller (IVC) 26. The IVC 26 will be customised from one application to another, enabling the hardware designer to customise the interrupt scheme (to fit in with the internal scheme for interrupts and exceptions) as required. When an external source requires the attention of the processor 10, one or more interrupt requests (IRQ) are sent along the interrupt line to the IVC 26, which generates a corresponding interrupt and passes it to the processor 10.
Interrupts belong to one of two classes: * Maskable Interrupts (Ml) -are used for all normal operations and are processed in Interrupt mode. MIs can be disabled by software.
Non-Maskable Interrupts (NMI) -cannot be disabled by software. NMls do not usually occur in normal operation, only for recovery from a hardware error.
In one example, the IVC 26 accepts up to 32 interrupt requests (IRQ) along the interrupt line from external sources, of which four are treated as non-maskable interrupts (NMIs) and the remainder are maskable interrupts (MIs).
Whether or not maskable interrupts are to be processed is governed by the setting of the %flags[i] bit in the FLAGS register, wherein MIs are enabled (i.e. may be processed) when the bit is set to 1, disabled when the bit is set to 0.
Interrupt Processing Typically, the core processor 10 receives an interrupt number (typically from an external interrupt controller, such as IVC 26) and branches to an appropriate interrupt handler, which is a piece of code that handles the response to the interrupt. While an interrupt is being serviced by the interrupt handler, the processor 10 enters Interrupt mode and disables further maskable interrupts by setting %flags[i] = 0. At the end of the interrupt processing, the processor 10 returns to the interrupted code, restoring processor status to that prior to the interrupt.
* priority Interrupts are generally serviced promptly by the processor. Nevertheless, the events which trigger interrupts are not all necessarily of equal urgency. Accordingly, each interrupt generated by the IVC 26 is accompanied by an interrupt number (0 to 31) and also an interrupt priority (0=highest to 15=lowest). The new Interrupt Number, Interrupt Priority and I Flag determine whether the interrupt is processed immediately, or kept in the pool for later processing. In one embodiment, NMIs and enabled Maskable Interrupts take precedence over Exceptions. Priorities are only meaningful for maskable interrupts -not for exceptions or NMls.
* nesting Maskable interrupts are nestable. Nested interrupts can be achieved by re-enabling interrupts in an interrupt handler. Maskable interrupts can then be interrupted by maskable interrupts of greater importance (lower priority number) and NMIs. Services can only occur from MIs, and will cause a soft reset if called from an NMI handler.
* procedure When an interrupt or exception occurs, the processor performs a context-switch. A context switch involves storing the current processor state by pushing four logical words to the current stack. In particular, these words may comprise: the entire contents of the FLAGS register; the contents of the PC register (which contains either the address for the current instruction being executed or the next instruction to be executed, according to -14 -whether the interrupt allows for the current instruction to be completed); and two general purpose registers (RO, Ri) containing the address for the current instruction. This is shown in Figure 6a(i). Note that although four logical words are pushed to the stack, the PC register may actually comprise two words according to the version of the processor used. For example, as shown in Figure 6a(i), the PC register containing respectively a 16-bit address in the 16-bit XAP4 processor case and a 32-bit address in the 32-bit X.AP3 processor case can each be accommodated within a single word of the respective architecture. By contrast, in the 16-bit XAP5 processor the PC register requires two words (shown as %pc-H and %pc-L) to store the 24-bit address used in the XAP5 processor.
This is called a context push. Control is then passed to an associated software handler.
As with all software functions, the handlers use the stacks to store temporary variables.
When the handler has finished, it ends with an rtie (return from interrupt, exception) instruction. This pops the four logical words from the stack (five actual words in the XAP5 case because of the length of the PC register, as described above), thus restoring the processor to its original state, that is, the state it was in before the interrupt or exception event.
When a Maskable Interrupt is serviced, it causes the processor to switch to Interrupt Mode and sets FLAGS[IJ to 0. Privileged mode software can set FLAGS[IJ directly, for example, with a mov.1.i or mov.1.r instruction (setting the single bit using an immediate or to a value stored in a register) or by using the movr2s (write to a special register) instruction. The required processing in Interrupt mode is completed with an rtie instruction that returns to the original mode where the Interrupt occurred.
Maskable Interrupts are disabled (%flags[i] = 0) on all exceptions (resets, services, errors) and interrupts (Ml and NMI). It is good practise to have maskable interrupts disabled at the start of any Interrupt or Exception handler as it prevents further maskable interrupts from being serviced until the first one has been serviced to a safe state.
Consequently, all Interrupt and Exception events automatically set %flags[i] = 0.
When a Non-Maskable Interrupt is serviced, it causes the processor to switch to NMI state and sets FLAGS[IJ 0. It does not change the value of FLAGS[M]. The required processing in NMI state is completed with an instruction that returns to the original mode where the NMI occurred. While an NMI is being serviced, it cannot be interrupted.
Interrupts which occur while the processor core is doing this are remembered and are serviced after the handler returns. If an exception occurs in an NMI handler, a soft reset is triggered.
Figure 6a shows the procedure when an Interrupt or Exception is encountered i) %FLAGS pushed to stack ii) FLAGS[I] copied to FLAGS[C] iii) interrupts are disabled i.e. set flags[i] = 0 Hence, when an Exception or Interrupt event is taken, in addition to the information which is pushed to the stack (via the context push), the value of the I-bit (Maskable Interrupt enable bit) before the exception/interrupt event occurred is copied to the C (carry) bit i.e. the processor 10 copies %flags[i] to %flags[c] before setting %flags[i] to 0. i.e it uses %flags[c] as a temporary storage bit.
Fast restore of the Interrupt bit On encountering an interrupt, the interrupt bit %flags[i] is set to 0, disabling further (maskable) interrupts. However, some handlers do not need to keep maskable interrupts disabled and it is preferable if they can be re-enabled as soon as possible.
To do this, one option is for the handler to turn maskable interrupts back on directly with: mov.1.i %flags[i], #1 However, so as to enable the handler to restore interrupts to the same state they were in before the context push (due to an interrupt or exception), the processor instead copies -16-the value stored in the C-bit (which stores the previous value of the I-bit i.e. the interrupt state prior to the interrupt) back to the I-bit.
Figure 6b shows how this is accomplished in the processor 10, by restoring the value of the %flag[i] bit from the value temporarily stored in the %flags[c] bit. This is done with the following instruction: mov.1.r %flags[i], %flags[c] I/i.e copy C bit back to I bit This is a 16-bit instruction and only takes one clock cycle.
This operation is carried out early in the handler, before the C bit gets "corrupted" by some other instruction. In one example, this operation is carried out at the start of the handler execution, usually as the first instruction.
Setting the C bit this way allows the interrupt/exception handler to restore the I-bit to the state it was in before the exception/interrupt (turn them back on if they were on before the interrupt/exception) using a single register-to-register instruction. Register-to-register instructions are fast and use little instruction set space. This "overloading" or reuse of the C-bit means that the ability to quickly restore the interrupt enable state is done at very little cost.
Returning from Interrupts and Exceptions The rtie (Return from Interrupt, Exception) instruction is used to return from all Exceptions and Interrupts. It can only be executed in the Privileged modes. It pops the context from the current Stack (Stacki in Trusted mode, StackO in Supervisor and Interrupt modes). From all modes (Trusted, Supervisor, Interrupt) and states (NMI, Recovery), it carries out the same operation, which is: * Load FLAGS from the current stack.
* Load RO from the current stack.
* Load Ri from the current stack.
* Load PC from the current stack.
* Clear the INFO[NL] bit when executed in NMI state -17-Clear the INFO[R] bit when executed in Recovery state The rtie instruction is simply the null interrupt handler, restoring RO, Ri, FLAGS and PC, disabling NMI state or Recovery state, then returning to the original code (being executed when the event originally happened).
Alternative restore of the Interrupt bit Note that the whole FLAGS register value before the event is still available on the stack and this contains the same value of I bit before the event, which is the same as the value copied to the C-bit. The whole FLAGS register is restored at the end of the handler when the rtie instruction is executed (that restores the previous state with a context pop).
Since the I-bit is part of the FLAGS register it is also pushed to the stack when the FLAGS register is pushed to the stack during the exception entry sequence (i.e. the I-bit is copied to two places), and will be restored at the end of the interrupt or exception handler when the handler executes the rtie instruction. This means that if the exception handler wants to run with interrupts disabled, it can just ignore the C-bit -its value does not need to be saved.
Figure 7 is a flow chart showing an example of how interrupts are serviced by the processor 10. Detailed commentaries on the steps sl-s28 are as follows: For the first part of the sequence (Si -Si 1), interrupts are disabled i.e. the I-bit is set to 0.
Si. Start processing user code.
52. Processing user code. Processor will be in user mode (m3).
S3. NMI-1 encountered, control transferred to interrupt handler. NMIs cannot be disabled by software, therefore having interrupts disabled has no effect. Sequence A, as described by Figure 5a, is run i.e. i) %FLAGS pushed to stack ii) FLAGS[I] copied to FLAGS[C] iii) interrupts are disabled i.e. set flags[i] = 0 S4. Interrupt handler services interrupt.
-18 -S5. NMI-2 is encountered S6 and is pooled.
S7. Control returned from interrupt handler with an rile instruction S8. NMI-2 may now be serviced S9. Interrupt handler services NMI-2 Sb. Control returned from interrupt handler with an rtie instruction SI 1. MI-I encountered, not serviced as interrupts disabled.
For the second part of the sequence (si I-s28), interrupts are enabled i.e. the I-bit is set to I S12. Interrupts enabled by setting %flags[i] = I S13. Ml-2 encountered, control transferred to interrupt handler S14. Sequence A is run i.e. I) %FLAGS pushed to stack ii) FLAGS[I] copied to FLAGS[C] iii) interrupts are disabled i.e. set flags[i] = 0 S15. Servicing of interrupt Ml-2 S16. Control returned from interrupt handler with an rUe instruction S17. Continue processing user code S18. Ml-3 encountered, control transferred to interrupt handler S19. Sequence A is run i.e. i) %FLAGS pushed to stack ii) FLAGS[I] copied to FLAGS[CJ iii) interrupts are disabled i.e. set flags[i] = 0 S20. As the handler for MI-3 is capable of running with interrupts enabled, it initiates a fast restore of interrupt bit FLAGS[I] i.e. mov.1.r %flags[iJ, %flags[c] S21. Interrupt handler services Ml-3 S22. Ml-4 encountered. Although interrupts have been enabled in the fast restore described in step S20.
S23. MI-4 is not serviced immediately as previous Ml-3 not yet at safe state S24. MI-3 now at safe state, MI-4 passed to interrupt handler (only if higher priority than Ml-3) -19-S25. Ml-4 is serviced S26. Control returned from interrupt handler with an rtie instruction S27. Remaining servicing of MI-3 resumed S28. Control returned from interrupt handler with an rtie instruction S29. End.
In summary, the preferred embodiment preferably comprises at least the following three steps: 1. On detecting an Event (for example, an interrupt or exception), copying the I bit to the C bit in FLAGS register; 2. Disabling further maskable interrupts, by setting the I bit = 0; and 3. If required, copying the C bit back to I bit at or near the start of the interrupt (or exception) handler, for example by means of a mov.1.r instruction, to return the processor interrupt state to the state it was in prior to the interrupt or exception It will be understood that the present invention has been described above purely by way of example, and modifications of detail can be made within the scope of the invention.
Each feature disclosed in the description, and (where appropriate) the claims and drawings may be provided independently or in any appropriate combination.
Claims (39)
- -20 -CLAIMS1. A data processing apparatus comprising: a processor; a first memory location, the processor being adapted to control whether the operation of the processor may be interrupted in dependence on a value stored in the first memory location; and a second memory location, the processor being adapted a) to store a value in the second memory location following an event that is related to the value stored in the first memory location, and b) otherwise to store a value in the second memory location that is not related to the value stored in the first memory location.
- 2. Apparatus according to claim 1, wherein the event is an interrupt.
- 3. Apparatus according to claim 2, wherein the interrupt is an external, asynchronous event triggered by some action outside the processor.
- 4. Apparatus according to claim 3, wherein the interrupt is an external hardware event.5. Apparatus according to claim 4, wherein the interrupt is a timer reaching its terminal count.
- 5. Apparatus according to claim 4, wherein the interrupt is a serial port receiving a character.
- 6. Apparatus according to claim 1, wherein the event is an exception.
- 7. Apparatus according to claim 6, wherein the exception is an internai, synchronous event triggered by some action inside the processor.
- 8. Apparatus according to claim 7, wherein the exception is a reset.
- 9. Apparatus according to claim 7, wherein the exception is a service.-21 -
- 10. Apparatus according to claim 7, wherein the exception is an error.
- 11. Apparatus according to any preceding claim, wherein the vaiue stored in the second memory location is logically related to the value stored in the first memory location.
- 12. Apparatus according to claim 11, wherein the value stored in the second memory location is a copy of the value stored in the first memory location.
- 13. Apparatus according to any preceding claim, wherein the value is a single bit in size.
- 14. Apparatus according to any of claims 1 to 12, wherein the value is multiple bits in size.
- 15. Apparatus according to any preceding claim, wherein the processor further comprises means for storing a value in the first memory location in dependence on the value stored in the second memory location.
- 16. Apparatus according to any preceding claim, wherein the second memory location is primarily used for storing said unrelated value, and is only temporarily used for storing said related value.
- 17. Apparatus according to claim 16, wherein the second memory location is used for storing said related value following an interrupt or an exception related to the value stored in the first memory location.
- 18. Apparatus according to any preceding claim, wherein the second memory location is related to a control and/or status aspect of the processor.
- 19. Apparatus according to any preceding claim, wherein the second memory location is related to any other aspect of the processor other than a control and/or status aspect of the processor.-22 -
- 20. Apparatus according to any preceding claim, wherein the second memory location is not a general purpose memory location.
- 21. Apparatus according to any of claims 15 to 20, wherein the means for storing a value in the first memory location in dependence on the value stored in the second memory location is adapted to store said value in the first memory location before the value stored in the second memory location is altered by the processor.
- 22. Apparatus according to any preceding claim, wherein the second memory location is not a memory location which may be frequently used by the processor
- 23. Apparatus according to any preceding claim, wherein the second memory location is primarily used for storing an unrelated value which is used by arithmetic instructions.
- 24. Apparatus according to claim 23, wherein the unrelated value is used primarily to represent a carry bit.
- 25. Apparatus according to claim 23, wherein the unrelated value is used primarily to represent an overflow bit.
- 26. Apparatus according to any preceding claim, wherein the first and second memory locations are locations within registers of the processor.
- 27. Apparatus according to claim 26, wherein the apparatus is adapted to copy the value between register locations using a single processor instruction.
- 28. Apparatus according to claim 27, wherein the copying is performed within a single clock cycle.
- 29. Apparatus according to any of claims 26 to 28, wherein the first register location and the second register location are both located in the same register.
- 30. Apparatus according to claim 29, wherein the same register is a special register.
- 31. Apparatus according to claim 30, wherein the special register is adapted to store a plurality of values related to control and/or status aspects of the processor.
- 32. Apparatus according to any of claims 26 to 28, wherein the first register location and the second register location are located in different registers.
- 33. Apparatus according to any preceding claim, wherein the apparatus further comprises means for servicing an event.
- 34. Apparatus according to claim 33, wherein said means for servicing an event comprises the processor running program code specific to that event.
- 35. Apparatus according to any of claims 15 to 34, wherein the apparatus is adapted to store said value in the first memory location in dependence on said value stored in the second memory location within less than eight, preferably less than three, more preferably less than two, operations.
- 36. Apparatus according to any of claims 2 to 5 or 11 to 35, wherein there are at least two types of interrupts.
- 37. Apparatus according to claim 36, wherein the value stored in the first memory location controls whether the operation of the processor may be interrupted by a first type of interrupt.
- 38. Apparatus according to claim 37, wherein the first type of interrupt is a maskable interrupt.
- 39. Apparatus according to any of claim 38, wherein there is a hierarchy of maskable interrupts. -24-40. Apparatus according to claim 39, wherein the hierarchy is determined by the priority value associated with each maskable interrupt.41. Apparatus according to any of the preceding claims, further comprising means for servicing an event, wherein the event is a maskable interrupt, may be interrupted by a maskable interrupt of higher priority.42. Apparatus according to any preceding claim, wherein the processor further comprises means for storing a value in the first memory location following an interrupt.43. Apparatus according to claim 42, wherein the value stored determines whether the operation of the processor may be interrupted.44. Apparatus according to claim 43, wherein the value stored in the first memory location does not control whether the processor may be interrupted by a second type of interrupt.45. Apparatus according to claim 44, wherein the second type of interrupt is a non-maskable interrupt.46. Apparatus according to any of the preceding claims, further comprising means for servicing an event, wherein the operation of the means for servicing an event is adapted such that it may be interrupted by further non-maskable interrupts.47. Apparatus according to claim 46, wherein the operation of the means for servicing an event, such as an interrupt (or exception), is adapted such that it may only be interrupted once the servicing of the interrupt has progressed to a safe state.48. Apparatus according to any preceding claim, wherein the apparatus is adapted to enable or disable interrupts in dependence on the value stored in the first memory location.-25 - 49. Apparatus according to claim 48, wherein the first memory location is a bit within a special register (an interrupt bit).50. Apparatus according to claim 49, wherein setting the bit to one enables interrupts.51. Apparatus according to claim 49, wherein setting the bit to zero disables interrupts.52. Apparatus according to claim 49, wherein the apparatus is adapted, upon the occurrence of an event, such as an interrupt (or exception), to set the bit to zero.53. Apparatus according to any preceding claim, wherein the apparatus further comprises computer memory.54. Apparatus according to claim 53, wherein the processor is adapted to access said memory by means of a linear data structure such as a stack.55. Apparatus according to claim 54, wherein the apparatus is adapted such that when the processor operation is interrupted the value stored in the first register location is also copied onto the stack.56. Apparatus according to claim 55, wherein the apparatus is adapted to copy the value onto the stack by means of a hardware context push operation.57. Apparatus according to claim 56, wherein the hardware context push operation comprises copying onto the stack the entire contents of the register which includes the first register location.58. Apparatus according to any of claims 55 to 57, wherein the apparatus is adapted to store, when the operation of the processor is interrupted, the value which controls whether the operation of the processor may be interrupted by a first type of interrupt in at least two memory locations.-26 - 59. Apparatus according to claim 58, wherein at least one of the locations can be in a register.60. Apparatus according to claim 58 or 59, wherein at least one of the locations can be on the stack.61. A method of data processing, comprising: operating a processor, wherein the operation of the processor may be interrupted in dependence on a value stored in a first memory location; storing, in the first memory location, a value by which means the processor determines whether the operation of the processor may be interrupted; and storing, in a second memory location, a) after an interrupt, a value that is related to the value stored in the first memory location, and b) otherwise storing a value in the second memory location that is not related to the value stored in the first memory location.62. A computer program and a computer program product comprising software code adapted, when executed on a data processing apparatus, to perform a method according to claim 61.
Priority Applications (6)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
GB0812665A GB2461851A (en) | 2008-07-10 | 2008-07-10 | Processor, which stores interrupt enable flags in a location used for other functions |
PCT/GB2009/001318 WO2010004245A1 (en) | 2008-07-10 | 2009-05-27 | Processor with push instruction |
US13/003,432 US9645949B2 (en) | 2008-07-10 | 2009-05-27 | Data processing apparatus using privileged and non-privileged modes with multiple stacks |
PCT/GB2009/001314 WO2010004243A2 (en) | 2008-07-10 | 2009-05-27 | Interrupt processing |
PCT/GB2009/001309 WO2010004240A1 (en) | 2008-07-10 | 2009-05-27 | Data processing apparatus, for example using modes |
PCT/GB2009/001313 WO2010004242A2 (en) | 2008-07-10 | 2009-05-27 | Data processing apparatus, for example using vector pointers |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
GB0812665A GB2461851A (en) | 2008-07-10 | 2008-07-10 | Processor, which stores interrupt enable flags in a location used for other functions |
Publications (2)
Publication Number | Publication Date |
---|---|
GB0812665D0 GB0812665D0 (en) | 2009-03-04 |
GB2461851A true GB2461851A (en) | 2010-01-20 |
Family
ID=40445894
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
GB0812665A Withdrawn GB2461851A (en) | 2008-07-10 | 2008-07-10 | Processor, which stores interrupt enable flags in a location used for other functions |
Country Status (1)
Country | Link |
---|---|
GB (1) | GB2461851A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
DE3736890A1 (en) * | 1986-10-31 | 1988-05-11 | Sonic Cleaning Ab | SOUND TRANSMITTER |
US7948429B2 (en) | 2008-05-05 | 2011-05-24 | Raytheon Company | Methods and apparatus for detection/classification of radar targets including birds and other hazards |
US8344937B2 (en) | 2009-04-17 | 2013-01-01 | Raytheon Company | Methods and apparatus for integration of distributed sensors and airport surveillance radar to mitigate blind spots |
CN109240815A (en) * | 2018-08-24 | 2019-01-18 | 珠海格力电器股份有限公司 | Multi-task running method, device and equipment for shared stack |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1063594A2 (en) * | 1999-06-23 | 2000-12-27 | Denso Corporation | An interrupt controller and a microcomputer incorporating this controller |
US6175890B1 (en) * | 1996-06-12 | 2001-01-16 | Ricoh Company, Ltd. | Device for efficiently handling interrupt request processes |
WO2001014977A1 (en) * | 1999-08-19 | 2001-03-01 | Koninklijke Philips Electronics N.V. | Servicing of interrupts with stored and restored flags |
US20050240701A1 (en) * | 2004-04-27 | 2005-10-27 | Matsushita Electric Industrial Co., Ltd. | Interrupt control apparatus |
-
2008
- 2008-07-10 GB GB0812665A patent/GB2461851A/en not_active Withdrawn
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6175890B1 (en) * | 1996-06-12 | 2001-01-16 | Ricoh Company, Ltd. | Device for efficiently handling interrupt request processes |
EP1063594A2 (en) * | 1999-06-23 | 2000-12-27 | Denso Corporation | An interrupt controller and a microcomputer incorporating this controller |
WO2001014977A1 (en) * | 1999-08-19 | 2001-03-01 | Koninklijke Philips Electronics N.V. | Servicing of interrupts with stored and restored flags |
US20050240701A1 (en) * | 2004-04-27 | 2005-10-27 | Matsushita Electric Industrial Co., Ltd. | Interrupt control apparatus |
Non-Patent Citations (1)
Title |
---|
MCS6500 microcomputer family programming manual; Synertek Inc * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
DE3736890A1 (en) * | 1986-10-31 | 1988-05-11 | Sonic Cleaning Ab | SOUND TRANSMITTER |
US7948429B2 (en) | 2008-05-05 | 2011-05-24 | Raytheon Company | Methods and apparatus for detection/classification of radar targets including birds and other hazards |
US8344937B2 (en) | 2009-04-17 | 2013-01-01 | Raytheon Company | Methods and apparatus for integration of distributed sensors and airport surveillance radar to mitigate blind spots |
CN109240815A (en) * | 2018-08-24 | 2019-01-18 | 珠海格力电器股份有限公司 | Multi-task running method, device and equipment for shared stack |
CN109240815B (en) * | 2018-08-24 | 2021-07-23 | 珠海格力电器股份有限公司 | Multi-task running method, device and equipment for shared stack |
Also Published As
Publication number | Publication date |
---|---|
GB0812665D0 (en) | 2009-03-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2010004243A2 (en) | Interrupt processing | |
US7925864B2 (en) | Method and apparatus for binding shadow registers to vectored interrupts | |
US7600100B2 (en) | Instruction encoding for system register bit set and clear | |
US5812868A (en) | Method and apparatus for selecting a register file in a data processing system | |
US5517651A (en) | Method and apparatus for loading a segment register in a microprocessor capable of operating in multiple modes | |
US7185183B1 (en) | Atomic update of CPO state | |
US20060036824A1 (en) | Managing the updating of storage keys | |
JPH07248897A (en) | Method and device for recovery from exception in computer system | |
JPH07175666A (en) | Data processor and interruption request processing method for the same | |
JPH11327903A (en) | Ieee-based floating-point unit | |
KR100440361B1 (en) | Data processing system with auto-aligned stack pointer and method thereof | |
KR0133237B1 (en) | Backout logic for dual execution unit processor | |
JP2009163442A (en) | Arithmetic processing unit and method for extending instruction | |
JP2004157636A (en) | Data processing apparatus | |
GB2461851A (en) | Processor, which stores interrupt enable flags in a location used for other functions | |
CN115904649A (en) | User-level inter-processor interrupts | |
US5410660A (en) | System and method for executing branch on bit set/clear instructions using microprogramming flow | |
US6363474B1 (en) | Process switching register replication in a data processing system | |
US6199156B1 (en) | System for explicitly referencing a register for its current content when performing processor context switch | |
GB2461848A (en) | Processor with a privileged stack pointer and a stack pointer used in privileged and non-privileged modes | |
US20090063881A1 (en) | Low-overhead/power-saving processor synchronization mechanism, and applications thereof | |
US5327567A (en) | Method and system for returning emulated results from a trap handler | |
JP4114946B2 (en) | Data processing device | |
GB2461849A (en) | Push immediate instruction with several operands | |
JP2000235489A (en) | Processor |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
WAP | Application withdrawn, taken to be withdrawn or refused ** after publication under section 16(1) |