Commit 63ce9e0a42503fbdb40eb8fb4b0933a058213925
1 parent
e1c485be
pci empty device read fix - piix3 ide init
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@854 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
27 additions
and
8 deletions
hw/pci.c
@@ -316,7 +316,18 @@ static uint32_t pci_data_read(void *opaque, uint32_t addr, | @@ -316,7 +316,18 @@ static uint32_t pci_data_read(void *opaque, uint32_t addr, | ||
316 | pci_dev = bus[(s->config_reg >> 8) & 0xff]; | 316 | pci_dev = bus[(s->config_reg >> 8) & 0xff]; |
317 | if (!pci_dev) { | 317 | if (!pci_dev) { |
318 | fail: | 318 | fail: |
319 | - val = 0; | 319 | + switch(len) { |
320 | + case 1: | ||
321 | + val = 0xff; | ||
322 | + break; | ||
323 | + case 2: | ||
324 | + val = 0xffff; | ||
325 | + break; | ||
326 | + default: | ||
327 | + case 4: | ||
328 | + val = 0xffffffff; | ||
329 | + break; | ||
330 | + } | ||
320 | goto the_end; | 331 | goto the_end; |
321 | } | 332 | } |
322 | config_addr = (s->config_reg & 0xfc) | (addr & 3); | 333 | config_addr = (s->config_reg & 0xfc) | (addr & 3); |
@@ -682,16 +693,24 @@ static void pci_bios_init_device(PCIDevice *d) | @@ -682,16 +693,24 @@ static void pci_bios_init_device(PCIDevice *d) | ||
682 | int class; | 693 | int class; |
683 | PCIIORegion *r; | 694 | PCIIORegion *r; |
684 | uint32_t *paddr; | 695 | uint32_t *paddr; |
685 | - int i, pin, pic_irq; | 696 | + int i, pin, pic_irq, vendor_id, device_id; |
686 | 697 | ||
687 | - class = d->config[0x0a] | (d->config[0x0b] << 8); | 698 | + class = pci_config_readw(d, PCI_CLASS_DEVICE); |
688 | switch(class) { | 699 | switch(class) { |
689 | case 0x0101: | 700 | case 0x0101: |
690 | - /* IDE: we map it as in ISA mode */ | ||
691 | - pci_set_io_region_addr(d, 0, 0x1f0); | ||
692 | - pci_set_io_region_addr(d, 1, 0x3f4); | ||
693 | - pci_set_io_region_addr(d, 2, 0x170); | ||
694 | - pci_set_io_region_addr(d, 3, 0x374); | 701 | + vendor_id = pci_config_readw(d, PCI_VENDOR_ID); |
702 | + device_id = pci_config_readw(d, PCI_DEVICE_ID); | ||
703 | + if (vendor_id == 0x8086 && device_id == 0x7010) { | ||
704 | + /* PIIX3 IDE */ | ||
705 | + pci_config_writew(d, PCI_COMMAND, PCI_COMMAND_IO); | ||
706 | + pci_config_writew(d, 0x40, 0x8000); // enable IDE0 | ||
707 | + } else { | ||
708 | + /* IDE: we map it as in ISA mode */ | ||
709 | + pci_set_io_region_addr(d, 0, 0x1f0); | ||
710 | + pci_set_io_region_addr(d, 1, 0x3f4); | ||
711 | + pci_set_io_region_addr(d, 2, 0x170); | ||
712 | + pci_set_io_region_addr(d, 3, 0x374); | ||
713 | + } | ||
695 | break; | 714 | break; |
696 | case 0x0300: | 715 | case 0x0300: |
697 | /* VGA: map frame buffer to default Bochs VBE address */ | 716 | /* VGA: map frame buffer to default Bochs VBE address */ |