Message-Id: <199911011050.SAA01756@eastgate.cyberway.com.sg> From: "Rob Kramer" To: djgpp AT delorie DOT com Date: Mon, 1 Nov 1999 18:50:44 +0800 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: DMA despair. X-mailer: Pegasus Mail for Win32 (v3.01b) Reply-To: djgpp AT delorie DOT com Hi all, I'm trying to get DMA to work for a hardware MPEG decoder. A rather large buffer is needed (256k) to allow some slack in data feeding. The MPEG chip has it's own DMA controller that expects a 32bit physical address of the DMA buffer in one of its registers. Page boundaries are supposedly not a problem, all it requires is that bits 0 and 1 of the address are zero. Now I've tried just about everything, to no avail. I'm afraid I'm missing something completely trivial. I tried: - CR3 trick by Neil Jarvis (18-09-96), - XMS trick by Neil Jarvis (13-12-95), - DOS buffer with mapping to linear address space, - Plain DOS buffer. I'm not using swapping at all, cwsdpmi is configured to 0kb swap. For the cr3 trick I use cwsdpr0. For the easiest method (DOS buffer), I've go the following code: ulong dma::allocateBuffer (ulong size) { ulong pages = (size / 0x1000) + 2; ulong paragraphs = pages * (0x1000 / 0x10); ulong paddress; _go32_dpmi_seginfo seginfo; /* Size must be page aligned */ if (size & 0xfff) return 0; if (allocated) freeBuffer(); seginfo.size = paragraphs; if (_go32_dpmi_allocate_dos_memory (&seginfo) != -1) { paddress = seginfo.rm_segment << 4; return paddress; } return 0; } After that, I use the buffer with dosmemput(), and give 'paddress' to the MPEG DMA controller. I take it I can completely ignore the selector returned in seginfo.pm_selector? Can anyone see something wrong with this? My hardware totally ignores whatever I copy into the buffer. Physical address equals linear address in this case, right? Thanks, Rob Kramer robk AT cyberway DOT com DOT sg