ayield.s 1.32 KB
/*
 * ayield.s
 *
 * save graphics output buffer in the case of yield, and restore it 
 * when done.
 */

 #############################################################
 ### SAVE XBUS BUFFER IF NOT EMPTY ###########################
 #############################################################

#ifdef STARTUP_YIELD
.name	tmp,	$4
.name	stat,	$5

	.ent	yieldSave
yieldSave:
	mfc0	stat, CMD_STATUS		    # Get DP buffer status
	andi	tmp, stat, DPC_STATUS_XBUS_DMEM_DMA # Is buffer in DMEM?
	beq	tmp, zero, noYield		    # If not, no yield
	andi	tmp, stat, DPC_STATUS_DMA_BUSY      # Is buffer still in use?
 ### BRANCH OCCURS TO noYield: if DP buffer is in DRAM
	beq	tmp, zero, noYield		    # If not, no yield
	nop					    #

	#
	# instead of yield, wait for DP to finish
	#
yieldwaitloop:
	mfc0    tmp, CMD_STATUS
	andi    tmp, tmp, 0x100       	    	    # dma busy ?
	bgtz    tmp, yieldwaitloop     	    	    # wait until not busy
noYield:					    #
	nop

	.end	yieldSave

						    #
.unname	tmp					    #
.unname	stat					    #
						    #

#endif /* STARTUP_YIELD */

 #############################################################
 ### RESTORE XBUS BUFFER IF NOT EMPTY ########################
 #############################################################

#ifdef DONE_UNYIELD
	#
	# don't need to do anything anymore
	#
#endif /* DONE_UNYIELD */