From 17bd42896d31bf57cb3cc16abefb3221391eb288 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:11 +0100 Subject: [PATCH 01/53] dino: checkpatch fixes Signed-off-by: Mark Cave-Ayland Reviewed-by: Richard Henderson Acked-by: Helge Deller Message-Id: <20220504092600.10048-2-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index eab96dd84e..4031cfb7f0 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -101,8 +101,10 @@ static const uint32_t reg800_keep_bits[DINO800_REGS] = { struct DinoState { PCIHostState parent_obj; - /* PCI_CONFIG_ADDR is parent_obj.config_reg, via pci_host_conf_be_ops, - so that we can map PCI_CONFIG_DATA to pci_host_data_be_ops. */ + /* + * PCI_CONFIG_ADDR is parent_obj.config_reg, via pci_host_conf_be_ops, + * so that we can map PCI_CONFIG_DATA to pci_host_data_be_ops. + */ uint32_t config_reg_dino; /* keep original copy, including 2 lowest bits */ uint32_t iar0; From 7cdfa94166fb5aa25681152675c85c709e927602 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:12 +0100 Subject: [PATCH 02/53] dino: move registers from dino_init() to DINO_PCI_BRIDGE init function Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-3-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index 4031cfb7f0..9401b68ff7 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -526,21 +526,6 @@ PCIBus *dino_init(MemoryRegion *addr_space, s->iar0 = s->iar1 = CPU_HPA + 3; s->toc_addr = 0xFFFA0030; /* IO_COMMAND of CPU */ - /* Dino PCI access from main memory. */ - memory_region_init_io(&s->this_mem, OBJECT(s), &dino_chip_ops, - s, "dino", 4096); - memory_region_add_subregion(addr_space, DINO_HPA, &s->this_mem); - - /* Dino PCI config. */ - memory_region_init_io(&s->parent_obj.conf_mem, OBJECT(&s->parent_obj), - &dino_config_addr_ops, dev, "pci-conf-idx", 4); - memory_region_init_io(&s->parent_obj.data_mem, OBJECT(&s->parent_obj), - &dino_config_data_ops, dev, "pci-conf-data", 4); - memory_region_add_subregion(&s->this_mem, DINO_PCI_CONFIG_ADDR, - &s->parent_obj.conf_mem); - memory_region_add_subregion(&s->this_mem, DINO_CONFIG_DATA, - &s->parent_obj.data_mem); - /* Dino PCI bus memory. */ memory_region_init(&s->pci_mem, OBJECT(s), "pci-memory", 4 * GiB); @@ -550,6 +535,9 @@ PCIBus *dino_init(MemoryRegion *addr_space, s->parent_obj.bus = b; sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + memory_region_add_subregion(addr_space, DINO_HPA, + sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0)); + /* Set up windows into PCI bus memory. */ for (i = 1; i < 31; i++) { uint32_t addr = 0xf0000000 + i * DINO_MEM_CHUNK_SIZE; @@ -588,6 +576,31 @@ PCIBus *dino_init(MemoryRegion *addr_space, return b; } +static void dino_pcihost_init(Object *obj) +{ + DinoState *s = DINO_PCI_HOST_BRIDGE(obj); + PCIHostState *phb = PCI_HOST_BRIDGE(obj); + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); + + /* Dino PCI access from main memory. */ + memory_region_init_io(&s->this_mem, OBJECT(s), &dino_chip_ops, + s, "dino", 4096); + + /* Dino PCI config. */ + memory_region_init_io(&phb->conf_mem, OBJECT(phb), + &dino_config_addr_ops, DEVICE(s), + "pci-conf-idx", 4); + memory_region_init_io(&phb->data_mem, OBJECT(phb), + &dino_config_data_ops, DEVICE(s), + "pci-conf-data", 4); + memory_region_add_subregion(&s->this_mem, DINO_PCI_CONFIG_ADDR, + &phb->conf_mem); + memory_region_add_subregion(&s->this_mem, DINO_CONFIG_DATA, + &phb->data_mem); + + sysbus_init_mmio(sbd, &s->this_mem); +} + static void dino_pcihost_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -598,6 +611,7 @@ static void dino_pcihost_class_init(ObjectClass *klass, void *data) static const TypeInfo dino_pcihost_info = { .name = TYPE_DINO_PCI_HOST_BRIDGE, .parent = TYPE_PCI_HOST_BRIDGE, + .instance_init = dino_pcihost_init, .instance_size = sizeof(DinoState), .class_init = dino_pcihost_class_init, }; From 63901b6cc4d8b471ac4b92826220db914b908368 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:13 +0100 Subject: [PATCH 03/53] dino: move PCI bus initialisation to dino_pcihost_init() Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-4-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index 9401b68ff7..c6c01ea14c 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -526,13 +526,7 @@ PCIBus *dino_init(MemoryRegion *addr_space, s->iar0 = s->iar1 = CPU_HPA + 3; s->toc_addr = 0xFFFA0030; /* IO_COMMAND of CPU */ - /* Dino PCI bus memory. */ - memory_region_init(&s->pci_mem, OBJECT(s), "pci-memory", 4 * GiB); - - b = pci_register_root_bus(dev, "pci", dino_set_irq, dino_pci_map_irq, s, - &s->pci_mem, get_system_io(), - PCI_DEVFN(0, 0), 32, TYPE_PCI_BUS); - s->parent_obj.bus = b; + b = s->parent_obj.bus; sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); memory_region_add_subregion(addr_space, DINO_HPA, @@ -598,6 +592,14 @@ static void dino_pcihost_init(Object *obj) memory_region_add_subregion(&s->this_mem, DINO_CONFIG_DATA, &phb->data_mem); + /* Dino PCI bus memory. */ + memory_region_init(&s->pci_mem, OBJECT(s), "pci-memory", 4 * GiB); + + phb->bus = pci_register_root_bus(DEVICE(s), "pci", + dino_set_irq, dino_pci_map_irq, s, + &s->pci_mem, get_system_io(), + PCI_DEVFN(0, 0), 32, TYPE_PCI_BUS); + sysbus_init_mmio(sbd, &s->this_mem); } From cc363c4a10b99709ea4e9e185c7b71de72f88a17 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:14 +0100 Subject: [PATCH 04/53] dino: move PCI windows initialisation to dino_pcihost_init() Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-5-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index c6c01ea14c..bc27aad5dc 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -519,7 +519,6 @@ PCIBus *dino_init(MemoryRegion *addr_space, DeviceState *dev; DinoState *s; PCIBus *b; - int i; dev = qdev_new(TYPE_DINO_PCI_HOST_BRIDGE); s = DINO_PCI_HOST_BRIDGE(dev); @@ -532,16 +531,6 @@ PCIBus *dino_init(MemoryRegion *addr_space, memory_region_add_subregion(addr_space, DINO_HPA, sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0)); - /* Set up windows into PCI bus memory. */ - for (i = 1; i < 31; i++) { - uint32_t addr = 0xf0000000 + i * DINO_MEM_CHUNK_SIZE; - char *name = g_strdup_printf("PCI Outbound Window %d", i); - memory_region_init_alias(&s->pci_mem_alias[i], OBJECT(s), - name, &s->pci_mem, addr, - DINO_MEM_CHUNK_SIZE); - g_free(name); - } - /* Set up PCI view of memory: Bus master address space. */ memory_region_init(&s->bm, OBJECT(s), "bm-dino", 4 * GiB); memory_region_init_alias(&s->bm_ram_alias, OBJECT(s), @@ -575,6 +564,7 @@ static void dino_pcihost_init(Object *obj) DinoState *s = DINO_PCI_HOST_BRIDGE(obj); PCIHostState *phb = PCI_HOST_BRIDGE(obj); SysBusDevice *sbd = SYS_BUS_DEVICE(obj); + int i; /* Dino PCI access from main memory. */ memory_region_init_io(&s->this_mem, OBJECT(s), &dino_chip_ops, @@ -600,6 +590,16 @@ static void dino_pcihost_init(Object *obj) &s->pci_mem, get_system_io(), PCI_DEVFN(0, 0), 32, TYPE_PCI_BUS); + /* Set up windows into PCI bus memory. */ + for (i = 1; i < 31; i++) { + uint32_t addr = 0xf0000000 + i * DINO_MEM_CHUNK_SIZE; + char *name = g_strdup_printf("PCI Outbound Window %d", i); + memory_region_init_alias(&s->pci_mem_alias[i], OBJECT(s), + name, &s->pci_mem, addr, + DINO_MEM_CHUNK_SIZE); + g_free(name); + } + sysbus_init_mmio(sbd, &s->this_mem); } From 270b29587f4705aa8d6b46ba2c0ff5bf712cc637 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:15 +0100 Subject: [PATCH 05/53] dino: add memory-as property containing a link to the memory address space Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-6-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index bc27aad5dc..13b2210462 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -17,6 +17,7 @@ #include "hw/irq.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bus.h" +#include "hw/qdev-properties.h" #include "migration/vmstate.h" #include "hppa_sys.h" #include "trace.h" @@ -124,6 +125,8 @@ struct DinoState { MemoryRegion pci_mem; MemoryRegion pci_mem_alias[32]; + MemoryRegion *memory_as; + AddressSpace bm_as; MemoryRegion bm; MemoryRegion bm_ram_alias; @@ -521,6 +524,8 @@ PCIBus *dino_init(MemoryRegion *addr_space, PCIBus *b; dev = qdev_new(TYPE_DINO_PCI_HOST_BRIDGE); + object_property_set_link(OBJECT(dev), "memory-as", OBJECT(addr_space), + &error_fatal); s = DINO_PCI_HOST_BRIDGE(dev); s->iar0 = s->iar1 = CPU_HPA + 3; s->toc_addr = 0xFFFA0030; /* IO_COMMAND of CPU */ @@ -603,10 +608,17 @@ static void dino_pcihost_init(Object *obj) sysbus_init_mmio(sbd, &s->this_mem); } +static Property dino_pcihost_properties[] = { + DEFINE_PROP_LINK("memory-as", DinoState, memory_as, TYPE_MEMORY_REGION, + MemoryRegion *), + DEFINE_PROP_END_OF_LIST(), +}; + static void dino_pcihost_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + device_class_set_props(dc, dino_pcihost_properties); dc->vmsd = &vmstate_dino; } From 5ac6c43c856a81e0ca1a1bab8f2fbd7b3a66274d Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:16 +0100 Subject: [PATCH 06/53] dino: move pci_setup_iommu() to dino_pcihost_init() Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-7-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index 13b2210462..dcebb9f98f 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -556,7 +556,6 @@ PCIBus *dino_init(MemoryRegion *addr_space, memory_region_add_subregion(&s->bm, 0xfff00000, &s->bm_cpu_alias); address_space_init(&s->bm_as, &s->bm, "pci-bm"); - pci_setup_iommu(b, dino_pcihost_set_iommu, s); *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0); *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0); @@ -605,6 +604,8 @@ static void dino_pcihost_init(Object *obj) g_free(name); } + pci_setup_iommu(phb->bus, dino_pcihost_set_iommu, s); + sysbus_init_mmio(sbd, &s->this_mem); } From 9cf69f444c4034e5278ec52ae9869f13ae9a2bd2 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:17 +0100 Subject: [PATCH 07/53] dino: move PCI bus master address space setup to dino_pcihost_realize() Add a new dino_pcihost_unrealize() function to remove the address space when the device is unrealized. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-8-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index dcebb9f98f..ae79ddbf5c 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -536,17 +536,27 @@ PCIBus *dino_init(MemoryRegion *addr_space, memory_region_add_subregion(addr_space, DINO_HPA, sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0)); + *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0); + *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0); + + return b; +} + +static void dino_pcihost_realize(DeviceState *dev, Error **errp) +{ + DinoState *s = DINO_PCI_HOST_BRIDGE(dev); + /* Set up PCI view of memory: Bus master address space. */ memory_region_init(&s->bm, OBJECT(s), "bm-dino", 4 * GiB); memory_region_init_alias(&s->bm_ram_alias, OBJECT(s), - "bm-system", addr_space, 0, + "bm-system", s->memory_as, 0, 0xf0000000 + DINO_MEM_CHUNK_SIZE); memory_region_init_alias(&s->bm_pci_alias, OBJECT(s), "bm-pci", &s->pci_mem, 0xf0000000 + DINO_MEM_CHUNK_SIZE, 30 * DINO_MEM_CHUNK_SIZE); memory_region_init_alias(&s->bm_cpu_alias, OBJECT(s), - "bm-cpu", addr_space, 0xfff00000, + "bm-cpu", s->memory_as, 0xfff00000, 0xfffff); memory_region_add_subregion(&s->bm, 0, &s->bm_ram_alias); @@ -555,12 +565,15 @@ PCIBus *dino_init(MemoryRegion *addr_space, &s->bm_pci_alias); memory_region_add_subregion(&s->bm, 0xfff00000, &s->bm_cpu_alias); + address_space_init(&s->bm_as, &s->bm, "pci-bm"); +} - *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0); - *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0); +static void dino_pcihost_unrealize(DeviceState *dev) +{ + DinoState *s = DINO_PCI_HOST_BRIDGE(dev); - return b; + address_space_destroy(&s->bm_as); } static void dino_pcihost_init(Object *obj) @@ -619,6 +632,8 @@ static void dino_pcihost_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + dc->realize = dino_pcihost_realize; + dc->unrealize = dino_pcihost_unrealize; device_class_set_props(dc, dino_pcihost_properties); dc->vmsd = &vmstate_dino; } From 98d168f359319ddd20b21058a081ec77837f7347 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:18 +0100 Subject: [PATCH 08/53] dino: move initial register configuration to new dino_pcihost_reset() function Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-9-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index ae79ddbf5c..d3cd8578a1 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -527,8 +527,6 @@ PCIBus *dino_init(MemoryRegion *addr_space, object_property_set_link(OBJECT(dev), "memory-as", OBJECT(addr_space), &error_fatal); s = DINO_PCI_HOST_BRIDGE(dev); - s->iar0 = s->iar1 = CPU_HPA + 3; - s->toc_addr = 0xFFFA0030; /* IO_COMMAND of CPU */ b = s->parent_obj.bus; sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); @@ -542,6 +540,14 @@ PCIBus *dino_init(MemoryRegion *addr_space, return b; } +static void dino_pcihost_reset(DeviceState *dev) +{ + DinoState *s = DINO_PCI_HOST_BRIDGE(dev); + + s->iar0 = s->iar1 = CPU_HPA + 3; + s->toc_addr = 0xFFFA0030; /* IO_COMMAND of CPU */ +} + static void dino_pcihost_realize(DeviceState *dev, Error **errp) { DinoState *s = DINO_PCI_HOST_BRIDGE(dev); @@ -632,6 +638,7 @@ static void dino_pcihost_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + dc->reset = dino_pcihost_reset; dc->realize = dino_pcihost_realize; dc->unrealize = dino_pcihost_unrealize; device_class_set_props(dc, dino_pcihost_properties); From ee313d5abb1f911c426f8fbcb3abb4b1d8e281ce Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:19 +0100 Subject: [PATCH 09/53] dino: use QOM cast instead of directly referencing parent_obj Use a QOM cast in both dino_chip_read_with_attrs() and dino_chip_write_with_attrs() instead of directly referencing parent_obj. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-10-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index d3cd8578a1..77b8089664 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -205,6 +205,7 @@ static MemTxResult dino_chip_read_with_attrs(void *opaque, hwaddr addr, MemTxAttrs attrs) { DinoState *s = opaque; + PCIHostState *phb = PCI_HOST_BRIDGE(s); MemTxResult ret = MEMTX_OK; AddressSpace *io; uint16_t ioaddr; @@ -214,7 +215,7 @@ static MemTxResult dino_chip_read_with_attrs(void *opaque, hwaddr addr, case DINO_PCI_IO_DATA ... DINO_PCI_IO_DATA + 3: /* Read from PCI IO space. */ io = &address_space_io; - ioaddr = s->parent_obj.config_reg + (addr & 3); + ioaddr = phb->config_reg + (addr & 3); switch (size) { case 1: val = address_space_ldub(io, ioaddr, attrs, &ret); @@ -297,6 +298,7 @@ static MemTxResult dino_chip_write_with_attrs(void *opaque, hwaddr addr, MemTxAttrs attrs) { DinoState *s = opaque; + PCIHostState *phb = PCI_HOST_BRIDGE(s); AddressSpace *io; MemTxResult ret; uint16_t ioaddr; @@ -308,7 +310,7 @@ static MemTxResult dino_chip_write_with_attrs(void *opaque, hwaddr addr, case DINO_IO_DATA ... DINO_PCI_IO_DATA + 3: /* Write into PCI IO space. */ io = &address_space_io; - ioaddr = s->parent_obj.config_reg + (addr & 3); + ioaddr = phb->config_reg + (addr & 3); switch (size) { case 1: address_space_stb(io, ioaddr, val, attrs, &ret); From 079e7ad989e3902ac7ecb70086d3b380faeeaf63 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:20 +0100 Subject: [PATCH 10/53] dino: return PCIBus from dino_init() using qdev_get_child_bus() This allows access to the PCI bus without having to reference parent_obj directly. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-11-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index 77b8089664..d89b48493f 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -523,14 +523,12 @@ PCIBus *dino_init(MemoryRegion *addr_space, { DeviceState *dev; DinoState *s; - PCIBus *b; + PCIBus *pci_bus; dev = qdev_new(TYPE_DINO_PCI_HOST_BRIDGE); object_property_set_link(OBJECT(dev), "memory-as", OBJECT(addr_space), &error_fatal); s = DINO_PCI_HOST_BRIDGE(dev); - - b = s->parent_obj.bus; sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); memory_region_add_subregion(addr_space, DINO_HPA, @@ -539,7 +537,8 @@ PCIBus *dino_init(MemoryRegion *addr_space, *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0); *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0); - return b; + pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci")); + return pci_bus; } static void dino_pcihost_reset(DeviceState *dev) From 14e275efcbe9cc8653a90f2085e2cdf0f7f7e24f Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:21 +0100 Subject: [PATCH 11/53] dino: split declarations from dino.c into dino.h This is to allow access to DinoState from outside dino.c. With the changes to the headers it is now possible to remove the duplicate definition for TYPE_DINO_PCI_HOST_BRIDGE from hppa_sys.h. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-12-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 111 +-------------------------------------- hw/hppa/dino.h | 127 +++++++++++++++++++++++++++++++++++++++++++++ hw/hppa/hppa_sys.h | 2 - 3 files changed, 128 insertions(+), 112 deletions(-) create mode 100644 hw/hppa/dino.h diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index d89b48493f..01546ff6fc 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -18,122 +18,13 @@ #include "hw/pci/pci.h" #include "hw/pci/pci_bus.h" #include "hw/qdev-properties.h" +#include "dino.h" #include "migration/vmstate.h" #include "hppa_sys.h" #include "trace.h" #include "qom/object.h" -#define TYPE_DINO_PCI_HOST_BRIDGE "dino-pcihost" - -#define DINO_IAR0 0x004 -#define DINO_IODC 0x008 -#define DINO_IRR0 0x00C /* RO */ -#define DINO_IAR1 0x010 -#define DINO_IRR1 0x014 /* RO */ -#define DINO_IMR 0x018 -#define DINO_IPR 0x01C -#define DINO_TOC_ADDR 0x020 -#define DINO_ICR 0x024 -#define DINO_ILR 0x028 /* RO */ -#define DINO_IO_COMMAND 0x030 /* WO */ -#define DINO_IO_STATUS 0x034 /* RO */ -#define DINO_IO_CONTROL 0x038 -#define DINO_IO_GSC_ERR_RESP 0x040 /* RO */ -#define DINO_IO_ERR_INFO 0x044 /* RO */ -#define DINO_IO_PCI_ERR_RESP 0x048 /* RO */ -#define DINO_IO_FBB_EN 0x05c -#define DINO_IO_ADDR_EN 0x060 -#define DINO_PCI_CONFIG_ADDR 0x064 -#define DINO_PCI_CONFIG_DATA 0x068 -#define DINO_PCI_IO_DATA 0x06c -#define DINO_PCI_MEM_DATA 0x070 /* Dino 3.x only */ -#define DINO_GSC2X_CONFIG 0x7b4 /* RO */ -#define DINO_GMASK 0x800 -#define DINO_PAMR 0x804 -#define DINO_PAPR 0x808 -#define DINO_DAMODE 0x80c -#define DINO_PCICMD 0x810 -#define DINO_PCISTS 0x814 /* R/WC */ -#define DINO_MLTIM 0x81c -#define DINO_BRDG_FEAT 0x820 -#define DINO_PCIROR 0x824 -#define DINO_PCIWOR 0x828 -#define DINO_TLTIM 0x830 - -#define DINO_IRQS 11 /* bits 0-10 are architected */ -#define DINO_IRR_MASK 0x5ff /* only 10 bits are implemented */ -#define DINO_LOCAL_IRQS (DINO_IRQS + 1) -#define DINO_MASK_IRQ(x) (1 << (x)) - -#define PCIINTA 0x001 -#define PCIINTB 0x002 -#define PCIINTC 0x004 -#define PCIINTD 0x008 -#define PCIINTE 0x010 -#define PCIINTF 0x020 -#define GSCEXTINT 0x040 -/* #define xxx 0x080 - bit 7 is "default" */ -/* #define xxx 0x100 - bit 8 not used */ -/* #define xxx 0x200 - bit 9 not used */ -#define RS232INT 0x400 - -#define DINO_MEM_CHUNK_SIZE (8 * MiB) - -OBJECT_DECLARE_SIMPLE_TYPE(DinoState, DINO_PCI_HOST_BRIDGE) - -#define DINO800_REGS (1 + (DINO_TLTIM - DINO_GMASK) / 4) -static const uint32_t reg800_keep_bits[DINO800_REGS] = { - MAKE_64BIT_MASK(0, 1), /* GMASK */ - MAKE_64BIT_MASK(0, 7), /* PAMR */ - MAKE_64BIT_MASK(0, 7), /* PAPR */ - MAKE_64BIT_MASK(0, 8), /* DAMODE */ - MAKE_64BIT_MASK(0, 7), /* PCICMD */ - MAKE_64BIT_MASK(0, 9), /* PCISTS */ - MAKE_64BIT_MASK(0, 32), /* Undefined */ - MAKE_64BIT_MASK(0, 8), /* MLTIM */ - MAKE_64BIT_MASK(0, 30), /* BRDG_FEAT */ - MAKE_64BIT_MASK(0, 24), /* PCIROR */ - MAKE_64BIT_MASK(0, 22), /* PCIWOR */ - MAKE_64BIT_MASK(0, 32), /* Undocumented */ - MAKE_64BIT_MASK(0, 9), /* TLTIM */ -}; - -struct DinoState { - PCIHostState parent_obj; - - /* - * PCI_CONFIG_ADDR is parent_obj.config_reg, via pci_host_conf_be_ops, - * so that we can map PCI_CONFIG_DATA to pci_host_data_be_ops. - */ - uint32_t config_reg_dino; /* keep original copy, including 2 lowest bits */ - - uint32_t iar0; - uint32_t iar1; - uint32_t imr; - uint32_t ipr; - uint32_t icr; - uint32_t ilr; - uint32_t io_fbb_en; - uint32_t io_addr_en; - uint32_t io_control; - uint32_t toc_addr; - - uint32_t reg800[DINO800_REGS]; - - MemoryRegion this_mem; - MemoryRegion pci_mem; - MemoryRegion pci_mem_alias[32]; - - MemoryRegion *memory_as; - - AddressSpace bm_as; - MemoryRegion bm; - MemoryRegion bm_ram_alias; - MemoryRegion bm_pci_alias; - MemoryRegion bm_cpu_alias; -}; - /* * Dino can forward memory accesses from the CPU in the range between * 0xf0800000 and 0xff000000 to the PCI bus. diff --git a/hw/hppa/dino.h b/hw/hppa/dino.h new file mode 100644 index 0000000000..1a26667377 --- /dev/null +++ b/hw/hppa/dino.h @@ -0,0 +1,127 @@ +/* + * HP-PARISC Dino PCI chipset emulation, as in B160L and similiar machines + * + * (C) 2017-2019 by Helge Deller + * + * This work is licensed under the GNU GPL license version 2 or later. + * + * Documentation available at: + * https://parisc.wiki.kernel.org/images-parisc/9/91/Dino_ers.pdf + * https://parisc.wiki.kernel.org/images-parisc/7/70/Dino_3_1_Errata.pdf + */ + +#ifndef DINO_H +#define DINO_H + +#include "hw/pci/pci_host.h" + +#define TYPE_DINO_PCI_HOST_BRIDGE "dino-pcihost" +OBJECT_DECLARE_SIMPLE_TYPE(DinoState, DINO_PCI_HOST_BRIDGE) + +#define DINO_IAR0 0x004 +#define DINO_IODC 0x008 +#define DINO_IRR0 0x00C /* RO */ +#define DINO_IAR1 0x010 +#define DINO_IRR1 0x014 /* RO */ +#define DINO_IMR 0x018 +#define DINO_IPR 0x01C +#define DINO_TOC_ADDR 0x020 +#define DINO_ICR 0x024 +#define DINO_ILR 0x028 /* RO */ +#define DINO_IO_COMMAND 0x030 /* WO */ +#define DINO_IO_STATUS 0x034 /* RO */ +#define DINO_IO_CONTROL 0x038 +#define DINO_IO_GSC_ERR_RESP 0x040 /* RO */ +#define DINO_IO_ERR_INFO 0x044 /* RO */ +#define DINO_IO_PCI_ERR_RESP 0x048 /* RO */ +#define DINO_IO_FBB_EN 0x05c +#define DINO_IO_ADDR_EN 0x060 +#define DINO_PCI_CONFIG_ADDR 0x064 +#define DINO_PCI_CONFIG_DATA 0x068 +#define DINO_PCI_IO_DATA 0x06c +#define DINO_PCI_MEM_DATA 0x070 /* Dino 3.x only */ +#define DINO_GSC2X_CONFIG 0x7b4 /* RO */ +#define DINO_GMASK 0x800 +#define DINO_PAMR 0x804 +#define DINO_PAPR 0x808 +#define DINO_DAMODE 0x80c +#define DINO_PCICMD 0x810 +#define DINO_PCISTS 0x814 /* R/WC */ +#define DINO_MLTIM 0x81c +#define DINO_BRDG_FEAT 0x820 +#define DINO_PCIROR 0x824 +#define DINO_PCIWOR 0x828 +#define DINO_TLTIM 0x830 + +#define DINO_IRQS 11 /* bits 0-10 are architected */ +#define DINO_IRR_MASK 0x5ff /* only 10 bits are implemented */ +#define DINO_LOCAL_IRQS (DINO_IRQS + 1) +#define DINO_MASK_IRQ(x) (1 << (x)) + +#define PCIINTA 0x001 +#define PCIINTB 0x002 +#define PCIINTC 0x004 +#define PCIINTD 0x008 +#define PCIINTE 0x010 +#define PCIINTF 0x020 +#define GSCEXTINT 0x040 +/* #define xxx 0x080 - bit 7 is "default" */ +/* #define xxx 0x100 - bit 8 not used */ +/* #define xxx 0x200 - bit 9 not used */ +#define RS232INT 0x400 + +#define DINO_MEM_CHUNK_SIZE (8 * MiB) + +#define DINO800_REGS (1 + (DINO_TLTIM - DINO_GMASK) / 4) +static const uint32_t reg800_keep_bits[DINO800_REGS] = { + MAKE_64BIT_MASK(0, 1), /* GMASK */ + MAKE_64BIT_MASK(0, 7), /* PAMR */ + MAKE_64BIT_MASK(0, 7), /* PAPR */ + MAKE_64BIT_MASK(0, 8), /* DAMODE */ + MAKE_64BIT_MASK(0, 7), /* PCICMD */ + MAKE_64BIT_MASK(0, 9), /* PCISTS */ + MAKE_64BIT_MASK(0, 32), /* Undefined */ + MAKE_64BIT_MASK(0, 8), /* MLTIM */ + MAKE_64BIT_MASK(0, 30), /* BRDG_FEAT */ + MAKE_64BIT_MASK(0, 24), /* PCIROR */ + MAKE_64BIT_MASK(0, 22), /* PCIWOR */ + MAKE_64BIT_MASK(0, 32), /* Undocumented */ + MAKE_64BIT_MASK(0, 9), /* TLTIM */ +}; + +struct DinoState { + PCIHostState parent_obj; + + /* + * PCI_CONFIG_ADDR is parent_obj.config_reg, via pci_host_conf_be_ops, + * so that we can map PCI_CONFIG_DATA to pci_host_data_be_ops. + */ + uint32_t config_reg_dino; /* keep original copy, including 2 lowest bits */ + + uint32_t iar0; + uint32_t iar1; + uint32_t imr; + uint32_t ipr; + uint32_t icr; + uint32_t ilr; + uint32_t io_fbb_en; + uint32_t io_addr_en; + uint32_t io_control; + uint32_t toc_addr; + + uint32_t reg800[DINO800_REGS]; + + MemoryRegion this_mem; + MemoryRegion pci_mem; + MemoryRegion pci_mem_alias[32]; + + MemoryRegion *memory_as; + + AddressSpace bm_as; + MemoryRegion bm; + MemoryRegion bm_ram_alias; + MemoryRegion bm_pci_alias; + MemoryRegion bm_cpu_alias; +}; + +#endif diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index 0b18271cc9..9d8b28ec01 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -14,8 +14,6 @@ PCIBus *dino_init(MemoryRegion *, qemu_irq *, qemu_irq *); DeviceState *lasi_init(MemoryRegion *); #define enable_lasi_lan() 0 -#define TYPE_DINO_PCI_HOST_BRIDGE "dino-pcihost" - /* hppa_pci.c. */ extern const MemoryRegionOps hppa_pci_ignore_ops; extern const MemoryRegionOps hppa_pci_conf1_ops; From 0d98fbb57d4facff538a8155d1f3fa1eaf0111f0 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:22 +0100 Subject: [PATCH 12/53] hppa: use new CONFIG_HPPA_B160L option instead of CONFIG_DINO to build hppa machine DINO refers to the GSC-PCI bridge device which will soon be handled separately, however the QEMU HPPA machine is actually based upon the HPPA B160L as indicated by the Linux kernel dmesg output when booted in qemu-system-hppa and the QEMU MAINTAINERS file. Update the machine configuration to use CONFIG_HPPA_B160L instead of CONFIG_DINO and also update the machine description accordingly. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-13-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- configs/devices/hppa-softmmu/default.mak | 2 +- hw/hppa/Kconfig | 2 +- hw/hppa/machine.c | 2 +- hw/hppa/meson.build | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configs/devices/hppa-softmmu/default.mak b/configs/devices/hppa-softmmu/default.mak index b64c5eb3ff..b0364bb88f 100644 --- a/configs/devices/hppa-softmmu/default.mak +++ b/configs/devices/hppa-softmmu/default.mak @@ -6,4 +6,4 @@ # Boards: # -CONFIG_DINO=y +CONFIG_HPPA_B160L=y diff --git a/hw/hppa/Kconfig b/hw/hppa/Kconfig index 22948db025..8d64ead217 100644 --- a/hw/hppa/Kconfig +++ b/hw/hppa/Kconfig @@ -1,4 +1,4 @@ -config DINO +config HPPA_B160L bool imply PCI_DEVICES imply E1000_PCI diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index f7595c0857..971d7ffcfe 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -366,7 +366,7 @@ static void hppa_nmi(NMIState *n, int cpu_index, Error **errp) static void machine_hppa_machine_init(MachineClass *mc) { - mc->desc = "HPPA generic machine"; + mc->desc = "HPPA B160L machine"; mc->default_cpu_type = TYPE_HPPA_CPU; mc->init = machine_hppa_init; mc->reset = hppa_machine_reset; diff --git a/hw/hppa/meson.build b/hw/hppa/meson.build index 1deae83aee..32072bf204 100644 --- a/hw/hppa/meson.build +++ b/hw/hppa/meson.build @@ -1,4 +1,4 @@ hppa_ss = ss.source_set() -hppa_ss.add(when: 'CONFIG_DINO', if_true: files('pci.c', 'machine.c', 'dino.c', 'lasi.c')) +hppa_ss.add(when: 'CONFIG_HPPA_B160L', if_true: files('pci.c', 'machine.c', 'dino.c', 'lasi.c')) hw_arch += {'hppa': hppa_ss} From 05245daf47b7c645d9952b476d63531f6d8aa7f8 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:23 +0100 Subject: [PATCH 13/53] dino: change dino_init() to return the DINO device instead of PCIBus This is in preparation for using more qdev APIs during the configuration of the HPPA generic machine. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-14-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 8 +++----- hw/hppa/hppa_sys.h | 3 ++- hw/hppa/machine.c | 6 ++++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index 01546ff6fc..6c488c908e 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -409,12 +409,11 @@ static void dino_set_serial_irq(void *opaque, int irq, int level) dino_set_irq(opaque, 10, level); } -PCIBus *dino_init(MemoryRegion *addr_space, - qemu_irq *p_rtc_irq, qemu_irq *p_ser_irq) +DinoState *dino_init(MemoryRegion *addr_space, + qemu_irq *p_rtc_irq, qemu_irq *p_ser_irq) { DeviceState *dev; DinoState *s; - PCIBus *pci_bus; dev = qdev_new(TYPE_DINO_PCI_HOST_BRIDGE); object_property_set_link(OBJECT(dev), "memory-as", OBJECT(addr_space), @@ -428,8 +427,7 @@ PCIBus *dino_init(MemoryRegion *addr_space, *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0); *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0); - pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci")); - return pci_bus; + return s; } static void dino_pcihost_reset(DeviceState *dev) diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index 9d8b28ec01..88773d2c35 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -9,8 +9,9 @@ #include "hw/intc/i8259.h" #include "hppa_hardware.h" +#include "dino.h" -PCIBus *dino_init(MemoryRegion *, qemu_irq *, qemu_irq *); +DinoState *dino_init(MemoryRegion *, qemu_irq *, qemu_irq *); DeviceState *lasi_init(MemoryRegion *); #define enable_lasi_lan() 0 diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 971d7ffcfe..94bc1b202a 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -17,6 +17,7 @@ #include "hw/char/serial.h" #include "hw/net/lasi_82596.h" #include "hw/nmi.h" +#include "dino.h" #include "hppa_sys.h" #include "qemu/units.h" #include "qapi/error.h" @@ -126,7 +127,7 @@ static void machine_hppa_init(MachineState *machine) const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; - DeviceState *dev; + DeviceState *dev, *dino_dev; PCIBus *pci_bus; ISABus *isa_bus; qemu_irq rtc_irq, serial_irq; @@ -166,7 +167,8 @@ static void machine_hppa_init(MachineState *machine) lasi_init(addr_space); /* Init Dino (PCI host bus chip). */ - pci_bus = dino_init(addr_space, &rtc_irq, &serial_irq); + dino_dev = DEVICE(dino_init(addr_space, &rtc_irq, &serial_irq)); + pci_bus = PCI_BUS(qdev_get_child_bus(dino_dev, "pci")); assert(pci_bus); /* Create ISA bus. */ From efdb3ce2de8e5d3e27fbb7d403616be71b950130 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:24 +0100 Subject: [PATCH 14/53] machine.c: map DINO device during board configuration Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-15-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 3 --- hw/hppa/machine.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index 6c488c908e..82f301653b 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -421,9 +421,6 @@ DinoState *dino_init(MemoryRegion *addr_space, s = DINO_PCI_HOST_BRIDGE(dev); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - memory_region_add_subregion(addr_space, DINO_HPA, - sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0)); - *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0); *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0); diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 94bc1b202a..5a490a9c37 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -168,6 +168,9 @@ static void machine_hppa_init(MachineState *machine) /* Init Dino (PCI host bus chip). */ dino_dev = DEVICE(dino_init(addr_space, &rtc_irq, &serial_irq)); + memory_region_add_subregion(addr_space, DINO_HPA, + sysbus_mmio_get_region( + SYS_BUS_DEVICE(dino_dev), 0)); pci_bus = PCI_BUS(qdev_get_child_bus(dino_dev, "pci")); assert(pci_bus); From 10c5264172bea2d7f55e013095a80000f00d05c0 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:25 +0100 Subject: [PATCH 15/53] dino.h: add defines for DINO IRQ numbers This is to allow the DINO IRQs to be defined as qdev GPIOs. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-16-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/hppa/dino.h b/hw/hppa/dino.h index 1a26667377..70fb8c52c8 100644 --- a/hw/hppa/dino.h +++ b/hw/hppa/dino.h @@ -58,6 +58,18 @@ OBJECT_DECLARE_SIMPLE_TYPE(DinoState, DINO_PCI_HOST_BRIDGE) #define DINO_LOCAL_IRQS (DINO_IRQS + 1) #define DINO_MASK_IRQ(x) (1 << (x)) +#define DINO_IRQ_PCIINTA 0 +#define DINO_IRQ_PCIINTB 1 +#define DINO_IRQ_PCIINTC 2 +#define DINO_IRQ_PCIINTD 3 +#define DINO_IRQ_PCIINTE 4 +#define DINO_IRQ_PCIINTF 5 +#define DINO_IRQ_GSCEXTINT 6 +#define DINO_IRQ_BUSERRINT 7 +#define DINO_IRQ_PS2INT 8 +#define DINO_IRQ_UNUSED 9 +#define DINO_IRQ_RS232INT 10 + #define PCIINTA 0x001 #define PCIINTB 0x002 #define PCIINTC 0x004 From 4b5faaf94ff3cf47a6c63393ed1332ef4928dadf Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:26 +0100 Subject: [PATCH 16/53] dino: define IRQ inputs as qdev GPIOs Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-17-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 2 ++ hw/hppa/dino.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index 82f301653b..f58aebf94d 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -513,6 +513,8 @@ static void dino_pcihost_init(Object *obj) pci_setup_iommu(phb->bus, dino_pcihost_set_iommu, s); sysbus_init_mmio(sbd, &s->this_mem); + + qdev_init_gpio_in(DEVICE(obj), dino_set_irq, DINO_IRQS); } static Property dino_pcihost_properties[] = { diff --git a/hw/hppa/dino.h b/hw/hppa/dino.h index 70fb8c52c8..ca380515f2 100644 --- a/hw/hppa/dino.h +++ b/hw/hppa/dino.h @@ -134,6 +134,8 @@ struct DinoState { MemoryRegion bm_ram_alias; MemoryRegion bm_pci_alias; MemoryRegion bm_cpu_alias; + + qemu_irq irqs[DINO_IRQS]; }; #endif From a4b74c1924b79b91ca6aeb20cdd39156b5c7b4f7 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:27 +0100 Subject: [PATCH 17/53] dino: wire up serial IRQ using a qdev GPIO in machine.c This makes it unnecessary to allocate a separate IRQ for the serial port. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-18-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 8 +------- hw/hppa/hppa_sys.h | 2 +- hw/hppa/machine.c | 7 ++++--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index f58aebf94d..80ffe27188 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -404,13 +404,8 @@ static void dino_set_timer_irq(void *opaque, int irq, int level) /* ??? Not connected. */ } -static void dino_set_serial_irq(void *opaque, int irq, int level) -{ - dino_set_irq(opaque, 10, level); -} - DinoState *dino_init(MemoryRegion *addr_space, - qemu_irq *p_rtc_irq, qemu_irq *p_ser_irq) + qemu_irq *p_rtc_irq) { DeviceState *dev; DinoState *s; @@ -422,7 +417,6 @@ DinoState *dino_init(MemoryRegion *addr_space, sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0); - *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0); return s; } diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index 88773d2c35..c238e7ebc8 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -11,7 +11,7 @@ #include "hppa_hardware.h" #include "dino.h" -DinoState *dino_init(MemoryRegion *, qemu_irq *, qemu_irq *); +DinoState *dino_init(MemoryRegion *, qemu_irq *); DeviceState *lasi_init(MemoryRegion *); #define enable_lasi_lan() 0 diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 5a490a9c37..f757aecda0 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -130,7 +130,7 @@ static void machine_hppa_init(MachineState *machine) DeviceState *dev, *dino_dev; PCIBus *pci_bus; ISABus *isa_bus; - qemu_irq rtc_irq, serial_irq; + qemu_irq rtc_irq; char *firmware_filename; uint64_t firmware_low, firmware_high; long size; @@ -167,7 +167,7 @@ static void machine_hppa_init(MachineState *machine) lasi_init(addr_space); /* Init Dino (PCI host bus chip). */ - dino_dev = DEVICE(dino_init(addr_space, &rtc_irq, &serial_irq)); + dino_dev = DEVICE(dino_init(addr_space, &rtc_irq)); memory_region_add_subregion(addr_space, DINO_HPA, sysbus_mmio_get_region( SYS_BUS_DEVICE(dino_dev), 0)); @@ -184,7 +184,8 @@ static void machine_hppa_init(MachineState *machine) /* Serial code setup. */ if (serial_hd(0)) { uint32_t addr = DINO_UART_HPA + 0x800; - serial_mm_init(addr_space, addr, 0, serial_irq, + serial_mm_init(addr_space, addr, 0, + qdev_get_gpio_in(dino_dev, DINO_IRQ_RS232INT), 115200, serial_hd(0), DEVICE_BIG_ENDIAN); } From 36f9bbdb1717eeb9b10cbfa3135c942c43d13d25 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:28 +0100 Subject: [PATCH 18/53] dino: remove unused dino_set_timer_irq() IRQ handler According to the comments in dino.c the timer IRQ is unused, so remove the empty dino_set_timer_irq() handler function and simply pass NULL to mc146818_rtc_init() in machine.c instead. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-19-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 10 +--------- hw/hppa/hppa_sys.h | 2 +- hw/hppa/machine.c | 5 ++--- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index 80ffe27188..d8baf139d6 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -399,13 +399,7 @@ static int dino_pci_map_irq(PCIDevice *d, int irq_num) return slot & 0x03; } -static void dino_set_timer_irq(void *opaque, int irq, int level) -{ - /* ??? Not connected. */ -} - -DinoState *dino_init(MemoryRegion *addr_space, - qemu_irq *p_rtc_irq) +DinoState *dino_init(MemoryRegion *addr_space) { DeviceState *dev; DinoState *s; @@ -416,8 +410,6 @@ DinoState *dino_init(MemoryRegion *addr_space, s = DINO_PCI_HOST_BRIDGE(dev); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0); - return s; } diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index c238e7ebc8..ebedecf1c8 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -11,7 +11,7 @@ #include "hppa_hardware.h" #include "dino.h" -DinoState *dino_init(MemoryRegion *, qemu_irq *); +DinoState *dino_init(MemoryRegion *); DeviceState *lasi_init(MemoryRegion *); #define enable_lasi_lan() 0 diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index f757aecda0..49ecb971be 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -130,7 +130,6 @@ static void machine_hppa_init(MachineState *machine) DeviceState *dev, *dino_dev; PCIBus *pci_bus; ISABus *isa_bus; - qemu_irq rtc_irq; char *firmware_filename; uint64_t firmware_low, firmware_high; long size; @@ -167,7 +166,7 @@ static void machine_hppa_init(MachineState *machine) lasi_init(addr_space); /* Init Dino (PCI host bus chip). */ - dino_dev = DEVICE(dino_init(addr_space, &rtc_irq)); + dino_dev = DEVICE(dino_init(addr_space)); memory_region_add_subregion(addr_space, DINO_HPA, sysbus_mmio_get_region( SYS_BUS_DEVICE(dino_dev), 0)); @@ -179,7 +178,7 @@ static void machine_hppa_init(MachineState *machine) assert(isa_bus); /* Realtime clock, used by firmware for PDC_TOD call. */ - mc146818_rtc_init(isa_bus, 2000, rtc_irq); + mc146818_rtc_init(isa_bus, 2000, NULL); /* Serial code setup. */ if (serial_hd(0)) { From 0d068996310c33c2f40dd347746304054fdfa16d Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:29 +0100 Subject: [PATCH 19/53] hppa: move dino_init() from dino.c to machine.c Now that dino_init() is completely decoupled from dino.c it can be moved to machine.c with the rest of the board configuration. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-20-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 14 -------------- hw/hppa/hppa_sys.h | 2 -- hw/hppa/machine.c | 12 ++++++++++++ 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index d8baf139d6..6d12c385aa 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -399,20 +399,6 @@ static int dino_pci_map_irq(PCIDevice *d, int irq_num) return slot & 0x03; } -DinoState *dino_init(MemoryRegion *addr_space) -{ - DeviceState *dev; - DinoState *s; - - dev = qdev_new(TYPE_DINO_PCI_HOST_BRIDGE); - object_property_set_link(OBJECT(dev), "memory-as", OBJECT(addr_space), - &error_fatal); - s = DINO_PCI_HOST_BRIDGE(dev); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - - return s; -} - static void dino_pcihost_reset(DeviceState *dev) { DinoState *s = DINO_PCI_HOST_BRIDGE(dev); diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index ebedecf1c8..7c31dd8396 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -9,9 +9,7 @@ #include "hw/intc/i8259.h" #include "hppa_hardware.h" -#include "dino.h" -DinoState *dino_init(MemoryRegion *); DeviceState *lasi_init(MemoryRegion *); #define enable_lasi_lan() 0 diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 49ecb971be..4b753fa346 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -122,6 +122,18 @@ static FWCfgState *create_fw_cfg(MachineState *ms) return fw_cfg; } +static DinoState *dino_init(MemoryRegion *addr_space) +{ + DeviceState *dev; + + dev = qdev_new(TYPE_DINO_PCI_HOST_BRIDGE); + object_property_set_link(OBJECT(dev), "memory-as", OBJECT(addr_space), + &error_fatal); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + + return DINO_PCI_HOST_BRIDGE(dev); +} + static void machine_hppa_init(MachineState *machine) { const char *kernel_filename = machine->kernel_filename; From 2fb11c7cac7f6074f42d821cfbff4d7b80b3ab6f Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:30 +0100 Subject: [PATCH 20/53] dino: use numerical constant for iar0 and iar1 reset values This is to allow us to decouple the DINO device from the board logic. The choice of using a hard-coded constant (along with a comment) is to match how this is already done for toc_addr. If it is decided later that these values need to be configurable then they can easily be converted to qdev properties. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-21-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c index 6d12c385aa..aa7f812e22 100644 --- a/hw/hppa/dino.c +++ b/hw/hppa/dino.c @@ -403,7 +403,7 @@ static void dino_pcihost_reset(DeviceState *dev) { DinoState *s = DINO_PCI_HOST_BRIDGE(dev); - s->iar0 = s->iar1 = CPU_HPA + 3; + s->iar0 = s->iar1 = 0xFFFB0000 + 3; /* CPU_HPA + 3 */ s->toc_addr = 0xFFFA0030; /* IO_COMMAND of CPU */ } From e111f288d9264dae070bd144a60f43162e34a7be Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:31 +0100 Subject: [PATCH 21/53] dino: move DINO HPA constants from hppa_hardware.h to dino.h This is to allow us to decouple the DINO device from the board logic. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-22-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/dino.h | 5 +++++ hw/hppa/hppa_hardware.h | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/hppa/dino.h b/hw/hppa/dino.h index ca380515f2..a1b0184940 100644 --- a/hw/hppa/dino.h +++ b/hw/hppa/dino.h @@ -101,6 +101,11 @@ static const uint32_t reg800_keep_bits[DINO800_REGS] = { MAKE_64BIT_MASK(0, 9), /* TLTIM */ }; +/* offsets to DINO HPA: */ +#define DINO_PCI_ADDR 0x064 +#define DINO_CONFIG_DATA 0x068 +#define DINO_IO_DATA 0x06c + struct DinoState { PCIHostState parent_obj; diff --git a/hw/hppa/hppa_hardware.h b/hw/hppa/hppa_hardware.h index 5edf577563..8b6b9222cb 100644 --- a/hw/hppa/hppa_hardware.h +++ b/hw/hppa/hppa_hardware.h @@ -30,11 +30,6 @@ #define PCI_HPA DINO_HPA /* PCI bus */ #define IDE_HPA 0xf9000000 /* Boot disc controller */ -/* offsets to DINO HPA: */ -#define DINO_PCI_ADDR 0x064 -#define DINO_CONFIG_DATA 0x068 -#define DINO_IO_DATA 0x06c - #define PORT_PCI_CMD (PCI_HPA + DINO_PCI_ADDR) #define PORT_PCI_DATA (PCI_HPA + DINO_CONFIG_DATA) From 0db9350e6e5aba3dc864d36756b01fb0922ad7cb Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:32 +0100 Subject: [PATCH 22/53] dino: move from hw/hppa to hw/pci-host Move the DINO device implementation from hw/hppa to hw/pci-host so that it is located with all the other PCI host bridges. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-23-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- MAINTAINERS | 2 ++ hw/hppa/Kconfig | 2 +- hw/hppa/machine.c | 2 +- hw/hppa/meson.build | 2 +- hw/hppa/trace-events | 5 ----- hw/pci-host/Kconfig | 4 ++++ hw/{hppa => pci-host}/dino.c | 3 +-- hw/pci-host/meson.build | 3 +++ hw/pci-host/trace-events | 5 +++++ {hw/hppa => include/hw/pci-host}/dino.h | 0 10 files changed, 18 insertions(+), 10 deletions(-) rename hw/{hppa => pci-host}/dino.c (99%) rename {hw/hppa => include/hw/pci-host}/dino.h (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 218c9459b6..59210b093a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1113,7 +1113,9 @@ S: Odd Fixes F: configs/devices/hppa-softmmu/default.mak F: hw/hppa/ F: hw/net/*i82596* +F: hw/pci-host/dino.c F: include/hw/net/lasi_82596.h +F: include/hw/pci-host/dino.h F: pc-bios/hppa-firmware.img M68K Machines diff --git a/hw/hppa/Kconfig b/hw/hppa/Kconfig index 8d64ead217..724380ecec 100644 --- a/hw/hppa/Kconfig +++ b/hw/hppa/Kconfig @@ -3,7 +3,7 @@ config HPPA_B160L imply PCI_DEVICES imply E1000_PCI imply VIRTIO_VGA - select PCI + select DINO select SERIAL select ISA_BUS select I8259 diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 4b753fa346..c847febe5d 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -17,7 +17,7 @@ #include "hw/char/serial.h" #include "hw/net/lasi_82596.h" #include "hw/nmi.h" -#include "dino.h" +#include "hw/pci-host/dino.h" #include "hppa_sys.h" #include "qemu/units.h" #include "qapi/error.h" diff --git a/hw/hppa/meson.build b/hw/hppa/meson.build index 32072bf204..a6f9db455c 100644 --- a/hw/hppa/meson.build +++ b/hw/hppa/meson.build @@ -1,4 +1,4 @@ hppa_ss = ss.source_set() -hppa_ss.add(when: 'CONFIG_HPPA_B160L', if_true: files('pci.c', 'machine.c', 'dino.c', 'lasi.c')) +hppa_ss.add(when: 'CONFIG_HPPA_B160L', if_true: files('pci.c', 'machine.c', 'lasi.c')) hw_arch += {'hppa': hppa_ss} diff --git a/hw/hppa/trace-events b/hw/hppa/trace-events index 3f42be9056..871a473771 100644 --- a/hw/hppa/trace-events +++ b/hw/hppa/trace-events @@ -3,11 +3,6 @@ # pci.c hppa_pci_iack_write(void) "" -# dino.c -dino_chip_mem_valid(uint64_t addr, uint32_t val) "access to addr 0x%"PRIx64" is %d" -dino_chip_read(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x" -dino_chip_write(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x" - # lasi.c lasi_chip_mem_valid(uint64_t addr, uint32_t val) "access to addr 0x%"PRIx64" is %d" lasi_chip_read(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x" diff --git a/hw/pci-host/Kconfig b/hw/pci-host/Kconfig index 2b5f7d58cc..38fd2ee8f3 100644 --- a/hw/pci-host/Kconfig +++ b/hw/pci-host/Kconfig @@ -77,3 +77,7 @@ config MV64361 bool select PCI select I8259 + +config DINO + bool + select PCI diff --git a/hw/hppa/dino.c b/hw/pci-host/dino.c similarity index 99% rename from hw/hppa/dino.c rename to hw/pci-host/dino.c index aa7f812e22..f257c24e64 100644 --- a/hw/hppa/dino.c +++ b/hw/pci-host/dino.c @@ -18,9 +18,8 @@ #include "hw/pci/pci.h" #include "hw/pci/pci_bus.h" #include "hw/qdev-properties.h" -#include "dino.h" +#include "hw/pci-host/dino.h" #include "migration/vmstate.h" -#include "hppa_sys.h" #include "trace.h" #include "qom/object.h" diff --git a/hw/pci-host/meson.build b/hw/pci-host/meson.build index 4c4f39c15c..c07596d0d1 100644 --- a/hw/pci-host/meson.build +++ b/hw/pci-host/meson.build @@ -25,6 +25,9 @@ pci_ss.add(when: 'CONFIG_MV64361', if_true: files('mv64361.c')) # ARM devices pci_ss.add(when: 'CONFIG_VERSATILE_PCI', if_true: files('versatile.c')) +# HPPA devices +pci_ss.add(when: 'CONFIG_DINO', if_true: files('dino.c')) + softmmu_ss.add_all(when: 'CONFIG_PCI', if_true: pci_ss) specific_ss.add(when: 'CONFIG_PCI_POWERNV', if_true: files( diff --git a/hw/pci-host/trace-events b/hw/pci-host/trace-events index 6e5d8d3355..437e66ff50 100644 --- a/hw/pci-host/trace-events +++ b/hw/pci-host/trace-events @@ -34,3 +34,8 @@ unin_read(uint64_t addr, uint64_t value) "addr=0x%" PRIx64 " val=0x%"PRIx64 pnv_phb4_xive_notify(uint64_t notif_port, uint64_t data) "notif=@0x%"PRIx64" data=0x%"PRIx64 pnv_phb4_xive_notify_ic(uint64_t addr, uint64_t data) "addr=@0x%"PRIx64" data=0x%"PRIx64 pnv_phb4_xive_notify_abt(uint64_t notif_port, uint64_t data) "notif=@0x%"PRIx64" data=0x%"PRIx64 + +# dino.c +dino_chip_mem_valid(uint64_t addr, uint32_t val) "access to addr 0x%"PRIx64" is %d" +dino_chip_read(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x" +dino_chip_write(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x" diff --git a/hw/hppa/dino.h b/include/hw/pci-host/dino.h similarity index 100% rename from hw/hppa/dino.h rename to include/hw/pci-host/dino.h From 63588da809704c8e674d8ffb01f66597cf5e6150 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:33 +0100 Subject: [PATCH 23/53] lasi: checkpatch fixes Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-24-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 88c3791eb6..3b77fba1c6 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -169,10 +169,11 @@ static MemTxResult lasi_chip_write_with_attrs(void *opaque, hwaddr addr, break; case LASI_IMR: s->imr = val; - if (((val & LASI_IRQ_BITS) != val) && (val != 0xffffffff)) + if (((val & LASI_IRQ_BITS) != val) && (val != 0xffffffff)) { qemu_log_mask(LOG_GUEST_ERROR, "LASI: tried to set invalid %lx IMR value.\n", (unsigned long) val); + } break; case LASI_IPR: /* Any write to IPR clears the register. */ @@ -200,8 +201,9 @@ static MemTxResult lasi_chip_write_with_attrs(void *opaque, hwaddr addr, break; case LASI_PCR: - if (val == 0x02) /* immediately power off */ + if (val == 0x02) { /* immediately power off */ qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + } break; case LASI_ERRLOG: s->errlog = val; From 46f2594cfca9e888531a5d45a1e33d5446f75578 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:34 +0100 Subject: [PATCH 24/53] lasi: move memory region initialisation to new lasi_init() function Create a new lasi_init() instance initialisation function and move the LASI memory region initialisation into it. Rename the existing lasi_init() function to lasi_initfn() for now. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-25-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/hppa_sys.h | 2 +- hw/hppa/lasi.c | 13 ++++++++++--- hw/hppa/machine.c | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index 7c31dd8396..0929dedded 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -10,7 +10,7 @@ #include "hppa_hardware.h" -DeviceState *lasi_init(MemoryRegion *); +DeviceState *lasi_initfn(MemoryRegion *); #define enable_lasi_lan() 0 /* hppa_pci.c. */ diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 3b77fba1c6..c028b7786e 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -296,7 +296,7 @@ static int lasi_get_irq(unsigned long hpa) } } -DeviceState *lasi_init(MemoryRegion *address_space) +DeviceState *lasi_initfn(MemoryRegion *address_space) { DeviceState *dev; LasiState *s; @@ -306,8 +306,6 @@ DeviceState *lasi_init(MemoryRegion *address_space) s->iar = CPU_HPA + 3; /* Lasi access from main memory. */ - memory_region_init_io(&s->this_mem, OBJECT(s), &lasi_chip_ops, - s, "lasi", 0x100000); memory_region_add_subregion(address_space, LASI_HPA, &s->this_mem); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); @@ -347,6 +345,14 @@ DeviceState *lasi_init(MemoryRegion *address_space) return dev; } +static void lasi_init(Object *obj) +{ + LasiState *s = LASI_CHIP(obj); + + memory_region_init_io(&s->this_mem, OBJECT(s), &lasi_chip_ops, + s, "lasi", 0x100000); +} + static void lasi_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -357,6 +363,7 @@ static void lasi_class_init(ObjectClass *klass, void *data) static const TypeInfo lasi_pcihost_info = { .name = TYPE_LASI_CHIP, .parent = TYPE_SYS_BUS_DEVICE, + .instance_init = lasi_init, .instance_size = sizeof(LasiState), .class_init = lasi_class_init, }; diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index c847febe5d..2fa55de549 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -175,7 +175,7 @@ static void machine_hppa_init(MachineState *machine) /* Init Lasi chip */ - lasi_init(addr_space); + lasi_initfn(addr_space); /* Init Dino (PCI host bus chip). */ dino_dev = DEVICE(dino_init(addr_space)); From 2683758c7c48718d032ed8bffdeb2c37f3a357c8 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:35 +0100 Subject: [PATCH 25/53] lasi: move register memory mapping from lasi.c to machine.c The device register should be mapped directly by the board code. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-26-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 7 +++---- hw/hppa/machine.c | 7 +++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index c028b7786e..08ebe7c6d9 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -304,10 +304,6 @@ DeviceState *lasi_initfn(MemoryRegion *address_space) dev = qdev_new(TYPE_LASI_CHIP); s = LASI_CHIP(dev); s->iar = CPU_HPA + 3; - - /* Lasi access from main memory. */ - memory_region_add_subregion(address_space, LASI_HPA, &s->this_mem); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); /* LAN */ @@ -348,9 +344,12 @@ DeviceState *lasi_initfn(MemoryRegion *address_space) static void lasi_init(Object *obj) { LasiState *s = LASI_CHIP(obj); + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); memory_region_init_io(&s->this_mem, OBJECT(s), &lasi_chip_ops, s, "lasi", 0x100000); + + sysbus_init_mmio(sbd, &s->this_mem); } static void lasi_class_init(ObjectClass *klass, void *data) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 2fa55de549..6618bce435 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -139,7 +139,7 @@ static void machine_hppa_init(MachineState *machine) const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; - DeviceState *dev, *dino_dev; + DeviceState *dev, *dino_dev, *lasi_dev; PCIBus *pci_bus; ISABus *isa_bus; char *firmware_filename; @@ -175,7 +175,10 @@ static void machine_hppa_init(MachineState *machine) /* Init Lasi chip */ - lasi_initfn(addr_space); + lasi_dev = lasi_initfn(addr_space); + memory_region_add_subregion(addr_space, LASI_HPA, + sysbus_mmio_get_region( + SYS_BUS_DEVICE(lasi_dev), 0)); /* Init Dino (PCI host bus chip). */ dino_dev = DEVICE(dino_init(addr_space)); From b3cdb7e4b29a4f1824ff6c1c12ddcf65857bfb9e Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:36 +0100 Subject: [PATCH 26/53] lasi: move initialisation of iar and rtc to new lasi_reset() function Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-27-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 08ebe7c6d9..242713c7bd 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -303,7 +303,6 @@ DeviceState *lasi_initfn(MemoryRegion *address_space) dev = qdev_new(TYPE_LASI_CHIP); s = LASI_CHIP(dev); - s->iar = CPU_HPA + 3; sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); /* LAN */ @@ -319,11 +318,6 @@ DeviceState *lasi_initfn(MemoryRegion *address_space) parallel_mm_init(address_space, LASI_LPT_HPA + 0x800, 0, lpt_irq, parallel_hds[0]); - /* Real time clock (RTC), it's only one 32-bit counter @9000 */ - - s->rtc = time(NULL); - s->rtc_ref = 0; - if (serial_hd(1)) { /* Serial port */ qemu_irq serial_irq = qemu_allocate_irq(lasi_set_irq, s, @@ -341,6 +335,17 @@ DeviceState *lasi_initfn(MemoryRegion *address_space) return dev; } +static void lasi_reset(DeviceState *dev) +{ + LasiState *s = LASI_CHIP(dev); + + s->iar = CPU_HPA + 3; + + /* Real time clock (RTC), it's only one 32-bit counter @9000 */ + s->rtc = time(NULL); + s->rtc_ref = 0; +} + static void lasi_init(Object *obj) { LasiState *s = LASI_CHIP(obj); @@ -356,6 +361,7 @@ static void lasi_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + dc->reset = lasi_reset; dc->vmsd = &vmstate_lasi; } From b514f432445608c516cd82a93ae7c761454f17ea Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:37 +0100 Subject: [PATCH 27/53] lasi: move LASIState and associated QOM structures to lasi.h Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-28-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 44 +------------------------------------- hw/hppa/lasi.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 43 deletions(-) create mode 100644 hw/hppa/lasi.h diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 242713c7bd..c1dfd5310f 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -24,50 +24,8 @@ #include "hw/input/lasips2.h" #include "migration/vmstate.h" #include "qom/object.h" +#include "lasi.h" -#define TYPE_LASI_CHIP "lasi-chip" - -#define LASI_IRR 0x00 /* RO */ -#define LASI_IMR 0x04 -#define LASI_IPR 0x08 -#define LASI_ICR 0x0c -#define LASI_IAR 0x10 - -#define LASI_PCR 0x0C000 /* LASI Power Control register */ -#define LASI_ERRLOG 0x0C004 /* LASI Error Logging register */ -#define LASI_VER 0x0C008 /* LASI Version Control register */ -#define LASI_IORESET 0x0C00C /* LASI I/O Reset register */ -#define LASI_AMR 0x0C010 /* LASI Arbitration Mask register */ -#define LASI_IO_CONF 0x7FFFE /* LASI primary configuration register */ -#define LASI_IO_CONF2 0x7FFFF /* LASI secondary configuration register */ - -#define LASI_BIT(x) (1ul << (x)) -#define LASI_IRQ_BITS (LASI_BIT(5) | LASI_BIT(7) | LASI_BIT(8) | LASI_BIT(9) \ - | LASI_BIT(13) | LASI_BIT(14) | LASI_BIT(16) | LASI_BIT(17) \ - | LASI_BIT(18) | LASI_BIT(19) | LASI_BIT(20) | LASI_BIT(21) \ - | LASI_BIT(26)) - -#define ICR_BUS_ERROR_BIT LASI_BIT(8) /* bit 8 in ICR */ -#define ICR_TOC_BIT LASI_BIT(1) /* bit 1 in ICR */ - -OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP) - -struct LasiState { - PCIHostState parent_obj; - - uint32_t irr; - uint32_t imr; - uint32_t ipr; - uint32_t icr; - uint32_t iar; - - uint32_t errlog; - uint32_t amr; - uint32_t rtc; - time_t rtc_ref; - - MemoryRegion this_mem; -}; static bool lasi_chip_mem_valid(void *opaque, hwaddr addr, unsigned size, bool is_write, diff --git a/hw/hppa/lasi.h b/hw/hppa/lasi.h new file mode 100644 index 0000000000..559aae2560 --- /dev/null +++ b/hw/hppa/lasi.h @@ -0,0 +1,58 @@ +/* + * HP-PARISC Lasi chipset emulation. + * + * (C) 2019 by Helge Deller + * + * This work is licensed under the GNU GPL license version 2 or later. + * + * Documentation available at: + * https://parisc.wiki.kernel.org/images-parisc/7/79/Lasi_ers.pdf + */ + +#ifndef LASI_H +#define LASI_H + +#define TYPE_LASI_CHIP "lasi-chip" +OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP) + +#define LASI_IRR 0x00 /* RO */ +#define LASI_IMR 0x04 +#define LASI_IPR 0x08 +#define LASI_ICR 0x0c +#define LASI_IAR 0x10 + +#define LASI_PCR 0x0C000 /* LASI Power Control register */ +#define LASI_ERRLOG 0x0C004 /* LASI Error Logging register */ +#define LASI_VER 0x0C008 /* LASI Version Control register */ +#define LASI_IORESET 0x0C00C /* LASI I/O Reset register */ +#define LASI_AMR 0x0C010 /* LASI Arbitration Mask register */ +#define LASI_IO_CONF 0x7FFFE /* LASI primary configuration register */ +#define LASI_IO_CONF2 0x7FFFF /* LASI secondary configuration register */ + +#define LASI_BIT(x) (1ul << (x)) +#define LASI_IRQ_BITS (LASI_BIT(5) | LASI_BIT(7) | LASI_BIT(8) | LASI_BIT(9) \ + | LASI_BIT(13) | LASI_BIT(14) | LASI_BIT(16) | LASI_BIT(17) \ + | LASI_BIT(18) | LASI_BIT(19) | LASI_BIT(20) | LASI_BIT(21) \ + | LASI_BIT(26)) + +#define ICR_BUS_ERROR_BIT LASI_BIT(8) /* bit 8 in ICR */ +#define ICR_TOC_BIT LASI_BIT(1) /* bit 1 in ICR */ + +struct LasiState { + PCIHostState parent_obj; + + uint32_t irr; + uint32_t imr; + uint32_t ipr; + uint32_t icr; + uint32_t iar; + + uint32_t errlog; + uint32_t amr; + uint32_t rtc; + time_t rtc_ref; + + MemoryRegion this_mem; +}; + +#endif From 0f04d5777b7c3b1fe260838f3c1f05a6c6452a8d Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:38 +0100 Subject: [PATCH 28/53] lasi: replace lasi_get_irq() with defined constants Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-29-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 31 ++++--------------------------- hw/hppa/lasi.h | 9 +++++++++ 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index c1dfd5310f..ec079601a1 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -231,29 +231,6 @@ static void lasi_set_irq(void *opaque, int irq, int level) } } -static int lasi_get_irq(unsigned long hpa) -{ - switch (hpa) { - case LASI_HPA: - return 14; - case LASI_UART_HPA: - return 5; - case LASI_LPT_HPA: - return 7; - case LASI_LAN_HPA: - return 8; - case LASI_SCSI_HPA: - return 9; - case LASI_AUDIO_HPA: - return 13; - case LASI_PS2KBD_HPA: - case LASI_PS2MOU_HPA: - return 26; - default: - g_assert_not_reached(); - } -} - DeviceState *lasi_initfn(MemoryRegion *address_space) { DeviceState *dev; @@ -266,20 +243,20 @@ DeviceState *lasi_initfn(MemoryRegion *address_space) /* LAN */ if (enable_lasi_lan()) { qemu_irq lan_irq = qemu_allocate_irq(lasi_set_irq, s, - lasi_get_irq(LASI_LAN_HPA)); + LASI_IRQ_LAN_HPA); lasi_82596_init(address_space, LASI_LAN_HPA, lan_irq); } /* Parallel port */ qemu_irq lpt_irq = qemu_allocate_irq(lasi_set_irq, s, - lasi_get_irq(LASI_LPT_HPA)); + LASI_IRQ_LPT_HPA); parallel_mm_init(address_space, LASI_LPT_HPA + 0x800, 0, lpt_irq, parallel_hds[0]); if (serial_hd(1)) { /* Serial port */ qemu_irq serial_irq = qemu_allocate_irq(lasi_set_irq, s, - lasi_get_irq(LASI_UART_HPA)); + LASI_IRQ_UART_HPA); serial_mm_init(address_space, LASI_UART_HPA + 0x800, 0, serial_irq, 8000000 / 16, serial_hd(0), DEVICE_NATIVE_ENDIAN); @@ -287,7 +264,7 @@ DeviceState *lasi_initfn(MemoryRegion *address_space) /* PS/2 Keyboard/Mouse */ qemu_irq ps2kbd_irq = qemu_allocate_irq(lasi_set_irq, s, - lasi_get_irq(LASI_PS2KBD_HPA)); + LASI_IRQ_PS2KBD_HPA); lasips2_init(address_space, LASI_PS2KBD_HPA, ps2kbd_irq); return dev; diff --git a/hw/hppa/lasi.h b/hw/hppa/lasi.h index 559aae2560..f40546da6e 100644 --- a/hw/hppa/lasi.h +++ b/hw/hppa/lasi.h @@ -38,6 +38,15 @@ OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP) #define ICR_BUS_ERROR_BIT LASI_BIT(8) /* bit 8 in ICR */ #define ICR_TOC_BIT LASI_BIT(1) /* bit 1 in ICR */ +#define LASI_IRQ_HPA 14 +#define LASI_IRQ_UART_HPA 5 +#define LASI_IRQ_LPT_HPA 7 +#define LASI_IRQ_LAN_HPA 8 +#define LASI_IRQ_SCSI_HPA 9 +#define LASI_IRQ_AUDIO_HPA 13 +#define LASI_IRQ_PS2KBD_HPA 26 +#define LASI_IRQ_PS2MOU_HPA 26 + struct LasiState { PCIHostState parent_obj; From cb9f6c4b65d48717be251dcb2a171152d00885e9 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:39 +0100 Subject: [PATCH 29/53] lasi: define IRQ inputs as qdev GPIOs Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-30-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 2 ++ hw/hppa/lasi.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index ec079601a1..9489a80bad 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -290,6 +290,8 @@ static void lasi_init(Object *obj) s, "lasi", 0x100000); sysbus_init_mmio(sbd, &s->this_mem); + + qdev_init_gpio_in(DEVICE(obj), lasi_set_irq, LASI_IRQS); } static void lasi_class_init(ObjectClass *klass, void *data) diff --git a/hw/hppa/lasi.h b/hw/hppa/lasi.h index f40546da6e..63a2be3740 100644 --- a/hw/hppa/lasi.h +++ b/hw/hppa/lasi.h @@ -38,6 +38,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP) #define ICR_BUS_ERROR_BIT LASI_BIT(8) /* bit 8 in ICR */ #define ICR_TOC_BIT LASI_BIT(1) /* bit 1 in ICR */ +#define LASI_IRQS 27 + #define LASI_IRQ_HPA 14 #define LASI_IRQ_UART_HPA 5 #define LASI_IRQ_LPT_HPA 7 From e004499fd52f0bb10e1e77bedc3be0dbdd2e0f52 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:40 +0100 Subject: [PATCH 30/53] lasi: use qdev GPIOs to wire up IRQs in lasi_initfn() Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-31-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 9489a80bad..32c7514d3a 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -234,38 +234,31 @@ static void lasi_set_irq(void *opaque, int irq, int level) DeviceState *lasi_initfn(MemoryRegion *address_space) { DeviceState *dev; - LasiState *s; dev = qdev_new(TYPE_LASI_CHIP); - s = LASI_CHIP(dev); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); /* LAN */ if (enable_lasi_lan()) { - qemu_irq lan_irq = qemu_allocate_irq(lasi_set_irq, s, - LASI_IRQ_LAN_HPA); - lasi_82596_init(address_space, LASI_LAN_HPA, lan_irq); + lasi_82596_init(address_space, LASI_LAN_HPA, + qdev_get_gpio_in(dev, LASI_IRQ_LAN_HPA)); } /* Parallel port */ - qemu_irq lpt_irq = qemu_allocate_irq(lasi_set_irq, s, - LASI_IRQ_LPT_HPA); parallel_mm_init(address_space, LASI_LPT_HPA + 0x800, 0, - lpt_irq, parallel_hds[0]); + qdev_get_gpio_in(dev, LASI_IRQ_LAN_HPA), + parallel_hds[0]); if (serial_hd(1)) { /* Serial port */ - qemu_irq serial_irq = qemu_allocate_irq(lasi_set_irq, s, - LASI_IRQ_UART_HPA); serial_mm_init(address_space, LASI_UART_HPA + 0x800, 0, - serial_irq, 8000000 / 16, + qdev_get_gpio_in(dev, LASI_IRQ_UART_HPA), 8000000 / 16, serial_hd(0), DEVICE_NATIVE_ENDIAN); } /* PS/2 Keyboard/Mouse */ - qemu_irq ps2kbd_irq = qemu_allocate_irq(lasi_set_irq, s, - LASI_IRQ_PS2KBD_HPA); - lasips2_init(address_space, LASI_PS2KBD_HPA, ps2kbd_irq); + lasips2_init(address_space, LASI_PS2KBD_HPA, + qdev_get_gpio_in(dev, LASI_IRQ_PS2KBD_HPA)); return dev; } From fe744ca3eee65e5d666a06e72c1e6b671eb2c74a Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:41 +0100 Subject: [PATCH 31/53] lasi: fix serial port initialisation The existing code checks for serial_hd(1) but sets the LASI serial port chardev to serial_hd(0). Use serial_hd(1) for the LASI serial port and also set the serial port endian to DEVICE_BIG_ENDIAN (which also matches the endian of the existing serial port). Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-32-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 32c7514d3a..219eb779f3 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -253,7 +253,7 @@ DeviceState *lasi_initfn(MemoryRegion *address_space) /* Serial port */ serial_mm_init(address_space, LASI_UART_HPA + 0x800, 0, qdev_get_gpio_in(dev, LASI_IRQ_UART_HPA), 8000000 / 16, - serial_hd(0), DEVICE_NATIVE_ENDIAN); + serial_hd(1), DEVICE_BIG_ENDIAN); } /* PS/2 Keyboard/Mouse */ From 954f6f7564ef48688d2146e498cb012605d461c6 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:42 +0100 Subject: [PATCH 32/53] lasi: update lasi_initfn() to return LASIState Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-33-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/hppa_sys.h | 3 ++- hw/hppa/lasi.c | 4 ++-- hw/hppa/machine.c | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index 0929dedded..3832b787d1 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -7,10 +7,11 @@ #include "hw/pci/pci_host.h" #include "hw/boards.h" #include "hw/intc/i8259.h" +#include "lasi.h" #include "hppa_hardware.h" -DeviceState *lasi_initfn(MemoryRegion *); +LasiState *lasi_initfn(MemoryRegion *); #define enable_lasi_lan() 0 /* hppa_pci.c. */ diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 219eb779f3..65139bb29b 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -231,7 +231,7 @@ static void lasi_set_irq(void *opaque, int irq, int level) } } -DeviceState *lasi_initfn(MemoryRegion *address_space) +LasiState *lasi_initfn(MemoryRegion *address_space) { DeviceState *dev; @@ -260,7 +260,7 @@ DeviceState *lasi_initfn(MemoryRegion *address_space) lasips2_init(address_space, LASI_PS2KBD_HPA, qdev_get_gpio_in(dev, LASI_IRQ_PS2KBD_HPA)); - return dev; + return LASI_CHIP(dev); } static void lasi_reset(DeviceState *dev) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 6618bce435..c815dde305 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -18,6 +18,7 @@ #include "hw/net/lasi_82596.h" #include "hw/nmi.h" #include "hw/pci-host/dino.h" +#include "lasi.h" #include "hppa_sys.h" #include "qemu/units.h" #include "qapi/error.h" @@ -175,7 +176,7 @@ static void machine_hppa_init(MachineState *machine) /* Init Lasi chip */ - lasi_dev = lasi_initfn(addr_space); + lasi_dev = DEVICE(lasi_initfn(addr_space)); memory_region_add_subregion(addr_space, LASI_HPA, sysbus_mmio_get_region( SYS_BUS_DEVICE(lasi_dev), 0)); From c3c3fe47086221de21cc387ef4c876f316463876 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:43 +0100 Subject: [PATCH 33/53] lasi: move LAN initialisation to machine.c Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-34-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 7 ------- hw/hppa/machine.c | 5 +++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 65139bb29b..88ff9141e4 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -18,7 +18,6 @@ #include "sysemu/sysemu.h" #include "sysemu/runstate.h" #include "hppa_sys.h" -#include "hw/net/lasi_82596.h" #include "hw/char/parallel.h" #include "hw/char/serial.h" #include "hw/input/lasips2.h" @@ -238,12 +237,6 @@ LasiState *lasi_initfn(MemoryRegion *address_space) dev = qdev_new(TYPE_LASI_CHIP); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - /* LAN */ - if (enable_lasi_lan()) { - lasi_82596_init(address_space, LASI_LAN_HPA, - qdev_get_gpio_in(dev, LASI_IRQ_LAN_HPA)); - } - /* Parallel port */ parallel_mm_init(address_space, LASI_LPT_HPA + 0x800, 0, qdev_get_gpio_in(dev, LASI_IRQ_LAN_HPA), diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index c815dde305..b3b4a00ad6 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -221,6 +221,11 @@ static void machine_hppa_init(MachineState *machine) } /* Network setup. */ + if (enable_lasi_lan()) { + lasi_82596_init(addr_space, LASI_LAN_HPA, + qdev_get_gpio_in(lasi_dev, LASI_IRQ_LAN_HPA)); + } + for (i = 0; i < nb_nics; i++) { if (!enable_lasi_lan()) { pci_nic_init_nofail(&nd_table[i], pci_bus, "tulip", NULL); From 9701e56943282ea94876c1e4202ed30ce3a3c706 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:44 +0100 Subject: [PATCH 34/53] lasi: move parallel port initialisation to machine.c Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-35-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 6 ------ hw/hppa/machine.c | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 88ff9141e4..6faa98dca5 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -18,7 +18,6 @@ #include "sysemu/sysemu.h" #include "sysemu/runstate.h" #include "hppa_sys.h" -#include "hw/char/parallel.h" #include "hw/char/serial.h" #include "hw/input/lasips2.h" #include "migration/vmstate.h" @@ -237,11 +236,6 @@ LasiState *lasi_initfn(MemoryRegion *address_space) dev = qdev_new(TYPE_LASI_CHIP); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - /* Parallel port */ - parallel_mm_init(address_space, LASI_LPT_HPA + 0x800, 0, - qdev_get_gpio_in(dev, LASI_IRQ_LAN_HPA), - parallel_hds[0]); - if (serial_hd(1)) { /* Serial port */ serial_mm_init(address_space, LASI_UART_HPA + 0x800, 0, diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index b3b4a00ad6..5244178aaf 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -15,6 +15,7 @@ #include "hw/rtc/mc146818rtc.h" #include "hw/timer/i8254.h" #include "hw/char/serial.h" +#include "hw/char/parallel.h" #include "hw/net/lasi_82596.h" #include "hw/nmi.h" #include "hw/pci-host/dino.h" @@ -204,6 +205,11 @@ static void machine_hppa_init(MachineState *machine) 115200, serial_hd(0), DEVICE_BIG_ENDIAN); } + /* Parallel port */ + parallel_mm_init(addr_space, LASI_LPT_HPA + 0x800, 0, + qdev_get_gpio_in(lasi_dev, LASI_IRQ_LAN_HPA), + parallel_hds[0]); + /* fw_cfg configuration interface */ create_fw_cfg(machine); From 2da547b81968f601ca870ace0a1e1528c4402d09 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:45 +0100 Subject: [PATCH 35/53] lasi: move second serial port initialisation to machine.c Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-36-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 8 -------- hw/hppa/machine.c | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 6faa98dca5..753a08d454 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -18,7 +18,6 @@ #include "sysemu/sysemu.h" #include "sysemu/runstate.h" #include "hppa_sys.h" -#include "hw/char/serial.h" #include "hw/input/lasips2.h" #include "migration/vmstate.h" #include "qom/object.h" @@ -236,13 +235,6 @@ LasiState *lasi_initfn(MemoryRegion *address_space) dev = qdev_new(TYPE_LASI_CHIP); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - if (serial_hd(1)) { - /* Serial port */ - serial_mm_init(address_space, LASI_UART_HPA + 0x800, 0, - qdev_get_gpio_in(dev, LASI_IRQ_UART_HPA), 8000000 / 16, - serial_hd(1), DEVICE_BIG_ENDIAN); - } - /* PS/2 Keyboard/Mouse */ lasips2_init(address_space, LASI_PS2KBD_HPA, qdev_get_gpio_in(dev, LASI_IRQ_PS2KBD_HPA)); diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 5244178aaf..5b43ae2960 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -205,6 +205,13 @@ static void machine_hppa_init(MachineState *machine) 115200, serial_hd(0), DEVICE_BIG_ENDIAN); } + if (serial_hd(1)) { + /* Serial port */ + serial_mm_init(addr_space, LASI_UART_HPA + 0x800, 0, + qdev_get_gpio_in(lasi_dev, LASI_IRQ_UART_HPA), 8000000 / 16, + serial_hd(1), DEVICE_BIG_ENDIAN); + } + /* Parallel port */ parallel_mm_init(addr_space, LASI_LPT_HPA + 0x800, 0, qdev_get_gpio_in(lasi_dev, LASI_IRQ_LAN_HPA), From d26c575c44379d9df7843677c7d59729ffe18764 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:46 +0100 Subject: [PATCH 36/53] lasi: move PS2 initialisation to machine.c Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-37-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 5 ----- hw/hppa/machine.c | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 753a08d454..9d8c9e3936 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -18,7 +18,6 @@ #include "sysemu/sysemu.h" #include "sysemu/runstate.h" #include "hppa_sys.h" -#include "hw/input/lasips2.h" #include "migration/vmstate.h" #include "qom/object.h" #include "lasi.h" @@ -235,10 +234,6 @@ LasiState *lasi_initfn(MemoryRegion *address_space) dev = qdev_new(TYPE_LASI_CHIP); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - /* PS/2 Keyboard/Mouse */ - lasips2_init(address_space, LASI_PS2KBD_HPA, - qdev_get_gpio_in(dev, LASI_IRQ_PS2KBD_HPA)); - return LASI_CHIP(dev); } diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 5b43ae2960..1d48ec341d 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -16,6 +16,7 @@ #include "hw/timer/i8254.h" #include "hw/char/serial.h" #include "hw/char/parallel.h" +#include "hw/input/lasips2.h" #include "hw/net/lasi_82596.h" #include "hw/nmi.h" #include "hw/pci-host/dino.h" @@ -245,6 +246,10 @@ static void machine_hppa_init(MachineState *machine) } } + /* PS/2 Keyboard/Mouse */ + lasips2_init(addr_space, LASI_PS2KBD_HPA, + qdev_get_gpio_in(lasi_dev, LASI_IRQ_PS2KBD_HPA)); + /* register power switch emulation */ qemu_register_powerdown_notifier(&hppa_system_powerdown_notifier); From deaa5d3b4e8eccf4010c9099b99c267ff1f2223e Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:47 +0100 Subject: [PATCH 37/53] lasi: remove address space parameter from lasi_initfn() Now that all of the LASI devices are mapped by the board, this parameter is no longer required. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-38-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/hppa_sys.h | 2 +- hw/hppa/lasi.c | 2 +- hw/hppa/machine.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index 3832b787d1..31e3856059 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -11,7 +11,7 @@ #include "hppa_hardware.h" -LasiState *lasi_initfn(MemoryRegion *); +LasiState *lasi_initfn(void); #define enable_lasi_lan() 0 /* hppa_pci.c. */ diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 9d8c9e3936..81c8e4d2d9 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -227,7 +227,7 @@ static void lasi_set_irq(void *opaque, int irq, int level) } } -LasiState *lasi_initfn(MemoryRegion *address_space) +LasiState *lasi_initfn(void) { DeviceState *dev; diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 1d48ec341d..52f12f6604 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -178,7 +178,7 @@ static void machine_hppa_init(MachineState *machine) /* Init Lasi chip */ - lasi_dev = DEVICE(lasi_initfn(addr_space)); + lasi_dev = DEVICE(lasi_initfn()); memory_region_add_subregion(addr_space, LASI_HPA, sysbus_mmio_get_region( SYS_BUS_DEVICE(lasi_dev), 0)); From e881e3c83a47214d5d5d4141a1bc4ad99486f80a Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:48 +0100 Subject: [PATCH 38/53] lasi: move lasi_initfn() to machine.c Move the simplified lasi_initfn() back to machine.c whilst also renaming it back to its original lasi_init() name. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-39-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/hppa_sys.h | 2 -- hw/hppa/lasi.c | 10 ---------- hw/hppa/machine.c | 12 +++++++++++- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index 31e3856059..f7a127be19 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -7,11 +7,9 @@ #include "hw/pci/pci_host.h" #include "hw/boards.h" #include "hw/intc/i8259.h" -#include "lasi.h" #include "hppa_hardware.h" -LasiState *lasi_initfn(void); #define enable_lasi_lan() 0 /* hppa_pci.c. */ diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 81c8e4d2d9..ad50880a13 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -227,16 +227,6 @@ static void lasi_set_irq(void *opaque, int irq, int level) } } -LasiState *lasi_initfn(void) -{ - DeviceState *dev; - - dev = qdev_new(TYPE_LASI_CHIP); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - - return LASI_CHIP(dev); -} - static void lasi_reset(DeviceState *dev) { LasiState *s = LASI_CHIP(dev); diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 52f12f6604..58b25ca5bc 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -125,6 +125,16 @@ static FWCfgState *create_fw_cfg(MachineState *ms) return fw_cfg; } +static LasiState *lasi_init(void) +{ + DeviceState *dev; + + dev = qdev_new(TYPE_LASI_CHIP); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + + return LASI_CHIP(dev); +} + static DinoState *dino_init(MemoryRegion *addr_space) { DeviceState *dev; @@ -178,7 +188,7 @@ static void machine_hppa_init(MachineState *machine) /* Init Lasi chip */ - lasi_dev = DEVICE(lasi_initfn()); + lasi_dev = DEVICE(lasi_init()); memory_region_add_subregion(addr_space, LASI_HPA, sysbus_mmio_get_region( SYS_BUS_DEVICE(lasi_dev), 0)); From ca7b468be8944d2c166f6b7cf25cd5e8e006bc03 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:49 +0100 Subject: [PATCH 39/53] lasi: use constants for device register offsets Instead of generating the offset based upon the physical address of the register, add constants for each of the device registers to lasi.h and update lasi.c to use them. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-40-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 28 ++++++++++++++-------------- hw/hppa/lasi.h | 5 +++++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index ad50880a13..11ca33fba3 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -36,10 +36,10 @@ static bool lasi_chip_mem_valid(void *opaque, hwaddr addr, case LASI_ICR: case LASI_IAR: - case (LASI_LAN_HPA - LASI_HPA): - case (LASI_LPT_HPA - LASI_HPA): - case (LASI_UART_HPA - LASI_HPA): - case (LASI_RTC_HPA - LASI_HPA): + case LASI_LPT: + case LASI_UART: + case LASI_LAN: + case LASI_RTC: case LASI_PCR ... LASI_AMR: ret = true; @@ -76,12 +76,12 @@ static MemTxResult lasi_chip_read_with_attrs(void *opaque, hwaddr addr, val = s->iar; break; - case (LASI_LAN_HPA - LASI_HPA): - case (LASI_LPT_HPA - LASI_HPA): - case (LASI_UART_HPA - LASI_HPA): + case LASI_LPT: + case LASI_UART: + case LASI_LAN: val = 0; break; - case (LASI_RTC_HPA - LASI_HPA): + case LASI_RTC: val = time(NULL); val += s->rtc_ref; break; @@ -141,16 +141,16 @@ static MemTxResult lasi_chip_write_with_attrs(void *opaque, hwaddr addr, s->iar = val; break; - case (LASI_LAN_HPA - LASI_HPA): - /* XXX: reset LAN card */ - break; - case (LASI_LPT_HPA - LASI_HPA): + case LASI_LPT: /* XXX: reset parallel port */ break; - case (LASI_UART_HPA - LASI_HPA): + case LASI_UART: /* XXX: reset serial port */ break; - case (LASI_RTC_HPA - LASI_HPA): + case LASI_LAN: + /* XXX: reset LAN card */ + break; + case LASI_RTC: s->rtc_ref = val - time(NULL); break; diff --git a/hw/hppa/lasi.h b/hw/hppa/lasi.h index 63a2be3740..11cf7d6b0b 100644 --- a/hw/hppa/lasi.h +++ b/hw/hppa/lasi.h @@ -21,6 +21,11 @@ OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP) #define LASI_ICR 0x0c #define LASI_IAR 0x10 +#define LASI_LPT 0x02000 +#define LASI_UART 0x05000 +#define LASI_LAN 0x07000 +#define LASI_RTC 0x09000 + #define LASI_PCR 0x0C000 /* LASI Power Control register */ #define LASI_ERRLOG 0x0C004 /* LASI Error Logging register */ #define LASI_VER 0x0C008 /* LASI Version Control register */ From 8e81ffe32070490b27d8e9ccac48a3f470e19c96 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:50 +0100 Subject: [PATCH 40/53] lasi: use numerical constant for iar reset value This is to allow us to decouple the LASI device from the board logic. If it is decided later that this value needs to be configurable then it can easily be converted to a qdev property. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-41-mark.cave-ayland@ilande.co.uk> Acked-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/lasi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c index 11ca33fba3..5ef36f3f58 100644 --- a/hw/hppa/lasi.c +++ b/hw/hppa/lasi.c @@ -231,7 +231,7 @@ static void lasi_reset(DeviceState *dev) { LasiState *s = LASI_CHIP(dev); - s->iar = CPU_HPA + 3; + s->iar = 0xFFFB0000 + 3; /* CPU_HPA + 3 */ /* Real time clock (RTC), it's only one 32-bit counter @9000 */ s->rtc = time(NULL); From 134ba73f32036256e0a89bcd166ddbe1fd19b824 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:51 +0100 Subject: [PATCH 41/53] hppa: move device headers from hppa_sys.h into individual .c files Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-42-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/hppa_sys.h | 3 --- hw/hppa/lasi.h | 4 ++++ hw/hppa/machine.c | 2 ++ hw/hppa/pci.c | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index f7a127be19..9964d4a7a7 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -3,10 +3,7 @@ #ifndef HW_HPPA_SYS_H #define HW_HPPA_SYS_H -#include "hw/pci/pci.h" -#include "hw/pci/pci_host.h" #include "hw/boards.h" -#include "hw/intc/i8259.h" #include "hppa_hardware.h" diff --git a/hw/hppa/lasi.h b/hw/hppa/lasi.h index 11cf7d6b0b..ecc7065ce8 100644 --- a/hw/hppa/lasi.h +++ b/hw/hppa/lasi.h @@ -12,6 +12,10 @@ #ifndef LASI_H #define LASI_H +#include "exec/address-spaces.h" +#include "hw/pci/pci_host.h" +#include "hw/boards.h" + #define TYPE_LASI_CHIP "lasi-chip" OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 58b25ca5bc..9d904b7a60 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -16,9 +16,11 @@ #include "hw/timer/i8254.h" #include "hw/char/serial.h" #include "hw/char/parallel.h" +#include "hw/intc/i8259.h" #include "hw/input/lasips2.h" #include "hw/net/lasi_82596.h" #include "hw/nmi.h" +#include "hw/pci/pci.h" #include "hw/pci-host/dino.h" #include "lasi.h" #include "hppa_sys.h" diff --git a/hw/hppa/pci.c b/hw/hppa/pci.c index 32609aba63..a92dcb6b9e 100644 --- a/hw/hppa/pci.c +++ b/hw/hppa/pci.c @@ -6,6 +6,9 @@ #include "qemu/osdep.h" #include "hppa_sys.h" #include "qemu/log.h" +#include "hw/pci/pci.h" +#include "hw/pci/pci_host.h" +#include "hw/intc/i8259.h" #include "trace.h" From 45f569a11666051f98edc678616d135c9feaf506 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:52 +0100 Subject: [PATCH 42/53] lasi: move from hw/hppa to hw/misc Move the LASI device implementation from hw/hppa to hw/misc so that it is located with all the other miscellaneous devices. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-43-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- MAINTAINERS | 2 ++ hw/hppa/Kconfig | 1 + hw/hppa/machine.c | 2 +- hw/hppa/meson.build | 2 +- hw/hppa/trace-events | 5 ----- hw/misc/Kconfig | 3 +++ hw/{hppa => misc}/lasi.c | 3 +-- hw/misc/meson.build | 3 +++ hw/misc/trace-events | 5 +++++ {hw/hppa => include/hw/misc}/lasi.h | 0 10 files changed, 17 insertions(+), 9 deletions(-) rename hw/{hppa => misc}/lasi.c (99%) rename {hw/hppa => include/hw/misc}/lasi.h (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 59210b093a..662ec47246 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1113,7 +1113,9 @@ S: Odd Fixes F: configs/devices/hppa-softmmu/default.mak F: hw/hppa/ F: hw/net/*i82596* +F: hw/misc/lasi.c F: hw/pci-host/dino.c +F: include/hw/misc/lasi.h F: include/hw/net/lasi_82596.h F: include/hw/pci-host/dino.h F: pc-bios/hppa-firmware.img diff --git a/hw/hppa/Kconfig b/hw/hppa/Kconfig index 724380ecec..5dd8b5b21e 100644 --- a/hw/hppa/Kconfig +++ b/hw/hppa/Kconfig @@ -4,6 +4,7 @@ config HPPA_B160L imply E1000_PCI imply VIRTIO_VGA select DINO + select LASI select SERIAL select ISA_BUS select I8259 diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 9d904b7a60..f3d72b4c35 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -22,7 +22,7 @@ #include "hw/nmi.h" #include "hw/pci/pci.h" #include "hw/pci-host/dino.h" -#include "lasi.h" +#include "hw/misc/lasi.h" #include "hppa_sys.h" #include "qemu/units.h" #include "qapi/error.h" diff --git a/hw/hppa/meson.build b/hw/hppa/meson.build index a6f9db455c..bd5a1fb1d2 100644 --- a/hw/hppa/meson.build +++ b/hw/hppa/meson.build @@ -1,4 +1,4 @@ hppa_ss = ss.source_set() -hppa_ss.add(when: 'CONFIG_HPPA_B160L', if_true: files('pci.c', 'machine.c', 'lasi.c')) +hppa_ss.add(when: 'CONFIG_HPPA_B160L', if_true: files('pci.c', 'machine.c')) hw_arch += {'hppa': hppa_ss} diff --git a/hw/hppa/trace-events b/hw/hppa/trace-events index 871a473771..1a4fbe2fa8 100644 --- a/hw/hppa/trace-events +++ b/hw/hppa/trace-events @@ -2,8 +2,3 @@ # pci.c hppa_pci_iack_write(void) "" - -# lasi.c -lasi_chip_mem_valid(uint64_t addr, uint32_t val) "access to addr 0x%"PRIx64" is %d" -lasi_chip_read(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x" -lasi_chip_write(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x" diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 507058d8bf..cbabe9f78c 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -171,4 +171,7 @@ config SIFIVE_U_PRCI config VIRT_CTRL bool +config LASI + bool + source macio/Kconfig diff --git a/hw/hppa/lasi.c b/hw/misc/lasi.c similarity index 99% rename from hw/hppa/lasi.c rename to hw/misc/lasi.c index 5ef36f3f58..23a7634a8c 100644 --- a/hw/hppa/lasi.c +++ b/hw/misc/lasi.c @@ -17,10 +17,9 @@ #include "hw/irq.h" #include "sysemu/sysemu.h" #include "sysemu/runstate.h" -#include "hppa_sys.h" #include "migration/vmstate.h" #include "qom/object.h" -#include "lasi.h" +#include "hw/misc/lasi.h" static bool lasi_chip_mem_valid(void *opaque, hwaddr addr, diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 2ff05c7afa..132b7b7344 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -134,3 +134,6 @@ specific_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_cmgcr.c', 'mips_cp specific_ss.add(when: 'CONFIG_MIPS_ITU', if_true: files('mips_itu.c')) specific_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c')) + +# HPPA devices +softmmu_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c')) diff --git a/hw/misc/trace-events b/hw/misc/trace-events index 4e0c7973a4..c5e37b0154 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -263,3 +263,8 @@ virt_ctrl_write(void *dev, unsigned int addr, unsigned int size, uint64_t value) virt_ctrl_reset(void *dev) "ctrl: %p" virt_ctrl_realize(void *dev) "ctrl: %p" virt_ctrl_instance_init(void *dev) "ctrl: %p" + +# lasi.c +lasi_chip_mem_valid(uint64_t addr, uint32_t val) "access to addr 0x%"PRIx64" is %d" +lasi_chip_read(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x" +lasi_chip_write(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x" diff --git a/hw/hppa/lasi.h b/include/hw/misc/lasi.h similarity index 100% rename from hw/hppa/lasi.h rename to include/hw/misc/lasi.h From 28f5332ae9283fa76f736e9011ae647799b9cdc0 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:53 +0100 Subject: [PATCH 43/53] hppa: move hppa_pci_ignore_ops from pci.c to machine.c The memory region only has one user which is for ensuring accesses to the ISA bus memory do not fault. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-44-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/hppa_sys.h | 1 - hw/hppa/machine.c | 23 +++++++++++++++++++++++ hw/hppa/pci.c | 26 -------------------------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index 9964d4a7a7..d984b2895d 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -10,7 +10,6 @@ #define enable_lasi_lan() 0 /* hppa_pci.c. */ -extern const MemoryRegionOps hppa_pci_ignore_ops; extern const MemoryRegionOps hppa_pci_conf1_ops; extern const MemoryRegionOps hppa_pci_iack_ops; diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index f3d72b4c35..ca595d343e 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -57,6 +57,29 @@ static Notifier hppa_system_powerdown_notifier = { .notify = hppa_powerdown_req }; +/* Fallback for unassigned PCI I/O operations. Avoids MCHK. */ +static uint64_t ignore_read(void *opaque, hwaddr addr, unsigned size) +{ + return 0; +} + +static void ignore_write(void *opaque, hwaddr addr, uint64_t v, unsigned size) +{ +} + +static const MemoryRegionOps hppa_pci_ignore_ops = { + .read = ignore_read, + .write = ignore_write, + .endianness = DEVICE_BIG_ENDIAN, + .valid = { + .min_access_size = 1, + .max_access_size = 8, + }, + .impl = { + .min_access_size = 1, + .max_access_size = 8, + }, +}; static ISABus *hppa_isa_bus(void) { diff --git a/hw/hppa/pci.c b/hw/hppa/pci.c index a92dcb6b9e..4d62d54c22 100644 --- a/hw/hppa/pci.c +++ b/hw/hppa/pci.c @@ -12,32 +12,6 @@ #include "trace.h" -/* Fallback for unassigned PCI I/O operations. Avoids MCHK. */ - -static uint64_t ignore_read(void *opaque, hwaddr addr, unsigned size) -{ - return 0; -} - -static void ignore_write(void *opaque, hwaddr addr, uint64_t v, unsigned size) -{ -} - -const MemoryRegionOps hppa_pci_ignore_ops = { - .read = ignore_read, - .write = ignore_write, - .endianness = DEVICE_BIG_ENDIAN, - .valid = { - .min_access_size = 1, - .max_access_size = 8, - }, - .impl = { - .min_access_size = 1, - .max_access_size = 8, - }, -}; - - /* PCI config space reads/writes, to byte-word addressable memory. */ static uint64_t bw_conf1_read(void *opaque, hwaddr addr, unsigned size) From 3c2ce5bba379aa87a3098bffc06101c8a9544940 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:54 +0100 Subject: [PATCH 44/53] hppa: remove hw/hppa/pci.c The functions and definitions in this file are not used anywhere within the generic hppa machine. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-45-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/hppa_sys.h | 6 ---- hw/hppa/meson.build | 2 +- hw/hppa/pci.c | 65 -------------------------------------------- hw/hppa/trace-events | 3 -- 4 files changed, 1 insertion(+), 75 deletions(-) delete mode 100644 hw/hppa/pci.c diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index d984b2895d..17e2c6dec1 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -3,14 +3,8 @@ #ifndef HW_HPPA_SYS_H #define HW_HPPA_SYS_H -#include "hw/boards.h" - #include "hppa_hardware.h" #define enable_lasi_lan() 0 -/* hppa_pci.c. */ -extern const MemoryRegionOps hppa_pci_conf1_ops; -extern const MemoryRegionOps hppa_pci_iack_ops; - #endif diff --git a/hw/hppa/meson.build b/hw/hppa/meson.build index bd5a1fb1d2..3d0c586c30 100644 --- a/hw/hppa/meson.build +++ b/hw/hppa/meson.build @@ -1,4 +1,4 @@ hppa_ss = ss.source_set() -hppa_ss.add(when: 'CONFIG_HPPA_B160L', if_true: files('pci.c', 'machine.c')) +hppa_ss.add(when: 'CONFIG_HPPA_B160L', if_true: files('machine.c')) hw_arch += {'hppa': hppa_ss} diff --git a/hw/hppa/pci.c b/hw/hppa/pci.c deleted file mode 100644 index 4d62d54c22..0000000000 --- a/hw/hppa/pci.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * QEMU HP-PARISC PCI support functions. - * - */ - -#include "qemu/osdep.h" -#include "hppa_sys.h" -#include "qemu/log.h" -#include "hw/pci/pci.h" -#include "hw/pci/pci_host.h" -#include "hw/intc/i8259.h" -#include "trace.h" - - -/* PCI config space reads/writes, to byte-word addressable memory. */ -static uint64_t bw_conf1_read(void *opaque, hwaddr addr, - unsigned size) -{ - PCIBus *b = opaque; - return pci_data_read(b, addr, size); -} - -static void bw_conf1_write(void *opaque, hwaddr addr, - uint64_t val, unsigned size) -{ - PCIBus *b = opaque; - pci_data_write(b, addr, val, size); -} - -const MemoryRegionOps hppa_pci_conf1_ops = { - .read = bw_conf1_read, - .write = bw_conf1_write, - .endianness = DEVICE_BIG_ENDIAN, - .impl = { - .min_access_size = 1, - .max_access_size = 4, - }, -}; - -/* PCI/EISA Interrupt Acknowledge Cycle. */ - -static uint64_t iack_read(void *opaque, hwaddr addr, unsigned size) -{ - return pic_read_irq(isa_pic); -} - -static void special_write(void *opaque, hwaddr addr, - uint64_t val, unsigned size) -{ - trace_hppa_pci_iack_write(); -} - -const MemoryRegionOps hppa_pci_iack_ops = { - .read = iack_read, - .write = special_write, - .endianness = DEVICE_BIG_ENDIAN, - .valid = { - .min_access_size = 4, - .max_access_size = 4, - }, - .impl = { - .min_access_size = 4, - .max_access_size = 4, - }, -}; diff --git a/hw/hppa/trace-events b/hw/hppa/trace-events index 1a4fbe2fa8..23bc9b19b9 100644 --- a/hw/hppa/trace-events +++ b/hw/hppa/trace-events @@ -1,4 +1 @@ # See docs/devel/tracing.rst for syntax documentation. - -# pci.c -hppa_pci_iack_write(void) "" From 192e32284b15827e056ff504e0eeb19c2e164759 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:55 +0100 Subject: [PATCH 45/53] hppa: remove unused trace-events from from hw/hppa Now that there are no longer any devices in hw/hppa the trace-events file is empty and can be removed. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-46-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/trace-events | 1 - meson.build | 1 - 2 files changed, 2 deletions(-) delete mode 100644 hw/hppa/trace-events diff --git a/hw/hppa/trace-events b/hw/hppa/trace-events deleted file mode 100644 index 23bc9b19b9..0000000000 --- a/hw/hppa/trace-events +++ /dev/null @@ -1 +0,0 @@ -# See docs/devel/tracing.rst for syntax documentation. diff --git a/meson.build b/meson.build index 40132b4804..fa672e57bc 100644 --- a/meson.build +++ b/meson.build @@ -2944,7 +2944,6 @@ if have_system 'hw/char', 'hw/display', 'hw/dma', - 'hw/hppa', 'hw/hyperv', 'hw/i2c', 'hw/i386', From 932befaa557d9f4ab3d830107ada66dfe3cffba2 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:56 +0100 Subject: [PATCH 46/53] hppa: move enable_lan() define from hppa_sys.h to machine.c Now that the board configuration is in one place, the define is only needed when wiring up the board in machine.c. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-47-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/hppa_sys.h | 2 -- hw/hppa/machine.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h index 17e2c6dec1..e7f65cad75 100644 --- a/hw/hppa/hppa_sys.h +++ b/hw/hppa/hppa_sys.h @@ -5,6 +5,4 @@ #include "hppa_hardware.h" -#define enable_lasi_lan() 0 - #endif diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index ca595d343e..e6431aa541 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -36,6 +36,9 @@ #define HPA_POWER_BUTTON (FIRMWARE_END - 0x10) +#define enable_lasi_lan() 0 + + static void hppa_powerdown_req(Notifier *n, void *opaque) { hwaddr soft_power_reg = HPA_POWER_BUTTON; From 148da6708580c46c87f8e917d6bfd53b8e6a59ab Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:57 +0100 Subject: [PATCH 47/53] hppa: remove the empty hppa_sys.h file This file is now just a simple wrapper that includes hppa_hardware.h so remove the file completely, and update its single user in machine.c to include hppa_hardware.h directly. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-48-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/hppa_sys.h | 8 -------- hw/hppa/machine.c | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 hw/hppa/hppa_sys.h diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h deleted file mode 100644 index e7f65cad75..0000000000 --- a/hw/hppa/hppa_sys.h +++ /dev/null @@ -1,8 +0,0 @@ -/* HPPA cores and system support chips. */ - -#ifndef HW_HPPA_SYS_H -#define HW_HPPA_SYS_H - -#include "hppa_hardware.h" - -#endif diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index e6431aa541..75820838bf 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -23,7 +23,7 @@ #include "hw/pci/pci.h" #include "hw/pci-host/dino.h" #include "hw/misc/lasi.h" -#include "hppa_sys.h" +#include "hppa_hardware.h" #include "qemu/units.h" #include "qapi/error.h" #include "net/net.h" From c165905c1764bebf90e31527fafbe0f1fa7c888e Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:58 +0100 Subject: [PATCH 48/53] hppa: use MACHINE QOM macros for defining the hppa machine Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-49-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/machine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 75820838bf..2393335a64 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -471,8 +471,8 @@ static void machine_hppa_machine_init_class_init(ObjectClass *oc, void *data) } static const TypeInfo machine_hppa_machine_init_typeinfo = { - .name = ("hppa" "-machine"), - .parent = "machine", + .name = MACHINE_TYPE_NAME("hppa"), + .parent = TYPE_MACHINE, .class_init = machine_hppa_machine_init_class_init, .interfaces = (InterfaceInfo[]) { { TYPE_NMI }, From 42cc2bf63c2b61b43300e70a4965aa9d48eda790 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:25:59 +0100 Subject: [PATCH 49/53] hppa: fold machine_hppa_machine_init() into machine_hppa_machine_init_class_init() There is no need for a separate function to set the machine class properties separately from the others. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-50-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/machine.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 2393335a64..724ee24795 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -446,8 +446,11 @@ static void hppa_nmi(NMIState *n, int cpu_index, Error **errp) } } -static void machine_hppa_machine_init(MachineClass *mc) +static void machine_hppa_machine_init_class_init(ObjectClass *oc, void *data) { + MachineClass *mc = MACHINE_CLASS(oc); + NMIClass *nc = NMI_CLASS(oc); + mc->desc = "HPPA B160L machine"; mc->default_cpu_type = TYPE_HPPA_CPU; mc->init = machine_hppa_init; @@ -459,14 +462,7 @@ static void machine_hppa_machine_init(MachineClass *mc) mc->default_ram_size = 512 * MiB; mc->default_boot_order = "cd"; mc->default_ram_id = "ram"; -} -static void machine_hppa_machine_init_class_init(ObjectClass *oc, void *data) -{ - MachineClass *mc = MACHINE_CLASS(oc); - machine_hppa_machine_init(mc); - - NMIClass *nc = NMI_CLASS(oc); nc->nmi_monitor_handler = hppa_nmi; } From 297d410387cb5a93bb32469aef34b02843d99b71 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 10:26:00 +0100 Subject: [PATCH 50/53] hppa: simplify machine function names in machine.c Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220504092600.10048-51-mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson Signed-off-by: Mark Cave-Ayland --- hw/hppa/machine.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 724ee24795..ae0bc07e75 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -446,7 +446,7 @@ static void hppa_nmi(NMIState *n, int cpu_index, Error **errp) } } -static void machine_hppa_machine_init_class_init(ObjectClass *oc, void *data) +static void hppa_machine_init_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); NMIClass *nc = NMI_CLASS(oc); @@ -466,19 +466,19 @@ static void machine_hppa_machine_init_class_init(ObjectClass *oc, void *data) nc->nmi_monitor_handler = hppa_nmi; } -static const TypeInfo machine_hppa_machine_init_typeinfo = { +static const TypeInfo hppa_machine_init_typeinfo = { .name = MACHINE_TYPE_NAME("hppa"), .parent = TYPE_MACHINE, - .class_init = machine_hppa_machine_init_class_init, + .class_init = hppa_machine_init_class_init, .interfaces = (InterfaceInfo[]) { { TYPE_NMI }, { } }, }; -static void machine_hppa_machine_init_register_types(void) +static void hppa_machine_init_register_types(void) { - type_register_static(&machine_hppa_machine_init_typeinfo); + type_register_static(&hppa_machine_init_typeinfo); } -type_init(machine_hppa_machine_init_register_types) +type_init(hppa_machine_init_register_types) From 5d61789e04bf3313d012eb5c04d9de234013ff39 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 16:37:06 +0100 Subject: [PATCH 51/53] artist: checkpatch and newline style fixes Ensure that subsequent patches do not cause checkpatch to fail and also tidy up extra/missing newlines. Signed-off-by: Mark Cave-Ayland Message-Id: <20220504153708.10352-2-mark.cave-ayland@ilande.co.uk> Reviewed-by: Peter Maydell Reviewed-by: Helge Deller Reviewed-by: Sven Schnelle Signed-off-by: Mark Cave-Ayland --- hw/display/artist.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/hw/display/artist.c b/hw/display/artist.c index 8e121bb0b4..be92113494 100644 --- a/hw/display/artist.c +++ b/hw/display/artist.c @@ -211,8 +211,9 @@ static void artist_invalidate_lines(struct vram_buffer *buf, int start = starty * buf->width; int size; - if (starty + height > buf->height) + if (starty + height > buf->height) { height = buf->height - starty; + } size = height * buf->width; @@ -321,8 +322,9 @@ static void artist_get_cursor_pos(ARTISTState *s, int *x, int *y) } lx = artist_get_x(s->cursor_pos); - if (lx < offset) + if (lx < offset) { offset = lx; + } *x = (lx - offset) / 2; *y = 1146 - artist_get_y(s->cursor_pos); @@ -343,6 +345,7 @@ static void artist_get_cursor_pos(ARTISTState *s, int *x, int *y) static void artist_invalidate_cursor(ARTISTState *s) { int x, y; + artist_get_cursor_pos(s, &x, &y); artist_invalidate_lines(&s->vram_buffer[ARTIST_BUFFER_AP], y, s->cursor_height); @@ -470,10 +473,9 @@ static void draw_line(ARTISTState *s, if ((x1 >= buf->width && x2 >= buf->width) || (y1 >= buf->height && y2 >= buf->height)) { - return; + return; } - if (update_start) { s->vram_start = (x2 << 16) | y2; } @@ -553,15 +555,15 @@ static void draw_line(ARTISTState *s, x++; } while (x <= x2 && (max_pix == -1 || --max_pix > 0)); - if (c1) + if (c1) { artist_invalidate_lines(buf, x1, x2 - x1); - else + } else { artist_invalidate_lines(buf, y1 > y2 ? y2 : y1, x2 - x1); + } } static void draw_line_pattern_start(ARTISTState *s) { - int startx = artist_get_x(s->vram_start); int starty = artist_get_y(s->vram_start); int endx = artist_get_x(s->blockmove_size); @@ -574,7 +576,6 @@ static void draw_line_pattern_start(ARTISTState *s) static void draw_line_pattern_next(ARTISTState *s) { - int startx = artist_get_x(s->vram_start); int starty = artist_get_y(s->vram_start); int endx = artist_get_x(s->blockmove_size); @@ -589,7 +590,6 @@ static void draw_line_pattern_next(ARTISTState *s) static void draw_line_size(ARTISTState *s, bool update_start) { - int startx = artist_get_x(s->vram_start); int starty = artist_get_y(s->vram_start); int endx = artist_get_x(s->line_size); @@ -600,7 +600,6 @@ static void draw_line_size(ARTISTState *s, bool update_start) static void draw_line_xy(ARTISTState *s, bool update_start) { - int startx = artist_get_x(s->vram_start); int starty = artist_get_y(s->vram_start); int sizex = artist_get_x(s->blockmove_size); @@ -650,7 +649,6 @@ static void draw_line_xy(ARTISTState *s, bool update_start) static void draw_line_end(ARTISTState *s, bool update_start) { - int startx = artist_get_x(s->vram_start); int starty = artist_get_y(s->vram_start); int endx = artist_get_x(s->line_end); @@ -835,6 +833,7 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { ARTISTState *s = opaque; + s->vram_char_y = 0; trace_artist_vram_write(size, addr, val); vram_bit_write(opaque, addr, 0, val, size); @@ -1244,7 +1243,6 @@ static void artist_update_display(void *opaque) DisplaySurface *surface = qemu_console_surface(s->con); int first = 0, last; - framebuffer_update_display(surface, &s->fbsection, s->width, s->height, s->width, s->width * 4, 0, 0, artist_draw_line, s, &first, &last); @@ -1258,6 +1256,7 @@ static void artist_invalidate(void *opaque) { ARTISTState *s = ARTIST(opaque); struct vram_buffer *buf = &s->vram_buffer[ARTIST_BUFFER_AP]; + memory_region_set_dirty(&buf->mr, 0, buf->size); } From ada804eb8972c42418a8052c0a1e0493714c75f5 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 16:37:07 +0100 Subject: [PATCH 52/53] artist: remove unused ROP8OFF() macro This macro is unused and so can simply be removed. Signed-off-by: Mark Cave-Ayland Message-Id: <20220504153708.10352-3-mark.cave-ayland@ilande.co.uk> Reviewed-by: Peter Maydell Reviewed-by: Helge Deller Reviewed-by: Sven Schnelle Signed-off-by: Mark Cave-Ayland --- hw/display/artist.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hw/display/artist.c b/hw/display/artist.c index be92113494..4a9f7b5e59 100644 --- a/hw/display/artist.c +++ b/hw/display/artist.c @@ -25,12 +25,6 @@ #define TYPE_ARTIST "artist" OBJECT_DECLARE_SIMPLE_TYPE(ARTISTState, ARTIST) -#if HOST_BIG_ENDIAN -#define ROP8OFF(_i) (3 - (_i)) -#else -#define ROP8OFF -#endif - struct vram_buffer { MemoryRegion mr; uint8_t *data; From 1f110516190f146df40f49aef2f1ef5903b8f540 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 4 May 2022 16:37:08 +0100 Subject: [PATCH 53/53] artist: only render dirty scanlines on the display surface The framebuffer_update_display() function returns the dirty scanlines that were touched since the last display update, however artist_update_display() always calls dpy_gfx_update() with start and end scanlines of 0 and s->height causing the entire display surface to be rendered on every update. Update artist_update_display() so that dpy_gfx_update() only renders the dirty scanlines on the display surface, bypassing the display surface rendering completely if framebuffer_update_display() indicates no changes occurred. This noticeably improves boot performance when the framebuffer is enabled on my rather modest laptop here, including making the GTK UI usable. Signed-off-by: Mark Cave-Ayland Message-Id: <20220504153708.10352-4-mark.cave-ayland@ilande.co.uk> Reviewed-by: Helge Deller Reviewed-by: Sven Schnelle Signed-off-by: Mark Cave-Ayland --- hw/display/artist.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/display/artist.c b/hw/display/artist.c index 4a9f7b5e59..39fc0c4ca5 100644 --- a/hw/display/artist.c +++ b/hw/display/artist.c @@ -1243,7 +1243,9 @@ static void artist_update_display(void *opaque) artist_draw_cursor(s); - dpy_gfx_update(s->con, 0, 0, s->width, s->height); + if (first >= 0) { + dpy_gfx_update(s->con, 0, first, s->width, last - first + 1); + } } static void artist_invalidate(void *opaque)