From owner-freebsd-hackers Fri Aug 1 17:41:14 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id RAA22315 for hackers-outgoing; Fri, 1 Aug 1997 17:41:14 -0700 (PDT) Received: from sendero-ppp.i-connect.net (sendero-ppp.i-Connect.Net [206.190.143.100]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id RAA22308 for ; Fri, 1 Aug 1997 17:41:12 -0700 (PDT) Received: (qmail 10478 invoked by uid 1000); 2 Aug 1997 00:41:27 -0000 Message-ID: X-Mailer: XFMail 1.2-alpha [p0] on FreeBSD Content-Type: text/plain; charset=iso-8859-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <199708012118.QAA05888@dyson.iquest.net> Date: Fri, 01 Aug 1997 17:41:27 -0700 (PDT) Organization: Atlas Telecom From: Simon Shapiro To: "John S. Dyson" Subject: Re: Kernel howto, Second Request Cc: FreeBSD-Hackers@FreeBSD.ORG Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk 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 > >