Deleted Added
full compact
biosdisk.c (51586) biosdisk.c (53207)
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/boot/pc98/libpc98/biosdisk.c 51586 1999-09-23 03:57:16Z kato $
26 * $FreeBSD: head/sys/boot/pc98/libpc98/biosdisk.c 53207 1999-11-16 00:42:18Z nyan $
27 */
28
29/*
30 * BIOS disk device handling.
31 *
32 * Ideas and algorithms from:
33 *
34 * - NetBSD libi386/biosdisk.c

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

89 * BIOS unit number.
90 */
91static struct bdinfo
92{
93 int bd_unit; /* BIOS unit number */
94 int bd_flags;
95 int bd_type; /* BIOS 'drive type' (floppy only) */
96#ifdef PC98
27 */
28
29/*
30 * BIOS disk device handling.
31 *
32 * Ideas and algorithms from:
33 *
34 * - NetBSD libi386/biosdisk.c

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

89 * BIOS unit number.
90 */
91static struct bdinfo
92{
93 int bd_unit; /* BIOS unit number */
94 int bd_flags;
95 int bd_type; /* BIOS 'drive type' (floppy only) */
96#ifdef PC98
97 int bd_da_unit; /* kernel unit number for da */
97 int bd_da_unit; /* kernel unit number for da */
98#endif
99} bdinfo [MAXBDDEV];
100static int nbdinfo = 0;
101
102static int bd_getgeom(struct open_disk *od);
103static int bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest);
104
105static int bd_int13probe(struct bdinfo *bd);

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

222
223/*
224 * Try to detect a device supported by the legacy int13 BIOS
225 */
226
227static int
228bd_int13probe(struct bdinfo *bd)
229{
98#endif
99} bdinfo [MAXBDDEV];
100static int nbdinfo = 0;
101
102static int bd_getgeom(struct open_disk *od);
103static int bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest);
104
105static int bd_int13probe(struct bdinfo *bd);

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

222
223/*
224 * Try to detect a device supported by the legacy int13 BIOS
225 */
226
227static int
228bd_int13probe(struct bdinfo *bd)
229{
230
230#ifdef PC98
231 int addr;
232 if (bd->bd_flags & BD_FLOPPY){
233 addr = 0xa155c;
234 }
235 else {
236 if ((bd->bd_unit & 0xf0) == 0x80)
237 addr = 0xa155d;

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

530 * a partition to start with.
531 *
532 * XXX we might want to check the label checksum.
533 */
534 if (dev->d_kind.biosdisk.partition < 0) {
535 od->od_boff = sector; /* no partition, must be after the slice */
536 DEBUG("opening raw slice");
537 } else {
231#ifdef PC98
232 int addr;
233 if (bd->bd_flags & BD_FLOPPY){
234 addr = 0xa155c;
235 }
236 else {
237 if ((bd->bd_unit & 0xf0) == 0x80)
238 addr = 0xa155d;

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

531 * a partition to start with.
532 *
533 * XXX we might want to check the label checksum.
534 */
535 if (dev->d_kind.biosdisk.partition < 0) {
536 od->od_boff = sector; /* no partition, must be after the slice */
537 DEBUG("opening raw slice");
538 } else {
539
538 if (bd_read(od, sector + LABELSECTOR, 1, buf)) {
539 DEBUG("error reading disklabel");
540 error = EIO;
541 goto out;
542 }
543 DEBUG("copy %d bytes of label from %p to %p", sizeof(struct disklabel), buf + LABELOFFSET, &od->od_disklabel);
544 bcopy(buf + LABELOFFSET, &od->od_disklabel, sizeof(struct disklabel));
545 lp = &od->od_disklabel;

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

591#define PREF_NONE 4
592
593static int
594bd_bestslice(struct dos_partition *dptr)
595{
596 int i;
597 int preflevel, pref;
598
540 if (bd_read(od, sector + LABELSECTOR, 1, buf)) {
541 DEBUG("error reading disklabel");
542 error = EIO;
543 goto out;
544 }
545 DEBUG("copy %d bytes of label from %p to %p", sizeof(struct disklabel), buf + LABELOFFSET, &od->od_disklabel);
546 bcopy(buf + LABELOFFSET, &od->od_disklabel, sizeof(struct disklabel));
547 lp = &od->od_disklabel;

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

593#define PREF_NONE 4
594
595static int
596bd_bestslice(struct dos_partition *dptr)
597{
598 int i;
599 int preflevel, pref;
600
599
601
600#ifndef PC98
601 /*
602 * Check for the historically bogus MBR found on true dedicated disks
603 */
604 if ((dptr[3].dp_typ == DOSPTYP_386BSD) &&
605 (dptr[3].dp_start == 0) &&
606 (dptr[3].dp_size == 50000))
607 return(0);

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

933 od->od_hds = ((v86.edx & 0xff00) >> 8) + 1;
934 od->od_sec = v86.ecx & 0x3f;
935#endif
936
937 DEBUG("unit 0x%x geometry %d/%d/%d", od->od_unit, od->od_cyl, od->od_hds, od->od_sec);
938 return(0);
939}
940
602#ifndef PC98
603 /*
604 * Check for the historically bogus MBR found on true dedicated disks
605 */
606 if ((dptr[3].dp_typ == DOSPTYP_386BSD) &&
607 (dptr[3].dp_start == 0) &&
608 (dptr[3].dp_size == 50000))
609 return(0);

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

935 od->od_hds = ((v86.edx & 0xff00) >> 8) + 1;
936 od->od_sec = v86.ecx & 0x3f;
937#endif
938
939 DEBUG("unit 0x%x geometry %d/%d/%d", od->od_unit, od->od_cyl, od->od_hds, od->od_sec);
940 return(0);
941}
942
943#ifndef PC98
941/*
944/*
945 * Return the BIOS geometry of a given "fixed drive" in a format
946 * suitable for the legacy bootinfo structure. Since the kernel is
947 * expecting raw int 0x13/0x8 values for N_BIOS_GEOM drives, we
948 * prefer to get the information directly, rather than rely on being
949 * able to put it together from information already maintained for
950 * different purposes and for a probably different number of drives.
951 *
952 * For valid drives, the geometry is expected in the format (31..0)
953 * "000000cc cccccccc hhhhhhhh 00ssssss"; and invalid drives are
954 * indicated by returning the geometry of a "1.2M" PC-format floppy
955 * disk. And, incidentally, what is returned is not the geometry as
956 * such but the highest valid cylinder, head, and sector numbers.
957 */
958u_int32_t
959bd_getbigeom(int bunit)
960{
961
962 v86.ctl = V86_FLAGS;
963 v86.addr = 0x13;
964 v86.eax = 0x800;
965 v86.edx = 0x80 + bunit;
966 v86int();
967 if (v86.efl & 0x1)
968 return 0x4f010f;
969 return ((v86.ecx & 0xc0) << 18) | ((v86.ecx & 0xff00) << 8) |
970 (v86.edx & 0xff00) | (v86.ecx & 0x3f);
971}
972#endif
973
974/*
942 * Return a suitable dev_t value for (dev).
943 *
944 * In the case where it looks like (dev) is a SCSI disk, we allow the number of
945 * IDE disks to be specified in $num_ide_disks. There should be a Better Way.
946 */
947int
948bd_getdev(struct i386_devdesc *dev)
949{

--- 86 unchanged lines hidden ---
975 * Return a suitable dev_t value for (dev).
976 *
977 * In the case where it looks like (dev) is a SCSI disk, we allow the number of
978 * IDE disks to be specified in $num_ide_disks. There should be a Better Way.
979 */
980int
981bd_getdev(struct i386_devdesc *dev)
982{

--- 86 unchanged lines hidden ---