gyield.s
4.97 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/**************************************************************************
* *
* 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 */
#ifdef YIELD_SUSPENDING
# ifdef OUTPUT_DUMP
lbu $3, -8(outp)
# else
lbu $3, 0(outp)
# endif
addi $2, zero, G_RDPFULLSYNC # Full Sync Command
# if (defined(DMA2BUF)||defined(DMANOWAIT))
jal DMAwait
lw $21, RSP_STATE_FIFO_OUTP(rsp_state)
mtc0 $21, CMD_END
# endif
# ifdef OUTPUT_DUMP
jal OutputOpen
addi $18, zero, 8
# endif
beq $2, $3, TaskDone # return if already sent
sb $2, 0(outp)
# ifndef OUTPUT_DUMP
jal OutputClose
addi outp, outp, 8
# endif
# if (defined(DMA2BUF)||defined(DMANOWAIT))
jal DMAwait
lw $21, RSP_STATE_FIFO_OUTP(rsp_state)
j TaskDone
mtc0 $21, CMD_END
# else
j TaskDone
# ifdef OUTPUT_DUMP
addi outp, outp, 8
# else
nop
# endif
# endif
#else
# save important registers to DMEM
# only the "constant" registers are important.
ori yield, zero, SP_SET_YIELDED # indicate yield
#ifdef SWITCH_UCODE
lw $6, (RSP_TASK_OFFSET+OS_TASK_OFF_UCODE)(zero)
#endif
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)
#ifdef SWITCH_UCODE
sw $6, (RSP_YIELD_SAVE_LEN - 4)(zero)
#endif
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:
#endif
.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
#
# rspboot0 で BOOT されたときは $v16 は All 0 なので
# これを認証に使用する. for Zelda64
#
#ifdef RSPBOOT0
vxor vconst, vconst, $v16
#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 */