0

I'm having a problem with a parallel connection I've got to establish using DMA (Direct Acces Memory).

I've got to write some characters to a parallel port with a given address, through a C application. I know that for a PIO access, there are the _inp/_outp functions, but I don't know how to manage a direct memory access parallel communication.

Does anyone know how I should do or has any good links (I couldn't find any even after long research on the Web

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
watiss
  • 111
  • 1
  • 6

1 Answers1

2

This is not something that can be answered generically.

DMA access is determined by either a DMA controller (in OLD PC's), or using "bus mastering" (PCI onwards). Either of these solutions requires access to the relevant hardware manuals for the device that you are working with (and the DMA controller, if applicable).

In general, the principle works as this:

  1. Reserve a piece of memory (DMA buffer) for the device to store data in.
  2. Configure the device to store the data in said region (remember that in nearly all cases, DMA happens on physical addresses, as opposed to the virtual addresses that Windows or Linux uses).
  3. When the device has stored the requested data, an interrupt is fired, the software responsible for the device takes the interrupt and signals some higher level software that the data is ready, and (perhaps) reprograms the device to start storing data again (either after copying the DMA buffer to someplace else, or assigning a new DMA buffer).
Mats Petersson
  • 126,704
  • 14
  • 140
  • 227
  • Thank you for your answer. In fact, being really new to all these terms, I have been reading quite a lot of things about memory management and memory access lately. It is a little bit more clear for me now but in a theoretical sense only... Basically, I want to write stuff in adress 0x80000000 which is normally allocated for the OS (in Win) so forbidden to user. So,I'm trying to map memory to a file in which I will then write my characters. The thing is:the prototype of the CreatFileMapping funtion deals with datatypes I'd never seen before such as HANDLE,DWORD,so it's a bit tough :s – watiss Aug 09 '13 at 13:24
  • You will need to write a driver... Which is not trivial, and dealing with DMA in a driver makes for a bit of extra knowledge & coding. – Mats Petersson Aug 09 '13 at 13:27