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,6 +125,7 @@ typedef struct NE2000State { | ||
125 | uint8_t curpag; | 125 | uint8_t curpag; |
126 | uint8_t mult[8]; /* multicast mask array */ | 126 | uint8_t mult[8]; /* multicast mask array */ |
127 | int irq; | 127 | int irq; |
128 | + PCIDevice *pci_dev; | ||
128 | NetDriverState *nd; | 129 | NetDriverState *nd; |
129 | uint8_t mem[NE2000_MEM_SIZE]; | 130 | uint8_t mem[NE2000_MEM_SIZE]; |
130 | } NE2000State; | 131 | } NE2000State; |
@@ -153,10 +154,13 @@ static void ne2000_update_irq(NE2000State *s) | @@ -153,10 +154,13 @@ static void ne2000_update_irq(NE2000State *s) | ||
153 | printf("NE2000: Set IRQ line %d to %d (%02x %02x)\n", | 154 | printf("NE2000: Set IRQ line %d to %d (%02x %02x)\n", |
154 | s->irq, isr ? 1 : 0, s->isr, s->imr); | 155 | s->irq, isr ? 1 : 0, s->isr, s->imr); |
155 | #endif | 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 | /* return the max buffer size if the NE2000 can receive more data */ | 166 | /* return the max buffer size if the NE2000 can receive more data */ |
@@ -581,21 +585,6 @@ typedef struct PCINE2000State { | @@ -581,21 +585,6 @@ typedef struct PCINE2000State { | ||
581 | NE2000State ne2000; | 585 | NE2000State ne2000; |
582 | } PCINE2000State; | 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 | static void ne2000_map(PCIDevice *pci_dev, int region_num, | 588 | static void ne2000_map(PCIDevice *pci_dev, int region_num, |
600 | uint32_t addr, uint32_t size, int type) | 589 | uint32_t addr, uint32_t size, int type) |
601 | { | 590 | { |
@@ -624,8 +613,7 @@ void pci_ne2000_init(NetDriverState *nd) | @@ -624,8 +613,7 @@ void pci_ne2000_init(NetDriverState *nd) | ||
624 | 613 | ||
625 | d = (PCINE2000State *)pci_register_device("NE2000", sizeof(PCINE2000State), | 614 | d = (PCINE2000State *)pci_register_device("NE2000", sizeof(PCINE2000State), |
626 | 0, -1, | 615 | 0, -1, |
627 | - ne2000_read_config, | ||
628 | - ne2000_write_config); | 616 | + NULL, NULL); |
629 | pci_conf = d->dev.config; | 617 | pci_conf = d->dev.config; |
630 | pci_conf[0x00] = 0xec; // Realtek 8029 | 618 | pci_conf[0x00] = 0xec; // Realtek 8029 |
631 | pci_conf[0x01] = 0x10; | 619 | pci_conf[0x01] = 0x10; |
@@ -634,15 +622,13 @@ void pci_ne2000_init(NetDriverState *nd) | @@ -634,15 +622,13 @@ void pci_ne2000_init(NetDriverState *nd) | ||
634 | pci_conf[0x0a] = 0x00; // ethernet network controller | 622 | pci_conf[0x0a] = 0x00; // ethernet network controller |
635 | pci_conf[0x0b] = 0x02; | 623 | pci_conf[0x0b] = 0x02; |
636 | pci_conf[0x0e] = 0x00; // header_type | 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 | pci_register_io_region((PCIDevice *)d, 0, 0x100, | 627 | pci_register_io_region((PCIDevice *)d, 0, 0x100, |
643 | PCI_ADDRESS_SPACE_IO, ne2000_map); | 628 | PCI_ADDRESS_SPACE_IO, ne2000_map); |
644 | s = &d->ne2000; | 629 | s = &d->ne2000; |
645 | - s->irq = 11; | 630 | + s->irq = 16; // PCI interrupt |
631 | + s->pci_dev = (PCIDevice *)d; | ||
646 | s->nd = nd; | 632 | s->nd = nd; |
647 | ne2000_reset(s); | 633 | ne2000_reset(s); |
648 | qemu_add_read_packet(nd, ne2000_can_receive, ne2000_receive, s); | 634 | qemu_add_read_packet(nd, ne2000_can_receive, ne2000_receive, s); |