|
|
1.1.1.9 root 1: /*
1.1 root 2: * UAE - The Un*x Amiga Emulator
1.1.1.9 root 3: *
1.1 root 4: * Miscellaneous machine dependent support functions and definitions
5: *
6: * Copyright 1996 Bernd Schmidt
7: */
8:
9:
10: #include "sysconfig.h"
11: #include "sysdeps.h"
12:
13: #include "options.h"
14: #include "machdep/m68k.h"
1.1.1.3 root 15: #include "events.h"
1.1.1.5 root 16: #include "custom.h"
1.1 root 17:
1.1.1.2 root 18: #ifndef USE_UNDERSCORE
19: #define LARGE_ALIGNMENT ".align 16\n"
20: #else
21: #define LARGE_ALIGNMENT ".align 4,0x90\n"
22: #endif
23:
1.1 root 24: struct flag_struct regflags;
25:
1.1.1.6 root 26: /* All the Win32 configurations handle this in od-win32/win32.c */
27: #ifndef _WIN32
1.1 root 28:
1.1.1.6 root 29: #include <signal.h>
1.1.1.2 root 30:
1.1.1.6 root 31: static volatile frame_time_t last_time, best_time;
32: static volatile int loops_to_go;
1.1.1.2 root 33:
1.1.1.6 root 34: #ifndef HAVE_SETITIMER
35: #define TIME_UNIT 1000000
1.1.1.2 root 36: #else
1.1.1.6 root 37: #define TIME_UNIT 100000
1.1.1.2 root 38: #endif
39:
1.1.1.6 root 40: static void set_alarm (void)
41: {
42: #ifndef HAVE_SETITIMER
43: alarm (1);
44: #else
45: struct itimerval t;
46: t.it_value.tv_sec = 0;
47: t.it_value.tv_usec = TIME_UNIT;
48: t.it_interval.tv_sec = 0;
49: t.it_interval.tv_usec = TIME_UNIT;
50: setitimer (ITIMER_REAL, &t, NULL);
1.1.1.2 root 51: #endif
1.1 root 52: }
1.1.1.2 root 53:
1.1.1.6 root 54: static int first_loop = 1;
1.1.1.2 root 55:
56: #ifdef __cplusplus
57: static RETSIGTYPE alarmhandler(...)
58: #else
59: static RETSIGTYPE alarmhandler(int foo)
60: #endif
61: {
62: frame_time_t bar;
63: bar = read_processor_time ();
1.1.1.6 root 64: if (! first_loop && bar - last_time < best_time)
1.1.1.2 root 65: best_time = bar - last_time;
1.1.1.6 root 66: first_loop = 0;
1.1.1.2 root 67: if (--loops_to_go > 0) {
68: signal (SIGALRM, alarmhandler);
69: last_time = read_processor_time();
1.1.1.6 root 70: set_alarm ();
1.1.1.8 root 71: } else {
72: alarm (0);
73: signal (SIGALRM, SIG_IGN);
1.1.1.2 root 74: }
75: }
76:
1.1.1.4 root 77: #include <setjmp.h>
78: jmp_buf catch_test;
79:
1.1.1.3 root 80: #ifdef __cplusplus
81: static RETSIGTYPE illhandler(...)
82: #else
83: static RETSIGTYPE illhandler(int foo)
84: #endif
85: {
86: rpt_available = 0;
1.1.1.4 root 87: longjmp(catch_test,1);
1.1.1.3 root 88: }
89:
1.1.1.2 root 90: void machdep_init (void)
91: {
1.1.1.3 root 92: rpt_available = 1;
1.1.1.7 root 93: write_log ("Testing the RDTSC instruction ... ");
1.1.1.3 root 94: signal (SIGILL, illhandler);
1.1.1.5 root 95: if (setjmp (catch_test) == 0)
96: read_processor_time ();
1.1.1.3 root 97: signal (SIGILL, SIG_DFL);
1.1.1.7 root 98: write_log ("done.\n");
1.1.1.3 root 99: if (! rpt_available) {
1.1.1.7 root 100: write_log ("Your processor does not support the RDTSC instruction.\n");
1.1.1.3 root 101: return;
102: }
1.1.1.7 root 103: write_log ("Calibrating delay loop.. ");
1.1.1.3 root 104: fflush (stderr);
1.1.1.2 root 105: best_time = (frame_time_t)-1;
106: loops_to_go = 5;
107: signal (SIGALRM, alarmhandler);
108: /* We want exact values... */
109: sync (); sync (); sync ();
110: last_time = read_processor_time();
1.1.1.6 root 111: set_alarm ();
1.1.1.2 root 112: while (loops_to_go != 0)
1.1.1.6 root 113: usleep (10000);
1.1.1.7 root 114: write_log ("ok - %.2f BogoMIPS\n",
1.1.1.6 root 115: ((double)best_time / TIME_UNIT), best_time);
116: syncbase = best_time * (1000000 / TIME_UNIT);
1.1.1.2 root 117: }
118:
119: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.