1360 |
mateusz.vi |
1 |
/*
|
|
|
2 |
* High-resolution timing routines (PIT reprogramming)
|
|
|
3 |
*
|
|
|
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.
|
|
|
6 |
*
|
|
|
7 |
* Copyright (C) 2014-2022 Mateusz Viste
|
|
|
8 |
*
|
|
|
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
|
|
|
11 |
* deal in the Software without restriction, including without limitation the
|
|
|
12 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
13 |
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
14 |
* furnished to do so, subject to the following conditions:
|
|
|
15 |
*
|
|
|
16 |
* The above copyright notice and this permission notice shall be included in
|
|
|
17 |
* all copies or substantial portions of the Software.
|
|
|
18 |
*
|
|
|
19 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
20 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
21 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
22 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
23 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
24 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
25 |
* IN THE SOFTWARE.
|
|
|
26 |
*/
|
|
|
27 |
|
|
|
28 |
#ifndef MDR_TIMER_H
|
|
|
29 |
#define MDR_TIMER_H
|
|
|
30 |
|
|
|
31 |
/* reset the timer value, this can be used by the application to make sure
|
|
|
32 |
* no timer wrap occurs during critical parts of the code flow */
|
|
|
33 |
void timer_reset(void);
|
|
|
34 |
|
|
|
35 |
/* This routine will stop the fast clock if it is going. It has void return
|
|
|
36 |
* value so that it can be an exit procedure. */
|
|
|
37 |
void timer_stop(void);
|
|
|
38 |
|
|
|
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 |
* 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. */
|
|
|
45 |
void timer_init(void);
|
|
|
46 |
|
|
|
47 |
/* This routine will return the present value of the time, which is
|
|
|
48 |
* read from the nowtime structure. Interrupts are disabled during this
|
|
|
49 |
* time to prevent the clock from changing while it is being read. */
|
|
|
50 |
void timer_read(unsigned long *res);
|
|
|
51 |
|
|
|
52 |
#endif
|