Communicating with PCI device

Hi guys. I am trying to communicate with a PCI device from within my C++ application, however I am having a nightmare with all this Kernel space and user space jargon and am getting my self confused.

I was led to believe that to communicate with a PCI device you use the functions available in "linux/pci.h". However this header file has the following wrapped around some of the basic functions I need:

1
2
3
4
5
#ifdef __KERNEL__

<code i need to use>

#endif 


However according to some research the __KERNEL__ macro is only enabled when executing in "kernel space", and since my program is in "user space" this will not compile because it cannot see the functions that I require.

The main function I am trying to access is one called "get_pci_device()" in order to obtain a 'PCI_DEV' structure that contains a pointer to the PCI devices base address. This (in theory) would let me start writing to the device PORTS in order to communicate with the device using the functions "outb()" and "outw()"... etc.

This is driving me mental and to me everything just seems overly complicated, and I would really appreciate some reasoning, advice and guidence from you lovely people.

regards.
Last edited on
User space programs communicate to hardware through kernel device drivers. Are you writing an application, a device driver, or both?
Topic archived. No new replies allowed.