hw/pc: Support system flash memory with -pflash parameter
PATCH v2 1/1 hw/pc: Support system flash memory with -pflash parameter
From: Jordan Justen <[email protected]>
If -pflash is specified and -bios is specified then pflash will be mapped just below the system rom using the hw/pflash_cfi01.c interface.
If -pflash is specified on the command line, but -bios is not specified, then 'bios.bin' will NOT be loaded, and instead the -pflash flash image will be mapped just below 4GB in place of the normal rom image.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/pc.c | 155 +++++++++++++++++++++++++++--------- 3 files changed, 119 insertions(+), 38 deletions(-)
default-configs/i386-softmmu.mak +1 -0
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y CONFIG_SOUND=y CONFIG_HPET=y CONFIG_APPLESMC=y +CONFIG_PFLASH_CFI01=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y CONFIG_SOUND=y CONFIG_HPET=y CONFIG_APPLESMC=y +CONFIG_PFLASH_CFI01=y
hw/pc.c +117 -38
184 lines not on this page · raw message
Signature · 1 line
1.7.1
hw/pc.c void pc_cpus_init(const char *cpu_model) · line 968
Quoted 8 lines · On 03/24/11 03:07, [email protected] wrote:
hw/pc.c +8
-0+static void pc_isa_bios_init (ram_addr_t ram_offset,int ram_size) +{ +int isa_bios_size; + +/* map the last 128KB of the BIOS in ISA space */ + isa_bios_size = ram_size; +if (isa_bios_size > (128 *1024 )) + isa_bios_size =128 *1024 ;
You're missing braces here to comply with coding style. I realize some of the cosmetics comes from old code you are moving, but please fix it up in the move.
hw/pc.c void pc_cpus_init(const char *cpu_model) · line 971
Quoted 3 lines
hw/pc.c +3
-0+cpu_register_physical_memory (0x100000 - isa_bios_size, + isa_bios_size, + (ram_offset + ram_size - isa_bios_size) |IO_MEM_ROM );
A line is 80 characters, please wrap it or calculate the number before the function call.
Quoted 14 lines
hw/pc.c +14
-0+ bdrv = pflash_drv->bdrv; + size =bdrv_getlength (pflash_drv->bdrv); + sector_bits =12 ; + sector_size =1 << sector_bits; + +if ((size % sector_size) !=0 ) { +fprintf (stderr, +"qemu: -pflash size must be a multiple of 0x%x\n" , + sector_size); +exit (1 ); + } + + phys_addr =0x100000000ULL - rom_size - size; + addr =qemu_ram_alloc (NULL ,"system.flash" , size);
hw/pc.c void pc_cpus_init(const char *cpu_model) · line 1047
Quoted 10 lines
hw/pc.c +10
-0+DPRINTF ("flash addr: 0x%lx\n" , (int64_t )phys_addr); +#if 1 +pflash_cfi01_register (phys_addr, addr, bdrv, + sector_size, size >> sector_bits, +4 ,0x0000 ,0x0000 ,0x0000 ,0x0000 ,0 ); +#else +pflash_cfi02_register (phys_addr, addr, bdrv, + sector_size, size >> sector_bits, +1 ,4 ,0x0000 ,0x0000 ,0x0000 ,0x0000 ,0x55 ,0xaa ,0 ); +#endif
Please get rid of the #ifdef here.
Cheers,
Jes