Serial Port - UART com1 base address

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pcatst
Posts: 1
Joined: Sun Nov 24, 2024 9:38 am
Libera.chat IRC: mod

Serial Port - UART com1 base address

Post by pcatst »

Greetings,

I am in the process of implementing a basic serial driver for my OS. The example code given here, https://wiki.osdev.org/Serial_Ports#Example_Code, has COM1 hard coded to 0x3F8.

My question is where in the UEFI/ACPI tree of tables and pointers to tables (RSDT, etc) can I go to find the actual base address of all the serial / UART controllers with the goal of ( for example ), not having to guess that 0x3F8 is the actual base address and ideally some field in some table can confirm that for me?

Thanks,
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Serial Port - UART com1 base address

Post by Gigasoft »

Serial ports are declared with AML as devices with a hardware ID (_HID) of PNP0500 or PNP0501. The I/O base and IRQ line number are given in the resource descriptor (_CRS).
rdos
Member
Member
Posts: 3297
Joined: Wed Oct 01, 2008 1:55 pm

Re: Serial Port - UART com1 base address

Post by rdos »

I don't trust ACPI for this and use detection. Only a small number of base addresses and IRQs are used in real systems, and the COM port dates back to times when ACPI was non-existent or not working properly. PCI based COM ports can be found though PCI device discovery.
User avatar
eekee
Member
Member
Posts: 891
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: Serial Port - UART com1 base address

Post by eekee »

rdos wrote: Sun Nov 24, 2024 2:34 pm the COM port dates back to times when ACPI was non-existent or not working properly.
That's an understatement! :) The COM port greatly predates ACPI's predecessor Plug 'n Pray Play.

The wiki's Serial Ports page, Port Addresses section, describes how to probe them. (Note the plural in the page name. Don't get it mixed up with the Serial Port page which has no programming information.)
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
Post Reply