aboutsummaryrefslogtreecommitdiff
path: root/hw/pc.c
diff options
context:
space:
mode:
authorj_mayer <j_mayer@c046a42c-6fe2-441c-8c8c-71466251a162>2007-11-11 01:50:45 +0000
committerj_mayer <j_mayer@c046a42c-6fe2-441c-8c8c-71466251a162>2007-11-11 01:50:45 +0000
commit28c5af54c661e73e5596918fa67a22b5e87c2022 (patch)
tree23f4fcb5f64820a05bdd7e943e932acde49319d6 /hw/pc.c
parentaba9ee8726e3a06ba3e08d985531049e68c45181 (diff)
More generic boot devices specification, allowing more devices to be specified
and avoiding per-target hardcoded limitations. The machine implementations can then check if the given devices match the actual hardware implementation and firmware API. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3577 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/pc.c')
-rw-r--r--hw/pc.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/hw/pc.c b/hw/pc.c
index 727ae3a235..8c165ee5d0 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -173,6 +173,7 @@ static int boot_device2nibble(char boot_device)
static void cmos_init(int ram_size, const char *boot_device, BlockDriverState **hd_table)
{
RTCState *s = rtc_state;
+ int nbds, bds[3] = { 0, };
int val;
int fd0, fd1, nb;
int i;
@@ -202,11 +203,22 @@ static void cmos_init(int ram_size, const char *boot_device, BlockDriverState **
rtc_set_memory(s, 0x35, val >> 8);
/* set boot devices, and disable floppy signature check if requested */
- rtc_set_memory(s, 0x3d,
- boot_device2nibble(boot_device[1]) << 4 |
- boot_device2nibble(boot_device[0]) );
- rtc_set_memory(s, 0x38,
- boot_device2nibble(boot_device[2]) << 4 | (fd_bootchk ? 0x0 : 0x1));
+#define PC_MAX_BOOT_DEVICES 3
+ nbds = strlen(boot_device);
+ if (nbds > PC_MAX_BOOT_DEVICES) {
+ fprintf(stderr, "Too many boot devices for PC\n");
+ exit(1);
+ }
+ for (i = 0; i < nbds; i++) {
+ bds[i] = boot_device2nibble(boot_device[i]);
+ if (bds[i] == 0) {
+ fprintf(stderr, "Invalid boot device for PC: '%c'\n",
+ boot_device[i]);
+ exit(1);
+ }
+ }
+ rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]);
+ rtc_set_memory(s, 0x38, (bds[2] << 4) | (fd_bootchk ? 0x0 : 0x1));
/* floppy type */