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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
/* -*- mode: C++; tab-width: 4 -*- */
/* ===================================================================== *\
Copyright (c) 2001 Palm, Inc. or its subsidiaries.
All rights reserved.
This file is part of the Palm OS Emulator.
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.
\* ===================================================================== */
#include "EmCommon.h"
#include "EmCPUARM.h"
#include "EmSession.h" // ExecuteSpecial
/*
This file interfaces between the Palm OS Emulator and the embedded
instance of the ARMulator.
This version of the ARMulator comes from gdb 5.0, which in turn was
derived from the ARM6 ARMulator from ARM, Inc. ARM apparently no
longer makes public source-code to their version of ARMulator
available, so the version here is probably just a distant cousin
of that version.
The ARMulator here comes with the following files:
* armcopro.c
ARM coprocessor emulation
* armemu.c
Main ARM processor emulation. It can be compiled for either
26-bit or 32-bit modes.
* arminit.c
Contains routines to perform one-time initialization of
ARMulator, create an emulator instance, select a processor,
reset a processor, run one or more instructions, or trigger
an abort.
* armos.c
(Something to do with knowledge of an ARM-based OS)
* armrdi.c
Implements the ARM RDI (Remote Debugger Interface). All
functions are exported via an RDI 1.0 RDIProcVec table
(armul_rdi).
* armsupp.c
Support routines for common actions like determining addressing
modes, reading and writing bytes, reading and writing registers, etc.
* armvirt.c
A simple memory emulator that maps in RAM pages on demand.
* bag.c
A simple dictionary data structure. Used by kid.c to manage
breakpoints. (!!!Why are they managed there and not in armrdi?)
* communicate.c
Utility routines to read and write bytes, words, and strings
over a socket.
* gdbhost.c
Interface routines between gdb and ARMulator. ARMulator calls
these functions to invoke gdb console facilities.
* kid.c
Infinite loops that listens on a socket for ADP packets. It
reads these and invokes the appropriate RDI functions in armrdi.c.
* main.c
Front-end application that sits between gdb and ARMulator, intercepting
packets and passing them on. (!!! It's not clear to me why this
intermediary -- implemented in parent.c -- is required.)
* parent.c
Implements the loop that listens for packets from either gdb
or ARMulator and forwards them on to the other.
* thumbemu.c
Emulator of the Thumb sub-cell. Translates Thumb opcodes into
ARM opcodes, and then invokes the ARM opcode emulator.
* wrapper.c
ARMulator wrapper that allows it to be incorporated into the gdb
Simulator system. This includes implementing functions that
respond to the gdb set of remote debugger commands.
When incorporated into the gdb Simulator system, only the files armcopro.c,
armemu.c, arminit.c, armos.c, armsupp.c, armvirt.c, bag.c thumbemu.c, and
wrapper.c seem to be used. (!!! Why bag.c, when it's only used by kid.c?)
*/
#if 0
extern "C"
{
#include "armdefs.h"
#include "armemu.h"
#include "arm/dbg_rdi.h" // RDIProcVec
#include "arm/dbg_hif.h" // Dbg_HostosInterface (struct)
#include "arm/dbg_conf.h" // Dbg_ConfigBlock, Dbg_HostosInterface (typdef)
}
extern "C"
{
int stop_simulator; // Referenced in ARMul_Emulate32 loop
int mumkid[2] = {1, 2}; // Referenced in kid.c
int kidmum[2] = {3, 4}; // Referenced in kid.c, armrdi.c
/* RDI interface */
extern const struct RDIProcVec armul_rdi;
void ARMul_CheckAfterCycle (void);
void ARMul_SetSession (void* session);
void EmCPUARM_CheckAfterCycle (void* session)
{
((EmSession*) session)->ExecuteSpecial (false);
}
/***************************************************************************\
* Time for the Operating System to initialise itself. *
\***************************************************************************/
// Referenced in RDI_open in armrdi.c
unsigned
ARMul_OSInit (ARMul_State * state)
{
return (TRUE);
}
// Referenced in RDI_close in armrdi.c
void
ARMul_OSExit (ARMul_State * state)
{
}
/***************************************************************************\
* Return the last Operating System Error. *
\***************************************************************************/
// Referenced in RDI_info in armrdi.c
ARMword ARMul_OSLastErrorP (ARMul_State * state)
{
return 0;
}
/***************************************************************************\
* The emulator calls this routine when a SWI instruction is encuntered. The *
* parameter passed is the SWI number (lower 24 bits of the instruction). *
\***************************************************************************/
// Referenced in "case 0x7f" of ARMul_Emulate32 in armemu.c
// Referenced in "case 0xf0..0xff" of ARMul_Emulate32 in armemu.c
unsigned
ARMul_OSHandleSWI (ARMul_State * state, ARMword number)
{
return (FALSE);
}
/***************************************************************************\
* The emulator calls this routine when an Exception occurs. The second *
* parameter is the address of the relevant exception vector. Returning *
* FALSE from this routine causes the trap to be taken, TRUE causes it to *
* be ignored (so set state->Emulate to FALSE!). *
\***************************************************************************/
// Referenced in ARMul_Abort in arminit.c
unsigned
ARMul_OSException (ARMul_State * state, ARMword vector, ARMword pc)
{
return (FALSE);
}
}
#endif
#pragma mark -
EmCPUARM* gCPUARM;
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::EmCPUARM
// ---------------------------------------------------------------------------
EmCPUARM::EmCPUARM (EmSession* session) :
EmCPU (session)
{
this->DoReset (true);
EmAssert (gCPUARM == NULL);
gCPUARM = this;
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::~EmCPUARM
// ---------------------------------------------------------------------------
EmCPUARM::~EmCPUARM (void)
{
#if 0
/* int i = */ armul_rdi.close ();
#endif
EmAssert (gCPUARM == this);
gCPUARM = NULL;
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::Reset
// ---------------------------------------------------------------------------
void EmCPUARM::Reset (Bool hardwareReset)
{
if (hardwareReset)
{
this->DoReset (false);
}
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::Save
// ---------------------------------------------------------------------------
void EmCPUARM::Save (SessionFile&)
{
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::Load
// ---------------------------------------------------------------------------
void EmCPUARM::Load (SessionFile&)
{
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::Execute
// ---------------------------------------------------------------------------
void EmCPUARM::Execute (void)
{
#if 0
PointHandle point;
/* int i = */ armul_rdi.execute (&point);
#endif
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::CheckAfterCycle
// ---------------------------------------------------------------------------
void EmCPUARM::CheckAfterCycle (void)
{
#if 0
ARMul_CheckAfterCycle ();
#endif
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::GetPC
// ---------------------------------------------------------------------------
emuptr EmCPUARM::GetPC (void)
{
return EmMemNULL;
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::GetSP
// ---------------------------------------------------------------------------
emuptr EmCPUARM::GetSP (void)
{
return EmMemNULL;
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::GetRegister
// ---------------------------------------------------------------------------
uint32 EmCPUARM::GetRegister (int /*index*/)
{
return 0;
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::SetPC
// ---------------------------------------------------------------------------
void EmCPUARM::SetPC (emuptr /*newPC*/)
{
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::SetSP
// ---------------------------------------------------------------------------
void EmCPUARM::SetSP (emuptr /*newPC*/)
{
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::SetRegister
// ---------------------------------------------------------------------------
void EmCPUARM::SetRegister (int /*index*/, uint32 /*val*/)
{
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::Stopped
// ---------------------------------------------------------------------------
// Return whether or not the CPU itself is halted. This is seperate from
// whether or not the session (that is, the thread emulating the CPU) is
// halted.
Bool EmCPUARM::Stopped (void)
{
return false;
}
// ---------------------------------------------------------------------------
// ¥ EmCPUARM::DoReset
// ---------------------------------------------------------------------------
void EmCPUARM::DoReset (Bool /*cold*/)
{
#if 0
// Taken from RDP_Start in kid.c
Dbg_ConfigBlock config;
config.processor = 0;
config.memorysize = 1024 * 1024L;
config.bytesex = RDISex_Little;
Dbg_HostosInterface hostif;
hostif.dbgprint = NULL; // myprint; // Called in ARMul_DebugPrint, ARMul_DebugPrint_i, which are called only if RDI_VERBOSE is defined.
hostif.dbgpause = NULL; // mypause; // Called in ARMul_DebugPause, which in turn is not called.
hostif.dbgarg = NULL; // stdout; // Passed to dbgprint and dbgpause.
hostif.writec = NULL; // mywritec;// Not called
hostif.readc = NULL; // myreadc; // Not called
hostif.write = NULL; // mywrite; // Not called
hostif.gets = NULL; // mygets; // Not called
hostif.hostosarg = NULL; // Not referenced
hostif.reset = NULL; // mypause; // Not referenced
hostif.resetarg = NULL; // Not referenced
/* int i = */ armul_rdi.open (cold ? 0 : 1, &config, &hostif, NULL);
ARMul_SetSession (fSession);
#endif
}
|