OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [utils/] [amd-udi/] [mondfe/] [xcmd.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
static char _[] = "@(#)xcmd.c   5.20 93/07/30 16:39:02, Srini, AMD";
2
/******************************************************************************
3
 * Copyright 1991 Advanced Micro Devices, Inc.
4
 *
5
 * This software is the property of Advanced Micro Devices, Inc  (AMD)  which
6
 * specifically  grants the user the right to modify, use and distribute this
7
 * software provided this notice is not removed or altered.  All other rights
8
 * are reserved by AMD.
9
 *
10
 * AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
11
 * SOFTWARE.  IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
12
 * DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
13
 * USE OF THIS SOFTWARE.
14
 *
15
 * So that all may benefit from your experience, please report  any  problems
16
 * or  suggestions about this software to the 29K Technical Support Center at
17
 * 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131  in  the  UK,  or
18
 * 0031-11-1129 in Japan, toll free.  The direct dial number is 512-462-4118.
19
 *
20
 * Advanced Micro Devices, Inc.
21
 * 29K Support Products
22
 * Mail Stop 573
23
 * 5900 E. Ben White Blvd.
24
 * Austin, TX 78741
25
 * 800-292-9263
26
 *****************************************************************************
27
 *      Engineer: Srini Subramanian.
28
 *****************************************************************************
29
 **       This code implements a subset of the MON29K-like "x"
30
 **       commands.
31
 *****************************************************************************
32
 */
33
 
34
 
35
#include <stdio.h>
36
#include <ctype.h>
37
#include <memory.h>
38
#include "main.h"
39
#include "macros.h"
40
#include "miniint.h"
41
#include "memspcs.h"
42
#include "error.h"
43
 
44
 
45
#ifdef MSDOS
46
#include <stdlib.h>
47
#include <string.h>
48
#else
49
#include <string.h>
50
#endif
51
 
52
INT32    xp_cmd PARAMS((char **, int));
53
INT32    xc_cmd PARAMS((char **, int));
54
 
55
int   get_addr_29k PARAMS((char *, struct addr_29k_t *));
56
int   addr_29k_ok PARAMS((struct addr_29k_t *));
57
int   print_addr_29k PARAMS((INT32, ADDR32));
58
int get_word PARAMS((char *buffer, INT32 *data_word));
59
void convert32 PARAMS(( BYTE *byte));
60
 
61
void  dasm_instr PARAMS((ADDR32, struct instr_t *));
62
 
63
/* Variable definitions */
64
struct xp_cmd_t {
65
   INT32  vtb;
66
   INT32  ops;
67
   INT32  cps;
68
   INT32  cfg;
69
   INT32  cha;
70
   INT32  chd;
71
   INT32  chc;
72
   INT32  rbp;
73
   INT32  tmc;
74
   INT32  tmr;
75
   INT32  pc0;
76
   INT32  pc1;
77
   INT32  pc2;
78
   INT32  mmuc;
79
   INT32  lru;
80
};
81
#define XP_CMD_SZ       15 * sizeof (INT32)
82
/* #define      XP_CMD_SZ       sizeof(struct xp_cmd_t) */
83
 
84
/*
85
** The function below is used to implement the MON29K-like
86
** "x" commands.  the function below, x_cmd() is called
87
** in the main command loop parser of the monitor.  The
88
** parameters passed to this function are:
89
**
90
** token - This is an array of pointers to strings.  Each string
91
**         referenced by this array is a "token" of the user's
92
**         input, translated to lower case.
93
**
94
** token_count - This is the number of tokens in "token".
95
**
96
** This function then calls the specific "x" commands,
97
** such as "xp" or "xc".
98
*/
99
 
100
 
101
INT32
102
x_cmd(token, token_count)
103
   char   *token[];
104
   int     token_count;
105
   {
106
   INT32    result;
107
 
108
   if (strcmp(token[0], "xp") == 0)
109
      result = xp_cmd(token, token_count);
110
   else
111
   if (strcmp(token[0], "xc") == 0)
112
      result = xc_cmd(token, token_count);
113
   else
114
      result = EMSYNTAX;
115
 
116
   return (result);
117
   }  /* end xcmd() */
118
 
119
 
120
/*
121
** This command is used to print out formatted information
122
** about protected special registers.  The format is borrowed
123
** from MON29K, and produces a full screen of data, giving
124
** bit fields of the various registers.
125
*/
126
 
127
INT32
128
xp_cmd(token, token_count)
129
   char   *token[];
130
   int     token_count;
131
   {
132
   INT32  byte_count;
133
   int    prl;
134
   INT32  vtb;
135
   INT32  ops;
136
   INT32  cps;
137
   INT32  cfg;
138
   INT32  cha;
139
   INT32  chd;
140
   INT32  chc;
141
   INT32  rbp;
142
   INT32  tmc;
143
   INT32  tmr;
144
   INT32  pc0;
145
   INT32  pc1;
146
   INT32  pc2;
147
   INT32  mmuc;
148
   INT32  lru;
149
 
150
   INT32        retval;
151
   INT32        bytes_ret;
152
   INT32        hostendian;
153
   union  {
154
     struct     xp_cmd_t   xp_cmd;
155
     char       read_buffer[XP_CMD_SZ];
156
   } xp_cmd_val;
157
   char         prtbuf[256];
158
 
159
   if ((strcmp(token[0], "xp") != 0) ||
160
       (token_count != 1))
161
      return (EMSYNTAX);
162
 
163
   /*
164
   ** Get data
165
   */
166
 
167
   byte_count = XP_CMD_SZ;
168
 
169
   /* Will the data overflow the message buffer? Done in TIP */
170
 
171
   hostendian = FALSE;
172
   if ((retval = Mini_read_req (SPECIAL_REG,
173
                                (ADDR32) 0,
174
                                byte_count/4,
175
                                (INT16) 4, /* size */
176
                                &bytes_ret,
177
                                xp_cmd_val.read_buffer,
178
                                hostendian)) != SUCCESS) {
179
        return(FAILURE);
180
   };
181
   /* The following is executed if SUCCESSful */
182
      vtb  = xp_cmd_val.xp_cmd.vtb;
183
      ops  = xp_cmd_val.xp_cmd.ops;
184
      cps  = xp_cmd_val.xp_cmd.cps;
185
      cfg  = xp_cmd_val.xp_cmd.cfg;
186
      cha  = xp_cmd_val.xp_cmd.cha;
187
      chd  = xp_cmd_val.xp_cmd.chd;
188
      chc  = xp_cmd_val.xp_cmd.chc;
189
      rbp  = xp_cmd_val.xp_cmd.rbp;
190
      tmc  = xp_cmd_val.xp_cmd.tmc;
191
      tmr  = xp_cmd_val.xp_cmd.tmr;
192
      pc0  = xp_cmd_val.xp_cmd.pc0;
193
      pc1  = xp_cmd_val.xp_cmd.pc1;
194
      pc2  = xp_cmd_val.xp_cmd.pc2;
195
      mmuc = xp_cmd_val.xp_cmd.mmuc;
196
      lru  = xp_cmd_val.xp_cmd.lru;
197
 
198
      if (host_config.host_endian != host_config.target_endian) {
199
         convert32((BYTE *)&vtb);
200
         convert32((BYTE *)&ops);
201
         convert32((BYTE *)&cps);
202
         convert32((BYTE *)&cfg);
203
         convert32((BYTE *)&cha);
204
         convert32((BYTE *)&chd);
205
         convert32((BYTE *)&chc);
206
         convert32((BYTE *)&rbp);
207
         convert32((BYTE *)&tmc);
208
         convert32((BYTE *)&tmr);
209
         convert32((BYTE *)&pc0);
210
         convert32((BYTE *)&pc1);
211
         convert32((BYTE *)&pc2);
212
         convert32((BYTE *)&mmuc);
213
         convert32((BYTE *)&lru);
214
      }
215
 
216
 
217
   /* Print CPS */
218
   sprintf(&prtbuf[0], "\n");
219
   sprintf(&prtbuf[strlen(prtbuf)], "       TD MM CA IP TE TP TU FZ LK RE WM PD PI SM IM DI DA\n");
220
   if (io_config.echo_mode == (INT32) TRUE)
221
      fprintf (io_config.echo_file, "%s", &prtbuf[0]);
222
   fprintf (stderr, "%s", &prtbuf[0]);
223
   sprintf(&prtbuf[0], "CPS:");
224
   sprintf(&prtbuf[strlen(prtbuf)], "  %3x", ((cps >> 17) & 0x01));  /* td */
225
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >> 16) & 0x01));  /* mm */
226
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >> 15) & 0x01));  /* ca */
227
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >> 14) & 0x01));  /* ip */
228
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >> 13) & 0x01));  /* te */
229
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >> 12) & 0x01));  /* tp */
230
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >> 11) & 0x01));  /* tu */
231
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >> 10) & 0x01));  /* fz */
232
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >>  9) & 0x01));  /* lk */
233
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >>  8) & 0x01));  /* re */
234
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >>  7) & 0x01));  /* wm */
235
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >>  6) & 0x01));  /* pd */
236
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >>  5) & 0x01));  /* pi */
237
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >>  4) & 0x01));  /* sm */
238
 
239
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >>  2) & 0x03));  /* im */
240
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >>  1) & 0x01));  /* di */
241
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cps >>  0) & 0x01));  /* da */
242
   sprintf(&prtbuf[strlen(prtbuf)], "\n");
243
   if (io_config.echo_mode == (INT32) TRUE)
244
      fprintf (io_config.echo_file, "%s", &prtbuf[0]);
245
   fprintf (stderr, "%s", &prtbuf[0]);
246
 
247
   /* Print OPS */
248
   sprintf(&prtbuf[0], "OPS:");
249
   sprintf(&prtbuf[strlen(prtbuf)], "  %3x", ((ops >> 17) & 0x01));  /* td */
250
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >> 16) & 0x01));  /* mm */
251
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >> 15) & 0x01));  /* ca */
252
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >> 14) & 0x01));  /* ip */
253
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >> 13) & 0x01));  /* te */
254
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >> 12) & 0x01));  /* tp */
255
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >> 11) & 0x01));  /* tu */
256
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >> 10) & 0x01));  /* fz */
257
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >>  9) & 0x01));  /* lk */
258
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >>  8) & 0x01));  /* re */
259
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >>  7) & 0x01));  /* wm */
260
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >>  6) & 0x01));  /* pd */
261
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >>  5) & 0x01));  /* pi */
262
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >>  4) & 0x01));  /* sm */
263
 
264
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >>  2) & 0x03));  /* im */
265
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >>  1) & 0x01));  /* di */
266
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((ops >>  0) & 0x01));  /* da */
267
   sprintf(&prtbuf[strlen(prtbuf)], "\n");
268
   sprintf(&prtbuf[strlen(prtbuf)], "\n");
269
   if (io_config.echo_mode == (INT32) TRUE)
270
      fprintf (io_config.echo_file, "%s", &prtbuf[0]);
271
   fprintf (stderr, "%s", &prtbuf[0]);
272
 
273
   /* Get Processor Revision Number */
274
   prl = (int) ((cfg >> 24) & 0xff);
275
 
276
   /* Print VAB / CFG */
277
   if (PROCESSOR(prl) == PROC_AM29030) {
278
      sprintf(&prtbuf[0], "  VAB       CFG: PRL PMB IL ID VF BO\n");
279
      sprintf(&prtbuf[strlen(prtbuf)], "%08lx          ", vtb);
280
      sprintf(&prtbuf[strlen(prtbuf)], "%02lx", ((cfg >> 24) & 0xff));  /* prl */
281
      sprintf(&prtbuf[strlen(prtbuf)], "%4x", ((cfg >> 16) & 0x03));    /* pmb */
282
      sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cfg >>  9) & 0x03));    /* il */
283
      sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cfg >>  8) & 0x01));    /* id */
284
      sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cfg >>  4) & 0x01));    /* vf */
285
      sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cfg >>  2) & 0x01));    /* bo */
286
      sprintf(&prtbuf[strlen(prtbuf)], "\n");
287
      sprintf(&prtbuf[strlen(prtbuf)], "\n");
288
      }
289
   else {  /* Am29000 or Am29050 */
290
      sprintf(&prtbuf[0], "  VAB       CFG: PRL DW VF RV BO CP CD\n");
291
      sprintf(&prtbuf[strlen(prtbuf)], "%08lx          ", vtb);
292
      sprintf(&prtbuf[strlen(prtbuf)], "%02lx", ((cfg >> 24) & 0xff));  /* prl */
293
      sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cfg >>  5) & 0x01));    /* dw */
294
      sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cfg >>  4) & 0x01));    /* vf */
295
      sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cfg >>  3) & 0x01));    /* rv */
296
      sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cfg >>  2) & 0x01));    /* bo */
297
      sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cfg >>  1) & 0x01));    /* cp */
298
      sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((cfg >>  0) & 0x01));    /* cd */
299
      sprintf(&prtbuf[strlen(prtbuf)], "\n");
300
      sprintf(&prtbuf[strlen(prtbuf)], "\n");
301
      }
302
   if (io_config.echo_mode == (INT32) TRUE)
303
      fprintf (io_config.echo_file, "%s", &prtbuf[0]);
304
   fprintf (stderr, "%s", &prtbuf[0]);
305
 
306
   /* Print CHA / CHD / CHC */
307
   sprintf(&prtbuf[0], "  CHA       CHD     CHC: CE CNTL CR LS ML ST LA TF TR NN CV\n");
308
   if (io_config.echo_mode == (INT32) TRUE)
309
      fprintf (io_config.echo_file, "%s", &prtbuf[0]);
310
   fprintf (stderr, "%s", &prtbuf[0]);
311
   sprintf(&prtbuf[0], "%08lx  ", cha);     /* cha */
312
   sprintf(&prtbuf[strlen(prtbuf)], "%08lx       ", chd);  /* chd */
313
   sprintf(&prtbuf[strlen(prtbuf)], "%2x", ((chc >>  31) & 0x01));    /* ce   */
314
   sprintf(&prtbuf[strlen(prtbuf)], "%5x", ((chc >>  24) & 0xff));    /* cntl */
315
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((chc >>  16) & 0xff));    /* cr   */
316
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((chc >>  15) & 0x01));    /* ls   */
317
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((chc >>  14) & 0x01));    /* ml   */
318
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((chc >>  13) & 0x01));    /* st   */
319
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((chc >>  12) & 0x01));    /* la   */
320
 
321
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((chc >>  10) & 0x01));    /* tf   */
322
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((chc >>   2) & 0xff));    /* tr   */
323
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((chc >>   1) & 0x01));    /* nn   */
324
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((chc >>   0) & 0x01));    /* cv   */
325
   sprintf(&prtbuf[strlen(prtbuf)], "\n");
326
   sprintf(&prtbuf[strlen(prtbuf)], "\n");
327
   if (io_config.echo_mode == (INT32) TRUE)
328
      fprintf (io_config.echo_file, "%s", &prtbuf[0]);
329
   fprintf (stderr, "%s", &prtbuf[0]);
330
 
331
   /* Print RBP */
332
   sprintf(&prtbuf[0], "RBP: BF BE BD BC BB BA B9 B8 B7 B6 B5 B4 B3 B2 B1 B0\n");
333
   if (io_config.echo_mode == (INT32) TRUE)
334
      fprintf (io_config.echo_file, "%s", &prtbuf[0]);
335
   fprintf (stderr, "%s", &prtbuf[0]);
336
   sprintf(&prtbuf[0], "    %3x", ((rbp >>  15) & 0x01));
337
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>  14) & 0x01));
338
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>  13) & 0x01));
339
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>  12) & 0x01));
340
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>  11) & 0x01));
341
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>  10) & 0x01));
342
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>   9) & 0x01));
343
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>   8) & 0x01));
344
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>   7) & 0x01));
345
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>   6) & 0x01));
346
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>   5) & 0x01));
347
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>   4) & 0x01));
348
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>   3) & 0x01));
349
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>   2) & 0x01));
350
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>   1) & 0x01));
351
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((rbp >>   0) & 0x01));
352
   sprintf(&prtbuf[strlen(prtbuf)], "\n");
353
   sprintf(&prtbuf[strlen(prtbuf)], "\n");
354
   if (io_config.echo_mode == (INT32) TRUE)
355
      fprintf (io_config.echo_file, "%s", &prtbuf[0]);
356
   fprintf (stderr, "%s", &prtbuf[0]);
357
 
358
   /* Print TMC / TMR / PC0 / PC1 / PC2 */
359
   sprintf(&prtbuf[0], " TCV TR: OV IN IE   TRV     PC0      PC1      PC2\n");
360
   if (io_config.echo_mode == (INT32) TRUE)
361
      fprintf (io_config.echo_file, "%s", &prtbuf[0]);
362
   fprintf (stderr, "%s", &prtbuf[0]);
363
   sprintf(&prtbuf[0], "%06lx", (tmc & 0x00ffffff));      /* tcv */
364
   sprintf(&prtbuf[strlen(prtbuf)], "%5x", ((tmr >> 26) & 0x01));  /* ov  */
365
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((tmr >> 25) & 0x01));  /* in  */
366
   sprintf(&prtbuf[strlen(prtbuf)], "%3x", ((tmr >> 24) & 0x01));  /* ie  */
367
   sprintf(&prtbuf[strlen(prtbuf)], "  %06lx", (tmr & 0x00ffffff));    /* trv */
368
   sprintf(&prtbuf[strlen(prtbuf)], " %08lx", pc0);                /* pc0 */
369
   sprintf(&prtbuf[strlen(prtbuf)], " %08lx", pc1);                /* pc1 */
370
   sprintf(&prtbuf[strlen(prtbuf)], " %08lx", pc2);                /* pc2 */
371
   sprintf(&prtbuf[strlen(prtbuf)], "\n");
372
   sprintf(&prtbuf[strlen(prtbuf)], "\n");
373
   if (io_config.echo_mode == (INT32) TRUE)
374
      fprintf (io_config.echo_file, "%s", &prtbuf[0]);
375
   fprintf (stderr, "%s", &prtbuf[0]);
376
 
377
   /* Print MMUC / LRU */
378
   sprintf(&prtbuf[0], "MMU: PS PID LRU\n");
379
   if (io_config.echo_mode == (INT32) TRUE)
380
      fprintf (io_config.echo_file, "%s", &prtbuf[0]);
381
   fprintf (stderr, "%s", &prtbuf[0]);
382
   sprintf(&prtbuf[0], "     %02x", ((mmuc >>  8) & 0x03));  /* ps  */
383
   sprintf(&prtbuf[strlen(prtbuf)], "  %02x", (mmuc & 0xff));             /* pid */
384
   sprintf(&prtbuf[strlen(prtbuf)], "  %02x", (lru & 0xff));              /* lru */
385
   sprintf(&prtbuf[strlen(prtbuf)], "\n");
386
   sprintf(&prtbuf[strlen(prtbuf)], "\n");
387
   if (io_config.echo_mode == (INT32) TRUE)
388
      fprintf (io_config.echo_file, "%s", &prtbuf[0]);
389
   fprintf (stderr, "%s", &prtbuf[0]);
390
 
391
   return (0);
392
 
393
   }  /* end xp_cmd() */
394
 
395
 
396
 
397
/*
398
** This command is used to examine the contents of the cache
399
** in the Am29030.  First set 0 is printed, starting with the
400
** tag, followed by a disassembly of four instructions in
401
** the set.  Set 1 for the line follows similarly.
402
**
403
** The data comes in from the READ_ACK message in the following
404
** order:
405
**
406
**            tag      (data[0-3]    (set 0)
407
**         instr1      (data[4-7]
408
**         instr1      (data[8-11]
409
**         instr1      (data[12-15]
410
**         instr1      (data[16-19]
411
**
412
**            tag      (data[20-23]  (set 1)
413
**         instr1      (data[24-27]
414
**         instr1      (data[28-31]
415
**         instr1      (data[32-35]
416
**         instr1      (data[36-39]
417
*/
418
 
419
INT32
420
xc_cmd(token, token_count)
421
   char   *token[];
422
   int     token_count;
423
   {
424
   static INT32  memory_space=I_CACHE;
425
   static ADDR32 cache_line=0;
426
   static INT32  byte_count=(10*sizeof(INST32));
427
   static INT32  count=1;
428
   ADDR32 address;
429
   INT32  i;
430
   int    j;
431
   int    set;
432
   int    index;
433
   int    result;
434
   struct instr_t instr;
435
   INT32  cache_line_start;
436
   INT32  cache_line_end;
437
 
438
   INT32        retval;
439
   INT32        bytes_ret;
440
   INT32        host_endian;
441
   BYTE         read_buffer[10*sizeof(INST32)];
442
   char         prtbuf[256];
443
 
444
 
445
   /* Is it an 'xc' command? */
446
   if (strcmp(token[0], "xc") != 0)
447
      return (EMSYNTAX);
448
 
449
   /*
450
   ** Parse parameters
451
   */
452
 
453
   if (token_count == 1) {
454
      cache_line = cache_line + count;
455
      }
456
   else
457
   if (token_count == 2) {
458
      result = get_word(token[1], &cache_line_start);
459
      if (result != 0)
460
         return (EMSYNTAX);
461
      if ((cache_line_start < 0) ||
462
          (cache_line_start >255))
463
         return (EMBADADDR);
464
      cache_line = cache_line_start;
465
      }
466
   else
467
   if (token_count == 3) {
468
      /* Get first cache line to be dumped */
469
      result = get_word(token[1], &cache_line_start);
470
      if (result != 0)
471
         return (EMSYNTAX);
472
      if ((cache_line_start < 0) ||
473
          (cache_line_start > 255))
474
         return (EMBADADDR);
475
      /* Get last cache line to be dumped */
476
      result = get_word(token[2], &cache_line_end);
477
      if (result != 0)
478
         return (EMSYNTAX);
479
      if ((cache_line_end < 0) ||
480
          (cache_line_end > 255))
481
         return (EMBADADDR);
482
      if (cache_line_start > cache_line_end)
483
         return (EMBADADDR);
484
      cache_line = cache_line_start;
485
      count = (cache_line_end - cache_line_start) + 1;
486
      }
487
   else
488
   /* Too many args */
489
      return (EMSYNTAX);
490
 
491
   i = 0;
492
   while (i < count) {
493
 
494
      host_endian = FALSE;
495
      if ((retval = Mini_read_req(memory_space,
496
                                  (cache_line + i),
497
                                  byte_count/4,
498
                                  (INT16) 4, /* size */
499
                                  &bytes_ret,
500
                                  read_buffer,
501
                                  host_endian)) != SUCCESS) {
502
         return(FAILURE);
503
      };
504
      /* The following is executed if SUCCESSful */
505
 
506
      for (set=0; set<2; set++) {
507
 
508
         /* Print out formatted address tag and status information */
509
         index = (set * 20);
510
         sprintf(&prtbuf[0], "\n");
511
         sprintf(&prtbuf[strlen(prtbuf)], "Cache line 0x%lx, set %d.\n", (int) (cache_line+i), set);
512
         sprintf(&prtbuf[strlen(prtbuf)], "\n");
513
         if (io_config.echo_mode == (INT32) TRUE)
514
            fprintf (io_config.echo_file, "%s", &prtbuf[0]);
515
         fprintf (stderr, "%s", &prtbuf[0]);
516
         sprintf(&prtbuf[0], "IATAG  V  P US\n");
517
         if (io_config.echo_mode == (INT32) TRUE)
518
            fprintf (io_config.echo_file, "%s", &prtbuf[0]);
519
         fprintf (stderr, "%s", &prtbuf[0]);
520
         sprintf(&prtbuf[0], "%02x%02x%1x  %1x  %1x  %1x\n",
521
                read_buffer[index],
522
                read_buffer[index + 1],
523
                ((read_buffer[index + 2] >> 4) & 0x0f),
524
                ((read_buffer[index + 3] >> 2) & 0x01),
525
                ((read_buffer[index + 3] >> 1) & 0x01),
526
                (read_buffer[index + 3] & 0x01));
527
         sprintf(&prtbuf[strlen(prtbuf)], "\n");
528
         if (io_config.echo_mode == (INT32) TRUE)
529
           fprintf (io_config.echo_file, "%s", &prtbuf[0]);
530
         fprintf (stderr, "%s", &prtbuf[0]);
531
 
532
         /* Address = IATAG + line_number + <16 byte adddress> */
533
         address = ((read_buffer[index] << 24) |
534
                    (read_buffer[index + 1] << 16) |
535
                    (read_buffer[index + 2] << 8) |
536
                    ((cache_line+i) << 4));
537
 
538
         /* Disassemble four words */
539
         for (j=0; j<4; j=j+1) {
540
            index = (set * 20) + ((j+1) * sizeof(INT32));
541
            instr.op = read_buffer[index];
542
            instr.c = read_buffer[index + 1];
543
            instr.a = read_buffer[index + 2];
544
            instr.b = read_buffer[index + 3];
545
 
546
            /* Print address of instruction (in hex) */
547
            address = (address & 0xfffffff0);  /* Clear low four bits */
548
            address = (address | (j << 2));
549
            fprintf(stderr, "%08lx    ", address);
550
            if (io_config.echo_mode == (INT32) TRUE)
551
               fprintf(io_config.echo_file, "%08lx    ", address);
552
 
553
            /* Print instruction (in hex) */
554
            if (io_config.echo_mode == (INT32) TRUE)
555
               fprintf(io_config.echo_file, "%02x%02x%02x%02x    ", instr.op, instr.c,
556
                   instr.a, instr.b);
557
            fprintf(stderr, "%02x%02x%02x%02x    ", instr.op, instr.c,
558
                   instr.a, instr.b);
559
 
560
            /* Disassemble instruction */
561
            dasm_instr(address, &instr);
562
            fprintf(stderr, "\n");
563
            if (io_config.echo_mode == (INT32) TRUE)
564
               fprintf(io_config.echo_file, "\n");
565
 
566
            }  /* end for(j) */
567
 
568
         fprintf(stderr, "\n");
569
         if (io_config.echo_mode == (INT32) TRUE)
570
           fprintf(io_config.echo_file, "\n");
571
 
572
         }  /* end for(set) */
573
 
574
      i = i + 1;
575
 
576
      }  /* end while loop */
577
 
578
   return (0);
579
 
580
   }  /* end xc_cmd() */
581
 
582
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.