1 /* $NetBSD: dl.c,v 1.3 1997/10/16 23:24:31 lukem Exp $ */
4 * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Mats O Jansson.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
34 static char rcsid
[]="$NetBSD: dl.c,v 1.3 1997/10/16 23:24:31 lukem Exp $";
44 mopDumpDL(fd
, pkt
, trans
)
51 u_char tmpc
,c
,program
[257],code
,*ucp
;
52 u_short len
,tmps
,moplen
;
54 len
= mopGetLength(pkt
, trans
);
65 code
= mopGetChar(pkt
,&index
);
67 /* see above, if (len < 8) then moplen ends up around 65535 */
68 if (moplen
> len
) moplen
= len
;
73 tmpc
= mopGetChar(pkt
,&index
); /* Load Number */
74 (void)fprintf(fd
,"Load Number : %02x\n",tmpc
);
77 tmpl
= mopGetLong(pkt
,&index
);/* Load Address */
78 (void)fprintf(fd
,"Load Address : %08x\n", tmpl
);
83 for (i
= 0; i
< (moplen
- 10); i
++) {
95 (void)fprintf(fd
, "%02x ",
96 mopGetChar(pkt
,&index
));
98 (void)fprintf(fd
,"\n");
102 (void)fprintf(fd
,"\n");
104 index
= index
+ moplen
- 10;
108 tmpl
= mopGetLong(pkt
,&index
); /* Load Address */
109 (void)fprintf(fd
,"Xfer Address : %08x\n", tmpl
);
119 tmpc
= mopGetChar(pkt
,&index
); /* Load Number */
120 (void)fprintf(fd
,"Load Number : %02x\n",tmpc
);
122 tmpl
= mopGetLong(pkt
,&index
); /* Load Address */
123 (void)fprintf(fd
,"Load Address : %08x\n", tmpl
);
127 for (i
= 0; i
< (moplen
- 6); i
++) {
131 "Image Data : %04x ",
138 (void)fprintf(fd
,"%02x ",
139 mopGetChar(pkt
,&index
));
141 (void)fprintf(fd
,"\n");
145 (void)fprintf(fd
,"\n");
147 index
= index
+ moplen
- 6;
159 tmpl
= mopGetLong(pkt
,&index
); /* Memory Address */
160 (void)fprintf(fd
,"Mem Address : %08x\n", tmpl
);
162 tmps
= mopGetShort(pkt
,&index
); /* Count */
163 (void)fprintf(fd
,"Count : %04x (%d)\n",tmps
,tmps
);
168 tmpc
= mopGetChar(pkt
,&index
); /* Device Type */
169 (void)fprintf(fd
, "Device Type : %02x ",tmpc
);
170 mopPrintDevice(fd
, tmpc
); (void)fprintf(fd
, "\n");
172 tmpc
= mopGetChar(pkt
,&index
); /* Format Version */
173 (void)fprintf(fd
,"Format : %02x\n",tmpc
);
175 tmpc
= mopGetChar(pkt
,&index
); /* Program Type */
176 (void)fprintf(fd
,"Program Type : %02x ",tmpc
);
177 mopPrintPGTY(fd
, tmpc
); (void)fprintf(fd
, "\n");
180 tmpc
= mopGetChar(pkt
,&index
); /* Software ID Len */
181 for (i
= 0; i
< tmpc
; i
++) {
182 program
[i
] = mopGetChar(pkt
,&index
);
186 (void)fprintf(fd
,"Software : %02x '%s'\n",tmpc
,program
);
188 tmpc
= mopGetChar(pkt
,&index
); /* Processor */
189 (void)fprintf(fd
,"Processor : %02x ",tmpc
);
190 mopPrintBPTY(fd
, tmpc
); (void)fprintf(fd
, "\n");
192 mopPrintInfo(fd
, pkt
, &index
, moplen
, code
, trans
);
197 tmpc
= mopGetChar(pkt
,&index
); /* Load Number */
198 (void)fprintf(fd
,"Load Number : %02x\n",tmpc
);
200 tmpc
= mopGetChar(pkt
,&index
); /* Error */
201 (void)fprintf(fd
,"Error : %02x (",tmpc
);
203 (void)fprintf(fd
,"no error)\n");
205 (void)fprintf(fd
,"error)\n");
211 tmpc
= mopGetChar(pkt
,&index
); /* Device Type */
212 (void)fprintf(fd
, "Device Type : %02x ",tmpc
);
213 mopPrintDevice(fd
, tmpc
); (void)fprintf(fd
, "\n");
215 tmpc
= mopGetChar(pkt
,&index
); /* Format Version */
216 (void)fprintf(fd
,"Format : %02x\n",tmpc
);
218 tmpl
= mopGetLong(pkt
,&index
); /* Memory Size */
219 (void)fprintf(fd
,"Memory Size : %08x\n", tmpl
);
221 tmpc
= mopGetChar(pkt
,&index
); /* Bits */
222 (void)fprintf(fd
,"Bits : %02x\n",tmpc
);
224 mopPrintInfo(fd
, pkt
, &index
, moplen
, code
, trans
);
229 tmpl
= mopGetLong(pkt
,&index
); /* Memory Address */
230 (void)fprintf(fd
,"Mem Address : %08x\n", tmpl
);
234 for (i
= 0; i
< (moplen
- 5); i
++) {
238 "Image Data : %04x ",
245 (void)fprintf(fd
,"%02x ",
246 mopGetChar(pkt
,&index
));
248 (void)fprintf(fd
,"\n");
251 (void)fprintf(fd
,"\n");
253 index
= index
+ moplen
- 5;
260 tmpc
= mopGetChar(pkt
,&index
); /* Load Number */
261 (void)fprintf(fd
,"Load Number : %02x\n",tmpc
);
263 tmpc
= mopGetChar(pkt
,&index
); /* Parameter Type */
264 while (tmpc
!= MOP_K_PLTP_END
) {
265 c
= mopGetChar(pkt
,&index
); /* Parameter Length */
267 case MOP_K_PLTP_TSN
: /* Target Name */
268 (void)fprintf(fd
,"Target Name : %02x '",
270 for (i
= 0; i
< ((int) c
); i
++) {
271 (void)fprintf(fd
,"%c",
272 mopGetChar(pkt
,&index
));
274 (void)fprintf(fd
,"'\n");
276 case MOP_K_PLTP_TSA
: /* Target Address */
277 (void)fprintf(fd
,"Target Addr : %02x ",c
);
278 for (i
= 0; i
< ((int) c
); i
++) {
279 (void)fprintf(fd
,"%02x ",
280 mopGetChar(pkt
,&index
));
282 (void)fprintf(fd
,"\n");
284 case MOP_K_PLTP_HSN
: /* Host Name */
285 (void)fprintf(fd
,"Host Name : %02x '",
287 for (i
= 0; i
< ((int) c
); i
++) {
288 (void)fprintf(fd
,"%c",
289 mopGetChar(pkt
,&index
));
291 (void)fprintf(fd
,"'\n");
293 case MOP_K_PLTP_HSA
: /* Host Address */
294 (void)fprintf(fd
,"Host Addr : %02x ",c
);
295 for (i
= 0; i
< ((int) c
); i
++) {
296 (void)fprintf(fd
,"%02x ",
297 mopGetChar(pkt
,&index
));
299 (void)fprintf(fd
,"\n");
301 case MOP_K_PLTP_HST
: /* Host Time */
302 ucp
= pkt
+ index
; index
= index
+ 10;
303 (void)fprintf(fd
,"Host Time : ");
304 mopPrintTime(fd
, ucp
);
305 (void)fprintf(fd
,"\n");
310 tmpc
= mopGetChar(pkt
,&index
);/* Parameter Type */
313 tmpl
= mopGetLong(pkt
,&index
); /* Transfer Address */
314 (void)fprintf(fd
,"Transfer Addr: %08x\n", tmpl
);