Schmidtzilla wrote:
"WHERE ON EARTH ARE THESE PORT NUMBERS COMING FROM???"
Depends on which port you're asking about.
Schmidtzilla wrote:
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?
That article is incorrect. According to the PCI IDE Controller Specification, you're supposed to read all three bytes of the class code to determine whether the PCI IDE controller is using the BARs or legacy addresses. The BARs don't tell you the correct addresses when the controller is using legacy addresses because you're not supposed to read the BARs in that case.
The numbers 0x1F0 and 0x3F6 come from the IBM PC AT Fixed Disk and Diskette Drive Adapter, since IDE is designed to be backwards-compatible with it.
Schmidtzilla wrote:
Not to mention where on Earth did the initial PCI port number of 0xCF8 and 0xCFC even come from?
The PCI Local Bus Specification.
Schmidtzilla wrote:
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?
There isn't.
Schmidtzilla wrote:
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."
Those chips don't do their own address decoding, so they don't know which addresses they've been assigned.
Schmidtzilla wrote:
and every time I'm readying one the same thing pops into mind. Where is this port number coming from?
The port numbers for the interrupt controllers, keyboard controller, and DMA controllers were assigned by IBM when they designed the PC and PC AT. Everyone copied those numbers to maintain backwards compatibility.
Schmidtzilla wrote:
I have just started reading PnP bios but haven't finished yet, but am I on the right track? Is it BIOs? ISA? EISA?
No, no, no, and no.
Schmidtzilla wrote:
or do I have to finish reading PCI maybe?
That might help you when it comes to PCI devices.
Schmidtzilla wrote:
Do the devices themselves have the port number to listen to saved to them?
Depends on the device.
Schmidtzilla wrote:
And if so why does the 8259A's have multiple ports and the specs not say a single thing about them?
Those chips don't do their own address decoding, so they don't know which addresses they've been assigned.
Schmidtzilla wrote:
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?
No.
Schmidtzilla wrote:
Or is it literally the 0-31 address pins on the processor pins 60h in the address lines point at the keyboard controller?
Almost! There's also a line to select between memory and I/O addresses.