First sketches of ATA bus HIDD. Non compilable, just WIP backup and topic for discussion.
[AROS.git] / rom / hidds / ata_pci / timer.c
blobbf075be22521d248be036a9588d47ef078527775
1 /*
2 Copyright © 2009-2013, The AROS Development Team. All rights reserved
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <devices/timer.h>
10 #include <exec/io.h>
11 #include <proto/exec.h>
12 #include <aros/debug.h>
13 #include <proto/timer.h>
15 #include "timer.h"
16 #include "ata.h"
18 struct IORequest *ata_OpenTimer(void)
20 struct MsgPort *p = CreateMsgPort();
22 if (NULL != p)
24 struct IORequest *io = CreateIORequest(p, sizeof(struct timerequest));
26 if (NULL != io)
28 if (0 == OpenDevice("timer.device", UNIT_MICROHZ, io, 0))
30 return io;
32 DeleteIORequest(io);
34 DeleteMsgPort(p);
37 return NULL;
40 void ata_CloseTimer(struct IORequest *tmr)
42 if (NULL != tmr)
44 struct MsgPort *p = tmr->io_Message.mn_ReplyPort;
46 CloseDevice(tmr);
47 DeleteIORequest(tmr);
48 DeleteMsgPort(p);
52 void ata_WaitTO(struct IORequest* tmr, ULONG secs, ULONG micro)
54 tmr->io_Command = TR_ADDREQUEST;
55 ((struct timerequest*)tmr)->tr_time.tv_secs = secs;
56 ((struct timerequest*)tmr)->tr_time.tv_micro = micro;
58 DoIO(tmr);