mirror of
https://github.com/qemu/qemu.git
synced 2024-12-01 07:43:35 +08:00
b80d4a9887
Don't overwrite pci header type. Otherwise, multi function bit which pci_init_header_type() sets appropriately is lost. Anyway PCI_HEADER_TYPE_NORMAL is zero, so it is unnecessary to zero which is already zero cleared. how to test: run qemu and issue info pci to see whether a device in question is normal device, not pci-to-pci bridge. This is handy because guest os isn't required. tested changes: The following files are covered by using following commands. sparc64-softmmu apb_pci.c, vga-pci.c, cmd646.c, ne2k_pci.c, sun4u.c ppc-softmmu grackle_pci.c, cmd646.c, ne2k_pci.c, vga-pci.c, macio.c ppc-softmmu -M mac99 unin_pci.c(uni-north, uni-north-agp) ppc64-softmmu pci-ohci, ne2k_pci, vga-pci, unin_pci.c(u3-agp) x86_64-softmmu acpi_piix4.c, ide/piix.c, piix_pci.c -vga vmware vmware_vga.c -watchdog i6300esb wdt_i6300esb.c -usb usb-uhci.c -sound ac97 ac97.c -nic model=rtl8139 rtl8139.c -nic model=pcnet pcnet.c -balloon virtio virtio-pci.c: untested changes: The following changes aren't tested. prep_pci.c: ppc-softmmu -M prep should cover, but core dumped. unin_pci.c(uni-north-pci): the caller is commented out. openpic.c: the caller is commented out in ppc_prep.c Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
119 lines
4.4 KiB
C
119 lines
4.4 KiB
C
/*
|
|
* PowerMac MacIO device emulation
|
|
*
|
|
* Copyright (c) 2005-2007 Fabrice Bellard
|
|
* Copyright (c) 2007 Jocelyn Mayer
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*/
|
|
#include "hw.h"
|
|
#include "ppc_mac.h"
|
|
#include "pci.h"
|
|
#include "escc.h"
|
|
|
|
typedef struct macio_state_t macio_state_t;
|
|
struct macio_state_t {
|
|
int is_oldworld;
|
|
int pic_mem_index;
|
|
int dbdma_mem_index;
|
|
int cuda_mem_index;
|
|
int escc_mem_index;
|
|
void *nvram;
|
|
int nb_ide;
|
|
int ide_mem_index[4];
|
|
};
|
|
|
|
static void macio_map (PCIDevice *pci_dev, int region_num,
|
|
pcibus_t addr, pcibus_t size, int type)
|
|
{
|
|
macio_state_t *macio_state;
|
|
int i;
|
|
|
|
macio_state = (macio_state_t *)(pci_dev + 1);
|
|
if (macio_state->pic_mem_index >= 0) {
|
|
if (macio_state->is_oldworld) {
|
|
/* Heathrow PIC */
|
|
cpu_register_physical_memory(addr + 0x00000, 0x1000,
|
|
macio_state->pic_mem_index);
|
|
} else {
|
|
/* OpenPIC */
|
|
cpu_register_physical_memory(addr + 0x40000, 0x40000,
|
|
macio_state->pic_mem_index);
|
|
}
|
|
}
|
|
if (macio_state->dbdma_mem_index >= 0) {
|
|
cpu_register_physical_memory(addr + 0x08000, 0x1000,
|
|
macio_state->dbdma_mem_index);
|
|
}
|
|
if (macio_state->escc_mem_index >= 0) {
|
|
cpu_register_physical_memory(addr + 0x13000, ESCC_SIZE << 4,
|
|
macio_state->escc_mem_index);
|
|
}
|
|
if (macio_state->cuda_mem_index >= 0) {
|
|
cpu_register_physical_memory(addr + 0x16000, 0x2000,
|
|
macio_state->cuda_mem_index);
|
|
}
|
|
for (i = 0; i < macio_state->nb_ide; i++) {
|
|
if (macio_state->ide_mem_index[i] >= 0) {
|
|
cpu_register_physical_memory(addr + 0x1f000 + (i * 0x1000), 0x1000,
|
|
macio_state->ide_mem_index[i]);
|
|
}
|
|
}
|
|
if (macio_state->nvram != NULL)
|
|
macio_nvram_map(macio_state->nvram, addr + 0x60000);
|
|
}
|
|
|
|
void macio_init (PCIBus *bus, int device_id, int is_oldworld, int pic_mem_index,
|
|
int dbdma_mem_index, int cuda_mem_index, void *nvram,
|
|
int nb_ide, int *ide_mem_index, int escc_mem_index)
|
|
{
|
|
PCIDevice *d;
|
|
macio_state_t *macio_state;
|
|
int i;
|
|
|
|
d = pci_register_device(bus, "macio",
|
|
sizeof(PCIDevice) + sizeof(macio_state_t),
|
|
-1, NULL, NULL);
|
|
macio_state = (macio_state_t *)(d + 1);
|
|
macio_state->is_oldworld = is_oldworld;
|
|
macio_state->pic_mem_index = pic_mem_index;
|
|
macio_state->dbdma_mem_index = dbdma_mem_index;
|
|
macio_state->cuda_mem_index = cuda_mem_index;
|
|
macio_state->escc_mem_index = escc_mem_index;
|
|
macio_state->nvram = nvram;
|
|
if (nb_ide > 4)
|
|
nb_ide = 4;
|
|
macio_state->nb_ide = nb_ide;
|
|
for (i = 0; i < nb_ide; i++)
|
|
macio_state->ide_mem_index[i] = ide_mem_index[i];
|
|
for (; i < 4; i++)
|
|
macio_state->ide_mem_index[i] = -1;
|
|
/* Note: this code is strongly inspirated from the corresponding code
|
|
in PearPC */
|
|
|
|
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE);
|
|
pci_config_set_device_id(d->config, device_id);
|
|
pci_config_set_class(d->config, PCI_CLASS_OTHERS << 8);
|
|
|
|
d->config[0x3d] = 0x01; // interrupt on pin 1
|
|
|
|
pci_register_bar(d, 0, 0x80000,
|
|
PCI_BASE_ADDRESS_SPACE_MEMORY, macio_map);
|
|
}
|