From owner-freebsd-hackers@FreeBSD.ORG Tue Jul 11 21:34:07 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org 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 7B8DF16A4DA; Tue, 11 Jul 2006 21:34:07 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1227C43D58; Tue, 11 Jul 2006 21:34:02 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.4/8.13.4) with ESMTP id k6BLTPPK047248; Tue, 11 Jul 2006 15:29:26 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Tue, 11 Jul 2006 15:29:34 -0600 (MDT) Message-Id: <20060711.152934.-894584780.imp@bsdimp.com> To: jhb@freebsd.org From: "M. Warner Losh" In-Reply-To: <200607111550.00346.jhb@freebsd.org> References: <200607111413.37238.jhb@freebsd.org> <1152645913.31340@origin.intron.ac> <200607111550.00346.jhb@freebsd.org> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Tue, 11 Jul 2006 15:29:26 -0600 (MDT) Cc: freebsd-hackers@freebsd.org, mag@intron.ac Subject: Re: kern/99979: Get Ready for Kernel Module in C++ X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jul 2006 21:34:07 -0000 In message: <200607111550.00346.jhb@freebsd.org> John Baldwin writes: : On Tuesday 11 July 2006 15:21, mag@intron.ac wrote: : > John Baldwin wrote: : > : > > On Tuesday 11 July 2006 12:33, M. Warner Losh wrote: : > >> In message: <200607111115.59844.jhb@freebsd.org> : > >> John Baldwin writes: : > >> : and OS X both of which I've written a PCI driver for) we require device : > >> : driver writers to go through a lot more hoops to do certain things like : > >> : allocate resources. At the very least there is much that can be : improved : > > in : > >> : our driver model. : > >> : > >> bus_alloc_resources goes a long ways in this respect. : > > : > > Yes, but in OS X I didn't even have to do that. All I had to do was ask : it to : > > map a BAR if I wanted to use it. It already "allocated" all the resources : > > regardless. Windows was the same way (though a bit weirder, you get a : > > message that lists all your resources and you have to map them if you want : to : > > use them). : > > : > > -- : > > John Baldwin : > : > Do you mean that the kernel pre-allocate resources for all devices whether : > a device has been attached by a device driver? : > Does BIOS do the same thing before OS boots? : : Maybe (kernel can allocate it once probe has succeeded perhaps, or just always : do it) and Yes (if PNP OS is set to No, that is what PNP OS means, is if the : OS is smart enough to alloc the resources on its own). For FreeBSD, the kernel pre-allocates all resources that the BIOS allocated in the pci bus. We then give them out to the driver as the driver requests them. If the driver requests a resource that hasn't been pre-allocated, FreeBSD will attempt to allocate then and there that resource, and if successful return it. Generally, PnPOS == no means 'allocate everything you possibly can for these devices' while PnPOS == yes means 'allocate just enough to boot and leave the rest to the OS'. FreeBSD copes with both settings, as well as really old BIOSes that always allocated and new ones where you can't set PnPOS to "no". Warner