OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Jul 03, 2020 2:52 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Common Ports
PostPosted: Sat Jun 27, 2020 7:40 am 
Offline

Joined: Sat Jun 06, 2020 2:02 pm
Posts: 3
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.


Top
 Profile  
 
 Post subject: Re: Common Ports
PostPosted: Tue Jun 30, 2020 12:43 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 2079
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], mrjbom, thewrongchristian and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group