From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KllmO-0007zQ-KY for qemu-devel@nongnu.org; Fri, 03 Oct 2008 10:37:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KllmN-0007yu-Kt for qemu-devel@nongnu.org; Fri, 03 Oct 2008 10:37:16 -0400 Received: from [199.232.76.173] (port=40946 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KllmN-0007yo-CX for qemu-devel@nongnu.org; Fri, 03 Oct 2008 10:37:15 -0400 Received: from mail.free-electrons.com ([88.191.76.200]:59561) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KllmM-0006Ky-PF for qemu-devel@nongnu.org; Fri, 03 Oct 2008 10:37:15 -0400 Received: from surf (humanoidz.org [82.247.183.72]) by mail.free-electrons.com (Postfix) with ESMTPA id 97ED8E545 for ; Fri, 3 Oct 2008 16:39:28 +0200 (CEST) Date: Fri, 3 Oct 2008 16:37:13 +0200 From: Thomas Petazzoni Subject: Re: [Qemu-devel] [patch 4/4] Add Flash support to the Versatile PB platform Message-ID: <20081003163713.27fff17a@surf> In-Reply-To: <20081003154403.736e0e2b@surf> References: <20081002130214.299833919@free-electrons.com> <20081002130240.174723500@free-electrons.com> <200810021733.11290.paul@codesourcery.com> <20081003154403.736e0e2b@surf> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Le Fri, 3 Oct 2008 15:44:03 +0200, Thomas Petazzoni a =C3=A9crit : > Another solution is to set >=20 > .ram_require =3D 64 * 1024 * 1024 >=20 > So that 64 MB will always be allocated for the Flash. To these 64 MB, > the user-specified amount of memory is added for the RAM. The following patch implements this solution. The drawback is that these 64 MB of Flash are allocated even if the -pflash option is not passed. Thomas --- Add Flash support to the Versatile PB platform This patch adds the emulation of the 64 MB Intel Flash present at address 0x34000000 on the ARM Versatile PB platform, with a 256 KB sector size. This flash emulation is enabled using the -pflash option. If not enabled, Qemu falls back to the traditionnal way of loading the kernel. Signed-off-by: Thomas Petazzoni --- hw/versatilepb.c | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) Index: qemu/hw/versatilepb.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- qemu.orig/hw/versatilepb.c +++ qemu/hw/versatilepb.c @@ -15,6 +15,7 @@ #include "sysemu.h" #include "pci.h" #include "boards.h" +#include "flash.h" =20 /* Primary interrupt controller. */ =20 @@ -159,6 +160,10 @@ =20 static struct arm_boot_info versatile_binfo; =20 +#define VERSATILE_FLASH_ADDR 0x34000000 +#define VERSATILE_FLASH_SIZE (64 * 1024 * 1024) +#define VERSATILE_FLASH_SECT_SIZE (256 * 1024) + static void versatile_init(ram_addr_t ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, const char *kernel_filename, const char *kernel_cmd= line, @@ -174,6 +179,7 @@ int n; int done_smc =3D 0; int index; + int hasflash =3D 0; =20 if (!cpu_model) cpu_model =3D "arm926"; @@ -184,7 +190,8 @@ } /* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero. */ - cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); + cpu_register_physical_memory(0, ram_size, + qemu_ram_alloc(ram_size) | IO_MEM_RAM); =20 arm_sysctl_init(0x10000000, 0x41007004); pic =3D arm_pic_init_cpu(env); @@ -249,6 +256,21 @@ /* Add PL031 Real Time Clock. */ pl031_init(0x101e8000,pic[10]); =20 + index =3D drive_get_index(IF_PFLASH, 0, 0); + if (index !=3D -1) { + if (!pflash_cfi01_register(VERSATILE_FLASH_ADDR, + qemu_ram_alloc(VERSATILE_FLASH_SIZE), + drives_table[index].bdrv, + VERSATILE_FLASH_SECT_SIZE, + VERSATILE_FLASH_SIZE / VERSATILE_FLASH_SECT_SIZE, + 4, 0, 0, 0, 0)) { + fprintf(stderr, "qemu: error registering flash memory.\n"); + exit(1); + } + + hasflash =3D 1; + } + /* Memory map for Versatile/PB: */ /* 0x10000000 System registers. */ /* 0x10001000 PCI controller config registers. */ @@ -285,12 +307,17 @@ /* 0x101f3000 UART2. */ /* 0x101f4000 SSPI. */ =20 - versatile_binfo.ram_size =3D ram_size; - versatile_binfo.kernel_filename =3D kernel_filename; - versatile_binfo.kernel_cmdline =3D kernel_cmdline; - versatile_binfo.initrd_filename =3D initrd_filename; - versatile_binfo.board_id =3D board_id; - arm_load_kernel(env, &versatile_binfo); + if (! hasflash) { + versatile_binfo.ram_size =3D ram_size; + versatile_binfo.kernel_filename =3D kernel_filename; + versatile_binfo.kernel_cmdline =3D kernel_cmdline; + versatile_binfo.initrd_filename =3D initrd_filename; + versatile_binfo.board_id =3D board_id; + arm_load_kernel(env, &versatile_binfo); + } + else { + env->regs[15] =3D 0x34000000; + } } =20 static void vpb_init(ram_addr_t ram_size, int vga_ram_size, @@ -320,6 +347,7 @@ .desc =3D "ARM Versatile/PB (ARM926EJ-S)", .init =3D vpb_init, .use_scsi =3D 1, + .ram_require =3D VERSATILE_FLASH_SIZE, }; =20 QEMUMachine versatileab_machine =3D { @@ -327,4 +355,5 @@ .desc =3D "ARM Versatile/AB (ARM926EJ-S)", .init =3D vab_init, .use_scsi =3D 1, + .ram_require =3D VERSATILE_FLASH_SIZE, }; --=20 Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com