Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Aug 1997 16:18:33 -0500 (EST)
From:      "John S. Dyson" <toor@dyson.iquest.net>
To:        Shimon@i-connect.net (Simon Shapiro)
Cc:        FreeBSD-Hackers@FreeBSD.ORG
Subject:   Re: Kernel howto, Second Request
Message-ID:  <199708012118.QAA05888@dyson.iquest.net>
In-Reply-To: <XFMail.970801130025.Shimon@i-Connect.Net> from Simon Shapiro at "Aug 1, 97 01:00:25 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> Next Question:  What is the equivalent of SysV physmap()?
>     Physmap takes a physical memory address and returns a virtual address.
> I am trying to access certain memory location only known by physical
> addresses.
> 

Unlike certain (broken) systems, FreeBSD doesn't map all of phys memory
by default.  This of course, saves address space for user processes, and
keeps physical memory size from being constrained by kernel space limitations.

	/* Map memory mapped device */

	va = kmem_alloc_pageable(kernel_map, size_in_bytes);

	for(indx = 0; indx < size_in_bytes; indx += PAGE_SIZE)
		pmap_kenter(va + indx, phys_addr + indx);



	/* do stuff here */


	/* Now, unmap, release resources */

	for(indx = 0; indx < size_in_bytes; indx += PAGE_SIZE)
		pmap_kremove(va + indx);

	kmem_free(kernel_map, va, size_in_bytes);


Notes:
	You cannot do this at interrupt time, but there is a way to do it.
	Kernel_map is a limited resource, but don't worry about allocations
	of even 10-20MB.
	If you are going to use the resource for a long time, then don't
	allocate/free repeatedly unless you have to.
	I might have made a mistake, so RTSL :-).

John

	



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199708012118.QAA05888>