Add option -Bw that allows to write into a BAR region.
Add an option -BD, which does the same as -D (dumps a BAR region). However, the B makes it clearer that it operates on a BAR region.
Differential D55915
pciconf: Add option to write into a BAR region Authored by timo.voelker_fh-muenster.de on Wed, Mar 18, 1:34 PM. Tags None Referenced Files
Details Add option -Bw that allows to write into a BAR region. Add an option -BD, which does the same as -D (dumps a BAR region). However, the B makes it clearer that it operates on a BAR region. For example, a VirtIO PCI device % pciconf -lb pci0:0:10:0
virtio_pci0@pci0:0:10:0: class=0x020000 rev=0x00 hdr=0x00 vendor=0x1af4 device=0x1000 subvendor=0x1af4 subdevice=0x0001
bar [10] = type I/O Port, range 32, base 0, size 32, enabled
bar [18] = type Memory, range 32, base 0xe1852000, size 8192, enabledThe second 4 bytes of BAR 0x18 specifies the device's features based on the first 4 bytes. % sudo pciconf -BD pci0:0:10:0 0x18 0x0 2 | hexdump -C 00000000 01 00 00 00 01 00 00 00 |........| By writing a 0 in the first 4 bytes the device changes the second 4 bytes. % sudo pciconf -Bw pci0:0:10:0 0x18 0 0 % sudo pciconf -BD pci0:0:10:0 0x18 0x0 2 | hexdump -C 00000000 00 00 00 00 a3 dd 2f 00 |....../.|
Diff Detail
Event TimelineComment Actions I think rather than trying to overload -B, it would be better to just use a different getopt() letter for this mode. I would suggest using -R for reading from a BAR but keep 'D' as an alias for backwards compatibility, and using -W for writing into a BAR. Comment Actions You only write a single value into the specified offset, right? Comment Actions I thought about that too but decided against it because:
After I saw that -b is already overloaded, I decided to use -B. As a compromise, I could add a -W and leave the rest as it is (no -R). What do you think? Comment Actions In my use case, I only had to write a single value. Do you know use cases where a series of values needs to be written to a BAR region? I tried to make it similar to -w (write to config space). This is the man page part about -w:
Do you find this more clear? If so, I could try to write the part of -Bw more like that. If not, we should change that too. Comment Actions Yes
A selector is the device specification, basically 'pci:b:f:d' for pciconf. Comment Actions OK. This is the synopsis: pciconf -Bw [-b | -h | -x] device bar offset value and this is the current text:
How about this?
OK, my question was misleading. I mean, why is selector underlined? It is not a pciconf argument. The name of the argument it refers to is device. Shouldn't end the sentence like that:
Comment Actions Ok
I think this was some kind of typo. There are several instances of it in the man page. I suggest providing a preparational patch that would fix this first. |