Resources and ACPI

Alan Garfield alan at fromorbit.com
Thu Apr 12 03:03:12 UTC 2007


On Wed, 2007-04-11 at 11:40 -0500, Craig Boston wrote:

> Looking back at the thread I see that you're porting a Linux driver,
> that explains a lot of the confusion.  It's been a while since I've
> worked with the Linux kernel in depth, but I seem to remember that a lot
> of drivers (especially machine-specific ones) would get the resource
> directly, e.g. IO port base address, and then do stuff like
> 
> outb(base_addr + offset, value);
> value = inb(base_addr + offset);
> 
> or write to mapped memory directly by constructing a pointer to the
> address.

Indeed mapped memory is how this is driver is written.

> While doing this is possible in FreeBSD, it's discouraged as the
> bus_space API tends to make for cleaner code and is also more portable.
> On architectures with peculiar alignment requirements, or other
> restrictions (DMA buffers having to be below a particular address comes
> to mind, or bounce buffers for PAE), the OS will take care of most of
> the nitty gritty details for you and allow the driver to contain
> higher-level code.

Yes bus_space seems much nicer, and very useful I'm sure for platform
independence.

Cheers,
Alan.




More information about the freebsd-hackers mailing list