Title.mui: minor code cleanup
[AROS.git] / rom / devs / ata / waitto.c
blob8d0701e23ad026569ed00ef14d728506d19497b2
1 /*
2 Copyright © 2013-2014, The AROS Development Team. All rights reserved
3 $Id$
4 */
6 #include <exec/types.h>
7 #include <devices/timer.h>
8 #include <exec/io.h>
9 #include <proto/exec.h>
10 #include <aros/debug.h>
11 #include <proto/timer.h>
13 #include "timer.h"
14 #include "ata.h"
16 /* Waits for a signal or a timeout */
17 ULONG ata_WaitTO(struct IORequest* tmr, ULONG secs, ULONG micro, ULONG sigs)
19 ULONG sig = 1 << tmr->io_Message.mn_ReplyPort->mp_SigBit;
21 D(struct Node *t = FindTask(NULL));
22 D(bug("[ATA ] Timed wait %lds %ldu (task='%s')\n", secs, micro,
23 t->ln_Name));
25 tmr->io_Command = TR_ADDREQUEST;
26 ((struct timerequest*)tmr)->tr_time.tv_secs = secs;
27 ((struct timerequest*)tmr)->tr_time.tv_micro = micro;
29 SendIO(tmr);
30 D(bug("[ATA ] Preset signals: %lx ('%s')\n", SetSignal(0, 0), t->ln_Name));
31 D(bug("[ATA ] Signals requested: %lx ('%s')\n", sigs, t->ln_Name));
32 D(bug("[ATA ] Timer signal: %lx ('%s')\n", sig, t->ln_Name));
33 sigs = Wait(sigs | sig);
34 D(bug("[ATA ] Signals received: %lx ('%s')\n", sigs, t->ln_Name));
35 if (0 == (sigs & sig))
37 if (!CheckIO(tmr))
38 AbortIO(tmr);
40 WaitIO(tmr);
42 SetSignal(0, sig);
44 return sigs & ~sig;