1. Field of the Invention
The present invention relates to a direct memory access (DMA) mechanism, and more particularly, to a DMA controller and DMA control method.
2. Description of the Related Art
DMA is a unique data transfer technique between memory and peripheral devices. This technique allows the peripheral devices to directly transfer data to the memory through system buses without assistance from the CPU. Direct memory access controllers (DMAC), in hardware or software form, are commonly responsible for managing data transfer to and from the memory module. A DMAC usually has multiple DMA channels, each corresponding to a separate memory block of the memory module.
One problem with the conventional transfer method is that the availability of each DMA channel has to be reset by the DMAC after each DMA channel activity, and such mechanism affects the throughput of the system. In addition, if T1 is too long, the necessary stack which is used to temporarily store the transferred data will miss some data due to overflow. Furthermore, because the real-time requirements and transfer bandwidth for each peripheral device are different, designing a universal memory access mechanism capable of adapting to all kinds of situations will unavoidably waste hardware resources.
A direct memory access (DMA) controlling method in accordance with one embodiment of the present invention comprises the steps of: building a linking table, wherein the linking table records the status of each memory block and a pointer pointing to a next memory block; activating a first memory block; receiving an interrupt signal and linking to a next associated memory block after the first memory block finishes a data transfer; activating the next associated block; and updating the linking table to release the first memory block for reuse.
A DMA controller in accordance with one embodiment of the present invention comprises a linking table configured to record the status of each memory block and a pointer pointing to a next associated memory block. The DMA controller initializes the status of each memory block and the pointer, then updates a transfer status of a memory block after receiving an interrupt signal from the memory block, and finally accesses the next associated memory block as indicated by the pointer.
A memory system in accordance with one embodiment of the present invention comprises a memory module and a DMA controller. The DMA controller is configured to activate the status of each memory block and a pointer pointing to a next associated memory block, to update a transfer state of a memory block after receiving an interrupt signal from the memory block, and to access the next associated memory block as indicated by the pointer.
The invention will be described according to the appended drawings in which:
For example, at the start of the DMA process, the contents of the linking table are as follows:
When the field of the block activating state of a memory block is marked as “H,” the block is settable. When the field of the block mask state of a memory block is marked as “H,” the block has not yet been activated; otherwise if marked as “L,” the block has been activated.
In accordance with the above table, only the block mask state of the memory block 0 is indicated as “L,” so the memory block 0 starts to transfer data. Since the pointer indicates the next memory block candidate is memory block 1, the block mask state of the memory block 1 will be set to “L” to provide accessibility to the DMAC after the data transfer of the memory block 0 is completed. The memory block 0 then sends an interrupt signal to DMAC, and the DMAC updates the block activating state and block mask state to retain the accessibility.
In accordance with another embodiment of the present invention, the fulfillment of a data transfer demand determines whether a used memory block will be linked next. For example, if the size of the data transfer is 1.4 MB, while the capacity of memory block 0 plus the capacity of memory block 1 is 1.6 MB, then the transfer demand will release a right to access the bus after the access of memory block 0 and memory block 1. However, if the capacity of memory block 0 plus the capacity of memory block 1 is 1.0 MB, then the next block pointer of memory block 0 has to be updated to keep memory block 0 available after the data transfer of memory block 0 is completed. The number of linked memory blocks is not limited.
The linking table in accordance with the embodiment comprises the following information or their combination: an information source address, an object address, a block activating state, a block mask state, the number of transferred words and transfer types.
The linking structure of the DMA is changeable. For example, when the quantity of accessed data is large or unknown, the linking structure can be set to be circular. However, if the quantity of accessed data is small or known, each memory block can be linked once, or only a portion of available memory blocks used. The above applications change only one field of the linking table, and therefore the present invention provides both flexibility and convenience. In addition, the above control methods can be implemented via hardware or software methods.
The memory block is allocated in the memory module 44. The memory blocks can be implemented by a couple of separate hardware devices or by an integrated memory with a high capacity that is internally partitioned. The capacities of the memory blocks can be the same or different, depending on the application. For example, memory blocks with the same capacity are simpler to manage, whereas memory blocks with varying capacities provide a more flexible application.
The above-mentioned status includes activated information and mask information. The activated information is used to record whether the memory block is settable, and the mask information is used to record whether the memory block is being used. In the present invention, the handover latency is reduced by setting the next memory block during activation of the memory blocks. Therefore, the total throughput and efficiency will increase, and there is more time to set DMA channels. The present method and apparatus are flexible, and can be implemented in many applications including audio/video information, memory-to-memory data transfer or best-effort applications. The present invention can improve handover latency without increasing the capacity of the memory block.
The above-described embodiments of the present invention are intended to be illustrative only. Numerous alternative embodiments may be devised by persons skilled in the art without departing from the scope of the following claims.
Number | Date | Country | Kind |
---|---|---|---|
097128569 | Jul 2008 | TW | national |