1 |
106 |
markom |
/******************************************************************************
|
2 |
|
|
* Copyright 1991 Advanced Micro Devices, Inc.
|
3 |
|
|
*
|
4 |
|
|
* This software is the property of Advanced Micro Devices, Inc (AMD) which
|
5 |
|
|
* specifically grants the user the right to modify, use and distribute this
|
6 |
|
|
* software provided this notice is not removed or altered. All other rights
|
7 |
|
|
* are reserved by AMD.
|
8 |
|
|
*
|
9 |
|
|
* AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
|
10 |
|
|
* SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
|
11 |
|
|
* DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
|
12 |
|
|
* USE OF THIS SOFTWARE.
|
13 |
|
|
*
|
14 |
|
|
* So that all may benefit from your experience, please report any problems
|
15 |
|
|
* or suggestions about this software to the 29K Technical Support Center at
|
16 |
|
|
* 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
|
17 |
|
|
* 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
|
18 |
|
|
*
|
19 |
|
|
* Advanced Micro Devices, Inc.
|
20 |
|
|
* 29K Support Products
|
21 |
|
|
* Mail Stop 573
|
22 |
|
|
* 5900 E. Ben White Blvd.
|
23 |
|
|
* Austin, TX 78741
|
24 |
|
|
* 800-292-9263 (US)
|
25 |
|
|
*****************************************************************************
|
26 |
|
|
*/
|
27 |
|
|
static char soc2udip_c[]="@(#)soc2udip.c 2.14 Daniel Mann";
|
28 |
|
|
static char soc2udip_c_AMD[]="@(#)soc2udip.c 3.2, AMD";
|
29 |
|
|
/*
|
30 |
|
|
* This module converts UDI socket messages
|
31 |
|
|
* into UDI Procedural calls.
|
32 |
|
|
* It is used by TIP server processes
|
33 |
|
|
********************************************************************** HISTORY
|
34 |
|
|
*/
|
35 |
|
|
#include <stdio.h>
|
36 |
|
|
#include <stdio.h>
|
37 |
|
|
#include <errno.h>
|
38 |
|
|
#include <sys/types.h>
|
39 |
|
|
#include <sys/socket.h>
|
40 |
|
|
#include <sys/file.h>
|
41 |
|
|
#ifdef __hpux
|
42 |
|
|
#else
|
43 |
|
|
/* #include <sys/sockio.h> */
|
44 |
|
|
#endif
|
45 |
|
|
|
46 |
|
|
#include <sys/fcntl.h>
|
47 |
|
|
#include <netdb.h>
|
48 |
|
|
#include <netinet/in.h>
|
49 |
|
|
#include <signal.h>
|
50 |
|
|
#include <setjmp.h>
|
51 |
|
|
#include "udiproc.h"
|
52 |
|
|
#include "udisoc.h"
|
53 |
|
|
|
54 |
|
|
extern int errno;
|
55 |
|
|
|
56 |
|
|
/* local type decs. and macro defs. not in a .h file ************* MACRO/TYPE
|
57 |
|
|
*/
|
58 |
|
|
#define version_c 0x121 /* TIP-IPC version id */
|
59 |
|
|
#define PORT_NUM 7000
|
60 |
|
|
#define MAX_ERRNO 1
|
61 |
|
|
#define SOC_BUF_SIZE 4* 1024 /* size of socket comms buffer */
|
62 |
|
|
#define SBUF_SIZE 500 /* size of string buffer */
|
63 |
|
|
|
64 |
|
|
/* global dec/defs. which are not in a .h file ************* EXPORT DEC/DEFS
|
65 |
|
|
*/
|
66 |
|
|
|
67 |
|
|
/* local dec/defs. which are not in a .h file *************** LOCAL DEC/DEFS
|
68 |
|
|
*/
|
69 |
|
|
LOCAL UDIError tip_errno;
|
70 |
|
|
LOCAL int tip_sd;
|
71 |
|
|
LOCAL int connect_count = 0;
|
72 |
|
|
LOCAL int ns;
|
73 |
|
|
LOCAL int getlength;
|
74 |
|
|
LOCAL struct sockaddr getname;
|
75 |
|
|
LOCAL UDR udr;
|
76 |
|
|
LOCAL UDR* udrs = &udr;
|
77 |
|
|
LOCAL char sbuf[SBUF_SIZE]; /* String handler buffer */
|
78 |
|
|
LOCAL char* tip_errmsg[/*MAX_ERRNO*/] =
|
79 |
|
|
{ "Trying to present non negative error number to TIP "
|
80 |
|
|
};
|
81 |
|
|
|
82 |
|
|
LOCAL sig_handler(sig, code, scp, addr)
|
83 |
|
|
int sig;
|
84 |
|
|
int code;
|
85 |
|
|
struct sigcontext *scp;
|
86 |
|
|
char *addr;
|
87 |
|
|
{
|
88 |
|
|
if(sig == SIGUSR1)
|
89 |
|
|
{
|
90 |
|
|
UDIStop();
|
91 |
|
|
return;
|
92 |
|
|
}
|
93 |
|
|
if(sig == SIGIO )
|
94 |
|
|
{
|
95 |
|
|
return;
|
96 |
|
|
}
|
97 |
|
|
if(sig == SIGURG)
|
98 |
|
|
{
|
99 |
|
|
UDIStop();
|
100 |
|
|
return;
|
101 |
|
|
}
|
102 |
|
|
if(sig != -1)fprintf(stderr,
|
103 |
|
|
"\nTIP-ipc caught a signal %d, socket shutdown\n",sig);
|
104 |
|
|
#if 0
|
105 |
|
|
else fprintf(stderr,"\nTIP-ipc, socket shutdown\n");
|
106 |
|
|
#endif
|
107 |
|
|
sigblock(sigmask(SIGIO));
|
108 |
|
|
if(shutdown(tip_sd, 2))
|
109 |
|
|
fprintf(stderr, "TIP-ipc WARNING: socket shutdown failed");
|
110 |
|
|
if(udrs->domain == AF_UNIX)
|
111 |
|
|
if(unlink(udrs->soc_name))
|
112 |
|
|
fprintf(stderr,
|
113 |
|
|
"TIP-ipc WARNING: failed to unlink %s\n",udrs->soc_name);
|
114 |
|
|
exit(0);
|
115 |
|
|
}
|
116 |
|
|
/*********************************************************************** MAIN
|
117 |
|
|
*/
|
118 |
|
|
main(argc, argv)
|
119 |
|
|
int argc;
|
120 |
|
|
char* argv[];
|
121 |
|
|
{
|
122 |
|
|
char *domain_string = argv[1];
|
123 |
|
|
char *tip_string = argv[2];
|
124 |
|
|
struct sockaddr_in dfe_sockaddr;
|
125 |
|
|
struct sockaddr_in tip_sockaddr_in;
|
126 |
|
|
struct sockaddr tip_sockaddr;
|
127 |
|
|
struct hostent *tip_info_p;
|
128 |
|
|
int dfe_addrlen;
|
129 |
|
|
int domain;
|
130 |
|
|
int pgrp;
|
131 |
|
|
#define NAME_LEN 20
|
132 |
|
|
char tip_host[NAME_LEN];
|
133 |
|
|
|
134 |
|
|
pgrp = getpid();
|
135 |
|
|
setpgrp(0, pgrp); /* TIP not in same pgrp as DFE */
|
136 |
|
|
if(argc < 3)
|
137 |
|
|
{
|
138 |
|
|
TIPPrintUsage(argv[0]);
|
139 |
|
|
fprintf(stderr,"TIP UDI-IPC Version %d.%d.%d\n",
|
140 |
|
|
(version_c&0xf00)>>8, (version_c&0x0f0)>>4, (version_c&0x00f));
|
141 |
|
|
exit(1);
|
142 |
|
|
}
|
143 |
|
|
|
144 |
|
|
signal(SIGINT, sig_handler);
|
145 |
|
|
signal(SIGKILL, sig_handler);
|
146 |
|
|
signal(SIGQUIT, sig_handler);
|
147 |
|
|
signal(SIGTERM, sig_handler);
|
148 |
|
|
signal(SIGSEGV, sig_handler);
|
149 |
|
|
signal(SIGURG, sig_handler);
|
150 |
|
|
signal(SIGIO, sig_handler);
|
151 |
|
|
signal(SIGUSR1, sig_handler);
|
152 |
|
|
|
153 |
|
|
/*----------------------------------------------------------------- SOCKET */
|
154 |
|
|
if(!strcmp(domain_string, "AF_UNIX"))
|
155 |
|
|
domain = AF_UNIX;
|
156 |
|
|
else if(!strcmp(domain_string, "AF_INET"))
|
157 |
|
|
domain = AF_INET;
|
158 |
|
|
else
|
159 |
|
|
{ fprintf(stderr, " TIP-ipc ERROR: address family not known\n");
|
160 |
|
|
exit(1);
|
161 |
|
|
}
|
162 |
|
|
tip_sd = socket(domain, SOCK_STREAM, 0);
|
163 |
|
|
if (tip_sd == -1 )
|
164 |
|
|
{ perror(" TIP-ipc ERROR, server socket() call failed");
|
165 |
|
|
sig_handler(-1);
|
166 |
|
|
}
|
167 |
|
|
/*------------------------------------------------------------------- BIND */
|
168 |
|
|
if(domain==AF_UNIX)
|
169 |
|
|
{
|
170 |
|
|
memset( (char*)&tip_sockaddr, 0, sizeof(tip_sockaddr));
|
171 |
|
|
tip_sockaddr.sa_family = domain;
|
172 |
|
|
bcopy(tip_string, tip_sockaddr.sa_data, strlen(tip_string));
|
173 |
|
|
if (bind(tip_sd, &tip_sockaddr, sizeof(tip_sockaddr)) )
|
174 |
|
|
{ perror("TIP-ipc WARNING, server bind() failed");
|
175 |
|
|
}
|
176 |
|
|
}
|
177 |
|
|
else if(domain == AF_INET)
|
178 |
|
|
{
|
179 |
|
|
if(gethostname(tip_host, NAME_LEN))
|
180 |
|
|
{ fprintf(stderr,"TIP-ipc ERROR, unable to get TIP host name");
|
181 |
|
|
exit(1);
|
182 |
|
|
}
|
183 |
|
|
memset( (char*)&tip_sockaddr_in, 0, sizeof(tip_sockaddr_in));
|
184 |
|
|
tip_sockaddr_in.sin_family = domain;
|
185 |
|
|
tip_sockaddr_in.sin_family = AF_INET;
|
186 |
|
|
tip_sockaddr_in.sin_addr.s_addr = inet_addr(tip_host);
|
187 |
|
|
if( tip_sockaddr_in.sin_addr.s_addr == -1)
|
188 |
|
|
{
|
189 |
|
|
tip_info_p = gethostbyname(tip_host); /* use host name */
|
190 |
|
|
if( tip_info_p == NULL)
|
191 |
|
|
{ fprintf(stderr," TIP-ipc ERROR, %s not found in /etc/hosts\n",
|
192 |
|
|
tip_host);
|
193 |
|
|
exit(1);
|
194 |
|
|
}
|
195 |
|
|
bcopy(tip_info_p->h_addr, (char *) &tip_sockaddr_in.sin_addr,
|
196 |
|
|
tip_info_p->h_length);
|
197 |
|
|
}
|
198 |
|
|
tip_sockaddr_in.sin_port = htons(atoi(tip_string));
|
199 |
|
|
if (bind(tip_sd, &tip_sockaddr_in, sizeof(tip_sockaddr_in)))
|
200 |
|
|
{ perror(" TIP-ipc WARNING, server bind() failed");
|
201 |
|
|
}
|
202 |
|
|
}
|
203 |
|
|
/*----------------------------------------------------------------- LISTEN */
|
204 |
|
|
if(listen(tip_sd,1))
|
205 |
|
|
{ perror(" TIP-ipc ERROR, server listen failed");
|
206 |
|
|
sig_handler(-1);
|
207 |
|
|
}
|
208 |
|
|
/*----------------------------------------------------------------- ACCEPT */
|
209 |
|
|
while(1)
|
210 |
|
|
{ while(1)
|
211 |
|
|
{ dfe_addrlen = sizeof(dfe_sockaddr);
|
212 |
|
|
ns =accept(tip_sd, &dfe_sockaddr, &dfe_addrlen);
|
213 |
|
|
if(ns == -1)
|
214 |
|
|
{ if(errno == EINTR) continue;
|
215 |
|
|
perror(" TIP-ipc ERROR, server accept call");
|
216 |
|
|
sig_handler(-1);
|
217 |
|
|
}
|
218 |
|
|
else break;
|
219 |
|
|
}
|
220 |
|
|
errno = 0;
|
221 |
|
|
if(domain == AF_INET)
|
222 |
|
|
{
|
223 |
|
|
#ifdef __hpux
|
224 |
|
|
#else
|
225 |
|
|
if(fcntl(ns, F_SETOWN, getpid()) == -1)
|
226 |
|
|
{ perror(" TIP-ipc, fcntl(..F_SETOWN) call: ");
|
227 |
|
|
sig_handler(-1);
|
228 |
|
|
}
|
229 |
|
|
if(fcntl(ns, F_SETFL, FASYNC) == -1)
|
230 |
|
|
{ perror(" TIP-ipc, fcntl(..FASYNC) call: ");
|
231 |
|
|
sig_handler(-1);
|
232 |
|
|
}
|
233 |
|
|
#endif
|
234 |
|
|
}
|
235 |
|
|
udr_create(udrs, ns, SOC_BUF_SIZE);
|
236 |
|
|
udrs->domain = domain;
|
237 |
|
|
udrs->soc_name = tip_string;
|
238 |
|
|
service();
|
239 |
|
|
udr_free(udrs);
|
240 |
|
|
}
|
241 |
|
|
}
|
242 |
|
|
|
243 |
|
|
/******************************************************************** SERVICE
|
244 |
|
|
* Service each DFE request as they arrive.
|
245 |
|
|
*/
|
246 |
|
|
service()
|
247 |
|
|
{
|
248 |
|
|
UDIInt32 service_id; /* requested DFE service */
|
249 |
|
|
|
250 |
|
|
for(;;)
|
251 |
|
|
{
|
252 |
|
|
tip_errno = 0;
|
253 |
|
|
udrs->udr_op = UDR_DECODE;
|
254 |
|
|
if(udr_UDIInt32(udrs, &service_id))
|
255 |
|
|
{ connect_count--;
|
256 |
|
|
return -1;
|
257 |
|
|
}
|
258 |
|
|
switch(service_id)
|
259 |
|
|
{
|
260 |
|
|
default:
|
261 |
|
|
{
|
262 |
|
|
break;
|
263 |
|
|
}
|
264 |
|
|
/*----------------------------------------------------------------- UDIConnect
|
265 |
|
|
*/
|
266 |
|
|
case UDIConnect_c:
|
267 |
|
|
{
|
268 |
|
|
char* Config; /* in -- identification string */
|
269 |
|
|
UDISessionId Session; /* out -- session ID */
|
270 |
|
|
int tip_pid; /* pid of TIP process */
|
271 |
|
|
UDIUInt32 TIPIPCId;
|
272 |
|
|
UDIUInt32 DFEIPCId;
|
273 |
|
|
|
274 |
|
|
udr_UDIUInt32(udrs, &DFEIPCId); /* recv all "in" params */
|
275 |
|
|
if ((DFEIPCId & 0xfff) < version_c) {
|
276 |
|
|
fprintf(stderr, "TIP-ipc: Connect from obsolete DFE\n");
|
277 |
|
|
sig_handler(-1);
|
278 |
|
|
}
|
279 |
|
|
udr_string(udrs, sbuf);
|
280 |
|
|
|
281 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
282 |
|
|
tip_errno = UDIConnect(sbuf, &Session);
|
283 |
|
|
if( tip_errno <= UDINoError) connect_count++;
|
284 |
|
|
TIPIPCId = (company_c << 16) + (product_c << 12) + version_c;
|
285 |
|
|
udr_UDIUInt32(udrs, &TIPIPCId);
|
286 |
|
|
tip_pid = getpid();
|
287 |
|
|
udr_UDIInt32(udrs, &tip_pid);
|
288 |
|
|
udr_UDISessionId(udrs, &Session);
|
289 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
290 |
|
|
udr_sendnow(udrs);
|
291 |
|
|
break;
|
292 |
|
|
}
|
293 |
|
|
/*-------------------------------------------------------------- UDIDisconnect
|
294 |
|
|
*/
|
295 |
|
|
case UDIDisconnect_c:
|
296 |
|
|
{
|
297 |
|
|
UDISessionId Session; /* In */
|
298 |
|
|
UDIBool Terminate; /* In */
|
299 |
|
|
|
300 |
|
|
udr_UDISessionId(udrs, &Session);
|
301 |
|
|
udr_UDIBool(udrs, &Terminate);
|
302 |
|
|
|
303 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
304 |
|
|
tip_errno = UDIDisconnect(Session, Terminate);
|
305 |
|
|
if( tip_errno == UDINoError) connect_count--;
|
306 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
307 |
|
|
udr_sendnow(udrs);
|
308 |
|
|
if(Terminate != UDIContinueSession && connect_count == 0)
|
309 |
|
|
{
|
310 |
|
|
#if 0
|
311 |
|
|
fprintf(stderr, "\nTIP-ipc: DFE has disconnected all sessions\n");
|
312 |
|
|
#endif
|
313 |
|
|
sig_handler(-1);
|
314 |
|
|
}
|
315 |
|
|
if(connect_count == 0) return;
|
316 |
|
|
break;
|
317 |
|
|
}
|
318 |
|
|
/*-------------------------------------------------------------------- UDIKill
|
319 |
|
|
*/
|
320 |
|
|
case UDIKill_c:
|
321 |
|
|
{
|
322 |
|
|
UDISessionId Session; /* In */
|
323 |
|
|
UDIInt32 signal; /* In */
|
324 |
|
|
|
325 |
|
|
udr_UDISessionId(udrs, &Session);
|
326 |
|
|
udr_UDIInt32(udrs, signal);
|
327 |
|
|
|
328 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
329 |
|
|
tip_errno = 0;
|
330 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
331 |
|
|
udr_sendnow(udrs);
|
332 |
|
|
if(connect_count == 0)
|
333 |
|
|
{
|
334 |
|
|
#if 0
|
335 |
|
|
fprintf(stderr, "\nTIP-ipc: DFE has disconnected all sessions\n");
|
336 |
|
|
#endif
|
337 |
|
|
sig_handler(-1);
|
338 |
|
|
}
|
339 |
|
|
break;
|
340 |
|
|
}
|
341 |
|
|
/*---------------------------------------------------- UDISetCurrentConnection
|
342 |
|
|
*/
|
343 |
|
|
case UDISetCurrentConnection_c:
|
344 |
|
|
{
|
345 |
|
|
UDISessionId Session; /* In */
|
346 |
|
|
|
347 |
|
|
udr_UDISessionId(udrs, &Session);
|
348 |
|
|
|
349 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
350 |
|
|
tip_errno = UDISetCurrentConnection(Session);
|
351 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
352 |
|
|
udr_sendnow(udrs);
|
353 |
|
|
break;
|
354 |
|
|
}
|
355 |
|
|
/*------------------------------------------------------------ UDICapabilities
|
356 |
|
|
*/
|
357 |
|
|
case UDICapabilities_c:
|
358 |
|
|
{
|
359 |
|
|
UDIUInt32 TIPId; /* out */
|
360 |
|
|
UDIUInt32 TargetId; /* out */
|
361 |
|
|
UDIUInt32 DFEId; /* in */
|
362 |
|
|
UDIUInt32 DFE; /* in */
|
363 |
|
|
UDIUInt32 TIP; /* out */
|
364 |
|
|
UDIUInt32 DFEIPCId; /* out */
|
365 |
|
|
UDIUInt32 TIPIPCId; /* out */
|
366 |
|
|
char *TIPString = sbuf; /* out */
|
367 |
|
|
|
368 |
|
|
strcpy(TIPString, "No TIP Capability string");
|
369 |
|
|
udr_UDIUInt32(udrs, &DFEId);
|
370 |
|
|
udr_UDIUInt32(udrs, &DFE);
|
371 |
|
|
|
372 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" paramters */
|
373 |
|
|
tip_errno = UDICapabilities( &TIPId, &TargetId, DFEId, DFE,
|
374 |
|
|
&TIP, &DFEIPCId, &TIPIPCId, TIPString);
|
375 |
|
|
udr_UDIUInt32(udrs, &TIPId);
|
376 |
|
|
udr_UDIUInt32(udrs, &TargetId);
|
377 |
|
|
udr_UDIUInt32(udrs, &TIP);
|
378 |
|
|
udr_UDIUInt32(udrs, &DFEIPCId);
|
379 |
|
|
TIPIPCId = (company_c << 16) + (product_c << 12) + version_c;
|
380 |
|
|
udr_UDIUInt32(udrs, &TIPIPCId);
|
381 |
|
|
udr_string(udrs, TIPString);
|
382 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
383 |
|
|
udr_sendnow(udrs);
|
384 |
|
|
break;
|
385 |
|
|
}
|
386 |
|
|
/*------------------------------------------------------------- UDIGetErrorMsg
|
387 |
|
|
*/
|
388 |
|
|
case UDIGetErrorMsg_c:
|
389 |
|
|
{
|
390 |
|
|
UDIError error_code; /* In */
|
391 |
|
|
UDISizeT msg_len; /* In -- allowed message space */
|
392 |
|
|
char* msg = sbuf; /* Out -- length of message */
|
393 |
|
|
UDISizeT CountDone; /* Out -- number of chars */
|
394 |
|
|
|
395 |
|
|
strcpy(msg, "No TIP message");
|
396 |
|
|
udr_UDIError(udrs, &error_code); /* recv all "in" parameters */
|
397 |
|
|
udr_UDISizeT(udrs, &msg_len);
|
398 |
|
|
|
399 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
400 |
|
|
if(error_code < 0)
|
401 |
|
|
{
|
402 |
|
|
if(SBUF_SIZE < msg_len) msg_len = SBUF_SIZE;
|
403 |
|
|
tip_errno = UDIGetErrorMsg(error_code, msg_len, msg, &CountDone);
|
404 |
|
|
udr_string(udrs, msg);
|
405 |
|
|
}
|
406 |
|
|
else
|
407 |
|
|
{
|
408 |
|
|
udr_string(udrs, tip_errmsg[0]);
|
409 |
|
|
tip_errno = UDIErrorCantHappen;
|
410 |
|
|
CountDone = strlen(tip_errmsg[0]);
|
411 |
|
|
}
|
412 |
|
|
udr_UDISizeT(udrs, &CountDone);
|
413 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
414 |
|
|
udr_sendnow(udrs);
|
415 |
|
|
break;
|
416 |
|
|
}
|
417 |
|
|
/*--------------------------------------------------------- UDIGetTargetConfig
|
418 |
|
|
*/
|
419 |
|
|
case UDIGetTargetConfig_c:
|
420 |
|
|
{
|
421 |
|
|
char* KnownMemory_p; /* Out */
|
422 |
|
|
UDIInt NumberOfRanges; /* In and Out */
|
423 |
|
|
char* ChipVersions_p; /* Out */
|
424 |
|
|
UDIInt NumberOfChips; /* In and Out */
|
425 |
|
|
int cnt;
|
426 |
|
|
int MaxOfRanges;
|
427 |
|
|
char* NumberOfRanges_p;
|
428 |
|
|
|
429 |
|
|
udr_UDIInt(udrs, &NumberOfRanges); /* recieve all "in" params */
|
430 |
|
|
MaxOfRanges = NumberOfRanges;
|
431 |
|
|
udr_UDIInt(udrs, &NumberOfChips);
|
432 |
|
|
|
433 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
434 |
|
|
udr_work(udrs, &NumberOfRanges, 0); /* nothing yet */
|
435 |
|
|
KnownMemory_p = udr_getpos(udrs);
|
436 |
|
|
udr_inline(udrs, MaxOfRanges * sizeof(UDIMemoryRange) );
|
437 |
|
|
NumberOfRanges_p = udr_getpos(udrs);
|
438 |
|
|
udr_inline(udrs, sizeof(UDIInt) ); /* space for NumberOfRanges */
|
439 |
|
|
udr_inline(udrs, sizeof(UDIInt) ); /* space for NumberOfChips */
|
440 |
|
|
ChipVersions_p = udr_getpos(udrs);
|
441 |
|
|
tip_errno = UDIGetTargetConfig(KnownMemory_p, &NumberOfRanges,
|
442 |
|
|
ChipVersions_p, &NumberOfChips);
|
443 |
|
|
udr_setpos(udrs, NumberOfRanges_p);
|
444 |
|
|
udr_UDIInt(udrs, &NumberOfRanges);
|
445 |
|
|
udr_UDIInt(udrs, &NumberOfChips);
|
446 |
|
|
udr_inline(udrs, NumberOfChips * sizeof(UDIInt32) );
|
447 |
|
|
udr_UDIError(udrs, &tip_errno);
|
448 |
|
|
udr_sendnow(udrs);
|
449 |
|
|
break;
|
450 |
|
|
}
|
451 |
|
|
/*----------------------------------------------------------- UDICreateProcess
|
452 |
|
|
*/
|
453 |
|
|
case UDICreateProcess_c:
|
454 |
|
|
{
|
455 |
|
|
UDIPId pid; /* out */
|
456 |
|
|
|
457 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
458 |
|
|
tip_errno = UDICreateProcess(&pid);
|
459 |
|
|
udr_UDIPId(udrs, &pid);
|
460 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
461 |
|
|
udr_sendnow(udrs);
|
462 |
|
|
break;
|
463 |
|
|
}
|
464 |
|
|
/*------------------------------------------------------- UDIInitializeProcess
|
465 |
|
|
*/
|
466 |
|
|
case UDIInitializeProcess_c:
|
467 |
|
|
{
|
468 |
|
|
char* ProcessMemory_p; /* In */
|
469 |
|
|
UDIInt NumberOfRanges; /* In */
|
470 |
|
|
UDIResource EntryPoint; /* In */
|
471 |
|
|
char* StackSizes_p; /* In */
|
472 |
|
|
UDIInt NumberOfStacks; /* In */
|
473 |
|
|
char *ArgString = sbuf; /* In */
|
474 |
|
|
int cnt;
|
475 |
|
|
|
476 |
|
|
udr_UDIInt(udrs, &NumberOfRanges); /* recv all "in" parameters */
|
477 |
|
|
ProcessMemory_p = udr_getpos(udrs);
|
478 |
|
|
udr_inline(udrs, NumberOfRanges * sizeof(UDIMemoryRange) );
|
479 |
|
|
udr_UDIResource(udrs, &EntryPoint);
|
480 |
|
|
udr_UDIInt(udrs, &NumberOfStacks);
|
481 |
|
|
StackSizes_p = udr_getpos(udrs);
|
482 |
|
|
udr_inline(udrs, NumberOfStacks * sizeof(CPUSizeT) );
|
483 |
|
|
udr_string(udrs, ArgString);
|
484 |
|
|
|
485 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
486 |
|
|
tip_errno = UDIInitializeProcess( ProcessMemory_p, NumberOfRanges,
|
487 |
|
|
EntryPoint, StackSizes_p, NumberOfStacks, ArgString);
|
488 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
489 |
|
|
udr_sendnow(udrs);
|
490 |
|
|
break;
|
491 |
|
|
}
|
492 |
|
|
/*------------------------------------------------------- UDISetCurrentProcess
|
493 |
|
|
*/
|
494 |
|
|
case UDISetCurrentProcess_c:
|
495 |
|
|
{
|
496 |
|
|
UDIPId pid; /* in */
|
497 |
|
|
|
498 |
|
|
udr_UDIPId(udrs, &pid); /* recv all "in" parameters */
|
499 |
|
|
|
500 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
501 |
|
|
tip_errno = UDISetCurrentProcess(pid);
|
502 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
503 |
|
|
udr_sendnow(udrs);
|
504 |
|
|
break;
|
505 |
|
|
}
|
506 |
|
|
/*---------------------------------------------------------- UDIDestroyProcess
|
507 |
|
|
*/
|
508 |
|
|
case UDIDestroyProcess_c:
|
509 |
|
|
{
|
510 |
|
|
UDIPId pid; /* in */
|
511 |
|
|
|
512 |
|
|
udr_UDIPId(udrs, &pid); /* recv all "in" parameters */
|
513 |
|
|
|
514 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
515 |
|
|
tip_errno = UDIDestroyProcess(pid);
|
516 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
517 |
|
|
udr_sendnow(udrs);
|
518 |
|
|
break;
|
519 |
|
|
}
|
520 |
|
|
/*-------------------------------------------------------------------- UDIRead
|
521 |
|
|
*/
|
522 |
|
|
case UDIRead_c:
|
523 |
|
|
{
|
524 |
|
|
UDIResource from; /* in - source address on target */
|
525 |
|
|
UDIHostMemPtr to_dfe; /* out - destination adds on dfe host */
|
526 |
|
|
UDICount count; /* in -- count of objects */
|
527 |
|
|
UDISizeT size; /* in -- size of each object */
|
528 |
|
|
UDICount count_done; /* out - count actually transferred */
|
529 |
|
|
UDIBool host_endian; /* in -- flag for endian information */
|
530 |
|
|
char* count_done_p;
|
531 |
|
|
char* to_dfe_p;
|
532 |
|
|
|
533 |
|
|
udr_UDIResource(udrs, &from); /* recv all "in" parameters */
|
534 |
|
|
udr_UDICount(udrs, &count);
|
535 |
|
|
udr_UDISizeT(udrs, &size);
|
536 |
|
|
udr_UDIBool(udrs, &host_endian);
|
537 |
|
|
|
538 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
539 |
|
|
udr_work(udrs, count_done, 0); /* nothing to send yet */
|
540 |
|
|
count_done_p = udr_getpos(udrs);
|
541 |
|
|
udr_inline(udrs, sizeof(UDICount));/* make space for count_done */
|
542 |
|
|
to_dfe_p = udr_getpos(udrs);
|
543 |
|
|
tip_errno = UDIRead (from, to_dfe_p, count, size,
|
544 |
|
|
&count_done, host_endian);
|
545 |
|
|
udr_inline(udrs,count_done*size);/* make space in socket buffer */
|
546 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
547 |
|
|
udr_setpos(udrs, count_done_p); /* restore count_done stream position */
|
548 |
|
|
udr_UDICount(udrs, &count_done);
|
549 |
|
|
udr_sendnow(udrs);
|
550 |
|
|
break;
|
551 |
|
|
}
|
552 |
|
|
/*------------------------------------------------------------------- UDIWrite
|
553 |
|
|
*/
|
554 |
|
|
case UDIWrite_c:
|
555 |
|
|
{
|
556 |
|
|
UDIHostMemPtr from_dfe; /* in -- source address on DFE host */
|
557 |
|
|
UDIResource to; /* in -- destination adds on target */
|
558 |
|
|
UDICount count; /* in -- count of objects */
|
559 |
|
|
UDISizeT size; /* in -- size of each object */
|
560 |
|
|
UDICount count_done; /* out - count actually transferred */
|
561 |
|
|
UDIBool host_endian; /* in -- flag for endian information */
|
562 |
|
|
int byte_count;
|
563 |
|
|
char* from_dfe_p;
|
564 |
|
|
|
565 |
|
|
udr_UDIResource(udrs, &to); /* recv all "in" parameters */
|
566 |
|
|
udr_UDICount(udrs, &count);
|
567 |
|
|
udr_UDISizeT(udrs, &size);
|
568 |
|
|
udr_UDIBool(udrs, &host_endian);
|
569 |
|
|
from_dfe_p = udr_getpos(udrs); /* fake DFE host address */
|
570 |
|
|
byte_count = size * count;
|
571 |
|
|
udr_readnow(udrs, byte_count); /* read all data available from the
|
572 |
|
|
socket into the stream buffer */
|
573 |
|
|
|
574 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
575 |
|
|
tip_errno = UDIWrite( from_dfe_p, to, count, size,
|
576 |
|
|
&count_done, host_endian );
|
577 |
|
|
udr_UDICount(udrs, &count_done);
|
578 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
579 |
|
|
udr_sendnow(udrs);
|
580 |
|
|
break;
|
581 |
|
|
}
|
582 |
|
|
/*-------------------------------------------------------------------- UDICopy
|
583 |
|
|
*/
|
584 |
|
|
case UDICopy_c:
|
585 |
|
|
{
|
586 |
|
|
UDIResource from; /* in -- dest. address on target */
|
587 |
|
|
UDIResource to; /* in -- source address on target */
|
588 |
|
|
UDICount count; /* in -- count of objects */
|
589 |
|
|
UDISizeT size; /* in -- size of each object */
|
590 |
|
|
UDICount count_done; /* out - count actually transferred */
|
591 |
|
|
UDIBool direction; /* in -- high-to-low or reverse */
|
592 |
|
|
|
593 |
|
|
udr_UDIResource(udrs, &from); /* recv all "in" parameters */
|
594 |
|
|
udr_UDIResource(udrs, &to);
|
595 |
|
|
udr_UDICount(udrs, &count);
|
596 |
|
|
udr_UDISizeT(udrs, &size);
|
597 |
|
|
udr_UDIBool(udrs, &direction);
|
598 |
|
|
|
599 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
600 |
|
|
tip_errno = UDICopy(from, to, count, size, &count_done, direction );
|
601 |
|
|
udr_UDICount(udrs, &count_done);
|
602 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
603 |
|
|
udr_sendnow(udrs);
|
604 |
|
|
break;
|
605 |
|
|
}
|
606 |
|
|
/*----------------------------------------------------------------- UDIExecute
|
607 |
|
|
*/
|
608 |
|
|
case UDIExecute_c:
|
609 |
|
|
{
|
610 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
611 |
|
|
tip_errno = UDIExecute();
|
612 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
613 |
|
|
udr_sendnow(udrs);
|
614 |
|
|
break;
|
615 |
|
|
}
|
616 |
|
|
/*-------------------------------------------------------------------- UDIStep
|
617 |
|
|
*/
|
618 |
|
|
case UDIStep_c:
|
619 |
|
|
{
|
620 |
|
|
UDIUInt32 steps; /* in -- number of steps */
|
621 |
|
|
UDIStepType steptype; /* in -- type of stepping to be done */
|
622 |
|
|
UDIRange range; /* in -- range if StepInRange is TRUE */
|
623 |
|
|
|
624 |
|
|
udr_UDIInt32(udrs, &steps); /* recv all "in" parameters */
|
625 |
|
|
udr_UDIStepType(udrs, &steptype);
|
626 |
|
|
udr_UDIRange(udrs, &range);
|
627 |
|
|
|
628 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
629 |
|
|
tip_errno = UDIStep(steps, steptype, range);
|
630 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
631 |
|
|
udr_sendnow(udrs);
|
632 |
|
|
break;
|
633 |
|
|
}
|
634 |
|
|
/*-------------------------------------------------------------------- UDIWait
|
635 |
|
|
*/
|
636 |
|
|
case UDIWait_c:
|
637 |
|
|
{
|
638 |
|
|
UDIInt32 maxtime; /* in -- maximum time to wait for completion */
|
639 |
|
|
UDIPId pid; /* out -- pid of process which stopped if any */
|
640 |
|
|
UDIUInt32 stop_reason;/* out -- PC where process stopped */
|
641 |
|
|
|
642 |
|
|
udr_UDIInt32(udrs, &maxtime);
|
643 |
|
|
|
644 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
645 |
|
|
tip_errno = UDIWait(maxtime, &pid, &stop_reason);
|
646 |
|
|
udr_UDIPId(udrs, &pid);
|
647 |
|
|
udr_UDIUInt32(udrs, &stop_reason);
|
648 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
649 |
|
|
udr_sendnow(udrs);
|
650 |
|
|
break;
|
651 |
|
|
}
|
652 |
|
|
/*----------------------------------------------------------- UDISetBreakpoint
|
653 |
|
|
*/
|
654 |
|
|
case UDISetBreakpoint_c:
|
655 |
|
|
{
|
656 |
|
|
UDIResource addr; /* in -- where breakpoint gets set */
|
657 |
|
|
UDIInt32 passcount; /* in -- passcount for breakpoint */
|
658 |
|
|
UDIBreakType type; /* in -- breakpoint type */
|
659 |
|
|
UDIBreakId break_id; /* out - assigned break id */
|
660 |
|
|
|
661 |
|
|
udr_UDIResource(udrs, &addr); /* recv all "in" parameters */
|
662 |
|
|
udr_UDIInt32(udrs, &passcount);
|
663 |
|
|
udr_UDIBreakType(udrs, &type);
|
664 |
|
|
|
665 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
666 |
|
|
tip_errno = UDISetBreakpoint (addr, passcount, type, &break_id);
|
667 |
|
|
udr_UDIBreakId(udrs, &break_id);
|
668 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
669 |
|
|
udr_sendnow(udrs);
|
670 |
|
|
break;
|
671 |
|
|
}
|
672 |
|
|
/*--------------------------------------------------------- UDIQueryBreakpoint
|
673 |
|
|
*/
|
674 |
|
|
case UDIQueryBreakpoint_c:
|
675 |
|
|
{
|
676 |
|
|
UDIBreakId break_id; /* in -- assigned break id */
|
677 |
|
|
UDIResource addr; /* out - where breakpoint was set */
|
678 |
|
|
UDIInt32 passcount; /* out - trigger passcount */
|
679 |
|
|
UDIBreakType type; /* out - breakpoint type */
|
680 |
|
|
UDIInt32 current_count; /* out - current breakpoint count */
|
681 |
|
|
|
682 |
|
|
udr_UDIBreakId(udrs, &break_id);/* recv all "in" parameters */
|
683 |
|
|
|
684 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
685 |
|
|
tip_errno = UDIQueryBreakpoint (break_id, &addr, &passcount,
|
686 |
|
|
&type, ¤t_count);
|
687 |
|
|
udr_UDIResource(udrs, &addr);
|
688 |
|
|
udr_UDIInt32(udrs, &passcount);
|
689 |
|
|
udr_UDIBreakType(udrs, &type);
|
690 |
|
|
udr_UDIInt32(udrs, ¤t_count);
|
691 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
692 |
|
|
udr_sendnow(udrs);
|
693 |
|
|
break;
|
694 |
|
|
}
|
695 |
|
|
/*--------------------------------------------------------- UDIClearBreakpoint
|
696 |
|
|
*/
|
697 |
|
|
case UDIClearBreakpoint_c:
|
698 |
|
|
{
|
699 |
|
|
UDIBreakId break_id; /* in -- assigned break id */
|
700 |
|
|
|
701 |
|
|
udr_UDIBreakId(udrs, &break_id);/* recv all "in" parameters */
|
702 |
|
|
|
703 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
704 |
|
|
tip_errno = UDIClearBreakpoint (break_id);
|
705 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
706 |
|
|
udr_sendnow(udrs);
|
707 |
|
|
break;
|
708 |
|
|
}
|
709 |
|
|
/*--------------------------------------------------------------- UDIGetStdout
|
710 |
|
|
*/
|
711 |
|
|
case UDIGetStdout_c:
|
712 |
|
|
{
|
713 |
|
|
UDIHostMemPtr buf_dfe; /* out -- dfe buffer to be filled */
|
714 |
|
|
UDISizeT bufsize; /* in -- buffer size in bytes */
|
715 |
|
|
UDISizeT count_done; /* out -- number of bytes written */
|
716 |
|
|
char* buf_dfe_p;
|
717 |
|
|
char* count_done_p;
|
718 |
|
|
|
719 |
|
|
udr_UDISizeT(udrs, &bufsize); /* recv all "in" parameters */
|
720 |
|
|
|
721 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
722 |
|
|
udr_work(udrs, count_done, 0); /* nothing to send yet */
|
723 |
|
|
count_done_p = udr_getpos(udrs);
|
724 |
|
|
udr_inline(udrs,sizeof(UDISizeT));/* make space for count_done */
|
725 |
|
|
buf_dfe_p = udr_getpos(udrs); /* get start of string buffer */
|
726 |
|
|
tip_errno = UDIGetStdout(buf_dfe_p, bufsize, &count_done);
|
727 |
|
|
udr_inline(udrs, count_done); /* leave space for string */
|
728 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
729 |
|
|
udr_setpos(udrs, count_done_p); /* restore count_done stram position */
|
730 |
|
|
udr_UDISizeT(udrs, &count_done);
|
731 |
|
|
udr_sendnow(udrs);
|
732 |
|
|
break;
|
733 |
|
|
}
|
734 |
|
|
/*--------------------------------------------------------------- UDIGetStderr
|
735 |
|
|
*/
|
736 |
|
|
case UDIGetStderr_c:
|
737 |
|
|
{
|
738 |
|
|
UDIHostMemPtr buf_dfe; /* out -- dfe buffer to be filled */
|
739 |
|
|
UDISizeT bufsize; /* in -- buffer size in bytes */
|
740 |
|
|
UDISizeT count_done; /* out -- number of bytes written */
|
741 |
|
|
char* buf_dfe_p;
|
742 |
|
|
char* count_done_p;
|
743 |
|
|
|
744 |
|
|
udr_UDISizeT(udrs, &bufsize); /* recv all "in" parameters */
|
745 |
|
|
|
746 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
747 |
|
|
udr_work(udrs, count_done, 0); /* nothing to send yet */
|
748 |
|
|
count_done_p = udr_getpos(udrs);
|
749 |
|
|
udr_inline(udrs,sizeof(UDISizeT));/* make space for count_done */
|
750 |
|
|
buf_dfe_p = udr_getpos(udrs); /* get start of string buffer */
|
751 |
|
|
tip_errno = UDIGetStderr(buf_dfe_p, bufsize, &count_done);
|
752 |
|
|
udr_inline(udrs, count_done); /* leave space for string */
|
753 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
754 |
|
|
udr_setpos(udrs, count_done_p); /* restore count_done stram position */
|
755 |
|
|
udr_UDISizeT(udrs, &count_done);
|
756 |
|
|
udr_sendnow(udrs);
|
757 |
|
|
break;
|
758 |
|
|
}
|
759 |
|
|
/*---------------------------------------------------------------- UDIPutStdin
|
760 |
|
|
*/
|
761 |
|
|
case UDIPutStdin_c:
|
762 |
|
|
{
|
763 |
|
|
UDIHostMemPtr buf_dfe; /* in -- buffer to be filled */
|
764 |
|
|
UDISizeT count; /* in -- buffer size in bytes */
|
765 |
|
|
UDISizeT count_done; /* out - number bytes written to buf */
|
766 |
|
|
char* buf_dfe_p; /* pointer to incoming stream data */
|
767 |
|
|
|
768 |
|
|
udr_UDISizeT(udrs, &count); /* recv all "in" parameters */
|
769 |
|
|
buf_dfe_p = udr_getpos(udrs); /* get start of stream buffer */
|
770 |
|
|
|
771 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
772 |
|
|
tip_errno = UDIPutStdin (buf_dfe_p, count, &count_done);
|
773 |
|
|
udr_UDISizeT(udrs, &count_done);
|
774 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
775 |
|
|
udr_sendnow(udrs);
|
776 |
|
|
break;
|
777 |
|
|
}
|
778 |
|
|
/*--------------------------------------------------------------- UDIStdinMode
|
779 |
|
|
*/
|
780 |
|
|
case UDIStdinMode_c:
|
781 |
|
|
{
|
782 |
|
|
UDIMode mode; /* out - */
|
783 |
|
|
|
784 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
785 |
|
|
tip_errno = UDIStdinMode (&mode);
|
786 |
|
|
udr_UDIMode(udrs, &mode);
|
787 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
788 |
|
|
udr_sendnow(udrs);
|
789 |
|
|
break;
|
790 |
|
|
}
|
791 |
|
|
/*---------------------------------------------------------------- UDIPutTrans
|
792 |
|
|
*/
|
793 |
|
|
case UDIPutTrans_c:
|
794 |
|
|
{
|
795 |
|
|
UDIHostMemPtr buf; /* in -- buffer to be filled */
|
796 |
|
|
UDISizeT count; /* in -- buffer size in bytes */
|
797 |
|
|
UDISizeT count_done; /* out - number bytes written to buf */
|
798 |
|
|
|
799 |
|
|
udr_UDISizeT(udrs, &count); /* recv all "in" parameters */
|
800 |
|
|
buf = udr_getpos(udrs); /* get start of stream buffer */
|
801 |
|
|
|
802 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
803 |
|
|
tip_errno = UDIPutTrans (buf, count, &count_done);
|
804 |
|
|
udr_UDISizeT(udrs, &count_done);
|
805 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
806 |
|
|
udr_sendnow(udrs);
|
807 |
|
|
break;
|
808 |
|
|
}
|
809 |
|
|
/*---------------------------------------------------------------- UDIGetTrans
|
810 |
|
|
*/
|
811 |
|
|
case UDIGetTrans_c:
|
812 |
|
|
{
|
813 |
|
|
UDIHostMemPtr buf_dfe; /* out -- dfe buffer to be filled */
|
814 |
|
|
UDISizeT bufsize; /* in -- buffer size in bytes */
|
815 |
|
|
UDISizeT count_done; /* out -- number of bytes written */
|
816 |
|
|
char* buf_dfe_p;
|
817 |
|
|
char* count_done_p;
|
818 |
|
|
|
819 |
|
|
udr_UDISizeT(udrs, &bufsize); /* recv all "in" parameters */
|
820 |
|
|
|
821 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
822 |
|
|
udr_work(udrs, count_done, 0); /* nothing to send yet */
|
823 |
|
|
count_done_p = udr_getpos(udrs);
|
824 |
|
|
udr_inline(udrs,sizeof(UDISizeT));/* make space for count_done */
|
825 |
|
|
buf_dfe_p = udr_getpos(udrs); /* get start of string buffer */
|
826 |
|
|
tip_errno = UDIGetTrans (buf_dfe_p, bufsize, &count_done);
|
827 |
|
|
udr_inline(udrs, count_done); /* leave space for string */
|
828 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
829 |
|
|
udr_setpos(udrs, count_done_p); /* restore count_done stram position */
|
830 |
|
|
udr_UDISizeT(udrs, &count_done);
|
831 |
|
|
udr_sendnow(udrs);
|
832 |
|
|
break;
|
833 |
|
|
}
|
834 |
|
|
/*--------------------------------------------------------------- UDITransMode
|
835 |
|
|
*/
|
836 |
|
|
case UDITransMode_c:
|
837 |
|
|
{
|
838 |
|
|
UDIMode mode; /* in -- selected mode */
|
839 |
|
|
|
840 |
|
|
udr_UDIMode(udrs, &mode); /* recv all "in" parameters */
|
841 |
|
|
|
842 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
843 |
|
|
tip_errno = UDITransMode(&mode);
|
844 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
845 |
|
|
udr_sendnow(udrs);
|
846 |
|
|
}
|
847 |
|
|
/*-------------------------------------------------------------------- UDITest
|
848 |
|
|
*/
|
849 |
|
|
case UDITest_c:
|
850 |
|
|
{
|
851 |
|
|
UDISizeT cnt;
|
852 |
|
|
UDIHostMemPtr str_p;
|
853 |
|
|
UDIHostMemPtr iarray_dfe;
|
854 |
|
|
UDISizeT r_cnt;
|
855 |
|
|
UDIInt16 scnt;
|
856 |
|
|
UDIInt32 array[4];
|
857 |
|
|
|
858 |
|
|
udr_UDISizeT(udrs, &cnt);
|
859 |
|
|
udr_UDIInt16(udrs, &scnt);
|
860 |
|
|
udr_bytes(udrs, (char*)array, 4*sizeof(UDIInt32));
|
861 |
|
|
udr_string(udrs, sbuf);
|
862 |
|
|
|
863 |
|
|
udrs->udr_op = UDR_ENCODE; /* send all "out" parameters */
|
864 |
|
|
r_cnt = cnt;
|
865 |
|
|
cnt = array[3]; array[3] = array[0]; array[0] = cnt;
|
866 |
|
|
cnt = array[2]; array[2] = array[1]; array[1] = cnt;
|
867 |
|
|
tip_errno = 0;
|
868 |
|
|
udr_UDISizeT(udrs, &r_cnt);
|
869 |
|
|
scnt = -1* scnt;
|
870 |
|
|
udr_UDIInt16(udrs, &scnt);
|
871 |
|
|
udr_bytes(udrs, (char*)array, 4*sizeof(UDIInt32));
|
872 |
|
|
for(cnt=0; cnt< strlen(sbuf);cnt++)sbuf[cnt] -= 32;
|
873 |
|
|
udr_string(udrs, sbuf);
|
874 |
|
|
udr_UDIError(udrs, &tip_errno); /* send any TIP error */
|
875 |
|
|
udr_sendnow(udrs);
|
876 |
|
|
if(scnt == 3)
|
877 |
|
|
{ fprintf(stderr,"TIP-ipc test sleep(30) seconds\n");
|
878 |
|
|
sleep(30);
|
879 |
|
|
}
|
880 |
|
|
break;
|
881 |
|
|
}
|
882 |
|
|
}
|
883 |
|
|
}
|
884 |
|
|
}
|