gyield.s
3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**************************************************************************
* *
* 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 */