From owner-freebsd-hackers Fri Aug 1 14:18:50 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id OAA12874 for hackers-outgoing; Fri, 1 Aug 1997 14:18:50 -0700 (PDT) Received: from dyson.iquest.net (dyson.iquest.net [198.70.144.127]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id OAA12868 for ; Fri, 1 Aug 1997 14:18:45 -0700 (PDT) Received: (from root@localhost) by dyson.iquest.net (8.8.6/8.8.5) id QAA05888; Fri, 1 Aug 1997 16:18:33 -0500 (EST) From: "John S. Dyson" Message-Id: <199708012118.QAA05888@dyson.iquest.net> Subject: Re: Kernel howto, Second Request In-Reply-To: from Simon Shapiro at "Aug 1, 97 01:00:25 pm" To: Shimon@i-connect.net (Simon Shapiro) Date: Fri, 1 Aug 1997 16:18:33 -0500 (EST) Cc: FreeBSD-Hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > 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