home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <error.h>
- #include <ctype.h>
- #include <fcntl.h>
- #include <exec/types.h>
- #include <exec/exec.h>
- #include <exec/execbase.h>
- #include <exec/devices.h>
- #include <janus/janus.h>
- #include <libraries/expansionbase.h>
- #include <libraries/expansion.h>
- #include <libraries/configvars.h>
- #include <libraries/dos.h>
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <proto/janus.h>
- #include <proto/expansion.h>
-
- /**********************************************************************/
- /* Freely Given into the Public Domain */
- /**********************************************************************/
- /* This program is meant as a general-purpose informational tool for */
- /* working with the Amiga Bridgecard. All structures and operation */
- /* were gleaned from includes and various documents and may change or */
- /* be plain wrong. I welcome any clarifications and suggestions for */
- /* new pieces of data to display or new checks to perform on Janus. */
- /* */
- /* By: Jeff Rush of Tau Productions */
- /* BIX: jrush */
- /* Sysop of the Rising Star BBS (An Opus Echomail System) */
- /* (214) 231-1372 300/1200/2400 24hrs */
- /* Fidonet 1:124/4206 */
- /**********************************************************************/
- /* No attempt has been made to make this code small or efficient. */
- /* Due to the infrequent use and non-residency of this code, there is */
- /* little need to squeeze, but knock yourself out if you wish. It is */
- /* written so as to be easy to understand its workings and flow. I */
- /* hope I succeeded...:-) */
- /**********************************************************************/
- /* 26Feb90 JRR Original Creation */
- /* 04Mar90 JRR Added Service Interrupts */
- /**********************************************************************/
-
- /************************/
- /* Constants and Macros */
- /************************/
- #define MAXFLIST 100 /* Maximum # of Free Memory Blocks Expected Per Region */
-
- #ifndef TRUE
- #define TRUE 1
- #endif
-
- #ifndef FALSE
- #define FALSE 0
- #endif
-
- /***************************/
- /* Structures and Typedefs */
- /***************************/
- typedef unsigned long ulong;
- typedef unsigned char bool;
- typedef unsigned char byte;
- typedef unsigned short word;
-
- typedef struct Library LIBRARY;
-
- typedef struct ConfigDev CONFIGDEV;
- typedef struct JanusAmiga JANUSAMIGA;
- typedef struct JanusMemHead JANUSMEMHEAD;
- typedef struct JanusMemChunk JANUSMEMCHUNK;
-
- struct _flist {
- UBYTE *base; /* Base Address of Free Block */
- UWORD size; /* Length of Free Block */
- };
-
- /**************/
- /* Prototypes */
- /**************/
- bool Initialize(int argc, char *argv[]);
- void Terminate(int retcode);
- CONFIGDEV *FindBridgeCard(void);
- void ShowConfigDevices(void);
- void IdentifyJanus(void);
- void ShowJanusState(void);
- void ShowFreelist(JANUSMEMHEAD *jmh);
- void CheckNormalJanusFiles(void);
- void CheckCriticalJanusFiles(void);
- void CheckFile(char *f);
- long ScanFile(char *fname, long *ckcode);
-
- word CalcCRC16(word accum, byte *blk, int blklen);
- word CalcCRC_CCITT(word accum, byte *blk, int blklen);
-
- int cmpflist(struct _flist *a, struct _flist *b);
-
- /********************/
- /* Global Variables */
- /********************/
- struct ExpansionBase *ExpansionBase = NULL;
- bool shutdown = FALSE; /* Server Shutdown Request Flag */
- bool opt_skipfiles = FALSE;
-
- struct JanusBase *JanusBase = NULL;
- CONFIGDEV *Bridgecard = NULL;
-
- struct _flist flist[MAXFLIST];
- int numflist = 0;
-
- char *snames[] = {
- "Write to Mono Video RAM",
- "",
- "Write to CGA Video RAM",
- "",
- "Write to Mono Video Registers",
- "",
- "Write to CGA Video Registers",
- "",
- "PC Keyboard Ready for Keystroke",
- "",
- "Write to Parallel I/O Register",
- "",
- "Write to Serial I/O Register",
- "",
- "PC Booted, Ready for Action",
- "",
- "PC Wants to Scroll Its Video",
- "",
- "Amiga Reading PC Harddisk",
- "",
- "PC Reading Amiga Memory",
- "",
- "Amiga Reading PC Memory",
- "",
- "PC Executing Amiga Routine",
- "",
- "Amiga Causing PC Interrupt",
- "",
- "PC Triggering Amiga Side of",
- " a New Service",
- "Amiga Triggering PC Side of",
- " a New Service"
- };
- #define NUM_SNAMES (sizeof(snames)/sizeof(char *))
-
- /**********************************************************************/
- /* */
- /**********************************************************************/
- void
- main(int argc, char *argv[])
- {
- printf("Bridgecard Configuration Diagnostic v1.0 by Jeff Rush (04Mar90)\n");
- printf("* Freely Given into the Public Domain with Full Source Code *\n\n");
-
- if (Initialize(argc, argv)) {
-
- printf("Status of Bridgecard Hardware:\n");
- Bridgecard = FindBridgeCard(); /* Locate Bridgecard Autoconfig Hardware */
-
- if (!opt_skipfiles) {
- printf("Status of Critical Support Files:\n");
- CheckCriticalJanusFiles();
-
- printf("Status of Normal Support Files:\n");
- CheckNormalJanusFiles();
- }
-
- if (JanusBase != NULL) {
- IdentifyJanus(); /* Print Identifying Data About Janus Library */
- ShowJanusState(); /* Print Data in Janus Shared Memory */
- }
-
- Terminate(0);
- } else
- Terminate(10);
- }
- /**********************************************************************/
- /* */
- /**********************************************************************/
- void
- CheckFile(char *f)
- {
- long ckcode, n;
- char line[256];
-
- sprintf(line, " %s", f);
- while (strlen(line) < 38)
- strcat(line, " ");
-
- printf("%s", line);
-
- n = ScanFile(f, &ckcode);
- if (n < 0) printf("Error: %s\n", (errno<sys_nerr) ? sys_errlist[errno] : "Unknown");
- else printf("Check: 0x%08lX, %8lu\n", ckcode, n);
- }
- /**********************************************************************/
- /* */
- /**********************************************************************/
- void
- CheckCriticalJanusFiles()
- {
- CheckFile("SYS:Expansion/Janus.Library"); /* Janus Library */
-
- /**********************************/
- /* Check for an Old Janus Library */
- /**********************************/
- if (access("LIBS:Janus.Library", 0) == 0)
- printf(" *** Warning - Delete the JANUS.LIBRARY in LIBS: ***\n");
-
- CheckFile("SYS:Expansion/Janus.Library.info"); /* Janus Icon in Expansion Drawer */
- CheckFile("SYS:PC/System/PC.Boot"); /* Janus PC-Side Handler Code (PC.BOOT) */
- CheckFile("SYS:PC/System/ScanCode.Table"); /* Keyboard Conversion Table */
- CheckFile("SYS:PC/System/SidecarKeys.Table"); /* Sidecar Keys Table (Obsolete?) */
- CheckFile("SYS:PC/System/SidecarSettings.Table"); /* Sidecard Settings Table */
- CheckFile("SYS:PC/PCWindow"); /* PCWindow Program */
-
- printf("\n");
- }
- /**********************************************************************/
- /* */
- /**********************************************************************/
- void
- CheckNormalJanusFiles()
- {
- CheckFile("SYS:PC/PCHard");
- CheckFile("SYS:PC/PCDisk");
- CheckFile("SYS:PC/PCPrefs");
- CheckFile("SYS:PC/Services/Timeserv");
- CheckFile("SYS:PC/LPT1");
- CheckFile("FONTS:PCFont.font");
- CheckFile("DEVS:Jdisk.device");
- CheckFile("C:DJMount");
- CheckFile("SYS:PC/Amouse");
-
- printf("\n");
- }
- /**********************************************************************/
- /* */
- /**********************************************************************/
- long
- ScanFile(char *fname, long *ckcode)
- {
- byte buffer[1024];
- word ck1, ck2;
- int fd, n;
- long size = 0L;
-
- fd = open(fname, O_RDONLY);
- if (fd < 0)
- return -1;
-
- ck1 = ck2 = 0;
- size = 0L;
- while ((n = read(fd, buffer, sizeof(buffer))) > 0) {
- ck1 = CalcCRC16(ck1, buffer, n);
- ck2 = CalcCRC_CCITT(ck2, buffer, n);
- size += n;
- }
- *ckcode = ((long)ck1 << 16) | ck2;
-
- close(fd);
- return size;
- }
- /**********************************************************************/
- /* */
- /**********************************************************************/
- void
- IdentifyJanus()
- {
- struct Interrupt *i;
- struct ServiceBase *s;
- byte pcprefs, bank;
-
- printf("Status of Janus.Library for an %s-Bridgecard:\n",
- JanusBase->jb_ATFlag ? "(A2286) AT" : "(A2088) PC");
-
- printf(" Library Version %u.%u (%s), Open Count = %u, Checksum = 0x%08lX\n",
- JanusBase->jb_LibNode.lib_Version,
- JanusBase->jb_LibNode.lib_Revision,
- JanusBase->jb_LibNode.lib_IdString,
- JanusBase->jb_LibNode.lib_OpenCnt,
- JanusBase->jb_LibNode.lib_Sum);
-
- printf(" Outstanding Intr Requests (Bitfield) : 0x%08lX\n", JanusBase->jb_IntReq);
- printf(" Enabled Intrs (Bitfield) : 0x%08lX\n", JanusBase->jb_IntEna);
- printf(" Location of Parameter Memory : 0x%08lX\n", JanusBase->jb_ParamMem);
- printf(" Location of I/O Register Map : 0x%08lX\n", JanusBase->jb_IoBase);
- printf(" Base Address of Janus AutoConfig Hardware : 0x%08lX\n", JanusBase->jb_ExpanBase);
- printf(" Ptr to Seglist of Loaded Code : 0x%08lX\n", JanusBase->jb_SegList);
- printf(" Offset of the Keyboard Register : 0x%04X\n", JanusBase->jb_KeyboardRegisterOffset);
- printf(" Offset of the AT Rom Bank (ATs Only) : 0x%04X\n", JanusBase->jb_ATOffset);
- printf(" JSERV_READAMIGA Handler Code : 0x%08lX\n", JanusBase->jb_ReadHandler.is_Code);
- printf(" Data : 0x%08lX\n", JanusBase->jb_ReadHandler.is_Data);
- printf(" From-PC Hardware Interrupt Server Code : 0x%08lX\n", JanusBase->jb_IntServer.is_Code);
- printf(" Data : 0x%08lX\n", JanusBase->jb_IntServer.is_Data);
-
- pcprefs = *((byte *)(JanusBase->jb_IoBase) + 0x1FF7);
- bank = (pcprefs >> 5) & 0x03;
-
- printf("\n Emulation of PC Hardware by the Amiga (As Set by PCPREFS Utility)\n");
- printf(" PC Serial Interface (COM2:) : %s\n", (pcprefs & 0x01) ? "Enabled" : "Disabled");
- printf(" PC Parallel Interface (LPT1:) : %s\n", (pcprefs & 0x02) ? "Enabled" : "Disabled");
- printf(" PC Keyboard Interface : %s\n", (pcprefs & 0x04) ? "Enabled" : "Disabled");
- printf(" PC Monochrome Display (MDA) : %s\n", (pcprefs & 0x08) ? "Enabled" : "Disabled");
- printf(" PC Graphics Display (CGA) : %s\n", (pcprefs & 0x10) ? "Enabled" : "Disabled");
-
- printf("\n Hardware Operating Mode (As Set by PCPREFS Utility)\n");
- printf(" Location of PC Memory : ");
- switch(bank) {
- case 0: printf("(Not Used)\n"); break;
- case 1: printf("A0000-AFFFF\n"); break;
- case 2: printf("%s\n", (pcprefs & 0x80) ? "D0000-DFFFF" : "D4000-DFFFF"); break;
- case 3: printf("%s\n", (pcprefs & 0x80) ? "E0000-EFFFF" : "(Not Used)"); break;
- }
-
- printf(" Type of Machine Emulated in Hardware : %s\n", (pcprefs & 0x80) ? "PC" : "AT");
-
- i = *(JanusBase->jb_IntHandlers);
-
- s = JanusBase->jb_ServiceBase;
-
- printf("\n");
-
- #if FALSE
- struct Interrupt **jb_IntHandlers;/* base array of int handler ptrs */
- struct ServiceBase *jb_ServiceBase; /* Amiga Services data structure */
- #endif
- }
-
- /**********************************************************************/
- /* */
- /**********************************************************************/
- void
- ShowJanusState()
- {
- int i;
- JANUSAMIGA *ja;
- JANUSMEMHEAD *jmh;
- VOID (*nop_code)(), (*i_code)();
- APTR nop_data, i_data;
-
- ja = (JANUSAMIGA *)MakeWordPtr((APTR)(JanusBase->jb_ParamMem));
-
- printf("Status of Janus Shared Memory on Bridgecard Hardware:\n");
- printf(" Version of Janus.Library : %u.%u\n",
- ja->ja_JLibVer, ja->ja_JLibRev);
- printf(" Version of Janus Handler (PC.BOOT) : %u.%u\n",
- ja->ja_JHandlerVer, ja->ja_JHandlerRev);
- printf(" Janus Handler Initialization Flag : 0x%02X%02X%s\n",
- ja->ja_HandlerLoaded & 0xFF, ja->ja_HandlerLoaded >> 8,
- (ja->ja_HandlerLoaded == 0x5442) ? " ('BT')" : "");
- printf(" Maximum Number of Service Interrupts : %u\n", ja->ja_NumInterrupts);
-
- /**************************************************************/
- /* Heuristic! Assuming the Last Slot of the Services is Idle, */
- /* Its Contents Must Point to Null Stubs for Safe Operation. */
- /**************************************************************/
- nop_code = JanusBase->jb_IntHandlers[ja->ja_NumInterrupts - 1]->is_Code;
- nop_data = JanusBase->jb_IntHandlers[ja->ja_NumInterrupts - 1]->is_Data;
-
- printf("\n Table of Service Interrupts (Not for 3rd-Party Use):\n");
-
- for(i=0; i<ja->ja_NumInterrupts; i++) {
- i_code = JanusBase->jb_IntHandlers[i]->is_Code;
- i_data = JanusBase->jb_IntHandlers[i]->is_Data;
-
- printf(" %2d %-32sCode : 0x%08lX%s\n",
- i, (i*2 > NUM_SNAMES-1) ? "Unknown Service" : snames[i*2],
- i_code, (i_code == nop_code) ? " (Null Stub)" : "");
-
- printf(" %-32sData : 0x%08lX%s\n",
- (i*2 > NUM_SNAMES-1) ? "" : snames[i*2+1],
- i_data, (i_data == nop_data) ? " (Null Data)" : "");
- }
-
- /**********************************/
- /* Display Parameter Memory Usage */
- /**********************************/
- jmh = &(ja->ja_ParamMem);
- printf("\n Parameter Memory: (Used=%u, Free=%u, Total=%u)\n",
- jmh->jmh_Max - jmh->jmh_Free, jmh->jmh_Free + 1, jmh->jmh_Max + 1);
-
- printf(" Lock Byte : 0x%02X%s\n", jmh->jmh_Lock,
- (jmh->jmh_Lock == 0x00) ? " (Unlocked)" : " (Locked)");
- printf(" 68000 Base Address: 0x%08lX\n", jmh->jmh_68000Base);
- printf(" 80x86 Base Segment: 0x%04X\n", jmh->jmh_8088Segment);
-
- ShowFreelist(jmh);
-
- /*******************************/
- /* Display Buffer Memory Usage */
- /*******************************/
- jmh = &(ja->ja_BufferMem);
- printf("\n Buffer Memory: (Used=%u, Free=%u, Total=%u)\n",
- jmh->jmh_Max - jmh->jmh_Free, jmh->jmh_Free + 1, jmh->jmh_Max + 1);
-
- printf(" Lock Byte : 0x%02X%s\n", jmh->jmh_Lock,
- (jmh->jmh_Lock == 0x00) ? " (Unlocked)" : " (Locked)");
- printf(" 68000 Base Address: 0x%08lX\n", jmh->jmh_68000Base);
- printf(" 80x86 Base Segment: 0x%04X\n", jmh->jmh_8088Segment);
-
- ShowFreelist(jmh);
-
- printf("\n");
- }
- /**********************************************************************/
- /* */
- /**********************************************************************/
- void
- ShowFreelist(JANUSMEMHEAD *jmh)
- {
- JANUSMEMCHUNK *jmc;
- UBYTE *bp; /* Byte Pointer */
- int i;
-
- /***********************************/
- /* Collect Information and Sort It */
- /***********************************/
- jmc = (JANUSMEMCHUNK *)MakeWordPtr((APTR)((UBYTE *)(jmh->jmh_68000Base) + jmh->jmh_First));
- numflist = 0;
- JanusLock(MakeBytePtr((APTR)(&jmh->jmh_Lock)));
- while (jmc != (JANUSMEMCHUNK *)jmh->jmh_68000Base) {
- flist[numflist].base = (UBYTE *)jmc;
- flist[numflist].size = jmc->jmc_Size + 1;
-
- if (++numflist == MAXFLIST || jmc->jmc_Next == 0xFFFF)
- break;
-
- bp = (UBYTE *)(jmh->jmh_68000Base);
-
- if (jmc->jmc_Next & 1) /* If Odd Increment, Round to Next Word Boundary */
- bp++;
-
- jmc = (JANUSMEMCHUNK *)MakeWordPtr((APTR)(bp + jmc->jmc_Next));
- }
- JanusUnlock(MakeBytePtr((APTR)(&jmh->jmh_Lock)));
-
- qsort((char *)flist, numflist, sizeof(struct _flist), cmpflist);
-
- /******************************************/
- /* Display Information in Ascending Order */
- /******************************************/
- printf("\n Amiga-Addr PC-Addr Length Status\n");
- bp = (UBYTE *)jmh->jmh_68000Base;
- for(i=0; i<numflist; i++) {
- if (flist[i].base != bp) { /* If Out of Sync */
- printf(" 0x%08lX (%04X:%04X) %6u Allocated\n",
- bp, jmh->jmh_8088Segment,
- (bp - (UBYTE *)(jmh->jmh_68000Base)) & 0xFFFF,
- (flist[i].base - bp) & 0xFFFF);
-
- bp = flist[i].base; /* Catch Up to Tracking Pointer */
- }
-
- printf(" 0x%08lX (%04X:%04X) %6u Free\n",
- bp, jmh->jmh_8088Segment,
- (bp - (UBYTE *)(jmh->jmh_68000Base)) & 0xFFFF,
- flist[i].size);
-
- bp += flist[i].size; /* Advance Past Free Block */
- }
- if (bp < (UBYTE *)jmh->jmh_68000Base + jmh->jmh_Max) {
- printf(" 0x%08lX (%04X:%04X) %6u Allocated\n",
- bp, jmh->jmh_8088Segment,
- (bp - (UBYTE *)(jmh->jmh_68000Base)) & 0xFFFF,
- (flist[i].base - bp) & 0xFFFF);
- }
- }
- /**********************************************************************/
- /* */
- /**********************************************************************/
- int
- cmpflist(struct _flist *a, struct _flist *b)
- {
- if (a->base > b->base) return 1;
- else if (a->base < b->base) return -1;
- else return 0;
- }
- /**********************************************************************/
- /* */
- /**********************************************************************/
- CONFIGDEV *
- FindBridgeCard()
- {
- CONFIGDEV *cd;
-
- cd = FindConfigDev((LONG)NULL, 513L, 1L);
-
- if (cd == NULL) {
- printf("Bridgecard Autoconfig Interface Not Found (Manufacturer %lu, Product %lu)\n",
- 513L, 1L);
- printf("Other Autoconfig Devices are:\n");
- ShowConfigDevices();
-
- } else {
- printf("%s Bridgecard @ 0x%08lX, Length %4luKb, Driver @ 0x%08lX\n",
- (cd->cd_Flags & CDF_CONFIGME) ? "Unconfigured" : " Configured",
- cd->cd_BoardAddr, (long)cd->cd_BoardSize / 1024L, cd->cd_Driver);
- printf(" Given Slots %u Through %u (%u Slots)\n",
- cd->cd_SlotAddr, cd->cd_SlotAddr + cd->cd_SlotSize - 1, cd->cd_SlotSize);
- }
- printf("\n");
- return cd;
- }
- /**********************************************************************/
- /* */
- /**********************************************************************/
- void
- ShowConfigDevices()
- {
- CONFIGDEV *cd;
-
- cd = NULL;
- while ((cd = FindConfigDev((LONG)cd, -1, -1)) != NULL) {
- printf("%s Device @ 0x%08lX, Length %4luKb, Driver @ 0x%08lX\n",
- (cd->cd_Flags & CDF_CONFIGME) ? "Unconfigured" : " Configured",
- cd->cd_BoardAddr, (long)cd->cd_BoardSize / 1024L, cd->cd_Driver);
- printf(" Given Slots %u Through %u (%u Slots)\n",
- cd->cd_SlotAddr, cd->cd_SlotAddr + cd->cd_SlotSize - 1, cd->cd_SlotSize);
- }
- }
- /**********************************************************************/
- /* Calculate CRC16 of a Block of Data */
- /* */
- /* CRC16 polynomial: x**0 + x**2 + x**15 + x**16 (0xA001) */
- /* Initial condition: 0 */
- /* */
- /* D. Hugh Redelmeier 1983 April 15 */
- /* Latest change: 1984 April 2. */
- /* */
- /*>PROTOTYPE word CalcCRC16(word accum, byte *blk, int blklen) */
- /**********************************************************************/
-
- /**********************************************************************/
- /* */
- /**********************************************************************/
- static word CRC16table[256] = {
- 0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241,
- 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440,
- 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
- 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841,
- 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40,
- 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41,
- 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641,
- 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040,
- 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240,
- 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441,
- 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41,
- 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840,
- 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41,
- 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40,
- 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640,
- 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041,
- 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240,
- 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441,
- 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41,
- 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840,
- 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41,
- 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40,
- 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640,
- 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041,
- 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241,
- 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440,
- 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40,
- 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841,
- 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40,
- 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41,
- 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641,
- 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040
- };
- /**********************************************************************/
- /* */
- /**********************************************************************/
- word
- CalcCRC16(accum, blk, blklen)
- register word accum;
- byte *blk;
- int blklen;
- {
- while (blklen--)
- accum = CRC16table[(accum ^ *blk++) & 0xFF] ^ accum >> 8;
-
- return accum;
- }
- /**********************************************************************/
- /* Calculate CRC (CCITT) of a Block of Data */
- /* */
- /* CCITT SDLC/HDLC polynomial: X**0 + X**5 + X**12 + X**16 */
- /* Initial condition: 0 */
- /* */
- /* D. Hugh Redelmeier 1983 April 15 */
- /* Latest change: 1984 April 2. */
- /* */
- /*>PROTOTYPE word CalcCRC_CCITT(word accum, byte *blk, int blklen) */
- /**********************************************************************/
-
- /**********************************************************************/
- /* */
- /**********************************************************************/
- static word CRC16table2[256] = {
- 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
- 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
- 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
- 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
- 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
- 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
- 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
- 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
- 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
- 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
- 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
- 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
- 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
- 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
- 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
- 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
- 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
- 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
- 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
- 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
- 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
- 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
- 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
- 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
- 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
- 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
- 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
- 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
- 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
- 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
- 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
- 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
- };
- /**********************************************************************/
- /* */
- /**********************************************************************/
- word
- CalcCRC_CCITT(accum, blk, blklen)
- register word accum;
- byte *blk;
- int blklen;
- {
- while (blklen--)
- accum = CRC16table2[(accum ^ *blk++) & 0xFF] ^ accum >> 8;
-
- return accum;
- }
- /**********************************************************************/
- /* */
- /**********************************************************************/
- bool
- Initialize(int argc, char *argv[])
- {
- if (argc >= 2 && toupper(*argv[1]) == 'H') {
- printf("Usage: JDIAG {Fast}\n");
- printf(" Fast ::= Omit Scans of Command Files\n");
- return FALSE;
- }
-
- if ((ExpansionBase = (struct ExpansionBase *) OpenLibrary(EXPANSIONNAME, 0)) == NULL) {
- printf("Unable to Open Expansion.Library, Shutting Down.\n");
- return FALSE;
- }
-
- JanusBase = (struct JanusBase *)OpenLibrary(JANUSNAME, 0);
-
- if (argc >= 2 && toupper(*argv[1]) == 'F')
- opt_skipfiles = TRUE;
-
- return TRUE;
- }
- /**********************************************************************/
- /* */
- /**********************************************************************/
- void
- Terminate(int retcode)
- {
- if (JanusBase) CloseLibrary((LIBRARY *)JanusBase);
- if (ExpansionBase) CloseLibrary((LIBRARY *)ExpansionBase);
-
- exit(retcode);
- }
- /**********************************************************************/
- /* */
- /**********************************************************************/
-
-