6/9/2000- This is a device driver for the EDF Link Receiver Board (PC-MIP card). This is very preliminary and seems to work, but "Caveat Downloader"! Contact with any comments/questions. Files in this archive: 2522 2000-05-31 11:52 lrb.h Header file 9505 2000-06-06 13:17 lrb.c driver source code 665 2000-06-06 13:17 Makefile yes 1686 2000-06-09 09:37 driver_demo.c demo program Requirements: Linux 2.2 or later kernel on Intel (only tested with stock RedHat 6.0 kernel v2.2.5-15) Some PCI device with no more than one BAR (base address register) which must be in memory. Currently set up for LRB. What works: Access to configuration space and one BAR0 address of 4 bytes. Only one card is currently supported. Configuration space can be accessed by setting the file pointer (using lseek()) to a value 0-255. Byte, word and dword accesses are supported (only). The BAR0 address is accessed by setting the file pointer to 256. There is also untested code to access configuration space using ioctls, which works as follows: ioctl( fd, addr | LRB_IOC_WRITE | LRB_IOC_BYTE, (long)&data); This will write one byte to config address "addr". (see lrb.h for LRB_IOC_xxxx symbols); To Do: Support access to BAR0 area bigger than 4 bytes! Requires changing: lrb_bar0 = ioremap_nocache( bar0, 4); Support for more than one card of a type. Make ioctl() the primary way of accessing configuration space, get rid of the current kludge of using addresses 0-255 for config. Installation: cd tar -xzvf Make lrb.o # compile, can be done as normal user Make devices # do ONCE as root to make files in /dev Make install # to copy lrb.o (driver) to system modules directory # (this is not necessary) insmod ./lrb.o # as root to install device driver... needed # once after reboot make driver_demo # compile ./driver_demo # and run demo program Debugging: 1. "more /proc/pci" for a list of PCI devices. Try to find your card by it's Vendor and Device ID. Here is the entry for the LRB on our system: Bus 1, device 4, function 0: RAM memory: Unknown vendor Unknown device (rev 1). Vendor id=55. Device id=1. Fast devsel. Non-prefetchable 32 bit memory at 0xdd000000 [0xdd000000]. 2. Check that the device file is correct (after doing "make devices") # ls -l /dev/lrb* crw-rw-rw- 1 root root 242, 0 Jun 4 06:20 /dev/lrb0 3. "/sbin/lsmod" to be sure the device driver is installed. (after doing "insmod ./lrb.o" as root) Here is the beginning of the list on our system with lrb.o installed: Module Size Used by lrb 1476 0 (unused) 4. "cat /proc/devices" to check for the installed driver: Character devices: 1 mem 2 pty 3 ttyp 4 ttyS 5 cua 7 vcs 10 misc 29 fb 36 netlink 128 ptm 136 pts 242 lrb <----------- here is the lrb Note that I have somewhat arbitrarily chosen major# 242 for the lrb. If there is some other device claiming this number (check the list before installing lrb.o) then you will have to change LRB_MAJOR in lrb.h and re-make everything. 5. Compile and run the demo program: make driver_demo ./driver_demo If you get: # ./driver_demo VENDOR ID = 0x0055 DEVICE ID = 0x0001 Read rc=4 data= 0x00000000 Error Reading 2 bytes from PCI: Input/output error Read rc=-1 data= 0x00000000 Then everything is working! If you get: Error Opening PCI device: No such file or directory Then the device driver isn't there... try the above steps. You can also uncomment the line: # DEBUG=-DLRB_DEBUG In the Makefile and re-compile the driver. This will put lots of debugging output into the syslog stream (you can normally access this in real time by typing "tail -f /var/log/messages" as root)