2 * ntfs.handler - New Technology FileSystem handler
4 * Copyright © 2012 The AROS Development Team
6 * This program is free software; you can redistribute it and/or modify it
7 * under the same terms as AROS itself.
12 #include <devices/timer.h>
14 #include <proto/exec.h>
17 #include "ntfs_protos.h"
23 LONG err
= ERROR_NO_FREE_STORE
;
25 D(bug("[NTFS]: %s()\n", __PRETTY_FUNCTION__
));
27 glob
->timerport
= CreateMsgPort();
28 if (glob
->timerport
) {
29 glob
->timereq
= (struct timerequest
*)CreateIORequest(glob
->timerport
,
30 sizeof(struct timerequest
));
32 if (OpenDevice("timer.device", UNIT_VBLANK
, (struct IORequest
*)glob
->timereq
, 0))
33 err
= ERROR_DEVICE_NOT_MOUNTED
;
35 glob
->timer_active
= 0;
36 glob
->restart_timer
= 1;
37 D(bug("[NTFS] %s: Timer ready\n", __PRETTY_FUNCTION__
));
40 DeleteIORequest((struct IORequest
*)glob
->timereq
);
42 DeleteMsgPort(glob
->timerport
);
47 void CleanupTimer(void)
49 D(bug("[NTFS]: %s()\n", __PRETTY_FUNCTION__
));
51 D(bug("[NTFS] %s: Cleaning up timer\n", __PRETTY_FUNCTION__
));
52 if (glob
->timer_active
) {
53 D(bug("[NTFS] %s: Terminating active request\n", __PRETTY_FUNCTION__
));
54 AbortIO((struct IORequest
*)glob
->timereq
);
55 WaitIO((struct IORequest
*)glob
->timereq
);
57 CloseDevice((struct IORequest
*)glob
->timereq
);
58 DeleteIORequest((struct IORequest
*)glob
->timereq
);
59 DeleteMsgPort(glob
->timerport
);
62 void RestartTimer(void)
64 D(bug("[NTFS]: %s()\n", __PRETTY_FUNCTION__
));
66 if (glob
->timer_active
) {
67 D(bug("[NTFS] %s: Queuing timer restart\n", __PRETTY_FUNCTION__
));
68 glob
->restart_timer
= 1;
70 D(bug("[NTFS] %s: Immediate timer restart\n", __PRETTY_FUNCTION__
));
71 glob
->timereq
->tr_node
.io_Command
= TR_ADDREQUEST
;
72 glob
->timereq
->tr_time
.tv_secs
= 1;
73 glob
->timereq
->tr_time
.tv_micro
= 0;
74 SendIO((struct IORequest
*)glob
->timereq
);
75 glob
->timer_active
= 1;
79 void HandleTimer(void)
81 D(bug("[NTFS]: %s()\n", __PRETTY_FUNCTION__
));
83 WaitIO((struct IORequest
*)glob
->timereq
);
84 glob
->timer_active
= 0;
85 if (glob
->restart_timer
) {
86 D(bug("[NTFS] %s: Timer restart queued\n", __PRETTY_FUNCTION__
));
87 glob
->restart_timer
= 0;
90 D(bug("[NTFS] %s: Updating disk\n", __PRETTY_FUNCTION__
));