From 28c5af54c661e73e5596918fa67a22b5e87c2022 Mon Sep 17 00:00:00 2001 From: j_mayer Date: Sun, 11 Nov 2007 01:50:45 +0000 Subject: 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 --- hw/pc.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'hw/pc.c') diff --git a/hw/pc.c b/hw/pc.c index 727ae3a..8c165ee 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 */ -- cgit v1.1