cvs commit: src/sys/dev/pci vga_pci.c
John Baldwin
jhb at freebsd.org
Wed Dec 21 07:35:29 PST 2005
On Tuesday 20 December 2005 05:47 pm, Nate Lawson wrote:
> John Baldwin wrote:
> > jhb 2005-12-20 22:41:33 UTC
> >
> > FreeBSD src repository
> >
> > Added files:
> > sys/dev/pci vga_pci.c
> > Log:
> > Add a vgapci(4) stub device driver for VGA PCI devices. This device
> > serves as a bus so that other drivers such as drm(4), acpi_video(4), and
> > agp(4) can attach to it thus allowing multiple drivers for the same
> > device. It also removes the need for the drmsub hack for the
> > i8[13]0/i915 drm and agp drivers.
> >
> > Revision Changes Path
> > 1.3 +262 -0 src/sys/dev/pci/vga_pci.c (new)
>
> All the methods seem to just be a straight-through mapping or a debug
> print + mapping. For the ones you don't plan to do anything special in,
> can you just make the methods map directly to the generic versions?
The ones that do map, yes. I was mostly paranoid to see if functions whose
stubs weren't really right were getting called or not. There is room for
cleaning.
> > +static int
> > +vga_pci_suspend(device_t dev)
> > +{
> > +
> > + return (bus_generic_suspend(dev));
> > +}
> > +
> > +static int
> > +vga_pci_resume(device_t dev)
> > +{
> > +
> > + return (bus_generic_resume(dev));
> > +}
These are generics and could just use bus_generic_foo().
> > +
> > +/* Bus interface. */
> > +
> > +static int
> > +vga_pci_read_ivar(device_t dev, device_t child, int which, uintptr_t
> > *result) +{
> > +
> > + return (BUS_READ_IVAR(device_get_parent(dev), dev, which, result));
> > +}
> > +
> > +static int
> > +vga_pci_write_ivar(device_t dev, device_t child, int which, uintptr_t
> > value) +{
> > +
> > + return (EINVAL);
> > +}
These are not generics. The generic would pass child as the second arg rather
than dev.
> > +static struct resource *
> > +vga_pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
> > + u_long start, u_long end, u_long count, u_int flags)
> > +{
> > +
> > + return (bus_alloc_resource(dev, type, rid, start, end, count, flags));
> > +}
> > +
> > +static int
> > +vga_pci_release_resource(device_t dev, device_t child, int type, int
> > rid, + struct resource *r)
> > +{
> > +
> > + return (bus_release_resource(dev, type, rid, r));
> > +}
Same with these two.
> > +
> > +/* PCI interface. */
> > +
> > +static uint32_t
> > +vga_pci_read_config(device_t dev, device_t child, int reg, int width)
> > +{
> > +
> > + return (pci_read_config(dev, reg, width));
> > +}
> > +
> > +static void
> > +vga_pci_write_config(device_t dev, device_t child, int reg,
> > + uint32_t val, int width)
> > +{
> > +
> > + pci_write_config(dev, reg, val, width);
> > +}
And all of the PCI ones including these and the others you quoted. The
different is subtle, but important.
--
John Baldwin <jhb at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
More information about the cvs-src
mailing list