Invoking the device driver
Hi
I have written a non-STREAMS character device driver for Solaris...It passes the 'modload', 'modinfo' and 'modunload' test successfully.....
Now, I have the xxopen(), xxclose(), xxattach(), xxdetach() entry points in my driver.. I am also using the ddi_create_minor_node() function in my xxattach() routine but I do not see any device node being created in /devices.
I am trying to write a sample application which will invoke open(2) and close(2) system calls... What is the path that I provide to the open(2) system call for oepning the file.. also, exactly when will the device node get created in the /devices directory.
also, how can my user-land application invoke the xxattach() routine of the driver ?
Awaiting urgent replies..
-Kaushik
# 1
Hello.
Loading a driver from the "userland" would be something very useful but it does not work.
The driver must be installed using "add_drv". Then some hardware identifier must be assigned to the driver. If the hardware is detected Solaris will automatically load the driver and pass hardware information (such as address and interrupt number) to the attach() routine.
If you wrote a driver for a "virtual device" (such as ram disks, ...) you must write a driver.conf file. Name this file xxxx.conf (xxxx = Name of the driver) and place it into /kernel/drv (or /usr/kernel/drv ...) but NOT into a machine-dependent directory like /kernel/drv/sparcv9 or /kernel/drv/amd64. In the .conf file add the following line:
name="xxxx" parent="pseudo" instance=0;
This means: There is a device (#0) on the "pseudo" bus (a dummy bus for all virtual devices) handled by the xxxx driver.
Then type "update_drv xxxx".
Martin
# 2
Thanks a lot.... My driver is for a physical device, and hence is not a pseudo driver.
somebody told me that for a device driver meant for a real, physical device, I need to supply a set of PCI IDs the driver should bind to.... Can you tell me where to specify these PCI IDs and how do I get to know more about them ? (Basically, I want to know the process of creation of device nodes under /devices directory and symlinks in the /dev directory for 'real hardware' drivers and not pseudo drivers)
Also, upon copying my driver to /usr/kernel/drv and issuing 'add_drv' results in the following message
"Driver (vmci) successfully added to the system but failed to attach"
Running "dmesg | tail" tells me that only the _init() routine was called when I issued "add_drv" command......
I then tried commenting the entire block of code inside xxattach() but it still gives me the same error upon issuing "add_drv".. Is it because I need a .conf file (containing the PCI IDs) before my driver is able to attach to the device ?
# 3
... and 'add_drv' says '... but failed to attach the driver'.
Hello again.
You may use the "-i" option in add_drv or modify /etc/driver_aliases manually. The device id for a PCI device is "pciVVVV,DDDD" while VVVV is the PCI vendor ID (hexadecimal, lowercase, no leading zeroes) and DDDD is the PCI device ID (in the same format).
After a re-boot or an "update_drv" Solaris will load the driver automatically and call the "attach()" routine as soon as it detects the PCI device.
Martin