Common Ports
Posted: Sat Jun 27, 2020 7:40 am
I've been reading nonstop now for the past several months and the same one question keeps coming to mind, which I have seen been asked numerous times by others as well over and over again. What are these IO Ports and/or where is a list for them. On this sites wiki page https://wiki.osdev.org/I/O_Ports it states that I should not be looking for a list, which it also posts a link to bochs beautiful list of ports as well. However, I'm also left with the same question even while possessing such a list, "WHERE ON EARTH ARE THESE PORT NUMBERS COMING FROM???" When I view the PCI it gives me BARs to look over. Say, as a basis for clarification of my question, I am trying to program an ATA/ATAPI driver for my hard drive. I look through my PCI's BARs and find it says 0x0 or 0x1 in BAR 1, as it says to do here, https://wiki.osdev.org/PCI_IDE_Controller. Now it tells me that 0 or 1 means that the address is 0x1F0 and 0x3F6 however where did these numbers come from if I read the thing and it tells me the address is 0? Why doesn't it tell me the address 0x1F0 or 0x3F6 within the BAR and where are these other port numbers coming from? Not to mention where on Earth did the initial PCI port number of 0xCF8 and 0xCFC even come from?
I am assuming there is a configuration table somewhere in memory, as with all things in programming (working with descriptor tables on everything) there is something in maybe the extended bios data area or somewhere in the BIOS chip with a more accurate listing of all these available port numbers actually available on my specific PC? I keep reading things seeing people saying "You gotta read the standard for the device" and things like that however I have already read the standard on several of these chips such as the 8259A whose ports are 20h-21h and A0h-A1h as well as different keyboard controllers the DMA controller and several others not a single one of these standards have told me anything about "port numbers." and every time I'm readying one the same thing pops into mind. Where is this port number coming from? I have just started reading PnP bios but haven't finished yet, but am I on the right track? Is it BIOs? ISA? EISA? or do I have to finish reading PCI maybe? Do the devices themselves have the port number to listen to saved to them? And if so why does the 8259A's have multiple ports and the specs not say a single thing about them? Maybe PCI has a configuration saved inside of it so when it hits a 0101h in its class config space it gives the device the port 1F0h? Or is it literally the 0-31 address pins on the processor pins 60h in the address lines point at the keyboard controller? I'm so confused and it's that one question that will never stop haunting me every day now for SEVERAL months!
Sorry for the repeated question as I know it has been asked several times EVERYWHERE else but its gotta have an actual answer to it.
I am assuming there is a configuration table somewhere in memory, as with all things in programming (working with descriptor tables on everything) there is something in maybe the extended bios data area or somewhere in the BIOS chip with a more accurate listing of all these available port numbers actually available on my specific PC? I keep reading things seeing people saying "You gotta read the standard for the device" and things like that however I have already read the standard on several of these chips such as the 8259A whose ports are 20h-21h and A0h-A1h as well as different keyboard controllers the DMA controller and several others not a single one of these standards have told me anything about "port numbers." and every time I'm readying one the same thing pops into mind. Where is this port number coming from? I have just started reading PnP bios but haven't finished yet, but am I on the right track? Is it BIOs? ISA? EISA? or do I have to finish reading PCI maybe? Do the devices themselves have the port number to listen to saved to them? And if so why does the 8259A's have multiple ports and the specs not say a single thing about them? Maybe PCI has a configuration saved inside of it so when it hits a 0101h in its class config space it gives the device the port 1F0h? Or is it literally the 0-31 address pins on the processor pins 60h in the address lines point at the keyboard controller? I'm so confused and it's that one question that will never stop haunting me every day now for SEVERAL months!
Sorry for the repeated question as I know it has been asked several times EVERYWHERE else but its gotta have an actual answer to it.