2007-04-24 11:40:49 +04:00
|
|
|
/*
|
|
|
|
* QEMU PowerPC 405 evaluation boards emulation
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2007-04-24 11:40:49 +04:00
|
|
|
* Copyright (c) 2007 Jocelyn Mayer
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2007-04-24 11:40:49 +04:00
|
|
|
* 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.
|
|
|
|
*/
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/hw.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/ppc/ppc.h"
|
2013-03-18 20:36:02 +04:00
|
|
|
#include "ppc405.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/timer/m48t59.h"
|
|
|
|
#include "hw/block/flash.h"
|
2012-12-17 21:20:04 +04:00
|
|
|
#include "sysemu/sysemu.h"
|
2013-08-05 17:27:23 +04:00
|
|
|
#include "sysemu/qtest.h"
|
2012-12-17 21:19:44 +04:00
|
|
|
#include "block/block.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/boards.h"
|
2012-12-17 21:20:00 +04:00
|
|
|
#include "qemu/log.h"
|
2013-08-05 17:27:23 +04:00
|
|
|
#include "qemu/error-report.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/loader.h"
|
2012-12-17 21:20:04 +04:00
|
|
|
#include "sysemu/blockdev.h"
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "exec/address-spaces.h"
|
2007-04-24 11:40:49 +04:00
|
|
|
|
|
|
|
#define BIOS_FILENAME "ppc405_rom.bin"
|
|
|
|
#define BIOS_SIZE (2048 * 1024)
|
|
|
|
|
|
|
|
#define KERNEL_LOAD_ADDR 0x00000000
|
|
|
|
#define INITRD_LOAD_ADDR 0x01800000
|
|
|
|
|
|
|
|
#define USE_FLASH_BIOS
|
|
|
|
|
2013-08-05 17:27:21 +04:00
|
|
|
//#define DEBUG_BOARD_INIT
|
2007-04-24 11:40:49 +04:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* PPC405EP reference board (IBM) */
|
|
|
|
/* Standalone board with:
|
|
|
|
* - PowerPC 405EP CPU
|
|
|
|
* - SDRAM (0x00000000)
|
|
|
|
* - Flash (0xFFF80000)
|
|
|
|
* - SRAM (0xFFF00000)
|
|
|
|
* - NVRAM (0xF0000000)
|
|
|
|
* - FPGA (0xF0300000)
|
|
|
|
*/
|
2009-10-02 01:12:16 +04:00
|
|
|
typedef struct ref405ep_fpga_t ref405ep_fpga_t;
|
|
|
|
struct ref405ep_fpga_t {
|
2007-04-24 11:40:49 +04:00
|
|
|
uint8_t reg0;
|
|
|
|
uint8_t reg1;
|
|
|
|
};
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static uint32_t ref405ep_fpga_readb (void *opaque, hwaddr addr)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
2009-10-02 01:12:16 +04:00
|
|
|
ref405ep_fpga_t *fpga;
|
2007-04-24 11:40:49 +04:00
|
|
|
uint32_t ret;
|
|
|
|
|
|
|
|
fpga = opaque;
|
|
|
|
switch (addr) {
|
|
|
|
case 0x0:
|
|
|
|
ret = fpga->reg0;
|
|
|
|
break;
|
|
|
|
case 0x1:
|
|
|
|
ret = fpga->reg1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ref405ep_fpga_writeb (void *opaque,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr addr, uint32_t value)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
2009-10-02 01:12:16 +04:00
|
|
|
ref405ep_fpga_t *fpga;
|
2007-04-24 11:40:49 +04:00
|
|
|
|
|
|
|
fpga = opaque;
|
|
|
|
switch (addr) {
|
|
|
|
case 0x0:
|
|
|
|
/* Read only */
|
|
|
|
break;
|
|
|
|
case 0x1:
|
|
|
|
fpga->reg1 = value;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static uint32_t ref405ep_fpga_readw (void *opaque, hwaddr addr)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
|
|
|
uint32_t ret;
|
|
|
|
|
|
|
|
ret = ref405ep_fpga_readb(opaque, addr) << 8;
|
|
|
|
ret |= ref405ep_fpga_readb(opaque, addr + 1);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ref405ep_fpga_writew (void *opaque,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr addr, uint32_t value)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
|
|
|
ref405ep_fpga_writeb(opaque, addr, (value >> 8) & 0xFF);
|
|
|
|
ref405ep_fpga_writeb(opaque, addr + 1, value & 0xFF);
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static uint32_t ref405ep_fpga_readl (void *opaque, hwaddr addr)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
|
|
|
uint32_t ret;
|
|
|
|
|
|
|
|
ret = ref405ep_fpga_readb(opaque, addr) << 24;
|
|
|
|
ret |= ref405ep_fpga_readb(opaque, addr + 1) << 16;
|
|
|
|
ret |= ref405ep_fpga_readb(opaque, addr + 2) << 8;
|
|
|
|
ret |= ref405ep_fpga_readb(opaque, addr + 3);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ref405ep_fpga_writel (void *opaque,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr addr, uint32_t value)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
2008-12-12 01:43:07 +03:00
|
|
|
ref405ep_fpga_writeb(opaque, addr, (value >> 24) & 0xFF);
|
|
|
|
ref405ep_fpga_writeb(opaque, addr + 1, (value >> 16) & 0xFF);
|
|
|
|
ref405ep_fpga_writeb(opaque, addr + 2, (value >> 8) & 0xFF);
|
2007-04-24 11:40:49 +04:00
|
|
|
ref405ep_fpga_writeb(opaque, addr + 3, value & 0xFF);
|
|
|
|
}
|
|
|
|
|
2011-09-12 17:43:53 +04:00
|
|
|
static const MemoryRegionOps ref405ep_fpga_ops = {
|
|
|
|
.old_mmio = {
|
|
|
|
.read = {
|
|
|
|
ref405ep_fpga_readb, ref405ep_fpga_readw, ref405ep_fpga_readl,
|
|
|
|
},
|
|
|
|
.write = {
|
|
|
|
ref405ep_fpga_writeb, ref405ep_fpga_writew, ref405ep_fpga_writel,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
2007-04-24 11:40:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void ref405ep_fpga_reset (void *opaque)
|
|
|
|
{
|
2009-10-02 01:12:16 +04:00
|
|
|
ref405ep_fpga_t *fpga;
|
2007-04-24 11:40:49 +04:00
|
|
|
|
|
|
|
fpga = opaque;
|
|
|
|
fpga->reg0 = 0x00;
|
|
|
|
fpga->reg1 = 0x0F;
|
|
|
|
}
|
|
|
|
|
2012-10-16 00:22:02 +04:00
|
|
|
static void ref405ep_fpga_init(MemoryRegion *sysmem, uint32_t base)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
2009-10-02 01:12:16 +04:00
|
|
|
ref405ep_fpga_t *fpga;
|
2011-09-12 17:43:53 +04:00
|
|
|
MemoryRegion *fpga_memory = g_new(MemoryRegion, 1);
|
2007-04-24 11:40:49 +04:00
|
|
|
|
2011-08-21 07:09:37 +04:00
|
|
|
fpga = g_malloc0(sizeof(ref405ep_fpga_t));
|
2013-06-06 13:41:28 +04:00
|
|
|
memory_region_init_io(fpga_memory, NULL, &ref405ep_fpga_ops, fpga,
|
2011-09-12 17:43:53 +04:00
|
|
|
"fpga", 0x00000100);
|
|
|
|
memory_region_add_subregion(sysmem, base, fpga_memory);
|
2009-06-27 11:25:07 +04:00
|
|
|
qemu_register_reset(&ref405ep_fpga_reset, fpga);
|
2007-04-24 11:40:49 +04:00
|
|
|
}
|
|
|
|
|
2014-05-07 18:42:57 +04:00
|
|
|
static void ref405ep_init(MachineState *machine)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
2014-05-07 18:42:57 +04:00
|
|
|
ram_addr_t ram_size = machine->ram_size;
|
|
|
|
const char *kernel_filename = machine->kernel_filename;
|
|
|
|
const char *kernel_cmdline = machine->kernel_cmdline;
|
|
|
|
const char *initrd_filename = machine->initrd_filename;
|
2009-05-30 03:52:44 +04:00
|
|
|
char *filename;
|
2009-10-02 01:12:16 +04:00
|
|
|
ppc4xx_bd_info_t bd;
|
2007-04-24 11:40:49 +04:00
|
|
|
CPUPPCState *env;
|
|
|
|
qemu_irq *pic;
|
2011-08-04 16:55:30 +04:00
|
|
|
MemoryRegion *bios;
|
2011-09-12 17:43:53 +04:00
|
|
|
MemoryRegion *sram = g_new(MemoryRegion, 1);
|
|
|
|
ram_addr_t bdloc;
|
2011-08-15 18:17:27 +04:00
|
|
|
MemoryRegion *ram_memories = g_malloc(2 * sizeof(*ram_memories));
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr ram_bases[2], ram_sizes[2];
|
2010-09-18 09:53:14 +04:00
|
|
|
target_ulong sram_size;
|
|
|
|
long bios_size;
|
2007-04-24 11:40:49 +04:00
|
|
|
//int phy_addr = 0;
|
|
|
|
//static int phy_addr = 1;
|
2010-09-18 09:53:14 +04:00
|
|
|
target_ulong kernel_base, initrd_base;
|
|
|
|
long kernel_size, initrd_size;
|
2007-04-24 11:40:49 +04:00
|
|
|
int linux_boot;
|
|
|
|
int fl_idx, fl_sectors, len;
|
2009-07-22 18:42:57 +04:00
|
|
|
DriveInfo *dinfo;
|
2011-09-12 17:43:53 +04:00
|
|
|
MemoryRegion *sysmem = get_system_memory();
|
2007-04-24 11:40:49 +04:00
|
|
|
|
|
|
|
/* XXX: fix this */
|
2014-07-10 16:01:03 +04:00
|
|
|
memory_region_allocate_system_memory(&ram_memories[0], NULL, "ef405ep.ram",
|
|
|
|
0x08000000);
|
2011-08-15 18:17:27 +04:00
|
|
|
ram_bases[0] = 0;
|
2007-04-24 11:40:49 +04:00
|
|
|
ram_sizes[0] = 0x08000000;
|
2013-06-06 13:41:28 +04:00
|
|
|
memory_region_init(&ram_memories[1], NULL, "ef405ep.ram1", 0);
|
2007-04-24 11:40:49 +04:00
|
|
|
ram_bases[1] = 0x00000000;
|
|
|
|
ram_sizes[1] = 0x00000000;
|
|
|
|
ram_size = 128 * 1024 * 1024;
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
|
|
|
printf("%s: register cpu\n", __func__);
|
|
|
|
#endif
|
2011-09-12 17:43:53 +04:00
|
|
|
env = ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes,
|
2011-08-12 03:07:17 +04:00
|
|
|
33333333, &pic, kernel_filename == NULL ? 0 : 1);
|
2007-04-24 11:40:49 +04:00
|
|
|
/* allocate SRAM */
|
2009-04-10 18:29:45 +04:00
|
|
|
sram_size = 512 * 1024;
|
2014-09-09 09:27:55 +04:00
|
|
|
memory_region_init_ram(sram, NULL, "ef405ep.sram", sram_size, &error_abort);
|
ppc: fix -mem-path failure
commit e938ba0c tried to enable -mem-path for ppc but breaked some ppc
boards.
The problems are:
1. it fails when allocating memory for rom, sram whose sizes are less
than huge page size:
./ppc-softmmu/qemu-system-ppc -m 512 -mem-path /hugepages/ \
-kernel /home/hutao/Downloads/vmlinux-ppc -initrd \
/home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: /mnt/data/projects/qemu/exec.c:1184: qemu_ram_set_idstr: Assertion `new_block' failed.
2. if there is a numa node backed by memory backend object, qemu fails
with message:
./ppc-softmmu/qemu-system-ppc -m 512 \
-object memory-backend-file,size=512M,mem-path=/hugepages,id=f0 \
-numa node,nodeid=0,memdev=f0 \
-kernel /home/hutao/Downloads/vmlinux-ppc \
-initrd /home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: memory backend f0 is used multiple times. Each -numa option must use a different memdev value.
This patch does following:
1. replaces memory_region_allocate_system_memory() with
memory_region_init_ram() for rom, sram. Then only system memory
is backed by hugepages when specifying mem-path.
2. for memory banks, allocates all ram with
one memory_region_allocate_system_memory(), and use
memory_region_init_alias() to initialize memory banks.
Tested machines: default(g3beige), mac99, taihu, bamboo, ref405ep.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-07-21 13:30:17 +04:00
|
|
|
vmstate_register_ram_global(sram);
|
2011-09-12 17:43:53 +04:00
|
|
|
memory_region_add_subregion(sysmem, 0xFFF00000, sram);
|
2007-04-24 11:40:49 +04:00
|
|
|
/* allocate and load BIOS */
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
|
|
|
printf("%s: register BIOS\n", __func__);
|
|
|
|
#endif
|
|
|
|
fl_idx = 0;
|
|
|
|
#ifdef USE_FLASH_BIOS
|
2009-07-22 18:42:57 +04:00
|
|
|
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
|
|
|
if (dinfo) {
|
|
|
|
bios_size = bdrv_getlength(dinfo->bdrv);
|
2007-04-24 11:40:49 +04:00
|
|
|
fl_sectors = (bios_size + 65535) >> 16;
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
2010-09-18 09:53:14 +04:00
|
|
|
printf("Register parallel flash %d size %lx"
|
2011-08-04 16:55:30 +04:00
|
|
|
" at addr %lx '%s' %d\n",
|
|
|
|
fl_idx, bios_size, -bios_size,
|
2009-07-22 18:42:57 +04:00
|
|
|
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
|
2007-04-24 11:40:49 +04:00
|
|
|
#endif
|
2011-08-04 16:55:30 +04:00
|
|
|
pflash_cfi02_register((uint32_t)(-bios_size),
|
|
|
|
NULL, "ef405ep.bios", bios_size,
|
2009-07-22 18:42:57 +04:00
|
|
|
dinfo->bdrv, 65536, fl_sectors, 1,
|
2011-08-25 23:39:18 +04:00
|
|
|
2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
|
|
|
|
1);
|
2007-04-24 11:40:49 +04:00
|
|
|
fl_idx++;
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
|
|
|
printf("Load BIOS from file\n");
|
|
|
|
#endif
|
2011-08-04 16:55:30 +04:00
|
|
|
bios = g_new(MemoryRegion, 1);
|
2014-09-09 09:27:55 +04:00
|
|
|
memory_region_init_ram(bios, NULL, "ef405ep.bios", BIOS_SIZE,
|
|
|
|
&error_abort);
|
ppc: fix -mem-path failure
commit e938ba0c tried to enable -mem-path for ppc but breaked some ppc
boards.
The problems are:
1. it fails when allocating memory for rom, sram whose sizes are less
than huge page size:
./ppc-softmmu/qemu-system-ppc -m 512 -mem-path /hugepages/ \
-kernel /home/hutao/Downloads/vmlinux-ppc -initrd \
/home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: /mnt/data/projects/qemu/exec.c:1184: qemu_ram_set_idstr: Assertion `new_block' failed.
2. if there is a numa node backed by memory backend object, qemu fails
with message:
./ppc-softmmu/qemu-system-ppc -m 512 \
-object memory-backend-file,size=512M,mem-path=/hugepages,id=f0 \
-numa node,nodeid=0,memdev=f0 \
-kernel /home/hutao/Downloads/vmlinux-ppc \
-initrd /home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: memory backend f0 is used multiple times. Each -numa option must use a different memdev value.
This patch does following:
1. replaces memory_region_allocate_system_memory() with
memory_region_init_ram() for rom, sram. Then only system memory
is backed by hugepages when specifying mem-path.
2. for memory banks, allocates all ram with
one memory_region_allocate_system_memory(), and use
memory_region_init_alias() to initialize memory banks.
Tested machines: default(g3beige), mac99, taihu, bamboo, ref405ep.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-07-21 13:30:17 +04:00
|
|
|
vmstate_register_ram_global(bios);
|
|
|
|
|
2007-10-05 17:08:35 +04:00
|
|
|
if (bios_name == NULL)
|
|
|
|
bios_name = BIOS_FILENAME;
|
2009-05-30 03:52:44 +04:00
|
|
|
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
|
|
|
|
if (filename) {
|
2011-08-04 16:55:30 +04:00
|
|
|
bios_size = load_image(filename, memory_region_get_ram_ptr(bios));
|
2011-08-21 07:09:37 +04:00
|
|
|
g_free(filename);
|
2013-08-05 17:27:23 +04:00
|
|
|
if (bios_size < 0 || bios_size > BIOS_SIZE) {
|
|
|
|
error_report("Could not load PowerPC BIOS '%s'", bios_name);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
bios_size = (bios_size + 0xfff) & ~0xfff;
|
|
|
|
memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios);
|
|
|
|
} else if (!qtest_enabled() || kernel_filename != NULL) {
|
|
|
|
error_report("Could not load PowerPC BIOS '%s'", bios_name);
|
|
|
|
exit(1);
|
2009-05-30 03:52:44 +04:00
|
|
|
} else {
|
2013-08-05 17:27:23 +04:00
|
|
|
/* Avoid an uninitialized variable warning */
|
2009-05-30 03:52:44 +04:00
|
|
|
bios_size = -1;
|
|
|
|
}
|
2011-08-04 16:55:30 +04:00
|
|
|
memory_region_set_readonly(bios, true);
|
2007-04-24 11:40:49 +04:00
|
|
|
}
|
|
|
|
/* Register FPGA */
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
|
|
|
printf("%s: register FPGA\n", __func__);
|
|
|
|
#endif
|
2011-09-12 17:43:53 +04:00
|
|
|
ref405ep_fpga_init(sysmem, 0xF0300000);
|
2007-04-24 11:40:49 +04:00
|
|
|
/* Register NVRAM */
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
|
|
|
printf("%s: register NVRAM\n", __func__);
|
|
|
|
#endif
|
|
|
|
m48t59_init(NULL, 0xF0000000, 0, 8192, 8);
|
|
|
|
/* Load kernel */
|
|
|
|
linux_boot = (kernel_filename != NULL);
|
|
|
|
if (linux_boot) {
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
|
|
|
printf("%s: load kernel\n", __func__);
|
|
|
|
#endif
|
|
|
|
memset(&bd, 0, sizeof(bd));
|
|
|
|
bd.bi_memstart = 0x00000000;
|
|
|
|
bd.bi_memsize = ram_size;
|
2007-10-03 05:04:20 +04:00
|
|
|
bd.bi_flashstart = -bios_size;
|
2007-04-24 11:40:49 +04:00
|
|
|
bd.bi_flashsize = -bios_size;
|
|
|
|
bd.bi_flashoffset = 0;
|
|
|
|
bd.bi_sramstart = 0xFFF00000;
|
|
|
|
bd.bi_sramsize = sram_size;
|
|
|
|
bd.bi_bootflags = 0;
|
|
|
|
bd.bi_intfreq = 133333333;
|
|
|
|
bd.bi_busfreq = 33333333;
|
|
|
|
bd.bi_baudrate = 115200;
|
|
|
|
bd.bi_s_version[0] = 'Q';
|
|
|
|
bd.bi_s_version[1] = 'M';
|
|
|
|
bd.bi_s_version[2] = 'U';
|
|
|
|
bd.bi_s_version[3] = '\0';
|
|
|
|
bd.bi_r_version[0] = 'Q';
|
|
|
|
bd.bi_r_version[1] = 'E';
|
|
|
|
bd.bi_r_version[2] = 'M';
|
|
|
|
bd.bi_r_version[3] = 'U';
|
|
|
|
bd.bi_r_version[4] = '\0';
|
|
|
|
bd.bi_procfreq = 133333333;
|
|
|
|
bd.bi_plb_busfreq = 33333333;
|
|
|
|
bd.bi_pci_busfreq = 33333333;
|
|
|
|
bd.bi_opbfreq = 33333333;
|
2007-09-27 03:55:31 +04:00
|
|
|
bdloc = ppc405_set_bootinfo(env, &bd, 0x00000001);
|
2007-04-24 11:40:49 +04:00
|
|
|
env->gpr[3] = bdloc;
|
|
|
|
kernel_base = KERNEL_LOAD_ADDR;
|
|
|
|
/* now we can load the kernel */
|
2009-04-10 18:29:45 +04:00
|
|
|
kernel_size = load_image_targphys(kernel_filename, kernel_base,
|
|
|
|
ram_size - kernel_base);
|
2007-04-24 11:40:49 +04:00
|
|
|
if (kernel_size < 0) {
|
2007-09-17 01:08:06 +04:00
|
|
|
fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
2007-04-24 11:40:49 +04:00
|
|
|
kernel_filename);
|
|
|
|
exit(1);
|
|
|
|
}
|
2010-09-18 09:53:14 +04:00
|
|
|
printf("Load kernel size %ld at " TARGET_FMT_lx,
|
2009-04-10 18:29:45 +04:00
|
|
|
kernel_size, kernel_base);
|
2007-04-24 11:40:49 +04:00
|
|
|
/* load initrd */
|
|
|
|
if (initrd_filename) {
|
|
|
|
initrd_base = INITRD_LOAD_ADDR;
|
2009-04-10 18:29:45 +04:00
|
|
|
initrd_size = load_image_targphys(initrd_filename, initrd_base,
|
|
|
|
ram_size - initrd_base);
|
2007-04-24 11:40:49 +04:00
|
|
|
if (initrd_size < 0) {
|
2007-09-17 01:08:06 +04:00
|
|
|
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
|
2007-04-24 11:40:49 +04:00
|
|
|
initrd_filename);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
initrd_base = 0;
|
|
|
|
initrd_size = 0;
|
|
|
|
}
|
|
|
|
env->gpr[4] = initrd_base;
|
|
|
|
env->gpr[5] = initrd_size;
|
|
|
|
if (kernel_cmdline != NULL) {
|
|
|
|
len = strlen(kernel_cmdline);
|
|
|
|
bdloc -= ((len + 255) & ~255);
|
2013-04-12 22:53:58 +04:00
|
|
|
cpu_physical_memory_write(bdloc, kernel_cmdline, len + 1);
|
2007-04-24 11:40:49 +04:00
|
|
|
env->gpr[6] = bdloc;
|
|
|
|
env->gpr[7] = bdloc + len;
|
|
|
|
} else {
|
|
|
|
env->gpr[6] = 0;
|
|
|
|
env->gpr[7] = 0;
|
|
|
|
}
|
|
|
|
env->nip = KERNEL_LOAD_ADDR;
|
|
|
|
} else {
|
|
|
|
kernel_base = 0;
|
|
|
|
kernel_size = 0;
|
|
|
|
initrd_base = 0;
|
|
|
|
initrd_size = 0;
|
|
|
|
bdloc = 0;
|
|
|
|
}
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
2013-08-05 17:27:21 +04:00
|
|
|
printf("bdloc " RAM_ADDR_FMT "\n", bdloc);
|
2007-04-24 11:40:49 +04:00
|
|
|
printf("%s: Done\n", __func__);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-05-21 03:38:09 +04:00
|
|
|
static QEMUMachine ref405ep_machine = {
|
2008-10-08 00:34:35 +04:00
|
|
|
.name = "ref405ep",
|
|
|
|
.desc = "ref405ep",
|
|
|
|
.init = ref405ep_init,
|
2007-04-24 11:40:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* AMCC Taihu evaluation board */
|
|
|
|
/* - PowerPC 405EP processor
|
|
|
|
* - SDRAM 128 MB at 0x00000000
|
|
|
|
* - Boot flash 2 MB at 0xFFE00000
|
|
|
|
* - Application flash 32 MB at 0xFC000000
|
|
|
|
* - 2 serial ports
|
|
|
|
* - 2 ethernet PHY
|
|
|
|
* - 1 USB 1.1 device 0x50000000
|
|
|
|
* - 1 LCD display 0x50100000
|
|
|
|
* - 1 CPLD 0x50100000
|
|
|
|
* - 1 I2C EEPROM
|
|
|
|
* - 1 I2C thermal sensor
|
|
|
|
* - a set of LEDs
|
|
|
|
* - bit-bang SPI port using GPIOs
|
|
|
|
* - 1 EBC interface connector 0 0x50200000
|
|
|
|
* - 1 cardbus controller + expansion slot.
|
|
|
|
* - 1 PCI expansion slot.
|
|
|
|
*/
|
|
|
|
typedef struct taihu_cpld_t taihu_cpld_t;
|
|
|
|
struct taihu_cpld_t {
|
|
|
|
uint8_t reg0;
|
|
|
|
uint8_t reg1;
|
|
|
|
};
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static uint32_t taihu_cpld_readb (void *opaque, hwaddr addr)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
|
|
|
taihu_cpld_t *cpld;
|
|
|
|
uint32_t ret;
|
|
|
|
|
|
|
|
cpld = opaque;
|
|
|
|
switch (addr) {
|
|
|
|
case 0x0:
|
|
|
|
ret = cpld->reg0;
|
|
|
|
break;
|
|
|
|
case 0x1:
|
|
|
|
ret = cpld->reg1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void taihu_cpld_writeb (void *opaque,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr addr, uint32_t value)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
|
|
|
taihu_cpld_t *cpld;
|
|
|
|
|
|
|
|
cpld = opaque;
|
|
|
|
switch (addr) {
|
|
|
|
case 0x0:
|
|
|
|
/* Read only */
|
|
|
|
break;
|
|
|
|
case 0x1:
|
|
|
|
cpld->reg1 = value;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static uint32_t taihu_cpld_readw (void *opaque, hwaddr addr)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
|
|
|
uint32_t ret;
|
|
|
|
|
|
|
|
ret = taihu_cpld_readb(opaque, addr) << 8;
|
|
|
|
ret |= taihu_cpld_readb(opaque, addr + 1);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void taihu_cpld_writew (void *opaque,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr addr, uint32_t value)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
|
|
|
taihu_cpld_writeb(opaque, addr, (value >> 8) & 0xFF);
|
|
|
|
taihu_cpld_writeb(opaque, addr + 1, value & 0xFF);
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static uint32_t taihu_cpld_readl (void *opaque, hwaddr addr)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
|
|
|
uint32_t ret;
|
|
|
|
|
|
|
|
ret = taihu_cpld_readb(opaque, addr) << 24;
|
|
|
|
ret |= taihu_cpld_readb(opaque, addr + 1) << 16;
|
|
|
|
ret |= taihu_cpld_readb(opaque, addr + 2) << 8;
|
|
|
|
ret |= taihu_cpld_readb(opaque, addr + 3);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void taihu_cpld_writel (void *opaque,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr addr, uint32_t value)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
|
|
|
taihu_cpld_writel(opaque, addr, (value >> 24) & 0xFF);
|
|
|
|
taihu_cpld_writel(opaque, addr + 1, (value >> 16) & 0xFF);
|
|
|
|
taihu_cpld_writel(opaque, addr + 2, (value >> 8) & 0xFF);
|
|
|
|
taihu_cpld_writeb(opaque, addr + 3, value & 0xFF);
|
|
|
|
}
|
|
|
|
|
2011-09-12 17:43:53 +04:00
|
|
|
static const MemoryRegionOps taihu_cpld_ops = {
|
|
|
|
.old_mmio = {
|
|
|
|
.read = { taihu_cpld_readb, taihu_cpld_readw, taihu_cpld_readl, },
|
|
|
|
.write = { taihu_cpld_writeb, taihu_cpld_writew, taihu_cpld_writel, },
|
|
|
|
},
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
2007-04-24 11:40:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void taihu_cpld_reset (void *opaque)
|
|
|
|
{
|
|
|
|
taihu_cpld_t *cpld;
|
|
|
|
|
|
|
|
cpld = opaque;
|
|
|
|
cpld->reg0 = 0x01;
|
|
|
|
cpld->reg1 = 0x80;
|
|
|
|
}
|
|
|
|
|
2012-10-16 00:22:02 +04:00
|
|
|
static void taihu_cpld_init(MemoryRegion *sysmem, uint32_t base)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
|
|
|
taihu_cpld_t *cpld;
|
2011-09-12 17:43:53 +04:00
|
|
|
MemoryRegion *cpld_memory = g_new(MemoryRegion, 1);
|
2007-04-24 11:40:49 +04:00
|
|
|
|
2011-08-21 07:09:37 +04:00
|
|
|
cpld = g_malloc0(sizeof(taihu_cpld_t));
|
2013-06-06 13:41:28 +04:00
|
|
|
memory_region_init_io(cpld_memory, NULL, &taihu_cpld_ops, cpld, "cpld", 0x100);
|
2011-09-12 17:43:53 +04:00
|
|
|
memory_region_add_subregion(sysmem, base, cpld_memory);
|
2009-06-27 11:25:07 +04:00
|
|
|
qemu_register_reset(&taihu_cpld_reset, cpld);
|
2007-04-24 11:40:49 +04:00
|
|
|
}
|
|
|
|
|
2014-05-07 18:42:57 +04:00
|
|
|
static void taihu_405ep_init(MachineState *machine)
|
2007-04-24 11:40:49 +04:00
|
|
|
{
|
2014-05-07 18:42:57 +04:00
|
|
|
ram_addr_t ram_size = machine->ram_size;
|
|
|
|
const char *kernel_filename = machine->kernel_filename;
|
|
|
|
const char *initrd_filename = machine->initrd_filename;
|
2009-05-30 03:52:44 +04:00
|
|
|
char *filename;
|
2007-04-24 11:40:49 +04:00
|
|
|
qemu_irq *pic;
|
2011-09-12 17:43:53 +04:00
|
|
|
MemoryRegion *sysmem = get_system_memory();
|
2011-08-04 16:55:30 +04:00
|
|
|
MemoryRegion *bios;
|
2011-08-15 18:17:27 +04:00
|
|
|
MemoryRegion *ram_memories = g_malloc(2 * sizeof(*ram_memories));
|
ppc: fix -mem-path failure
commit e938ba0c tried to enable -mem-path for ppc but breaked some ppc
boards.
The problems are:
1. it fails when allocating memory for rom, sram whose sizes are less
than huge page size:
./ppc-softmmu/qemu-system-ppc -m 512 -mem-path /hugepages/ \
-kernel /home/hutao/Downloads/vmlinux-ppc -initrd \
/home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: /mnt/data/projects/qemu/exec.c:1184: qemu_ram_set_idstr: Assertion `new_block' failed.
2. if there is a numa node backed by memory backend object, qemu fails
with message:
./ppc-softmmu/qemu-system-ppc -m 512 \
-object memory-backend-file,size=512M,mem-path=/hugepages,id=f0 \
-numa node,nodeid=0,memdev=f0 \
-kernel /home/hutao/Downloads/vmlinux-ppc \
-initrd /home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: memory backend f0 is used multiple times. Each -numa option must use a different memdev value.
This patch does following:
1. replaces memory_region_allocate_system_memory() with
memory_region_init_ram() for rom, sram. Then only system memory
is backed by hugepages when specifying mem-path.
2. for memory banks, allocates all ram with
one memory_region_allocate_system_memory(), and use
memory_region_init_alias() to initialize memory banks.
Tested machines: default(g3beige), mac99, taihu, bamboo, ref405ep.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-07-21 13:30:17 +04:00
|
|
|
MemoryRegion *ram = g_malloc0(sizeof(*ram));
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr ram_bases[2], ram_sizes[2];
|
2010-09-18 09:53:14 +04:00
|
|
|
long bios_size;
|
|
|
|
target_ulong kernel_base, initrd_base;
|
|
|
|
long kernel_size, initrd_size;
|
2007-04-24 11:40:49 +04:00
|
|
|
int linux_boot;
|
|
|
|
int fl_idx, fl_sectors;
|
2009-07-22 18:42:57 +04:00
|
|
|
DriveInfo *dinfo;
|
2007-09-17 12:09:54 +04:00
|
|
|
|
2007-04-24 11:40:49 +04:00
|
|
|
/* RAM is soldered to the board so the size cannot be changed */
|
ppc: fix -mem-path failure
commit e938ba0c tried to enable -mem-path for ppc but breaked some ppc
boards.
The problems are:
1. it fails when allocating memory for rom, sram whose sizes are less
than huge page size:
./ppc-softmmu/qemu-system-ppc -m 512 -mem-path /hugepages/ \
-kernel /home/hutao/Downloads/vmlinux-ppc -initrd \
/home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: /mnt/data/projects/qemu/exec.c:1184: qemu_ram_set_idstr: Assertion `new_block' failed.
2. if there is a numa node backed by memory backend object, qemu fails
with message:
./ppc-softmmu/qemu-system-ppc -m 512 \
-object memory-backend-file,size=512M,mem-path=/hugepages,id=f0 \
-numa node,nodeid=0,memdev=f0 \
-kernel /home/hutao/Downloads/vmlinux-ppc \
-initrd /home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: memory backend f0 is used multiple times. Each -numa option must use a different memdev value.
This patch does following:
1. replaces memory_region_allocate_system_memory() with
memory_region_init_ram() for rom, sram. Then only system memory
is backed by hugepages when specifying mem-path.
2. for memory banks, allocates all ram with
one memory_region_allocate_system_memory(), and use
memory_region_init_alias() to initialize memory banks.
Tested machines: default(g3beige), mac99, taihu, bamboo, ref405ep.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-07-21 13:30:17 +04:00
|
|
|
ram_size = 0x08000000;
|
|
|
|
memory_region_allocate_system_memory(ram, NULL, "taihu_405ep.ram",
|
|
|
|
ram_size);
|
|
|
|
|
2011-08-15 18:17:27 +04:00
|
|
|
ram_bases[0] = 0;
|
2007-04-24 11:40:49 +04:00
|
|
|
ram_sizes[0] = 0x04000000;
|
ppc: fix -mem-path failure
commit e938ba0c tried to enable -mem-path for ppc but breaked some ppc
boards.
The problems are:
1. it fails when allocating memory for rom, sram whose sizes are less
than huge page size:
./ppc-softmmu/qemu-system-ppc -m 512 -mem-path /hugepages/ \
-kernel /home/hutao/Downloads/vmlinux-ppc -initrd \
/home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: /mnt/data/projects/qemu/exec.c:1184: qemu_ram_set_idstr: Assertion `new_block' failed.
2. if there is a numa node backed by memory backend object, qemu fails
with message:
./ppc-softmmu/qemu-system-ppc -m 512 \
-object memory-backend-file,size=512M,mem-path=/hugepages,id=f0 \
-numa node,nodeid=0,memdev=f0 \
-kernel /home/hutao/Downloads/vmlinux-ppc \
-initrd /home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: memory backend f0 is used multiple times. Each -numa option must use a different memdev value.
This patch does following:
1. replaces memory_region_allocate_system_memory() with
memory_region_init_ram() for rom, sram. Then only system memory
is backed by hugepages when specifying mem-path.
2. for memory banks, allocates all ram with
one memory_region_allocate_system_memory(), and use
memory_region_init_alias() to initialize memory banks.
Tested machines: default(g3beige), mac99, taihu, bamboo, ref405ep.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-07-21 13:30:17 +04:00
|
|
|
memory_region_init_alias(&ram_memories[0], NULL,
|
|
|
|
"taihu_405ep.ram-0", ram, ram_bases[0],
|
|
|
|
ram_sizes[0]);
|
2011-08-15 18:17:27 +04:00
|
|
|
ram_bases[1] = 0x04000000;
|
2007-04-24 11:40:49 +04:00
|
|
|
ram_sizes[1] = 0x04000000;
|
ppc: fix -mem-path failure
commit e938ba0c tried to enable -mem-path for ppc but breaked some ppc
boards.
The problems are:
1. it fails when allocating memory for rom, sram whose sizes are less
than huge page size:
./ppc-softmmu/qemu-system-ppc -m 512 -mem-path /hugepages/ \
-kernel /home/hutao/Downloads/vmlinux-ppc -initrd \
/home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: /mnt/data/projects/qemu/exec.c:1184: qemu_ram_set_idstr: Assertion `new_block' failed.
2. if there is a numa node backed by memory backend object, qemu fails
with message:
./ppc-softmmu/qemu-system-ppc -m 512 \
-object memory-backend-file,size=512M,mem-path=/hugepages,id=f0 \
-numa node,nodeid=0,memdev=f0 \
-kernel /home/hutao/Downloads/vmlinux-ppc \
-initrd /home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: memory backend f0 is used multiple times. Each -numa option must use a different memdev value.
This patch does following:
1. replaces memory_region_allocate_system_memory() with
memory_region_init_ram() for rom, sram. Then only system memory
is backed by hugepages when specifying mem-path.
2. for memory banks, allocates all ram with
one memory_region_allocate_system_memory(), and use
memory_region_init_alias() to initialize memory banks.
Tested machines: default(g3beige), mac99, taihu, bamboo, ref405ep.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-07-21 13:30:17 +04:00
|
|
|
memory_region_init_alias(&ram_memories[1], NULL,
|
|
|
|
"taihu_405ep.ram-1", ram, ram_bases[1],
|
|
|
|
ram_sizes[1]);
|
2007-04-24 11:40:49 +04:00
|
|
|
#ifdef DEBUG_BOARD_INIT
|
|
|
|
printf("%s: register cpu\n", __func__);
|
|
|
|
#endif
|
2011-09-12 17:43:53 +04:00
|
|
|
ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes,
|
2011-08-12 03:07:17 +04:00
|
|
|
33333333, &pic, kernel_filename == NULL ? 0 : 1);
|
2007-04-24 11:40:49 +04:00
|
|
|
/* allocate and load BIOS */
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
|
|
|
printf("%s: register BIOS\n", __func__);
|
|
|
|
#endif
|
|
|
|
fl_idx = 0;
|
|
|
|
#if defined(USE_FLASH_BIOS)
|
2009-07-22 18:42:57 +04:00
|
|
|
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
|
|
|
if (dinfo) {
|
|
|
|
bios_size = bdrv_getlength(dinfo->bdrv);
|
2007-04-24 11:40:49 +04:00
|
|
|
/* XXX: should check that size is 2MB */
|
|
|
|
// bios_size = 2 * 1024 * 1024;
|
|
|
|
fl_sectors = (bios_size + 65535) >> 16;
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
2010-09-18 09:53:14 +04:00
|
|
|
printf("Register parallel flash %d size %lx"
|
2011-08-04 16:55:30 +04:00
|
|
|
" at addr %lx '%s' %d\n",
|
|
|
|
fl_idx, bios_size, -bios_size,
|
2009-07-22 18:42:57 +04:00
|
|
|
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
|
2007-04-24 11:40:49 +04:00
|
|
|
#endif
|
2011-08-04 16:55:30 +04:00
|
|
|
pflash_cfi02_register((uint32_t)(-bios_size),
|
|
|
|
NULL, "taihu_405ep.bios", bios_size,
|
2009-07-22 18:42:57 +04:00
|
|
|
dinfo->bdrv, 65536, fl_sectors, 1,
|
2011-08-25 23:39:18 +04:00
|
|
|
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
|
|
|
|
1);
|
2007-04-24 11:40:49 +04:00
|
|
|
fl_idx++;
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
|
|
|
printf("Load BIOS from file\n");
|
|
|
|
#endif
|
2007-10-05 17:08:35 +04:00
|
|
|
if (bios_name == NULL)
|
|
|
|
bios_name = BIOS_FILENAME;
|
2011-08-04 16:55:30 +04:00
|
|
|
bios = g_new(MemoryRegion, 1);
|
2014-09-09 09:27:55 +04:00
|
|
|
memory_region_init_ram(bios, NULL, "taihu_405ep.bios", BIOS_SIZE,
|
|
|
|
&error_abort);
|
ppc: fix -mem-path failure
commit e938ba0c tried to enable -mem-path for ppc but breaked some ppc
boards.
The problems are:
1. it fails when allocating memory for rom, sram whose sizes are less
than huge page size:
./ppc-softmmu/qemu-system-ppc -m 512 -mem-path /hugepages/ \
-kernel /home/hutao/Downloads/vmlinux-ppc -initrd \
/home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: /mnt/data/projects/qemu/exec.c:1184: qemu_ram_set_idstr: Assertion `new_block' failed.
2. if there is a numa node backed by memory backend object, qemu fails
with message:
./ppc-softmmu/qemu-system-ppc -m 512 \
-object memory-backend-file,size=512M,mem-path=/hugepages,id=f0 \
-numa node,nodeid=0,memdev=f0 \
-kernel /home/hutao/Downloads/vmlinux-ppc \
-initrd /home/hutao/Downloads/initrd-ppc.gz
qemu-system-ppc: memory backend f0 is used multiple times. Each -numa option must use a different memdev value.
This patch does following:
1. replaces memory_region_allocate_system_memory() with
memory_region_init_ram() for rom, sram. Then only system memory
is backed by hugepages when specifying mem-path.
2. for memory banks, allocates all ram with
one memory_region_allocate_system_memory(), and use
memory_region_init_alias() to initialize memory banks.
Tested machines: default(g3beige), mac99, taihu, bamboo, ref405ep.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-07-21 13:30:17 +04:00
|
|
|
vmstate_register_ram_global(bios);
|
2009-05-30 03:52:44 +04:00
|
|
|
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
|
|
|
|
if (filename) {
|
2011-08-04 16:55:30 +04:00
|
|
|
bios_size = load_image(filename, memory_region_get_ram_ptr(bios));
|
2011-08-21 07:09:37 +04:00
|
|
|
g_free(filename);
|
2013-08-05 17:27:23 +04:00
|
|
|
if (bios_size < 0 || bios_size > BIOS_SIZE) {
|
|
|
|
error_report("Could not load PowerPC BIOS '%s'", bios_name);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
bios_size = (bios_size + 0xfff) & ~0xfff;
|
|
|
|
memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios);
|
|
|
|
} else if (!qtest_enabled()) {
|
|
|
|
error_report("Could not load PowerPC BIOS '%s'", bios_name);
|
2007-04-24 11:40:49 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
2011-08-04 16:55:30 +04:00
|
|
|
memory_region_set_readonly(bios, true);
|
2007-04-24 11:40:49 +04:00
|
|
|
}
|
|
|
|
/* Register Linux flash */
|
2009-07-22 18:42:57 +04:00
|
|
|
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
|
|
|
if (dinfo) {
|
|
|
|
bios_size = bdrv_getlength(dinfo->bdrv);
|
2007-04-24 11:40:49 +04:00
|
|
|
/* XXX: should check that size is 32MB */
|
|
|
|
bios_size = 32 * 1024 * 1024;
|
|
|
|
fl_sectors = (bios_size + 65535) >> 16;
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
2010-09-18 09:53:14 +04:00
|
|
|
printf("Register parallel flash %d size %lx"
|
2011-08-04 16:55:30 +04:00
|
|
|
" at addr " TARGET_FMT_lx " '%s'\n",
|
|
|
|
fl_idx, bios_size, (target_ulong)0xfc000000,
|
2009-07-22 18:42:57 +04:00
|
|
|
bdrv_get_device_name(dinfo->bdrv));
|
2007-04-24 11:40:49 +04:00
|
|
|
#endif
|
2011-08-04 16:55:30 +04:00
|
|
|
pflash_cfi02_register(0xfc000000, NULL, "taihu_405ep.flash", bios_size,
|
2009-07-22 18:42:57 +04:00
|
|
|
dinfo->bdrv, 65536, fl_sectors, 1,
|
2011-08-25 23:39:18 +04:00
|
|
|
4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
|
|
|
|
1);
|
2007-04-24 11:40:49 +04:00
|
|
|
fl_idx++;
|
|
|
|
}
|
|
|
|
/* Register CLPD & LCD display */
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
|
|
|
printf("%s: register CPLD\n", __func__);
|
|
|
|
#endif
|
2011-09-12 17:43:53 +04:00
|
|
|
taihu_cpld_init(sysmem, 0x50100000);
|
2007-04-24 11:40:49 +04:00
|
|
|
/* Load kernel */
|
|
|
|
linux_boot = (kernel_filename != NULL);
|
|
|
|
if (linux_boot) {
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
|
|
|
printf("%s: load kernel\n", __func__);
|
|
|
|
#endif
|
|
|
|
kernel_base = KERNEL_LOAD_ADDR;
|
|
|
|
/* now we can load the kernel */
|
2009-04-10 18:29:45 +04:00
|
|
|
kernel_size = load_image_targphys(kernel_filename, kernel_base,
|
|
|
|
ram_size - kernel_base);
|
2007-04-24 11:40:49 +04:00
|
|
|
if (kernel_size < 0) {
|
2007-09-17 01:08:06 +04:00
|
|
|
fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
2007-04-24 11:40:49 +04:00
|
|
|
kernel_filename);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
/* load initrd */
|
|
|
|
if (initrd_filename) {
|
|
|
|
initrd_base = INITRD_LOAD_ADDR;
|
2009-04-10 18:29:45 +04:00
|
|
|
initrd_size = load_image_targphys(initrd_filename, initrd_base,
|
|
|
|
ram_size - initrd_base);
|
2007-04-24 11:40:49 +04:00
|
|
|
if (initrd_size < 0) {
|
|
|
|
fprintf(stderr,
|
2007-09-17 01:08:06 +04:00
|
|
|
"qemu: could not load initial ram disk '%s'\n",
|
2007-04-24 11:40:49 +04:00
|
|
|
initrd_filename);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
initrd_base = 0;
|
|
|
|
initrd_size = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
kernel_base = 0;
|
|
|
|
kernel_size = 0;
|
|
|
|
initrd_base = 0;
|
|
|
|
initrd_size = 0;
|
|
|
|
}
|
|
|
|
#ifdef DEBUG_BOARD_INIT
|
|
|
|
printf("%s: Done\n", __func__);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-05-21 03:38:09 +04:00
|
|
|
static QEMUMachine taihu_machine = {
|
2009-04-11 21:41:32 +04:00
|
|
|
.name = "taihu",
|
|
|
|
.desc = "taihu",
|
|
|
|
.init = taihu_405ep_init,
|
2007-04-24 11:40:49 +04:00
|
|
|
};
|
2009-05-21 03:38:09 +04:00
|
|
|
|
|
|
|
static void ppc405_machine_init(void)
|
|
|
|
{
|
|
|
|
qemu_register_machine(&ref405ep_machine);
|
|
|
|
qemu_register_machine(&taihu_machine);
|
|
|
|
}
|
|
|
|
|
|
|
|
machine_init(ppc405_machine_init);
|