From f0e1b30b4be8727a01a26a6924cebef4855ed670 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 11 Jun 2016 19:19:04 +0300 Subject: [PATCH] Configurable PCI device IRQ callback. --- include/pci_hw.h | 2 +- pci.cpp | 3 ++- qemuvga/es1370.cpp | 8 +++++--- qemuvga/ne2000.cpp | 8 +++++--- qemuvga/ne2000.h | 1 + sndboard.cpp | 12 ++++++------ 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/pci_hw.h b/include/pci_hw.h index 508db125..0608919c 100644 --- a/include/pci_hw.h +++ b/include/pci_hw.h @@ -47,7 +47,6 @@ struct pci_board pci_dev_free free; pci_dev_reset reset; pci_dev_hsync hsync; - pci_dev_irq irq; pci_addrbank bars[MAX_PCI_BARS]; }; @@ -67,6 +66,7 @@ struct pci_board_state bool memory_map_active; bool io_map_active; struct pci_bridge *bridge; + pci_dev_irq irq_callback; }; struct pci_bridge diff --git a/pci.cpp b/pci.cpp index 38e14694..ae6d698f 100644 --- a/pci.cpp +++ b/pci.cpp @@ -113,6 +113,7 @@ static void pci_board_add(struct pci_bridge *pcib, const struct pci_board *pci, pcibs->slot = slot; pcibs->func = func; pcibs->bridge = pcib; + pcibs->irq_callback = pci_irq_callback; memset(pcibs->config_data, 0, sizeof pcibs->config_data); for (int i = 0; i < MAX_PCI_BARS; i++) { pcibs->bar_size[i] = pci->config->bars[i]; @@ -1452,7 +1453,7 @@ static const struct pci_config ncr_53c815_pci_config = static const struct pci_board ncr_53c815_pci_board = { _T("NCR53C815"), - &ncr_53c815_pci_config, NULL, NULL, NULL, NULL, pci_irq_callback, + &ncr_53c815_pci_config, NULL, NULL, NULL, NULL, { { wildfire_lget, wildfire_wget, wildfire_bget, wildfire_lput, wildfire_wput, wildfire_bput }, { wildfire_lget, wildfire_wget, wildfire_bget, wildfire_lput, wildfire_wput, wildfire_bput }, diff --git a/qemuvga/es1370.cpp b/qemuvga/es1370.cpp index 46e6fab0..33e5d26a 100644 --- a/qemuvga/es1370.cpp +++ b/qemuvga/es1370.cpp @@ -317,6 +317,7 @@ typedef struct ES1370State { uint32_t mempage; uint32_t codec; uint32_t sctl; + pci_dev_irq irq_callback; } ES1370State; struct chan_bits { @@ -362,7 +363,7 @@ static void es1370_update_status (ES1370State *s, uint32_t new_status) } else { s->status = new_status & ~STAT_INTR; } - es1370state.device->irq(es1370state.dev, !!level); + es1370state.irq_callback(es1370state.dev, !!level); // pci_set_irq(&s->dev, !!level); } @@ -388,7 +389,7 @@ static void es1370_reset (ES1370State *s) s->dac_voice[i] = NULL; } } - es1370state.device->irq(es1370state.dev, false); + es1370state.irq_callback(es1370state.dev, false); // pci_irq_deassert(&s->dev); } @@ -1185,6 +1186,7 @@ static bool es1370_init(struct pci_board_state *pcibs) { init(pcibs); es1370_reset(&es1370state); + es1370state.irq_callback = pcibs->irq_callback; return true; } @@ -1197,7 +1199,7 @@ static const struct pci_config es1370_pci_config = const struct pci_board es1370_pci_board = { _T("ES1370"), - &es1370_pci_config, es1370_init, es1370_free, es1370_reset, NULL, pci_irq_callback, + &es1370_pci_config, es1370_init, es1370_free, es1370_reset, NULL, { { es1370_lget, es1370_wget, es1370_bget, es1370_lput, es1370_wput, es1370_bput }, { NULL }, diff --git a/qemuvga/ne2000.cpp b/qemuvga/ne2000.cpp index 891d2fac..111cca4f 100644 --- a/qemuvga/ne2000.cpp +++ b/qemuvga/ne2000.cpp @@ -231,7 +231,7 @@ static void ne2000_update_irq(NE2000State *s) write_log("NE2000: Set IRQ to %d (%02x %02x)\n", isr ? 1 : 0, s->isr, s->imr); #endif - ncs.device->irq(ncs.pcistate, isr != 0); + s->irq_callback(ncs.pcistate, isr != 0); // qemu_set_irq(s->irq, (isr != 0)); } @@ -1046,6 +1046,7 @@ static bool ne2000_init(struct pci_board_state *pcibs) ncs.pcistate = pcibs; ncs.ne2000state = &ne2000state; memset(&ne2000state, 0, sizeof ne2000state); + ncs.ne2000state->irq_callback = pcibs->irq_callback; uae_sem_init(&ne2000_sem, 0, 1); if (!receive_buffer) { @@ -1054,8 +1055,9 @@ static bool ne2000_init(struct pci_board_state *pcibs) td = NULL; uae_u8 *m = ncs.ne2000state->c.macaddr.a; + const TCHAR *name = currprefs.ne2000pciname[0] ? currprefs.ne2000pciname : currprefs.ne2000pcmcianame; // hack! memset(m, 0, 6); - if (ethernet_enumerate(&td, currprefs.ne2000pciname)) { + if (ethernet_enumerate(&td, name)) { memcpy(m, td->mac, 6); if (!m[0] && !m[1] && !m[2]) { m[0] = 0x52; @@ -1097,7 +1099,7 @@ static const struct pci_config ne2000_pci_config = const struct pci_board ne2000_pci_board = { _T("RTL8029"), - &ne2000_pci_config, ne2000_init, ne2000_free, ne2000_reset, ne2000_hsync_handler, pci_irq_callback, + &ne2000_pci_config, ne2000_init, ne2000_free, ne2000_reset, ne2000_hsync_handler, { { ne2000_lget, ne2000_wget, ne2000_bget, ne2000_lput, ne2000_wput, ne2000_bput }, { NULL }, diff --git a/qemuvga/ne2000.h b/qemuvga/ne2000.h index fd4fffd0..b9a8a2ad 100644 --- a/qemuvga/ne2000.h +++ b/qemuvga/ne2000.h @@ -29,6 +29,7 @@ typedef struct NE2000State { //NICState *nic; NICConf c; uint8_t mem[NE2000_MEM_SIZE]; + pci_dev_irq irq_callback; } NE2000State; #if 0 diff --git a/sndboard.cpp b/sndboard.cpp index 7351e52c..7d4b6df2 100644 --- a/sndboard.cpp +++ b/sndboard.cpp @@ -361,7 +361,7 @@ void sndboard_hsync(void) capture_read_index = 0; } - write_log(_T("%d %d %d %d\n"), capture_read_index, capture_write_index, size, bytes); + //write_log(_T("%d %d %d %d\n"), capture_read_index, capture_write_index, size, bytes); if (data->data_in_record_fifo > FIFO_SIZE_HALF && oldfifo <= FIFO_SIZE_HALF) { data->fifo_half |= STATUS_FIFO_RECORD; @@ -704,9 +704,9 @@ static void fm801_swap_buffers(struct fm801_data *data) static void fm801_interrupt(struct fm801_data *data) { if ((data->interrupt_status & 0x100) && !(data->interrupt_control & 1)) { - data->pcibs->board->irq(data->pcibs, true); + data->pcibs->irq_callback(data->pcibs, true); } else { - data->pcibs->board->irq(data->pcibs, false); + data->pcibs->irq_callback(data->pcibs, false); } } @@ -934,7 +934,7 @@ static const struct pci_config fm801_pci_config_func1 = const struct pci_board fm801_pci_board = { _T("FM801"), - &fm801_pci_config, fm801_init, fm801_free, fm801_reset, fm801_hsync_handler, pci_irq_callback, + &fm801_pci_config, fm801_init, fm801_free, fm801_reset, fm801_hsync_handler, { { fm801_lget, fm801_wget, fm801_bget, fm801_lput, fm801_wput, fm801_bput }, { NULL }, @@ -949,7 +949,7 @@ const struct pci_board fm801_pci_board = const struct pci_board fm801_pci_board_func1 = { _T("FM801-2"), - &fm801_pci_config_func1, NULL, NULL, NULL, NULL, NULL, + &fm801_pci_config_func1, NULL, NULL, NULL, NULL, { { fm801_lget, fm801_wget, fm801_bget, fm801_lput, fm801_wput, fm801_bput }, { NULL }, @@ -1042,7 +1042,7 @@ static const struct pci_config solo1_pci_config = const struct pci_board solo1_pci_board = { _T("SOLO1"), - &solo1_pci_config, solo1_init, solo1_free, solo1_reset, NULL, pci_irq_callback, + &solo1_pci_config, solo1_init, solo1_free, solo1_reset, NULL, { { solo1_lget, solo1_wget, solo1_bget, solo1_lput, solo1_wput, solo1_bput }, { solo1_lget, solo1_wget, solo1_bget, solo1_lput, solo1_wput, solo1_bput }, -- 2.47.3