From owner-freebsd-hackers@FreeBSD.ORG Thu May 20 03:17:32 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3344B16A4CE; Thu, 20 May 2004 03:17:32 -0700 (PDT) Received: from arginine.spc.org (arginine.spc.org [195.206.69.236]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0107043D1F; Thu, 20 May 2004 03:17:32 -0700 (PDT) (envelope-from bms@spc.org) Received: from localhost (localhost [127.0.0.1]) by arginine.spc.org (Postfix) with ESMTP id DA4D6653DF; Thu, 20 May 2004 11:17:22 +0100 (BST) Received: from arginine.spc.org ([127.0.0.1]) by localhost (arginine.spc.org [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 99984-05-6; Thu, 20 May 2004 11:17:22 +0100 (BST) Received: from empiric.dek.spc.org (82-147-17-88.dsl.uk.rapidplay.com [82.147.17.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by arginine.spc.org (Postfix) with ESMTP id 1956B653D2; Thu, 20 May 2004 11:17:22 +0100 (BST) Received: by empiric.dek.spc.org (Postfix, from userid 1001) id 5A2E2612E; Thu, 20 May 2004 11:17:21 +0100 (BST) Date: Thu, 20 May 2004 11:17:21 +0100 From: Bruce M Simpson To: Steve Watt Message-ID: <20040520101721.GB30196@empiric.dek.spc.org> References: <20040519122907.GO81341@elvis.mu.org> <200405192229.i4JMT95J087312@wattres.Watt.COM> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200405192229.i4JMT95J087312@wattres.Watt.COM> cc: hackers@freebsd.org cc: pjd@freebsd.org Subject: Re: api for sharing memory from kernel to userspace? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2004 10:17:32 -0000 On Wed, May 19, 2004 at 03:29:09PM -0700, Steve Watt wrote: > >On Wed, May 19, 2004 at 05:29:07AM -0700, Alfred Perlstein wrote: > >+> I need to share about 100megs of memory between kernel and userspace. > >+> > >+> The memory can not be paged and should appear contig in the process's > >+> address space. Any suggestions? > >+> > > The way we accomplished this in some other operating system was to > create a shared memory segment with an implementation-reserved > name, and then have the application shm_open the name and mmap it in. > > Shouldn't be hard with a device driver. This sounds like the way to go. The way I achieved this with a PCMCIA memory card was to kmem_alloc_nofault() a range and then pmap_map() it, then handle mmap() as per the regular character device case. Do bear in mind that 100 megs is quite large in relative terms, so it's possible that kmem_alloc_nofault() would fail. Regards, BMS