The following applies to 2.1, 2.0 is basically similar, but the syntax
differs somewhat.
1) check for PCI: pci_present ()
2) find your device: struct pci_dev* pdev = pci_find_device (VENDOR_ID, DEV_ID, pdev)
Now you have access to the PCI config space of the device.
Use the info provided in it, especially:
3) get IRQ, IOSpace and MemRegions from the PCI config space
3a) enable busmastering (DMA), if necessary: pci_set_master (pdev)
4) register iospace: check_region (addr, ln); request_region (addr, ln, "NAME")
5) register IRQ handler: request_irq (irq, handler, SA_SHIRQ, "NAME", NULL)
handler is void handler (int irq, void* dev_id, struct pt_regs *regs);
6) You can access your device via IOPorts (inb,inw,inl/outb,outw,outl) or
via the memory mapped space. Use virt_to_bus () and bus_to_virt () to
translate addresses for busmastering memory accesses.
7) It's a good idea to protect your IRQ handler and the driver's data
structures by a spinlock. (2.1 only)
8) Design a user interface for it, if the kernel not already has one for
your device class.
Read kernel sources (drivers, include files) to get an idea on how this is
done in reality. Get PCI doc or read /usr/src/linux/include/linux/pci.h.
-- Kurt Garloff, Dortmund <K.Garloff@ping.de> PGP key on http://student.physik.uni-dortmund.de/homepages/garloff- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html