Lines Matching +full:bus +full:- +full:addr
5 * See the COPYING file in the top-level directory.
10 #include "pci-spapr.h"
16 #include "qemu/host-utils.h"
20 * PCI devices are always little-endian
21 * SPAPR by default is big-endian
25 static uint8_t qpci_spapr_pio_readb(QPCIBus *bus, uint32_t addr) in qpci_spapr_pio_readb() argument
27 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_pio_readb()
28 return qtest_readb(bus->qts, s->pio_cpu_base + addr); in qpci_spapr_pio_readb()
31 static void qpci_spapr_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t val) in qpci_spapr_pio_writeb() argument
33 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_pio_writeb()
34 qtest_writeb(bus->qts, s->pio_cpu_base + addr, val); in qpci_spapr_pio_writeb()
37 static uint16_t qpci_spapr_pio_readw(QPCIBus *bus, uint32_t addr) in qpci_spapr_pio_readw() argument
39 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_pio_readw()
40 return bswap16(qtest_readw(bus->qts, s->pio_cpu_base + addr)); in qpci_spapr_pio_readw()
43 static void qpci_spapr_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t val) in qpci_spapr_pio_writew() argument
45 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_pio_writew()
46 qtest_writew(bus->qts, s->pio_cpu_base + addr, bswap16(val)); in qpci_spapr_pio_writew()
49 static uint32_t qpci_spapr_pio_readl(QPCIBus *bus, uint32_t addr) in qpci_spapr_pio_readl() argument
51 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_pio_readl()
52 return bswap32(qtest_readl(bus->qts, s->pio_cpu_base + addr)); in qpci_spapr_pio_readl()
55 static void qpci_spapr_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t val) in qpci_spapr_pio_writel() argument
57 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_pio_writel()
58 qtest_writel(bus->qts, s->pio_cpu_base + addr, bswap32(val)); in qpci_spapr_pio_writel()
61 static uint64_t qpci_spapr_pio_readq(QPCIBus *bus, uint32_t addr) in qpci_spapr_pio_readq() argument
63 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_pio_readq()
64 return bswap64(qtest_readq(bus->qts, s->pio_cpu_base + addr)); in qpci_spapr_pio_readq()
67 static void qpci_spapr_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t val) in qpci_spapr_pio_writeq() argument
69 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_pio_writeq()
70 qtest_writeq(bus->qts, s->pio_cpu_base + addr, bswap64(val)); in qpci_spapr_pio_writeq()
73 static void qpci_spapr_memread(QPCIBus *bus, uint32_t addr, in qpci_spapr_memread() argument
76 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_memread()
77 qtest_memread(bus->qts, s->mmio32_cpu_base + addr, buf, len); in qpci_spapr_memread()
80 static void qpci_spapr_memwrite(QPCIBus *bus, uint32_t addr, in qpci_spapr_memwrite() argument
83 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_memwrite()
84 qtest_memwrite(bus->qts, s->mmio32_cpu_base + addr, buf, len); in qpci_spapr_memwrite()
87 static uint8_t qpci_spapr_config_readb(QPCIBus *bus, int devfn, uint8_t offset) in qpci_spapr_config_readb() argument
89 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_config_readb()
91 return qrtas_ibm_read_pci_config(bus->qts, s->alloc, s->buid, in qpci_spapr_config_readb()
95 static uint16_t qpci_spapr_config_readw(QPCIBus *bus, int devfn, uint8_t offset) in qpci_spapr_config_readw() argument
97 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_config_readw()
99 return qrtas_ibm_read_pci_config(bus->qts, s->alloc, s->buid, in qpci_spapr_config_readw()
103 static uint32_t qpci_spapr_config_readl(QPCIBus *bus, int devfn, uint8_t offset) in qpci_spapr_config_readl() argument
105 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_config_readl()
107 return qrtas_ibm_read_pci_config(bus->qts, s->alloc, s->buid, in qpci_spapr_config_readl()
111 static void qpci_spapr_config_writeb(QPCIBus *bus, int devfn, uint8_t offset, in qpci_spapr_config_writeb() argument
114 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_config_writeb()
116 qrtas_ibm_write_pci_config(bus->qts, s->alloc, s->buid, in qpci_spapr_config_writeb()
120 static void qpci_spapr_config_writew(QPCIBus *bus, int devfn, uint8_t offset, in qpci_spapr_config_writew() argument
123 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_config_writew()
125 qrtas_ibm_write_pci_config(bus->qts, s->alloc, s->buid, in qpci_spapr_config_writew()
129 static void qpci_spapr_config_writel(QPCIBus *bus, int devfn, uint8_t offset, in qpci_spapr_config_writel() argument
132 QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus); in qpci_spapr_config_writel()
134 qrtas_ibm_write_pci_config(bus->qts, s->alloc, s->buid, in qpci_spapr_config_writel()
146 if (!g_strcmp0(interface, "pci-bus")) { in qpci_spapr_get_driver()
147 return &qpci->bus; in qpci_spapr_get_driver()
149 fprintf(stderr, "%s not present in pci-bus-spapr", interface); in qpci_spapr_get_driver()
159 qpci->bus.has_buggy_msi = true; in qpci_init_spapr()
161 qpci->alloc = alloc; in qpci_init_spapr()
163 qpci->bus.pio_readb = qpci_spapr_pio_readb; in qpci_init_spapr()
164 qpci->bus.pio_readw = qpci_spapr_pio_readw; in qpci_init_spapr()
165 qpci->bus.pio_readl = qpci_spapr_pio_readl; in qpci_init_spapr()
166 qpci->bus.pio_readq = qpci_spapr_pio_readq; in qpci_init_spapr()
168 qpci->bus.pio_writeb = qpci_spapr_pio_writeb; in qpci_init_spapr()
169 qpci->bus.pio_writew = qpci_spapr_pio_writew; in qpci_init_spapr()
170 qpci->bus.pio_writel = qpci_spapr_pio_writel; in qpci_init_spapr()
171 qpci->bus.pio_writeq = qpci_spapr_pio_writeq; in qpci_init_spapr()
173 qpci->bus.memread = qpci_spapr_memread; in qpci_init_spapr()
174 qpci->bus.memwrite = qpci_spapr_memwrite; in qpci_init_spapr()
176 qpci->bus.config_readb = qpci_spapr_config_readb; in qpci_init_spapr()
177 qpci->bus.config_readw = qpci_spapr_config_readw; in qpci_init_spapr()
178 qpci->bus.config_readl = qpci_spapr_config_readl; in qpci_init_spapr()
180 qpci->bus.config_writeb = qpci_spapr_config_writeb; in qpci_init_spapr()
181 qpci->bus.config_writew = qpci_spapr_config_writew; in qpci_init_spapr()
182 qpci->bus.config_writel = qpci_spapr_config_writel; in qpci_init_spapr()
187 qpci->buid = 0x800000020000000ULL; in qpci_init_spapr()
189 qpci->pio_cpu_base = SPAPR_PCI_BASE; in qpci_init_spapr()
190 qpci->pio.pci_base = 0; in qpci_init_spapr()
191 qpci->pio.size = SPAPR_PCI_IO_WIN_SIZE; in qpci_init_spapr()
193 /* 32-bit portion of the MMIO window is at PCI address 2..4 GiB */ in qpci_init_spapr()
194 qpci->mmio32_cpu_base = SPAPR_PCI_BASE; in qpci_init_spapr()
195 qpci->mmio32.pci_base = SPAPR_PCI_MMIO32_WIN_SIZE; in qpci_init_spapr()
196 qpci->mmio32.size = SPAPR_PCI_MMIO32_WIN_SIZE; in qpci_init_spapr()
198 qpci->bus.qts = qts; in qpci_init_spapr()
199 qpci->bus.pio_alloc_ptr = 0xc000; in qpci_init_spapr()
200 qpci->bus.pio_limit = 0x10000; in qpci_init_spapr()
201 qpci->bus.mmio_alloc_ptr = qpci->mmio32.pci_base; in qpci_init_spapr()
202 qpci->bus.mmio_limit = qpci->mmio32.pci_base + qpci->mmio32.size; in qpci_init_spapr()
204 qpci->obj.get_driver = qpci_spapr_get_driver; in qpci_init_spapr()
212 return &qpci->bus; in qpci_new_spapr()
215 void qpci_free_spapr(QPCIBus *bus) in qpci_free_spapr() argument
219 if (!bus) { in qpci_free_spapr()
222 s = container_of(bus, QPCIBusSPAPR, bus); in qpci_free_spapr()
229 qos_node_create_driver("pci-bus-spapr", NULL); in qpci_spapr_register_nodes()
230 qos_node_produces("pci-bus-spapr", "pci-bus"); in qpci_spapr_register_nodes()