Talk:Shutdown

From OSDev Wiki
Jump to navigation Jump to search

Shutdown in QEMU not always on port 0x604?

For various reasons I'm writing my own x86_64 BIOS for QEMU, and I've found that nothing is present on 0x604. Tracing while running a Linux guest reveals that under normal circumstances 'acpi-cnt' should be present there, though in the case of my custom BIOS it does not appear to be there. Looking at QEMU source code, it calls qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);, so that does look right. Checking with info mtree, it appears that 'acpi-cnt' is at 0x4, though masked by 'acpi-dma'. I'm guessing SeaBIOS is somehow telling QEMU to put 'acpi-cnt' at 0x604.

Looking through SeaBIOS code, I find:

  • u16 acpi_pm_base = 0xb000;
  • acpi_pm_base = 0x0600;
  • acpi_pm1a_cnt = acpi_pm_base + 0x04

... but it doesn't seem to be writing that anywhere? Except:

  • pci_config_writel(bdf, PIIX_PMBASE, acpi_pm_base | 1);

I suppose that has to be it, let's see further:

  • #define PIIX_PMBASE 0x40
  • PORT_PCI_CMD and PORT_PCI_DATA at 0xcf8 and 0xcfc respectively.
  • 0x80000000 | (bdf << 8) | (addr & 0xfc)

"bdf" is "Bus Device Function" I guess. We should probably enumerate the PCI bus then...

I will post an update once I've got PCI enumeration working.

Demindiro (talk) 21:26, 11 October 2025 (UTC)