Subject: Re: allocating physical memory
To: None <M.Drochner@fz-juelich.de>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-kern
Date: 07/20/1999 10:12:24
On Tue, 20 Jul 1999 11:11:52 +0200 
 Matthias Drochner <drochner@zel459.zel.kfa-juelich.de> wrote:

 > Here is what my experimental pnpbios code does:
 > 
 > static caddr_t
 > mapit(addr, len, prot)
 > 	u_long addr, len;
 > 	int prot;
 > {
 > 	u_long startpa, pa, endpa;
 > 	vaddr_t startva, va;
 > 
 > 	pa = startpa = i386_trunc_page(addr);
 > 	endpa = i386_round_page(addr + len);
 > 
 > 	va = startva = uvm_km_valloc(kernel_map, endpa - startpa);
 > 	if (!startva)
 > 		return (0);
 > 	for (; pa < endpa; pa += NBPG, va += NBPG)
 > 		pmap_kenter_pa(va, pa, prot);
 > 
 > 	return ((caddr_t)(startva + (addr - startpa)));
 > }

On the i386 port, you can also use the machine-dependent function
_i386_memio_map(), like the apm code does:

	if (_i386_memio_map(I386_BUS_SPACE_MEM,
	    apminfo.apm_data_seg_base,
	    apminfo.apm_data_seg_len, 0, &memh)) {
		printf("couldn't map data segment");
		goto bail;
	}

        -- Jason R. Thorpe <thorpej@nas.nasa.gov>