Lines Matching refs:bd

196 	bdinfo_t *bd = NULL;
201 return (bd);
204 STAILQ_FOREACH(bd, bdi, bd_link) {
206 return (bd);
209 return (bd);
219 bdinfo_t *bd;
225 STAILQ_FOREACH(bd, bdi[i], bd_link) {
226 if (bd->bd_unit == biosdev) {
227 DEBUG("bd unit %d is BIOS device 0x%x", unit,
228 bd->bd_unit);
241 bdinfo_t *bd;
249 STAILQ_FOREACH(bd, bdi, bd_link) {
251 return (bd->bd_unit);
291 bdinfo_t *bd;
295 if ((bd = calloc(1, sizeof(*bd))) == NULL)
298 bd->bd_sectorsize = BIOSDISK_SECSIZE;
299 bd->bd_flags = BD_FLOPPY;
300 bd->bd_unit = unit;
303 if (bd_get_diskinfo_std(bd) != 0) {
304 free(bd);
307 if (bd->bd_sectors == 0)
308 bd->bd_flags |= BD_NO_MEDIA;
313 STAILQ_INSERT_TAIL(&fdinfo, bd, bd_link);
324 bdinfo_t *bd;
331 if ((bd = calloc(1, sizeof(*bd))) == NULL)
333 bd->bd_unit = base + unit;
334 if (!bd_int13probe(bd)) {
335 free(bd);
342 STAILQ_INSERT_TAIL(&hdinfo, bd, bd_link);
364 bd_get_diskinfo_cd(struct bdinfo *bd)
376 v86.edx = bd->bd_unit;
382 bc_sp.sp_drive == bd->bd_unit) {
383 bd->bd_cyl = ((bc_sp.sp_cylsec & 0xc0) << 2) +
385 bd->bd_sec = bc_sp.sp_cylsec & 0x3f;
386 bd->bd_hds = bc_sp.sp_head + 1;
387 bd->bd_sectors = (uint64_t)bd->bd_cyl * bd->bd_hds * bd->bd_sec;
391 bd->bd_sectorsize = BIOSDISK_SECSIZE;
394 bd->bd_sectorsize = 2048;
395 bd->bd_flags = BD_MODEEDD | BD_CDROM;
403 if (ret != 0 && bd->bd_unit >= 0x88) {
404 bd->bd_cyl = 0;
405 bd->bd_hds = 1;
406 bd->bd_sec = 15;
407 bd->bd_sectorsize = 2048;
408 bd->bd_flags = BD_MODEEDD | BD_CDROM;
409 bd->bd_sectors = 0;
422 if (bd->bd_sectors == 0)
423 bd->bd_sectors = 4173824;
431 bdinfo_t *bd;
437 if ((bd = calloc(1, sizeof(*bd))) == NULL)
440 bd->bd_unit = biosdev;
441 if (bd_get_diskinfo_cd(bd) < 0) {
442 free(bd);
446 STAILQ_INSERT_TAIL(&cdinfo, bd, bd_link);
497 bd_get_diskinfo_std(struct bdinfo *bd)
503 v86.edx = bd->bd_unit;
513 bd->bd_cyl = ((v86.ecx & 0xc0) << 2) + ((v86.ecx & 0xff00) >> 8) + 1;
515 bd->bd_hds = ((v86.edx & 0xff00) >> 8) + 1;
516 bd->bd_sec = v86.ecx & 0x3f;
517 bd->bd_type = v86.ebx;
518 bd->bd_sectors = (uint64_t)bd->bd_cyl * bd->bd_hds * bd->bd_sec;
530 bd_get_diskinfo_ext(struct bdinfo *bd)
548 v86.edx = bd->bd_unit;
565 bd->bd_sectorsize = params->sector_size;
567 bd->bd_cyl = params->cylinders;
568 bd->bd_hds = params->heads;
569 bd->bd_sec = params->sectors_per_track;
577 bd->bd_sectors = total;
586 bd_int13probe(bdinfo_t *bd)
590 bd->bd_flags &= ~BD_NO_MEDIA;
592 if ((bd->bd_flags & BD_CDROM) != 0) {
593 return (bd_get_diskinfo_cd(bd) == 0);
596 edd = bd_check_extensions(bd->bd_unit);
598 bd->bd_flags |= BD_MODEINT13;
600 bd->bd_flags |= BD_MODEEDD1;
602 bd->bd_flags |= BD_MODEEDD3;
605 if (bd->bd_sectorsize == 0)
606 bd->bd_sectorsize = BIOSDISK_SECSIZE;
612 if (bd->bd_unit < 0x80) {
614 bd_reset_disk(bd->bd_unit);
620 v86.edx = bd->bd_unit;
628 ret = bd_get_diskinfo_ext(bd);
629 if (ret != 0 || bd->bd_sectors == 0)
630 ret = bd_get_diskinfo_std(bd);
632 if (ret != 0 && bd->bd_unit < 0x80) {
634 bd->bd_cyl = 80;
635 bd->bd_hds = 2;
636 bd->bd_sec = 18;
637 bd->bd_sectors = 2880;
639 bd->bd_flags |= BD_NO_MEDIA;
644 if (bd->bd_sectors != 0 && edd != 0) {
645 bd->bd_sec = 63;
646 bd->bd_hds = 255;
647 bd->bd_cyl =
648 (bd->bd_sectors + bd->bd_sec * bd->bd_hds - 1) /
649 bd->bd_sec * bd->bd_hds;
653 if ((bd->bd_flags & BD_FLOPPY) != 0)
659 dv_name, bd->bd_unit);
664 if (bd->bd_sec == 0)
665 bd->bd_sec = 63;
666 if (bd->bd_hds == 0)
667 bd->bd_hds = 255;
669 if (bd->bd_sectors == 0)
670 bd->bd_sectors = (uint64_t)bd->bd_cyl * bd->bd_hds * bd->bd_sec;
672 DEBUG("unit 0x%x geometry %d/%d/%d\n", bd->bd_unit, bd->bd_cyl,
673 bd->bd_hds, bd->bd_sec);
681 bdinfo_t *bd;
685 STAILQ_FOREACH(bd, bdi, bd_link)
698 bdinfo_t *bd;
710 STAILQ_FOREACH(bd, bdi, bd_link) {
728 (bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA ?
730 (uintmax_t)bd->bd_sectors,
731 bd->bd_sectorsize);
735 if ((bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA)
746 bd->bd_sectorsize * bd->bd_sectors,
747 bd->bd_sectorsize) == 0) {
787 bdinfo_t *bd;
791 bd = bd_get_bdinfo(&dev->dd);
792 if (bd == NULL)
801 size = bd->bd_sectors * bd->bd_sectorsize;
802 if (disk_open(&disk, size, bd->bd_sectorsize) == 0) {
806 return (size / bd->bd_sectorsize);
822 bdinfo_t *bd;
831 bd = bd_get_bdinfo(&dev->dd);
832 if (bd == NULL)
835 if ((bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) {
836 if (!bd_int13probe(bd))
838 if ((bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA)
841 if (bd->bd_bcache == NULL)
842 bd->bd_bcache = bcache_allocate();
844 if (bd->bd_open == 0)
845 bd->bd_sectors = bd_disk_get_sectors(dev);
846 bd->bd_open++;
850 rc = disk_open(dev, bd->bd_sectors * bd->bd_sectorsize,
851 bd->bd_sectorsize);
853 bd->bd_open--;
854 if (bd->bd_open == 0) {
855 bcache_free(bd->bd_bcache);
856 bd->bd_bcache = NULL;
867 bdinfo_t *bd;
871 bd = bd_get_bdinfo(&dev->dd);
872 if (bd == NULL)
875 bd->bd_open--;
876 if (bd->bd_open == 0) {
877 bcache_free(bd->bd_bcache);
878 bd->bd_bcache = NULL;
888 bdinfo_t *bd;
893 bd = bd_get_bdinfo(&dev->dd);
894 if (bd == NULL)
905 *(uint32_t *)data = bd->bd_sectorsize;
908 *(uint64_t *)data = bd->bd_sectors * bd->bd_sectorsize;
920 bdinfo_t *bd;
926 bd = bd_get_bdinfo(&dev->dd);
927 if (bd == NULL)
932 bcd.dv_cache = bd->bd_bcache;
937 offset = dev->d_offset * bd->bd_sectorsize;
949 bdinfo_t *bd;
955 bd = bd_get_bdinfo(&dev->dd);
956 if (bd == NULL || (bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA)
974 dblk = offset / bd->bd_sectorsize;
975 blkoff = offset % bd->bd_sectorsize;
988 blks = size / bd->bd_sectorsize;
989 if (blks == 0 || (size % bd->bd_sectorsize) != 0)
1007 disk_blocks /= bd->bd_sectorsize;
1012 disk_blocks = bd->bd_sectors - d_offset;
1023 size = blks * bd->bd_sectorsize;
1028 while (bio_size > bd->bd_sectorsize) {
1032 bio_size -= bd->bd_sectorsize;
1036 if (bio_size / bd->bd_sectorsize == 0)
1045 int x = min(blks, bio_size / bd->bd_sectorsize);
1050 bsize = bd->bd_sectorsize * x - blkoff;
1054 if ((rc = bd_io(dev, bd, dblk, x, bbuf, BD_RD)) != 0) {
1069 bsize = bd->bd_sectorsize - blkoff;
1071 rc = bd_io(dev, bd, dblk, x, bbuf, BD_RD);
1072 } else if (rest < bd->bd_sectorsize) {
1079 rc = bd_io(dev, bd, dblk, x, bbuf, BD_RD);
1082 bsize = bd->bd_sectorsize * x;
1089 if ((rc = bd_io(dev, bd, dblk, x, bbuf, BD_WR)) != 0) {
1117 bd_edd_io(bdinfo_t *bd, daddr_t dblk, int blks, caddr_t dest,
1134 v86.edx = bd->bd_unit;
1144 bd_chs_io(bdinfo_t *bd, daddr_t dblk, int blks, caddr_t dest,
1149 bpc = bd->bd_sec * bd->bd_hds; /* blocks per cylinder */
1153 hd = x / bd->bd_sec; /* offset / blocks per track */
1154 sec = x % bd->bd_sec; /* offset into track */
1171 v86.edx = (hd << 8) | bd->bd_unit;
1181 bd_io_workaround(bdinfo_t *bd)
1185 bd_edd_io(bd, 0xffffffff, 1, (caddr_t)buf, BD_RD);
1189 bd_io(struct disk_devdesc *dev, bdinfo_t *bd, daddr_t dblk, int blks,
1210 bd_io_workaround(bd);
1212 if (bd->bd_flags & BD_MODEEDD)
1213 result = bd_edd_io(bd, dblk, blks, dest, dowrite);
1215 result = bd_chs_io(bd, dblk, blks, dest, dowrite);
1218 if (bd->bd_flags & BD_NO_MEDIA)
1219 bd->bd_flags &= ~BD_NO_MEDIA;
1223 bd_reset_disk(bd->bd_unit);
1233 bd->bd_flags |= BD_NO_MEDIA;
1238 if (result != 0 && (bd->bd_flags & BD_NO_MEDIA) == 0) {
1294 bdinfo_t *bd;
1306 bd = bd_get_bdinfo(&dev->dd);
1307 if (bd == NULL)
1316 if (disk_open(dev, bd->bd_sectors * bd->bd_sectorsize,
1317 bd->bd_sectorsize) != 0) /* oops, not a viable device */
1327 if (bd->bd_type == DT_ATAPI) {