delint
[AROS.git] / rom / devs / ata / timer.c
blob64551292321804f0cdef78303957d0ea1158b30d
1 /*
2 Copyright © 2009-2013, The AROS Development Team. All rights reserved
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <exec/types.h>
10 #include <devices/timer.h>
11 #include <exec/io.h>
12 #include <proto/exec.h>
13 #include <aros/debug.h>
14 #include <proto/timer.h>
16 #include "timer.h"
17 #include "ata.h"
19 struct IORequest *ata_OpenTimer(struct ataBase *base)
21 struct MsgPort *p = CreateMsgPort();
22 if (NULL != p)
24 struct IORequest *io = CreateIORequest(p, sizeof(struct timerequest));
26 if (NULL != io)
29 * ok. ECLOCK does not have too great resolution, either.
30 * we will have to sacrifice our performance a little bit, meaning, the 400ns will turn into (worst case) 2us.
31 * hopefully we won't have to call that TOO often...
33 if (0 == OpenDevice("timer.device", UNIT_MICROHZ, io, 0))
35 return io;
37 else
39 bug("[ATA ] Failed to open timer.device, unit MICROHZ\n");
41 DeleteIORequest(io);
43 else
45 bug("[ATA ] Failed to create timerequest\n");
47 DeleteMsgPort(p);
49 else
51 bug("[ATA ] Failed to create timer port\n");
54 return NULL;
57 void ata_CloseTimer(struct IORequest *tmr)
59 if (NULL != tmr)
61 struct MsgPort *p = tmr->io_Message.mn_ReplyPort;
62 CloseDevice(tmr);
63 DeleteIORequest(tmr);
64 DeleteMsgPort(p);