First Commit of my working state
[simh.git] / sim_timer.h
1 /* sim_timer.h: simulator timer library headers
2
3 Copyright (c) 1993-2007, Robert M Supnik
4
5 Permission is hereby granted, free of charge, to any person obtaining a
6 copy of this software and associated documentation files (the "Software"),
7 to deal in the Software without restriction, including without limitation
8 the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 and/or sell copies of the Software, and to permit persons to whom the
10 Software is furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the name of Robert M Supnik shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from Robert M Supnik.
25
26 28-Apr-07 RMS Added sim_rtc_init_all
27 17-Oct-06 RMS Added idle support
28 02-Jan-04 RMS Split out from SCP
29 */
30
31 #ifndef _SIM_TIMER_H_
32 #define _SIM_TIMER_H_ 0
33
34 #define SIM_NTIMERS 8 /* # timers */
35 #define SIM_TMAX 500 /* max timer makeup */
36
37 #define SIM_IDLE_CAL 10 /* ms to calibrate */
38 #define SIM_IDLE_MAX 10 /* max granularity idle */
39
40 #define SIM_THROT_WINIT 1000 /* cycles to skip */
41 #define SIM_THROT_WST 10000 /* initial wait */
42 #define SIM_THROT_WMUL 4 /* multiplier */
43 #define SIM_THROT_WMIN 100 /* min wait */
44 #define SIM_THROT_MSMIN 10 /* min for measurement */
45 #define SIM_THROT_NONE 0 /* throttle parameters */
46 #define SIM_THROT_MCYC 1
47 #define SIM_THROT_KCYC 2
48 #define SIM_THROT_PCT 3
49
50 t_bool sim_timer_init (void);
51 int32 sim_rtcn_init (int32 time, int32 tmr);
52 void sim_rtcn_init_all (void);
53 int32 sim_rtcn_calb (int32 ticksper, int32 tmr);
54 int32 sim_rtc_init (int32 time);
55 int32 sim_rtc_calb (int32 ticksper);
56 t_bool sim_idle (uint32 tmr, t_bool sin_cyc);
57 t_stat sim_set_throt (int32 arg, char *cptr);
58 t_stat sim_show_throt (FILE *st, DEVICE *dnotused, UNIT *unotused, int32 flag, char *cptr);
59 t_stat sim_set_idle (UNIT *uptr, int32 val, char *cptr, void *desc);
60 t_stat sim_clr_idle (UNIT *uptr, int32 val, char *cptr, void *desc);
61 t_stat sim_show_idle (FILE *st, UNIT *uptr, int32 val, void *desc);
62 void sim_throt_sched (void);
63 void sim_throt_cancel (void);
64 uint32 sim_os_msec (void);
65 void sim_os_sleep (unsigned int sec);
66 uint32 sim_os_ms_sleep (unsigned int msec);
67 uint32 sim_os_ms_sleep_init (void);
68
69 #endif