mirror of https://github.com/deadw00d/AROS.git
Provide 32-bit variable to store number of cylinders
This allow for using identical algorithm as ata.device. Number of cylinders needs to be 32-bit as often division by 2 and 3 yields no results and heads stay at 1 while cylinders is a number larger than 2^16.
This commit is contained in:
parent
80046e3470
commit
f5ee826e7f
|
@ -274,7 +274,7 @@ static BOOL ahci_RegisterVolume(struct ahci_port *ap, struct ata_port *at, struc
|
|||
pp[DE_BLKSPERTRACK + 4] = at->at_identify.nsectors;
|
||||
pp[DE_RESERVEDBLKS + 4] = 2;
|
||||
pp[DE_LOWCYL + 4] = 0;
|
||||
pp[DE_HIGHCYL + 4] = (ap->ap_type == ATA_PORT_T_DISK) ? (at->at_identify.ncyls - 1) : 0;
|
||||
pp[DE_HIGHCYL + 4] = (ap->ap_type == ATA_PORT_T_DISK) ? (at->at_ncyls - 1) : 0;
|
||||
pp[DE_NUMBUFFERS + 4] = 10;
|
||||
pp[DE_BUFMEMTYPE + 4] = MEMF_PUBLIC;
|
||||
pp[DE_MAXTRANSFER + 4] = 0x00200000;
|
||||
|
@ -421,8 +421,10 @@ ata_fix_identify(struct ata_identify *id)
|
|||
}
|
||||
|
||||
static void
|
||||
ata_fix_chs(struct ata_identify *id, u_int64_t capacity48)
|
||||
ata_fix_chs(struct ata_identify *id, u_int32_t *ncyls, u_int64_t capacity48)
|
||||
{
|
||||
*ncyls = id->ncyls;
|
||||
|
||||
if (le16toh(id->cmdset83) & 0x0400) {
|
||||
/* LBA48 feature set supported */
|
||||
/* Code copied from ata.device */
|
||||
|
@ -438,9 +440,6 @@ ata_fix_chs(struct ata_identify *id, u_int64_t capacity48)
|
|||
id->nsectors = 63;
|
||||
sec /= 63;
|
||||
|
||||
/* Make the number even, otherwise if there is no division by 2 and by 3, resulting number will be
|
||||
too large to fit into u_int16_t and will be cut down */
|
||||
sec = (sec >> 1) << 1;
|
||||
/*
|
||||
* keep dividing by 2
|
||||
*/
|
||||
|
@ -464,7 +463,7 @@ ata_fix_chs(struct ata_identify *id, u_int64_t capacity48)
|
|||
sec /= 3;
|
||||
} while (1);
|
||||
|
||||
id->ncyls = sec;
|
||||
*ncyls = sec;
|
||||
id->nheads = div;
|
||||
}
|
||||
}
|
||||
|
@ -813,7 +812,7 @@ ahci_cam_probe(struct ahci_port *ap, struct ata_port *atx)
|
|||
|
||||
capacity_bytes = capacity * 512;
|
||||
|
||||
ata_fix_chs(&at->at_identify, capacity);
|
||||
ata_fix_chs(&at->at_identify, &at->at_ncyls, at->at_capacity);
|
||||
|
||||
/*
|
||||
* Negotiate NCQ, throw away any ata_xfer's beyond the negotiated
|
||||
|
|
|
@ -330,7 +330,7 @@ AROS_LH1(void, BeginIO,
|
|||
SetMem(geom, 0, len);
|
||||
if (ap->ap_type == ATA_PORT_T_DISK) {
|
||||
geom->dg_SectorSize = at->at_identify.sector_size;
|
||||
geom->dg_Cylinders = at->at_identify.ncyls;
|
||||
geom->dg_Cylinders = at->at_ncyls;
|
||||
geom->dg_CylSectors = at->at_identify.nsectors * at->at_identify.nheads;
|
||||
if (((UQUAD)geom->dg_Cylinders * geom->dg_CylSectors) >> 32 != 0)
|
||||
geom->dg_TotalSectors = 0xffffffff;
|
||||
|
|
|
@ -325,6 +325,7 @@ struct ata_port {
|
|||
u_int64_t at_capacity; /* only if ATA_PORT_T_DISK */
|
||||
int at_target; /* port multiplier port */
|
||||
char at_name[16];
|
||||
u_int32_t at_ncyls; /* only if ATA_PORT_T_DISK */
|
||||
};
|
||||
|
||||
struct ata_xfer {
|
||||
|
|
Loading…
Reference in New Issue