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

Subversion Repositories or1k

[/] [or1k/] [branches/] [oc/] [gdb-5.0/] [utils/] [amd-udi/] [mondfe/] [mini2udi.c] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
static char _[] = "@(#)mini2udi.c       5.23 93/08/18 13:48:08, 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
 * Definitions of the functions that define Minimon's Interface
30
 * to the UDI
31
 * interface The minimon functions are declared in miniint.h The UDI
32
 * functions are declared in udi/udiproc.h
33
 *****************************************************************************
34
 */
35
 
36
 
37
#include <stdio.h>
38
#ifdef  MSDOS
39
#include <io.h>
40
#endif
41
#include <string.h>
42
#include "main.h"
43
#include "memspcs.h"
44
#include "macros.h"
45
#include "miniint.h"
46
#include "udiproc.h"
47
#include "udiids.h"
48
#include "udiext.h"
49
#include "versions.h"
50
 
51
 
52
/* Define BreakIdType here to avoid having to change at many places
53
 * every time it changes.
54
 */
55
typedef unsigned int    BreakIdType;
56
 
57
/* ABOUT UDI calls:
58
 * There are three types of return values:
59
 * < 0: means a TIP failure.
60
 * = 0: means success.
61
 * > 0: means a "local" failure.
62
 */
63
 
64
 
65
 
66
static  UDISessionId    SessionID;
67
static  char            MONErrorMsg[MONErrorMsgSize];
68
static  int             GoForever=0;
69
 
70
static  char    *udi_errmsg[] = {
71
/*
72
#define UDINoError                      0
73
*/ "UDIERR: No Error",
74
/*
75
#define UDIErrorNoSuchConfiguration     1
76
*/ "UDIERR: No Such Configuration in Config File.",
77
/*
78
#define UDIErrorCantHappen              2
79
*/ "UDIERR: Cannot Happen With Current Environment Setup.",
80
/*
81
#define UDIErrorCantConnect             3
82
*/ "UDIERR: Cannot Connect to TIP Specified.",
83
/*
84
#define UDIErrorNoSuchConnection        4
85
*/ "UDIERR: No Such Connection Found.",
86
/*
87
#define UDIErrorNoConnection            5
88
*/ "UDIERR: No Connection Occurred.",
89
/*
90
#define UDIErrorCantOpenConfigFile      6
91
*/ "UDIERR: Cannot Open UDI Config File.",
92
/*
93
#define UDIErrorCantStartTIP            7
94
*/ "UDIERR: Cannot Start TIP In Current Environment Setup.",
95
/*
96
#define UDIErrorConnectionUnavailable   8
97
*/ "UDIERR: Requested Connection Unavailable.",
98
/*
99
#define UDIErrorTryAnotherTIP           9
100
*/ "UDIERR: Try Another TIP For Connection.",
101
/*
102
#define UDIErrorExecutableNotTIP        10
103
*/ "UDIERR: TIP Specified in Config File Not An Executable.",
104
/*
105
#define UDIErrorInvalidTIPOption        11
106
*/ "UDIERR: Connection Failed Due To Invalid TIP Options in Config File.",
107
/*
108
#define UDIErrorCantDisconnect          12
109
*/ "UDIERR: Cannot Disconnect TIP",
110
/*
111
#define UDIErrorUnknownError            13
112
*/ "UDIERR: Unknown Error Number Specified.",
113
/*
114
#define UDIErrorCantCreateProcess       14
115
*/ "UDIERR: TIP Cannot Create a New Process.",
116
/*
117
#define UDIErrorNoSuchProcess           15
118
*/ "UDIERR: No Such Process in the Current TIP.",
119
/*
120
#define UDIErrorUnknownResourceSpace    16
121
*/ "UDIERR: Unknown Resource Space Encountered By TIP.",
122
/*
123
#define UDIErrorInvalidResource         17
124
*/ "UDIERR: Invalid Resource Specified To TIP.",
125
/*
126
#define UDIErrorUnsupportedStepType     18
127
*/ "UDIERR: Unsupported Step Type For This TIP Specified.",
128
/*
129
#define UDIErrorCantSetBreakpoint       19
130
*/ "UDIERR: Could Not Set The Breakpoint.",
131
/*
132
#define UDIErrorTooManyBreakpoints      20
133
*/ "UDIERR: Too Many Breakpoints Already In Use.",
134
/*
135
#define UDIErrorInvalidBreakId          21
136
*/ "UDIERR: Breakpoint Does Not Exist For This BreakId.",
137
/*
138
#define UDIErrorNoMoreBreakIds          22
139
*/ "UDIERR: No More Breakpoints. BreakId Too High.",
140
/*
141
#define UDIErrorUnsupportedService      23
142
*/ "UDIERR: TIP Does Not Support The Requested Service.",
143
/*
144
#define UDIErrorTryAgain                24
145
*/ "UDIERR: Error Occurred. Trying Again.",
146
/*
147
#define UDIErrorIPCLimitation           25
148
*/ "UDIERR: IPC Limitation Exceeded.",
149
/*
150
#define UDIErrorIncomplete              26
151
*/ "UDIERR: Service Incomplete.More Data Available.",
152
/*
153
#define UDIErrorAborted                 27
154
*/ "UDIERR: Aborted Requested Service.",
155
/*
156
#define UDIErrorTransDone               28
157
*/ "UDIERR: Transaction Completed.",
158
/*
159
#define UDIErrorCantAccept              29
160
*/ "UDIERR: Cannot Accept.",
161
/*
162
#define UDIErrorTransInputNeeded        30
163
*/ "UDIERR: Transaction Input Needed.",
164
/*
165
#define UDIErrorTransModeX              31
166
*/ "UDIERR: Transaction ModeX",
167
/*
168
#define UDIErrorInvalidSize             32
169
*/ "UDIERR: Invalid Object Size Specified.",
170
/*
171
#define UDIErrorBadConfigFileEntry      33
172
*/ "UDIERR: Bad Entry In UDI Config File Found.",
173
/*
174
#define UDIErrorIPCInternal             34
175
*/ "UDIERR: Internal Error Occurred In IPC Layer."
176
};
177
 
178
static  UDIPId          CurrentPID=(UDIPId) UDIProcessProcessor;
179
static  void            PrintErrorMessage PARAMS((UDIError num));
180
static  void            udi_warning PARAMS((int num));
181
static  CPUSpace        xlate_mspace_mon2udi PARAMS((INT32 mspace));
182
static  INT32           xlate_mspace_udi2mon PARAMS((CPUSpace mspace));
183
static UDIError         FillString PARAMS(( UDIResource from,
184
                                           UDIHostMemPtr pattern,
185
                                           UDISizeT   pattern_count,
186
                                           UDICount   fill_count));
187
static UDIError         FillWords PARAMS(( UDIResource from,
188
                                           UDIHostMemPtr pattern,
189
                                           UDISizeT   pattern_count,
190
                                           UDICount   fill_count));
191
 
192
 
193
INT32
194
/*********************************************Mini_TIP_init    */
195
Mini_TIP_init(connect_string, mon_session_id)
196
  char           *connect_string;
197
  int            *mon_session_id;
198
{
199
  UDIError      UDIretval;
200
  UDISessionId  session;
201
 
202
  /* First connect the target  */
203
  if ((UDIretval = UDIConnect(connect_string,
204
                           &session)) <= TIPFAILURE) {
205
    SessionID = session;
206
    *mon_session_id = (int) session;
207
    PrintErrorMessage (UDIretval);
208
    return ((INT32) UDIretval);
209
  } else if (UDIretval == SUCCESS) {
210
     SessionID = session;
211
    *mon_session_id = (int) session;
212
     return (SUCCESS);
213
  } else {
214
     SessionID = session;
215
    *mon_session_id = (int) session;
216
     udi_warning(UDIretval);
217
     return((INT32) UDIretval);
218
  };
219
}
220
 
221
INT32
222
Mini_TIP_Capabilities()
223
{
224
  UDIError      UDIretval;
225
  UDIUInt32     TIPId;                  /* Out */
226
  UDIUInt32     TargetId;               /* Out */
227
  UDIUInt32     DFEId;                  /* In */
228
  UDIUInt32     DFE;                    /* In */
229
  UDIUInt32     TIP;                    /* Out */
230
  UDIUInt32     DFEIPCId;               /* Out */
231
  UDIUInt32     TIPIPCId;               /* Out */
232
  char          TIPString[80];          /* Out */
233
 
234
    (void) strcpy (TIPString,"");
235
    DFEId = (UDIUInt32) UDIID (UDIProductCode_Mondfe, MONDFERev, MONDFESubRev, MONDFESubSubRev);
236
    DFE = (UDIUInt32) MONDFEUDIVers;
237
    if ((UDIretval = UDICapabilities ( &TIPId,
238
                                       &TargetId,
239
                                       DFEId,
240
                                       DFE,
241
                                       &TIP,
242
                                       &DFEIPCId,
243
                                       &TIPIPCId,
244
                                       &TIPString[0])) <= TIPFAILURE) {
245
       PrintErrorMessage (UDIretval);
246
       return (FAILURE);
247
     } else if (UDIretval == SUCCESS) {
248
       if (!QuietMode) {
249
         if (io_config.echo_mode == (INT32) TRUE) {
250
           fprintf(io_config.echo_file, "MiniMON29K Release 3.0\n");
251
           fprintf(io_config.echo_file, ">AMD MONDFE Version: %d.%d.%d",
252
                                  (int) ((DFEId & 0x00000F00) >> 8),
253
                                  (int) ((DFEId & 0x000000F0) >> 4),
254
                                  (int) ((DFEId & 0x0000000F) >> 0));
255
           fprintf(io_config.echo_file, "\tIPC Version: %d.%d.%d UDI Rev. %d.%d.%d <\n",
256
                                  (int) ((DFEIPCId & 0x00000F00) >> 8),
257
                                  (int) ((DFEIPCId & 0x000000F0) >> 4),
258
                                  (int) ((DFEIPCId & 0x0000000F) >> 0),
259
                                  (int) ((DFE & 0x00000F00) >> 8),
260
                                  (int) ((DFE & 0x000000F0) >> 4),
261
                                  (int) ((DFE & 0x0000000F) >> 0));
262
           fprintf(io_config.echo_file, "%s\n", TIPString);
263
           fprintf(io_config.echo_file, ">TIP Version: %d.%d.%d",
264
                                  (int) ((TIPId & 0x00000F00) >> 8),
265
                                  (int) ((TIPId & 0x000000F0) >> 4),
266
                                  (int) ((TIPId & 0x0000000F) >> 0));
267
           fprintf(io_config.echo_file, "\tIPC Version: %d.%d.%d UDI Rev. %d.%d.%d<\n",
268
                                  (int) ((TIPIPCId & 0x00000F00) >> 8),
269
                                  (int) ((TIPIPCId & 0x000000F0) >> 4),
270
                                  (int) ((TIPIPCId & 0x0000000F) >> 0),
271
                                  (int) ((TIP & 0x00000F00) >> 8),
272
                                  (int) ((TIP & 0x000000F0) >> 4),
273
                                  (int) ((TIP & 0x0000000F) >> 0));
274
         }
275
         fprintf(stderr, "MiniMON29K Release 3.0\n");
276
         fprintf(stderr, ">AMD MONDFE Version: %d.%d.%d",
277
                                  (int) ((DFEId & 0x00000F00) >> 8),
278
                                  (int) ((DFEId & 0x000000F0) >> 4),
279
                                  (int) ((DFEId & 0x0000000F) >> 0));
280
         fprintf(stderr, "\tIPC Version: %d.%d.%d UDI Rev. %d.%d.%d <\n",
281
                                  (int) ((DFEIPCId & 0x00000F00) >> 8),
282
                                  (int) ((DFEIPCId & 0x000000F0) >> 4),
283
                                  (int) ((DFEIPCId & 0x0000000F) >> 0),
284
                                  (int) ((DFE & 0x00000F00) >> 8),
285
                                  (int) ((DFE & 0x000000F0) >> 4),
286
                                  (int) ((DFE & 0x0000000F) >> 0));
287
         fprintf(stderr, "%s\n", TIPString);
288
         fprintf(stderr, ">TIP Version: %d.%d.%d",
289
                                  (int) ((TIPId & 0x00000F00) >> 8),
290
                                  (int) ((TIPId & 0x000000F0) >> 4),
291
                                  (int) ((TIPId & 0x0000000F) >> 0));
292
         fprintf(stderr, "\tIPC Version: %d.%d.%d UDI Rev. %d.%d.%d<\n",
293
                                  (int) ((TIPIPCId & 0x00000F00) >> 8),
294
                                  (int) ((TIPIPCId & 0x000000F0) >> 4),
295
                                  (int) ((TIPIPCId & 0x0000000F) >> 0),
296
                                  (int) ((TIP & 0x00000F00) >> 8),
297
                                  (int) ((TIP & 0x000000F0) >> 4),
298
                                  (int) ((TIP & 0x0000000F) >> 0));
299
       }
300
       if ( (int) ((TIPId & 0x00000F00) >> 8) <
301
            (int) ((DFEId & 0x00000F00) >> 8) ) {
302
         fprintf(stderr, "!!!!! WARNING: MONTIP's major version number is older than that of MONDFE's         !!!!!\n");
303
         fprintf(stderr, "!!!!! Please verify the versions and call AMD 29K Technical Support for assistance. !!!!!\n");
304
       }
305
       if ((TIP == (UDIUInt32) 0) || ((TIP & 0xFFF) > (DFE & 0xFFF))) {
306
          fprintf(stderr, "UDI WARNING: UDI Versions NOT Compatible.\n");
307
       }
308
       if (TIP == (UDIUInt32) 0)
309
          return (FAILURE);
310
       return (SUCCESS);
311
     } else {
312
        udi_warning(UDIretval);
313
        return(FAILURE);
314
     }
315
}
316
 
317
INT32
318
Mini_TIP_CreateProc()
319
{
320
     UDIError   UDIretval;
321
     UDIPId     pid;
322
 
323
     if ((UDIretval = UDICreateProcess(&pid)) <= TIPFAILURE) {
324
       PrintErrorMessage (UDIretval);
325
       return (FAILURE);
326
     } else if (UDIretval == SUCCESS) {
327
       CurrentPID = pid;
328
       return (SUCCESS);
329
     } else {
330
        udi_warning(UDIretval);
331
        return(FAILURE);
332
     }
333
}
334
 
335
INT32
336
Mini_TIP_disc()
337
{
338
  UDIError      UDIretval;
339
 
340
  if ((UDIretval = UDIDisconnect(SessionID,
341
                              UDIContinueSession)) <= TIPFAILURE) {
342
       PrintErrorMessage (UDIretval);
343
       return (FAILURE);
344
  } else if (UDIretval == SUCCESS) {
345
       return(SUCCESS);
346
  } else {
347
        udi_warning(UDIretval);
348
        return(FAILURE);
349
  };
350
}
351
 
352
INT32
353
Mini_TIP_SetCurrSession(sid)
354
int     sid;
355
{
356
  UDIError      UDIretval;
357
 
358
  if ((UDIretval = UDISetCurrentConnection((UDISessionId) sid)) <= TIPFAILURE) {
359
       PrintErrorMessage (UDIretval);
360
       return (FAILURE);
361
  } else if (UDIretval == SUCCESS) {
362
       SessionID = (UDISessionId) sid;
363
       return (SUCCESS);
364
  } else {
365
        udi_warning(UDIretval);
366
        return(FAILURE);
367
  }
368
}
369
 
370
INT32
371
Mini_TIP_SetPID(pid)
372
int     pid;
373
{
374
  UDIError      UDIretval;
375
 
376
  if ((UDIretval = UDISetCurrentProcess((UDIPId) pid)) <= TIPFAILURE) {
377
       PrintErrorMessage (UDIretval);
378
       return (FAILURE);
379
  } else if (UDIretval == SUCCESS) {
380
       return (SUCCESS);
381
  } else {
382
        udi_warning(UDIretval);
383
        return(FAILURE);
384
  }
385
}
386
 
387
INT32
388
Mini_TIP_DestroyProc()
389
{
390
  UDIError      UDIretval;
391
 
392
  if ((UDIretval = UDIDestroyProcess(CurrentPID)) <= TIPFAILURE) {
393
       PrintErrorMessage (UDIretval);
394
       return (FAILURE);
395
  } else if (UDIretval == SUCCESS) {
396
       return (SUCCESS);
397
  } else {
398
        udi_warning(UDIretval);
399
        return(FAILURE);
400
  }
401
}
402
 
403
INT32
404
Mini_TIP_exit()
405
{
406
  UDIError      UDIretval;
407
 
408
     if ((UDIretval = UDIDisconnect(SessionID,
409
                              UDITerminateSession)) <= TIPFAILURE) {
410
       PrintErrorMessage (UDIretval);
411
       return (FAILURE);
412
     } else if (UDIretval == SUCCESS) {
413
       return(SUCCESS);
414
     } else {
415
        udi_warning(UDIretval);
416
        return(FAILURE);
417
     };
418
}
419
/* Breakpoint routines    */
420
 
421
/* Remove breakpoint      */
422
INT32
423
/*******************************************Mini_bkpt_rm   */
424
Mini_bkpt_rm(break_id)
425
int       break_id;
426
{
427
  UDIError      UDIretval;
428
 
429
  if ((UDIretval = UDIClearBreakpoint ((BreakIdType) break_id)) <= TIPFAILURE) {
430
    PrintErrorMessage (UDIretval);
431
    return (FAILURE);
432
  } else if (UDIretval == SUCCESS) {
433
    return(SUCCESS);
434
  } else {
435
     udi_warning(UDIretval);
436
     return(FAILURE);
437
  };
438
}
439
 
440
/* Set   Breakpoints    */
441
 
442
INT32
443
/**********************************************Mini_bkpt_set   */
444
Mini_bkpt_set(m_space, address, pass_count, type, break_id)
445
  INT32        m_space;
446
  ADDR32          address;
447
  INT32        pass_count;
448
  INT32        type;
449
  int       *break_id;
450
{
451
  UDIResource   addr;
452
  UDIError      UDIretval;
453
 
454
 
455
  addr.Space = xlate_mspace_mon2udi(m_space);
456
  addr.Offset = address;
457
 
458
  if (type == BKPT_29000)
459
     type = (UDIBreakType) UDIBreakFlagExecute;
460
  else if (type == BKPT_29050)
461
     type = (UDIBreakType) (MONBreakFlagHardware | UDIBreakFlagExecute);
462
  else if (type == BKPT_29050_BTE_0)
463
     type = (UDIBreakType) (MONBreakFlagHardware | UDIBreakFlagExecute);
464
  else if (type == BKPT_29050_BTE_1)
465
     type = (UDIBreakType) (MONBreakTranslationEnabled | MONBreakFlagHardware | UDIBreakFlagExecute);
466
 
467
  if ((UDIretval = UDISetBreakpoint(addr,
468
                           (UDIInt32) pass_count,
469
                           (UDIBreakType) type,
470
                           (BreakIdType *) break_id)) <= TIPFAILURE) {
471
     PrintErrorMessage (UDIretval);
472
     return (FAILURE);
473
  } else if (UDIretval == SUCCESS) {
474
     return(SUCCESS);
475
  } else {
476
     udi_warning(UDIretval);
477
     return(FAILURE);
478
  }
479
}
480
 
481
/* Query   (get status)  Breakpoints   */
482
 
483
INT32
484
/**********************************************Mini_bkpt_stat   */
485
Mini_bkpt_stat(break_id, address, m_space, pass_count,
486
               bkpt_type, current_cnt)
487
  int       break_id;
488
  INT32       *m_space;
489
  ADDR32      *address;
490
  INT32       *pass_count;
491
  INT32       *bkpt_type;
492
  INT32       *current_cnt;
493
{
494
  UDIError      UDIretval;
495
  UDIResource   addr;
496
 
497
  if ((UDIretval = UDIQueryBreakpoint ((BreakIdType) break_id,
498
                                &addr,
499
                                (UDIInt32 *)pass_count,
500
                                (UDIBreakType *) bkpt_type,
501
                                (UDIInt32 *) current_cnt)) <= TIPFAILURE) {
502
    PrintErrorMessage (UDIretval);
503
    return (FAILURE);
504
  } else if (UDIretval == SUCCESS) {
505
    *address = addr.Offset;
506
    *m_space = xlate_mspace_udi2mon(addr.Space);
507
    if (*bkpt_type & MONBreakFlagHardware)
508
        *bkpt_type = BKPT_29050;
509
    return(SUCCESS);
510
  } else {
511
     if (UDIretval == UDIErrorNoMoreBreakIds)
512
        return ((INT32) MONBreakNoMore);
513
     else if (UDIretval == UDIErrorInvalidBreakId)
514
        return ((INT32) MONBreakInvalid);
515
     else {
516
       udi_warning(UDIretval);
517
       return(FAILURE);
518
     }
519
  };
520
}
521
 
522
/* Kill    Target     */
523
 
524
INT32
525
/**********************************************Mini_break   */
526
Mini_break()
527
{
528
 
529
  UDIStop();
530
  return (SUCCESS);
531
}
532
 
533
/* Obtain Target configuration and resynchronize with target  */
534
 
535
UDIInt32
536
/**********************************************Mini_config_req   */
537
Mini_config_req(target_config, versions)
538
  TARGET_CONFIG  *target_config;
539
  VERSIONS_ETC   *versions;
540
{
541
  UDIError      UDIretval;
542
  UDIMemoryRange        DFEMemRange[MONMaxMemRanges];
543
  UDIUInt32     ChipVersions[MONMaxChips];
544
  UDIInt        NumRanges, NumChips;
545
  UDIInt        i;
546
 
547
  NumRanges = (UDIInt) MONMaxMemRanges;
548
  NumChips  = (UDIInt) MONMaxChips;
549
 
550
  if ((UDIretval = UDIGetTargetConfig(
551
                           (UDIMemoryRange *) &DFEMemRange[0],
552
                           (UDIInt *) &NumRanges, /* 3 -> I, D, R */
553
                           (UDIUInt32 *) &ChipVersions[0],
554
                           (UDIInt *) &NumChips)) <= TIPFAILURE) {
555
      PrintErrorMessage (UDIretval);
556
      return(FAILURE);
557
  } else if ((UDIretval == SUCCESS) || (UDIretval == UDIErrorIncomplete)) {
558
      if (UDIretval == UDIErrorIncomplete) {
559
        fprintf(stderr, "Ignoring: ");
560
        if (io_config.echo_mode == (INT32) TRUE) {
561
           fprintf(io_config.echo_file, "Ignoring: ");
562
           fflush (io_config.echo_file);
563
        }
564
        udi_warning(UDIretval);
565
      };
566
      i = (UDIInt) 0;
567
      while ((i < (UDIInt) MONMaxMemRanges) && (i < NumRanges)) {
568
           switch ((int) DFEMemRange[i].Space) {
569
             case  UDI29KDRAMSpace:
570
                target_config->D_mem_start = (ADDR32) DFEMemRange[i].Offset;
571
                target_config->D_mem_size = (INT32) DFEMemRange[i].Size;
572
                break;
573
             case        UDI29KIROMSpace:
574
                target_config->ROM_start = (ADDR32) DFEMemRange[i].Offset;
575
                target_config->ROM_size = (INT32) DFEMemRange[i].Size;
576
                break;
577
             case        UDI29KIRAMSpace:
578
                target_config->I_mem_start = (ADDR32) DFEMemRange[i].Offset;
579
                target_config->I_mem_size = (INT32) DFEMemRange[i].Size;
580
                break;
581
             default: /* don't care, so ignore it */
582
                break;
583
           };
584
           i = i + (UDIInt) 1;
585
      } /* end while */
586
      i = (UDIInt) 0;
587
      while ((i < (UDIInt) MONMaxChips) && (i < NumChips)) {
588
           switch (i) {
589
              case      0:  /* cpu */
590
                target_config->processor_id = (UINT32) ChipVersions[i];
591
                break;
592
              case      1:  /* coprocessor */
593
                target_config->coprocessor = (UINT32) ChipVersions[i];
594
                if (target_config->coprocessor == (UINT32) UDI29KChipNotPresent)
595
                   target_config->coprocessor = (UINT32) -1; /* MONDFE's */
596
                break;
597
              default:  /* ignore */
598
                break;
599
           };
600
           i = i + (UDIInt) 1;
601
      } /* end while */
602
      return(SUCCESS);
603
  } else {
604
      udi_warning(UDIretval);
605
      return(FAILURE);
606
  }
607
}
608
 
609
 
610
/* Copy memory and registers    */
611
 
612
 
613
INT32
614
/**********************************************Mini_copy   */
615
Mini_copy(src_space, src_addr, dst_space, dst_addr, byte_count, size, dir)
616
  INT32        src_space,
617
               dst_space;
618
  ADDR32       src_addr,
619
               dst_addr;
620
  INT32          byte_count;
621
  INT16         size;
622
  INT32          dir;
623
{
624
  UDIError      UDIretval;
625
  UDIResource   from, to;
626
  UDICount      count_done;
627
 
628
  from.Space = xlate_mspace_mon2udi(src_space);
629
  from.Offset = src_addr;
630
  to.Space = xlate_mspace_mon2udi(dst_space);
631
  to.Offset = dst_addr;
632
 
633
  if ((UDIretval = UDICopy (from,
634
                            to,
635
                            (UDICount) byte_count,
636
                            (UDISizeT) size,
637
                            &count_done,
638
                            (UDIBool) dir)) <= TIPFAILURE) {
639
      PrintErrorMessage (UDIretval);
640
      return (FAILURE);
641
  } else if (UDIretval == SUCCESS) {
642
      return(SUCCESS);
643
  } else {
644
     udi_warning(UDIretval);
645
     return(FAILURE);
646
  }
647
}
648
 
649
/* Fill memory and registers    */
650
 
651
 
652
/* fill_count if greater than 4 should be a multiple of 4 */
653
INT32
654
/**********************************************Mini_fill   */
655
Mini_fill(m_space, start, fill_count, pattern_count, pattern)
656
  INT32        m_space;
657
  ADDR32          start;
658
  INT32        fill_count,
659
                  pattern_count;
660
  BYTE           *pattern;
661
{
662
  UDIBool         host_endian;
663
  UDIResource   from;
664
  UDICount      count_done;
665
  UDIError      UDIretval;
666
 
667
  host_endian = FALSE;
668
 
669
  from.Offset = start;
670
  from.Space = xlate_mspace_mon2udi (m_space);
671
 
672
  if (fill_count == (INT32) 1) { /* takes only one write */
673
     if ((UDIretval = UDIWrite((UDIHostMemPtr) pattern,
674
                               from,
675
                               (UDICount) fill_count,
676
                               (UDISizeT) pattern_count, /* a byte at a time */
677
                               (UDICount *) &count_done,
678
                               host_endian)) <= TIPFAILURE) {
679
        PrintErrorMessage (UDIretval);
680
        return (FAILURE);
681
     } else if (UDIretval == SUCCESS) {
682
        return(SUCCESS);
683
     } else {
684
        udi_warning(UDIretval);
685
        return(FAILURE);
686
     };
687
  } else {
688
     /* Handle arbitrary length strings to Data memory separately */
689
     if ((pattern_count > (INT32) 4) &&
690
                               ((int) (pattern_count % 4) != (int) 0)){
691
        if (from.Space != UDI29KDRAMSpace)
692
          return (FAILURE);
693
        return((INT32) FillString(from, (UDIHostMemPtr) pattern,
694
                           (UDISizeT) pattern_count, (UDICount) fill_count));
695
     } else {
696
        return((INT32) FillWords(from, (UDIHostMemPtr) pattern,
697
                           (UDISizeT) pattern_count, (UDICount) fill_count));
698
     }
699
  };
700
}
701
 
702
/* Initiate a wait and get target status  */
703
 
704
INT32
705
/**********************************************Mini_get_target_stats   */
706
Mini_get_target_stats(maxtime, target_status)
707
INT32   maxtime;
708
INT32  *target_status;
709
{
710
  UDIPId        pid;
711
  UDIError      UDIretval;
712
  UDIInt32      udiwait_code;
713
 
714
  if (maxtime == (INT32) -1) {
715
    udiwait_code = (UDIInt32) UDIWaitForever;
716
  } else {
717
    udiwait_code = (UDIInt32) maxtime;
718
  };
719
  if ((UDIretval = UDIWait ((UDIInt32) udiwait_code,
720
                            &pid,
721
                            (UDIUInt32 *) target_status)) <= TIPFAILURE) {
722
        PrintErrorMessage (UDIretval);
723
        return (SUCCESS);  /* considered non-fatal */
724
  } else if (UDIretval == SUCCESS) {
725
        CurrentPID = (UDIPId) pid; /* useful when reconnecting */
726
        return(SUCCESS);
727
  } else {
728
        udi_warning(UDIretval);
729
        return(FAILURE);
730
  };
731
}
732
 
733
 
734
INT32
735
/**********************************************Mini_go   */
736
Mini_go()
737
{
738
  UDIError      UDIretval;
739
 
740
  if ((UDIretval = UDIExecute()) <= TIPFAILURE) {
741
        PrintErrorMessage (UDIretval);
742
        return (FAILURE);
743
  } else if (UDIretval == SUCCESS) {
744
        return(SUCCESS);
745
  } else {
746
        udi_warning(UDIretval);
747
        return(FAILURE);
748
  };
749
}
750
 
751
INT32
752
/**********************************************Mini_init   */
753
Mini_init(txt_start, txt_end, dat_start, dat_end,
754
          entry_point, m_stack, r_stack,
755
          arg_string)
756
  ADDR32          txt_start,
757
                  txt_end,
758
                  dat_start,
759
                  dat_end;
760
  ADDR32          entry_point;
761
  INT32        m_stack,
762
                  r_stack;
763
  char          *arg_string;
764
{
765
  UDIMemoryRange        ProcessMemory[MONMaxProcessMemRanges];
766
  UDIInt        NumRanges;
767
  UDIResource   Entry;
768
  CPUSizeT      StackSizes[MONMaxStacks];
769
  UDIInt        NumStacks;
770
  UDIError      UDIretval;
771
 
772
  NumRanges = (UDIInt) MONMaxProcessMemRanges;
773
  NumStacks = (UDIInt) MONMaxStacks;
774
  ProcessMemory[0].Space = (CPUSpace) UDI29KIRAMSpace;
775
  ProcessMemory[0].Offset = (CPUOffset) txt_start;
776
  ProcessMemory[0].Size = (CPUSizeT) (txt_end - txt_start);
777
  ProcessMemory[1].Space = (CPUSpace) UDI29KDRAMSpace;
778
  ProcessMemory[1].Offset = (CPUOffset) dat_start;
779
  ProcessMemory[1].Size = (CPUSizeT) (dat_end - dat_start);
780
  Entry.Offset = entry_point;
781
  Entry.Space = xlate_mspace_mon2udi((INT32) I_MEM);
782
  StackSizes[0] = (CPUSizeT) r_stack;
783
  StackSizes[1] = (CPUSizeT) m_stack;
784
 
785
  if ((UDIretval = UDIInitializeProcess (&ProcessMemory[0],
786
                                         (UDIInt) NumRanges,
787
                                         Entry,
788
                                         &StackSizes[0],
789
                                         (UDIInt) NumStacks,
790
                                         arg_string)) <= TIPFAILURE) {
791
        PrintErrorMessage (UDIretval);
792
        return (FAILURE);
793
  } else if (UDIretval == SUCCESS) {
794
        return(SUCCESS);
795
  } else {
796
        udi_warning(UDIretval);
797
        return(FAILURE);
798
  };
799
}
800
 
801
 
802
/* Read memory or registers from target  */
803
INT32
804
/**********************************************Mini_read_req   */
805
Mini_read_req(m_space, address, byte_count, size, count_done,
806
              buffer, host_endian)
807
  INT32        m_space;
808
  ADDR32       address;
809
  INT32        byte_count;
810
  INT16        size;
811
  INT32        host_endian;
812
  INT32       *count_done;
813
  BYTE        *buffer;
814
{
815
  UDIError      UDIretval;
816
  UDIResource   from;
817
 
818
  from.Space = xlate_mspace_mon2udi(m_space);
819
  from.Offset = address;
820
 
821
  if ((UDIretval = UDIRead (from,
822
                            (UDIHostMemPtr) buffer,
823
                            (UDICount) byte_count,
824
                            (UDISizeT) size,
825
                            (UDICount *) count_done,
826
                            (UDIBool) host_endian)) <= TIPFAILURE) {
827
       PrintErrorMessage (UDIretval);
828
      return(FAILURE);
829
  } else if (UDIretval == SUCCESS) {
830
      return(SUCCESS);
831
  } else {
832
      udi_warning(UDIretval);
833
      return(FAILURE);
834
  }
835
}
836
 
837
/*
838
 * Reset target processor
839
 */
840
INT32
841
/**********************************************Mini_reset_processor   */
842
Mini_reset_processor()
843
{
844
  UDIMemoryRange        ProcessMemory[MONMaxProcessMemRanges];
845
  UDIInt        NumRanges;
846
  UDIResource   Entry;
847
  CPUSizeT      StackSizes[MONMaxStacks];
848
  UDIInt        NumStacks;
849
  UDIError      UDIretval;
850
  UDIPId        CurrentPID;
851
  UDIUInt32     StopReason;
852
 
853
 
854
  NumRanges = (UDIInt) MONMaxProcessMemRanges;
855
  NumStacks = (UDIInt) MONMaxStacks;
856
  ProcessMemory[0].Space = (CPUSpace) UDI29KIRAMSpace;
857
  ProcessMemory[0].Offset = (CPUOffset) 0;
858
  ProcessMemory[0].Size = (CPUSizeT) 0;
859
  ProcessMemory[0].Space = (CPUSpace) UDI29KIRAMSpace;
860
  ProcessMemory[0].Offset = (CPUOffset) 0;
861
  ProcessMemory[0].Size = (CPUSizeT) 0;
862
  Entry.Offset = 0;
863
  Entry.Space = xlate_mspace_mon2udi((INT32) I_MEM);
864
  StackSizes[0] = (CPUSizeT) 0;
865
  StackSizes[1] = (CPUSizeT) 0;
866
 
867
  if ((UDIretval = UDIWait((UDIInt32) 0, &CurrentPID, &StopReason))
868
                                                         <= TIPFAILURE) {
869
       PrintErrorMessage (UDIretval);
870
      return(FAILURE);
871
  } else if (UDIretval != SUCCESS) {
872
      udi_warning(UDIretval);
873
      return(FAILURE);
874
  };
875
  /* set PID to ProcProcessor */
876
  if (( UDIretval = UDISetCurrentProcess((UDIPId) UDIProcessProcessor))
877
                                                           <= TIPFAILURE) {
878
       PrintErrorMessage (UDIretval);
879
      return(FAILURE);
880
  } else if (UDIretval != SUCCESS) {
881
      udi_warning(UDIretval);
882
      return(FAILURE);
883
  };
884
  /* Successful */
885
  /* call InitializeProcess. Paramters ignored. */
886
  if ((UDIretval = UDIInitializeProcess (&ProcessMemory[0],
887
                                         (UDIInt) NumRanges,
888
                                         Entry,
889
                                         &StackSizes[0],
890
                                         (UDIInt) NumStacks,
891
                                         (char *) 0)) <= TIPFAILURE) {
892
       PrintErrorMessage (UDIretval);
893
      return(FAILURE);
894
  } else if (UDIretval != SUCCESS) {
895
      udi_warning(UDIretval);
896
      return(FAILURE);
897
  };
898
  /* Successful */
899
  if (( UDIretval = UDISetCurrentProcess((UDIPId) CurrentPID))
900
                                                         <= TIPFAILURE) {
901
       PrintErrorMessage (UDIretval);
902
      return(FAILURE);
903
  } else if (UDIretval != SUCCESS) {
904
      udi_warning(UDIretval);
905
      return(FAILURE);
906
  };
907
  return (SUCCESS);
908
}
909
 
910
/* Write memory or registers to target  */
911
INT32
912
/**********************************************Mini_write_req   */
913
Mini_write_req(m_space, address, byte_count, size, count_done,
914
               buffer, host_endian)
915
  INT32        m_space;
916
  ADDR32          address;
917
  INT32        byte_count;
918
  INT16         size;
919
  INT32       *count_done;
920
  BYTE           *buffer;
921
  INT32        host_endian;
922
{
923
  UDIError      UDIretval;
924
  UDIResource   to;
925
 
926
  to.Space = xlate_mspace_mon2udi(m_space);
927
  to.Offset = address;
928
 
929
  if ((UDIretval = UDIWrite((UDIHostMemPtr) buffer,
930
                            to,
931
                            (UDICount) byte_count,
932
                            (UDISizeT) size,
933
                            (UDICount *) count_done,
934
                            (UDIBool) host_endian)) <= TIPFAILURE) {
935
        PrintErrorMessage (UDIretval);
936
       return(FAILURE);
937
  } else if (UDIretval == SUCCESS) {
938
      return(SUCCESS);
939
  } else {
940
      udi_warning(UDIretval);
941
      return(FAILURE);
942
  }
943
}
944
 
945
INT32
946
Mini_stdin_mode_x(mode)
947
INT32   *mode;
948
{
949
  UDIError      UDIretval;
950
 
951
  if ((UDIretval = UDIStdinMode ((UDIMode *) mode)) <= TIPFAILURE) {
952
        PrintErrorMessage (UDIretval);
953
        return (FAILURE);
954
  } else if (UDIretval == SUCCESS) {
955
        return(SUCCESS);
956
  } else {
957
        udi_warning(UDIretval);
958
        return(FAILURE);
959
  };
960
}
961
 
962
INT32
963
/**********************************************Mini_put_stdin   */
964
Mini_put_stdin(buffer, bufsize, count)
965
  char       *buffer;
966
  INT32        bufsize;
967
  INT32       *count;
968
{
969
  UDIError      UDIretval;
970
 
971
  if ((UDIretval = UDIPutStdin ((UDIHostMemPtr) buffer,
972
                                (UDISizeT) bufsize,
973
                                (UDISizeT *) count)) <= TIPFAILURE) {
974
        PrintErrorMessage (UDIretval);
975
        return (FAILURE);
976
  } else if (UDIretval == SUCCESS) {
977
        return(SUCCESS);
978
  } else {
979
        udi_warning(UDIretval);
980
        return(FAILURE);
981
  };
982
}
983
 
984
/* Put characters to stdout   */
985
 
986
 
987
INT32
988
/**********************************************Mini_get_stdout   */
989
Mini_get_stdout(buffer, bufsize, count_done)
990
  char       *buffer;
991
  INT32       *count_done;
992
  INT32        bufsize;
993
{
994
  UDIError      UDIretval;
995
 
996
  if ((UDIretval = UDIGetStdout ((UDIHostMemPtr) buffer,
997
                         (UDISizeT) bufsize,
998
                         (UDISizeT *) count_done)) <= TIPFAILURE) {
999
        PrintErrorMessage (UDIretval);
1000
        return (FAILURE);
1001
  } else if (UDIretval == SUCCESS) {
1002
        return(SUCCESS);
1003
  } else {
1004
        udi_warning(UDIretval);
1005
        return(FAILURE);
1006
  }
1007
}
1008
 
1009
INT32
1010
/**********************************************Mini_get_stderr   */
1011
Mini_get_stderr(buffer, bufsize, count_done)
1012
  char       *buffer;
1013
  INT32       *count_done;
1014
  INT32        bufsize;
1015
{
1016
  UDIError      UDIretval;
1017
  if ((UDIretval = UDIGetStderr ((UDIHostMemPtr) buffer,
1018
                         (UDISizeT) bufsize,
1019
                         (UDISizeT *) count_done)) <= TIPFAILURE) {
1020
        PrintErrorMessage (UDIretval);
1021
        return (FAILURE);
1022
  } else if (UDIretval == SUCCESS) {
1023
        return(SUCCESS);
1024
  } else {
1025
        udi_warning(UDIretval);
1026
        return(FAILURE);
1027
  }
1028
}
1029
 
1030
/* Step instructions   */
1031
 
1032
 
1033
INT32
1034
/**********************************************Mini_step   */
1035
Mini_step(count)
1036
INT32   count;
1037
{
1038
  UDIError      UDIretval;
1039
  UDIRange      dummy_range;
1040
  UDIStepType   step_type;
1041
 
1042
  dummy_range.Low = 0;
1043
  dummy_range.High = 0xffffffff;
1044
 
1045
  step_type = UDIStepNatural;
1046
 
1047
  if ((UDIretval = UDIStep((UDIUInt32) count,
1048
                           step_type,
1049
                           dummy_range)) <= TIPFAILURE) {
1050
        PrintErrorMessage (UDIretval);
1051
        return (FAILURE);
1052
  } else if (UDIretval == SUCCESS) {
1053
        return(SUCCESS);
1054
  } else {
1055
        udi_warning(UDIretval);
1056
        return(FAILURE);
1057
  };
1058
}
1059
 
1060
INT32
1061
/***************************************************** Mini_put_trans */
1062
Mini_put_trans(buffer)
1063
char    *buffer;
1064
{
1065
  UDIError      UDIretval;
1066
  UDISizeT      count;
1067
  UDISizeT      *count_done;
1068
 
1069
  count = (UDISizeT) (strlen (buffer) + 1);
1070
  if ((UDIretval = UDIPutTrans((UDIHostMemPtr) buffer,
1071
                               (UDISizeT) count,
1072
                               (UDISizeT *) count_done)) <= TIPFAILURE) {
1073
        PrintErrorMessage (UDIretval);
1074
        return (FAILURE);
1075
  } else if (UDIretval == SUCCESS) {
1076
        return(SUCCESS);
1077
  } else {
1078
        udi_warning(UDIretval);
1079
        return(FAILURE);
1080
  };
1081
 
1082
}
1083
 
1084
 
1085
static CPUSpace
1086
xlate_mspace_mon2udi(m_space)
1087
INT32   m_space;
1088
{
1089
  switch(m_space) {
1090
    case        LOCAL_REG:
1091
        return((CPUSpace) UDI29KLocalRegs);
1092
    case        ABSOLUTE_REG:
1093
        return((CPUSpace) UDI29KGlobalRegs);
1094
    case        GLOBAL_REG:
1095
        return((CPUSpace) UDI29KGlobalRegs);
1096
    case        SPECIAL_REG:
1097
        return((CPUSpace) UDI29KSpecialRegs);
1098
    case        TLB_REG:
1099
        return((CPUSpace) UDI29KTLBRegs);
1100
    case        COPROC_REG:
1101
        return((CPUSpace) UDI29KAm29027Regs);
1102
    case        I_MEM:
1103
        return((CPUSpace) UDI29KIRAMSpace);
1104
    case        D_MEM:
1105
        return((CPUSpace) UDI29KDRAMSpace);
1106
    case        I_ROM:
1107
        return((CPUSpace) UDI29KIROMSpace);
1108
    case        D_ROM:
1109
        return((CPUSpace) UDI29KDRAMSpace);
1110
    case        I_O:
1111
        return((CPUSpace) UDI29KIOSpace);
1112
    case        I_CACHE:
1113
        return((CPUSpace) UDI29KICacheSpace);
1114
    case        D_CACHE:
1115
        return((CPUSpace) UDI29KDCacheSpace);
1116
    case        PC_SPACE:
1117
        return((CPUSpace) UDI29KPC);
1118
    case        A_SPCL_REG:
1119
        return((CPUSpace) UDI29KSpecialRegs);
1120
    case        GENERIC_SPACE:
1121
        return ((CPUSpace) UDI29KDRAMSpace);
1122
    case        VERSION_SPACE:
1123
        return ((CPUSpace) VERSION_SPACE);
1124
    default:
1125
        return((CPUSpace) FAILURE);
1126
  };
1127
}
1128
 
1129
static INT32
1130
xlate_mspace_udi2mon(mspace)
1131
CPUSpace        mspace;
1132
{
1133
   switch(mspace) {
1134
     case       UDI29KDRAMSpace:
1135
        return((INT32) D_MEM);
1136
     case       UDI29KIOSpace:
1137
        return((INT32) I_O);
1138
     case       UDI29KCPSpace0:
1139
        return((INT32) FAILURE);
1140
     case       UDI29KCPSpace1:
1141
        return((INT32) FAILURE);
1142
     case       UDI29KIROMSpace:
1143
        return((INT32) I_ROM);
1144
     case       UDI29KIRAMSpace:
1145
        return((INT32) I_MEM);
1146
     case       UDI29KLocalRegs:
1147
        return((INT32) LOCAL_REG);
1148
     case       UDI29KGlobalRegs:
1149
        return((INT32) GLOBAL_REG);
1150
     case       UDI29KRealRegs:
1151
        return((INT32) GLOBAL_REG);
1152
     case       UDI29KSpecialRegs:
1153
        return((INT32) SPECIAL_REG);
1154
     case       UDI29KTLBRegs:
1155
        return((INT32) TLB_REG);
1156
     case       UDI29KACCRegs:
1157
        return((INT32) FAILURE);
1158
     case       UDI29KICacheSpace:
1159
        return((INT32) I_CACHE);
1160
     case       UDI29KAm29027Regs:
1161
        return((INT32) COPROC_REG);
1162
     case       UDI29KPC:
1163
        return((INT32) PC_SPACE);
1164
     case       UDI29KDCacheSpace:
1165
        return((INT32) D_CACHE);
1166
     default:
1167
        return(FAILURE);
1168
   };
1169
}
1170
 
1171
static
1172
void udi_warning(num)
1173
int     num;
1174
{
1175
  fprintf(stderr, "UDIERROR: %d : %s\n", num, udi_errmsg[num]);
1176
  fflush(stderr);
1177
  if (io_config.echo_mode == (INT32) TRUE) {
1178
     fprintf(io_config.echo_file, "UDIERROR: %d :%s\n", num, udi_errmsg[num]);
1179
     fflush (io_config.echo_file);
1180
  }
1181
}
1182
 
1183
static void
1184
PrintErrorMessage(UDIretval)
1185
UDIError        UDIretval;
1186
{
1187
    UDISizeT    ErrorMsgCnt;
1188
 
1189
    fprintf(stderr, "TIPERROR: %d :", UDIretval);
1190
    fflush(stderr);
1191
    if (io_config.echo_mode == (INT32) TRUE) {
1192
       fprintf(io_config.echo_file, "TIPERROR: %d :", UDIretval);
1193
       fflush(io_config.echo_file);
1194
    }
1195
 
1196
    ErrorMsgCnt = (UDISizeT) 0;
1197
    do {
1198
       if (UDIGetErrorMsg(UDIretval,
1199
                             (UDISizeT) MONErrorMsgSize,
1200
                             MONErrorMsg, &ErrorMsgCnt) != UDINoError) {
1201
           fprintf(stderr, "TIPERROR: Could not get TIP error message.\n");
1202
           fflush(stderr);
1203
           return;
1204
        }
1205
       write (fileno(stderr), &MONErrorMsg[0], (int) ErrorMsgCnt);
1206
       if (io_config.echo_mode == (INT32) TRUE)
1207
          write (fileno(io_config.echo_file), &MONErrorMsg[0], (int) ErrorMsgCnt);
1208
    } while (ErrorMsgCnt == (UDISizeT) MONErrorMsgSize);
1209
    fprintf(stderr, "\n");
1210
    if (io_config.echo_mode == (INT32) TRUE) {
1211
       fprintf(io_config.echo_file, "\n");
1212
       fflush(io_config.echo_file);
1213
    }
1214
    return;
1215
}
1216
 
1217
static UDIError
1218
FillWords(from, pattern, pattern_count, fill_count)
1219
UDIResource     from;
1220
UDIHostMemPtr   pattern;
1221
UDISizeT        pattern_count;
1222
UDICount        fill_count;
1223
{
1224
   UDICount     count_done;
1225
   UDIBool      host_endian, direction;
1226
   UDIError     UDIretval;
1227
   UDIResource  to;
1228
 
1229
   INT32        isregspace = ISREG(xlate_mspace_udi2mon(from.Space));
1230
 
1231
   host_endian = FALSE;
1232
 
1233
        if ((UDIretval = UDIWrite((UDIHostMemPtr) pattern,
1234
                               from,
1235
                               (UDICount) 1,
1236
                               (UDISizeT) pattern_count,
1237
                               (UDICount *) &count_done,
1238
                               host_endian)) <= TIPFAILURE) {
1239
           PrintErrorMessage (UDIretval);
1240
           return (FAILURE);
1241
        } else if (UDIretval == SUCCESS) {  /* do copy */
1242
           fill_count = fill_count - 1; /* one less */
1243
           if (fill_count > (INT32) 0) { /* do copy */
1244
              if (isregspace)
1245
                   to.Offset = from.Offset + (pattern_count/4);
1246
              else
1247
                   to.Offset = from.Offset + pattern_count;
1248
              to.Space = from.Space; /* already translated */
1249
              direction = TRUE; /* front to back */
1250
              if (pattern_count > (INT32) 4) { /* is a multiple of 4 also */
1251
                 fill_count = (INT32) (fill_count * (pattern_count/4));
1252
                 pattern_count = (INT32) 4;
1253
              };
1254
              if ((UDIretval = UDICopy (from,
1255
                             to,
1256
                             fill_count,
1257
                             (UDISizeT) pattern_count,
1258
                             (UDICount *) &count_done,
1259
                             direction)) <= TIPFAILURE) {
1260
                  PrintErrorMessage (UDIretval);
1261
                  return (FAILURE);
1262
              } else if (UDIretval == SUCCESS) {
1263
                 return(SUCCESS);
1264
              } else {
1265
                 udi_warning(UDIretval);
1266
                 return(FAILURE);
1267
              }
1268
           };
1269
           /* return if no more to copy */
1270
           return(SUCCESS);
1271
        } else {
1272
           udi_warning(UDIretval);
1273
           return(FAILURE);
1274
        };
1275
}
1276
 
1277
static UDIError
1278
FillString(from, pattern, pattern_count, fill_count)
1279
UDIResource     from;
1280
UDIHostMemPtr   pattern;
1281
UDISizeT        pattern_count;
1282
UDICount        fill_count;
1283
{
1284
   UDICount     count_done;
1285
   UDIBool      host_endian, direction;
1286
   UDIError     UDIretval;
1287
   UDIResource  to;
1288
 
1289
   host_endian = FALSE;
1290
 
1291
        if ((UDIretval = UDIWrite((UDIHostMemPtr) pattern,
1292
                               from,
1293
                               (UDICount) pattern_count,
1294
                               (UDISizeT) 1,
1295
                               (UDICount *) &count_done,
1296
                               host_endian)) <= TIPFAILURE) {
1297
           PrintErrorMessage (UDIretval);
1298
           return (FAILURE);
1299
        } else if (UDIretval == SUCCESS) {  /* do copy */
1300
           fill_count = fill_count - 1; /* one less */
1301
           if (fill_count > (INT32) 0) { /* do copy */
1302
              to.Offset = from.Offset + pattern_count;
1303
              to.Space = from.Space;
1304
              direction = TRUE; /* front to back */
1305
              if ((UDIretval = UDICopy (from,
1306
                             to,
1307
                             (UDICount) (fill_count*pattern_count),
1308
                             (UDISizeT) 1,
1309
                             (UDICount *) &count_done,
1310
                             direction)) <= TIPFAILURE) {
1311
                  PrintErrorMessage (UDIretval);
1312
                  return (FAILURE);
1313
              } else if (UDIretval == SUCCESS) {
1314
                 return(SUCCESS);
1315
              } else {
1316
                 udi_warning(UDIretval);
1317
                 return(FAILURE);
1318
              }
1319
           };
1320
           /* return if no more to copy */
1321
           return(SUCCESS);
1322
        } else {
1323
           udi_warning(UDIretval);
1324
           return(FAILURE);
1325
        };
1326
}

powered by: WebSVN 2.1.0

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