1 /* $NetBSD: dl.c,v 1.6 2009/10/20 00:51:13 snj 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.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <sys/cdefs.h>
29 __RCSID("$NetBSD: dl.c,v 1.6 2009/10/20 00:51:13 snj Exp $");
39 mopDumpDL(FILE *fd
, const u_char
*pkt
, int trans
)
43 u_char tmpc
,c
,program
[257],code
;
45 u_short len
,tmps
,moplen
;
47 len
= mopGetLength(pkt
, trans
);
58 code
= mopGetChar(pkt
,&idx
);
63 tmpc
= mopGetChar(pkt
,&idx
); /* Load Number */
64 (void)fprintf(fd
,"Load Number : %02x\n",tmpc
);
67 tmpl
= mopGetLong(pkt
,&idx
);/* Load Address */
68 (void)fprintf(fd
,"Load Address : %08x\n", tmpl
);
73 for (i
= 0; i
< (moplen
- 10); i
++) {
85 (void)fprintf(fd
, "%02x ",
86 mopGetChar(pkt
,&idx
));
88 (void)fprintf(fd
,"\n");
92 (void)fprintf(fd
,"\n");
94 idx
= idx
+ moplen
- 10;
98 tmpl
= mopGetLong(pkt
,&idx
); /* Load Address */
99 (void)fprintf(fd
,"Xfer Address : %08x\n", tmpl
);
109 tmpc
= mopGetChar(pkt
,&idx
); /* Load Number */
110 (void)fprintf(fd
,"Load Number : %02x\n",tmpc
);
112 tmpl
= mopGetLong(pkt
,&idx
); /* Load Address */
113 (void)fprintf(fd
,"Load Address : %08x\n", tmpl
);
117 for (i
= 0; i
< (moplen
- 6); i
++) {
121 "Image Data : %04x ",
128 (void)fprintf(fd
,"%02x ",
129 mopGetChar(pkt
,&idx
));
131 (void)fprintf(fd
,"\n");
135 (void)fprintf(fd
,"\n");
137 idx
= idx
+ moplen
- 6;
149 tmpl
= mopGetLong(pkt
,&idx
); /* Memory Address */
150 (void)fprintf(fd
,"Mem Address : %08x\n", tmpl
);
152 tmps
= mopGetShort(pkt
,&idx
); /* Count */
153 (void)fprintf(fd
,"Count : %04x (%d)\n",tmps
,tmps
);
158 tmpc
= mopGetChar(pkt
,&idx
); /* Device Type */
159 (void)fprintf(fd
, "Device Type : %02x ",tmpc
);
160 mopPrintDevice(fd
, tmpc
); (void)fprintf(fd
, "\n");
162 tmpc
= mopGetChar(pkt
,&idx
); /* Format Version */
163 (void)fprintf(fd
,"Format : %02x\n",tmpc
);
165 tmpc
= mopGetChar(pkt
,&idx
); /* Program Type */
166 (void)fprintf(fd
,"Program Type : %02x ",tmpc
);
167 mopPrintPGTY(fd
, tmpc
); (void)fprintf(fd
, "\n");
170 tmpc
= mopGetChar(pkt
,&idx
); /* Software ID Len */
171 for (i
= 0; i
< tmpc
; i
++) {
172 program
[i
] = mopGetChar(pkt
,&idx
);
176 (void)fprintf(fd
,"Software : %02x '%s'\n",tmpc
,program
);
178 tmpc
= mopGetChar(pkt
,&idx
); /* Processor */
179 (void)fprintf(fd
,"Processor : %02x ",tmpc
);
180 mopPrintBPTY(fd
, tmpc
); (void)fprintf(fd
, "\n");
182 mopPrintInfo(fd
, pkt
, &idx
, moplen
, code
, trans
);
187 tmpc
= mopGetChar(pkt
,&idx
); /* Load Number */
188 (void)fprintf(fd
,"Load Number : %02x\n",tmpc
);
190 tmpc
= mopGetChar(pkt
,&idx
); /* Error */
191 (void)fprintf(fd
,"Error : %02x (",tmpc
);
193 (void)fprintf(fd
,"no error)\n");
195 (void)fprintf(fd
,"error)\n");
201 tmpc
= mopGetChar(pkt
,&idx
); /* Device Type */
202 (void)fprintf(fd
, "Device Type : %02x ",tmpc
);
203 mopPrintDevice(fd
, tmpc
); (void)fprintf(fd
, "\n");
205 tmpc
= mopGetChar(pkt
,&idx
); /* Format Version */
206 (void)fprintf(fd
,"Format : %02x\n",tmpc
);
208 tmpl
= mopGetLong(pkt
,&idx
); /* Memory Size */
209 (void)fprintf(fd
,"Memory Size : %08x\n", tmpl
);
211 tmpc
= mopGetChar(pkt
,&idx
); /* Bits */
212 (void)fprintf(fd
,"Bits : %02x\n",tmpc
);
214 mopPrintInfo(fd
, pkt
, &idx
, moplen
, code
, trans
);
219 tmpl
= mopGetLong(pkt
,&idx
); /* Memory Address */
220 (void)fprintf(fd
,"Mem Address : %08x\n", tmpl
);
224 for (i
= 0; i
< (moplen
- 5); i
++) {
228 "Image Data : %04x ",
235 (void)fprintf(fd
,"%02x ",
236 mopGetChar(pkt
,&idx
));
238 (void)fprintf(fd
,"\n");
241 (void)fprintf(fd
,"\n");
243 idx
= idx
+ moplen
- 5;
250 tmpc
= mopGetChar(pkt
,&idx
); /* Load Number */
251 (void)fprintf(fd
,"Load Number : %02x\n",tmpc
);
253 tmpc
= mopGetChar(pkt
,&idx
); /* Parameter Type */
254 while (tmpc
!= MOP_K_PLTP_END
) {
255 c
= mopGetChar(pkt
,&idx
); /* Parameter Length */
257 case MOP_K_PLTP_TSN
: /* Target Name */
258 (void)fprintf(fd
,"Target Name : %02x '",
260 for (i
= 0; i
< ((int) c
); i
++) {
261 (void)fprintf(fd
,"%c",
262 mopGetChar(pkt
,&idx
));
264 (void)fprintf(fd
,"'\n");
266 case MOP_K_PLTP_TSA
: /* Target Address */
267 (void)fprintf(fd
,"Target Addr : %02x ",c
);
268 for (i
= 0; i
< ((int) c
); i
++) {
269 (void)fprintf(fd
,"%02x ",
270 mopGetChar(pkt
,&idx
));
272 (void)fprintf(fd
,"\n");
274 case MOP_K_PLTP_HSN
: /* Host Name */
275 (void)fprintf(fd
,"Host Name : %02x '",
277 for (i
= 0; i
< ((int) c
); i
++) {
278 (void)fprintf(fd
,"%c",
279 mopGetChar(pkt
,&idx
));
281 (void)fprintf(fd
,"'\n");
283 case MOP_K_PLTP_HSA
: /* Host Address */
284 (void)fprintf(fd
,"Host Addr : %02x ",c
);
285 for (i
= 0; i
< ((int) c
); i
++) {
286 (void)fprintf(fd
,"%02x ",
287 mopGetChar(pkt
,&idx
));
289 (void)fprintf(fd
,"\n");
291 case MOP_K_PLTP_HST
: /* Host Time */
292 ucp
= pkt
+ idx
; idx
= idx
+ 10;
293 (void)fprintf(fd
,"Host Time : ");
294 mopPrintTime(fd
, ucp
);
295 (void)fprintf(fd
,"\n");
300 tmpc
= mopGetChar(pkt
,&idx
);/* Parameter Type */
303 tmpl
= mopGetLong(pkt
,&idx
); /* Transfer Address */
304 (void)fprintf(fd
,"Transfer Addr: %08x\n", tmpl
);