I want to do I/O on my PCIe device.I am running Ubuntu 16.0.4 LTS with linux kernel 4.4.0
The output of lspci -v
command is:
06:00.0 Unclassified device [00ff]: Device 1aa1:2000 (rev 01)
Subsystem: Device 1aa1:2000
Physical Slot: 1-4
Flags: bus master, fast devsel, latency 0, IRQ 16
Memory at f1008000 (32-bit, non-prefetchable) [size=8K]
Memory at ee000000 (32-bit, non-prefetchable) [size=32M]
Memory at f100a000 (32-bit, non-prefetchable) [size=4K]
Memory at f0000000 (32-bit, non-prefetchable) [size=16M]
Memory at f1000000 (32-bit, non-prefetchable) [size=32K]
Capabilities: <access denied>
Kernel driver in use: my_pci
Kernel modules: my_pci
Clearly, PCI addresses are 32-bit.
I want to know how to use ioread32/iowrite32 functions to read/write into the BAR addresses.
unsigned char __iomem *mem
types on my machine would be 64-bit and if I use the following say :
ioread32(mem + some_offset);
The expression mem + some_offset
would be 64-bit and result into crash.
How would I do the I/O ?