[OpenBIOS] [commit] r1373 - trunk/openbios-devel/drivers

repository service svn at openbios.org
Fri Jan 8 13:09:39 CET 2016


Author: mcayland
Date: Fri Jan  8 13:09:38 2016
New Revision: 1373
URL: http://tracker.coreboot.org/trac/openbios/changeset/1373

Log:
pci: support PCI spaces other than memory in pci_bus_addr_to_host_addr()

Currently only PCI memory space is mapped in ob_pci_map_in(). By adding
multi-space support to pci_bus_addr_to_host_addr(), it becomes possible
to translate physical addresses for both memory and IO space.

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>

Modified:
   trunk/openbios-devel/drivers/pci.c
   trunk/openbios-devel/drivers/pci.h

Modified: trunk/openbios-devel/drivers/pci.c
==============================================================================
--- trunk/openbios-devel/drivers/pci.c	Fri Jan  8 13:09:35 2016	(r1372)
+++ trunk/openbios-devel/drivers/pci.c	Fri Jan  8 13:09:38 2016	(r1373)
@@ -144,9 +144,16 @@
 }
 #endif
 
-static unsigned long pci_bus_addr_to_host_addr(uint32_t ba)
+static unsigned long pci_bus_addr_to_host_addr(int space, uint32_t ba)
 {
-    return arch->host_pci_base + (unsigned long)ba;
+    if (space == IO_SPACE) {
+        return arch->io_base + (unsigned long)ba;
+    } else if (space == MEMORY_SPACE_32) {
+        return arch->host_pci_base + (unsigned long)ba;
+    } else {
+        /* Return unaltered to aid debugging property values */
+        return (unsigned long)ba;
+    }
 }
 
 static void
@@ -347,16 +354,20 @@
 {
 	phys_addr_t phys;
 	uint32_t ba;
-	ucell size, virt;
+	ucell size, virt, tmp;
+	int space;
 
 	PCI_DPRINTF("ob_pci_bar_map_in idx=%p\n", idx);
 
 	size = POP();
-	POP();
+	tmp = POP();
 	POP();
 	ba = POP();
 
-	phys = pci_bus_addr_to_host_addr(ba);
+	/* Get the space from the pci-addr.hi */
+	space = ((tmp & PCI_RANGE_TYPE_MASK) >> 24);
+
+	phys = pci_bus_addr_to_host_addr(space, ba);
 
 #if defined(CONFIG_OFMEM)
 	ofmem_claim_phys(phys, size, 0);
@@ -753,13 +764,19 @@
 int vga_config_cb (const pci_config_t *config)
 {
         unsigned long rom;
-        uint32_t rom_size, size;
+        uint32_t rom_size, size, mask;
+        int flags, space_code;
         phandle_t ph;
 
         if (config->assigned[0] != 0x00000000) {
             setup_video();
 
-            rom = pci_bus_addr_to_host_addr(config->assigned[1] & ~0x0000000F);
+            pci_decode_pci_addr(config->assigned[1],
+                &flags, &space_code, &mask);
+
+            rom = pci_bus_addr_to_host_addr(space_code,
+                                            config->assigned[1] & ~0x0000000F);
+
             rom_size = config->sizes[1];
 
             ph = get_cur_dev();

Modified: trunk/openbios-devel/drivers/pci.h
==============================================================================
--- trunk/openbios-devel/drivers/pci.h	Fri Jan  8 13:09:35 2016	(r1372)
+++ trunk/openbios-devel/drivers/pci.h	Fri Jan  8 13:09:38 2016	(r1373)
@@ -59,6 +59,15 @@
 #define PCI_MIN_GNT             0x3e    /* 8 bits */
 #define PCI_MAX_LAT             0x3f    /* 8 bits */
 
+#define PCI_RANGE_RELOCATABLE          0x80000000
+#define PCI_RANGE_PREFETCHABLE         0x40000000
+#define PCI_RANGE_ALIASED              0x20000000
+#define PCI_RANGE_TYPE_MASK            0x03000000
+#define PCI_RANGE_MMIO_64BIT           0x03000000
+#define PCI_RANGE_MMIO                 0x02000000
+#define PCI_RANGE_IOPORT               0x01000000
+#define PCI_RANGE_CONFIG               0x00000000
+
 typedef struct {
         u16     signature;
         u8      reserved[0x16];



More information about the OpenBIOS mailing list