PReP machine and devices

* ppc_rom.bin update
 * Raven PCI host bridge preparations for OpenBIOS
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJTIgblAAoJEPou0S0+fgE/kO0P/0QCzC8omYaBg5jTJvYLQhvw
 CQ1gOPp4HzundgK1fLXPhBOD6JhXK1uS0QnkwnrpnU69nSKL2snCdfb6rrN4BQRe
 L0MFjJmSQHW528DfUf4KbUhl+XeOZPiEnxjwXCUQdcVjVl1uo3DJHt1cur8adESW
 yoYxLbvMhkVxA3hhIXR/lZNiQBZVIxQ1DM92hgPtttiTEuC0yf+Ke9acyKrehi72
 xr5Ke2b6Osq3mR51X+8LOhmxV5zSmCEndP3gTHQ6ma1kOZ1Q0mbomrFjuhS6dWI0
 nNxi47A6roKLrwLH/ZMADaqJ1nviBWCQsNoKSwuT+rxLltvXhipY05pCRcTX0HQ8
 1Be9rcx83jEJnZMijwSComkML9W7e/fwFj6d3Au+t+k9xQwBj9iphR6u+gekgVwZ
 JxElpx2agjuEkKjCfL5oNBKJfXeAPDFGvtTYX85PHAHAHseZ1ygTBK8zBJ86JT2Q
 fUWTfZplPWmu8TFqeEyY7oYW2rMRtylblF3XC1G4NrvAvcAJvSTDpdPnNnuHgEf8
 aSISKxYJhea0mjIbqn/064yZfVYBGPzA5x8gsm0z4zetPtq7qo3LZjwzkwbsMQOW
 xNycQufNiIn+nMKWEf8SQj3alNNaFhltbRju2W8B+Rn2LVplOEB72frZ/lx5ea7F
 NMLotmkJV1fi9WZeIF63
 =rkuo
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/afaerber/tags/prep-for-2.0' into staging

PReP machine and devices

* ppc_rom.bin update
* Raven PCI host bridge preparations for OpenBIOS

# gpg: Signature made Thu 13 Mar 2014 19:28:37 GMT using RSA key ID 3E7E013F
# gpg: Good signature from "Andreas Färber <afaerber@suse.de>"
# gpg:                 aka "Andreas Färber <afaerber@suse.com>"

* remotes/afaerber/tags/prep-for-2.0:
  raven: Move BIOS loading from board code to PCI host
  prep: Update ppc_rom.bin

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2014-03-13 20:09:11 +00:00
commit 8bf0975902
4 changed files with 58 additions and 41 deletions

View File

@ -28,7 +28,9 @@
#include "hw/pci/pci_bus.h" #include "hw/pci/pci_bus.h"
#include "hw/pci/pci_host.h" #include "hw/pci/pci_host.h"
#include "hw/i386/pc.h" #include "hw/i386/pc.h"
#include "hw/loader.h"
#include "exec/address-spaces.h" #include "exec/address-spaces.h"
#include "elf.h"
#define TYPE_RAVEN_PCI_DEVICE "raven" #define TYPE_RAVEN_PCI_DEVICE "raven"
#define TYPE_RAVEN_PCI_HOST_BRIDGE "raven-pcihost" #define TYPE_RAVEN_PCI_HOST_BRIDGE "raven-pcihost"
@ -38,6 +40,10 @@
typedef struct RavenPCIState { typedef struct RavenPCIState {
PCIDevice dev; PCIDevice dev;
uint32_t elf_machine;
char *bios_name;
MemoryRegion bios;
} RavenPCIState; } RavenPCIState;
#define RAVEN_PCI_HOST_BRIDGE(obj) \ #define RAVEN_PCI_HOST_BRIDGE(obj) \
@ -52,6 +58,8 @@ typedef struct PRePPCIState {
RavenPCIState pci_dev; RavenPCIState pci_dev;
} PREPPCIState; } PREPPCIState;
#define BIOS_SIZE (1024 * 1024)
static inline uint32_t PPC_PCIIO_config(hwaddr addr) static inline uint32_t PPC_PCIIO_config(hwaddr addr)
{ {
int i; int i;
@ -169,10 +177,45 @@ static void raven_pcihost_initfn(Object *obj)
static int raven_init(PCIDevice *d) static int raven_init(PCIDevice *d)
{ {
RavenPCIState *s = RAVEN_PCI_DEVICE(d);
char *filename;
int bios_size = -1;
d->config[0x0C] = 0x08; // cache_line_size d->config[0x0C] = 0x08; // cache_line_size
d->config[0x0D] = 0x10; // latency_timer d->config[0x0D] = 0x10; // latency_timer
d->config[0x34] = 0x00; // capabilities_pointer d->config[0x34] = 0x00; // capabilities_pointer
memory_region_init_ram(&s->bios, OBJECT(s), "bios", BIOS_SIZE);
memory_region_set_readonly(&s->bios, true);
memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE),
&s->bios);
vmstate_register_ram_global(&s->bios);
if (s->bios_name) {
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, s->bios_name);
if (filename) {
if (s->elf_machine != EM_NONE) {
bios_size = load_elf(filename, NULL, NULL, NULL,
NULL, NULL, 1, s->elf_machine, 0);
}
if (bios_size < 0) {
bios_size = get_image_size(filename);
if (bios_size > 0 && bios_size <= BIOS_SIZE) {
hwaddr bios_addr;
bios_size = (bios_size + 0xfff) & ~0xfff;
bios_addr = (uint32_t)(-BIOS_SIZE);
bios_size = load_image_targphys(filename, bios_addr,
bios_size);
}
}
}
if (bios_size < 0 || bios_size > BIOS_SIZE) {
hw_error("qemu: could not load bios image '%s'\n", s->bios_name);
}
if (filename) {
g_free(filename);
}
}
return 0; return 0;
} }
@ -212,12 +255,20 @@ static const TypeInfo raven_info = {
.class_init = raven_class_init, .class_init = raven_class_init,
}; };
static Property raven_pcihost_properties[] = {
DEFINE_PROP_UINT32("elf-machine", PREPPCIState, pci_dev.elf_machine,
EM_NONE),
DEFINE_PROP_STRING("bios-name", PREPPCIState, pci_dev.bios_name),
DEFINE_PROP_END_OF_LIST()
};
static void raven_pcihost_class_init(ObjectClass *klass, void *data) static void raven_pcihost_class_init(ObjectClass *klass, void *data)
{ {
DeviceClass *dc = DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass);
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
dc->realize = raven_pcihost_realizefn; dc->realize = raven_pcihost_realizefn;
dc->props = raven_pcihost_properties;
dc->fw_name = "pci"; dc->fw_name = "pci";
} }

View File

@ -456,7 +456,6 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
MemoryRegion *sysmem = get_system_memory(); MemoryRegion *sysmem = get_system_memory();
PowerPCCPU *cpu = NULL; PowerPCCPU *cpu = NULL;
CPUPPCState *env = NULL; CPUPPCState *env = NULL;
char *filename;
nvram_t nvram; nvram_t nvram;
M48t59State *m48t59; M48t59State *m48t59;
MemoryRegion *PPC_io_memory = g_new(MemoryRegion, 1); MemoryRegion *PPC_io_memory = g_new(MemoryRegion, 1);
@ -464,9 +463,8 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
#if 0 #if 0
MemoryRegion *xcsr = g_new(MemoryRegion, 1); MemoryRegion *xcsr = g_new(MemoryRegion, 1);
#endif #endif
int linux_boot, i, nb_nics1, bios_size; int linux_boot, i, nb_nics1;
MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios = g_new(MemoryRegion, 1);
uint32_t kernel_base, initrd_base; uint32_t kernel_base, initrd_base;
long kernel_size, initrd_size; long kernel_size, initrd_size;
DeviceState *dev; DeviceState *dev;
@ -509,43 +507,6 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
vmstate_register_ram_global(ram); vmstate_register_ram_global(ram);
memory_region_add_subregion(sysmem, 0, ram); memory_region_add_subregion(sysmem, 0, ram);
/* allocate and load BIOS */
memory_region_init_ram(bios, NULL, "ppc_prep.bios", BIOS_SIZE);
memory_region_set_readonly(bios, true);
memory_region_add_subregion(sysmem, (uint32_t)(-BIOS_SIZE), bios);
vmstate_register_ram_global(bios);
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_elf(filename, NULL, NULL, NULL,
NULL, NULL, 1, ELF_MACHINE, 0);
if (bios_size < 0) {
bios_size = get_image_size(filename);
if (bios_size > 0 && bios_size <= BIOS_SIZE) {
hwaddr bios_addr;
bios_size = (bios_size + 0xfff) & ~0xfff;
bios_addr = (uint32_t)(-bios_size);
bios_size = load_image_targphys(filename, bios_addr, bios_size);
}
if (bios_size > BIOS_SIZE) {
fprintf(stderr, "qemu: PReP bios '%s' is too large (0x%x)\n",
bios_name, bios_size);
exit(1);
}
}
} else {
bios_size = -1;
}
if (bios_size < 0 && !qtest_enabled()) {
fprintf(stderr, "qemu: could not load PPC PReP bios '%s'\n",
bios_name);
exit(1);
}
if (filename) {
g_free(filename);
}
if (linux_boot) { if (linux_boot) {
kernel_base = KERNEL_LOAD_ADDR; kernel_base = KERNEL_LOAD_ADDR;
/* now we can load the kernel */ /* now we can load the kernel */
@ -593,6 +554,11 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
} }
dev = qdev_create(NULL, "raven-pcihost"); dev = qdev_create(NULL, "raven-pcihost");
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
qdev_prop_set_string(dev, "bios-name", bios_name);
qdev_prop_set_uint32(dev, "elf-machine", ELF_MACHINE);
pcihost = PCI_HOST_BRIDGE(dev); pcihost = PCI_HOST_BRIDGE(dev);
object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL); object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL);
qdev_init_nofail(dev); qdev_init_nofail(dev);

Binary file not shown.

@ -1 +1 @@
Subproject commit e9829b5584169ad14df2ca8776b87f4985aa9f06 Subproject commit 1af7e55425e58a6dcb5133b092fcf16f8c654fb9