[OpenBIOS] [PATCHv2 3/6] pci: fix AAPL, address property for IO space mappings

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Mon Jan 4 15:11:52 CET 2016

According to "Designing PCI Cards and Drivers for Power Macintosh Computers" the
AAPL,address property should be an array of virtual addresses representing the
bus addresses in the assigned-addresses array.

While this works for PCI memory addresses, IO addresses are incorrect because
the calculated address is still the PCI bus address. Switch over to using the
new space-aware pci_bus_addr_to_host_addr() so that addresses in both memory
and IO space are correctly calculated.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
Reviewed-by: Alexander Graf <agraf at suse.de>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
 openbios-devel/drivers/pci.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/openbios-devel/drivers/pci.c b/openbios-devel/drivers/pci.c
index 713b2f2..c204f15 100644
--- a/openbios-devel/drivers/pci.c
+++ b/openbios-devel/drivers/pci.c
@@ -597,13 +597,18 @@ static void pci_set_AAPL_address(const pci_config_t *config)
 	phandle_t dev = get_cur_dev();
 	cell props[7];
-	int ncells, i;
+	uint32_t mask;
+	int ncells, i, flags, space_code;
 	ncells = 0;
 	for (i = 0; i < 6; i++) {
 		if (!config->assigned[i] || !config->sizes[i])
-		props[ncells++] = config->assigned[i] & ~0x0000000F;
+		pci_decode_pci_addr(config->assigned[i],
+				    &flags, &space_code, &mask);
+		props[ncells++] = pci_bus_addr_to_host_addr(space_code,
+					config->assigned[i] & ~mask);
 	if (ncells)
 		set_property(dev, "AAPL,address", (char *)props,

More information about the OpenBIOS mailing list