Direct Memmory Access
Direct Memmory Access
Introduction:
I want to make a modular OS starting with a flexible table based structure design for hardware and software.
Works nice in concept. The control actions look like a TSQL instruction.
(only the instructions are not string("SELECT") but a byte(0x01) for example)
After completion of the basic instructions, I started to normalize the computer and create the first tables. (I'm soooo happy they are flexible by design)
Stupid question:
I bounced to de definition DMA (Direct Memory Access) I already know it but…
Is it possible if I would send data to a device to remap the device DMA-Base address to a memory location. And when it’s finished point it to the next location in RAM. So don’t have to copy memory from one place to another.
Or for read. Move the DMA to a "fresh space" in memory when the buffer is full so I don’t have to take immediately lots of actions when the cards tells me to.
Is this possible or just a stupid thought?
I want to make a modular OS starting with a flexible table based structure design for hardware and software.
Works nice in concept. The control actions look like a TSQL instruction.
(only the instructions are not string("SELECT") but a byte(0x01) for example)
After completion of the basic instructions, I started to normalize the computer and create the first tables. (I'm soooo happy they are flexible by design)
Stupid question:
I bounced to de definition DMA (Direct Memory Access) I already know it but…
Is it possible if I would send data to a device to remap the device DMA-Base address to a memory location. And when it’s finished point it to the next location in RAM. So don’t have to copy memory from one place to another.
Or for read. Move the DMA to a "fresh space" in memory when the buffer is full so I don’t have to take immediately lots of actions when the cards tells me to.
Is this possible or just a stupid thought?
Computer says NOOOO
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Direct Memmory Access
Both. DMA works the way you want but not the way you said.Holus wrote:Is this possible or just a stupid thought?
DMA works by telling the hardware the location in system memory where it should read or write. It will then do what it needs to do, and when its done it will let you know via an interrupt.
In any case DMA is neither a verb nor an object. You can not move DMA. It's either there or it isn't.
Re: Direct Memmory Access
I still don't get it.Combuster wrote:In any case DMA is neither a verb nor an object. You can not move DMA. It's either there or it isn't.
What is DMA it's not clear by reading articles to me.
Makes DMA it possible for hardware to access memory?
Or makes DMA it possible to access memory on the hardware so you can use it like normal RAM?
I always thought DMA is a piece RAM that is the communication area between the hardware and the CPU. Hardware with it’s own processor can access a the RAM so the rest of the computer can communicate with it. Because the hardware has its own controller to execute the command given to the hardware and there is a IRQ-line on the BUS that communicate the status of the command to the CPU.
I can’t get this out of my mind if I read articles.
What is DMA???
Computer says NOOOO
Re: Direct Memmory Access
To keep it concise, DMA is the data transmission mechanism between the hardware devices and the Random Access Memory. The concept behind DMA is that data is transmitted directly to/from the Memory Bus without employing the CPU. The data transfer takes place whenever the Memory Bus is free. Of course, you need to setup the respective DMA channels before you could actually perform data transmission. This implies setting up the physical address to transfer, transfer length etc. which implicitly depends upon the DMA standard you're using.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Re: Direct Memmory Access
I'm maybe stupid or simple minded.Chandra wrote:To keep it concise, DMA is the data transmission mechanism between the hardware devices and the Random Access Memory. The concept behind DMA is that data is transmitted directly to/from the Memory Bus without employing the CPU. The data transfer takes place whenever the Memory Bus is free. Of course, you need to setup the respective DMA channels before you could actually perform data transmission. This implies setting up the physical address to transfer, transfer length etc. which implicitly depends upon the DMA standard you're using.
But if I use the DMA channel just like it's set-up. With the physical memory location that's set up. I still have to copy memory to another memory location. So, the CPU is busy to copy memory to memory after all. Can't I just reset the memory location of the DMA channel to a address where the data is??
Computer says NOOOO
Re: Direct Memmory Access
Which DMA are you using?I'm maybe stupid or simple minded.
But if I use the DMA channel just like it's set-up. With the physical memory location that's set up. I still have to copy memory to another memory location. So, the CPU is busy to copy memory to memory after all. Can't I just reset the memory location of the DMA channel to a address where the data is??
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Re: Direct Memmory Access
PCI Busmastering DMAChandra wrote:Which DMA are you using?
Computer says NOOOO
Re: Direct Memmory Access
It should be possible then, though I haven't give it a try myself. If it was ISA DMA, you could have only access to 1st 16Mb of Memory. You may want to give some more info about which device you're accessing so that someone else more accustomed to that device can answer your question.Holus wrote: PCI Busmastering DMA
And of course, PCI Busmastering DMA involves the use of PCI Bus, so things are different here.
Cheers!
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Re: Direct Memmory Access
For example the NETWORK and the HARDDISK.Chandra wrote:It should be possible then, though I haven't give it a try myself. If it was ISA DMA, you could have only access to 1st 16Mb of Memory. You may want to give some more info about which device you're accessing so that someone else more accustomed to that device can answer your question.Holus wrote: PCI Busmastering DMA
And of course, PCI Busmastering DMA involves the use of PCI Bus, so things are different here.
Cheers!
Computer says NOOOO
Re: Direct Memmory Access
You supply the device with a list of physical addresses and sizes and the device reads or writes directly to that memory. For a hard drive those addresses could be your block cache so no further copying will be required.Holus wrote:I'm maybe stupid or simple minded.
But if I use the DMA channel just like it's set-up. With the physical memory location that's set up. I still have to copy memory to another memory location. So, the CPU is busy to copy memory to memory after all. Can't I just reset the memory location of the DMA channel to a address where the data is??
If a trainstation is where trains stop, what is a workstation ?
Re: Direct Memmory Access
DMA copies directly to a buffer in main memory, the address and size of which you specify.
http://www.centrillium-it.com/Projects/idems100.pdf
http://www.centrillium-it.com/Projects/idems100.pdf
- DavidCooper
- Member
- Posts: 1150
- Joined: Wed Oct 27, 2010 4:53 pm
- Location: Scotland
Re: Direct Memmory Access
Moving data from one place in memory to another using the CPU isn't hugely time-consuming because there are no delays, though I suppose you could save a little time by doing it using DMA, but the real point of DMA is for getting data in (or out) from (or to) slower storage devices or networks where you don't want the CPU wasting time hanging around waiting for bytes to be delivered (or collected), or where you don't want it being repeatedly interrupted whenever it's a suitable time to send or receive a byte. Once the DMA has transferred the whole lot into a buffer, the CPU can move the whole lot in one rapid burst of activity.
I don't know if anyone uses DMA for memory to memory transfers, but if they don't it may be because of the difficulty in working out where the memory actually is - if you're using paged memory, the DMA isn't going to have any idea where the pages are (I assume, perhaps wrongly, that they lack the ability to read the page tables), so you're going to have to program it to transfer little 4KB chunks here and there, scattered about in physical memory, and that would be a nightmare.
I don't know if anyone uses DMA for memory to memory transfers, but if they don't it may be because of the difficulty in working out where the memory actually is - if you're using paged memory, the DMA isn't going to have any idea where the pages are (I assume, perhaps wrongly, that they lack the ability to read the page tables), so you're going to have to program it to transfer little 4KB chunks here and there, scattered about in physical memory, and that would be a nightmare.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Direct Memmory Access
No, it's because paging makes memory-to-memory transfers unnecessary. Finding the physical address for a virtual address simply requires a pagewalk so that can't be the problem either.I don't know if anyone uses DMA for memory to memory transfers, but if they don't it may be because of the difficulty in working out where the memory actually is
- DavidCooper
- Member
- Posts: 1150
- Joined: Wed Oct 27, 2010 4:53 pm
- Location: Scotland
Re: Direct Memmory Access
I suppose you could move a file to a new memory location just by changing the page table entries, but if you have a large file which is only contiguous and in proper order within a paged environment while actually being scattered around in physical memory, don't you have to move it into a buffer in physically contiguous memory somewhere before you get the DMA to transfer it to a storage device? The alternative would be to set up a whole series of DMA transfers for each contiguous chunk of file until it's all been done, each transfer being set up after the previous one is complete. (I'm obviously still working on the assumption that DMA can't read page tables, so please correct me if I'm behind the times on that point.)Combuster wrote:No, it's because paging makes memory-to-memory transfers unnecessary.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
Re: Direct Memmory Access
No, you can supply a list of physaddr/length pairs and the controller takes care of scatter/gathering the pieces.DavidCooper wrote:... but if you have a large file which is only contiguous and in proper order within a paged environment while actually being scattered around in physical memory, don't you have to move it into a buffer in physically contiguous memory somewhere before you get the DMA to transfer it to a storage device? The alternative would be to set up a whole series of DMA transfers for each contiguous chunk of file until it's all been done, each transfer being set up after the previous one is complete. (I'm obviously still working on the assumption that DMA can't read page tables, so please correct me if I'm behind the times on that point.)
If a trainstation is where trains stop, what is a workstation ?