/*
* DIAGNOSTICS
*/
#include <stdio.h>
#include <time.h>
#include <dos.h>
#include "global.h"
struct FAR_OBJ
{
unsigned int offset;
unsigned int segment;
};
union PTR_OBJ
{
struct FAR_OBJ seg_off;
char far *ptr;
};
static diag_code = 0;
struct DIAG_OBJ
{
char *str;
unsigned int bit_val;
};
static struct DIAG_OBJ diags[] =
{
{"No Diagnostics",DIAG_NONE},
{"Disable Ctrl-Break",DIAG_NO_CTRL_BRK},
{"ASPI loop-back, i.e. disable ASPI",DIAG_ASPI_DISABLE},
{"Dump first 64 bytes of read or write buffers",DIAG_BUF_DUMP},
{"Verbose",DIAG_VERBOSE},
{"Measure MBytes/sec",DIAG_MBYTE_PER_SEC},
{"Diaplay ASPI SRB",DIAG_DISP_SRB},
{"Log random requests to file, AE.LOG",DIAG_LOG_FILE},
{"Perform heap check",DIAG_HEAP_CHECK},
{"Check write buf after ASPI complete",DIAG_CHK_WR_BUF},
{"No Inquery",DIAG_NO_INQ},
{NULL,NULL}
};
static void diag_options(void);
/***************************************************************************
*
* diag_here(...)
*
***************************************************************************/
FLAG diag_here(code)
int code;
{
//
// Since returning FLAG and result of "&" is int, must convert to
// FLAG.
//
return ((diag_code & code) != 0);
}
/***************************************************************************
*
* diag_set(...)
*
***************************************************************************/
FLAG diag_set(code_str)
char *code_str;
{
if (code_str[0] == '?')
{
diag_options();
return (FALSE);
}
sscanf(code_str,"%x",&diag_code);
printf("Using 0x%.4X as diagnostics code.\n",diag_code);
return (TRUE);
}
/***************************************************************************
*
* diag_msg(...)
*
***************************************************************************/
void diag_msg(str)
char *str;
{
time_t t;
t = time(NULL);
printf("%s%s",ctime(&t),str);
}
/***************************************************************************
*
* diag_options(...)
*
***************************************************************************/
static void diag_options(void)
{
int i;
printf("Diagnostic Options:\n");
for (i = 0; diags[i].str; i++)
printf( " Option #%.2d, bit value=%.4X, %s\n",
i+1,
diags[i].bit_val,
diags[i].str);
}
/***************************************************************************
*
*
*
***************************************************************************/
U16 seg(void far *ptr_in)
{
static union PTR_OBJ ptr;
ptr.ptr = ptr_in;
return (ptr.seg_off.segment);
}
/***************************************************************************
*
*
*
***************************************************************************/
U16 off(void far *ptr_in)
{
static union PTR_OBJ ptr;
ptr.ptr = ptr_in;
return (ptr.seg_off.offset);
}