gtinit.s 3.83 KB
	
/*
 * Copyright 1995, Silicon Graphics, Inc.
 * ALL RIGHTS RESERVED
 *
 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
 * States.   Use of a copyright notice is precautionary only and does not
 * imply publication or disclosure.
 *
 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
 * Use, duplication or disclosure by the Government is subject to restrictions
 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
 * Supplement.  Contractor/manufacturer is Silicon Graphics, Inc.,
 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
 *
 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
 * GRAPHICS, INC.
 *
 */

/*
 * File:		gtinit.s
 * Creator:		hsa@sgi.com
 * Create Date:		Wed Oct 11 14:31:21 PDT 1995
 *
 * This in the init code for the 'turbo graphics task'
 *
 */


 ############################################################################
 #
 #  Begin task initialization
 #
 #  Register $1 holds the task header address
 # format for the task header:
 #	(see sptask.h)
 #
 #
		.ent	doInit
doInit:
	# set RSP yield flags to FALSE (IMPORTANT: don't clear yield flag)
		ori    $2,zero, (SP_CLR_YIELDED|SP_CLR_TASKDONE)
		mtc0   $2, SP_STATUS
	
	# reset output pointers
		lw	$2, OS_TASK_OFF_OUTBUFF($1)
		lw	$3, OS_TASK_OFF_OUTBUFF_SZ($1)
#ifdef OUTPUT_DRAM
		sw	$2, RSP_STATE_DRAM_OUTP(rsp_state)
#else
		sw	$0, RSP_STATE_DRAM_OUTP(rsp_state)
#endif
		sw	$3, RSP_STATE_DRAM_OUT_LENP(rsp_state)
	
	#
	# important constants:
	#
		lqv	vconst[0], VCONST_OFFSET(zero)
		lqv	vconst1[0], VCONST1_OFFSET(zero)
	
#if 0
	#
	# The task header should tell us if this is a restart
	# of a previously checkpointed run. If so, do some special
	# init sequence.
	#
.name	yield, $2
		lw	yield, (RSP_TASK_OFFSET+OS_TASK_OFF_FLAGS)(zero)
		andi	yield, yield, OS_TASK_YIELDED
		bne	yield, zero, RSPYieldRestart
		nop
.unname yield
#endif
		
	# OUTPUT:  initialize CP0 registers
	# This assumes the DP is idle. We expect the
	# host (or boot code) to enforce this.
#ifdef OUTPUT_DRAM
		addi	$4, zero, DPC_CLR_XBUS_DMEM_DMA
		mtc0	$4, CMD_STATUS
 		addi	outp, zero, RSP_OUTPUT_OFFSET
#else
#ifdef OUTPUT_FIFO
.name	bufend, $3
	# reset output pointers
		lw	outp, OS_TASK_OFF_OUTBUFF($1)
		lw	bufend, OS_TASK_OFF_OUTBUFF_SZ($1)
		sw	outp, RSP_STATE_FIFO_BUF_TOP(rsp_state)
		sw	bufend, RSP_STATE_FIFO_BUF_END(rsp_state)

		mfc0	$4, CMD_STATUS
		andi	$4, $4, DPC_STATUS_XBUS_DMEM_DMA
		bne	$4, zero, restart_fifo
		mfc0	$4, CMD_END
		sub	outp, outp, $4
		bgtz	outp, restart_fifo

	mfc0	$5, CMD_CURRENT
	beq	$5, zero, restart_fifo
	nop
	beq	$5, $4, restart_fifo
	

		nop
		j	set_fifo
		ori	bufend, $4, 0

restart_fifo:
		mfc0	$4, CMD_STATUS
		andi	$4, $4, DPC_STATUS_START_VALID
		bne	$4, zero, restart_fifo
		addi	$4, zero, DPC_CLR_XBUS_DMEM_DMA
 ### LOOP TO restart_fifo: UNTIL START_VALID=0
		mtc0	$4, CMD_STATUS
		mtc0	bufend, CMD_START
		mtc0	bufend, CMD_END
set_fifo:
		sw	bufend, RSP_STATE_FIFO_OUTP(rsp_state)
 		addi	outp, zero, RSP_OUTPUT_OFFSET
.unname	bufend
#else	/* XBUS */
		addi	$4, zero, DPC_SET_XBUS_DMEM_DMA
 		addi	outp, zero, 0x1000	# DP initial conditions
		mtc0	$4, CMD_STATUS
		mtc0	outp, CMD_START
		mtc0	outp, CMD_END
#endif
#endif
	
	#
	# get the first display list out of the header and
	# start the DMA of the display list into DMEM.
		jal	LoadDL
		lw	inp, OS_TASK_OFF_DATA($1)
	
	#
	# while DMA is going on, do some initializations:
	#
 #
 #
 #
 # end of initialization section
 #
 ############################################################################
		.end	doInit