gyield.s 3.96 KB

/**************************************************************************
 *								          *
 *               Copyright (C) 1994, Silicon Graphics, Inc.       	  *
 *								          *
 *  These coded instructions, statements, and computer programs  contain  *
 *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
 *  are protected by Federal copyright  law.  They  may not be disclosed  *
 *  to  third  parties  or copied or duplicated in any form, in whole or  *
 *  in part, without the prior written consent of Silicon Graphics, Inc.  *
 *								          *
 *************************************************************************/

/*
 * File:		gyield.s
 * Creator:		hsa@sgi.com
 * Create Date:		Fri Sep 30 10:59:23 PDT 1994
 *
 * This module implements some overhead routines for load balancing.
 * The strategy is very simple: Every so often, the graphics task
 * looks to see if it should stop (CPU will tell it). If so, we
 * save out our state and quit.
 *
 * Likewise, upon start-up, if this is a continuation of a stopped
 * task, we do a special initialization, then jump directly to
 * the processing.
 *
 */

 #######################################################################
 #  In FASTLIGHT3D this code is in overlays.  The RSPYieldRestart
 #  function is in the doInit code which is in the basic microcode,
 #  but gets overlayed by clip and lighting.  The RSPYieldOver function
 #  is in the Done overlay which is loaded over clip or lighting.
 #
 #  In cases other than FASTLIGHT3D this code is included in 2 different
 #  spots in the main code.  The RSPYield function is included by 
 #  defining YIELD_STOP and the RSPYieldRestart function is included by
 #  defining YIELD_RESTART.
 #

 #===========================================================================
 #===== This code (RSPYieldOver in FASTLIGHT3D, otherwise RSPYield) is ======
 #===== used to halt the microcode when a yield is requested and DMA   ======
 #===== the dmem (including saved registers) to dram                   ======
 #===========================================================================
#ifdef YIELD_STOP
.name	yield,	$2
.name   dmem_addr,      $20
.name   dram_addr,      $19
.name   dma_len,        $18
.name   iswrite,        $17


#ifndef FASTLIGHT3D
RSPYield:
#else /* FASTLIGHT3D */
RSPYieldOver:
#endif /* FASTLIGHT3D */
	# save important registers to DMEM
	# only the "constant" registers are important.
		ori	yield, zero, SP_SET_YIELDED	# indicate yield
		sw	dlcount,   (RSP_SETUP_TMP_OFFSET +  4)(zero)
		sw	dinp,      (RSP_SETUP_TMP_OFFSET +  8)(zero)
		sw	inp,       (RSP_SETUP_TMP_OFFSET + 12)(zero)
		sw	outp,      (RSP_SETUP_TMP_OFFSET + 16)(zero)

		lw	dram_addr, RSP_STATEP_YIELD_STORE(zero)
		ori	dmem_addr, zero,0
		ori	dma_len, zero, (RSP_YIELD_SAVE_LEN - 1)
		jal	DMAproc
		ori	iswrite, zero, 1
 ### CALL TO SUBROUTINE DMAproc:
		jal	DMAwait
		nop
 ### CALL TO SUBROUTINE DMAwait:
		j 	TaskDone
		mtc0	yield, SP_STATUS		# indicate yield
 ### JUMP OCCURS to TaskDone:

.unname dmem_addr
.unname dram_addr
.unname dma_len
.unname iswrite
.unname	yield

#endif /* YIELD_STOP */

 #===========================================================================
 #===== This code (RSPYieldRestart) is used to restart from a previous ======
 #===== yield.  At this point the dmem should have been restored from  ======
 #===== dram (this is done by the 4300 CPU).                           ======
 #===========================================================================
#ifdef YIELD_RESTART

	#
	# $1 holds the task header
	#		
RSPYieldRestart:
	# all 4K of DMEM is already initialized.

#ifndef TURBO3D
	# load Newton overlay
                jal     loadOverlaySR
                addi    $30, zero, OVERLAY_NEWTON
#endif

	# load some registers.
		lw	outp,      (RSP_SETUP_TMP_OFFSET + 16)(zero)
		lw	dlcount,   (RSP_SETUP_TMP_OFFSET +  4)(zero)
		lw	dinp,      (RSP_SETUP_TMP_OFFSET +  8)(zero)
		j	GfxDone
		lw	inp,       (RSP_SETUP_TMP_OFFSET + 12)(zero)

#endif /* YIELD_RESTART */