Skeleton / Example PCI Device Driver

Alexander Boettcher alexander.boettcher at genode-labs.com
Tue Dec 11 20:10:25 CET 2018


Hello,

On 08.12.18 23:05, John J. Karcher wrote:
> In my slow quest to port/write the VirtualBox Guest Additions, the first
> step is a driver for the virtual PCI device that handles communication
> with the VirtualBox host.
> 
> Is there a skeleton device driver for PCI devices?  My first goal is
> just the boilerplate init code, attaching to the IRQ and I/O memory, and
> logging the interrupts as they come in.
> 
> If there isn't a skeleton driver, could anyone recommend the simplest
> example that I could use as a starting point?

I would suggest look into [0] and [1], which is a very very basic test
to iterate over all available PCI devices and dumping some PCI
information ([3] or better look into the Genode Foundations Book). The
test may serve as a starting point.

Which devices are actually available/visible to a driver depend on the
configuration of the platform driver, which acts as an PCI guard. Please
look into [2] for configuration details.

When you have found/chosen your specific PCI device, you can invoke
several methods on a Platform::Device_client [4] object as used in the
test, which give you access to various PCI resources in form of
capabilities, like IRQ, IO-PORT or IO-MEM resources.

Please consult the Genode Foundations book for a basic introduction and
documentation - e.g. 3.4.7. Access to device resources, 4.1.1 device
drivers, 8.18. Utilities for user-level device drivers && 2.5.5
Responding to external events (for the IRQ handling)

Cheers,

Alex.

[0] repos/os/src/test/pci/test.cc
[1] repos/os/run/pci.run
[2] repos/os/src/drivers/platform/spec/x86/README
[3] repos/os/include/spec/x86/platform_session/client.h
[4] repos/os/include/spec/x86/platform_device/client.h
-- 
Alexander Boettcher
Genode Labs

https://www.genode-labs.com - https://www.genode.org

Genode Labs GmbH - Amtsgericht Dresden - HRB 28424 - Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth



More information about the users mailing list