Revision d9346e81 hw/pc.c

b/hw/pc.c
230 230
    return 0;
231 231
}
232 232

  
233
/* copy/pasted from cmos_init, should be made a general function
234
 and used there as well */
235
static int pc_boot_set(void *opaque, const char *boot_device)
233
static int set_boot_dev(RTCState *s, const char *boot_device, int fd_bootchk)
236 234
{
237 235
#define PC_MAX_BOOT_DEVICES 3
238
    RTCState *s = (RTCState *)opaque;
239 236
    int nbds, bds[3] = { 0, };
240 237
    int i;
241 238

  
......
253 250
        }
254 251
    }
255 252
    rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]);
256
    rtc_set_memory(s, 0x38, (bds[2] << 4));
253
    rtc_set_memory(s, 0x38, (bds[2] << 4) | (fd_bootchk ? 0x0 : 0x1));
257 254
    return(0);
258 255
}
259 256

  
257
static int pc_boot_set(void *opaque, const char *boot_device)
258
{
259
    return set_boot_dev(opaque, boot_device, 0);
260
}
261

  
260 262
/* hd_table must contain 4 block drivers */
261 263
static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
262 264
                      const char *boot_device, DriveInfo **hd_table)
263 265
{
264 266
    RTCState *s = rtc_state;
265
    int nbds, bds[3] = { 0, };
266 267
    int val;
267 268
    int fd0, fd1, nb;
268 269
    int i;
......
301 302
    rtc_set_memory(s, 0x5f, smp_cpus - 1);
302 303

  
303 304
    /* set boot devices, and disable floppy signature check if requested */
304
#define PC_MAX_BOOT_DEVICES 3
305
    nbds = strlen(boot_device);
306
    if (nbds > PC_MAX_BOOT_DEVICES) {
307
        fprintf(stderr, "Too many boot devices for PC\n");
305
    if (set_boot_dev(s, boot_device, fd_bootchk)) {
308 306
        exit(1);
309 307
    }
310
    for (i = 0; i < nbds; i++) {
311
        bds[i] = boot_device2nibble(boot_device[i]);
312
        if (bds[i] == 0) {
313
            fprintf(stderr, "Invalid boot device for PC: '%c'\n",
314
                    boot_device[i]);
315
            exit(1);
316
        }
317
    }
318
    rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]);
319
    rtc_set_memory(s, 0x38, (bds[2] << 4) | (fd_bootchk ?  0x0 : 0x1));
320 308

  
321 309
    /* floppy type */
322 310

  

Also available in: Unified diff