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

Subversion Repositories or1k

[/] [or1k/] [branches/] [oc/] [gdb-5.0/] [utils/] [amd-udi/] [mondfe/] [fill.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 _[] = "@(#)fill.c   5.20 93/07/30 16:38:31, 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
 **
30
 **       This code provides "fill" routines to fill memory and
31
 **       registers.  Data may be set as words (32 bit), half-words (16
32
 **       bit), bytes (8 bit), float (32 bit floating point) or double
33
 **       (64 bit floating point).
34
 **
35
 **       Since registers are 32 bits long, the fill byte and fill half
36
 **       commands will only be permitted for memory accesses.
37
 *****************************************************************************
38
 */
39
 
40
#include <stdio.h>
41
#include <string.h>
42
#include <ctype.h>
43
#include <memory.h>
44
#include "main.h"
45
#include "memspcs.h"
46
#include "miniint.h"
47
#include "macros.h"
48
#include "error.h"
49
 
50
 
51
#ifdef MSDOS
52
#include <stdlib.h>
53
#else
54
#include <malloc.h>
55
#endif
56
 
57
int   get_addr_29k PARAMS((char *, struct addr_29k_t *));
58
int   addr_29k_ok PARAMS((struct addr_29k_t *));
59
 
60
int   get_word PARAMS((char *, INT32 *));
61
int   get_half PARAMS((char *, INT16 *));
62
int   get_byte PARAMS((char *, BYTE *));
63
int   get_float PARAMS((char *, float *));
64
int   get_double PARAMS((char *, double *));
65
 
66
int   set_data PARAMS((BYTE *, BYTE *, int));
67
 
68
 
69
/*
70
** The function below is used in filling data.  This function is
71
** called in the main command loop parser of the monitor.  The
72
** parameters passed to this function are:
73
**
74
** token - This is an array of pointers to strings.  Each string
75
**         referenced by this array is a "token" of the user's
76
**         input, translated to lower case.
77
**
78
** token_count - This is the number of items in the token array.
79
**
80
** This function reduces the tokens to four parameters:
81
** the start address of the fill, the end address ofthe fill and
82
** and the data to be filled in this range.  This data
83
** is one of the "temp_" variables.
84
**
85
*/
86
 
87
#define MAX_FILL_LEN    128
88
 
89
INT32
90
fill_cmd(token, token_count)
91
   char   *token[];
92
   int     token_count;
93
   {
94
   int    result;
95
   INT32  object_size;
96
   INT32  align_mask;
97
   INT32  fill_count;
98
   struct addr_29k_t addr_29k_start;
99
   struct addr_29k_t addr_29k_end;
100
   INT32  temp_word;
101
   INT16  temp_half;
102
   BYTE   temp_byte;
103
   float  temp_float;
104
   double temp_double;
105
 
106
   INT32        retval;
107
   BYTE         fill_data[MAX_FILL_LEN];
108
 
109
 
110
   if (token_count < 4) {
111
      return (EMSYNTAX);
112
      }
113
 
114
   /*
115
   ** What is the data format?
116
   */
117
 
118
   if ((strcmp(token[0], "f") == 0) ||
119
       (strcmp(token[0], "fw") == 0)) {
120
      object_size = sizeof(INT32);
121
      align_mask = 0xfffffffc;
122
      result = get_word(token[3], &temp_word);
123
      if (result != 0)
124
         return (EMSYNTAX);
125
      result = set_data( fill_data, (BYTE *)&temp_word, sizeof(INT32));
126
      if (result != 0)
127
         return (EMSYNTAX);
128
      }
129
   else
130
   if (strcmp(token[0], "fh") == 0) {
131
      object_size = sizeof(INT16);
132
      align_mask = 0xfffffffe;
133
      result = get_half(token[3], &temp_half);
134
      if (result != 0)
135
         return (EMSYNTAX);
136
      result = set_data( fill_data, (BYTE *)&temp_half, sizeof(INT16));
137
      if (result != 0)
138
         return (EMSYNTAX);
139
      }
140
   else
141
   if (strcmp(token[0], "fb") == 0) {
142
      object_size = sizeof(BYTE);
143
      align_mask = 0xffffffff;
144
      result = get_byte(token[3], &temp_byte);
145
      if (result != 0)
146
         return (EMSYNTAX);
147
      result = set_data(fill_data, (BYTE *)&temp_byte, sizeof(BYTE));
148
      if (result != 0)
149
         return (EMSYNTAX);
150
      }
151
   else
152
   if (strcmp(token[0], "ff") == 0) {
153
      object_size = sizeof(float);
154
      align_mask = 0xfffffffc;
155
      result = get_float(token[3], &temp_float);
156
      if (result != 0)
157
         return (EMSYNTAX);
158
      result = set_data(fill_data, (BYTE *)&temp_float, sizeof(float));
159
      if (result != 0)
160
         return (EMSYNTAX);
161
      }
162
   else
163
   if (strcmp(token[0], "fd") == 0) {
164
      object_size = sizeof(double);
165
      align_mask = 0xfffffffc;
166
      result = get_double(token[3], &temp_double);
167
      if (result != 0)
168
         return (EMSYNTAX);
169
      result = set_data(fill_data, (BYTE *)&temp_double, sizeof(double));
170
      if (result != 0)
171
         return (EMSYNTAX);
172
      }
173
   else
174
   if (strcmp(token[0], "fs") == 0) { /* fill_data a string */
175
      object_size = (INT32) strlen ((char *) token[3]);
176
      if ((int) object_size >= (int) MAX_FILL_LEN)
177
        return (EMSYNTAX);
178
      align_mask = 0xfffffffc;
179
      (void) memset ((char *) fill_data, (int) '\0', sizeof(fill_data));
180
      (void) strcpy ((char *)&fill_data[0], (char *) token[3]);
181
      }
182
   else
183
      return(EMSYNTAX);
184
 
185
   /*
186
   ** Get addresses
187
   */
188
 
189
   result = get_addr_29k(token[1], &addr_29k_start);
190
   if (result != 0)
191
      return (EMSYNTAX);
192
   result = addr_29k_ok(&addr_29k_start);
193
   if (result != 0)
194
      return (result);
195
 
196
   result = get_addr_29k(token[2], &addr_29k_end);
197
   if (result != 0)
198
      return (EMSYNTAX);
199
   result = addr_29k_ok(&addr_29k_end);
200
   if (result != 0)
201
      return (result);
202
 
203
   /* Memory spaces must be the same */
204
   if (addr_29k_start.memory_space != addr_29k_end.memory_space)
205
      return (EMSYNTAX);
206
 
207
   /* No need to align registers */
208
   if (ISREG(addr_29k_start.memory_space))
209
      align_mask = 0xffffffff;
210
 
211
   /* Align addresses */
212
   addr_29k_start.address = (addr_29k_start.address & align_mask);
213
   addr_29k_end.address = (addr_29k_end.address & align_mask);
214
 
215
   /* End address must be larger than start address */
216
   if (addr_29k_start.address > addr_29k_end.address)
217
      return (EMSYNTAX);
218
 
219
   if (ISREG(addr_29k_end.memory_space)) {
220
      fill_count = ((addr_29k_end.address -
221
                     addr_29k_start.address + 1) * 4) /
222
                    object_size;
223
      }
224
   else
225
   if (ISMEM(addr_29k_end.memory_space)) {
226
      fill_count = (addr_29k_end.address -
227
                    addr_29k_start.address +
228
                    object_size) / object_size;
229
      }
230
   else
231
      return (EMSYNTAX);
232
 
233
   /*
234
   ** We don't set bytes or half words in registers
235
   */
236
 
237
   if (ISREG(addr_29k_start.memory_space) &&
238
        (object_size < sizeof(INT32)))
239
      return (EMSYNTAX);
240
 
241
   if ((retval = Mini_fill (addr_29k_start.memory_space,
242
                            addr_29k_start.address,
243
                            fill_count,
244
                            object_size,
245
                            fill_data)) <= TIPFAILURE) {
246
        return(FAILURE);
247
   } else if (retval == SUCCESS) {
248
      return(SUCCESS);
249
   } else {
250
      warning(retval);
251
      return(FAILURE);
252
   };
253
 
254
   }  /* end set_cmd() */
255
 
256
 
257
 

powered by: WebSVN 2.1.0

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