An interrupt processing module for protecting and restoring a scene
Data movement between the control/status register and memory is directly realized through the DMA unit and the internal register access unit of the processor core, which solves the time and code consumption problems caused by the general-purpose register bridge in the existing technology, and achieves more efficient interrupt processing.
Patent Information
- Application Number
- CN202210060983.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-19
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2042-01-19
AI Technical Summary
When existing processors protect and restore the scene, they need to use general registers as data bridges, which results in greater time consumption and larger code size.
The DMA unit and the internal register access unit of the processor core are used to directly realize the data movement between the control/status register and the memory, avoiding the general register, sending the startup instruction through the DMA read and write instruction generation unit, starting the DMA read/write operation, and directly transferring the data between the control/status register and the memory. Register data is written to/read from memory.
It greatly shortens the time to protect and restore the scene, reduces the code size, and improves the processor's interrupt handling efficiency.
Smart Images

Figure CN114416614B
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of processor interrupt processing, in particular to an interrupt processing module for protecting a scene and restoring a scene. Background Art
[0002] When an interrupt occurs, the processor will save the data in the internal registers of the processor core in the current state to the memory. This application refers to this behavior of the processor as "protecting the scene". The process of protecting the scene of the processor in the prior art is as follows: 1. The processor takes out the data in the control register and status register of its core and saves them to the general register; 2. The processor then saves the data in the general register to the memory.
[0003] When the interrupt processing is finished, the processor will restore the data to be restored in the memory to the corresponding registers inside the processor core. This application refers to this behavior of the processor as "recovery scene". The process of processor recovery scene in the prior art is as follows: 1. The processor takes out the data to be restored from the memory and saves it to the general register inside the processor core; 2. The processor then restores the data to be restored in the general register to the corresponding control register and status register inside the processor core.
[0004] Based on this, in the process of protecting / restoring the scene of the processor in the prior art, the general register is used as a bridge to move data between the control / status register and the memory. If the data movement between the control / status register and the memory can be realized directly, the time required for transferring data from the control / status register to the general register when protecting the scene and the time required for transferring data from the general register to the control / status register when restoring the scene will be saved, which greatly shortens the time required for protecting the scene and restoring the scene, and at the same time reduces the code volume of protecting the scene and restoring the scene. Summary of the invention
[0005] In view of the above problems existing in the existing processor interrupt processing technology, the present invention provides an interrupt processing module for protecting and restoring the scene, which can reduce the code volume and shorten the time required for protecting and restoring the scene.
[0006] An interrupt processing module for protecting and restoring a scene, comprising a DMA read / write instruction generating unit, a DMA unit, and a processor core internal register access unit, wherein the DMA read / write instruction generating unit is connected to the DMA unit, the DMA unit is bidirectionally connected to the processor core internal register access unit and a memory, and the processor core internal register access unit is bidirectionally connected to the processor core internal register;
[0007] A DMA read / write instruction generating unit, used for sending a DMA read / write start instruction to the DMA unit according to the DMA read / write assembly instruction;
[0008] The DMA unit is used to receive a DMA read / write start instruction and start a DMA read / write operation; a DMA write operation refers to the processor core internal register access unit reading the data to be protected in the processor core internal register, returning it to the DMA unit, and the DMA unit writing it into the memory; a DMA read operation refers to the DMA unit reading the data to be restored in the memory, and the processor core internal register access unit writing it into the corresponding processor core internal register;
[0009] The processor core internal register access unit is used to cooperate with the DMA unit to read and restore data in the processor core internal register, where the processor core internal registers are uniformly addressed and the address space is continuous.
[0010] Furthermore, the DMA unit starts a DMA write operation including sending a data fetch command to the processor core internal register access unit and sending a data write command to the memory; the DMA unit starts a DMA read operation including sending a data read command to the memory and sending a data recovery command to the processor core internal register access circuit.
[0011] Furthermore, the specific workflow of the interrupt processing module for protecting the scene and restoring the scene includes the following steps:
[0012] Step 1: When an interrupt occurs, the processor jumps to the interrupt entry, executes the DMA write assembly instruction, and starts protecting the scene;
[0013] Step 2, the DMA write assembly instruction triggers the DMA read and write instruction generation unit to set the dma_wr_start flag;
[0014] Step 3: The DMA unit detects the dma_wr_start flag, starts the DMA write operation, and sends a data fetch command to the internal register access unit of the processor core. The data fetch command includes a register read instruction and a register read address.
[0015] Step 4, after receiving the data fetch command, the register access unit inside the processor core returns the data in the register of the corresponding address to the DMA unit according to the register read address in the data fetch command;
[0016] Step 5, the DMA unit writes the received data into the memory;
[0017] Step 6, determine whether the protection scene is completed, if it is completed, go to step 7, otherwise jump to step 4;
[0018] Step 7, the DMA read / write instruction generation unit clears the dma_wr_start flag, and the processor starts processing interrupts;
[0019] Step 8: After the processor handles the interrupt, it executes the DMA read assembly instruction to start restoring the scene;
[0020] Step 9, the DMA read assembly instruction triggers the DMA read and write instruction generation unit to set the dma_rd_start flag;
[0021] Step 10, the DMA unit detects the dma_rd_start flag and starts the DMA read operation;
[0022] Step 11, the DMA unit reads the data to be recovered from the memory, and sends a data recovery command to the internal register access unit of the processor core, where the data recovery command includes a register write instruction, a register write address, and a register write data;
[0023] Step 12, after receiving the data recovery command, the register access unit inside the processor core recovers the data to be recovered to the register of the corresponding address according to the register write address in the data recovery command;
[0024] Step 13, determine whether the scene recovery is completed, if it is completed, go to step 14, otherwise jump to step 11;
[0025] Step 14, the DMA read / write instruction generation unit clears the dma_rd_start flag, and the processor executes the interrupt return instruction to exit the interrupt.
[0026] Furthermore, the processor core internal register access unit includes a register reduction unit, which is used to reduce the data and data valid signals of all processor core internal registers into x data and data valid signals, where x is a positive integer less than the number of processor core internal registers;
[0027] The register access unit inside the processor core then selects valid data and data valid signals from the x-path data and data valid signals reduced by the register reduction unit, and returns them to the DMA unit, wherein the data valid signal is the logical OR of the x-path data valid signals reduced by the register reduction circuit, and the valid data is selected from the x-path data reduced by the register reduction circuit using the x-path data valid signals reduced by the register reduction circuit.
[0028] The present invention realizes data migration between the internal registers of the processor core and the memory through the mutual cooperation of the internal register access unit of the processor core and the DMA unit, without using the general register as a bridge for moving data, thus saving the time required for protecting and restoring the scene, and reducing the code volume for protecting and restoring the scene. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1It is a structural block diagram and signal flow diagram of the interrupt processing module used for protecting and restoring the scene;
[0030] Figure 2 It is a specific workflow diagram of the interruption processing module used for protecting and restoring the scene;
[0031] Figure 3 It is a code volume comparison diagram of two processor interrupt processing methods of the prior art and the present invention. DETAILED DESCRIPTION
[0032] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The embodiments of the present invention are provided for the purpose of illustration and description, and are not intended to be exhaustive or to limit the present invention to the disclosed forms. Many modifications and variations will be apparent to those of ordinary skill in the art. The embodiments are selected and described in order to better illustrate the principles and practical applications of the present invention, and to enable those of ordinary skill in the art to understand the present invention and thereby design various embodiments with various modifications suitable for specific uses.
[0033] Example 1
[0034] An interrupt processing module for protecting and restoring the scene, such as Figure 1 As shown, it includes a DMA read and write instruction generating unit, a DMA unit, and a processor core internal register access unit. The DMA read and write instruction generating unit is connected to the DMA unit. The DMA unit is bidirectionally connected to the processor core internal register access unit and the memory. The processor core internal register access unit is bidirectionally connected to the processor core internal register.
[0035] The DMA read / write instruction generating unit is used to send a DMA read / write start instruction to the DMA unit according to the DMA read / write assembly instruction.
[0036] The specific working process of the DMA read and write instruction generation unit is as follows:
[0037] 1. When an interrupt occurs, the processor jumps to the interrupt entry, executes the DMA write assembly instruction, and starts protecting the scene;
[0038] 2. The DMA write assembly instruction triggers the DMA read / write instruction generation unit to set the dma_wr_start flag, which in turn enables the DMA unit to start the DMA write operation and perform interrupt protection on-site operations;
[0039] 3. After the interrupt protection site operation is completed, the DMA read and write instruction generation unit clears the dma_wr_start flag, and the processor starts to process the interrupt;
[0040] 4. After the processor handles the interrupt, it executes the DMA read assembly instruction and starts to restore the scene;
[0041] 5. The DMA read assembly instruction triggers the DMA read and write instruction generation unit to set the dma_rd_start flag, which in turn enables the DMA unit to start the DMA read operation and perform interrupt recovery on-site operation;
[0042] 6. After the interrupt recovery site operation is completed, the DMA read and write instruction generation unit clears the dma_rd_start flag, and the processor executes the interrupt return instruction to exit the interrupt.
[0043] The DMA unit receives a DMA read / write start instruction, and is used to send a DMA read / write operation to a register access unit inside the processor core, wherein sending a DMA read operation includes sending a read data command to the memory and sending a data recovery command to the register access unit inside the processor core, and sending a DMA write operation includes sending a fetch data command to the register access unit inside the processor core and sending a write data command to the memory.
[0044] The specific workflow of the DMA unit is as follows:
[0045] 1. Interruption protection on-site stage
[0046] ① The DMA unit detects the dma_wr_start flag, starts the DMA write operation, and sends a data fetch command to the register access unit inside the processor core. The data fetch command contains the register read instruction (reg_rd) and the register read address (reg_raddr);
[0047] ②After receiving the data fetch command, the register access unit inside the processor core returns the data (reg_rdata) and its data valid signal (reg_rdata_vld) in the register of the corresponding address to the DMA unit according to the register read address (reg_raddr) in the data fetch command;
[0048] ③After receiving reg_rdata and reg_rdata_vld, the DMA unit converts the reg_rdata, reg_rdata_vld signals and memory address into a write data command (including write instruction wr_cmd, write data wdata, and data valid signal wdata_vld), writes the data into the memory, and completes the operation of interrupting the protection scene.
[0049] 2. Interruption and recovery stage
[0050] ① The DMA unit detects the dma_rd_start flag, starts the DMA read operation, sends a read data command (rd_cmd) to the memory, reads out the data to be recovered (rdata) and the data valid signal (rdata_vld), and converts them into a data recovery command (including the register write instruction reg_wr, the register write address reg_waddr, and the register write data reg_wdata) and transmits them to the register access unit inside the processor core;
[0051] ② After receiving the data recovery command, the register access unit inside the processor core restores the data to be recovered to the register of the corresponding address, completing the operation of interrupt recovery site.
[0052] The processor core internal register access unit is used to receive the data fetch / data recovery command sent by the DMA unit, as well as the data and data valid signal of each register returned by the processor core internal register access unit, and send the data fetch / data recovery command to the read / write port of each register inside the processor core, wherein the processor core internal registers are uniformly addressed and the address space is continuous.
[0053] The specific workflow of the processor core internal register access unit is as follows:
[0054] 1. Interruption protection on-site stage
[0055] ① After receiving the data fetch command (reg_rd, reg_raddr), the register access unit inside the processor core sends the data fetch command (reg_rd, reg_raddr) to the read port of each register inside the processor core;
[0056] ② After the register at the corresponding address inside the processor core receives the data fetch command (reg_rd, reg_raddr), the data of n processor core internal registers (reg_rdata_x, x = 0, 1, 2, ..., n) and their data valid signals (reg_rdata_vld_x, x = 0, 1, 2, ..., n; high level is valid) are returned to the processor core internal register access unit;
[0057] ③ The register reduction circuit reduces the data reg_rdata_0, reg_rdata_1, ..., reg_rdata_n-1, reg_rdata_n and their data valid signals reg_rdata_vld_0, reg_rdata_vld_1, ..., reg_rdata_vld_n-1, reg_rdata_vld_n of the n processor core internal registers into three data reg_rdata_00, reg_rdata_11, reg_rdata_22 and their data valid signals (reg_rdata_vld_00, reg_rdata_vld_11, reg_rdata_vld_22);
[0058] ④The register access unit inside the processor core selects the corresponding valid data through the three data valid signals reg_rdata_vld_00, reg_rdata_vld_11, and reg_rdata_vld_22 to generate valid data reg_rdata;
[0059] ⑤The processor core internal register access unit performs an OR operation on the three data valid signals reg_rdata_vld_00, reg_rdata_vld_11, and reg_rdata_vld_22 to generate a data valid signal reg_rdata_vld;
[0060] ⑥The processor core internal register access unit returns the valid data reg_rdata and the data valid signal reg_rdata_vld to the DMA unit.
[0061] 2. Interruption and recovery stage
[0062] After receiving the data recovery command (reg_wr, reg_waddr, reg_wdata), the register access unit inside the processor core sends the data recovery command (reg_wr, reg_waddr, reg_wdata) to the write port of each register inside the processor core, and writes the data reg_wdata to be recovered into the register of the corresponding address.
[0063] In summary, the specific workflow of the interruption processing module for protecting and restoring the scene is as follows: Figure 2 As shown, the following steps are included:
[0064] Step 1: When an interrupt occurs, the processor jumps to the interrupt entry, executes the DMA write assembly instruction, and starts protecting the scene;
[0065] Step 2, the DMA write assembly instruction triggers the DMA read and write instruction generation unit to set the dma_wr_start flag;
[0066] Step 3: The DMA unit detects the dma_wr_start flag, starts the DMA write operation, and sends a data fetch command to the internal register access unit of the processor core. The data fetch command includes a register read instruction and a register read address.
[0067] Step 4, after receiving the data fetch command, the register access unit inside the processor core returns the data in the register of the corresponding address to the DMA unit according to the register read address in the data fetch command;
[0068] Step 5, the DMA unit writes the received data into the memory;
[0069] Step 6, determine whether the protection scene is completed, if it is completed, go to step 7, otherwise jump to step 4;
[0070] Step 7, the DMA read / write instruction generation unit clears the dma_wr_start flag, and the processor starts processing interrupts;
[0071] Step 8: After the processor handles the interrupt, it executes the DMA read assembly instruction to start restoring the scene;
[0072] Step 9, the DMA read assembly instruction triggers the DMA read and write instruction generation unit to set the dma_rd_start flag;
[0073] Step 10, the DMA unit detects the dma_rd_start flag and starts the DMA read operation;
[0074] Step 11, the DMA unit reads the data to be recovered from the memory, and sends a data recovery command to the internal register access unit of the processor core, where the data recovery command includes a register write instruction, a register write address, and a register write data;
[0075] Step 12, after receiving the data recovery command, the register access unit inside the processor core recovers the data to be recovered to the register of the corresponding address according to the register write address in the data recovery command;
[0076] Step 13, determine whether the scene recovery is completed, if it is completed, go to step 14, otherwise jump to step 11;
[0077] Step 14, the DMA read / write instruction generation unit clears the dma_rd_start flag, and the processor executes the interrupt return instruction to exit the interrupt.
[0078] The technical effect achieved by the present invention is demonstrated below with reference to a specific example. It is assumed that there are 1000 registers to be protected inside the processor core, the data bit width of each register is 32 bits, and the data bit width transmitted in each cycle is 256 bits, i.e., 8 32-bit registers.
[0079] 1. Use the existing processor interrupt processing method
[0080] The time required to move the data in the control register and the status register to the general register is 1000 / 8 = 125 clock cycles; the time required to move the data to be protected in the general register to the memory is 1000 / 8 = 125 clock cycles; the time required to move the data to be restored in the memory to the general register is 1000 / 8 = 125 clock cycles; the time required to move the data to be restored in the general register to the control register and the status register is 1000 / 8 = 125 clock cycles. Therefore, the time required to interrupt the protection scene is 250 clock cycles, and the time required to interrupt the restoration scene is 250 clock cycles.
[0081] 2. Using the processor interrupt processing method proposed by the present invention
[0082] The DMA read / write instruction generation unit sends a DMA read / write start instruction to the DMA unit. The time required to start the DMA read / write operation is 4 clock cycles. The time required for the DMA write operation to move the data in the internal register of the processor core to the memory is 1000 / 8=125 clock cycles. The time required for the DMA read operation to move the data to be restored in the memory to the corresponding register inside the processor core is 1000 / 8=125 clock cycles. Therefore, the time required to interrupt the protection scene is 129 clock cycles, and the time required to interrupt the recovery scene is 129 clock cycles.
[0083] By comparing the two, it can be seen that the present invention greatly saves the time required for protecting and restoring the scene. Figure 3 As shown, it can be clearly seen that the code size for protecting the scene and restoring the scene is reduced.
[0084] Each operation of the processor core internal register access unit is directed to the read / write ports of all processor core internal registers to be protected. When the processor core internal register access unit writes data to the register, only the register with the same address as the register write address reg_waddr in the data recovery command can write the register write data reg_wdata; similarly, when the processor core internal register access unit reads data from the register, only the register with the same address as the register read address reg_raddr in the data fetch command will return valid data and a valid (high level) data valid signal, and then the data in the register to be read by the DMA unit can be filtered out through the data valid signal fed back by each register.
[0085] Based on this principle, this embodiment uses a register reduction unit to implement the above screening. The register reduction unit is used to reduce the data and data valid signals of all processor core internal registers into x data and data valid signals, where x is a positive integer less than the number of processor core internal registers. In this embodiment, x=3, corresponding to 1 control register data, 1 status register data and 1 general register data. In this process, the data in the register of the corresponding address must be in these 3 data.
[0086] The register access unit inside the processor core then selects valid data and data valid signals from the three data and data valid signals reduced by the register reduction unit, and returns them to the DMA unit, where the data valid signal is the logical OR of the three data valid signals reduced by the register reduction circuit, and the valid data is selected from the three data reduced by the register reduction circuit using the three data valid signals reduced by the register reduction circuit (only one of which is at a high level).
[0087] The above method of selecting one channel of valid data from n channels of data can be implemented based on the existing technology and will not be described in detail here.
[0088] Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field and related fields without creative work should fall within the scope of protection of the present invention.
Claims
1. An interrupt processing module for protecting and restoring a scene, characterized in that: It includes a DMA read / write instruction generating unit, a DMA unit, and a processor core internal register access unit. The DMA read / write instruction generating unit is connected to the DMA unit. The DMA unit is bidirectionally connected to the processor core internal register access unit and the memory. The processor core internal register access unit is bidirectionally connected to the processor core internal register. A DMA read / write instruction generating unit, used for sending a DMA read / write start instruction to the DMA unit according to the DMA read / write assembly instruction; A DMA unit, used for receiving a DMA read / write start instruction and starting a DMA read / write operation; DMA write operation means that the processor core internal register access unit reads the data to be protected in the processor core internal register, returns it to the DMA unit, and the DMA unit writes it into the memory; DMA read operation means that the DMA unit reads the data to be restored in the memory, and the processor core internal register access unit writes it into the corresponding processor core internal register; The processor core internal register access unit is used to cooperate with the DMA unit to read and restore data in the processor core internal register, where the processor core internal registers are uniformly addressed and the address space is continuous.
2. The interrupt processing module for protecting and restoring a scene according to claim 1, characterized in that: The DMA unit starts a DMA write operation, including sending a data fetch command to the processor core internal register access unit and sending a data write command to the memory; the DMA unit starts a DMA read operation, including sending a data read command to the memory and sending a data recovery command to the processor core internal register access circuit.
3. The interrupt processing module for protecting and restoring a scene according to claim 2, characterized in that: The specific workflow includes the following steps: Step 1: When an interrupt occurs, the processor jumps to the interrupt entry, executes the DMA write assembly instruction, and starts protecting the scene; Step 2, the DMA write assembly instruction triggers the DMA read and write instruction generation unit to set the dma_wr_start flag; Step 3: The DMA unit detects the dma_wr_start flag, starts the DMA write operation, and sends a data fetch command to the internal register access unit of the processor core. The data fetch command includes a register read instruction and a register read address. Step 4, after receiving the data fetch command, the register access unit inside the processor core returns the data in the register of the corresponding address to the DMA unit according to the register read address in the data fetch command; Step 5, the DMA unit writes the received data into the memory; Step 6, determine whether the protection scene is completed, if it is completed, go to step 7, otherwise jump to step 4; Step 7, the DMA read / write instruction generation unit clears the dma_wr_start flag, and the processor starts processing interrupts; Step 8: After the processor handles the interrupt, it executes the DMA read assembly instruction to start restoring the scene; Step 9, the DMA read assembly instruction triggers the DMA read and write instruction generation unit to set the dma_rd_start flag; Step 10, the DMA unit detects the dma_rd_start flag and starts the DMA read operation; Step 11, the DMA unit reads the data to be recovered from the memory, and sends a data recovery command to the internal register access unit of the processor core, where the data recovery command includes a register write instruction, a register write address, and a register write data; Step 12, after receiving the data recovery command, the register access unit inside the processor core recovers the data to be recovered to the register of the corresponding address according to the register write address in the data recovery command; Step 13, determine whether the scene recovery is completed, if it is completed, go to step 14, otherwise jump to step 11; Step 14, the DMA read / write instruction generation unit clears the dma_rd_start flag, and the processor executes the interrupt return instruction to exit the interrupt.
4. The interrupt processing module for protecting and restoring a scene according to any one of claims 1 to 3, characterized in that: The processor core internal register access unit includes a register reduction unit, and the register reduction unit is used to uniformly reduce the data and data valid signals of all processor core internal registers into x-path data and data valid signals, where x is a positive integer less than the number of processor core internal registers; The register access unit inside the processor core then selects valid data and data valid signals from the x-path data and data valid signals reduced by the register reduction unit, and returns them to the DMA unit, wherein the data valid signal is the logical OR of the x-path data valid signals reduced by the register reduction circuit, and the valid data is selected from the x-path data reduced by the register reduction circuit using the x-path data valid signals reduced by the register reduction circuit.
Citation Information
Patent Citations
Direct memory access DMA controller and data access method
CN105786735A
Method and device for carrying out rapid data communication by embedded processor, and storage medium
CN110737618A
Deterministic control system for the operation of data transfer means by direct memory access
US20180113827A1
Virtual shadow registers and virtual register windows
US6128728A
Data transmission method and device and storage medium
WO2016202114A1
