make bootrom a machine parameter rather than a global argument

This commit is contained in:
espes 2013-04-18 13:00:53 +10:00
parent 6197413ba0
commit 573794771f
4 changed files with 28 additions and 30 deletions

View File

@ -20,8 +20,8 @@
#include "qemu/range.h"
#include "isa.h"
#include "sysbus.h"
#include "sysemu/sysemu.h"
#include "loader.h"
#include "qemu/config-file.h"
#include "pc.h"
#include "pci/pci.h"
#include "pci/pci_bus.h"
@ -241,25 +241,32 @@ static int xbox_lpc_initfn(PCIDevice *d)
/* southbridge chip contains and controls bootrom image.
* can't load it through loader.c because it overlaps with the bios...
* We really should just commandeer the entire top 16Mb.
*/
char *filename;
int rc, fd = -1;
if (bootrom_name
&& (filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bootrom_name))) {
s->bootrom_size = get_image_size(filename);
QemuOpts *machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
if (machine_opts) {
const char *bootrom_file = qemu_opt_get(machine_opts, "bootrom");
if (!bootrom_file) bootrom_file = "mcpx.bin";
if (s->bootrom_size != 512) {
fprintf(stderr, "MCPX bootrom should be 512 bytes, got %d\n",
s->bootrom_size);
return -1;
char *filename;
int rc, fd = -1;
if (bootrom_file
&& (filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bootrom_file))) {
s->bootrom_size = get_image_size(filename);
if (s->bootrom_size != 512) {
fprintf(stderr, "MCPX bootrom should be 512 bytes, got %d\n",
s->bootrom_size);
return -1;
}
fd = open(filename, O_RDONLY | O_BINARY);
assert(fd != -1);
rc = read(fd, s->bootrom_data, s->bootrom_size);
assert(rc == s->bootrom_size);
close(fd);
}
fd = open(filename, O_RDONLY | O_BINARY);
assert(fd != -1);
rc = read(fd, s->bootrom_data, s->bootrom_size);
assert(rc == s->bootrom_size);
close(fd);
}

View File

@ -13,7 +13,6 @@
/* vl.c */
extern const char *bios_name;
extern const char *bootrom_name;
extern const char *qemu_name;
extern uint8_t qemu_uuid[];

View File

@ -2624,14 +2624,6 @@ STEXI
Set the filename for the BIOS.
ETEXI
DEF("bootrom", HAS_ARG, QEMU_OPTION_bootrom, \
"-bootrom file set the filename for the boot rom\n", QEMU_ARCH_ALL)
STEXI
@item -bootrom @var{file}
@findex -bootrom
Set the filename for the boot rom.
ETEXI
DEF("enable-kvm", 0, QEMU_OPTION_enable_kvm, \
"-enable-kvm enable KVM full virtualization support\n", QEMU_ARCH_ALL)
STEXI

8
vl.c
View File

@ -182,7 +182,6 @@ int main(int argc, char **argv)
static const char *data_dir[16];
static int data_dir_idx;
const char *bios_name = NULL;
const char *bootrom_name = NULL;
enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
DisplayType display_type = DT_DEFAULT;
static int display_remote;
@ -430,6 +429,10 @@ static QemuOptsList qemu_machine_opts = {
.name = "usb",
.type = QEMU_OPT_BOOL,
.help = "Set on/off to enable/disable usb",
},{
.name = "bootrom",
.type = QEMU_OPT_STRING,
.help = "Xbox bootrom file",
},
{ /* End of list */ }
},
@ -3298,9 +3301,6 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_bios:
bios_name = optarg;
break;
case QEMU_OPTION_bootrom:
bootrom_name = optarg;
break;
case QEMU_OPTION_singlestep:
singlestep = 1;
break;