From 5bf3e72d37bb0cd4886a7e99ad2396a6f3095128 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Mon, 25 Jul 2022 13:47:56 +0200 Subject: [PATCH] pci: return correct I/O port base from BAR The base address of I/O ports has a different encoding than those of I/O memory. This needs to be encountered in the PCI config helper utilities. Fix genodelabs/genode#4576 --- repos/os/include/pci/config.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/repos/os/include/pci/config.h b/repos/os/include/pci/config.h index 4e5b61db59..3cb8931b1f 100644 --- a/repos/os/include/pci/config.h +++ b/repos/os/include/pci/config.h @@ -129,8 +129,12 @@ struct Pci::Config : Genode::Mmio Genode::uint64_t addr() { - return (bit64() ? ((Genode::uint64_t)read()<<32) : 0UL) - | Bar_32bit::Memory_base::masked(read()); + if (memory()) + return (bit64() + ? ((Genode::uint64_t)read()<<32) : 0UL) + | Bar_32bit::Memory_base::masked(read()); + else + return Bar_32bit::Io_base::masked(read()); } };