[OpenBIOS] [PATCHv2 2/6] pci: support PCI spaces other than memory in pci_bus_addr_to_host_addr()
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Mon Jan 4 15:11:51 CET 2016
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>
---
openbios-devel/drivers/pci.c | 31 ++++++++++++++++++++++++-------
openbios-devel/drivers/pci.h | 9 +++++++++
2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/openbios-devel/drivers/pci.c b/openbios-devel/drivers/pci.c
index 5847ec3..713b2f2 100644
--- a/openbios-devel/drivers/pci.c
+++ b/openbios-devel/drivers/pci.c
@@ -144,9 +144,16 @@ static void dump_reg_property(const char* description, int nreg, u32 *reg)
}
#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 @@ ob_pci_map_in(int *idx)
{
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 macio_keylargo_config_cb (const pci_config_t *config)
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();
diff --git a/openbios-devel/drivers/pci.h b/openbios-devel/drivers/pci.h
index 84a2b2c..d5aa5f8 100644
--- a/openbios-devel/drivers/pci.h
+++ b/openbios-devel/drivers/pci.h
@@ -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];
--
1.7.10.4
More information about the OpenBIOS
mailing list