I've been writing a user space driver for a proprietary ISA card for linux.I've used ioperm to give me access to the ports (using inw, outw) and mmap of /dev/mem to give me access to the memory.
This all works great if my ISA card is present.
But if it doesn't exist my code seg faults when I try to access the memory or ports which aren't there.
So my question is... how can I determine if the card exists or not without my code seg faulting?
Just use /dev/port for accesing the ports.
You can see port_fops in drivers/char/mem.c for details. The driver first checks if the port is accesible, and that is what you need ;)
A more friendly way to learn how /dev/port works should be reading section 2.2 of:
http://www.tldp.org/HOWTO/IO-Port-Programming.html
Cheers
Alfonso Acosta
-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/