Deleted Added
full compact
boot2.c (40307) boot2.c (40314)
1/*
2 * Copyright (c) 1998 Robert Nordier
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are freely
6 * permitted provided that the above copyright notice and this
7 * paragraph and the following disclaimer are duplicated in all
8 * such forms.
9 *
10 * This software is provided "AS IS" and without any express or
11 * implied warranties, including, without limitation, the implied
12 * warranties of merchantability and fitness for a particular
13 * purpose.
14 */
15
16/*
1/*
2 * Copyright (c) 1998 Robert Nordier
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are freely
6 * permitted provided that the above copyright notice and this
7 * paragraph and the following disclaimer are duplicated in all
8 * such forms.
9 *
10 * This software is provided "AS IS" and without any express or
11 * implied warranties, including, without limitation, the implied
12 * warranties of merchantability and fitness for a particular
13 * purpose.
14 */
15
16/*
17 * $Id: boot2.c,v 1.1.1.1 1998/10/12 21:16:26 rnordier Exp $
17 * $Id: boot2.c,v 1.2 1998/10/13 17:41:06 rnordier Exp $
18 */
19
20#include <sys/param.h>
21#include <sys/reboot.h>
22#include <sys/diskslice.h>
23#include <sys/disklabel.h>
24#include <sys/dirent.h>
25#include <machine/bootinfo.h>

--- 30 unchanged lines hidden (view full) ---

56#define MEM_EXT 0x15
57#define V86_CY(x) ((x) & 1)
58#define V86_ZR(x) ((x) & 0x40)
59
60#define DRV_HARD 0x80
61#define DRV_MASK 0x7f
62
63#define MAJ_WD 0
18 */
19
20#include <sys/param.h>
21#include <sys/reboot.h>
22#include <sys/diskslice.h>
23#include <sys/disklabel.h>
24#include <sys/dirent.h>
25#include <machine/bootinfo.h>

--- 30 unchanged lines hidden (view full) ---

56#define MEM_EXT 0x15
57#define V86_CY(x) ((x) & 1)
58#define V86_ZR(x) ((x) & 0x40)
59
60#define DRV_HARD 0x80
61#define DRV_MASK 0x7f
62
63#define MAJ_WD 0
64#define MAJ_WFD 1
64#define MAJ_WFD 1
65#define MAJ_FD 2
66#define MAJ_DA 4
67
68extern uint32_t _end;
69
70static const char optstr[NOPT] = "aCcdgrsv";
71static const unsigned char flags[NOPT] = {
72 RBX_ASKNAME,

--- 235 unchanged lines hidden (view full) ---

308 if (*arg < '0' || *arg > '9')
309 return -1;
310 drv = *arg - '0';
311 arg += 2;
312 }
313 if (q - arg != 2)
314 return -1;
315 for (i = 0; arg[0] != dev_nm[i][0] ||
65#define MAJ_FD 2
66#define MAJ_DA 4
67
68extern uint32_t _end;
69
70static const char optstr[NOPT] = "aCcdgrsv";
71static const unsigned char flags[NOPT] = {
72 RBX_ASKNAME,

--- 235 unchanged lines hidden (view full) ---

308 if (*arg < '0' || *arg > '9')
309 return -1;
310 drv = *arg - '0';
311 arg += 2;
312 }
313 if (q - arg != 2)
314 return -1;
315 for (i = 0; arg[0] != dev_nm[i][0] ||
316 arg[1] != dev_nm[i][1]; i++)
316 arg[1] != dev_nm[i][1]; i++)
317 if (i == NDEV - 1)
318 return -1;
319 dsk.type = i;
320 arg += 3;
321 if (arg[1] != ',' || *arg < '0' || *arg > '9')
322 return -1;
323 dsk.unit = *arg - '0';
324 arg += 2;
317 if (i == NDEV - 1)
318 return -1;
319 dsk.type = i;
320 arg += 3;
321 if (arg[1] != ',' || *arg < '0' || *arg > '9')
322 return -1;
323 dsk.unit = *arg - '0';
324 arg += 2;
325 dsk.slice = WHOLE_DISK_SLICE;
325 if (arg[1] == ',') {
326 if (arg[1] == ',') {
326 if (*arg < '0' || *arg > '4')
327 if (*arg < '0' || *arg > '0' + NDOSPART)
327 return -1;
328 if ((dsk.slice = *arg - '0'))
329 dsk.slice++;
330 arg += 2;
331 }
332 if (arg[1] != ')' || *arg < 'a' || *arg > 'p')
333 return -1;
334 dsk.part = *arg - 'a';

--- 162 unchanged lines hidden (view full) ---

497 struct dos_partition *dp;
498 struct disklabel *d;
499 unsigned sl, i;
500
501 if (!dsk.meta) {
502 if (!sec)
503 sec = malloc(DEV_BSIZE);
504 dsk.start = 0;
328 return -1;
329 if ((dsk.slice = *arg - '0'))
330 dsk.slice++;
331 arg += 2;
332 }
333 if (arg[1] != ')' || *arg < 'a' || *arg > 'p')
334 return -1;
335 dsk.part = *arg - 'a';

--- 162 unchanged lines hidden (view full) ---

498 struct dos_partition *dp;
499 struct disklabel *d;
500 unsigned sl, i;
501
502 if (!dsk.meta) {
503 if (!sec)
504 sec = malloc(DEV_BSIZE);
505 dsk.start = 0;
506 if (drvread(sec, DOSBBSECTOR, 1))
507 return -1;
508 dp = (void *)(sec + DOSPARTOFF);
505 sl = dsk.slice;
509 sl = dsk.slice;
510 if (sl < BASE_SLICE) {
511 for (i = 0; i < NDOSPART; i++)
512 if (dp[i].dp_typ == DOSPTYP_386BSD &&
513 (dp[i].dp_flag & 0x80 || sl < BASE_SLICE)) {
514 sl = BASE_SLICE + i;
515 if (dp[i].dp_flag & 0x80 ||
516 dsk.slice == COMPATIBILITY_SLICE)
517 break;
518 }
519 if (dsk.slice == WHOLE_DISK_SLICE)
520 dsk.slice = sl;
521 }
506 if (sl != WHOLE_DISK_SLICE) {
522 if (sl != WHOLE_DISK_SLICE) {
507 if (drvread(sec, DOSBBSECTOR, 1))
508 return -1;
509 dp = (void *)(sec + DOSPARTOFF);
510 if (sl == COMPATIBILITY_SLICE)
511 for (i = 0; i < NDOSPART; i++)
512 if (dp[i].dp_typ == DOSPTYP_386BSD &&
513 (dp[i].dp_flag & 0x80 ||
514 sl == COMPATIBILITY_SLICE))
515 sl = BASE_SLICE + i;
516 if (sl != COMPATIBILITY_SLICE)
517 dp += sl - BASE_SLICE;
518 if (dp->dp_typ != DOSPTYP_386BSD) {
519 printf("Invalid %s\n", "slice");
520 return -1;
521 }
522 dsk.start = dp->dp_start;
523 }
523 if (sl != COMPATIBILITY_SLICE)
524 dp += sl - BASE_SLICE;
525 if (dp->dp_typ != DOSPTYP_386BSD) {
526 printf("Invalid %s\n", "slice");
527 return -1;
528 }
529 dsk.start = dp->dp_start;
530 }
524 if (drvread(sec, dsk.start + LABELSECTOR, 1))
531 if (drvread(sec, dsk.start + LABELSECTOR, 1))
525 return -1;
526 d = (void *)(sec + LABELOFFSET);
527 if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC) {
528 if (dsk.part != RAW_PART) {
532 return -1;
533 d = (void *)(sec + LABELOFFSET);
534 if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC) {
535 if (dsk.part != RAW_PART) {
529 printf("Invalid %s\n", "label");
530 return -1;
536 printf("Invalid %s\n", "label");
537 return -1;
531 }
532 } else {
533 if (!dsk.init) {
538 }
539 } else {
540 if (!dsk.init) {
534 if (d->d_type == DTYPE_SCSI)
541 if (d->d_type == DTYPE_SCSI)
535 dsk.type = MAJ_DA;
536 dsk.init++;
537 }
538 if (dsk.part >= d->d_npartitions) {
539 printf("Invalid %s\n", "partition");
540 return -1;
541 }
542 dsk.start = d->d_partitions[dsk.part].p_offset;

--- 203 unchanged lines hidden ---
542 dsk.type = MAJ_DA;
543 dsk.init++;
544 }
545 if (dsk.part >= d->d_npartitions) {
546 printf("Invalid %s\n", "partition");
547 return -1;
548 }
549 dsk.start = d->d_partitions[dsk.part].p_offset;

--- 203 unchanged lines hidden ---