Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 01 Aug 1997 17:41:27 -0700 (PDT)
From:      Simon Shapiro <Shimon@i-Connect.Net>
To:        "John S. Dyson" <toor@dyson.iquest.net>
Cc:        FreeBSD-Hackers@FreeBSD.ORG
Subject:   Re: Kernel howto, Second Request
Message-ID:  <XFMail.970801174127.Shimon@i-Connect.Net>
In-Reply-To: <199708012118.QAA05888@dyson.iquest.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanx a million!

Simon

Hi "John S. Dyson";  On 01-Aug-97 you wrote: 
> > 
> > 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?XFMail.970801174127.Shimon>