dl.c revision 1.2 1 1.2 thorpej /* $NetBSD: dl.c,v 1.2 1997/03/25 03:07:09 thorpej 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.1 cjs #ifndef LINT
33 1.2 thorpej static char rcsid[] = "$NetBSD: dl.c,v 1.2 1997/03/25 03:07:09 thorpej Exp $";
34 1.1 cjs #endif
35 1.1 cjs
36 1.1 cjs #include "os.h"
37 1.1 cjs #include "common/get.h"
38 1.1 cjs #include "common/print.h"
39 1.1 cjs #include "common/mopdef.h"
40 1.1 cjs
41 1.1 cjs void
42 1.1 cjs mopDumpDL(fd, pkt, trans)
43 1.1 cjs FILE *fd;
44 1.1 cjs u_char *pkt;
45 1.1 cjs int trans;
46 1.1 cjs {
47 1.1 cjs int i,index = 0;
48 1.1 cjs long tmpl;
49 1.1 cjs u_char tmpc,c,program[17],code,*ucp;
50 1.1 cjs u_short len,tmps,moplen;
51 1.1 cjs
52 1.1 cjs len = mopGetLength(pkt, trans);
53 1.1 cjs
54 1.1 cjs switch (trans) {
55 1.1 cjs case TRANS_8023:
56 1.1 cjs index = 22;
57 1.1 cjs moplen = len - 8;
58 1.1 cjs break;
59 1.1 cjs default:
60 1.1 cjs index = 16;
61 1.1 cjs moplen = len;
62 1.1 cjs }
63 1.1 cjs code = mopGetChar(pkt,&index);
64 1.1 cjs
65 1.1 cjs switch (code) {
66 1.1 cjs case MOP_K_CODE_MLT:
67 1.1 cjs
68 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Load Number */
69 1.1 cjs (void)fprintf(fd,"Load Number : %02x\n",tmpc);
70 1.1 cjs
71 1.1 cjs if (moplen > 6) {
72 1.1 cjs tmpl = mopGetLong(pkt,&index);/* Load Address */
73 1.1 cjs (void)fprintf(fd,"Load Address : %08x\n",tmpl);
74 1.1 cjs }
75 1.1 cjs
76 1.1 cjs if (moplen > 10) {
77 1.1 cjs #ifndef SHORT_PRINT
78 1.1 cjs for (i = 0; i < (moplen - 10); i++) {
79 1.1 cjs if ((i % 16) == 0) {
80 1.1 cjs if ((i / 16) == 0) {
81 1.1 cjs (void)fprintf(fd,
82 1.1 cjs "Image Data : %04x ",
83 1.1 cjs moplen-10);
84 1.1 cjs } else {
85 1.1 cjs (void)fprintf(fd,
86 1.1 cjs " ");
87 1.1 cjs }
88 1.1 cjs }
89 1.1 cjs
90 1.1 cjs (void)fprintf(fd, "%02x ",
91 1.1 cjs mopGetChar(pkt,&index));
92 1.1 cjs if ((i % 16) == 15)
93 1.1 cjs (void)fprintf(fd,"\n");
94 1.1 cjs }
95 1.1 cjs
96 1.1 cjs if ((i % 16) != 15)
97 1.1 cjs (void)fprintf(fd,"\n");
98 1.1 cjs #else
99 1.1 cjs index = index + moplen - 10;
100 1.1 cjs #endif
101 1.1 cjs }
102 1.1 cjs
103 1.1 cjs tmpl = mopGetLong(pkt,&index); /* Load Address */
104 1.1 cjs (void)fprintf(fd,"Xfer Address : %08x\n",tmpl);
105 1.1 cjs
106 1.1 cjs break;
107 1.1 cjs case MOP_K_CODE_DCM:
108 1.1 cjs
109 1.1 cjs /* Empty Message */
110 1.1 cjs
111 1.1 cjs break;
112 1.1 cjs case MOP_K_CODE_MLD:
113 1.1 cjs
114 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Load Number */
115 1.1 cjs (void)fprintf(fd,"Load Number : %02x\n",tmpc);
116 1.1 cjs
117 1.1 cjs tmpl = mopGetLong(pkt,&index); /* Load Address */
118 1.1 cjs (void)fprintf(fd,"Load Address : %08x\n",tmpl);
119 1.1 cjs
120 1.1 cjs if (moplen > 6) {
121 1.1 cjs #ifndef SHORT_PRINT
122 1.1 cjs for (i = 0; i < (moplen - 6); i++) {
123 1.1 cjs if ((i % 16) == 0) {
124 1.1 cjs if ((i / 16) == 0) {
125 1.1 cjs (void)fprintf(fd,
126 1.1 cjs "Image Data : %04x ",
127 1.1 cjs moplen-6);
128 1.1 cjs } else {
129 1.1 cjs (void)fprintf(fd,
130 1.1 cjs " ");
131 1.1 cjs }
132 1.1 cjs }
133 1.1 cjs (void)fprintf(fd,"%02x ",
134 1.1 cjs mopGetChar(pkt,&index));
135 1.1 cjs if ((i % 16) == 15)
136 1.1 cjs (void)fprintf(fd,"\n");
137 1.1 cjs }
138 1.1 cjs
139 1.1 cjs if ((i % 16) != 15)
140 1.1 cjs (void)fprintf(fd,"\n");
141 1.1 cjs #else
142 1.1 cjs index = index + moplen - 6;
143 1.1 cjs #endif
144 1.1 cjs }
145 1.1 cjs
146 1.1 cjs break;
147 1.1 cjs case MOP_K_CODE_ASV:
148 1.1 cjs
149 1.1 cjs /* Empty Message */
150 1.1 cjs
151 1.1 cjs break;
152 1.1 cjs case MOP_K_CODE_RMD:
153 1.1 cjs
154 1.1 cjs tmpl = mopGetLong(pkt,&index); /* Memory Address */
155 1.1 cjs (void)fprintf(fd,"Mem Address : %08x\n",tmpl);
156 1.1 cjs
157 1.1 cjs tmps = mopGetShort(pkt,&index); /* Count */
158 1.1 cjs (void)fprintf(fd,"Count : %04x (%d)\n",tmps,tmps);
159 1.1 cjs
160 1.1 cjs break;
161 1.1 cjs case MOP_K_CODE_RPR:
162 1.1 cjs
163 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Device Type */
164 1.1 cjs (void)fprintf(fd, "Device Type : %02x ",tmpc);
165 1.1 cjs mopPrintDevice(fd, tmpc); (void)fprintf(fd, "\n");
166 1.1 cjs
167 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Format Version */
168 1.1 cjs (void)fprintf(fd,"Format : %02x\n",tmpc);
169 1.1 cjs
170 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Program Type */
171 1.1 cjs (void)fprintf(fd,"Program Type : %02x ",tmpc);
172 1.1 cjs mopPrintPGTY(fd, tmpc); (void)fprintf(fd, "\n");
173 1.1 cjs
174 1.1 cjs program[0] = 0;
175 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Software ID Len */
176 1.1 cjs for (i = 0; i < tmpc; i++) {
177 1.1 cjs program[i] = mopGetChar(pkt,&index);
178 1.1 cjs program[i+1] = '\0';
179 1.1 cjs }
180 1.1 cjs
181 1.1 cjs (void)fprintf(fd,"Software : %02x '%s'\n",tmpc,program);
182 1.1 cjs
183 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Processor */
184 1.1 cjs (void)fprintf(fd,"Processor : %02x ",tmpc);
185 1.1 cjs mopPrintBPTY(fd, tmpc); (void)fprintf(fd, "\n");
186 1.1 cjs
187 1.1 cjs mopPrintInfo(fd, pkt, &index, moplen, code, trans);
188 1.1 cjs
189 1.1 cjs break;
190 1.1 cjs case MOP_K_CODE_RML:
191 1.1 cjs
192 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Load Number */
193 1.1 cjs (void)fprintf(fd,"Load Number : %02x\n",tmpc);
194 1.1 cjs
195 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Error */
196 1.1 cjs (void)fprintf(fd,"Error : %02x (",tmpc);
197 1.1 cjs if ((tmpc == 0)) {
198 1.1 cjs (void)fprintf(fd,"no error)\n");
199 1.1 cjs } else {
200 1.1 cjs (void)fprintf(fd,"error)\n");
201 1.1 cjs }
202 1.1 cjs
203 1.1 cjs break;
204 1.1 cjs case MOP_K_CODE_RDS:
205 1.1 cjs
206 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Device Type */
207 1.1 cjs (void)fprintf(fd, "Device Type : %02x ",tmpc);
208 1.1 cjs mopPrintDevice(fd, tmpc); (void)fprintf(fd, "\n");
209 1.1 cjs
210 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Format Version */
211 1.1 cjs (void)fprintf(fd,"Format : %02x\n",tmpc);
212 1.1 cjs
213 1.1 cjs tmpl = mopGetLong(pkt,&index); /* Memory Size */
214 1.1 cjs (void)fprintf(fd,"Memory Size : %08x\n",tmpl);
215 1.1 cjs
216 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Bits */
217 1.1 cjs (void)fprintf(fd,"Bits : %02x\n",tmpc);
218 1.1 cjs
219 1.1 cjs mopPrintInfo(fd, pkt, &index, moplen, code, trans);
220 1.1 cjs
221 1.1 cjs break;
222 1.1 cjs case MOP_K_CODE_MDD:
223 1.1 cjs
224 1.1 cjs tmpl = mopGetLong(pkt,&index); /* Memory Address */
225 1.1 cjs (void)fprintf(fd,"Mem Address : %08x\n",tmpl);
226 1.1 cjs
227 1.1 cjs if (moplen > 5) {
228 1.1 cjs #ifndef SHORT_PRINT
229 1.1 cjs for (i = 0; i < (moplen - 5); i++) {
230 1.1 cjs if ((i % 16) == 0) {
231 1.1 cjs if ((i / 16) == 0) {
232 1.1 cjs (void)fprintf(fd,
233 1.1 cjs "Image Data : %04x ",
234 1.1 cjs moplen-5);
235 1.1 cjs } else {
236 1.1 cjs (void)fprintf(fd,
237 1.1 cjs " ");
238 1.1 cjs }
239 1.1 cjs }
240 1.1 cjs (void)fprintf(fd,"%02x ",
241 1.1 cjs mopGetChar(pkt,&index));
242 1.1 cjs if ((i % 16) == 15)
243 1.1 cjs (void)fprintf(fd,"\n");
244 1.1 cjs }
245 1.1 cjs if ((i % 16) != 15)
246 1.1 cjs (void)fprintf(fd,"\n");
247 1.1 cjs #else
248 1.1 cjs index = index + moplen - 5;
249 1.1 cjs #endif
250 1.1 cjs }
251 1.1 cjs
252 1.1 cjs break;
253 1.1 cjs case MOP_K_CODE_PLT:
254 1.1 cjs
255 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Load Number */
256 1.1 cjs (void)fprintf(fd,"Load Number : %02x\n",tmpc);
257 1.1 cjs
258 1.1 cjs tmpc = mopGetChar(pkt,&index); /* Parameter Type */
259 1.1 cjs while (tmpc != MOP_K_PLTP_END) {
260 1.1 cjs c = mopGetChar(pkt,&index); /* Parameter Length */
261 1.1 cjs switch(tmpc) {
262 1.1 cjs case MOP_K_PLTP_TSN: /* Target Name */
263 1.1 cjs (void)fprintf(fd,"Target Name : %02x '",
264 1.1 cjs tmpc);
265 1.1 cjs for (i = 0; i < ((int) c); i++) {
266 1.1 cjs (void)fprintf(fd,"%c",
267 1.1 cjs mopGetChar(pkt,&index));
268 1.1 cjs }
269 1.1 cjs (void)fprintf(fd,"'\n");
270 1.1 cjs break;
271 1.1 cjs case MOP_K_PLTP_TSA: /* Target Address */
272 1.1 cjs (void)fprintf(fd,"Target Addr : %02x ",c);
273 1.1 cjs for (i = 0; i < ((int) c); i++) {
274 1.1 cjs (void)fprintf(fd,"%02x ",
275 1.1 cjs mopGetChar(pkt,&index));
276 1.1 cjs }
277 1.1 cjs (void)fprintf(fd,"\n");
278 1.1 cjs break;
279 1.1 cjs case MOP_K_PLTP_HSN: /* Host Name */
280 1.1 cjs (void)fprintf(fd,"Host Name : %02x '",
281 1.1 cjs tmpc);
282 1.1 cjs for (i = 0; i < ((int) c); i++) {
283 1.1 cjs (void)fprintf(fd,"%c",
284 1.1 cjs mopGetChar(pkt,&index));
285 1.1 cjs }
286 1.1 cjs (void)fprintf(fd,"'\n");
287 1.1 cjs break;
288 1.1 cjs case MOP_K_PLTP_HSA: /* Host Address */
289 1.1 cjs (void)fprintf(fd,"Host Addr : %02x ",c);
290 1.1 cjs for (i = 0; i < ((int) c); i++) {
291 1.1 cjs (void)fprintf(fd,"%02x ",
292 1.1 cjs mopGetChar(pkt,&index));
293 1.1 cjs }
294 1.1 cjs (void)fprintf(fd,"\n");
295 1.1 cjs break;
296 1.1 cjs case MOP_K_PLTP_HST: /* Host Time */
297 1.1 cjs ucp = pkt + index; index = index + 10;
298 1.1 cjs (void)fprintf(fd,"Host Time : ");
299 1.1 cjs mopPrintTime(fd, ucp);
300 1.1 cjs (void)fprintf(fd,"\n");
301 1.1 cjs break;
302 1.1 cjs default:
303 1.1 cjs break;
304 1.1 cjs }
305 1.1 cjs tmpc = mopGetChar(pkt,&index);/* Parameter Type */
306 1.1 cjs }
307 1.1 cjs
308 1.1 cjs tmpl = mopGetLong(pkt,&index); /* Transfer Address */
309 1.1 cjs (void)fprintf(fd,"Transfer Addr: %08x\n",tmpl);
310 1.1 cjs
311 1.1 cjs break;
312 1.1 cjs default:
313 1.1 cjs break;
314 1.1 cjs }
315 1.1 cjs }
316 1.1 cjs
317 1.1 cjs
318