1
votes

Let's assume that i have PCI device plugged to linux host.

In system that device is seen in sys pseudofs and i have:

/sys/bus/pci/devices/0001:03:00.0/resource0

file used for userspace access to pci memory bar0 of the device.

My question is what is the byte endiannes of this memory (little/big)?

1
Also see Userspace access to PCI memory. I think the answer is, "it depends...".jww
Never ever allow user to touch your PCI device's registers.0andriy

1 Answers

0
votes

As per this answer[1], mmap-ing the resource file ends up at pci_mmap_page_range which will make the resource visible with the byte order of the device, normally little endian for PCI. So if your architecture byte order is different you will need to swap bytes. The kernel ioread* and iowrite*, respectively ioread*be and iowrite*be do reads and writes in little and big endian respectively on all architectures, so for example ioread32 byte swaps on a big endian architecture and does not on a little endian. In user space you would have to handle this yourself.

[1] https://stackoverflow.com/a/20299743/213180