Some Questions

M. Warner Losh imp at bsdimp.com
Tue Oct 18 08:12:56 PDT 2005


In message: <200510180826.j9I8Quw26871 at cal1-1.us4.outblaze.com>
            "Yong Ma" <mayong at mail.com> writes:

: 1)Some drivers declares the device_open() as int device_open(dev_t
: dev,...),and some declare it as int device_open(struct cdev
: *dev,...),sometimes the first one couldn't be
: compliedsuccessfully,what's the difference?

In 4.x, the former was used.  In 5.x and newer, the latter is used.
On 4.x you could get away with the latter because dev_t was typedefed
to be struct cdev *.


: 2) if (pci_get_vendor(dev) == 0x11c1) { ...
:                               ~~~~~~~~how to get this number if I don't know it?

(1) Ask the vendor of your device (2) Read the datasheet for your
device (3) pciconf -l :-)

: 3)Could the device on PCI slot be listed by /pciconf -l /without driver.

Yes.

: 4)The printf() seems not work under XWindow mode in functions like
: deviec_prob or device_attach,how to make it work?

It works.  However, the output is sent to the console.  Under X
windows, the console is normally hidden from you somewhere.  You can
get the last bit of console output, however, using the dmesg command.

: 5)If only the pseudo-device in /dev can be destroyed with
: destroy_dev(sc->dev0) in detach() function in a KLD driver? I can't
: do that!

I'm afraid I don't understand this question.  If you have, say, a
global control device for all instances of the driver, you can keep a
'reference count' of the number of instances attached and then delete
the device when the last one detaches.  If it is something else, then
I'll need more information.

Warner


More information about the freebsd-drivers mailing list