2 * fat-handler - FAT12/16/32 filesystem handler
4 * Copyright © 2008-2015 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"
22 LONG
InitTimer(struct Globals
*glob
)
24 LONG err
= ERROR_NO_FREE_STORE
;
26 glob
->timerport
= CreateMsgPort();
30 (struct timerequest
*)CreateIORequest(glob
->timerport
,
31 sizeof(struct timerequest
));
34 if (OpenDevice("timer.device", UNIT_VBLANK
,
35 (struct IORequest
*)glob
->timereq
, 0))
36 err
= ERROR_DEVICE_NOT_MOUNTED
;
39 glob
->timer_active
= FALSE
;
40 glob
->restart_timer
= TRUE
;
41 glob
->gl_TimerBase
= glob
->timereq
->tr_node
.io_Device
;
42 D(bug("[fat] Timer ready\n"));
45 DeleteIORequest((struct IORequest
*)glob
->timereq
);
47 DeleteMsgPort(glob
->timerport
);
52 void CleanupTimer(struct Globals
*glob
)
54 D(bug("[fat] Cleaning up timer\n"));
55 if (glob
->timer_active
)
57 D(bug("[fat] Terminating active request\n"));
58 AbortIO((struct IORequest
*)glob
->timereq
);
59 WaitIO((struct IORequest
*)glob
->timereq
);
61 CloseDevice((struct IORequest
*)glob
->timereq
);
62 DeleteIORequest((struct IORequest
*)glob
->timereq
);
63 DeleteMsgPort(glob
->timerport
);
66 void RestartTimer(struct Globals
*glob
)
68 if (glob
->timer_active
)
70 D(bug("Queuing timer restart\n"));
71 glob
->restart_timer
= TRUE
;
75 D(bug("Immediate timer restart\n"));
76 glob
->timereq
->tr_node
.io_Command
= TR_ADDREQUEST
;
77 glob
->timereq
->tr_time
.tv_secs
= 1;
78 glob
->timereq
->tr_time
.tv_micro
= 0;
79 SendIO((struct IORequest
*)glob
->timereq
);
80 glob
->timer_active
= TRUE
;
84 void HandleTimer(struct Globals
*glob
)
86 WaitIO((struct IORequest
*)glob
->timereq
);
87 glob
->timer_active
= 0;
88 if (glob
->restart_timer
)
90 D(bug("Timer restart queued\n"));
91 glob
->restart_timer
= FALSE
;
96 D(bug("Updating disk\n"));