Watt-32 tcp/ip  2.2 dev-rel.10
timer.h
Go to the documentation of this file.
1 
3 #ifndef _w32_TIMER_H
4 #define _w32_TIMER_H
5 
6 #ifndef __SYS_WTIME_H
7 #include <sys/wtime.h> /* struct timeval */
8 #endif
9 
10 #define user_tick_active W32_NAMESPACE (user_tick_active)
11 #define user_tick_base W32_NAMESPACE (user_tick_base)
12 #define user_tick_msec W32_NAMESPACE (user_tick_msec)
13 #define clocks_per_usec W32_NAMESPACE (clocks_per_usec)
14 #define millisec_clock W32_NAMESPACE (millisec_clock)
15 #define start_time W32_NAMESPACE (start_time)
16 #define start_day W32_NAMESPACE (start_day)
17 #define init_timers W32_NAMESPACE (init_timers)
18 
19 #define time_str W32_NAMESPACE (time_str)
20 #define hms_str W32_NAMESPACE (hms_str)
21 #define elapsed_str W32_NAMESPACE (elapsed_str)
22 #define init_timer_isr W32_NAMESPACE (init_timer_isr)
23 #define exit_timer_isr W32_NAMESPACE (exit_timer_isr)
24 
25 #define has_rdtsc W32_NAMESPACE (has_rdtsc)
26 #define use_rdtsc W32_NAMESPACE (use_rdtsc)
27 
28 #if defined(WIN32)
29  #define win_get_perf_count W32_NAMESPACE (win_get_perf_count)
30 
31  W32_DATA BOOL has_rdtsc, use_rdtsc;
32  extern uint64 win_get_perf_count (void);
33 
34 #else
35  /*
36  * System clock at BIOS location 40:6C (dword). Counts upwards.
37  */
38  #define BIOS_CLK 0x46C
39 
40  #define has_8254 W32_NAMESPACE (has_8254)
41  #define using_int8 W32_NAMESPACE (using_int8)
42  #define clockbits W32_NAMESPACE (clockbits)
43  #define ms_clock W32_NAMESPACE (ms_clock)
44  #define hires_timer W32_NAMESPACE (hires_timer)
45 
46  extern BOOL has_8254, using_int8;
47  extern BOOL has_rdtsc, use_rdtsc;
48 
49  extern DWORD clockbits (void);
50  extern int hires_timer (int on);
51  extern DWORD ms_clock (void);
52  extern void init_timer_isr (void);
53  extern void exit_timer_isr (void);
54 #endif
55 
56 W32_DATA BOOL user_tick_active;
57 W32_DATA DWORD clocks_per_usec, user_tick_msec;
58 W32_DATA time_t user_tick_base;
59 W32_DATA DWORD start_time, start_day;
60 
61 extern void init_timers (void);
62 extern DWORD millisec_clock (void);
63 
64 extern const char *time_str (DWORD val);
65 extern const char *hms_str (DWORD sec);
66 extern const char *elapsed_str(DWORD val);
67 
68 #if defined(__HIGHC__) || (defined(__DMC__) && defined(__MSDOS__))
69  #define delay W32_NAMESPACE (delay)
70 
71  extern void delay (unsigned int msec);
72 #endif
73 
74 #if (DOSX) && defined(HAVE_UINT64)
75  #define get_cpu_speed W32_NAMESPACE (get_cpu_speed)
76 
77  extern uint64 get_cpu_speed (void);
78 #endif
79 
80 #endif
81 
DWORD start_day
Start-day of watt_sock_init()
Definition: timer.c:48
BOOL has_rdtsc
Never set in Watt-32.
Definition: timer.c:52
DWORD clocks_per_usec
Measured CPU speed (MHz)
Definition: timer.c:62
BOOL use_rdtsc
Ditto.
Definition: timer.c:53
unsigned long long uint64
our unsigned "long long" type
Definition: wattcp.h:60
uint64 get_cpu_speed(void)
Return estimated CPU speed in Hz.
Definition: timer.c:838
BOOL has_8254
Do we have a working 8254 timer chip?
Definition: timer.c:56
BOOL using_int8
init_timer_isr() called
Definition: timer.c:59
DWORD start_time
Start-time of watt_sock_init() (in msec)
Definition: timer.c:47
void init_timers(void)
Setup timer stuff and measure CPU speed.
Definition: timer.c:111
int hires_timer(int on)
Control use of high-resolution timer.
Definition: timer.c:377