Lines Matching full:pci
27 #include "hw/pci/pci_device.h"
80 static void esp_pci_update_irq(PCIESPState *pci) in esp_pci_update_irq() argument
82 int scsi_level = !!(pci->dma_regs[DMA_STAT] & DMA_STAT_SCSIINT); in esp_pci_update_irq()
83 int dma_level = (pci->dma_regs[DMA_CMD] & DMA_CMD_INTE_D) ? in esp_pci_update_irq()
84 !!(pci->dma_regs[DMA_STAT] & DMA_STAT_DONE) : 0; in esp_pci_update_irq()
87 pci_set_irq(PCI_DEVICE(pci), level); in esp_pci_update_irq()
92 PCIESPState *pci = PCI_ESP(opaque); in esp_irq_handler() local
95 pci->dma_regs[DMA_STAT] |= DMA_STAT_SCSIINT; in esp_irq_handler()
104 if ((pci->dma_regs[DMA_CMD] & DMA_CMD_MASK) == 0x3 && in esp_irq_handler()
105 pci->dma_regs[DMA_WBC] == 0) { in esp_irq_handler()
106 pci->dma_regs[DMA_STAT] |= DMA_STAT_DONE; in esp_irq_handler()
109 pci->dma_regs[DMA_STAT] &= ~DMA_STAT_SCSIINT; in esp_irq_handler()
112 esp_pci_update_irq(pci); in esp_irq_handler()
115 static void esp_pci_handle_idle(PCIESPState *pci, uint32_t val) in esp_pci_handle_idle() argument
117 ESPState *s = &pci->esp; in esp_pci_handle_idle()
123 static void esp_pci_handle_blast(PCIESPState *pci, uint32_t val) in esp_pci_handle_blast() argument
127 pci->dma_regs[DMA_STAT] |= DMA_STAT_BCMBLT; in esp_pci_handle_blast()
130 static void esp_pci_handle_abort(PCIESPState *pci, uint32_t val) in esp_pci_handle_abort() argument
132 ESPState *s = &pci->esp; in esp_pci_handle_abort()
140 static void esp_pci_handle_start(PCIESPState *pci, uint32_t val) in esp_pci_handle_start() argument
142 ESPState *s = &pci->esp; in esp_pci_handle_start()
146 pci->dma_regs[DMA_WBC] = pci->dma_regs[DMA_STC]; in esp_pci_handle_start()
147 pci->dma_regs[DMA_WAC] = pci->dma_regs[DMA_SPA]; in esp_pci_handle_start()
148 pci->dma_regs[DMA_WMAC] = pci->dma_regs[DMA_SMDLA]; in esp_pci_handle_start()
150 pci->dma_regs[DMA_STAT] &= ~(DMA_STAT_BCMBLT | DMA_STAT_SCSIINT in esp_pci_handle_start()
157 static void esp_pci_dma_write(PCIESPState *pci, uint32_t saddr, uint32_t val) in esp_pci_dma_write() argument
159 trace_esp_pci_dma_write(saddr, pci->dma_regs[saddr], val); in esp_pci_dma_write()
162 pci->dma_regs[saddr] = val; in esp_pci_dma_write()
165 esp_pci_handle_idle(pci, val); in esp_pci_dma_write()
168 esp_pci_handle_blast(pci, val); in esp_pci_dma_write()
171 esp_pci_handle_abort(pci, val); in esp_pci_dma_write()
174 esp_pci_handle_start(pci, val); in esp_pci_dma_write()
183 pci->dma_regs[saddr] = val; in esp_pci_dma_write()
186 if (pci->sbac & SBAC_STATUS) { in esp_pci_dma_write()
189 pci->dma_regs[DMA_STAT] &= ~(val & mask); in esp_pci_dma_write()
190 esp_pci_update_irq(pci); in esp_pci_dma_write()
199 static uint32_t esp_pci_dma_read(PCIESPState *pci, uint32_t saddr) in esp_pci_dma_read() argument
203 val = pci->dma_regs[saddr]; in esp_pci_dma_read()
205 if (!(pci->sbac & SBAC_STATUS)) { in esp_pci_dma_read()
206 pci->dma_regs[DMA_STAT] &= ~(DMA_STAT_ERROR | DMA_STAT_ABORT | in esp_pci_dma_read()
208 esp_pci_update_irq(pci); in esp_pci_dma_read()
219 PCIESPState *pci = opaque; in esp_pci_io_write() local
220 ESPState *s = &pci->esp; in esp_pci_io_write()
230 current = pci->dma_regs[(addr - 0x40) >> 2]; in esp_pci_io_write()
232 current = pci->sbac; in esp_pci_io_write()
250 /* PCI DMA CCB */ in esp_pci_io_write()
251 esp_pci_dma_write(pci, (addr - 0x40) >> 2, val); in esp_pci_io_write()
254 trace_esp_pci_sbac_write(pci->sbac, val); in esp_pci_io_write()
255 pci->sbac = val; in esp_pci_io_write()
264 PCIESPState *pci = opaque; in esp_pci_io_read() local
265 ESPState *s = &pci->esp; in esp_pci_io_read()
272 /* PCI DMA CCB */ in esp_pci_io_read()
273 ret = esp_pci_dma_read(pci, (addr - 0x40) >> 2); in esp_pci_io_read()
276 trace_esp_pci_sbac_read(pci->sbac); in esp_pci_io_read()
277 ret = pci->sbac; in esp_pci_io_read()
291 static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len, in esp_pci_dma_memory_rw() argument
297 if (pci->dma_regs[DMA_CMD] & DMA_CMD_DIR) { in esp_pci_dma_memory_rw()
308 if (pci->dma_regs[DMA_STAT] & DMA_CMD_MDL) { in esp_pci_dma_memory_rw()
312 addr = pci->dma_regs[DMA_WAC]; in esp_pci_dma_memory_rw()
313 if (pci->dma_regs[DMA_WBC] < len) { in esp_pci_dma_memory_rw()
314 len = pci->dma_regs[DMA_WBC]; in esp_pci_dma_memory_rw()
317 pci_dma_rw(PCI_DEVICE(pci), addr, buf, len, dir, MEMTXATTRS_UNSPECIFIED); in esp_pci_dma_memory_rw()
320 pci->dma_regs[DMA_WBC] -= len; in esp_pci_dma_memory_rw()
321 pci->dma_regs[DMA_WAC] += len; in esp_pci_dma_memory_rw()
326 PCIESPState *pci = opaque; in esp_pci_dma_memory_read() local
327 esp_pci_dma_memory_rw(pci, buf, len, DMA_DIRECTION_TO_DEVICE); in esp_pci_dma_memory_read()
332 PCIESPState *pci = opaque; in esp_pci_dma_memory_write() local
333 esp_pci_dma_memory_rw(pci, buf, len, DMA_DIRECTION_FROM_DEVICE); in esp_pci_dma_memory_write()
348 PCIESPState *pci = PCI_ESP(dev); in esp_pci_hard_reset() local
349 ESPState *s = &pci->esp; in esp_pci_hard_reset()
352 pci->dma_regs[DMA_CMD] &= ~(DMA_CMD_DIR | DMA_CMD_INTE_D | DMA_CMD_INTE_P in esp_pci_hard_reset()
354 pci->dma_regs[DMA_WBC] &= ~0xffff; in esp_pci_hard_reset()
355 pci->dma_regs[DMA_WAC] = 0xffffffff; in esp_pci_hard_reset()
356 pci->dma_regs[DMA_STAT] &= ~(DMA_STAT_BCMBLT | DMA_STAT_SCSIINT in esp_pci_hard_reset()
359 pci->dma_regs[DMA_WMAC] = 0xfffffffd; in esp_pci_hard_reset()
388 PCIESPState *pci = PCI_ESP(dev); in esp_pci_scsi_realize() local
390 ESPState *s = &pci->esp; in esp_pci_scsi_realize()
404 s->dma_opaque = pci; in esp_pci_scsi_realize()
406 memory_region_init_io(&pci->io, OBJECT(pci), &esp_pci_io_ops, pci, in esp_pci_scsi_realize()
409 pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->io); in esp_pci_scsi_realize()
410 s->irq = qemu_allocate_irq(esp_irq_handler, pci, 0); in esp_pci_scsi_realize()
417 PCIESPState *pci = PCI_ESP(d); in esp_pci_scsi_exit() local
418 ESPState *s = &pci->esp; in esp_pci_scsi_exit()
425 PCIESPState *pci = PCI_ESP(obj); in esp_pci_init() local
427 object_initialize_child(obj, "esp", &pci->esp, TYPE_ESP); in esp_pci_init()
442 dc->desc = "AMD Am53c974 PCscsi-PCI SCSI adapter"; in esp_pci_class_init()
460 PCIESPState pci; member
487 DC390State *pci = DC390(dev); in DECLARE_INSTANCE_CHECKER() local
494 if (!eeprom93xx_read(pci->eeprom)) { in DECLARE_INSTANCE_CHECKER()
505 DC390State *pci = DC390(dev); in dc390_write_config() local
510 eeprom93xx_write(pci->eeprom, 1, eesk, eedi); in dc390_write_config()
513 eeprom93xx_write(pci->eeprom, 0, 0, 0); in dc390_write_config()
521 DC390State *pci = DC390(dev); in dc390_scsi_realize() local
535 pci->eeprom = eeprom93xx_new(DEVICE(dev), 64); in dc390_scsi_realize()
538 contents = (uint8_t *)eeprom93xx_data(pci->eeprom); in dc390_scsi_realize()