-
Notifications
You must be signed in to change notification settings - Fork 3
/
dagstandalone.c
105 lines (89 loc) · 2.94 KB
/
dagstandalone.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* dagstandalone.c -- ARMulator RDP/RDI interface: ARM6 Instruction Emulator.
Copyright (C) 1994 Advanced RISC Machines Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/*********************************************************************/
/* Modified by Dave Gilbert (arcem@treblig.org) to be more */
/* independent. Not very cleanly done - more of a hack than anything */
/*********************************************************************/
#include <sys/types.h>
#include <signal.h>
#ifdef LINUX
#include <linux/time.h>
#endif
#include "dagstandalone.h"
#include "armdefs.h"
#include "dbugsys.h"
#include "ArcemConfig.h"
#include "ControlPane.h"
/**************************************************************/
/* Signal handler that terminates excecution in the ARMulator */
/**************************************************************/
#ifndef _WIN32
#ifndef AMIGA
static void dagstandalone_handlesignal(int sig) {
dbug("Terminate ARMulator - excecution\n");
#ifdef BENCHMARKEXIT
warn("Emulated cycles = %ld\n", ARMul_Time);
exit(0);
#endif
if (sig != SIGUSR1) {
warn("Unsupported signal.\n");
return;
}
exit(0); /* ??? */
}
#endif
#endif
static void InitFail(int exitcode, char const *which) {
ControlPane_Error(exitcode,"%s interface failed to initialise. Exiting\n",
which);
}
/**
* dagstandalone
*
* Called directly from main() and WinMain() this
* is in effect the main function of the program.
*
*
*/
void dagstandalone(ArcemConfig *pConfig) {
#ifndef _WIN32
#ifndef AMIGA
struct sigaction action;
#endif
#endif
ARMul_State *emu_state = NULL;
#ifndef _WIN32
#ifndef AMIGA
/* Setup a signal handler for SIGUSR1 */
action.sa_handler = dagstandalone_handlesignal;
sigemptyset (&action.sa_mask);
action.sa_flags = 0;
sigaction(SIGUSR1, &action, (struct sigaction *) 0);
#endif
#endif
ARMul_EmulateInit();
emu_state = ARMul_NewState(pConfig);
ARMul_Reset(emu_state);
if (!ARMul_MemoryInit(emu_state))
InitFail(1, "Memory");
if (!ARMul_CoProInit(emu_state))
InitFail(2, "Co-Processor");
ARMul_Reset(emu_state);
/* Excecute */
ARMul_DoProg(emu_state);
emu_state->Reg[15] -= 8; /* undo the pipeline (bogus?) */
/* Close and Finalise */
ARMul_CoProExit(emu_state);
ARMul_MemoryExit(emu_state);
}