News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Memory to memory copy with DMA

Started by korte, January 31, 2009, 02:05:55 PM

Previous topic - Next topic

korte


Memory to memory copy with DMA.
Possible?


MichaelW

I think it should be possible, but I have never bothered to test it. I have read that for the original hardware the transfer rate was much lower than what could be done with the CPU. The diskette drive used DMA, but for the first hard drives IBM chose to use Programmed I/O where the data was transferred by the CPU between a 16-bit I/O port and memory. I think DMA has gotten much faster in recent times, but then so have the CPUs.
eschew obfuscation

Tedd

The old ISA DMA chips did have a memory-to-memory transfer mode, though I seem to remember reading somewhere that it was physically impossible on a PC due to the way it's connected in (and some other features were also disabled by this.)
Of course, that might be wrong, but I've never tried it, and I haven't seen any code doing it.
No snowflake in an avalanche feels responsible.

korte

ok.

But.

what a best way video memory to video memory copy (than BitBlt).

Dos FlatReal mode.

hardware bitblt?
Vesa?




Tedd

Use a hardware bitblt where available - the video card/chips will use their best method.
I think even 'old' VGA cards have this capability.
No snowflake in an avalanche feels responsible.

MichaelW

AFAIK there is nothing resembling a hardware bitblt function for the VGA. The EGA/VGA had a 32-bit internal bus that could be used effectively to move data from one display memory location to another, but the feature was not generally useful for animation because it was restricted to moving byte-aligned data (as opposed to pixel-aligned data). The later SVGA adapters supported a hardware linear framebuffer that allowed the entire display buffer to be mapped into the host address space, accessible from 32-bit protected mode. I think the hardware bitblt capability for the SVGA and later is controller specific.
eschew obfuscation

Tedd

Yeah, that was it, there's a byte-aligned-copy write mode - so not quite bitblt, but could still be useful depending on your video mode and what/why you want to copy.
Then SVGA made everything interesting (read: device dependent) - which is partly what the VESA extensions were meant to solve..



korte:
Assuming you want a software method (no bitblt) to copy memory into the vga framebuffer, it gets complicated if you want to copy sections (not the whole screen) because of the way video memory is set out. If you do want it just for a full screen at a time, and you can assume the memory to be copied is linear and in the correct order, then you can do a simple "rep movsd" (or unroll it a bit to copy 2 dwords each loop.)
No snowflake in an avalanche feels responsible.

MichaelW

korte,

Of the VGA graphics modes, 13h is the easiest to use. It has a resolution of only 320x200, but it supports 256 simultaneous colors and has a very easy programming model. The VGA hardware handles the display planes internally, so from the point of view of the programmer the display buffer is a linear array of bytes were each byte specifies the color of one pixel. And because only 320*200=64000 bytes are required, the entire array can be mapped into the host (real mode) address space, and the CPU can access it at whatever speed the bus and adapter hardware will allow. The SVGA packed pixel modes work in a similar way, except with hardware linear framebuffer support and protected mode the larger available address space allows much higher resolutions.
eschew obfuscation

FORTRANS

Quote from: Tedd on January 31, 2009, 05:16:52 PM
The old ISA DMA chips did have a memory-to-memory transfer mode, though I seem to remember reading somewhere that it was physically impossible on a PC due to the way it's connected in (and some other features were also disabled by this.)
Of course, that might be wrong, but I've never tried it, and I haven't seen any code doing it.

HI,

   Checking in "The Undocumented PC", he says memory to memory
DMA is possible.  He then goes on to say that there can be problems,
limitations, and that the CPU can do the copy faster than the DMA
hardware anyway (MOVSD on 386+).

   So it seems to be a yes you can, but who cares, kind of thing.

Regards,

Steve N.

daydreamer

you can successfully make use of MMX even in realmode, I have done it
if its videoram, VESA works different, you switch pages, you can scroll with changing videopointer, dont know if there is undocumented functions to blit, but probably should be on all videocards that directx shows support hardware blitting, but I think that requires RE drivers to find those functions