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

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [gdb-5.0/] [utils/] [amd-udi/] [mondfe/] [set.c] - Blame information for rev 1778

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

Line No. Rev Author Line
1 106 markom
static char _[] = "@(#)set.c    5.20 93/07/30 16:39:00, 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 provides "set" routines to set memory and
30
 **       registers.  Data may be set as words (32 bit), half-words
31
 **       (16 bit), bytes (8 bit), float (32 bit floating point) or
32
 **       double (64 bit floating point).
33
 **
34
 **       Since registers are 32 bits long, the set byte and set half
35
 **       commands will only be permitted for memory accesses.
36
 *****************************************************************************
37
 */
38
 
39
 
40
#include <stdio.h>
41
#include <ctype.h>
42
#include <memory.h>
43
#include "main.h"
44
#include "monitor.h"
45
#include "miniint.h"
46
#include "memspcs.h"
47
#include "macros.h"
48
#include "error.h"
49
 
50
 
51
#ifdef MSDOS
52
#include <stdlib.h>
53
#include <string.h>
54
#else
55
#include <string.h>
56
 
57
#endif
58
 
59
int   get_addr_29k PARAMS((char *, struct addr_29k_t *));
60
int   addr_29k_ok PARAMS((struct addr_29k_t *));
61
 
62
int   get_word PARAMS((char *, INT32 *));
63
int   get_half PARAMS((char *, INT16 *));
64
int   get_byte PARAMS((char *, BYTE *));
65
int   get_float PARAMS((char *, float *));
66
int   get_double PARAMS((char *, double *));
67
 
68
int   set_data PARAMS((BYTE *, BYTE *, int));
69
 
70
/*
71
** The function below is used in setting data.  This function is
72
** called in the main command loop parser of the monitor.  The
73
** parameters passed to this function are:
74
**
75
** token - This is an array of pointers to strings.  Each string
76
**         referenced by this array is a "token" of the user's
77
**         input, translated to lower case.
78
**
79
** token_count - This is the number of items in the token array.
80
**
81
** This function reduces the tokens to three parameters:
82
** memory_space, address and the data to be set.  This data
83
** is one of the "temp_" variables.
84
**
85
*/
86
 
87
 
88
INT32
89
set_cmd(token, token_count)
90
   char   *token[];
91
   int     token_count;
92
   {
93
   INT16  size;
94
   int    result;
95
   struct addr_29k_t addr_29k;
96
   int    set_format;
97
   INT32  temp_word;
98
   INT16  temp_half;
99
   BYTE   temp_byte;
100
   float  temp_float;
101
   double temp_double;
102
 
103
   INT32        retval;
104
   BYTE         write_buffer[16];  /* */
105
   INT32        bytes_ret;
106
   INT32        hostendian;     /* UDI conformant */
107
   INT32        count;
108
 
109
 
110
   if (token_count != 3) {
111
      return (EMSYNTAX);
112
      }
113
 
114
   /*
115
   ** What is the data format?
116
   */
117
 
118
   count = (INT32) 1;
119
   if ((strcmp(token[0], "s") == 0) ||
120
       (strcmp(token[0], "sw") == 0)) {
121
      set_format = WORD_FORMAT;
122
      size = (INT16) sizeof(INT32);
123
      result = get_word(token[2], &temp_word);
124
      if (result != 0)
125
         return (EMSYNTAX);
126
      result = set_data(write_buffer, (BYTE *)&temp_word, sizeof(INT32));
127
      if (result != 0)
128
         return (EMSYNTAX);
129
      }
130
   else
131
   if (strcmp(token[0], "sh") == 0) {
132
      set_format = HALF_FORMAT;
133
      size = (INT16) sizeof(INT16);
134
      result = get_half(token[2], &temp_half);
135
      if (result != 0)
136
         return (EMSYNTAX);
137
      result = set_data(write_buffer, (BYTE *)&temp_half, sizeof(INT16));
138
      if (result != 0)
139
         return (EMSYNTAX);
140
      }
141
   else
142
   if (strcmp(token[0], "sb") == 0) {
143
      set_format = BYTE_FORMAT;
144
      size = (INT16) sizeof(BYTE);
145
      result = get_byte(token[2], &temp_byte);
146
      if (result != 0)
147
         return (EMSYNTAX);
148
      result = set_data(write_buffer, (BYTE *)&temp_byte, sizeof(BYTE));
149
      if (result != 0)
150
         return (EMSYNTAX);
151
      }
152
   else
153
   if (strcmp(token[0], "sf") == 0) {
154
      set_format = FLOAT_FORMAT;
155
      size = (INT16) sizeof(float);
156
      result = get_float(token[2], &temp_float);
157
      if (result != 0)
158
         return (EMSYNTAX);
159
      result = set_data(write_buffer, (BYTE *)&temp_float, sizeof(float));
160
      if (result != 0)
161
         return (EMSYNTAX);
162
      }
163
   else
164
   if (strcmp(token[0], "sd") == 0) {
165
      set_format = DOUBLE_FORMAT;
166
      size = (INT16) sizeof(double);
167
      result = get_double(token[2], &temp_double);
168
      if (result != 0)
169
         return (EMSYNTAX);
170
      result = set_data(write_buffer, (BYTE *)&temp_double, sizeof(double));
171
      if (result != 0)
172
         return (EMSYNTAX);
173
      }
174
   else
175
      return(EMSYNTAX);
176
 
177
   /*
178
   ** Get address
179
   */
180
 
181
   result = get_addr_29k(token[1], &addr_29k);
182
   if (result != 0)
183
      return (EMSYNTAX);
184
   result = addr_29k_ok(&addr_29k);
185
   if (result != 0)
186
      return (result);
187
 
188
   /*
189
   ** We don't set bytes or half words in registers
190
   */
191
 
192
   if (((ISREG(addr_29k.memory_space)) &&
193
        (set_format == BYTE_FORMAT)) ||
194
 
195
      ((ISREG(addr_29k.memory_space)) &&
196
        (set_format == HALF_FORMAT)))
197
      return (EMSYNTAX);
198
 
199
   /* Will the data overflow the message buffer? Done in TIP */
200
 
201
   hostendian = FALSE;
202
   if ((retval = Mini_write_req (addr_29k.memory_space,
203
                                 addr_29k.address,
204
                                 count,
205
                                 (INT16) size,
206
                                 &bytes_ret,
207
                                 write_buffer,
208
                                 hostendian)) != SUCCESS) {
209
        return(FAILURE);
210
   } else
211
      return(SUCCESS);
212
 
213
   }  /* end set_cmd() */
214
 
215
 

powered by: WebSVN 2.1.0

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