Page 1 of 1

Serial Port - UART com1 base address

Posted: Sun Nov 24, 2024 9:42 am
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,

Re: Serial Port - UART com1 base address

Posted: Sun Nov 24, 2024 12:28 pm
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).

Re: Serial Port - UART com1 base address

Posted: Sun Nov 24, 2024 2:34 pm
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.

Re: Serial Port - UART com1 base address

Posted: Sun Nov 24, 2024 6:39 pm
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.)