Subject: Re: DMA buffers
To: Marcus Comstedt <marcus@idonex.se>
From: Jason R Thorpe <thorpej@zembu.com>
List: port-dreamcast
Date: 01/19/2001 11:05:31
On Fri, Jan 19, 2001 at 07:55:46PM +0100, Marcus Comstedt wrote:

 > But any such "framework" should go into the SH3 core somewhere
 > (shb.c?), if it doesn't already exist there, right?  I'm not talking
 > about DMA services for maple bus _units_ (there is no such thing), but
 > only about getting some DMA memory space for the bus driver itself
 > (fixed size).

Well, some, maybe.  The SHB->PCI bridge may be Dreamcast-specific?  That
may require Dreamcast-specific bus_dma(9) routines.

Anyway, you would probably be served a little better for Maple right now
by just using uvm_pglistalloc() directly, which gives you a list of
vm_page structures.  Like so:

int
maple_alloc_dma(size_t size, vaddr_t *vap, paddr_t *pap)
{
	struct pglist mlist;
	vm_page_t m;
	int error;

	size = round_page(size);

	TAILQ_INIT(&mlist);
	error = uvm_pglistalloc(size, avail_start, avail_end - PAGE_SIZE,
	    0, 0, &mlist, 1, 0);
	if (error)
		return (error);

	m = TAILQ_FIRST(&mlist);
	*pap = VM_PAGE_TO_PHYS(m);
	*vap = SH3_PHYS_TO_P2SEG(VM_PAGE_TO_PHYS(m));

	return (0);
}

-- 
        -- Jason R. Thorpe <thorpej@zembu.com>