pflash_cfi01: New pflash_cfi01_legacy_drive()

Factored out of pc_system_firmware_init() so the next commit can reuse
it in hw/arm/virt.c.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20190416091348.26075-3-armbru@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Markus Armbruster 2019-05-07 12:55:02 +01:00 committed by Peter Maydell
parent c8d8ef00a1
commit 2d731dbd5e
3 changed files with 31 additions and 14 deletions

View file

@ -269,9 +269,7 @@ void pc_system_firmware_init(PCMachineState *pcms,
{
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
int i;
DriveInfo *pflash_drv;
BlockBackend *pflash_blk[ARRAY_SIZE(pcms->flash)];
Location loc;
if (!pcmc->pci_enabled) {
old_pc_system_rom_init(rom_memory, true);
@ -280,18 +278,8 @@ void pc_system_firmware_init(PCMachineState *pcms,
/* Map legacy -drive if=pflash to machine properties */
for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) {
pflash_drv = drive_get(IF_PFLASH, 0, i);
if (pflash_drv) {
loc_push_none(&loc);
qemu_opts_loc_restore(pflash_drv->opts);
if (pflash_cfi01_get_blk(pcms->flash[i])) {
error_report("clashes with -machine");
exit(1);
}
qdev_prop_set_drive(DEVICE(pcms->flash[i]), "drive",
blk_by_legacy_dinfo(pflash_drv), &error_fatal);
loc_pop(&loc);
}
pflash_cfi01_legacy_drive(pcms->flash[i],
drive_get(IF_PFLASH, 0, i));
pflash_blk[i] = pflash_cfi01_get_blk(pcms->flash[i]);
}