5

我在搞一些业余爱好者的操作系统开发,我对内存映射的 I/O 地址有点困惑。我了解整个内存映射 I/O 概念,但我试图弄清楚开发人员如何获取地址来操作硬件。

这些地址是硬件供应商指定的,还是所有计算机的某种标准地址?例如,用于文本打印的 VGA 内存从地址 0xB8000 开始。这是每台 x86 机器的标准吗?如果是这样,谁制定了这个标准?例如,如果我想与以太网卡通信,我如何知道它用于通信的地址或端口?

提前致谢。

4

2 回答 2

3

我不能 100% 确定谁设置了地址,但据我所知,硬件供应商可以根据需要设置内存映射。

对于它的价值,Linux 可以让您通过执行以下操作查看内存当前如何映射到您的机器上cat /proc/iomem

00000000-0000ffff : reserved
00010000-0009f3ff : System RAM
0009f400-0009ffff : reserved
000a0000-000bffff : PCI Bus 0000:00
  000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000ca000-000cbfff : reserved
  000ca000-000cafff : Adapter ROM
000cc000-000cffff : PCI Bus 0000:00
000d0000-000d3fff : PCI Bus 0000:00
000d4000-000d7fff : PCI Bus 0000:00
000d8000-000dbfff : PCI Bus 0000:00
000dc000-000fffff : reserved
  000f0000-000fffff : System ROM
00100000-3fedffff : System RAM
  01000000-01536143 : Kernel code
  01536144-017c007f : Kernel data
  01875000-0194bfff : Kernel bss
3fee0000-3fefefff : ACPI Tables
....
于 2012-03-08T05:36:11.880 回答
2

You get the port with some hardware detection mechanism like PCI bus scanning, usb, and ACPI. For example, if you found a supported display card on PCI, you query its BARs(base address registers) and you got the physical address, and/or IO port base, and/or IRQ number. Same for NIC and other card.

For things that are not on any bus, eg. ps/2 controller, the detection is a lot difficult and involve parsing the ACPI tables.

于 2012-05-13T18:31:55.893 回答