File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / d / fpevent / ldf_r.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:30:17 2019 UTC (6 years, 11 months ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21


#include "stdio.h"
#include "../fpp_defs.h"


/***************************************************************************
*
*	LDF  -FLOATING POINT SINGLE PRECISION LOAD RESERVED OPERAND TEST
*
***************************************************************************/

func_ptr_array ldf_r_tests; 		/* table of pointers to subtests  */
int max_ldf_r_sbtst_no;			/* # reserved operand tests */


/*
 * SUBTEST MESSAGE TABLE: messages describing the subtests
*/
char *ldf_r_sbtst_msg1[] =
{
     "  LDF -test 1 -Resop, Register data ",		/* subtest # 1 */
     "  LDF -test 2 -Resop, Cache data "		/* subtest # 2 */
};


/*
 * ERROR MESSAGE TABLE
*/
char *ldf_r_err_msg[] =
{
     "-expected fault didn't occur\n"			/* error code = 1 */
};


/***************************************************************************
*
*		LOAD SINGLE PRECISION RESERVED OPERAND MONITOR
*
***************************************************************************/
ldf_event()
{
	asm(".globl _ldf_e");
	asm("_ldf_e:");				/* entry address */
	if( (cycle == 1) && (prt_hdrs) )	/* print header on 1st cycle */
	{
	   writes(" LDF");
	}
	stuff_ldf_r_array();			/* fill in subtest ptr array */
	ldf_r_sched();				/* load reserved operands    */
	asm("jmp *return");;			/* return to test monitor    */
} 






/*****************************************************************************
*
*		LDF - RESERVED OPERAND TEST SEQUENCER
*
* This function will select the subtest and call the subtest schedualer
*
*****************************************************************************/
ldf_r_sched()
{
int sbtst_index;
	for( subtest = 1; subtest < max_ldf_r_sbtst_no; subtest++ )
	{
	     sbtst_index = subtest - 1;
	     subtest_message = ldf_r_sbtst_msg1[ sbtst_index ];
	     test_ldf_r( ldf_r_tests[ sbtst_index ] );	/* execute the test */
	}
}







/*****************************************************************************
*
*		LDF RESERVED OPERAND TEST 
*
*  This function will call the specific subtest sequences. The subtest will
*  load a Reserved Operand. A Reserved Operand Fault ( code 2d ) should 
*  occur. The fault handler will return control to this function.
*
*****************************************************************************/
test_ldf_r( current_subtest ) 
int (*current_subtest)();			/* pointer to test sequence */
{
	asm("moval (r14),_pre_event_sp");	/* save the stack pointer   */
	asm("moval (r13),_pre_event_fp");	/* save the frame pointer   */
	asm("moval _ldf_r_ret,_event_return");  /* set event return address */
/*
 *  test all of the data pattenrs
*/
	for( index = 0; index < max_ldf_resop_index; index++ );
	{
	    sgl_ld_acc = ldf_resop_data[index];	/* get Reserved Op data    */
	    asm("_ldf_r_loop:");
	    exp_event = RESOP_CODE;		/* RESOP fault expected    */
	    (*current_subtest)();		/* run the test            */
/* 
 *       We shouldn't get to this point - if we do then there was no trap.
*/
	    err_code = 1;			/* error type 1 (no event) */
	    exp_event = FALSE;			/* no events are expected  */
	    asm("movl _pre_event_sp,r14");	/* restore stack pointer   */
	    asm("movl _pre_event_fp,r13");	/* restore frame pointer   */
	    if( force_loop )
	    {
	         loop_val_1b = sgl_ld_acc;	/* save last OP_1 pattern  */
	         sgl_ld_acc = loop_val_1a;	/* get next OP_1 pattern   */
	         loop_val_1a = loop_val_1b;	/* get ready for next loop */
	         asm("jmp _ldf_r_loop");	/* loop forever            */
	    };
	    errcnt++;				/* bump the error count    */
	    if( prt_error ) {
		 error_message = ldf_r_err_msg[ err_code -1 ];
		 ldf_r_print_error( error_message );
	    };
	    if ( halt_flg ) 			/* halt on error           */
		 ldf_err_hlt();
	    if ( loop_on_err ) 
	    {
		 get_ldf_r_loop_data();		/* set up the loop data    */
		 force_loop = 1;		/* set the force loop flag */
		 asm("jmp _ldf_r_loop");	/* and loop                */
	    };
/*
 *  Reserved Operand events will return here:
*/
	    asm(".globl _ldf_r_ret"); 
	    asm("_ldf_r_ret:"); 
	    if( force_loop )
	    {
		 get_ldf_r_loop_data();		/* set up the loop data    */
		 asm("jmp _ldf_r_loop");	/* loop on previous error  */
	    };
      };
      asm("movl _pre_event_sp,r14");		/* restore stack pointer   */
      asm("movl _pre_event_fp,r13");		/* restore frame pointer   */
}  /* end of subtest schedualer */





/***************************************************************************
*
*		SUBTEST 1 - Register data
*
***************************************************************************/
ldf_r_reg()
{
	   asm("movl _sgl_ld_acc,r4");		/* move the data to a reg */
	   asm("ldf r4");			/* trigger the fault      */
	   asm("nop");				/* waste a little time    */
	   asm("nop");				/* waste a little time    */
	   sgl_dummy1 = 0;			/* dummy instr for "C"    */
}





/***************************************************************************
*
*		SUBTEST 2 - Cache data
*
***************************************************************************/
ldf_r_cache()
{
	   asm("ldf _sgl_ld_acc");		/* trigger the fault      */
	   asm("nop");				/* waste a little time    */
	   asm("nop");				/* waste a little time    */
	   sgl_dummy1 = 0;			/* dummy instr for "C"    */
}




/******************************************************************************
*
*	FILL IN THE SUBTEST POINTER ARRAY WITH THE SUBTEST ADDRESSES
*
******************************************************************************/
stuff_ldf_r_array()
{
	ldf_r_tests[0] = ldf_r_reg;    		/* subtest 1 (register data) */
	ldf_r_tests[1] = ldf_r_cache;		/* subtest 2 (cache data)    */
	max_ldf_r_sbtst_no = 2;			/* set # of reserved op tsts */
}




/******************************************************************************
*
*		HALT ON ERROR
*
******************************************************************************/
ldf_err_hlt()
{
	asm("movl _test_no,r0");	/* r0  = test number          */
	asm("movl _subtest,r1");	/* r1  = subtest number       */
	asm("movl _err_code,r2");	/* r2  = error code           */
	asm("movl _cycle,r3");		/* r3  = cycle count          */
	asm("movl _sgl_ld_acc,r4");	/* r4  = operand              */
	asm(".globl _ldf_resop_hlt");
	asm("_ldf_resop_hlt:");		/* PC after the halt          */
	asm("halt");			/* HALT ...                   */
	sgl_dummy1 = 0;			/* dummy statement for 'C'    */
}





/******************************************************************************
*
*		PRINT AN ERROR MESSAGE
*
******************************************************************************/
ldf_r_print_error()
{
	writes("\ncycle: ");
	writed( cycle );
	writes( subtest_message );
	writes( error_message );
	writes("operand = ");
	write32h( sgl_ld_acc );
	writes(" \n");
}





/******************************************************************************
*
*		GET DATA PATTERNS FOR LOOPING ON THE ERROR
*
******************************************************************************/
get_ldf_r_loop_data()
{
     if( (index > 0) && (!no_data_swap_on_lp) )
     {
	  old_indx = index -1;			/* get the last data pattern */
          loop_val_1a  = ldf_resop_data[old_indx]; 
     }
     else
          loop_val_1a = sgl_ld_acc;		/* use the same data pattern */
}





unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.