我正在尝试编写一个程序来在 linux 上转储选项/扩展 ROM。我已经有必要的 PCI 端口 IO 从偏移 0x30 处的 PCI 配置数据中获取扩展 ROM 的基地址并使其启用,但是当我尝试访问内存中的基时,我得到了段错误。因此,我试图了解当您从 linux 命令行执行“echo 1 > rom”时会发生什么,因为此后 rom 似乎很容易访问(有关更多上下文,请参见此处:http: //etherboot.org/维基/romdumping)
例如,假设我执行以下操作:
lspci
01:00.0 VGA 兼容控制器:ATI Technologies Inc RV370 5B60 [Radeon X300 (PCIE)]
cd /sys/bus/pci/devices/0000:01:00.0
lspci -x -v -s 01:00.0
01:00.0 VGA compatible controller: ATI Technologies Inc RV370 5B60 [Radeon X300 (PCIE)]
Subsystem: ATI Technologies Inc Device 0402
Flags: bus master, fast devsel, latency 0, IRQ 27
Memory at d0000000 (32-bit, prefetchable) [size=128M]
I/O ports at dc00 [size=256]
Memory at dfde0000 (32-bit, non-prefetchable) [size=64K]
Expansion ROM at dfe00000 [disabled] [size=128K]
Capabilities: [50] Power Management version 2
Capabilities: [58] Express Endpoint, MSI 00
Capabilities: [80] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable+
Capabilities: [100] Advanced Error Reporting <?>
Kernel driver in use: radeon
Kernel modules: radeonfb, radeon
00: 02 10 60 5b 07 04 10 00 00 00 00 03 10 00 80 00
10: 08 00 00 d0 01 dc 00 00 00 00 de df 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 02 10 02 04
30: 00 00 e0 df 50 00 00 00 00 00 00 00 0b 01 00 00
请注意“扩展 ROM at dfe00000 [disabled] [size=128K]”的行0xdfe00001,然后我得到
01:00.0 VGA compatible controller: ATI Technologies Inc RV370 5B60 [Radeon X300 (PCIE)]
Subsystem: ATI Technologies Inc Device 0402
Flags: bus master, fast devsel, latency 0, IRQ 27
Memory at d0000000 (32-bit, prefetchable) [size=128M]
I/O ports at dc00 [size=256]
Memory at dfde0000 (32-bit, non-prefetchable) [size=64K]
Expansion ROM at dfe00000 [size=128K]
Capabilities: [50] Power Management version 2
Capabilities: [58] Express Endpoint, MSI 00
Capabilities: [80] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable+
Capabilities: [100] Advanced Error Reporting <?>
Kernel driver in use: radeon
Kernel modules: radeonfb, radeon
00: 02 10 60 5b 07 04 10 00 00 00 00 03 10 00 80 00
10: 08 00 00 d0 01 dc 00 00 00 00 de df 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 02 10 02 04
30: 01 00 e0 df 50 00 00 00 00 00 00 00 0b 01 00 00
(注意偏移量 0x30 处的 0x01 和现在显示“扩展 ROM 在 dfe00000 [size=128K]”的行)。
但我无法访问 0xdfe00000。同时,当 O 在命令行中执行“echo 1 > rom”时,它不会更改行以删除“禁用”,实际上它根本不会对 lspci 的输出进行任何更改。那么“echo 1 > rom”在做什么而我不是,这使得随后可以执行“dd if=rom of=/tmp/rom”?
非常感激