DMA example, how does DMA work?
DMA example, how does DMA work?
Is DMA handled by the Super I/O chip on modern motherboards? How does DMA work register- and I/O port-wise, and are there any code examples anywhere?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:DMA example, how does DMA work?
don't know of any example quickly, but
http://www.mega-tokyo.com/forum/index.p ... eadid=6599
http://www.mega-tokyo.com/forum/index.p ... eadid=6624
could help you with basic information.
And yes, nowaday the 8237 (iirc) is emulated by the chipset.
http://www.mega-tokyo.com/forum/index.p ... eadid=6599
http://www.mega-tokyo.com/forum/index.p ... eadid=6624
could help you with basic information.
And yes, nowaday the 8237 (iirc) is emulated by the chipset.
Re:DMA example, how does DMA work?
Do anybody know some links to pages about programming DMA in 32bit addresing "mode"" or even in "24bit mode"?
Re:DMA example, how does DMA work?
PS: in the net, the only faqs and tutorials i found was about DMA programming in real mode - 16bit addressing
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:DMA example, how does DMA work?
the DMA completely ignores what the CPU does with addresses. It works the very same way regardless of whether the CPU is in real or protected mode. DMA only has access to lowest 16MB of physical memory and must be programmed with *physical* address.
Thus when operating the DMA controller from protected mode, one must compute the physical address (looking up pages and segment descriptors manually in some cases) of the target buffer rather than programming the DMA with the 'linear' address (e.g. what &buffer returns)
Thus when operating the DMA controller from protected mode, one must compute the physical address (looking up pages and segment descriptors manually in some cases) of the target buffer rather than programming the DMA with the 'linear' address (e.g. what &buffer returns)
Re:DMA example, how does DMA work?
ok, but how physical 32bit address is computed when there are only 24 bits avaible in DMA chip?
How to calculate page and the rest of the address knowing physical position of the buffer?
How to calculate page and the rest of the address knowing physical position of the buffer?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:DMA example, how does DMA work?
very simple: the highest 8 bits are always zero ... the 'page' register has nothing to do with the 'paging' unit of the MMU, here. It just contains bits 16..23 (iirc). Thus once you have the physical address,
Code: Select all
page=phys>>16;
offset=phys & 0xFFFF;
Re:DMA example, how does DMA work?
Hi,
It might be a good idea to use a memory area that is specially selected for DMA use though. If you used *any* physical address you felt like then you might end up with DMAoffset too high, which would restrict the size of the DMA transfer. In general you probably want DMAoffset=0x0000 so that you can transfer a full 64 KB in one go.
If you had DMAoffset = 0xFFF0 and tried to transfer more than 16 bytes it'd wrap around. For example, if you tried to transfer 32 Kb to 0x0007FFF0 it'd put the first 16 bytes from 0x0007FFF0 to 0x0007FFFF and the remaining 32752 bytes from 0x00070000 to 0x00077FF0 - probably not what you'd want.
Cheers,
Brendan
The DMA chip can only address 16 Mb of physical memory. It only needs 24 bits for this (there's no way for ISA DMA to transfer anything above 16 Mb).RMX wrote: ok, but how physical 32bit address is computed when there are only 24 bits avaible in DMA chip?
That's not too hard:RMX wrote: How to calculate page and the rest of the address knowing physical position of the buffer?
Code: Select all
DMApage = (bufferAddress >> 16);
DMAoffset = (bufferAddress & 0xFFFF);
If you had DMAoffset = 0xFFF0 and tried to transfer more than 16 bytes it'd wrap around. For example, if you tried to transfer 32 Kb to 0x0007FFF0 it'd put the first 16 bytes from 0x0007FFF0 to 0x0007FFFF and the remaining 32752 bytes from 0x00070000 to 0x00077FF0 - probably not what you'd want.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re:DMA example, how does DMA work?
hm...i thought that this problem was already solved by adding new couter registers and few other(?):It might be a good idea to use a memory area that is specially selected for DMA use though. If you used *any* physical address you felt like then you might end up with DMAoffset too high, which would restrict the size of the DMA transfer. In general you probably want DMAoffset=0x0000 so that you can transfer a full 64 KB in one go.
If you had DMAoffset = 0xFFF0 and tried to transfer more than 16 bytes it'd wrap around. For example, if you tried to transfer 32 Kb to 0x0007FFF0 it'd put the first 16 bytes from 0x0007FFF0 to 0x0007FFFF and the remaining 32752 bytes from 0x00070000 to 0x00077FF0 - probably not what you'd want.
http://members.tripod.com/ben_schmitz/freebsd/handbook/handbook295.html
Re:DMA example, how does DMA work?
Hi,
As far as I can tell the EISA DMA controller was only ever present in EISA computers (which are rare as EISA died before it really got started)...
Of course PCI devices can have built in bus mastering capabilities, but that doesn't help the legacy ISA stuff (floppy, parallel port, older sound cards, etc)..
Cheers,
Brendan
Yes it was solved, but the solution was abandonedRMX wrote: hm...i thought that this problem was already solved by adding new couter registers and few other(?):
As far as I can tell the EISA DMA controller was only ever present in EISA computers (which are rare as EISA died before it really got started)...
Of course PCI devices can have built in bus mastering capabilities, but that doesn't help the legacy ISA stuff (floppy, parallel port, older sound cards, etc)..
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.