Add get_fw_dev_path callback for system bus.
Prints out mmio or pio used to access child device. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
		
							parent
							
								
									dc1a46b609
								
							
						
					
					
						commit
						c646f74ffd
					
				| 
						 | 
					@ -140,6 +140,7 @@ void pci_host_conf_register_ioport(pio_addr_t ioport, PCIHostState *s)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    pci_host_init(s);
 | 
					    pci_host_init(s);
 | 
				
			||||||
    register_ioport_simple(&s->conf_handler, ioport, 4, 4);
 | 
					    register_ioport_simple(&s->conf_handler, ioport, 4, 4);
 | 
				
			||||||
 | 
					    sysbus_init_ioports(&s->busdev, ioport, 4);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int pci_host_data_register_mmio(PCIHostState *s, int endian)
 | 
					int pci_host_data_register_mmio(PCIHostState *s, int endian)
 | 
				
			||||||
| 
						 | 
					@ -154,4 +155,5 @@ void pci_host_data_register_ioport(pio_addr_t ioport, PCIHostState *s)
 | 
				
			||||||
    register_ioport_simple(&s->data_handler, ioport, 4, 1);
 | 
					    register_ioport_simple(&s->data_handler, ioport, 4, 1);
 | 
				
			||||||
    register_ioport_simple(&s->data_handler, ioport, 4, 2);
 | 
					    register_ioport_simple(&s->data_handler, ioport, 4, 2);
 | 
				
			||||||
    register_ioport_simple(&s->data_handler, ioport, 4, 4);
 | 
					    register_ioport_simple(&s->data_handler, ioport, 4, 4);
 | 
				
			||||||
 | 
					    sysbus_init_ioports(&s->busdev, ioport, 4);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										30
									
								
								hw/sysbus.c
								
								
								
								
							
							
						
						
									
										30
									
								
								hw/sysbus.c
								
								
								
								
							| 
						 | 
					@ -22,11 +22,13 @@
 | 
				
			||||||
#include "monitor.h"
 | 
					#include "monitor.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent);
 | 
					static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent);
 | 
				
			||||||
 | 
					static char *sysbus_get_fw_dev_path(DeviceState *dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct BusInfo system_bus_info = {
 | 
					struct BusInfo system_bus_info = {
 | 
				
			||||||
    .name       = "System",
 | 
					    .name       = "System",
 | 
				
			||||||
    .size       = sizeof(BusState),
 | 
					    .size       = sizeof(BusState),
 | 
				
			||||||
    .print_dev  = sysbus_dev_print,
 | 
					    .print_dev  = sysbus_dev_print,
 | 
				
			||||||
 | 
					    .get_fw_dev_path = sysbus_get_fw_dev_path,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
 | 
					void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
 | 
				
			||||||
| 
						 | 
					@ -106,6 +108,16 @@ void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size,
 | 
				
			||||||
    dev->mmio[n].cb = cb;
 | 
					    dev->mmio[n].cb = cb;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    pio_addr_t i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (i = 0; i < size; i++) {
 | 
				
			||||||
 | 
					        assert(dev->num_pio < QDEV_MAX_PIO);
 | 
				
			||||||
 | 
					        dev->pio[dev->num_pio++] = ioport++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int sysbus_device_init(DeviceState *dev, DeviceInfo *base)
 | 
					static int sysbus_device_init(DeviceState *dev, DeviceInfo *base)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    SysBusDeviceInfo *info = container_of(base, SysBusDeviceInfo, qdev);
 | 
					    SysBusDeviceInfo *info = container_of(base, SysBusDeviceInfo, qdev);
 | 
				
			||||||
| 
						 | 
					@ -171,3 +183,21 @@ static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
 | 
				
			||||||
                       indent, "", s->mmio[i].addr, s->mmio[i].size);
 | 
					                       indent, "", s->mmio[i].addr, s->mmio[i].size);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static char *sysbus_get_fw_dev_path(DeviceState *dev)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    SysBusDevice *s = sysbus_from_qdev(dev);
 | 
				
			||||||
 | 
					    char path[40];
 | 
				
			||||||
 | 
					    int off;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (s->num_mmio) {
 | 
				
			||||||
 | 
					        snprintf(path + off, sizeof(path) - off, "@"TARGET_FMT_plx,
 | 
				
			||||||
 | 
					                 s->mmio[0].addr);
 | 
				
			||||||
 | 
					    } else if (s->num_pio) {
 | 
				
			||||||
 | 
					        snprintf(path + off, sizeof(path) - off, "@i%04x", s->pio[0]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return strdup(path);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,7 @@
 | 
				
			||||||
#include "qdev.h"
 | 
					#include "qdev.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define QDEV_MAX_MMIO 32
 | 
					#define QDEV_MAX_MMIO 32
 | 
				
			||||||
 | 
					#define QDEV_MAX_PIO 32
 | 
				
			||||||
#define QDEV_MAX_IRQ 256
 | 
					#define QDEV_MAX_IRQ 256
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct SysBusDevice SysBusDevice;
 | 
					typedef struct SysBusDevice SysBusDevice;
 | 
				
			||||||
| 
						 | 
					@ -23,6 +24,8 @@ struct SysBusDevice {
 | 
				
			||||||
        mmio_mapfunc cb;
 | 
					        mmio_mapfunc cb;
 | 
				
			||||||
        ram_addr_t iofunc;
 | 
					        ram_addr_t iofunc;
 | 
				
			||||||
    } mmio[QDEV_MAX_MMIO];
 | 
					    } mmio[QDEV_MAX_MMIO];
 | 
				
			||||||
 | 
					    int num_pio;
 | 
				
			||||||
 | 
					    pio_addr_t pio[QDEV_MAX_PIO];
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef int (*sysbus_initfn)(SysBusDevice *dev);
 | 
					typedef int (*sysbus_initfn)(SysBusDevice *dev);
 | 
				
			||||||
| 
						 | 
					@ -45,6 +48,7 @@ void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size,
 | 
				
			||||||
                            mmio_mapfunc cb);
 | 
					                            mmio_mapfunc cb);
 | 
				
			||||||
void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
 | 
					void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
 | 
				
			||||||
void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
 | 
					void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
 | 
				
			||||||
 | 
					void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
 | 
					void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue