Lines Matching defs:od

102 static int	bd_getgeom(struct open_disk *od);
103 static int bd_read(struct open_disk *od, daddr_t dblk, int blks,
105 static int bd_write(struct open_disk *od, daddr_t dblk, int blks,
110 static void bd_printslice(struct open_disk *od, struct pc98_partition *dp,
112 static void bd_printbsdslice(struct open_disk *od, daddr_t offset,
137 static void bd_closedisk(struct open_disk *od);
138 static int bd_open_pc98(struct open_disk *od, struct i386_devdesc *dev);
139 static int bd_bestslice(struct open_disk *od);
140 static void bd_checkextended(struct open_disk *od, int slicenum);
251 struct open_disk *od;
263 if (!bd_opendisk(&od, &dev)) {
266 if (od->od_flags & BD_PARTTABOK) {
267 dptr = &od->od_slicetab[0];
270 for (j = 0; j < od->od_nslices; j++) {
272 bd_printslice(od, &dptr[j], line, verbose);
275 bd_closedisk(od);
308 bd_printslice(struct open_disk *od, struct pc98_partition *dp, char *prefix,
315 cylsecs = od->od_hds * od->od_sec;
316 start = dp->dp_scyl * cylsecs + dp->dp_shd * od->od_sec + dp->dp_ssect;
327 bd_printbsdslice(od, start, prefix, verbose);
354 bd_printbsdslice(struct open_disk *od, daddr_t offset, char *prefix,
363 if (bd_read(od, offset + LABELSECTOR, 1, buf))
384 (od->od_flags & BD_FLOPPY) && (i == 0))) {
421 struct open_disk *od;
427 if ((error = bd_opendisk(&od, dev)))
433 ((struct i386_devdesc *)(f->f_devdata))->d_kind.biosdisk.data = od;
434 DEBUG("open_disk %p, partition at 0x%x", od, od->od_boff);
441 struct open_disk *od;
449 od = (struct open_disk *)malloc(sizeof(struct open_disk));
450 if (!od) {
456 od->od_dkunit = dev->d_unit;
457 od->od_unit = bdinfo[od->od_dkunit].bd_unit;
458 od->od_flags = bdinfo[od->od_dkunit].bd_flags;
459 od->od_boff = 0;
466 if (bd_getgeom(od)) {
473 error = bd_open_pc98(od, dev);
477 free(od);
479 *odp = od; /* return the open disk */
485 bd_open_pc98(struct open_disk *od, struct i386_devdesc *dev)
501 od->od_nslices = 0;
502 if (od->od_flags & BD_FLOPPY) {
506 if (bd_read(od, 0, 1, buf)) {
523 if (bd_read(od, 1, 1, buf)) {
531 bcopy(buf + PC98_PARTOFF, &od->od_slicetab,
533 od->od_nslices = PC98_NPARTS; /* extended slices start here */
534 od->od_flags |= BD_PARTTABOK;
535 dptr = &od->od_slicetab[0];
548 if (slice >= od->od_nslices) {
556 slice = bd_bestslice(od);
563 dptr = &od->od_slicetab[0];
569 sector = dptr->dp_scyl * od->od_hds * od->od_sec +
570 dptr->dp_shd * od->od_sec + dptr->dp_ssect;
572 int end = dptr->dp_ecyl * od->od_hds * od->od_sec +
573 dptr->dp_ehd * od->od_sec + dptr->dp_esect;
592 od->od_boff = sector; /* no partition, must be after the slice */
596 if (bd_read(od, sector + LABELSECTOR, 1, buf)) {
600 DEBUG("copy %d bytes of label from %p to %p", sizeof(struct disklabel), buf + LABELOFFSET, &od->od_disklabel);
601 bcopy(buf + LABELOFFSET, &od->od_disklabel, sizeof(struct disklabel));
602 lp = &od->od_disklabel;
603 od->od_flags |= BD_LABELOK;
618 !(od->od_flags & BD_FLOPPY))
622 od->od_boff =
653 bd_bestslice(struct open_disk *od)
662 dp = &od->od_slicetab[0];
663 for (i = 0; i < od->od_nslices; i++, dp++) {
699 struct open_disk *od = (struct open_disk *)(((struct i386_devdesc *)(f->f_devdata))->d_kind.biosdisk.data);
701 bd_closedisk(od);
706 bd_closedisk(struct open_disk *od)
708 DEBUG("open_disk %p", od);
711 if (od->od_flags & BD_FLOPPY)
714 free(od);
721 struct open_disk *od = (struct open_disk *)(((struct i386_devdesc *)devdata)->d_kind.biosdisk.data);
725 return(bcache_strategy(&bcd, od->od_unit, rw, dblk+od->od_boff, size, buf, rsize));
731 struct open_disk *od = (struct open_disk *)(((struct i386_devdesc *)devdata)->d_kind.biosdisk.data);
743 DEBUG("open_disk %p", od);
752 if (blks && bd_read(od, dblk, blks, buf)) {
759 if (fragsize && bd_read(od, dblk + blks, 1, fragsize)) {
769 if (blks && bd_write(od, dblk, blks, buf)) {
794 bd_chs_io(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest, int write)
798 bpc = (od->od_sec * od->od_hds); /* blocks per cylinder */
802 hd = x / od->od_sec; /* offset / blocks per track */
803 sec = x % od->od_sec; /* offset into track */
808 v86.eax = 0x0500 | od->od_unit;
810 v86.eax = 0x0600 | od->od_unit;
811 if (od->od_flags & BD_FLOPPY) {
815 } else if (od->od_flags & BD_OPTICAL) {
831 bd_io(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest, int write)
855 x = min(od->od_sec, (unsigned)blks);
874 sec = dblk % od->od_sec; /* offset into track */
875 x = min(od->od_sec - sec, resid);
898 v86.eax = 0x0300 | od->od_unit;
902 result = bd_chs_io(od, dblk, x, xp, write);
928 bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
931 return (bd_io(od, dblk, blks, dest, 0));
935 bd_write(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest)
938 return (bd_io(od, dblk, blks, dest, 1));
942 bd_getgeom(struct open_disk *od)
945 if (od->od_flags & BD_FLOPPY) {
946 od->od_cyl = 79;
947 od->od_hds = 2;
948 od->od_sec = (od->od_unit & 0xf0) == 0x30 ? 18 : 15;
949 } else if (od->od_flags & BD_OPTICAL) {
950 od->od_cyl = 0xFFFE;
951 od->od_hds = 8;
952 od->od_sec = 32;
956 v86.eax = 0x8400 | od->od_unit;
959 od->od_cyl = v86.ecx;
960 od->od_hds = (v86.edx >> 8) & 0xff;
961 od->od_sec = v86.edx & 0xff;
966 DEBUG("unit 0x%x geometry %d/%d/%d", od->od_unit, od->od_cyl, od->od_hds, od->od_sec);
1027 struct open_disk *od;
1038 if (bd_opendisk(&od, dev) != 0) /* oops, not a viable device */
1052 if ((od->od_flags & BD_LABELOK) && (od->od_disklabel.d_type == DTYPE_SCSI)) {