/* Copyright Motorola, Inc. 1993, 1994, 1999, 2000 ALL RIGHTS RESERVED You are hereby granted a copyright license to use, modify, and distribute the SOFTWARE so long as this entire notice is retained without alteration in any modified and/or redistributed versions, and that such modified versions are clearly identified as such. No licenses are granted by implication, estoppel or otherwise under any patents or trademarks of Motorola, Inc. The SOFTWARE is provided on an "AS IS" basis and without warranty. To the maximum extent permitted by applicable law, MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH REGARD TO THE SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) AND ANY ACCOMPANYING WRITTEN MATERIALS. To the maximum extent permitted by applicable law, IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE. Motorola assumes no responsibility for the maintenance and support of the SOFTWARE. */ /* config_utils.c functions to decode each config register * * * * mo 6/2/00 * */ /* Includes */ #include "config_decoder.h" int printOpen() { printf("Enter all values in hex, DO NOT preceed them with 0x\n"); printf(" Only use word boundry addresses, e.g. 0,4,8,etc\n"); printf(" Values are in little endian orientation\n "); printf(" and will be padded with zeros on the left\n"); printf(" Enter address : value\n"); printf(" Example: 04 : a00106\n"); printf(" Enter \"^D\" i.e. EOF to exit\n"); return 0; } int checkZero(int candidate) { if(candidate == 0 ) { sprintf((lh[lc]+strlen(lh[lc])),"\n"); } else { sprintf((lh[lc]+strlen(lh[lc]))," ERROR => should be zero\n"); } return 0; } int checkOne(int candidate) { if(candidate == 1 ) { sprintf((lh[lc]+strlen(lh[lc])),"\n"); } else { sprintf((lh[lc]+strlen(lh[lc]))," ERROR => should be one\n"); } return 0; } int checkAllOnes(int bitsize, int candidate) /* ensure that entire bitsize value is all ones, i.e. 2^bitsize */ { int size; size=power(2,bitsize)-1; if(candidate == size ) { sprintf((lh[lc]+strlen(lh[lc])),"\n"); } else { sprintf((lh[lc]+strlen(lh[lc]))," ERROR => should be all ones\n"); } return 0; } power(int x, int n) /* raise x to n-th power n > 0 */ { int i,p; if( n < 0 ) { sprintf((lh[lc]+strlen(lh[lc])),"ERROR: power: n < 0 \n"); return 0; } p=1; for(i=1;i<=n;++i) p = p * x; return p; } int printMsg(int candidate, char *msg1, char *msg2) /* Print first message is cindidate is 0, else print second message */ { if(candidate == 0 ) { sprintf((lh[lc]+strlen(lh[lc])),"%s\n",msg1); } else { sprintf((lh[lc]+strlen(lh[lc])),"%s\n",msg2); } return 0; } int printMsgChoice(int eol, int candidate, int first, char *msg1, int second, char *msg2) /* print msg1 only if candidate == first, * print msg2 only if candidate == second * EOL = PCR, print carrage return * != NO_PCR, don't print carrage return */ { if(candidate == first) sprintf((lh[lc]+strlen(lh[lc])),"%s",msg1); if(candidate == second) sprintf((lh[lc]+strlen(lh[lc])),"%s",msg2); if(eol == PCR) sprintf((lh[lc]+strlen(lh[lc])),"\n"); return 0; } printMCCR3(int candidate,int low,int high, int eight, int sixteen) /* printf description of MCCR3 values, * eight is used when 0 => 8 set to != 0 when not used * sixteen is used when 0 => 16 set to != 0 when not used * low is lowest value that => clocks * high is highest value that => clocks * else it is a reserved value */ { if(candidate == eight) sprintf((lh[lc]+strlen(lh[lc])),"8 clocks\n"); else if(candidate == sixteen) sprintf((lh[lc]+strlen(lh[lc])),"16 clocks\n"); else if((candidate < low) || (candidate > high) ) sprintf((lh[lc]+strlen(lh[lc])),"Reserved Do not use\n"); else sprintf((lh[lc]+strlen(lh[lc])),"%d clocks\n",candidate); } int printTS_WAIT(int candidate) /* printf description of TS_WAIT_TIMER values, */ { int clock; int mhz66[8]={30,30,45,60,75,90,105,120}; int mhz83[8]={24,24,36,48,60,72,84,96}; if((candidate == 0) || (candidate == 1)) clock=2; else clock=candidate+1; sprintf((lh[lc]+strlen(lh[lc])),"%d clocks %dns @ 66MHz %dns @83MHz\n", clock,mhz66[candidate],mhz83[candidate]); } int decodeSDMODE_106(int value) /* decode the SDMODE bits for the MPC106 */ { int OPCODE=0x00000f80, CAS=0x00000070, WT=0x00000008, WLNTH=0x00000007; int temp; temp=(value&WLNTH); lc++;sprintf((lh[lc])," Wrap Length = 0x%01X ",temp); if(temp == 2) sprintf((lh[lc]+strlen(lh[lc])),"4\n"); else sprintf((lh[lc]+strlen(lh[lc])),"%s\n",msga8CMM1); temp=(value&WT)>>3; lc++;sprintf((lh[lc])," Wrap Type = 0x%01X ",temp); printMsg(temp,msgfcWT0,msgfcWT1); temp=(value&CAS)>>4; lc++;sprintf((lh[lc])," CAS Latency = 0x%01X ",temp); if((temp > 0) && (temp < 5)) sprintf((lh[lc]+strlen(lh[lc])),"%d\n",temp); else sprintf((lh[lc]+strlen(lh[lc])),"%s\n",msga8CMM1); temp=(value&OPCODE)>>7; lc++;sprintf((lh[lc])," OPCODE = 0x%01X\n",temp); return 0; } int decodeSDMODE_107(int value) /* decode the SDMODE bits for the MPC107 and MPC8240A and H mode */ { int CAS=0x00000070, WT=0x00000008, BLNTH=0x00000007; int temp; temp=(value&BLNTH); lc++;sprintf((lh[lc])," Burst Length = 0x%01X ",temp); if(temp == 2) sprintf((lh[lc]+strlen(lh[lc])),"4\n"); else if(temp == 3) sprintf((lh[lc]+strlen(lh[lc])),"8\n"); else sprintf((lh[lc]+strlen(lh[lc])),"%s\n",msga8CMM1); temp=(value&WT)>>3; lc++;sprintf((lh[lc])," Wrap Type = 0x%01X ",temp); printMsg(temp,msgfcWT0,msgfcWT1); temp=(value&CAS)>>4; lc++;sprintf((lh[lc])," CAS Latency = 0x%01X ",temp); if((temp > 0) && (temp < 4)) sprintf((lh[lc]+strlen(lh[lc])),"%d\n",temp); else sprintf((lh[lc]+strlen(lh[lc])),"%s\n",msga8CMM1); return 0; } int decodePCI_106(int value) /* decode the PCI Command Register bit 14 for the MPC106 */ { int Z1=0x00000020, RDLCK=0x00000010, Z2=0x0000000f; int temp; temp=(value&Z2); lc++;sprintf((lh[lc])," unnamed bits 13-10 = 0x%x",temp); checkZero(temp); temp=(value&RDLCK)>>4; lc++;sprintf((lh[lc])," Read_Lock = 0x%x ",temp); printMsg(temp,msg04RDL0,msg04RDL1); temp=(value&Z1)>>5; lc++;sprintf((lh[lc])," unnamed bit 15 = 0x%x",temp); checkZero(temp); return 0; } int printOrder() /* print the lines from lh in order specified * BIG endian or * LITTLE endian */ { int i; if(lc > MAXLINE) { printf("ERROR: lh lc larger than MAXLINE! Aborting\n"); exit(1); } if(lc < 0) { printf("ERROR: lh lc less than ZERO! Aborting\n"); exit(1); } if(order == BIG) /* big endian order */ { for(i=0;i<=lc;i++) printf("%s",lh[i]); } else /* little endian order */ { if(li == -1) { for(i=lc;i>=0;i--) printf("%s",lh[i]); } else /* li is the last index */ { while(li >=0) { #ifdef DEBUG printf("DEBUG:li = %d, lhIndex[li] = %d\n",li,lhIndex[li] ); #endif /* DEBUG */ printf("%s",lh[ lhIndex[li] ]); for(i=lc;i>lhIndex[li];i--) printf("%s",lh[i]); li--; lc=i-1; } } } lc=-1; /* reset */ li=-1; /* reset */ }