Lines Matching +full:slice +full:- +full:per +full:- +full:line

35  * - NetBSD libi386/biosdisk.c
36 * - FreeBSD biosboot/disk.c
197 if (dev->dv_type == DEVT_DISK) in bd_get_bdinfo_list()
199 if (dev->dv_type == DEVT_CD) in bd_get_bdinfo_list()
201 if (dev->dv_type == DEVT_FD) in bd_get_bdinfo_list()
214 bdi = bd_get_bdinfo_list(dev->d_dev); in bd_get_bdinfo()
220 if (unit == dev->d_unit) in bd_get_bdinfo()
241 if (bd->bd_unit == biosdev) { in bd_bios2unit()
243 bd->bd_unit); in bd_bios2unit()
249 return (-1); in bd_bios2unit()
259 bdi = bd_get_bdinfo_list(dev->dd.d_dev); in bd_unit2bios()
261 return (-1); in bd_unit2bios()
265 if (unit == dev->dd.d_unit) in bd_unit2bios()
266 return (bd->bd_unit); in bd_unit2bios()
269 return (-1); in bd_unit2bios()
273 * Use INT13 AH=15 - Read Drive Type.
313 bd->bd_sectorsize = BIOSDISK_SECSIZE; in fd_init()
314 bd->bd_flags = BD_FLOPPY; in fd_init()
315 bd->bd_unit = unit; in fd_init()
322 if (bd->bd_sectors == 0) in fd_init()
323 bd->bd_flags |= BD_NO_MEDIA; in fd_init()
346 bd->bd_unit = base + unit; in bd_init()
372 * Information from bootable CD-ROM.
378 int ret = -1; in bd_get_diskinfo_cd()
381 /* Set sp_size as per specification. */ in bd_get_diskinfo_cd()
382 bc_sp.sp_size = sizeof (bc_sp) - sizeof (bc_sp.sp_dummy); in bd_get_diskinfo_cd()
387 v86.edx = bd->bd_unit; in bd_get_diskinfo_cd()
393 bc_sp.sp_drive == bd->bd_unit) { in bd_get_diskinfo_cd()
394 bd->bd_cyl = ((bc_sp.sp_cylsec & 0xc0) << 2) + in bd_get_diskinfo_cd()
396 bd->bd_sec = bc_sp.sp_cylsec & 0x3f; in bd_get_diskinfo_cd()
397 bd->bd_hds = bc_sp.sp_head + 1; in bd_get_diskinfo_cd()
398 bd->bd_sectors = (uint64_t)bd->bd_cyl * bd->bd_hds * bd->bd_sec; in bd_get_diskinfo_cd()
401 /* Floppy or hard-disk emulation */ in bd_get_diskinfo_cd()
402 bd->bd_sectorsize = BIOSDISK_SECSIZE; in bd_get_diskinfo_cd()
403 return (-1); in bd_get_diskinfo_cd()
405 bd->bd_sectorsize = 2048; in bd_get_diskinfo_cd()
406 bd->bd_flags = BD_MODEEDD | BD_CDROM; in bd_get_diskinfo_cd()
412 * If this is the boot_drive, default to non-emulation bootable CD-ROM. in bd_get_diskinfo_cd()
414 if (ret != 0 && bd->bd_unit >= 0x88) { in bd_get_diskinfo_cd()
415 bd->bd_cyl = 0; in bd_get_diskinfo_cd()
416 bd->bd_hds = 1; in bd_get_diskinfo_cd()
417 bd->bd_sec = 15; in bd_get_diskinfo_cd()
418 bd->bd_sectorsize = 2048; in bd_get_diskinfo_cd()
419 bd->bd_flags = BD_MODEEDD | BD_CDROM; in bd_get_diskinfo_cd()
420 bd->bd_sectors = 0; in bd_get_diskinfo_cd()
426 * here - some systems do get hung with those. in bd_get_diskinfo_cd()
433 if (bd->bd_sectors == 0) in bd_get_diskinfo_cd()
434 bd->bd_sectors = 4173824; in bd_get_diskinfo_cd()
446 return (-1); in bc_add()
449 return (-1); in bc_add()
451 bd->bd_unit = biosdev; in bc_add()
454 return (-1); in bc_add()
486 /* extended disk access functions (AH=42h-44h,47h,48h) supported */ in bd_check_extensions()
514 v86.edx = bd->bd_unit; in bd_get_diskinfo_std()
524 bd->bd_cyl = ((v86.ecx & 0xc0) << 2) + ((v86.ecx & 0xff00) >> 8) + 1; in bd_get_diskinfo_std()
525 /* Convert max head # -> # of heads */ in bd_get_diskinfo_std()
526 bd->bd_hds = ((v86.edx & 0xff00) >> 8) + 1; in bd_get_diskinfo_std()
527 bd->bd_sec = v86.ecx & 0x3f; in bd_get_diskinfo_std()
528 bd->bd_type = v86.ebx; in bd_get_diskinfo_std()
529 bd->bd_sectors = (uint64_t)bd->bd_cyl * bd->bd_hds * bd->bd_sec; in bd_get_diskinfo_std()
554 params->len = sizeof (struct edd_params_v3); in bd_get_diskinfo_ext()
558 v86.edx = bd->bd_unit; in bd_get_diskinfo_ext()
572 if (params->sector_size >= 512 && in bd_get_diskinfo_ext()
573 params->sector_size <= 16384 && in bd_get_diskinfo_ext()
574 (params->sector_size % BIOSDISK_SECSIZE) == 0) in bd_get_diskinfo_ext()
575 bd->bd_sectorsize = params->sector_size; in bd_get_diskinfo_ext()
577 bd->bd_cyl = params->cylinders; in bd_get_diskinfo_ext()
578 bd->bd_hds = params->heads; in bd_get_diskinfo_ext()
579 bd->bd_sec = params->sectors_per_track; in bd_get_diskinfo_ext()
581 if (params->sectors != 0) { in bd_get_diskinfo_ext()
582 total = params->sectors; in bd_get_diskinfo_ext()
584 total = (uint64_t)params->cylinders * in bd_get_diskinfo_ext()
585 params->heads * params->sectors_per_track; in bd_get_diskinfo_ext()
587 bd->bd_sectors = total; in bd_get_diskinfo_ext()
600 bd->bd_flags &= ~BD_NO_MEDIA; in bd_int13probe()
602 if ((bd->bd_flags & BD_CDROM) != 0) { in bd_int13probe()
606 edd = bd_check_extensions(bd->bd_unit); in bd_int13probe()
608 bd->bd_flags |= BD_MODEINT13; in bd_int13probe()
610 bd->bd_flags |= BD_MODEEDD1; in bd_int13probe()
612 bd->bd_flags |= BD_MODEEDD3; in bd_int13probe()
615 if (bd->bd_sectorsize == 0) in bd_int13probe()
616 bd->bd_sectorsize = BIOSDISK_SECSIZE; in bd_int13probe()
622 if (bd->bd_unit < 0x80) { in bd_int13probe()
624 bd_reset_disk(bd->bd_unit); in bd_int13probe()
630 v86.edx = bd->bd_unit; in bd_int13probe()
639 if (ret != 0 || bd->bd_sectors == 0) in bd_int13probe()
642 if (ret != 0 && bd->bd_unit < 0x80) { in bd_int13probe()
644 bd->bd_cyl = 80; in bd_int13probe()
645 bd->bd_hds = 2; in bd_int13probe()
646 bd->bd_sec = 18; in bd_int13probe()
647 bd->bd_sectors = 2880; in bd_int13probe()
649 bd->bd_flags |= BD_NO_MEDIA; in bd_int13probe()
654 if (bd->bd_sectors != 0 && edd != 0) { in bd_int13probe()
655 bd->bd_sec = 63; in bd_int13probe()
656 bd->bd_hds = 255; in bd_int13probe()
657 bd->bd_cyl = in bd_int13probe()
658 (bd->bd_sectors + bd->bd_sec * bd->bd_hds - 1) / in bd_int13probe()
659 bd->bd_sec * bd->bd_hds; in bd_int13probe()
663 if ((bd->bd_flags & BD_FLOPPY) != 0) in bd_int13probe()
669 dv_name, bd->bd_unit); in bd_int13probe()
674 if (bd->bd_sec == 0) in bd_int13probe()
675 bd->bd_sec = 63; in bd_int13probe()
676 if (bd->bd_hds == 0) in bd_int13probe()
677 bd->bd_hds = 255; in bd_int13probe()
679 if (bd->bd_sectors == 0) in bd_int13probe()
680 bd->bd_sectors = (uint64_t)bd->bd_cyl * bd->bd_hds * bd->bd_sec; in bd_int13probe()
682 DPRINTF("unit 0x%x geometry %d/%d/%d\n", bd->bd_unit, bd->bd_cyl, in bd_int13probe()
683 bd->bd_hds, bd->bd_sec); in bd_int13probe()
706 char line[80]; in bd_print_common() local
715 printf("%s devices:", dev->dv_name); in bd_print_common()
719 i = -1; in bd_print_common()
723 switch (dev->dv_type) { in bd_print_common()
735 snprintf(line, sizeof (line), in bd_print_common()
737 dev->dv_name, i, drive + i, in bd_print_common()
738 (bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA ? in bd_print_common()
740 (uintmax_t)bd->bd_sectors, in bd_print_common()
741 bd->bd_sectorsize); in bd_print_common()
742 if ((ret = pager_output(line)) != 0) in bd_print_common()
745 if ((bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) in bd_print_common()
748 if (dev->dv_type != DEVT_DISK) in bd_print_common()
756 bd->bd_sectorsize * bd->bd_sectors, in bd_print_common()
757 bd->bd_sectorsize) == 0) { in bd_print_common()
758 snprintf(line, sizeof (line), " %s%d", in bd_print_common()
759 dev->dv_name, i); in bd_print_common()
760 ret = disk_print(&devd, line, verbose); in bd_print_common()
801 bd = bd_get_bdinfo(&dev->dd); in bd_disk_get_sectors()
805 disk.dd.d_dev = dev->dd.d_dev; in bd_disk_get_sectors()
806 disk.dd.d_unit = dev->dd.d_unit; in bd_disk_get_sectors()
811 size = bd->bd_sectors * bd->bd_sectorsize; in bd_disk_get_sectors()
812 if (disk_open(&disk, size, bd->bd_sectorsize) == 0) { in bd_disk_get_sectors()
816 return (size / bd->bd_sectorsize); in bd_disk_get_sectors()
825 * (eg. given no slice or partition value, with a disk that is
826 * sliced - are they after the first BSD slice, or the DOS
827 * slice before it?)
841 bd = bd_get_bdinfo(&dev->dd); in bd_open()
845 if ((bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) { in bd_open()
848 if ((bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) in bd_open()
851 if (bd->bd_bcache == NULL) in bd_open()
852 bd->bd_bcache = bcache_allocate(); in bd_open()
854 if (bd->bd_open == 0) in bd_open()
855 bd->bd_sectors = bd_disk_get_sectors(dev); in bd_open()
856 bd->bd_open++; in bd_open()
859 if (dev->dd.d_dev->dv_type == DEVT_DISK) { in bd_open()
860 rc = disk_open(dev, bd->bd_sectors * bd->bd_sectorsize, in bd_open()
861 bd->bd_sectorsize); in bd_open()
863 bd->bd_open--; in bd_open()
864 if (bd->bd_open == 0) { in bd_open()
865 bcache_free(bd->bd_bcache); in bd_open()
866 bd->bd_bcache = NULL; in bd_open()
880 dev = (struct disk_devdesc *)f->f_devdata; in bd_close()
881 bd = bd_get_bdinfo(&dev->dd); in bd_close()
885 bd->bd_open--; in bd_close()
886 if (bd->bd_open == 0) { in bd_close()
887 bcache_free(bd->bd_bcache); in bd_close()
888 bd->bd_bcache = NULL; in bd_close()
890 if (dev->dd.d_dev->dv_type == DEVT_DISK) in bd_close()
902 dev = (struct disk_devdesc *)f->f_devdata; in bd_ioctl()
903 bd = bd_get_bdinfo(&dev->dd); in bd_ioctl()
907 if (dev->dd.d_dev->dv_type == DEVT_DISK) { in bd_ioctl()
915 *(uint32_t *)data = bd->bd_sectorsize; in bd_ioctl()
918 *(uint64_t *)data = bd->bd_sectors * bd->bd_sectorsize; in bd_ioctl()
936 bd = bd_get_bdinfo(&dev->dd); in bd_strategy()
942 bcd.dv_cache = bd->bd_bcache; in bd_strategy()
945 if (dev->dd.d_dev->dv_type == DEVT_DISK) { in bd_strategy()
947 offset = dev->d_offset * bd->bd_sectorsize; in bd_strategy()
965 bd = bd_get_bdinfo(&dev->dd); in bd_realstrategy()
966 if (bd == NULL || (bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) in bd_realstrategy()
984 dblk = offset / bd->bd_sectorsize; in bd_realstrategy()
985 blkoff = offset % bd->bd_sectorsize; in bd_realstrategy()
998 blks = size / bd->bd_sectorsize; in bd_realstrategy()
999 if (blks == 0 || (size % bd->bd_sectorsize) != 0) in bd_realstrategy()
1014 if (dev->dd.d_dev->dv_type == DEVT_DISK) { in bd_realstrategy()
1017 disk_blocks /= bd->bd_sectorsize; in bd_realstrategy()
1019 d_offset = dev->d_offset; in bd_realstrategy()
1022 disk_blocks = bd->bd_sectors - d_offset; in bd_realstrategy()
1032 blks = d_offset + disk_blocks - dblk; in bd_realstrategy()
1033 size = blks * bd->bd_sectorsize; in bd_realstrategy()
1038 while (bio_size > bd->bd_sectorsize) { in bd_realstrategy()
1042 bio_size -= bd->bd_sectorsize; in bd_realstrategy()
1046 if (bio_size < bd->bd_sectorsize) in bd_realstrategy()
1055 int x = min(blks, bio_size / bd->bd_sectorsize); in bd_realstrategy()
1060 bsize = bd->bd_sectorsize * x - blkoff; in bd_realstrategy()
1079 bsize = bd->bd_sectorsize - blkoff; in bd_realstrategy()
1082 } else if (rest < bd->bd_sectorsize) { in bd_realstrategy()
1092 bsize = bd->bd_sectorsize * x; in bd_realstrategy()
1112 rest -= bsize; in bd_realstrategy()
1113 blks -= x; in bd_realstrategy()
1142 v86.edx = bd->bd_unit; in bd_edd_io()
1157 bpc = bd->bd_sec * bd->bd_hds; /* blocks per cylinder */ in bd_chs_io()
1159 cyl = x / bpc; /* block # / blocks per cylinder */ in bd_chs_io()
1161 hd = x / bd->bd_sec; /* offset / blocks per track */ in bd_chs_io()
1162 sec = x % bd->bd_sec; /* offset into track */ in bd_chs_io()
1164 /* correct sector number for 1-based BIOS numbering */ in bd_chs_io()
1179 v86.edx = (hd << 8) | bd->bd_unit; in bd_chs_io()
1202 /* Just in case some idiot actually tries to read/write -1 blocks... */ in bd_io()
1204 return (-1); in bd_io()
1220 if (bd->bd_flags & BD_MODEEDD) in bd_io()
1226 if (bd->bd_flags & BD_NO_MEDIA) in bd_io()
1227 bd->bd_flags &= ~BD_NO_MEDIA; in bd_io()
1231 bd_reset_disk(bd->bd_unit); in bd_io()
1241 bd->bd_flags |= BD_NO_MEDIA; in bd_io()
1246 if (result != 0 && (bd->bd_flags & BD_NO_MEDIA) == 0) { in bd_io()
1249 "to %lld: 0x%x\n", dev->dd.d_dev->dv_name, in bd_io()
1250 dev->dd.d_unit, blks, dest, VTOP(dest), dblk, in bd_io()
1254 "(0x%x): 0x%x\n", dev->dd.d_dev->dv_name, in bd_io()
1255 dev->dd.d_unit, blks, dblk, dest, VTOP(dest), in bd_io()
1273 * indicated by returning the geometry of a "1.2M" PC-format floppy
1307 int i, unit, slice, partition; in bd_getdev() local
1310 slice = 0; in bd_getdev()
1314 bd = bd_get_bdinfo(&dev->dd); in bd_getdev()
1316 return (-1); in bd_getdev()
1319 DPRINTF("unit %d BIOS device %d", dev->dd.d_unit, biosdev); in bd_getdev()
1320 if (biosdev == -1) /* not a BIOS device */ in bd_getdev()
1321 return (-1); in bd_getdev()
1323 if (dev->dd.d_dev->dv_type == DEVT_DISK) { in bd_getdev()
1324 if (disk_open(dev, bd->bd_sectors * bd->bd_sectorsize, in bd_getdev()
1325 bd->bd_sectorsize) != 0) /* oops, not a viable device */ in bd_getdev()
1326 return (-1); in bd_getdev()
1329 slice = dev->d_slice + 1; in bd_getdev()
1330 partition = dev->d_partition; in bd_getdev()
1335 if (bd->bd_type == DT_ATAPI) { in bd_getdev()
1349 if (dev->dd.d_dev->dv_type == DEVT_CD) { in bd_getdev()
1357 * we pass -C to the boot args if we are the boot device. in bd_getdev()
1371 rootdev = MAKEBOOTDEV(major, slice, unit, partition); in bd_getdev()