kern/99979: Get Ready for Kernel Module in C++

M. Warner Losh imp at bsdimp.com
Tue Jul 11 21:34:07 UTC 2006


In message: <200607111550.00346.jhb at freebsd.org>
            John Baldwin <jhb at freebsd.org> writes:
: On Tuesday 11 July 2006 15:21, mag at intron.ac wrote:
: > John Baldwin wrote:
: > 
: > > On Tuesday 11 July 2006 12:33, M. Warner Losh wrote:
: > >> In message: <200607111115.59844.jhb at freebsd.org>
: > >>             John Baldwin <jhb at freebsd.org> 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


More information about the freebsd-hackers mailing list