Intel 386 Computer Hardware User Manual


 
12-55
DMA CONTROLLER
Description:
Sets the target memory address for the DMA channel specified
by nChannel.
Parameters:
nChannel --channel for which to set target address
ptMemory --pointer to target memory location
Returns:
None
Assumptions:
Processor is in real mode.
Syntax:
static char lpsz[]=”Hello World”;
SetDMATargMemAddr(DMA_Channel1, lpsz);
Real/Protected Mode:
The address calculation from ptMemory assumes the processor is in real
mode.
*****************************************************************************/
int SetDMATargMemAddr(int nChannel, void *ptMemory)
{
WORD addrDMATar0_1;
WORD addrDMATar2;
WORD addrDMATar3;
WORD wSegment;
WORD wOffset;
DWORD lAddress;
/*Check input*/
if ( (nChannel != DMA_Channel0) && (nChannel != DMA_Channel1) )
return ERR_BADINPUT;
/*Set registers to correct channel*/
addrDMATar0_1 = ( nChannel == DMA_Channel0 ? DMA0TAR0_1 : DMA1TAR0_1);
addrDMATar2 = ( nChannel == DMA_Channel0 ? DMA0TAR2 : DMA1TAR2);
addrDMATar3 = ( nChannel == DMA_Channel0 ? DMA0TAR3 : DMA1TAR3);
/*If in tiny, small, or medium model,*/
#if defined(M_I86TM) || defined(M_I86SM) || defined(M_I86MM)
_asm
{ /*...then grab our segment from DS*/
mov ax, ds
mov wSegment, ds
}
wOffset = (WORD) ptMemory; /*...and our offset from the pointer*/