On 02.01.16 21:44, Mark Cave-Ayland wrote:
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@ilande.co.uk
openbios-devel/drivers/pci.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/openbios-devel/drivers/pci.c b/openbios-devel/drivers/pci.c index 6347118..97d3ef3 100644 --- a/openbios-devel/drivers/pci.c +++ b/openbios-devel/drivers/pci.c @@ -144,9 +144,13 @@ 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 {
return arch->host_pci_base + (unsigned long)ba;
- }
}
static void @@ -347,16 +351,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 & 0x03000000) >> 24);
You could try to reuse the defines we have in QEMU for the parameter bits:
#define FDT_PCI_RANGE_RELOCATABLE 0x80000000 #define FDT_PCI_RANGE_PREFETCHABLE 0x40000000 #define FDT_PCI_RANGE_ALIASED 0x20000000 #define FDT_PCI_RANGE_TYPE_MASK 0x03000000 #define FDT_PCI_RANGE_MMIO_64BIT 0x03000000 #define FDT_PCI_RANGE_MMIO 0x02000000 #define FDT_PCI_RANGE_IOPORT 0x01000000 #define FDT_PCI_RANGE_CONFIG 0x00000000
While at it, you probably also want to double-check you're not mapping MMIO_64BIT or CONFIG by accident ;).
Alex
- phys = pci_bus_addr_to_host_addr(space, ba);
#if defined(CONFIG_OFMEM) ofmem_claim_phys(phys, size, 0); @@ -753,13 +761,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();