Commit 4a9c9687c62f10bdd9a4ba24933f3d4830d4a6b9
1 parent
73c11f63
PCI irq support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@822 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
12 additions
and
26 deletions
hw/ne2000.c
... | ... | @@ -125,6 +125,7 @@ typedef struct NE2000State { |
125 | 125 | uint8_t curpag; |
126 | 126 | uint8_t mult[8]; /* multicast mask array */ |
127 | 127 | int irq; |
128 | + PCIDevice *pci_dev; | |
128 | 129 | NetDriverState *nd; |
129 | 130 | uint8_t mem[NE2000_MEM_SIZE]; |
130 | 131 | } NE2000State; |
... | ... | @@ -153,10 +154,13 @@ static void ne2000_update_irq(NE2000State *s) |
153 | 154 | printf("NE2000: Set IRQ line %d to %d (%02x %02x)\n", |
154 | 155 | s->irq, isr ? 1 : 0, s->isr, s->imr); |
155 | 156 | #endif |
156 | - if (isr) | |
157 | - pic_set_irq(s->irq, 1); | |
158 | - else | |
159 | - pic_set_irq(s->irq, 0); | |
157 | + if (s->irq == 16) { | |
158 | + /* PCI irq */ | |
159 | + pci_set_irq(s->pci_dev, 0, (isr != 0)); | |
160 | + } else { | |
161 | + /* ISA irq */ | |
162 | + pic_set_irq(s->irq, (isr != 0)); | |
163 | + } | |
160 | 164 | } |
161 | 165 | |
162 | 166 | /* return the max buffer size if the NE2000 can receive more data */ |
... | ... | @@ -581,21 +585,6 @@ typedef struct PCINE2000State { |
581 | 585 | NE2000State ne2000; |
582 | 586 | } PCINE2000State; |
583 | 587 | |
584 | -static uint32_t ne2000_read_config(PCIDevice *d, | |
585 | - uint32_t address, int len) | |
586 | -{ | |
587 | - uint32_t val; | |
588 | - val = 0; | |
589 | - memcpy(&val, d->config + address, len); | |
590 | - return val; | |
591 | -} | |
592 | - | |
593 | -static void ne2000_write_config(PCIDevice *d, | |
594 | - uint32_t address, uint32_t val, int len) | |
595 | -{ | |
596 | - memcpy(d->config + address, &val, len); | |
597 | -} | |
598 | - | |
599 | 588 | static void ne2000_map(PCIDevice *pci_dev, int region_num, |
600 | 589 | uint32_t addr, uint32_t size, int type) |
601 | 590 | { |
... | ... | @@ -624,8 +613,7 @@ void pci_ne2000_init(NetDriverState *nd) |
624 | 613 | |
625 | 614 | d = (PCINE2000State *)pci_register_device("NE2000", sizeof(PCINE2000State), |
626 | 615 | 0, -1, |
627 | - ne2000_read_config, | |
628 | - ne2000_write_config); | |
616 | + NULL, NULL); | |
629 | 617 | pci_conf = d->dev.config; |
630 | 618 | pci_conf[0x00] = 0xec; // Realtek 8029 |
631 | 619 | pci_conf[0x01] = 0x10; |
... | ... | @@ -634,15 +622,13 @@ void pci_ne2000_init(NetDriverState *nd) |
634 | 622 | pci_conf[0x0a] = 0x00; // ethernet network controller |
635 | 623 | pci_conf[0x0b] = 0x02; |
636 | 624 | pci_conf[0x0e] = 0x00; // header_type |
637 | - | |
638 | - /* XXX: do that in the BIOS */ | |
639 | - pci_conf[0x3c] = 11; // interrupt line | |
640 | - pci_conf[0x3d] = 1; // interrupt pin | |
625 | + pci_conf[0x3d] = 1; // interrupt pin 0 | |
641 | 626 | |
642 | 627 | pci_register_io_region((PCIDevice *)d, 0, 0x100, |
643 | 628 | PCI_ADDRESS_SPACE_IO, ne2000_map); |
644 | 629 | s = &d->ne2000; |
645 | - s->irq = 11; | |
630 | + s->irq = 16; // PCI interrupt | |
631 | + s->pci_dev = (PCIDevice *)d; | |
646 | 632 | s->nd = nd; |
647 | 633 | ne2000_reset(s); |
648 | 634 | qemu_add_read_packet(nd, ne2000_can_receive, ne2000_receive, s); | ... | ... |