Subversion Repositories SvarDOS

Rev

Rev 1360 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1360 Rev 1542
Line 2... Line 2...
2
 * High-resolution timing routines (PIT reprogramming)
2
 * High-resolution timing routines (PIT reprogramming)
3
 *
3
 *
4
 * This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
4
 * This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
5
 * Published under the terms of the MIT License, as stated below.
5
 * Published under the terms of the MIT License, as stated below.
6
 *
6
 *
7
 * Copyright (C) 2014-2022 Mateusz Viste
7
 * Copyright (C) 2014-2023 Mateusz Viste
8
 *
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
10
 * of this software and associated documentation files (the "Software"), to
10
 * of this software and associated documentation files (the "Software"), to
11
 * deal in the Software without restriction, including without limitation the
11
 * deal in the Software without restriction, including without limitation the
12
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
Line 26... Line 26...
26
 */
26
 */
27
 
27
 
28
#ifndef MDR_TIMER_H
28
#ifndef MDR_TIMER_H
29
#define MDR_TIMER_H
29
#define MDR_TIMER_H
30
 
30
 
31
/* reset the timer value, this can be used by the application to make sure
31
/* Starts the timer by reprogramming the 8253 chip from its default 18.2 Hz
-
 
32
 * frequency to about 1.1 kHz. It is mandatory to revert the timer to its
32
 * no timer wrap occurs during critical parts of the code flow */
33
 * original frequency via mdr_timer_stop() before your application quits. */
33
void timer_reset(void);
34
void mdr_timer_init(void);
34
 
35
 
35
/* This routine will stop the fast clock if it is going. It has void return
36
/* Fills res with the amount of microseconds that elapsed since either
-
 
37
 * mdr_timer_init() or mdr_timer_reset(), whichever was called last.
-
 
38
 * Note that the res counter wraps around approximately every 71 minutes if
36
 * value so that it can be an exit procedure. */
39
 * mdr_timer_reset() is not called. */
37
void timer_stop(void);
40
void mdr_timer_read(unsigned long *res);
38
 
41
 
39
/* This routine will start the fast clock rate by installing the
-
 
40
 * handle_clock routine as the interrupt service routine for the clock
-
 
41
 * interrupt and then setting the interrupt rate up to its higher speed
42
/* Reset the timer value, this can be used by the application to make sure
42
 * by programming the 8253 timer chip.
-
 
43
 * This routine does nothing if the clock rate is already set to
-
 
44
 * its higher rate, but then it returns -1 to indicate the error. */
43
 * no timer wrap occurs during critical parts of your code flow */
45
void timer_init(void);
44
void mdr_timer_reset(void);
46
 
45
 
47
/* This routine will return the present value of the time, which is
46
/* Stops (uninstalls) the timer. This must be called before your application
48
 * read from the nowtime structure. Interrupts are disabled during this
47
 * quits, otherwise the system will likely crash. This function has a void
49
 * time to prevent the clock from changing while it is being read. */
48
 * return value so that it can be registered as an atexit() procedure. */
50
void timer_read(unsigned long *res);
49
void mdr_timer_stop(void);
51
 
50
 
52
#endif
51
#endif