dl.c revision 1.4 1 1.4 simonb /* $NetBSD: dl.c,v 1.4 1999/08/17 12:38:09 simonb Exp $ */
2 1.2 thorpej
3 1.1 cjs /*
4 1.1 cjs * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
5 1.1 cjs *
6 1.1 cjs * Redistribution and use in source and binary forms, with or without
7 1.1 cjs * modification, are permitted provided that the following conditions
8 1.1 cjs * are met:
9 1.1 cjs * 1. Redistributions of source code must retain the above copyright
10 1.1 cjs * notice, this list of conditions and the following disclaimer.
11 1.1 cjs * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 cjs * notice, this list of conditions and the following disclaimer in the
13 1.1 cjs * documentation and/or other materials provided with the distribution.
14 1.1 cjs * 3. All advertising materials mentioning features or use of this software
15 1.1 cjs * must display the following acknowledgement:
16 1.1 cjs * This product includes software developed by Mats O Jansson.
17 1.1 cjs * 4. The name of the author may not be used to endorse or promote products
18 1.1 cjs * derived from this software without specific prior written permission.
19 1.1 cjs *
20 1.1 cjs * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.1 cjs * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.1 cjs * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.1 cjs * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.1 cjs * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.1 cjs * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1 cjs * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1 cjs * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1 cjs * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.1 cjs * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 cjs */
31 1.1 cjs
32 1.3 lukem #include <sys/cdefs.h>
33 1.3 lukem #ifndef lint
34 1.4 simonb __RCSID("$NetBSD: dl.c,v 1.4 1999/08/17 12:38:09 simonb Exp $");
35 1.1 cjs #endif
36 1.1 cjs
37 1.1 cjs #include "os.h"
38 1.3 lukem #include "dl.h"
39 1.3 lukem #include "get.h"
40 1.3 lukem #include "mopdef.h"
41 1.3 lukem #include "print.h"
42 1.1 cjs
43 1.1 cjs void
44 1.1 cjs mopDumpDL(fd, pkt, trans)
45 1.1 cjs FILE *fd;
46 1.1 cjs u_char *pkt;
47 1.1 cjs int trans;
48 1.1 cjs {
49 1.1 cjs int i,index = 0;
50 1.3 lukem u_int32_t tmpl;
51 1.4 simonb u_char tmpc,c,program[257],code,*ucp;
52 1.1 cjs u_short len,tmps,moplen;
53 1.1 cjs
54 1.1 cjs len = mopGetLength(pkt, trans);
55 1.1 cjs
56 1.1 cjs switch (trans) {
57 1.1 cjs case TRANS_8023:
58 1.1 cjs index = 22;
59 1.1 cjs moplen = len - 8;
60 1.1 cjs break;
61 1.1 cjs default:
62 1.1 cjs index = 16;
63 1.1 cjs moplen = len;
64 1.1 cjs }
65 1.1 cjs code = mopGetChar(pkt,&index);
66 1.1 cjs
67 1.1 cjs switch (code) {
68 1.1 cjs case MOP_K_CODE_MLT:
69 1.1 cjs
70 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Load Number */
71 1.1 cjs (void)fprintf(fd,"Load Number : %02x\n",tmpc);
72 1.1 cjs
73 1.1 cjs if (moplen > 6) {
74 1.1 cjs tmpl = mopGetLong(pkt,&index);/* Load Address */
75 1.3 lukem (void)fprintf(fd,"Load Address : %08x\n", tmpl);
76 1.1 cjs }
77 1.1 cjs
78 1.1 cjs if (moplen > 10) {
79 1.1 cjs #ifndef SHORT_PRINT
80 1.1 cjs for (i = 0; i < (moplen - 10); i++) {
81 1.1 cjs if ((i % 16) == 0) {
82 1.1 cjs if ((i / 16) == 0) {
83 1.1 cjs (void)fprintf(fd,
84 1.1 cjs "Image Data : %04x ",
85 1.1 cjs moplen-10);
86 1.1 cjs } else {
87 1.1 cjs (void)fprintf(fd,
88 1.1 cjs " ");
89 1.1 cjs }
90 1.1 cjs }
91 1.1 cjs
92 1.1 cjs (void)fprintf(fd, "%02x ",
93 1.1 cjs mopGetChar(pkt,&index));
94 1.1 cjs if ((i % 16) == 15)
95 1.1 cjs (void)fprintf(fd,"\n");
96 1.1 cjs }
97 1.1 cjs
98 1.1 cjs if ((i % 16) != 15)
99 1.1 cjs (void)fprintf(fd,"\n");
100 1.1 cjs #else
101 1.1 cjs index = index + moplen - 10;
102 1.1 cjs #endif
103 1.1 cjs }
104 1.1 cjs
105 1.1 cjs tmpl = mopGetLong(pkt,&index); /* Load Address */
106 1.3 lukem (void)fprintf(fd,"Xfer Address : %08x\n", tmpl);
107 1.1 cjs
108 1.1 cjs break;
109 1.1 cjs case MOP_K_CODE_DCM:
110 1.1 cjs
111 1.1 cjs /* Empty Message */
112 1.1 cjs
113 1.1 cjs break;
114 1.1 cjs case MOP_K_CODE_MLD:
115 1.1 cjs
116 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Load Number */
117 1.1 cjs (void)fprintf(fd,"Load Number : %02x\n",tmpc);
118 1.1 cjs
119 1.1 cjs tmpl = mopGetLong(pkt,&index); /* Load Address */
120 1.3 lukem (void)fprintf(fd,"Load Address : %08x\n", tmpl);
121 1.1 cjs
122 1.1 cjs if (moplen > 6) {
123 1.1 cjs #ifndef SHORT_PRINT
124 1.1 cjs for (i = 0; i < (moplen - 6); i++) {
125 1.1 cjs if ((i % 16) == 0) {
126 1.1 cjs if ((i / 16) == 0) {
127 1.1 cjs (void)fprintf(fd,
128 1.1 cjs "Image Data : %04x ",
129 1.1 cjs moplen-6);
130 1.1 cjs } else {
131 1.1 cjs (void)fprintf(fd,
132 1.1 cjs " ");
133 1.1 cjs }
134 1.1 cjs }
135 1.1 cjs (void)fprintf(fd,"%02x ",
136 1.1 cjs mopGetChar(pkt,&index));
137 1.1 cjs if ((i % 16) == 15)
138 1.1 cjs (void)fprintf(fd,"\n");
139 1.1 cjs }
140 1.1 cjs
141 1.1 cjs if ((i % 16) != 15)
142 1.1 cjs (void)fprintf(fd,"\n");
143 1.1 cjs #else
144 1.1 cjs index = index + moplen - 6;
145 1.1 cjs #endif
146 1.1 cjs }
147 1.1 cjs
148 1.1 cjs break;
149 1.1 cjs case MOP_K_CODE_ASV:
150 1.1 cjs
151 1.1 cjs /* Empty Message */
152 1.1 cjs
153 1.1 cjs break;
154 1.1 cjs case MOP_K_CODE_RMD:
155 1.1 cjs
156 1.1 cjs tmpl = mopGetLong(pkt,&index); /* Memory Address */
157 1.3 lukem (void)fprintf(fd,"Mem Address : %08x\n", tmpl);
158 1.1 cjs
159 1.1 cjs tmps = mopGetShort(pkt,&index); /* Count */
160 1.1 cjs (void)fprintf(fd,"Count : %04x (%d)\n",tmps,tmps);
161 1.1 cjs
162 1.1 cjs break;
163 1.1 cjs case MOP_K_CODE_RPR:
164 1.1 cjs
165 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Device Type */
166 1.1 cjs (void)fprintf(fd, "Device Type : %02x ",tmpc);
167 1.1 cjs mopPrintDevice(fd, tmpc); (void)fprintf(fd, "\n");
168 1.1 cjs
169 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Format Version */
170 1.1 cjs (void)fprintf(fd,"Format : %02x\n",tmpc);
171 1.1 cjs
172 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Program Type */
173 1.1 cjs (void)fprintf(fd,"Program Type : %02x ",tmpc);
174 1.1 cjs mopPrintPGTY(fd, tmpc); (void)fprintf(fd, "\n");
175 1.1 cjs
176 1.1 cjs program[0] = 0;
177 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Software ID Len */
178 1.1 cjs for (i = 0; i < tmpc; i++) {
179 1.1 cjs program[i] = mopGetChar(pkt,&index);
180 1.1 cjs program[i+1] = '\0';
181 1.1 cjs }
182 1.1 cjs
183 1.1 cjs (void)fprintf(fd,"Software : %02x '%s'\n",tmpc,program);
184 1.1 cjs
185 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Processor */
186 1.1 cjs (void)fprintf(fd,"Processor : %02x ",tmpc);
187 1.1 cjs mopPrintBPTY(fd, tmpc); (void)fprintf(fd, "\n");
188 1.1 cjs
189 1.1 cjs mopPrintInfo(fd, pkt, &index, moplen, code, trans);
190 1.1 cjs
191 1.1 cjs break;
192 1.1 cjs case MOP_K_CODE_RML:
193 1.1 cjs
194 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Load Number */
195 1.1 cjs (void)fprintf(fd,"Load Number : %02x\n",tmpc);
196 1.1 cjs
197 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Error */
198 1.1 cjs (void)fprintf(fd,"Error : %02x (",tmpc);
199 1.1 cjs if ((tmpc == 0)) {
200 1.1 cjs (void)fprintf(fd,"no error)\n");
201 1.1 cjs } else {
202 1.1 cjs (void)fprintf(fd,"error)\n");
203 1.1 cjs }
204 1.1 cjs
205 1.1 cjs break;
206 1.1 cjs case MOP_K_CODE_RDS:
207 1.1 cjs
208 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Device Type */
209 1.1 cjs (void)fprintf(fd, "Device Type : %02x ",tmpc);
210 1.1 cjs mopPrintDevice(fd, tmpc); (void)fprintf(fd, "\n");
211 1.1 cjs
212 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Format Version */
213 1.1 cjs (void)fprintf(fd,"Format : %02x\n",tmpc);
214 1.1 cjs
215 1.1 cjs tmpl = mopGetLong(pkt,&index); /* Memory Size */
216 1.3 lukem (void)fprintf(fd,"Memory Size : %08x\n", tmpl);
217 1.1 cjs
218 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Bits */
219 1.1 cjs (void)fprintf(fd,"Bits : %02x\n",tmpc);
220 1.1 cjs
221 1.1 cjs mopPrintInfo(fd, pkt, &index, moplen, code, trans);
222 1.1 cjs
223 1.1 cjs break;
224 1.1 cjs case MOP_K_CODE_MDD:
225 1.1 cjs
226 1.1 cjs tmpl = mopGetLong(pkt,&index); /* Memory Address */
227 1.3 lukem (void)fprintf(fd,"Mem Address : %08x\n", tmpl);
228 1.1 cjs
229 1.1 cjs if (moplen > 5) {
230 1.1 cjs #ifndef SHORT_PRINT
231 1.1 cjs for (i = 0; i < (moplen - 5); i++) {
232 1.1 cjs if ((i % 16) == 0) {
233 1.1 cjs if ((i / 16) == 0) {
234 1.1 cjs (void)fprintf(fd,
235 1.1 cjs "Image Data : %04x ",
236 1.1 cjs moplen-5);
237 1.1 cjs } else {
238 1.1 cjs (void)fprintf(fd,
239 1.1 cjs " ");
240 1.1 cjs }
241 1.1 cjs }
242 1.1 cjs (void)fprintf(fd,"%02x ",
243 1.1 cjs mopGetChar(pkt,&index));
244 1.1 cjs if ((i % 16) == 15)
245 1.1 cjs (void)fprintf(fd,"\n");
246 1.1 cjs }
247 1.1 cjs if ((i % 16) != 15)
248 1.1 cjs (void)fprintf(fd,"\n");
249 1.1 cjs #else
250 1.1 cjs index = index + moplen - 5;
251 1.1 cjs #endif
252 1.1 cjs }
253 1.1 cjs
254 1.1 cjs break;
255 1.1 cjs case MOP_K_CODE_PLT:
256 1.1 cjs
257 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Load Number */
258 1.1 cjs (void)fprintf(fd,"Load Number : %02x\n",tmpc);
259 1.1 cjs
260 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Parameter Type */
261 1.1 cjs while (tmpc != MOP_K_PLTP_END) {
262 1.1 cjs c = mopGetChar(pkt,&index); /* Parameter Length */
263 1.1 cjs switch(tmpc) {
264 1.1 cjs case MOP_K_PLTP_TSN: /* Target Name */
265 1.1 cjs (void)fprintf(fd,"Target Name : %02x '",
266 1.1 cjs tmpc);
267 1.1 cjs for (i = 0; i < ((int) c); i++) {
268 1.1 cjs (void)fprintf(fd,"%c",
269 1.1 cjs mopGetChar(pkt,&index));
270 1.1 cjs }
271 1.1 cjs (void)fprintf(fd,"'\n");
272 1.1 cjs break;
273 1.1 cjs case MOP_K_PLTP_TSA: /* Target Address */
274 1.1 cjs (void)fprintf(fd,"Target Addr : %02x ",c);
275 1.1 cjs for (i = 0; i < ((int) c); i++) {
276 1.1 cjs (void)fprintf(fd,"%02x ",
277 1.1 cjs mopGetChar(pkt,&index));
278 1.1 cjs }
279 1.1 cjs (void)fprintf(fd,"\n");
280 1.1 cjs break;
281 1.1 cjs case MOP_K_PLTP_HSN: /* Host Name */
282 1.1 cjs (void)fprintf(fd,"Host Name : %02x '",
283 1.1 cjs tmpc);
284 1.1 cjs for (i = 0; i < ((int) c); i++) {
285 1.1 cjs (void)fprintf(fd,"%c",
286 1.1 cjs mopGetChar(pkt,&index));
287 1.1 cjs }
288 1.1 cjs (void)fprintf(fd,"'\n");
289 1.1 cjs break;
290 1.1 cjs case MOP_K_PLTP_HSA: /* Host Address */
291 1.1 cjs (void)fprintf(fd,"Host Addr : %02x ",c);
292 1.1 cjs for (i = 0; i < ((int) c); i++) {
293 1.1 cjs (void)fprintf(fd,"%02x ",
294 1.1 cjs mopGetChar(pkt,&index));
295 1.1 cjs }
296 1.1 cjs (void)fprintf(fd,"\n");
297 1.1 cjs break;
298 1.1 cjs case MOP_K_PLTP_HST: /* Host Time */
299 1.1 cjs ucp = pkt + index; index = index + 10;
300 1.1 cjs (void)fprintf(fd,"Host Time : ");
301 1.1 cjs mopPrintTime(fd, ucp);
302 1.1 cjs (void)fprintf(fd,"\n");
303 1.1 cjs break;
304 1.1 cjs default:
305 1.1 cjs break;
306 1.1 cjs }
307 1.1 cjs tmpc = mopGetChar(pkt,&index);/* Parameter Type */
308 1.1 cjs }
309 1.1 cjs
310 1.1 cjs tmpl = mopGetLong(pkt,&index); /* Transfer Address */
311 1.3 lukem (void)fprintf(fd,"Transfer Addr: %08x\n", tmpl);
312 1.1 cjs
313 1.1 cjs break;
314 1.1 cjs default:
315 1.1 cjs break;
316 1.1 cjs }
317 1.1 cjs }
318 1.1 cjs
319 1.1 cjs
320