Revision 28c5af54 hw/pc.c

b/hw/pc.c
173 173
static void cmos_init(int ram_size, const char *boot_device, BlockDriverState **hd_table)
174 174
{
175 175
    RTCState *s = rtc_state;
176
    int nbds, bds[3] = { 0, };
176 177
    int val;
177 178
    int fd0, fd1, nb;
178 179
    int i;
......
202 203
    rtc_set_memory(s, 0x35, val >> 8);
203 204

  
204 205
    /* set boot devices, and disable floppy signature check if requested */
205
    rtc_set_memory(s, 0x3d,
206
            boot_device2nibble(boot_device[1]) << 4 |
207
            boot_device2nibble(boot_device[0]) );
208
    rtc_set_memory(s, 0x38,
209
            boot_device2nibble(boot_device[2]) << 4 | (fd_bootchk ?  0x0 : 0x1));
206
#define PC_MAX_BOOT_DEVICES 3
207
    nbds = strlen(boot_device);
208
    if (nbds > PC_MAX_BOOT_DEVICES) {
209
        fprintf(stderr, "Too many boot devices for PC\n");
210
        exit(1);
211
    }
212
    for (i = 0; i < nbds; i++) {
213
        bds[i] = boot_device2nibble(boot_device[i]);
214
        if (bds[i] == 0) {
215
            fprintf(stderr, "Invalid boot device for PC: '%c'\n",
216
                    boot_device[i]);
217
            exit(1);
218
        }
219
    }
220
    rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]);
221
    rtc_set_memory(s, 0x38, (bds[2] << 4) | (fd_bootchk ?  0x0 : 0x1));
210 222

  
211 223
    /* floppy type */
212 224

  

Also available in: Unified diff