mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-07 12:58:20 +00:00
PCI irq support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@822 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
73c11f630b
commit
4a9c9687c6
38
hw/ne2000.c
38
hw/ne2000.c
@ -125,6 +125,7 @@ typedef struct NE2000State {
|
|||||||
uint8_t curpag;
|
uint8_t curpag;
|
||||||
uint8_t mult[8]; /* multicast mask array */
|
uint8_t mult[8]; /* multicast mask array */
|
||||||
int irq;
|
int irq;
|
||||||
|
PCIDevice *pci_dev;
|
||||||
NetDriverState *nd;
|
NetDriverState *nd;
|
||||||
uint8_t mem[NE2000_MEM_SIZE];
|
uint8_t mem[NE2000_MEM_SIZE];
|
||||||
} NE2000State;
|
} NE2000State;
|
||||||
@ -153,10 +154,13 @@ static void ne2000_update_irq(NE2000State *s)
|
|||||||
printf("NE2000: Set IRQ line %d to %d (%02x %02x)\n",
|
printf("NE2000: Set IRQ line %d to %d (%02x %02x)\n",
|
||||||
s->irq, isr ? 1 : 0, s->isr, s->imr);
|
s->irq, isr ? 1 : 0, s->isr, s->imr);
|
||||||
#endif
|
#endif
|
||||||
if (isr)
|
if (s->irq == 16) {
|
||||||
pic_set_irq(s->irq, 1);
|
/* PCI irq */
|
||||||
else
|
pci_set_irq(s->pci_dev, 0, (isr != 0));
|
||||||
pic_set_irq(s->irq, 0);
|
} else {
|
||||||
|
/* ISA irq */
|
||||||
|
pic_set_irq(s->irq, (isr != 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return the max buffer size if the NE2000 can receive more data */
|
/* return the max buffer size if the NE2000 can receive more data */
|
||||||
@ -581,21 +585,6 @@ typedef struct PCINE2000State {
|
|||||||
NE2000State ne2000;
|
NE2000State ne2000;
|
||||||
} PCINE2000State;
|
} PCINE2000State;
|
||||||
|
|
||||||
static uint32_t ne2000_read_config(PCIDevice *d,
|
|
||||||
uint32_t address, int len)
|
|
||||||
{
|
|
||||||
uint32_t val;
|
|
||||||
val = 0;
|
|
||||||
memcpy(&val, d->config + address, len);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ne2000_write_config(PCIDevice *d,
|
|
||||||
uint32_t address, uint32_t val, int len)
|
|
||||||
{
|
|
||||||
memcpy(d->config + address, &val, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ne2000_map(PCIDevice *pci_dev, int region_num,
|
static void ne2000_map(PCIDevice *pci_dev, int region_num,
|
||||||
uint32_t addr, uint32_t size, int type)
|
uint32_t addr, uint32_t size, int type)
|
||||||
{
|
{
|
||||||
@ -624,8 +613,7 @@ void pci_ne2000_init(NetDriverState *nd)
|
|||||||
|
|
||||||
d = (PCINE2000State *)pci_register_device("NE2000", sizeof(PCINE2000State),
|
d = (PCINE2000State *)pci_register_device("NE2000", sizeof(PCINE2000State),
|
||||||
0, -1,
|
0, -1,
|
||||||
ne2000_read_config,
|
NULL, NULL);
|
||||||
ne2000_write_config);
|
|
||||||
pci_conf = d->dev.config;
|
pci_conf = d->dev.config;
|
||||||
pci_conf[0x00] = 0xec; // Realtek 8029
|
pci_conf[0x00] = 0xec; // Realtek 8029
|
||||||
pci_conf[0x01] = 0x10;
|
pci_conf[0x01] = 0x10;
|
||||||
@ -634,15 +622,13 @@ void pci_ne2000_init(NetDriverState *nd)
|
|||||||
pci_conf[0x0a] = 0x00; // ethernet network controller
|
pci_conf[0x0a] = 0x00; // ethernet network controller
|
||||||
pci_conf[0x0b] = 0x02;
|
pci_conf[0x0b] = 0x02;
|
||||||
pci_conf[0x0e] = 0x00; // header_type
|
pci_conf[0x0e] = 0x00; // header_type
|
||||||
|
pci_conf[0x3d] = 1; // interrupt pin 0
|
||||||
/* XXX: do that in the BIOS */
|
|
||||||
pci_conf[0x3c] = 11; // interrupt line
|
|
||||||
pci_conf[0x3d] = 1; // interrupt pin
|
|
||||||
|
|
||||||
pci_register_io_region((PCIDevice *)d, 0, 0x100,
|
pci_register_io_region((PCIDevice *)d, 0, 0x100,
|
||||||
PCI_ADDRESS_SPACE_IO, ne2000_map);
|
PCI_ADDRESS_SPACE_IO, ne2000_map);
|
||||||
s = &d->ne2000;
|
s = &d->ne2000;
|
||||||
s->irq = 11;
|
s->irq = 16; // PCI interrupt
|
||||||
|
s->pci_dev = (PCIDevice *)d;
|
||||||
s->nd = nd;
|
s->nd = nd;
|
||||||
ne2000_reset(s);
|
ne2000_reset(s);
|
||||||
qemu_add_read_packet(nd, ne2000_can_receive, ne2000_receive, s);
|
qemu_add_read_packet(nd, ne2000_can_receive, ne2000_receive, s);
|
||||||
|
Loading…
Reference in New Issue
Block a user