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