plan 9 kernel history: overview | file list | diff list

1993/0915/pc/dma.c (diff list | history)

1992/1013/sys/src/9/pc/dma.c:33,391993/0915/sys/src/9/pc/dma.c:33,39 (short | long | prev | next)
1991/0803    
 */ 
struct DMAxfer 
{ 
	Page	*pg;		/* page used by dma */ 
1993/0915    
	Page	pg;		/* page used by dma */ 
1991/0803    
	void	*va;		/* virtual address destination/src */ 
	long	len;		/* bytes to be transferred */ 
	int	isread; 
1992/1013/sys/src/9/pc/dma.c:79,841993/0915/sys/src/9/pc/dma.c:79,105
1991/0803    
}; 
 
/* 
1993/0915    
 *  DMA must be in the first 16 meg.  This gets called early by main() to 
 *  ensure that. 
 */ 
void 
dmainit(void) 
{ 
	int i, chan; 
	DMA *dp; 
	DMAxfer *xp; 
 
	for(i = 0; i < 2; i++){ 
		dp = &dma[i]; 
		for(chan = 0; chan < 4; chan++){ 
			xp = &dp->x[chan]; 
			xp->pg.pa = (ulong)xspanalloc(BY2PG, BY2PG, 0); 
			xp->pg.va = KZERO|xp->pg.pa; 
		} 
	} 
} 
 
/* 
1991/0803    
 *  setup a dma transfer.  if the destination is not in kernel 
 *  memory, allocate a page for the transfer. 
 * 
1992/1013/sys/src/9/pc/dma.c:101,1221993/0915/sys/src/9/pc/dma.c:122,142
1991/0803    
	xp = &dp->x[chan]; 
 
	/* 
	 *  if this isn't kernel memory (or crossing 64k boundary), 
	 *  allocate a page for the DMA. 
1993/0915    
	 *  if this isn't kernel memory or crossing 64k boundary or above 16 meg 
	 *  use the allocated low memory page. 
1991/0803    
	 */ 
	pa = ((ulong)va) & ~KZERO; 
1993/0915    
	pa = PADDR(va); 
1992/1013    
	if((((ulong)va)&0xF0000000) != KZERO 
	|| (pa&0xFFFF0000) != ((pa+len)&0xFFFF0000)){ 
1991/0925    
		if(xp->pg == 0) 
			xp->pg = newpage(1, 0, 0); 
1993/0915    
	|| (pa&0xFFFF0000) != ((pa+len)&0xFFFF0000) 
	|| pa > 16*MB){ 
1991/0803    
		if(len > BY2PG) 
			len = BY2PG; 
		if(!isread) 
			memmove((void*)(KZERO|xp->pg->pa), va, len); 
1993/0915    
			memmove((void*)(xp->pg.va), va, len); 
1991/0803    
		xp->va = va; 
		xp->len = len; 
		xp->isread = isread; 
		pa = xp->pg->pa; 
1993/0915    
		pa = xp->pg.pa; 
1991/0925    
	} else 
		xp->len = 0; 
1991/0803    
 
1992/1013/sys/src/9/pc/dma.c:168,1731993/0915/sys/src/9/pc/dma.c:188,193
1991/0803    
	/* 
	 *  copy out of temporary page 
	 */ 
	memmove(xp->va, (void*)(KZERO|xp->pg->pa), xp->len); 
1993/0915    
	memmove(xp->va, (void*)(xp->pg.va), xp->len); 
1991/0925    
	xp->len = 0; 
1991/0803    
} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)