Forum Discussion
Altera_Forum
Honored Contributor
14 years agoUnlike USB, PCIe insertion/removal isn't handled well, but it is possible. Here's what I've seen done with a vendor X FPGA, which should behave similarly to Altera...
Linux has a system (kernel) routine pci_save_state which can save state of an already configured device. Once the state is saved, you can reconfigure the FPGA, or even unplug and replug it into PCIE, then use the pci_restore_state routine to restore the config registers and then call pci_enable_device to re-enable it. These routines would be called from a kernel module, and you would need /dev device file created to convey ioctl calls from a user app to the kernel module trigger the save and restore events. I'm afraid I can't show source code, but I suspect that similar code is probably available, maybe in the Linux Device Drivers book which O'Reilly allows you to read directly on their web site. This usage model presumes that the FPGA is programmed before Linux boots, so that the kernel does the required memory allocation at boot time (or maybe it uses the BIOS setup). I think that related routines may allow you to trigger setup for a newly inserted device, but we never explored that. \chuck