2 * fat.handler - FAT12/16/32 filesystem handler
4 * Copyright 2008-2010 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.
14 #include <devices/timer.h>
16 #include <proto/exec.h>
20 #include "fat_protos.h"
24 LONG err
= ERROR_NO_FREE_STORE
;
26 glob
->timerport
= CreateMsgPort();
27 if (glob
->timerport
) {
28 glob
->timereq
= (struct timerequest
*)CreateIORequest(glob
->timerport
,
29 sizeof(struct timerequest
));
31 if (OpenDevice("timer.device", UNIT_VBLANK
, (struct IORequest
*)glob
->timereq
, 0))
32 err
= ERROR_DEVICE_NOT_MOUNTED
;
34 glob
->timer_active
= 0;
35 glob
->restart_timer
= 1;
36 D(bug("[fat] Timer ready\n"));
39 DeleteIORequest((struct IORequest
*)glob
->timereq
);
41 DeleteMsgPort(glob
->timerport
);
46 void CleanupTimer(void)
48 D(bug("[fat] Cleaning up timer\n"));
49 if (glob
->timer_active
) {
50 D(bug("[fat] Terminating active request\n"));
51 AbortIO((struct IORequest
*)glob
->timereq
);
52 WaitIO((struct IORequest
*)glob
->timereq
);
54 CloseDevice((struct IORequest
*)glob
->timereq
);
55 DeleteIORequest((struct IORequest
*)glob
->timereq
);
56 DeleteMsgPort(glob
->timerport
);
59 void RestartTimer(void)
61 if (glob
->timer_active
) {
62 D(bug("Queuing timer restart\n"));
63 glob
->restart_timer
= 1;
65 D(bug("Immediate timer restart\n"));
66 glob
->timereq
->tr_node
.io_Command
= TR_ADDREQUEST
;
67 glob
->timereq
->tr_time
.tv_secs
= 1;
68 glob
->timereq
->tr_time
.tv_micro
= 0;
69 SendIO((struct IORequest
*)glob
->timereq
);
70 glob
->timer_active
= 1;
74 void HandleTimer(void)
76 WaitIO((struct IORequest
*)glob
->timereq
);
77 glob
->timer_active
= 0;
78 if (glob
->restart_timer
) {
79 D(bug("Timer restart queued\n"));
80 glob
->restart_timer
= 0;
83 D(bug("Updating disk\n"));