@@ -211,7 +211,7 @@ static void ata_IRQPIOReadAtapi(struct ata_Unit *unit, UBYTE status)
211211
212212AGAIN :
213213 retry_busy = 5000000 ;
214- retry_datareq = 500 ;
214+ retry_datareq = 5000 ;
215215
216216WAITBUSY :
217217 status = PIO_In (unit -> au_Bus , ata_Status );
@@ -244,7 +244,7 @@ static void ata_IRQPIOReadAtapi(struct ata_Unit *unit, UBYTE status)
244244 {
245245 ata_IRQSetHandler (unit , & ata_IRQNoData , NULL , 0 , 0 );
246246 unit -> au_cmd_error = HFERR_BadStatus ;
247- DERROR (bug ("[ATAPI] ata_IRQPIOReadAtapi: ERROR = RetryCount (500 ) reached ZERO on ATAF_DATAREQ SET\n" ));
247+ DERROR (bug ("[ATAPI] ata_IRQPIOReadAtapi: ERROR = RetryCount (5000 ) reached ZERO on ATAF_DATAREQ SET\n" ));
248248 return ;
249249 }
250250
@@ -281,13 +281,13 @@ static void ata_IRQPIOReadAtapi(struct ata_Unit *unit, UBYTE status)
281281 DERROR (status = PIO_In (unit -> au_Bus , ata_Status ));
282282 DERROR (if (status & ATAF_ERROR ) bug ("\n[ATAPI] *** ERROR: ata_IRQPIOReadAtapi - ATAF_ERROR" ));
283283
284- retry_busy = 0 ;
284+ retry_busy = 5000000 ;
285285 do
286286 {
287287 status = PIO_In (bus , atapi_Status );
288288 ata_WaitNano (400 , bus -> ab_Base );
289- retry_busy ++ ;
290- if (retry_busy == 5000000 )
289+ retry_busy -- ;
290+ if (retry_busy == 0 )
291291 {
292292 DERROR (bug ("[ATAPI] *** ERROR: ata_IRQPIOReadAtapi - ATAF_BUSY not cleared!\n" ));
293293 break ;
@@ -303,7 +303,7 @@ static void ata_IRQPIOWriteAtapi(struct ata_Unit *unit, UBYTE status)
303303
304304AGAINW :
305305 retry_busy = 5000000 ;
306- retry_datareq = 500 ;
306+ retry_datareq = 5000 ;
307307
308308WAITBUSYW :
309309 status = PIO_In (unit -> au_Bus , ata_Status );
@@ -335,7 +335,7 @@ static void ata_IRQPIOWriteAtapi(struct ata_Unit *unit, UBYTE status)
335335 {
336336 ata_IRQSetHandler (unit , & ata_IRQNoData , NULL , 0 , 0 );
337337 unit -> au_cmd_error = HFERR_BadStatus ;
338- DERROR (bug ("\n[ATAPI] *** ERROR: ata_IRQPIOWriteAtapi: ERROR = RetryCount (500 ) reached ZERO on ATAF_DATAREQ SET\n" ));
338+ DERROR (bug ("\n[ATAPI] *** ERROR: ata_IRQPIOWriteAtapi: ERROR = RetryCount (5000 ) reached ZERO on ATAF_DATAREQ SET\n" ));
339339 return ;
340340 }
341341
@@ -372,13 +372,13 @@ static void ata_IRQPIOWriteAtapi(struct ata_Unit *unit, UBYTE status)
372372 DERROR (status = PIO_In (unit -> au_Bus , ata_Status ));
373373 DERROR (if (status & ATAF_ERROR ) bug ("\n[ATAPI] *** ERROR: ata_IRQPIOWriteAtapi - ATAF_ERROR" ));
374374
375- retry_busy = 0 ;
375+ retry_busy = 5000000 ;
376376 do
377377 {
378378 status = PIO_In (bus , atapi_Status );
379379 ata_WaitNano (400 , bus -> ab_Base );
380- retry_busy ++ ;
381- if (retry_busy == 5000000 )
380+ retry_busy -- ;
381+ if (retry_busy == 0 )
382382 {
383383 DERROR (bug ("[ATAPI] *** ERROR: ata_IRQPIOWriteAtapi - ATAF_BUSY not cleared!\n" ));
384384 break ;
@@ -579,7 +579,7 @@ static BYTE atapi_SendPacket(struct ata_Unit *unit, APTR packet, APTR data, LONG
579579 UBYTE status ;
580580
581581 ULONG retry_busy = 200000 ;
582- ULONG retry_datareq = 500 ;
582+ ULONG retry_datareq = 5000 ;
583583
584584 UBYTE cmd [12 ] = {0 };
585585 register int t = 5 ,l = 0 ;
@@ -625,7 +625,7 @@ static BYTE atapi_SendPacket(struct ata_Unit *unit, APTR packet, APTR data, LONG
625625 {
626626 DDD (bug ("\n" ));
627627 DERROR (bug ("[ATAPI] atapi_SendPacket - ERROR: ATAF_BUSY | ATAF_DATAREQ not cleared, status = %u\n" , status ));
628- break ;
628+ return HFERR_BadStatus ;
629629 }
630630 } while ((status & (ATAF_BUSY | ATAF_DATAREQ )) != 0 ); // Wait for BSY and DRQ to CLEAR
631631 DDD (bug ("\n" ));
@@ -650,7 +650,7 @@ static BYTE atapi_SendPacket(struct ata_Unit *unit, APTR packet, APTR data, LONG
650650 {
651651 DDD (bug ("\n" ));
652652 DERROR (bug ("[ATAPI] atapi_SendPacket - ERROR: ATAF_DATAREQ not set!" ));
653- break ;
653+ return HFERR_BadStatus ;
654654 }
655655 } while ((status & ATAF_DATAREQ ) != ATAF_DATAREQ ); // Wait for DRQ to SET
656656 DDD (bug ("\n" ));
@@ -1183,25 +1183,38 @@ static BYTE ata_Identify(struct ata_Unit *unit)
11831183 unit -> au_Heads = 1 ;
11841184 unit -> au_Sectors = 75 ;
11851185 unit -> au_Cylinders = 4440 ;
1186+ unit -> au_StartCyl = 0 ; // Handled by CD Filesystem
1187+ unit -> au_EndCyl = 0 ; // Handled by CD Filesystem
1188+ unit -> au_Capacity = unit -> au_Heads * unit -> au_Sectors * unit -> au_Cylinders ;
1189+ unit -> au_Capacity48 = unit -> au_Capacity ;
11861190 break ;
11871191
11881192 case DG_DIRECT_ACCESS :
1189- unit -> au_SectorShift = 9 ;
1190- /*if (!strcmp("LS-120", &unit->au_Model[0])) // CHANGE: HARDCODED SUCKS
1193+ //DINIT(bug("[ATA:%02ld] ata_Identify: MODEL[0]=%s | MODEL[8]=%s | STRCMP = %u\n", unit->au_UnitNum, &unit->au_Model[0], &unit->au_Model[8], strcmp("ZIP 100", &unit->au_Model[8]) ));
1194+
1195+ /*if (strcmp("LS-120", &unit->au_Model[0]) == 0) // CHANGE: HARDCODED SUCKS
11911196 {
11921197 unit->au_Heads = 2;
11931198 unit->au_Sectors = 18;
11941199 unit->au_Cylinders = 6848;
11951200 }
1196- else if (!strcmp("ZIP 100 ", &unit->au_Model[8])) // CHANGE: HARDCODED SUCKS
1197- {
1198- unit->au_Heads = 1;
1199- unit->au_Sectors = 64;
1200- unit->au_Cylinders = 3072;
1201- }*/
1201+ else if (strcmp("ZIP 100", &unit->au_Model[8]) == 0) // CHANGE: HARDCODED SUCKS
1202+ {*/
1203+ unit -> au_SectorShift = 9 ;
1204+ unit -> au_Heads = 16 ;
1205+ unit -> au_Sectors = 63 ;
1206+ unit -> au_Cylinders = 195 ;
1207+ unit -> au_StartCyl = 4 ; // First partition starts on Cylinder 4
1208+ unit -> au_EndCyl = unit -> au_Cylinders - 1 ; // Partition covers full disk
1209+ unit -> au_Capacity = unit -> au_Heads * unit -> au_Sectors * unit -> au_Cylinders ;
1210+ unit -> au_Capacity48 = unit -> au_Capacity ;
1211+
1212+ //}
12021213 break ;
12031214 }
12041215
1216+ DINIT (bug ("[ATA:%02ld] ata_Identify: HARDCODE = Cap28=%u | Cap48=%llu | CHS=%u/%u/%u\n" , unit -> au_UnitNum , unit -> au_Capacity , unit -> au_Capacity48 , unit -> au_Cylinders , unit -> au_Heads , unit -> au_Sectors );)
1217+
12051218 ULONG retry_test = 10 ;
12061219 while (!(atapi_TestUnitOK (unit )) || (retry_test > 5 ))
12071220 {
@@ -1213,19 +1226,9 @@ static BYTE ata_Identify(struct ata_Unit *unit)
12131226 }
12141227
12151228 } else {
1216- /*
1217- For drive capacities > 8.3GB assume maximal possible layout.
1218- It really doesn't matter here, as BIOS will not handle them in
1219- CHS way anyway :)
1220- i guess this just solves that weirdo div-by-zero crash, if nothing
1221- else...
1222- */
12231229 if (supportLBA && ((unit -> au_Drive -> id_LBA48Sectors > (63 * 255 * 1024 )) || (unit -> au_Drive -> id_LBASectors > (63 * 255 * 1024 ))))
12241230 {
12251231 ULONG div = 1 ;
1226- /*
1227- * TODO: this shouldn't be casted down here.
1228- */
12291232 ULONG sec = unit -> au_Capacity48 ;
12301233
12311234 if (sec < unit -> au_Capacity48 )
@@ -1236,9 +1239,6 @@ static BYTE ata_Identify(struct ata_Unit *unit)
12361239
12371240 unit -> au_Sectors = 63 ;
12381241 sec /= 63 ;
1239- /*
1240- * keep dividing by 2
1241- */
12421242 do
12431243 {
12441244 if (((sec >> 1 ) << 1 ) != sec )
@@ -1267,6 +1267,10 @@ static BYTE ata_Identify(struct ata_Unit *unit)
12671267 unit -> au_Cylinders = unit -> au_Drive -> id_OldLCylinders ;
12681268 unit -> au_Heads = unit -> au_Drive -> id_OldLHeads ;
12691269 unit -> au_Sectors = unit -> au_Drive -> id_OldLSectors ;
1270+
1271+ unit -> au_StartCyl = 0 ; // RDB starts on Cylinder 0
1272+ unit -> au_EndCyl = unit -> au_Cylinders - 1 ; // Full disk
1273+
12701274 if (!supportLBA ) {
12711275 unit -> au_Capacity = unit -> au_Cylinders * unit -> au_Heads * unit -> au_Sectors ;
12721276 unit -> au_Capacity48 = unit -> au_Capacity ;
@@ -1580,6 +1584,9 @@ BOOL atapi_TestUnitOK(struct ata_Unit *unit)
15801584
15811585 result = unit -> au_DirectSCSI (unit , & sc );
15821586
1587+ DINIT (bug ("[ATA:%02ld] atapi_TestUnitOK: DETECTED = LBA = %u | Block = %u\n" ,
1588+ unit -> au_UnitNum , capacity .logicalsectors , capacity .blocksize ));
1589+
15831590 if ( (unit -> au_cmd_error ) == HFERR_BadStatus )
15841591 {
15851592 DINIT (bug ("[ATA:%02ld] unit->au_cmd_error == HFERR_BadStatus\n" , unit -> au_UnitNum ));
@@ -1590,20 +1597,13 @@ BOOL atapi_TestUnitOK(struct ata_Unit *unit)
15901597 unit -> au_Flags |= AF_DiscChanged ; // Set AF_DiscChanged
15911598 }
15921599
1593- /*unit->au_Capacity = 196575;
1594- unit->au_Capacity48 = 0;
1595- unit->au_Heads = 16;
1596- unit->au_Cylinders = 195;
1597- unit->au_Sectors = 63;
1598- capacity.blocksize = 512;*/
1599-
1600- DINIT (bug ("[ATA:%02ld] atapi_TestUnitOK: LBA = %u | Block = %u | Cylinders = %u | Heads = %u | Sectors = %u |" ,
1600+ DINIT (bug ("[ATA:%02ld] atapi_TestUnitOK: REGISTERED = LBA = %u | Block = %u | Cylinders = %u | Heads = %u | Sectors = %u |" ,
16011601 unit -> au_UnitNum , unit -> au_Capacity , 1 <<unit -> au_SectorShift , unit -> au_Cylinders , unit -> au_Heads , unit -> au_Sectors ));
16021602
16031603 DINIT (bug ("Result = %d | Media = %s | Change = %s\n" ,
16041604 result , unit -> au_Flags & AF_DiscPresent ? "YES" : "NO" , unit -> au_Flags & AF_DiscChanged ? "YES" : "NO" ));
16051605
1606- if (result == 0 )
1606+ if (result == 0 || result == 29 )
16071607 {
16081608 return (TRUE); // No Media but valid Device
16091609 } else {
@@ -1616,9 +1616,10 @@ BOOL atapi_TestUnitOK(struct ata_Unit *unit)
16161616 unit -> au_Flags |= AF_DiscChanged ; // Set AF_DiscChanged
16171617 }
16181618
1619- if (( unit -> au_DevType ) == DG_DIRECT_ACCESS )
1619+ if ( (( unit -> au_DevType ) == DG_DIRECT_ACCESS ) && (( unit -> au_Flags & AF_Removable ) == 0 ) )
16201620 {
16211621 unit -> au_Capacity = capacity .logicalsectors ;
1622+ unit -> au_Capacity48 = capacity .logicalsectors ;
16221623
16231624 #define HEADS_PER_CYLINDER 16
16241625 #define SECTORS_PER_TRACK 63
@@ -1630,7 +1631,7 @@ BOOL atapi_TestUnitOK(struct ata_Unit *unit)
16301631 unit -> au_Sectors = (UBYTE )SECTORS_PER_TRACK ;
16311632 }
16321633
1633- DINIT (bug ("[ATA:%02ld] atapi_TestUnitOK: LBA = %u | Block = %u | Cylinders = %u | Heads = %u | Sectors = %u | " ,
1634+ DINIT (bug ("[ATA:%02ld] atapi_TestUnitOK: REGISTERED = LBA = %u | Block = %u | Cylinders = %u | Heads = %u | Sectors = %u | " ,
16341635 unit -> au_UnitNum , unit -> au_Capacity , capacity .blocksize , unit -> au_Cylinders , unit -> au_Heads , unit -> au_Sectors ));
16351636
16361637 DINIT (bug ("Result = %d | Media = %s | Change = %s\n" ,
@@ -1940,16 +1941,6 @@ static BYTE atapi_EndCmd(struct ata_Unit *unit)
19401941 error = PIO_In (bus , atapi_Error );
19411942 DERROR (bug ("[ATA:%02ld] atapi_EndCmd: ERROR code 0x%lx\n" , unit -> au_UnitNum , error ));
19421943
1943- /*if (error != 0x60)
1944- {
1945- ULONG sense_lenght = 18;
1946- UBYTE* sense_data = AllocMem(sense_lenght, MEMF_ANY|MEMF_PUBLIC);
1947-
1948- atapi_RequestSense(unit, sense_data, sense_lenght);
1949-
1950- FreeMem(sense_data,sense_lenght);
1951- }*/
1952-
19531944 return ErrorMap [error >> 4 ];
19541945 }
19551946}
0 commit comments