1 |
106 |
markom |
/******************************************************************************
|
2 |
|
|
*
|
3 |
|
|
* The process and all routines contained herein are the
|
4 |
|
|
* property and trade secrets of AMD Inc.
|
5 |
|
|
*
|
6 |
|
|
* Except as provided for by licence agreement, this code
|
7 |
|
|
* shall not be duplicated, used or disclosed for any
|
8 |
|
|
* purpose or reason, in whole or part, without the express
|
9 |
|
|
* written consent of AMD.
|
10 |
|
|
*
|
11 |
|
|
* Copyright AMD Inc. 1991
|
12 |
|
|
*
|
13 |
|
|
*********************************************************************** MODULE
|
14 |
|
|
*
|
15 |
|
|
* $NAME @(#)udip2mm.c 1.2 91/06/12
|
16 |
|
|
* AUTHORS Daniel Mann
|
17 |
|
|
*
|
18 |
|
|
* This module implements the UDI-P interface.
|
19 |
|
|
********************************************************************** HISTORY
|
20 |
|
|
*
|
21 |
|
|
*
|
22 |
|
|
**************************************************************** INCLUDE FILES
|
23 |
|
|
*/
|
24 |
|
|
#include <stdio.h>
|
25 |
|
|
#include "udiproc.h"
|
26 |
|
|
#include "dbg_core.h"
|
27 |
|
|
#include "error.h"
|
28 |
|
|
|
29 |
|
|
/* local type decs. and macro defs. not in a .h file ************* MACRO/TYPE
|
30 |
|
|
*/
|
31 |
|
|
#define BUFER_SIZE 2048
|
32 |
|
|
typedef struct msgheader_str
|
33 |
|
|
{
|
34 |
|
|
INT32 class;
|
35 |
|
|
INT32 length;
|
36 |
|
|
UINT32 param[BUFER_SIZE];
|
37 |
|
|
} msgheader_t;
|
38 |
|
|
static msgheader_t msg_rbuf;
|
39 |
|
|
static msgheader_t msg_sbuf;
|
40 |
|
|
|
41 |
|
|
int (*msg_send)();
|
42 |
|
|
int (*msg_recv)();
|
43 |
|
|
|
44 |
|
|
/* local dec/defs. which are not in a .h file *************** LOCAL DEC/DEFS
|
45 |
|
|
*/
|
46 |
|
|
static INT8 SpaceMap_udi2mm[
|
47 |
|
|
/* DRAMSpace IOSpace CPSpace0 CPSpace1 IROMSpace */
|
48 |
|
|
D_MEM, I_O, -1 ,-1 I_ROM,
|
49 |
|
|
/* IRAMSpace LocalRegs GlobalRegs RealRegs SpecialRegs */
|
50 |
|
|
I_MEM, LOCAL_REG, GLOBAL_REG, GLOBAL_REG, SPECIAL_REG,
|
51 |
|
|
/* TLBRegs ACCRegs ICacheSpace Am29027Regs PC */
|
52 |
|
|
TLB_REG, SPECIAL_REG, I_CACHE, COPROC_REG, SPECIAL_REG
|
53 |
|
|
/* DCacheSpace */
|
54 |
|
|
D_CACHE ];
|
55 |
|
|
|
56 |
|
|
static INT8 SpaceMap_mm2udi[
|
57 |
|
|
/* LOCAL_REG GLOBAL_REG SPECIAL_REG TLB_REG COPROC_REG */
|
58 |
|
|
LocalRegs, GlobalRegs, SpecialRegs, TLBRegs, Am29029Regs,
|
59 |
|
|
/* I_MEM D_MEM I_ROM D_ROM I_O */
|
60 |
|
|
IRAMSpace, DRAMSpace, IROMSpace, -1, IOSpace,
|
61 |
|
|
/* I_CACHE D_CACHE */
|
62 |
|
|
ICacheSpace, DCacheSpace ];
|
63 |
|
|
|
64 |
|
|
UDIPID default_pid; /* requested PID */
|
65 |
|
|
|
66 |
|
|
typedef struct bkpt_entry_str
|
67 |
|
|
{
|
68 |
|
|
UDIResource addr;
|
69 |
|
|
INT32 passcount;
|
70 |
|
|
UDIBreakType type;
|
71 |
|
|
} bkpt_entry_t;
|
72 |
|
|
#define MAX_BKPT 20
|
73 |
|
|
bkpt_entry_t bkpt_table[MAX_BKPT];
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
/****************************************************************** PROCEDURES
|
77 |
|
|
*/
|
78 |
|
|
|
79 |
|
|
/*********************************************************** UDI_GET_ERROR_MSG
|
80 |
|
|
Errors above the value ERRUDI_TIP indicate that the
|
81 |
|
|
TIP was not able to complete the request for some
|
82 |
|
|
target specific reason. The DFE uses
|
83 |
|
|
UDIGetErrorMsg() to get the descriptive text for
|
84 |
|
|
the error message which can then be displayed to
|
85 |
|
|
the user.
|
86 |
|
|
*/
|
87 |
|
|
UDIError UDIGetErrorMsg(error_code, msg)
|
88 |
|
|
UINT32 error_code; /* in */
|
89 |
|
|
UDIHostMemPtr msg; /* out -- text of msg */
|
90 |
|
|
{
|
91 |
|
|
if(error_code <= 0 || error_code > EMBAUD)
|
92 |
|
|
return EMUSAGE;
|
93 |
|
|
bcopy(error_msg[error_code], (char*) msg,
|
94 |
|
|
strlen(error_msg[error_code]);
|
95 |
|
|
return 0;
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
/*************************************************************** UDI_TERMINATE
|
99 |
|
|
UDITerminate() is used to tell the TIP that the
|
100 |
|
|
DFE is finished.
|
101 |
|
|
*/
|
102 |
|
|
UDITerminate()
|
103 |
|
|
{
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
/******************************************************* UDI_GET_TARGET_CONFIG
|
107 |
|
|
UDIGetTargetConfig() gets information about the
|
108 |
|
|
target. I_mem_start/size defines the start address
|
109 |
|
|
and length of instruction RAM memory.
|
110 |
|
|
D_mem_start/size defines the start address and
|
111 |
|
|
length of instruction Data memory.
|
112 |
|
|
IR_mem_start/size defines the start address and
|
113 |
|
|
length of instruction ROM memory. coprocessor de-
|
114 |
|
|
fines the type of coprocessor present in the target
|
115 |
|
|
if any. max_breakpoints defines the maximum number
|
116 |
|
|
of breakpoints which the target can handle.
|
117 |
|
|
max_steps defines the maximum number of stepcount
|
118 |
|
|
that can be used in the UDIStep command.
|
119 |
|
|
*/
|
120 |
|
|
UDIError UDIGetTargetConfig(I_mem_start, I_mem_size, D_mem_start,
|
121 |
|
|
D_mem_size, R_mem_start, R_mem_size, cpu_prl, copro_prl)
|
122 |
|
|
UDIOffset *I_mem_start;/* out */
|
123 |
|
|
UDIOffset *I_mem_size; /* out */
|
124 |
|
|
UDIOffset *D_mem_start;/* out */
|
125 |
|
|
UDIOffset *D_mem_size; /* out */
|
126 |
|
|
UDIOffset *R_mem_start;/* out */
|
127 |
|
|
UDIOffset *R_mem_size; /* out */
|
128 |
|
|
UINT32 *cpu_prl; /* out */
|
129 |
|
|
UINT32 *copro_prl; /* out */
|
130 |
|
|
{
|
131 |
|
|
UDIError errno_mm = 0;
|
132 |
|
|
|
133 |
|
|
msg_sbuf.class = CODE_CONFIG_REQ;
|
134 |
|
|
msg_sbuf.length = 0;
|
135 |
|
|
|
136 |
|
|
(*msg_send)(&msg_sbuf); /* send MiniMON message */
|
137 |
|
|
while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */
|
138 |
|
|
|
139 |
|
|
if(msg_rbuf.class == CONFIG)
|
140 |
|
|
{
|
141 |
|
|
*I_mem_start = msg_rbuf.param[2];
|
142 |
|
|
*I_mem_size = msg_rbuf.param[3];
|
143 |
|
|
*D_mem_start = msg_rbuf.param[4];
|
144 |
|
|
*D_mem_size = msg_rbuf.param[5];
|
145 |
|
|
*R_mem_start = msg_rbuf.param[6];
|
146 |
|
|
*R_mem_size = msg_rbuf.param[7];
|
147 |
|
|
*cpu_prl = msg_rbuf.param[0];
|
148 |
|
|
*copro_prl = msg_rbuf.param[10];
|
149 |
|
|
}
|
150 |
|
|
else
|
151 |
|
|
{
|
152 |
|
|
errno_mm = EMBADMSG;
|
153 |
|
|
if(msg_rbuf.class == ERROR)
|
154 |
|
|
errno_mm = msg_rbuf.param[0];
|
155 |
|
|
}
|
156 |
|
|
return errno_mm;
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
/********************************************************** UDI_CREATE_PRCOESS
|
160 |
|
|
UDICreateProcess() tells the target OS that a
|
161 |
|
|
process is to be created and gets a PID back unless
|
162 |
|
|
there is some error.
|
163 |
|
|
*/
|
164 |
|
|
UDIError UDICreateProcess(pid)
|
165 |
|
|
UDIPID *pid; /* out */
|
166 |
|
|
{
|
167 |
|
|
UDIError errno_mm = 0;
|
168 |
|
|
|
169 |
|
|
*pid = 1; /* OSboot sets user PID=1 */
|
170 |
|
|
return errno_mm;
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
/********************************************************** UDI_SET_DEFALUT_PID
|
174 |
|
|
UDISetDefaultPid uses a pid supplied by
|
175 |
|
|
UDICreateProcess and sets it as the default for all
|
176 |
|
|
udi calls until a new default is set. A user of a
|
177 |
|
|
single-process OS would only have to use this once.
|
178 |
|
|
*/
|
179 |
|
|
UDIError UDISetDefaultPid(pid)
|
180 |
|
|
UDIPID pid; /* in */
|
181 |
|
|
{
|
182 |
|
|
UDIError errno_mm = 0;
|
183 |
|
|
|
184 |
|
|
default_pid = pid;
|
185 |
|
|
return errno_mm;
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
/********************************************************* UDI_DESTROY_PROCESS
|
189 |
|
|
UDIDestroyProcess() frees a process resource pre-
|
190 |
|
|
viously created by UDICreateProcess().
|
191 |
|
|
*/
|
192 |
|
|
UDIError UDIDestroyProcess(pid)
|
193 |
|
|
UDIPID pid; /* in */
|
194 |
|
|
{
|
195 |
|
|
UDIError errno_mm = 0;
|
196 |
|
|
|
197 |
|
|
return errno_mm;
|
198 |
|
|
}
|
199 |
|
|
|
200 |
|
|
/****************************************************** UDI_INITIALIZE_PROCESS
|
201 |
|
|
UDIInitializeProcess() is called after the code
|
202 |
|
|
for a process has been loaded. The pid used is the
|
203 |
|
|
one set by UDISetDfaultPid. The parameter
|
204 |
|
|
text_addr defines the lowest and highest text ad-
|
205 |
|
|
dresses used by the process. The parameter
|
206 |
|
|
data_addr defines the lowest and highest data ad-
|
207 |
|
|
dresses used by the process. The paramter
|
208 |
|
|
entry_point defines the entry point of the process.
|
209 |
|
|
The parameters mem_stack_size and reg_stack size
|
210 |
|
|
define the sizes of the memory and register stacks
|
211 |
|
|
required by the process. The special value
|
212 |
|
|
UDI_DEFAULT implies that the default stack sizes
|
213 |
|
|
for the target OS should be used. The parameter
|
214 |
|
|
argstring defines a character string that will get
|
215 |
|
|
parsed into the argv array for the process. The
|
216 |
|
|
target OS will use the supplied information to set
|
217 |
|
|
up the heaps and stacks and the program arguments
|
218 |
|
|
if any. On return; the PC will be set to the entry
|
219 |
|
|
point of the process.
|
220 |
|
|
*/
|
221 |
|
|
UDIError UDIInitializeProcess( text_addr, data_addr, entry_point,
|
222 |
|
|
mem_stack_size, reg_stack_size, argstring)
|
223 |
|
|
UDIRange text_addr; /* in--lowest and highest text addrs */
|
224 |
|
|
UDIRange data_addr; /* in--lowest and highest data addrs */
|
225 |
|
|
UDIResource entry_point; /* in--process entry point */
|
226 |
|
|
CPUSizeT mem_stack_size; /* in--memory stack size */
|
227 |
|
|
CPUSizeT reg_stack_size; /* in--register stack size */
|
228 |
|
|
char* argstring; /* in--argument string used to */
|
229 |
|
|
{
|
230 |
|
|
UDIError errno_mm = 0;
|
231 |
|
|
|
232 |
|
|
msg_sbuf.class = CODE_INIT;
|
233 |
|
|
msg_sbuf.length = 8*4;
|
234 |
|
|
|
235 |
|
|
msg_sbuf.param[0] = text_addr.low;
|
236 |
|
|
msg_sbuf.param[1] = text_addr.high;
|
237 |
|
|
msg_sbuf.param[2] = data_start.low;
|
238 |
|
|
msg_sbuf.param[3] = data_end.hich;
|
239 |
|
|
msg_sbuf.param[4] = entry_point.Offset;
|
240 |
|
|
msg_sbuf.param[5] = mem_stack_size;
|
241 |
|
|
msg_sbuf.param[6] = reg_stack_size;
|
242 |
|
|
msg_sbuf.param[7] = argstring;
|
243 |
|
|
|
244 |
|
|
(*msg_send)(&msg_sbuf); /* send MiniMON message */
|
245 |
|
|
while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */
|
246 |
|
|
|
247 |
|
|
if(msg_rbuf.class == ERROR)
|
248 |
|
|
errno_mm = msg_rbuf.param[0];
|
249 |
|
|
else if(msg_rbuf.class != INIT_ACK)
|
250 |
|
|
errno_mm = EMINIT;
|
251 |
|
|
return errno_mm;
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
/****************************************************************** UDI_READ
|
255 |
|
|
UDIRead() reads a block of objects from a target
|
256 |
|
|
address+space to host space. The parameter struc-
|
257 |
|
|
ture "from" specifies the address space and offset
|
258 |
|
|
of the source. The parameter "to" specifies the
|
259 |
|
|
destination address in the DFE on the host. The
|
260 |
|
|
parameter count specifies the number of objects to
|
261 |
|
|
be transferred and "size" specifies the size of
|
262 |
|
|
each object.
|
263 |
|
|
The size parameter is used by the TIP to
|
264 |
|
|
perform byte-swapping if the target is not the same
|
265 |
|
|
endian as the host. On completion; the output
|
266 |
|
|
parameter count_done is set to the number of ob-
|
267 |
|
|
jects successfully transferred.
|
268 |
|
|
*/
|
269 |
|
|
|
270 |
|
|
UDIError UDIRead (from, to, count, size, count_done, host_endian)
|
271 |
|
|
UDIResource from; /* in - source address on target */
|
272 |
|
|
UDIVoidPtr to; /* out - destination address on host */
|
273 |
|
|
UDICount count; /* in -- count of objects to be transferred */
|
274 |
|
|
UDISize size; /* in -- size of each object */
|
275 |
|
|
UDICount *count_done; /* out - count actually transferred */
|
276 |
|
|
UDIBool host_endian; /* in -- flag for endian information */
|
277 |
|
|
{
|
278 |
|
|
UDIError errno_mm = 0;
|
279 |
|
|
|
280 |
|
|
msg_sbuf.class = CODE_READ_REQ;
|
281 |
|
|
msg_sbuf.length = 3*4;
|
282 |
|
|
|
283 |
|
|
msg_sbuf.param[0] = MapSpace_udi2mm[from.Space]; /* space */
|
284 |
|
|
msg_sbuf.param[1] = from.Offset; /* address */
|
285 |
|
|
msg_sbuf.param[2] = size*count /* byte_count */
|
286 |
|
|
|
287 |
|
|
(*msg_send)(&msg_sbuf); /* send MiniMON message */
|
288 |
|
|
while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */
|
289 |
|
|
|
290 |
|
|
if(msg_rbuf.class == READ_ACK)
|
291 |
|
|
{ *count_done = msg_rbuf.param[2]/size;
|
292 |
|
|
bcopy((char*)&(msg_sbuf.param[3])), (char*)to, size*count);
|
293 |
|
|
}
|
294 |
|
|
else
|
295 |
|
|
{
|
296 |
|
|
errno_mm = EMREAD;
|
297 |
|
|
*count_done = 0;
|
298 |
|
|
if(msg_rbuf.class == ERROR)
|
299 |
|
|
errno_mm = msg_rbuf.param[0];
|
300 |
|
|
}
|
301 |
|
|
return errno_mm;
|
302 |
|
|
}
|
303 |
|
|
|
304 |
|
|
/****************************************************************** UDI_WRITE
|
305 |
|
|
UDIWrite() writes a block of objects from host
|
306 |
|
|
space to a target address+space The parameter
|
307 |
|
|
"from" specifies the source address in the DFE on
|
308 |
|
|
the host. The parameter structure "to" specifies
|
309 |
|
|
the address space and offset of the destination on
|
310 |
|
|
the target. The parameter count specifies the
|
311 |
|
|
number of objects to be transferred and "size"
|
312 |
|
|
specifies the size of each object. The size parameter
|
313 |
|
|
is used by the TIP to perform byte-swapping if
|
314 |
|
|
the target is not the same endian as the host. On
|
315 |
|
|
completion; the output parameter count_done is set
|
316 |
|
|
to the number of objects successfully transferred.
|
317 |
|
|
*/
|
318 |
|
|
UDIError UDIWrite( from, to, count, size, count_done, HostEndian )
|
319 |
|
|
UDIVoidPtr from; /* in -- destination address on host */
|
320 |
|
|
UDIResource to; /* in -- source address on target */
|
321 |
|
|
UDICount count; /* in -- count of objects to be transferred */
|
322 |
|
|
UDISize size; /* in -- size of each object */
|
323 |
|
|
UDICount *count_done; /* out - count actually transferred */
|
324 |
|
|
UDIBool HostEndian; /* in -- flag for endian information */
|
325 |
|
|
{
|
326 |
|
|
UDIError errno_mm = 0;
|
327 |
|
|
|
328 |
|
|
msg_sbuf.class = CODE_WRITE_REQ;
|
329 |
|
|
msg_sbuf.length = 3*4 + size*count;
|
330 |
|
|
|
331 |
|
|
msg_sbuf.param[0] = MapSpace_udi2mm[to.Space]; /* space */
|
332 |
|
|
msg_sbuf.param[1] = to.Offset; /* address */
|
333 |
|
|
msg_sbuf.param[2] = size*count /* byte_count */
|
334 |
|
|
bcopy((char*)from, (char*)msg_sbuf.param[3]), size*count);
|
335 |
|
|
|
336 |
|
|
(*msg_send)(&msg_sbuf); /* send MiniMON message */
|
337 |
|
|
while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */
|
338 |
|
|
|
339 |
|
|
if(msg_rbuf.class == WRITE_ACK)
|
340 |
|
|
*count_done = msg_rbuf.param[2]/size;
|
341 |
|
|
else
|
342 |
|
|
{
|
343 |
|
|
errno_mm = EMWRITE;
|
344 |
|
|
*count_done = 0;
|
345 |
|
|
if(msg_rbuf.class == ERROR)
|
346 |
|
|
errno_mm = msg_rbuf.param[0];
|
347 |
|
|
}
|
348 |
|
|
return errno_mm;
|
349 |
|
|
}
|
350 |
|
|
|
351 |
|
|
/******************************************************************** UDI_COPY
|
352 |
|
|
UDICopy() copies a block of objects from one tar-
|
353 |
|
|
get address/space to another target address/space.
|
354 |
|
|
If the source and destination overlap; the copy is
|
355 |
|
|
implemented as if a temporary buffer was used. The
|
356 |
|
|
parameter structure "from" specifies the address
|
357 |
|
|
space and offset of the destination on the target.
|
358 |
|
|
The parameter structure "to" specifies the address
|
359 |
|
|
space and offset of the destination on the target.
|
360 |
|
|
The parameter count specifies the number of objects
|
361 |
|
|
to be transferred and "size" specifies the size of
|
362 |
|
|
each object. On completion; the output parameter
|
363 |
|
|
count_done is set to the number of objects success-
|
364 |
|
|
fully transferred.
|
365 |
|
|
*/
|
366 |
|
|
UDIError UDICopy(from, to, count, size, count_done, direction )
|
367 |
|
|
UDIResource from; /* in -- destination address on target */
|
368 |
|
|
UDIResource to; /* in -- source address on target */
|
369 |
|
|
UDICount count; /* in -- count of objects to be transferred */
|
370 |
|
|
UDISize size; /* in -- size of each object */
|
371 |
|
|
UDICount *count_done; /* out - count actually transferred */
|
372 |
|
|
UDIBool direction; /* in -- high-to-low or reverse */
|
373 |
|
|
{
|
374 |
|
|
UDIError errno_mm = 0;
|
375 |
|
|
|
376 |
|
|
msg_sbuf.class = CODE_COPY;
|
377 |
|
|
msg_sbuf.length = 5*4
|
378 |
|
|
|
379 |
|
|
msg_sbuf.param[0] = MapSpace_udi2mm[from.Space]; /* source space */
|
380 |
|
|
msg_sbuf.param[1] = source.Offset; /* address */
|
381 |
|
|
msg_sbuf.param[2] = MapSpace_udi2mm[to.Space]; /* dest space */
|
382 |
|
|
msg_sbuf.param[3] = to.Offset; /* address */
|
383 |
|
|
msg_sbuf.param[4] = size*count /* byte_count */
|
384 |
|
|
|
385 |
|
|
(*msg_send)(&msg_sbuf); /* send MiniMON message */
|
386 |
|
|
while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */
|
387 |
|
|
|
388 |
|
|
if(msg_rbuf.class == COPY_ACK))
|
389 |
|
|
*count_done = msg_rbuf.param[4]/size;
|
390 |
|
|
else
|
391 |
|
|
{
|
392 |
|
|
errno_mm = EMCOPY;
|
393 |
|
|
*count_done = 0;
|
394 |
|
|
if(msg_rbuf.class == ERROR)
|
395 |
|
|
errno_mm = msg_rbuf.param[0];
|
396 |
|
|
}
|
397 |
|
|
return errno_mm;
|
398 |
|
|
}
|
399 |
|
|
|
400 |
|
|
/***************************************************************** UDI_EXECUTE
|
401 |
|
|
UDIExecute() continues execution of the default
|
402 |
|
|
process from the current PC.
|
403 |
|
|
*/
|
404 |
|
|
UDIError UDIExecute()
|
405 |
|
|
{
|
406 |
|
|
UDIError errno_mm = 0;
|
407 |
|
|
|
408 |
|
|
msg_sbuf.class = CODE_GO;
|
409 |
|
|
msg_sbuf.length = 0;
|
410 |
|
|
|
411 |
|
|
(*msg_send)(&msg_sbuf); /* send MiniMON message */
|
412 |
|
|
return errno_mm;
|
413 |
|
|
}
|
414 |
|
|
|
415 |
|
|
/******************************************************************** UDI_STEP
|
416 |
|
|
UDIStep() specifies a number of "instruction"
|
417 |
|
|
steps to make. The step can be further qualified
|
418 |
|
|
to state whether CALLs should or should not be
|
419 |
|
|
stepped over; whether TRAPs should or should not be
|
420 |
|
|
stepped over; and whether stepping should halt when
|
421 |
|
|
the PC gets outside a certain range. The semantics
|
422 |
|
|
of UDIStep imply that progress is made; ie; at
|
423 |
|
|
least one instruction is executed before traps or
|
424 |
|
|
interrupts are handled.
|
425 |
|
|
*/
|
426 |
|
|
UDIError UDIStep(steps, steptype, range)
|
427 |
|
|
UINT32 steps; /* in -- number of steps */
|
428 |
|
|
UDIStepType steptype; /* in -- type of stepping to be done */
|
429 |
|
|
UDIRange range; /* in -- range if StepInRange is TRUE */
|
430 |
|
|
{
|
431 |
|
|
UDIError errno_mm = 0;
|
432 |
|
|
|
433 |
|
|
msg_sbuf.class = CODE_STEP;
|
434 |
|
|
msg_sbuf.length = 1*4;
|
435 |
|
|
|
436 |
|
|
msg_sbuf.param[0] = steps; /* number of steps */
|
437 |
|
|
|
438 |
|
|
(*msg_send)(&msg_sbuf); /* send MiniMON message */
|
439 |
|
|
|
440 |
|
|
while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */
|
441 |
|
|
|
442 |
|
|
return errno_mm;
|
443 |
|
|
}
|
444 |
|
|
|
445 |
|
|
/******************************************************************** UDI_STOP
|
446 |
|
|
UDIStop() stops the default process
|
447 |
|
|
*/
|
448 |
|
|
UDIError UDIStop(stop_pc)
|
449 |
|
|
UDIResource *stop_pc; /* out -- value of PC where we stopped */
|
450 |
|
|
{
|
451 |
|
|
UDIError errno_mm = 0;
|
452 |
|
|
|
453 |
|
|
msg_sbuf.class = CODE_BREAK;
|
454 |
|
|
msg_sbuf.length = 0;
|
455 |
|
|
|
456 |
|
|
(*msg_send)(&msg_sbuf); /* send MiniMON message */
|
457 |
|
|
while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */
|
458 |
|
|
|
459 |
|
|
if(msg_rbuf.class == HALT)
|
460 |
|
|
stop_pc->Offset = msg_rbuf.param[2]; /* PC1 address */
|
461 |
|
|
stop_pc->Space =
|
462 |
|
|
MapSpace_mm2udi[msg_rbuf.param[0]]; /* address space */
|
463 |
|
|
else
|
464 |
|
|
{
|
465 |
|
|
errno_mm = EMBADMSG;
|
466 |
|
|
if(msg_rbuf.class == ERROR)
|
467 |
|
|
errno_mm = msg_rbuf.param[0];
|
468 |
|
|
}
|
469 |
|
|
return errno_mm;
|
470 |
|
|
}
|
471 |
|
|
|
472 |
|
|
|
473 |
|
|
/******************************************************************* SIG_TIMER
|
474 |
|
|
*/
|
475 |
|
|
void sig_timer()
|
476 |
|
|
{
|
477 |
|
|
}
|
478 |
|
|
|
479 |
|
|
/******************************************************************** UDI_WAIT
|
480 |
|
|
UDIWait() returns the state of the target proces-
|
481 |
|
|
sor. The TIP is expected to return when the target
|
482 |
|
|
state is no longer RUNNING or when maxtime mil-
|
483 |
|
|
liseconds have elapsed; whichever comes first. The
|
484 |
|
|
special maxtime value UDI_WAIT_FOREVER essentially
|
485 |
|
|
means that the DFE blocks until the target is no
|
486 |
|
|
longer RUNNING. On completion; pid is used to re-
|
487 |
|
|
port which process stopped (necessary for multi-
|
488 |
|
|
process targets). On completion; stop_pc is usual-
|
489 |
|
|
ly set to the PC where execution stopped.
|
490 |
|
|
|
491 |
|
|
The return status STDIN_NEEDED allows the TIP to
|
492 |
|
|
tell the DFE that the target program is requesting
|
493 |
|
|
input and the TIP's own internal buffer of
|
494 |
|
|
charcters is empty. The DFE can inform the user of
|
495 |
|
|
this situation if it desires.
|
496 |
|
|
|
497 |
|
|
Possible states are:
|
498 |
|
|
NOT_EXECUTING
|
499 |
|
|
RUNNING
|
500 |
|
|
STOPPED (due to UDIStop)
|
501 |
|
|
BREAK (breakpoint hit)
|
502 |
|
|
STEPPED (completed number of steps requested by UDIStep)
|
503 |
|
|
WAITING (wait mode bit set)
|
504 |
|
|
HALTED (at a halt instruction)
|
505 |
|
|
WARNED (not executing because WARN line asserted)
|
506 |
|
|
TRAPPED (invalid trap taken; indicates trap number)
|
507 |
|
|
STDOUT_READY (stopped waiting for stdout to be output)
|
508 |
|
|
STDERR_READY (stopped waiting for stderr to be output)
|
509 |
|
|
STDIN_NEEDED (stopped waiting for stdin to be supplied)
|
510 |
|
|
*/
|
511 |
|
|
UDIError UDIWait(maxtime, pid, stop_reason)
|
512 |
|
|
INT32 maxtime; /* in -- maximum time to wait for completion */
|
513 |
|
|
UDIPID *pid; /* out -- pid of process which stopped if any */
|
514 |
|
|
UINT32 *stop_reason; /* out -- PC where process stopped */
|
515 |
|
|
{
|
516 |
|
|
UDIError errno_mm = 0;
|
517 |
|
|
|
518 |
|
|
if(signal(SIGALRM, sig_timer)) == -1) errno_mm =
|
519 |
|
|
|
520 |
|
|
|
521 |
|
|
return errno_mm;
|
522 |
|
|
}
|
523 |
|
|
|
524 |
|
|
/********************************************************** UDI_SET_BREAKPOINT
|
525 |
|
|
UDISetBreakpoint() sets a breakpoint at an ad-
|
526 |
|
|
dress and uses the passcount to state how many
|
527 |
|
|
times that instruction should be hit before the
|
528 |
|
|
break occurs. The passcount continues to count
|
529 |
|
|
down; even if a different breakpoint is hit and is
|
530 |
|
|
reinitialized only when this breakpoint is hit. A
|
531 |
|
|
passcount value of 0 indicates a Temporary break-
|
532 |
|
|
point that will be removed whenever execution
|
533 |
|
|
stops. A negative passcount indicates a non-sticky
|
534 |
|
|
breakpoint.
|
535 |
|
|
*/
|
536 |
|
|
UDIError UDISetBreakpoint (addr, passcount, type, break_id)
|
537 |
|
|
UDIResource addr; /* in -- where breakpoint gets set */
|
538 |
|
|
INT32 passcount; /* in -- passcount for breakpoint */
|
539 |
|
|
UDIBreakType type; /* in -- breakpoint type */
|
540 |
|
|
INT32 *break_id; /* out-- break number assigned */
|
541 |
|
|
{
|
542 |
|
|
UDIError errno_mm = 0;
|
543 |
|
|
bkpt_entry_t *bkpt_p = &bkpt_table[break_id];
|
544 |
|
|
int cnt = 0;
|
545 |
|
|
|
546 |
|
|
if(type != UDIBreakFlagExecute)
|
547 |
|
|
{ errno_mm = EMBKPTSET;
|
548 |
|
|
return errno_mm;
|
549 |
|
|
}
|
550 |
|
|
while( cnt < MAX_BKPT) /* find BKPT slot in table */
|
551 |
|
|
if( !(bkpt_p->type) ) break;
|
552 |
|
|
else cnt++;
|
553 |
|
|
if(cnt >= MAX_BKPT)
|
554 |
|
|
{ errno_mm = EMBKPTNONE;
|
555 |
|
|
return errno_mm;
|
556 |
|
|
}
|
557 |
|
|
bkpt_p->address.Offset = addr.Offset;
|
558 |
|
|
bkpt_p->address.Space = addr.Space;
|
559 |
|
|
bkpt_p->passcount = passcount;
|
560 |
|
|
bkpt_p->type = type;
|
561 |
|
|
*break_id = cnt;
|
562 |
|
|
|
563 |
|
|
msg_sbuf.class = CODE_SET_BKPT;
|
564 |
|
|
msg_sbuf.length = 4*4;
|
565 |
|
|
|
566 |
|
|
msg_sbuf.param[0] = MapSpace_udi2mm[addr.Space];
|
567 |
|
|
msg_sbuf.param[1] = addr.Offset;
|
568 |
|
|
msg_sbuf.param[2] = passcount;
|
569 |
|
|
msg_sbuf.param[3] = -1; /* non 050 breakpoint */
|
570 |
|
|
|
571 |
|
|
(*msg_send)(&msg_sbuf); /* send MiniMON message */
|
572 |
|
|
while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */
|
573 |
|
|
|
574 |
|
|
if(msg_rbuf.class == ERROR)
|
575 |
|
|
errno_mm = msg_rbuf.param[0];
|
576 |
|
|
else if(msg_rbuf.class != CODE_SET_BKPT_ACK)
|
577 |
|
|
errno_mm = EMBKPTSET;
|
578 |
|
|
return error_mm;
|
579 |
|
|
}
|
580 |
|
|
|
581 |
|
|
/******************************************************** UDI_QUERY_BREAKPOINT
|
582 |
|
|
*/
|
583 |
|
|
UDIError UDIQueryBreakpoint (break_id, addr, passcount, type, current_count)
|
584 |
|
|
INT32 break_id; /* in -- select brekpoint */
|
585 |
|
|
UDIResource *addr; /* out - where breakpoint gets set */
|
586 |
|
|
INT32 *passcount; /* out - passcount for breakpoint */
|
587 |
|
|
UDIBreakType *type; /* out - breakpoint type */
|
588 |
|
|
INT32 *current_count; /* out - current passcount for breakpoint */
|
589 |
|
|
{
|
590 |
|
|
UDIError errno_mm = 0;
|
591 |
|
|
|
592 |
|
|
msg_sbuf.class = CODE_BKPT_STAT;
|
593 |
|
|
msg_sbuf.length = 2*4;
|
594 |
|
|
|
595 |
|
|
msg_sbuf.param[0] = MapSpace_udi2mm[addr.Space];
|
596 |
|
|
msg_sbuf.param[1] = addr.Offset;
|
597 |
|
|
|
598 |
|
|
(*msg_send)(&msg_sbuf); /* send MiniMON message */
|
599 |
|
|
while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */
|
600 |
|
|
|
601 |
|
|
if(msg_rbuf.class == CODE_BKPT_STAT_ACK)
|
602 |
|
|
{
|
603 |
|
|
addr->Offset = bkpt_table[break_id].addr.Offset;
|
604 |
|
|
addr->Space = bkpt_table[break_id].addr.Space;
|
605 |
|
|
*passcount = bkpt_table[break_id].passcount;
|
606 |
|
|
*type = bkpt_table[break_id].type;
|
607 |
|
|
*current_count = msg_rbuf.param[2];
|
608 |
|
|
}
|
609 |
|
|
else if(msg_rbuf.class == ERROR)
|
610 |
|
|
errno_mm = msg_rbuf.param[0];
|
611 |
|
|
else errno_mm = EMBKPTSTAT;
|
612 |
|
|
return errno_mm;
|
613 |
|
|
}
|
614 |
|
|
|
615 |
|
|
/******************************************************** UDI_CLEAR_BREAKPOINT
|
616 |
|
|
UDIClearBreakpoint() is used to clear a break-
|
617 |
|
|
point.
|
618 |
|
|
*/
|
619 |
|
|
UDIError UDIClearBreakpoint (break_id)
|
620 |
|
|
INT32 break_id; /* in -- select brekpoint */
|
621 |
|
|
{
|
622 |
|
|
UDIError errno_mm = 0;
|
623 |
|
|
bkpt_entry_t *bkpt_p = &bkpt_table[break_id];
|
624 |
|
|
|
625 |
|
|
msg_sbuf.class = CODE_RM_BKPT;
|
626 |
|
|
msg_sbuf.length = 2*4;
|
627 |
|
|
|
628 |
|
|
msg_sbuf.param[0] = MapSpace_udi2mm[bkpt_p->Space];
|
629 |
|
|
msg_sbuf.param[1] = bkpt->Offset;
|
630 |
|
|
|
631 |
|
|
(*msg_send)(&msg_sbuf); /* send MiniMON message */
|
632 |
|
|
while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */
|
633 |
|
|
|
634 |
|
|
if(msg_rbuf.class == CODE_RM_BKPT_ACK)
|
635 |
|
|
{
|
636 |
|
|
bkpt->Space = 0; /* invalidate BKPT entry */
|
637 |
|
|
}
|
638 |
|
|
else if(msg_rbuf.class == ERROR)
|
639 |
|
|
errno_mm = msg_rbuf.param[0];
|
640 |
|
|
else errno_mm = EMBKPTRM;
|
641 |
|
|
return errno_mm;
|
642 |
|
|
}
|
643 |
|
|
|
644 |
|
|
/************************************************************** UDI_GET_STDOUT
|
645 |
|
|
UDIGetStdout() is called when a call to
|
646 |
|
|
UDIWait() returns with the status STDOUT_READY.
|
647 |
|
|
The parameter "buf" specifies the DFE's buffer ad-
|
648 |
|
|
dress which is expected to be filled by the TIP.
|
649 |
|
|
The parameter "bufsize" specifies the size of this
|
650 |
|
|
buffer. On return; count_done is set to the number
|
651 |
|
|
of bytes actually written to buf. The DFE should
|
652 |
|
|
keep calling UDIGetStdout() until count_done is
|
653 |
|
|
less than bufsize.
|
654 |
|
|
*/
|
655 |
|
|
UDIError UDIGetStdout(buf, bufsize, count_done)
|
656 |
|
|
UDIHostMemPtr buf; /* out -- buffer to be filled */
|
657 |
|
|
CPUSizeT bufsize; /* in -- buffer size in bytes */
|
658 |
|
|
CPUSizeT *count_done; /* out -- number of bytes written to buf */
|
659 |
|
|
{
|
660 |
|
|
UDIError errno_mm = EMBADMSG;
|
661 |
|
|
|
662 |
|
|
return errno_mm;
|
663 |
|
|
}
|
664 |
|
|
|
665 |
|
|
/************************************************************** UDI_GET_STDERR
|
666 |
|
|
UDIGetStderr() is called when a call to
|
667 |
|
|
UDIWait() returns with the status STDERR_READY.
|
668 |
|
|
In other respects it is similar to
|
669 |
|
|
UDIGetStdout().
|
670 |
|
|
*/
|
671 |
|
|
UDIError UDIGetStderr(buf, bufsize, count)
|
672 |
|
|
UDIHostMemPtr buf; /* out -- buffer to be filled */
|
673 |
|
|
UINT32 bufsize; /* in -- buffer size in bytes */
|
674 |
|
|
INT32 *count; /* out -- number of bytes written to buf */
|
675 |
|
|
{
|
676 |
|
|
UDIError errno_mm = EMBADMSG;
|
677 |
|
|
|
678 |
|
|
return errno_mm;
|
679 |
|
|
}
|
680 |
|
|
|
681 |
|
|
/*************************************************************** UDI_PUT_STDIN
|
682 |
|
|
UDIPutStdin() is called whenever the DFE wants to
|
683 |
|
|
deliver an input character to the TIP. This may be
|
684 |
|
|
in response to a status STDIN_NEEDED but need not
|
685 |
|
|
be. (Some target operating systems will never
|
686 |
|
|
block for input). Any buffering and line editing
|
687 |
|
|
of the stdin characters is done under control of
|
688 |
|
|
the TIP.
|
689 |
|
|
*/
|
690 |
|
|
INT32 UDIPutStdin (buf, bufsize, count)
|
691 |
|
|
UDIHostMemPtr buf; /* out - buffer to be filled */
|
692 |
|
|
UINT32 bufsize; /* in -- buffer size in bytes */
|
693 |
|
|
INT32 *count; /* out - number of bytes written to buf */
|
694 |
|
|
{
|
695 |
|
|
UDIError errno_mm = EMBADMSG;
|
696 |
|
|
|
697 |
|
|
return errno_mm;
|
698 |
|
|
}
|
699 |
|
|
|
700 |
|
|
/*************************************************************** UDI_PUT_TRANS
|
701 |
|
|
UDIPutTrans() is used to feed input to the pass-
|
702 |
|
|
thru mode. The parameter "buf" is points to the
|
703 |
|
|
input data in DFE memory. The parameter "count"
|
704 |
|
|
specifies the number of bytes.
|
705 |
|
|
*/
|
706 |
|
|
INT32 UDIPutTrans (buf, count)
|
707 |
|
|
UDIHostMemPtr buf; /* in -- buffer address containing input data */
|
708 |
|
|
CPUSizeT count; /* in -- number of bytes in buf */
|
709 |
|
|
{
|
710 |
|
|
UDIError errno_mm = EMBADMSG;
|
711 |
|
|
|
712 |
|
|
return errno_mm;
|
713 |
|
|
}
|
714 |
|
|
|
715 |
|
|
/*************************************************************** UDI_GET_TRANS
|
716 |
|
|
UDIGetTrans() is used to get output lines from the
|
717 |
|
|
pass-thru mode The parameter "buf" specifies to the
|
718 |
|
|
buffer to be filled in DFE space. "bufsize" speci-
|
719 |
|
|
fies the size of the buffer and; on return, "count"
|
720 |
|
|
is set to the number of bytes put in the buffer.
|
721 |
|
|
The DFE should continue to call UDIGetTrans() un-
|
722 |
|
|
til count is less than bufsize. Other possible re-
|
723 |
|
|
turn values are:
|
724 |
|
|
EOF -- leave transparent mode
|
725 |
|
|
UDI_GET_INPUT -- host should get some in-
|
726 |
|
|
put; then call
|
727 |
|
|
UDIPutTrans().
|
728 |
|
|
*/
|
729 |
|
|
INT32 UDIGetTrans (buf, bufsize, count)
|
730 |
|
|
UDIHostMemPtr buf; /* out -- buffer to be filled */
|
731 |
|
|
CPUSizeT bufsize; /* in -- size of buf */
|
732 |
|
|
CPUSizeT *count; /* out -- number of bytes in buf */
|
733 |
|
|
{
|
734 |
|
|
UDIError errno_mm = EMBADMSG;
|
735 |
|
|
|
736 |
|
|
return errno_mm;
|
737 |
|
|
}
|