--- Gnu-Mach/linux/dev/drivers/block/ide.c 2020/09/02 04:41:39 1.1 +++ Gnu-Mach/linux/dev/drivers/block/ide.c 2020/09/02 04:43:27 1.1.1.2 @@ -613,7 +613,6 @@ static int lba_capacity_is_ok (struct hd /* very large drives (8GB+) may lie about the number of cylinders */ if (id->cyls == 16383 && id->heads == 16 && id->sectors == 63 && lba_sects > chs_sects) { - id->cyls = lba_sects / (16 * 63); /* correct cyls */ return 1; /* lba_capacity is our only option */ } /* perform a rough sanity check on lba_sects: within 10% is "okay" */ @@ -650,7 +649,6 @@ static unsigned long current_capacity (i /* Determine capacity, and use LBA if the drive properly supports it */ if (id != NULL && (id->capability & 2) && lba_capacity_is_ok(id)) { if (id->lba_capacity >= capacity) { - drive->cyl = id->lba_capacity / (drive->head * drive->sect); capacity = id->lba_capacity; drive->select.b.lba = 1; } @@ -1578,7 +1576,7 @@ static inline void do_request (ide_hwif_ blockend = block + rq->nr_sectors; if ((blockend < block) || (blockend > drive->part[minor&PARTN_MASK].nr_sects)) { #ifdef MACH - printk ("%s%c: bad access: block=%ld, count=%ld, blockend=%ld, nr_sects\n", + printk ("%s%c: bad access: block=%ld, count=%ld, blockend=%ld, nr_sects%ld\n", drive->name, (minor&PARTN_MASK)?'0'+(minor&PARTN_MASK):' ', block, rq->nr_sectors, blockend, drive->part[minor&PARTN_MASK].nr_sects); #else @@ -1606,7 +1604,7 @@ static inline void do_request (ide_hwif_ printk("%s: drive not ready for command\n", drive->name); return; } - + if (!drive->special.all) { if (rq->cmd == IDE_DRIVE_CMD) { execute_drive_cmd(drive, rq); @@ -1646,7 +1644,7 @@ static inline void do_request (ide_hwif_ #else do_rw_disk (drive, rq, block); /* simpler and faster */ return; -#endif /* CONFIG_BLK_DEV_IDEATAPI */; +#endif /* CONFIG_BLK_DEV_IDEATAPI */ } do_special(drive); return; @@ -1696,7 +1694,7 @@ void ide_do_request (ide_hwgroup_t *hwgr hwgroup->active = 0; return; /* no work left for this hwgroup */ } - got_rq: + got_rq: do_request(hwgroup->hwif = hwgroup->next_hwif = hwif, hwgroup->rq = rq); cli(); } while (hwgroup->handler == NULL); @@ -2429,7 +2427,7 @@ static inline void do_identify (ide_driv #if defined (CONFIG_SCSI_EATA_DMA) || defined (CONFIG_SCSI_EATA_PIO) || defined (CONFIG_SCSI_EATA) /* - * EATA SCSI controllers do a hardware ATA emulation: + * EATA SCSI controllers do a hardware ATA emulation: * Ignore them if there is a driver for them available. */ if ((id->model[0] == 'P' && id->model[1] == 'M') @@ -2598,13 +2596,23 @@ static inline void do_identify (ide_driv } /* calculate drive capacity, and select LBA if possible */ - (void) current_capacity (drive); + capacity = current_capacity (drive); /* Correct the number of cyls if the bios value is too small */ - if (drive->sect == drive->bios_sect && drive->head == drive->bios_head) { - if (drive->cyl > drive->bios_cyl) - drive->bios_cyl = drive->cyl; - } + if (!drive->forced_geom && + capacity > drive->bios_cyl * drive->bios_sect * drive->bios_head) { + unsigned long cylsize; + cylsize = drive->bios_sect * drive->bios_head; + if (cylsize == 0 || capacity/cylsize > 65535) { + drive->bios_sect = 63; + drive->bios_head = 255; + cylsize = 63*255; + } + if (capacity/cylsize > 65535) + drive->bios_cyl = 65535; + else + drive->bios_cyl = capacity/cylsize; + } if (!strncmp(id->model, "BMI ", 4) && strstr(id->model, " ENHANCED IDE ") && @@ -3321,7 +3329,7 @@ done: * This routine is called from the partition-table code in genhd.c * to "convert" a drive to a logical geometry with fewer than 1024 cyls. * - * The second parameter, "xparm", determines exactly how the translation + * The second parameter, "xparm", determines exactly how the translation * will be handled: * 0 = convert to CHS with fewer than 1024 cyls * using the same method as Ontrack DiskManager. @@ -3329,7 +3337,7 @@ done: * -1 = similar to "0", plus redirect sector 0 to sector 1. * >1 = convert to a CHS geometry with "xparm" heads. * - * Returns 0 if the translation was not possible, if the device was not + * Returns 0 if the translation was not possible, if the device was not * an IDE disk drive, or if a geometry was "forced" on the commandline. * Returns 1 if the geometry translation was successful. */ @@ -3640,7 +3648,7 @@ static int hwif_init (int h) { ide_hwif_t *hwif = &ide_hwifs[h]; void (*rfn)(void); - + if (!hwif->present) return 0; if (!hwif->irq) { @@ -3655,7 +3663,7 @@ static int hwif_init (int h) return (hwif->present = 0); } #endif /* CONFIG_BLK_DEV_HD */ - + hwif->present = 0; /* we set it back to 1 if all is ok below */ switch (hwif->major) { case IDE0_MAJOR: rfn = &do_ide0_request; break; @@ -3710,7 +3718,7 @@ int ide_init (void) #ifdef CONFIG_BLK_DEV_IDETAPE idetape_register_chrdev(); /* Register character device interface to the ide tape */ #endif /* CONFIG_BLK_DEV_IDETAPE */ - + return 0; }