Date: Sat, 11 Mar 2000 11:42:55 +0100 From: Jeroen Ruigrok/Asmodai <asmodai@wxs.nl> To: new-bus@freebsd.org Subject: Abstraction API for drivers Message-ID: <20000311114255.T68308@daemon.ninth-circle.org>
next in thread | raw e-mail | index | archive | help
[Matthew, please feel free to correct me] Hi guys, after Matthew Dodd and me discussed some abstracting the access to the newbus functionality with Poul-Henning Kamp. Basically what phk said was that we were repeating lots of code in our PCI drivers. Matthew and me agreed on that aspect, but were concerned about making the abstraction PCI only. If such an API would be created, it should be a complete solution. Basically one of the things that will repeat itself a lot in PCI drivers is: static int xl_probe(dev) device_t dev; { struct xl_type *t; t = xl_devs; while(t->xl_name != NULL) { if ((pci_get_vendor(dev) == t->xl_vid) && (pci_get_device(dev) == t->xl_did)) { device_set_desc(dev, t->xl_name); return(0); } t++; } return(ENXIO); } In the probe case of a driver we will always have some sort of if statement like the above excellent xl driver example. We will always pci_get_[vendor|device](dev) and comparing it to the vendor/device id of the struct array of devices. After we find matches, we will always want to set the name with device_set_desc(dev, name). In the case for PCI devices this will create a very repeatable piece of code all along the drivers. Of course, given the total different way how, for example, ISA, EISA, S-BUS, and such work this might provide some difficulty creating a sufficient general API to allow for bus-independant abstraction. And creating functionwrappers just for bus specific cases might be the only solution, but if we can avoid it, it would be cool. =) Ideas, comments, suggestions? Also, Matthew explained he had some issues with rman (resource manager), but I'll let him explain that... -- Jeroen Ruigrok vd Werven/Asmodai asmodai@[wxs.nl|bart.nl|freebsd.org] Documentation nutter/C-rated Coder BSD: Technical excellence at its best The BSD Programmer's Documentation Project <http://home.wxs.nl/~asmodai> There is no greater sorrow than to recall, in misery, the time when we were happy... To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-new-bus" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000311114255.T68308>