Subject: Re: physically contiguous memory
To: None <p99dreyf@criens.u-psud.fr>
From: Marcus Comstedt <marcus@idonex.se>
List: tech-kern
Date: 03/26/2001 00:33:32
>>>>> "Emmanuel" == Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr> writes:

  Emmanuel> How do I allocate physically contiguous memory? I don't find anything
  Emmanuel> about this in malloc(9)...

You have to use uvm_pglistalloc().  Something like this:


int
alloc_physmem(size, pap)
	size_t size;
	paddr_t *pap;
{
	extern paddr_t avail_start, avail_end;	/* from pmap.c */

	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);

	return (0);
}


  // Marcus