Skip to content

Commit 717b532

Browse files
committed
ata.device [44.41] - AutoMount CD/DVD Fixed
1 parent 6abd885 commit 717b532

File tree

3 files changed

+72
-76
lines changed

3 files changed

+72
-76
lines changed

rom/devs/ata/ata.c

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@
3232
#define DINIT(x) x
3333
#define DD(x) x
3434
#define DDD(x)
35+
#define DERROR(x) x
3536
//---------------------------IO Commands---------------------------------------
3637

3738
/* Invalid comand does nothing, complains only. */
3839
static void cmd_Invalid(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
3940
{
40-
DD(bug("[ATA%02ld] %s(%d)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, io->io_Command));
41+
DERROR(bug("[ATA%02ld] %s(%d)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, io->io_Command));
4142
io->io_Error = IOERR_NOCMD;
4243
}
4344

@@ -54,7 +55,7 @@ static void cmd_Read32(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
5455

5556
if (AF_Removable == (unit->au_Flags & (AF_Removable | AF_DiscPresent)))
5657
{
57-
DD(bug("[ATA%02ld] %s: USUALLY YOU'D WANT TO CHECK IF DISC IS PRESENT FIRST\n", unit->au_UnitNum, __func__));
58+
DERROR(bug("[ATA%02ld] %s: USUALLY YOU'D WANT TO CHECK IF DISC IS PRESENT FIRST\n", unit->au_UnitNum, __func__));
5859
io->io_Error = TDERR_DiskChanged;
5960
return;
6061
}
@@ -72,7 +73,7 @@ static void cmd_Read32(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
7273
*/
7374
if ((block & mask) | (count & mask))
7475
{
75-
DD(bug("[ATA%02ld] %s: offset or length not sector-aligned.\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
76+
DERROR(bug("[ATA%02ld] %s: offset or length not sector-aligned.\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
7677
cmd_Invalid(io, LIBBASE);
7778
}
7879
else
@@ -83,7 +84,7 @@ static void cmd_Read32(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
8384

8485
if ((0 == (unit->au_XferModes & AF_XFER_PACKET)) && ((block + count) > unit->au_Capacity))
8586
{
86-
bug("[ATA%02ld] %s: Requested block (%lx;%ld) outside disk range (%lx)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, block, count, unit->au_Capacity);
87+
DERROR(bug("[ATA%02ld] %s: Requested block (%lx;%ld) outside disk range (%lx)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, block, count, unit->au_Capacity));
8788
io->io_Error = IOERR_BADADDRESS;
8889
return;
8990
}
@@ -166,13 +167,13 @@ static void cmd_Read64(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
166167
UQUAD block = IOStdReq(io)->io_Offset | (UQUAD)(IOStdReq(io)->io_Actual) << 32;
167168
ULONG count = IOStdReq(io)->io_Length;
168169

169-
//DD(bug("[ATA%02ld] %s(%08x-%08x, %08x)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, IOStdReq(io)->io_Actual, IOStdReq(io)->io_Offset, count));
170+
DDD(bug("[ATA%02ld] %s(%08x-%08x, %08x)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, IOStdReq(io)->io_Actual, IOStdReq(io)->io_Offset, count));
170171

171172
ULONG mask = (1 << unit->au_SectorShift) - 1;
172173

173174
if ((block & (UQUAD)mask) | (count & mask) | (count == 0))
174175
{
175-
DD(bug("[ATA%02ld] %s: offset or length not sector-aligned.\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
176+
DERROR(bug("[ATA%02ld] %s: offset or length not sector-aligned.\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
176177
cmd_Invalid(io, LIBBASE);
177178
}
178179
else
@@ -190,7 +191,7 @@ static void cmd_Read64(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
190191
{
191192
if ((0 == (unit->au_XferModes & AF_XFER_PACKET)) && ((block + count) > unit->au_Capacity))
192193
{
193-
bug("[ATA%02ld] %s: Requested block (%lx;%ld) outside disk range (%lx)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, block, count, unit->au_Capacity);
194+
DERROR(bug("[ATA%02ld] %s: Requested block (%lx;%ld) outside disk range (%lx)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, block, count, unit->au_Capacity));
194195
io->io_Error = IOERR_BADADDRESS;
195196
return;
196197
}
@@ -332,7 +333,7 @@ static void cmd_Write32(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
332333
ULONG block = IOStdReq(io)->io_Offset;
333334
ULONG count = IOStdReq(io)->io_Length;
334335

335-
//DD(bug("[ATA%02ld] %s(%08x, %08x)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, block, count));
336+
DDD(bug("[ATA%02ld] %s(%08x, %08x)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, block, count));
336337

337338
ULONG mask = (1 << unit->au_SectorShift) - 1;
338339

@@ -342,7 +343,7 @@ static void cmd_Write32(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
342343
*/
343344
if ((block & mask) | (count & mask))
344345
{
345-
DD(bug("[ATA%02ld] %s: offset or length not sector-aligned.\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
346+
DERROR(bug("[ATA%02ld] %s: offset or length not sector-aligned.\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
346347
cmd_Invalid(io, LIBBASE);
347348
}
348349
else
@@ -354,9 +355,9 @@ static void cmd_Write32(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
354355
if ((0 == (unit->au_XferModes & AF_XFER_PACKET))
355356
&& ((block + count) > unit->au_Capacity))
356357
{
357-
bug("[ATA%02ld] %s: Requested block (%lx;%ld) outside disk range (%lx)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum,
358+
DERROR(bug("[ATA%02ld] %s: Requested block (%lx;%ld) outside disk range (%lx)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum,
358359
__func__,
359-
block, count, unit->au_Capacity);
360+
block, count, unit->au_Capacity));
360361
io->io_Error = IOERR_BADADDRESS;
361362
return;
362363
}
@@ -389,21 +390,21 @@ static void cmd_Write64(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
389390

390391
if (AF_Removable == (unit->au_Flags & (AF_Removable | AF_DiscPresent)))
391392
{
392-
D(bug("[ATA%02ld] %s: USUALLY YOU'D WANT TO CHECK IF DISC IS PRESENT FIRST\n", unit->au_UnitNum, __func__));
393+
DERROR(bug("[ATA%02ld] %s: USUALLY YOU'D WANT TO CHECK IF DISC IS PRESENT FIRST\n", unit->au_UnitNum, __func__));
393394
io->io_Error = TDERR_DiskChanged;
394395
return;
395396
}
396397

397398
UQUAD block = IOStdReq(io)->io_Offset | (UQUAD)(IOStdReq(io)->io_Actual) << 32;
398399
ULONG count = IOStdReq(io)->io_Length;
399400

400-
//DD(bug("[ATA%02ld] %s(%08x-%08x, %08x)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, IOStdReq(io)->io_Actual, IOStdReq(io)->io_Offset, count));
401+
DDD(bug("[ATA%02ld] %s(%08x-%08x, %08x)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, IOStdReq(io)->io_Actual, IOStdReq(io)->io_Offset, count));
401402

402403
ULONG mask = (1 << unit->au_SectorShift) - 1;
403404

404405
if ((block & mask) | (count & mask) | (count==0))
405406
{
406-
DD(bug("[ATA%02ld] %s: offset or length not sector-aligned.\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
407+
DERROR(bug("[ATA%02ld] %s: offset or length not sector-aligned.\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
407408
cmd_Invalid(io, LIBBASE);
408409
}
409410
else
@@ -422,8 +423,7 @@ static void cmd_Write64(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
422423
if ((0 == (unit->au_XferModes & AF_XFER_PACKET))
423424
&& ((block + count) > unit->au_Capacity))
424425
{
425-
bug("[ATA%02ld] %s: Requested block (%lx;%ld) outside disk range "
426-
"(%lx)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, block, count, unit->au_Capacity);
426+
DERROR(bug("[ATA%02ld] %s: Requested block (%lx;%ld) outside disk range (%lx)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, block, count, unit->au_Capacity));
427427
io->io_Error = IOERR_BADADDRESS;
428428
return;
429429
}
@@ -435,12 +435,11 @@ static void cmd_Write64(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
435435
if ((0 == (unit->au_XferModes & AF_XFER_PACKET))
436436
&& ((block + count) > unit->au_Capacity48))
437437
{
438-
bug("[ATA%02ld] %s: Requested block (%lx:%08lx;%ld) outside disk "
439-
"range (%lx:%08lx)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum,
438+
DERROR(bug("[ATA%02ld] %s: Requested block (%lx:%08lx;%ld) outside disk range (%lx:%08lx)\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum,
440439
__func__,
441440
block>>32, block&0xfffffffful,
442441
count, unit->au_Capacity48>>32,
443-
unit->au_Capacity48 & 0xfffffffful);
442+
unit->au_Capacity48 & 0xfffffffful));
444443
io->io_Error = IOERR_BADADDRESS;
445444
return;
446445
}
@@ -493,7 +492,7 @@ static void cmd_TestChanged(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
493492
struct ata_Unit *unit = (struct ata_Unit *)io->io_Unit;
494493
struct IORequest *msg;
495494

496-
DD(bug("[ATA%02ld] %s()\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
495+
DDD(bug("[ATA%02ld] %s()\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
497496

498497
if ((unit->au_XferModes & AF_XFER_PACKET) && (unit->au_Flags & AF_Removable))
499498
{
@@ -511,14 +510,14 @@ static void cmd_TestChanged(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
511510
if (unit->au_RemoveInt)
512511
{
513512
Cause(unit->au_RemoveInt);
514-
bug("[ATA%02ld] Calling unit->au_RemoveInt\n, unit->au_UnitNum");
513+
DD(bug("[ATA%02ld] Calling unit->au_RemoveInt\n", unit->au_UnitNum));
515514
}
516515

517516
// And now the whole list of possible calls
518517
ForeachNode(&unit->au_SoftList, msg)
519518
{
520519
Cause((struct Interrupt *)IOStdReq(msg)->io_Data);
521-
bug("[ATA%02ld] Calling unit->au_SoftList\n");
520+
DD(bug("[ATA%02ld] Calling unit->au_SoftList\n", unit->au_UnitNum));
522521
}
523522

524523
unit->au_Flags &= ~AF_DiscChanged;
@@ -531,7 +530,7 @@ static void cmd_TestChanged(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
531530
static void cmd_Update(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
532531
{
533532
/* Do nothing now. In near future there should be drive cache flush though */
534-
DD(bug("[ATA%02ld] %s()\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
533+
DDD(bug("[ATA%02ld] %s()\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
535534
}
536535

537536
static void cmd_Remove(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
@@ -557,7 +556,7 @@ static void cmd_ChangeState(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
557556
{
558557
struct ata_Unit *unit = (struct ata_Unit *)io->io_Unit;
559558

560-
DD(bug("[ATA%02ld] %s()\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
559+
DDD(bug("[ATA%02ld] %s()\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
561560

562561
if (unit->au_Flags & AF_DiscPresent)
563562
IOStdReq(io)->io_Actual = 0;
@@ -624,7 +623,7 @@ static void cmd_GetGeometry(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
624623
{
625624
struct ata_Unit *unit = (struct ata_Unit *)io->io_Unit;
626625

627-
DD(bug("[ATA%02ld] %s()\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
626+
DDD(bug("[ATA%02ld] %s()\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
628627

629628
if (IOStdReq(io)->io_Length == sizeof(struct DriveGeometry))
630629
{
@@ -726,7 +725,7 @@ static void cmd_SMART(struct IORequest *io, LIBBASETYPEPTR LIBBASE)
726725
struct ata_Bus *bus = unit->au_Bus;
727726
UBYTE u;
728727
#endif
729-
bug("[ATA%02ld] %s()\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__);
728+
DD(bug("[ATA%02ld] %s()\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
730729

731730
if (unit->au_Flags & AF_DiscPresent)
732731
{
@@ -973,15 +972,15 @@ AROS_LH1(void, BeginIO,
973972
/* Disable interrupts for a while to modify message flags */
974973
Disable();
975974

976-
DD(bug("[ATA%02ld] %s: Executing IO Command %lx\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, io->io_Command));
975+
DDD(bug("[ATA%02ld] %s: Executing IO Command %lx\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__, io->io_Command));
977976

978977
/*
979978
If the command is not-immediate, or presence of disc is still unknown,
980979
let the bus task do the job.
981980
*/
982981
if (isSlow(io))
983982
{
984-
DD(bug("[ATA%02ld] %s: ->Slow command\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
983+
DDD(bug("[ATA%02ld] %s: ->Slow command\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
985984

986985
unit->au_Unit.unit_flags |= UNITF_ACTIVE | UNITF_INTASK;
987986
io->io_Flags &= ~IOF_QUICK;
@@ -992,7 +991,7 @@ AROS_LH1(void, BeginIO,
992991
}
993992
else
994993
{
995-
DD(bug("[ATA%02ld] %s: ->Fast command\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
994+
DDD(bug("[ATA%02ld] %s: ->Fast command\n", ((struct ata_Unit*)io->io_Unit)->au_UnitNum, __func__));
996995

997996
/* Immediate command. Mark unit as active and do the command directly */
998997
unit->au_Unit.unit_flags |= UNITF_ACTIVE;
@@ -1062,7 +1061,7 @@ void DaemonCode(struct ataBase *ATABase, struct ata_Controller *ataNode)
10621061
timer = ata_OpenTimer(ATABase);
10631062
if (!timer)
10641063
{
1065-
DD(bug("[ATA++] Failed to open timer!\n"));
1064+
DERROR(bug("[ATA++] Failed to open timer!\n"));
10661065

10671066
Forbid();
10681067
Signal(ataNode->ac_daemonParent, SIGF_SINGLE);
@@ -1106,7 +1105,7 @@ void DaemonCode(struct ataBase *ATABase, struct ata_Controller *ataNode)
11061105
{
11071106
struct IOStdReq *ios;
11081107

1109-
DD(bug("[ATA++] Detecting media presence\n"));
1108+
//DD(bug("[ATA++] Detecting media presence\n"));
11101109
ObtainSemaphore(&ataNode->DaemonSem);
11111110

11121111
ForeachNode(&ataNode->Daemon_ios, ios)
@@ -1124,13 +1123,7 @@ void DaemonCode(struct ataBase *ATABase, struct ata_Controller *ataNode)
11241123
ReleaseSemaphore(&ataNode->DaemonSem);
11251124
}
11261125

1127-
/*
1128-
* And then hide and wait for 1 second
1129-
*/
1130-
//DD(bug("[ATA++] 1 second delay, timer 0x%p...\n", timer));
11311126
sigs = ata_WaitTO(timer, 1, 0, SIGBREAKF_CTRL_C);
1132-
1133-
//DD(bug("[ATA++] Delay completed\n"));
11341127
b++;
11351128
} while (!sigs);
11361129

@@ -1175,7 +1168,7 @@ void BusTaskCode(struct ata_Bus *bus, struct ataBase *ATABase)
11751168
{
11761169
if (bus->ab_Dev[iter] > DEV_UNKNOWN)
11771170
{
1178-
bug("[ATA:BusTask] Device %u type %d\n", iter, bus->ab_Dev[iter]);
1171+
DD(bug("[ATA:BusTask] Device %u type %d\n", iter, bus->ab_Dev[iter]));
11791172
unitObj = OOP_NewObject(ATABase->unitClass, NULL, NULL);
11801173
if (unitObj)
11811174
{
@@ -1286,7 +1279,7 @@ void BusTaskCode2(struct ata_Bus *bus, struct ataBase *ATABase)
12861279
OOP_Object *unitObj;
12871280
struct ata_Unit *unit;
12881281

1289-
bug("[ATA:BusTask2] TaskCode started (bus: %u)\n", bus->ab_BusNum);
1282+
DD(bug("[ATA:BusTask2] TaskCode started (bus: %u)\n", bus->ab_BusNum));
12901283

12911284
bus->ab_Timer = ata_OpenTimer(ATABase);
12921285

@@ -1301,7 +1294,7 @@ void BusTaskCode2(struct ata_Bus *bus, struct ataBase *ATABase)
13011294

13021295
for (iter = 0; iter < MAX_BUSUNITS; ++iter)
13031296
{
1304-
bug("[ATA:BusTask2] Device %u type %d\n", iter, bus->ab_Dev[iter]);
1297+
DD(bug("[ATA:BusTask2] Device %u type %d\n", iter, bus->ab_Dev[iter]));
13051298

13061299
if (bus->ab_Dev[iter] > DEV_UNKNOWN)
13071300
{

rom/devs/ata/ata.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
##begin config
22
basename ata
3-
version 44.40
3+
version 44.41
44
libbasetype struct ataBase
55
residentpri 4
66
beginio_func BeginIO

0 commit comments

Comments
 (0)