diff options
Diffstat (limited to 'hw/pc.c')
-rw-r--r-- | hw/pc.c | 35 |
1 files changed, 11 insertions, 24 deletions
@@ -230,40 +230,40 @@ static int boot_device2nibble(char boot_device) return 0; } -/* copy/pasted from cmos_init, should be made a general function - and used there as well */ -static int pc_boot_set(void *opaque, const char *boot_device) +static int set_boot_dev(RTCState *s, const char *boot_device, int fd_bootchk) { - Monitor *mon = cur_mon; #define PC_MAX_BOOT_DEVICES 3 - RTCState *s = (RTCState *)opaque; int nbds, bds[3] = { 0, }; int i; nbds = strlen(boot_device); if (nbds > PC_MAX_BOOT_DEVICES) { - monitor_printf(mon, "Too many boot devices for PC\n"); + error_report("Too many boot devices for PC"); return(1); } for (i = 0; i < nbds; i++) { bds[i] = boot_device2nibble(boot_device[i]); if (bds[i] == 0) { - monitor_printf(mon, "Invalid boot device for PC: '%c'\n", - boot_device[i]); + error_report("Invalid boot device for PC: '%c'", + boot_device[i]); return(1); } } rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]); - rtc_set_memory(s, 0x38, (bds[2] << 4)); + rtc_set_memory(s, 0x38, (bds[2] << 4) | (fd_bootchk ? 0x0 : 0x1)); return(0); } +static int pc_boot_set(void *opaque, const char *boot_device) +{ + return set_boot_dev(opaque, boot_device, 0); +} + /* hd_table must contain 4 block drivers */ static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, const char *boot_device, DriveInfo **hd_table) { RTCState *s = rtc_state; - int nbds, bds[3] = { 0, }; int val; int fd0, fd1, nb; int i; @@ -302,22 +302,9 @@ static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, rtc_set_memory(s, 0x5f, smp_cpus - 1); /* set boot devices, and disable floppy signature check if requested */ -#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"); + if (set_boot_dev(s, boot_device, fd_bootchk)) { 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 */ |