2008-12-16 13:44:06 +03:00
|
|
|
/*
|
|
|
|
* Qemu PowerPC 440 chip emulation
|
|
|
|
*
|
|
|
|
* Copyright 2007 IBM Corporation.
|
|
|
|
* Authors:
|
|
|
|
* Jerone Young <jyoung5@us.ibm.com>
|
|
|
|
* Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
|
|
|
|
* Hollis Blanchard <hollisb@us.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the GNU GPL license version 2 or later.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "hw.h"
|
2009-08-15 18:27:05 +04:00
|
|
|
#include "pc.h"
|
2008-12-16 13:44:06 +03:00
|
|
|
#include "isa.h"
|
|
|
|
#include "ppc.h"
|
|
|
|
#include "ppc4xx.h"
|
|
|
|
#include "ppc440.h"
|
|
|
|
#include "ppc405.h"
|
|
|
|
#include "sysemu.h"
|
|
|
|
#include "kvm.h"
|
|
|
|
|
|
|
|
#define PPC440EP_PCI_CONFIG 0xeec00000
|
|
|
|
#define PPC440EP_PCI_INTACK 0xeed00000
|
|
|
|
#define PPC440EP_PCI_SPECIAL 0xeed00000
|
|
|
|
#define PPC440EP_PCI_REGS 0xef400000
|
|
|
|
#define PPC440EP_PCI_IO 0xe8000000
|
|
|
|
#define PPC440EP_PCI_IOLEN 0x00010000
|
|
|
|
|
|
|
|
#define PPC440EP_SDRAM_NR_BANKS 4
|
|
|
|
|
|
|
|
static const unsigned int ppc440ep_sdram_bank_sizes[] = {
|
|
|
|
256<<20, 128<<20, 64<<20, 32<<20, 16<<20, 8<<20, 0
|
|
|
|
};
|
|
|
|
|
2011-08-12 03:07:18 +04:00
|
|
|
CPUState *ppc440ep_init(MemoryRegion *address_space_mem, ram_addr_t *ram_size,
|
|
|
|
PCIBus **pcip, const unsigned int pci_irq_nrs[4],
|
|
|
|
int do_init, const char *cpu_model)
|
2008-12-16 13:44:06 +03:00
|
|
|
{
|
2011-08-15 18:17:27 +04:00
|
|
|
MemoryRegion *ram_memories
|
|
|
|
= g_malloc(PPC440EP_SDRAM_NR_BANKS * sizeof(*ram_memories));
|
2009-10-02 01:12:16 +04:00
|
|
|
target_phys_addr_t ram_bases[PPC440EP_SDRAM_NR_BANKS];
|
|
|
|
target_phys_addr_t ram_sizes[PPC440EP_SDRAM_NR_BANKS];
|
2008-12-16 13:44:06 +03:00
|
|
|
CPUState *env;
|
|
|
|
qemu_irq *pic;
|
|
|
|
qemu_irq *irqs;
|
|
|
|
qemu_irq *pci_irqs;
|
|
|
|
|
2011-06-16 20:49:22 +04:00
|
|
|
if (cpu_model == NULL) {
|
|
|
|
cpu_model = "440-Xilinx"; // XXX: should be 440EP
|
|
|
|
}
|
2009-06-17 19:49:37 +04:00
|
|
|
env = cpu_init(cpu_model);
|
2008-12-16 13:44:06 +03:00
|
|
|
if (!env) {
|
|
|
|
fprintf(stderr, "Unable to initialize CPU!\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
ppc_dcr_init(env, NULL, NULL);
|
|
|
|
|
|
|
|
/* interrupt controller */
|
2011-08-21 07:09:37 +04:00
|
|
|
irqs = g_malloc0(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
|
2008-12-16 13:44:06 +03:00
|
|
|
irqs[PPCUIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
|
|
|
|
irqs[PPCUIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];
|
|
|
|
pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);
|
|
|
|
|
|
|
|
/* SDRAM controller */
|
|
|
|
memset(ram_bases, 0, sizeof(ram_bases));
|
|
|
|
memset(ram_sizes, 0, sizeof(ram_sizes));
|
|
|
|
*ram_size = ppc4xx_sdram_adjust(*ram_size, PPC440EP_SDRAM_NR_BANKS,
|
2011-08-15 18:17:27 +04:00
|
|
|
ram_memories,
|
2008-12-16 13:44:06 +03:00
|
|
|
ram_bases, ram_sizes,
|
|
|
|
ppc440ep_sdram_bank_sizes);
|
|
|
|
/* XXX 440EP's ECC interrupts are on UIC1, but we've only created UIC0. */
|
2011-08-15 18:17:27 +04:00
|
|
|
ppc4xx_sdram_init(env, pic[14], PPC440EP_SDRAM_NR_BANKS, ram_memories,
|
|
|
|
ram_bases, ram_sizes, do_init);
|
2008-12-16 13:44:06 +03:00
|
|
|
|
|
|
|
/* PCI */
|
2011-08-21 07:09:37 +04:00
|
|
|
pci_irqs = g_malloc(sizeof(qemu_irq) * 4);
|
2008-12-16 13:44:06 +03:00
|
|
|
pci_irqs[0] = pic[pci_irq_nrs[0]];
|
|
|
|
pci_irqs[1] = pic[pci_irq_nrs[1]];
|
|
|
|
pci_irqs[2] = pic[pci_irq_nrs[2]];
|
|
|
|
pci_irqs[3] = pic[pci_irq_nrs[3]];
|
|
|
|
*pcip = ppc4xx_pci_init(env, pci_irqs,
|
|
|
|
PPC440EP_PCI_CONFIG,
|
|
|
|
PPC440EP_PCI_INTACK,
|
|
|
|
PPC440EP_PCI_SPECIAL,
|
|
|
|
PPC440EP_PCI_REGS);
|
|
|
|
if (!*pcip)
|
|
|
|
printf("couldn't create PCI controller!\n");
|
|
|
|
|
2010-12-08 14:05:49 +03:00
|
|
|
isa_mmio_init(PPC440EP_PCI_IO, PPC440EP_PCI_IOLEN);
|
2008-12-16 13:44:06 +03:00
|
|
|
|
2009-08-15 18:27:05 +04:00
|
|
|
if (serial_hds[0] != NULL) {
|
2011-08-12 03:07:18 +04:00
|
|
|
serial_mm_init(address_space_mem, 0xef600300, 0, pic[0],
|
2011-08-12 03:07:16 +04:00
|
|
|
PPC_SERIAL_MM_BAUDBASE, serial_hds[0],
|
|
|
|
DEVICE_BIG_ENDIAN);
|
2009-08-15 18:27:05 +04:00
|
|
|
}
|
|
|
|
if (serial_hds[1] != NULL) {
|
2011-08-12 03:07:18 +04:00
|
|
|
serial_mm_init(address_space_mem, 0xef600400, 0, pic[1],
|
2011-08-12 03:07:16 +04:00
|
|
|
PPC_SERIAL_MM_BAUDBASE, serial_hds[1],
|
|
|
|
DEVICE_BIG_ENDIAN);
|
2009-08-15 18:27:05 +04:00
|
|
|
}
|
2008-12-16 13:44:06 +03:00
|
|
|
|
|
|
|
return env;
|
|
|
|
}
|