I am messing around with some hobbyist OS development, and I am a little confused on memory mapped I/O addresses. I understand the whole memory mapped I/O concept, but I am trying to figure out how developers get the addresses to manipulate hardware.
Are the addresses specified by the hardware vendors, or are they some sort of standard addresses for all computers? For example, VGA memory for text printing starts at address 0xB8000. Is that standard for every x86 machine? If so, who set that standard? And if I wanted to talk with an ethernet card, for example, how would I know the addresses or ports it uses for communication?
Thanks in advance.
I'm not 100% sure about who sets the addresses, but as far as I'm aware, hardware vendors can set their memory map however they want.
For what it's worth, Linux lets you see how memory is currently mapped on your machine by doing 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
....
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With