gloaduc.s
2.43 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
/*
* File: gloaduc.s
* Creator: yasu@rd3.nintendo.co.jp
*/
#ifdef SWITCH_UCODE
#------------------------------------------------------------------
# マイクロコードの SWITCH 処理 12 insts. 計 27insts.
# SMARTINP で +2 insts.
# DMA2BUF/DMANOWAIT で +3 insts.
# DMANOWAIT2 で +6 insts.
#
# +--------------+------------+------------+------------+
# |G_RDPHALF_1 | |
# +--------------+------------+------------+------------+
# | Pointer for ucode (Data section) |
# +--------------+------------+------------+------------+
# |G_SWITCH_UCODE| | (ucode_data size)-1 |
# +--------------+------------+------------+------------+
# | Pointer for ucode (Text section) |
# +--------------+------------+------------+------------+
#
case_G_SWITCH_UCODE:
#if (defined(DMANOWAIT2))
addi $6, outp, -(RSP_OUTPUT_OFFSET+1)
bgezal $6, OutputCloseFlush
nop
#endif
#if (defined(DMA2BUF)||defined(DMANOWAIT)||defined(DMANOWAIT2))
jal DMAwait
lw $6, RSP_STATEP_FIFO_OUTP(zero)
mtc0 $6, CMD_END
#endif
# これ以降共通のコードとなる
addi $19, gfx1, 0 # Text Section
sw gfx1, (RSP_TASK_OFFSET+OS_TASK_OFF_UCODE)(zero)
# Ucode の保存
#ifdef SMARTINP
add inp, inp, dinp
sub inp, inp, dlcount
#endif
sw inp, (RSP_TASK_OFFSET+OS_TASK_OFF_DATA)(zero)
addi $20, zero, TASKBASELO # Load into IMEM
jal DMAread
addi $18, zero, (0x1000-0x0080-26*4-1) # gloaduc
lw $19, RSP_STATEP_RDPHALF(zero) # Data Section
addi $20, zero, 0x0000 # Load into DMEM
jal DMAread
andi $18, gfx0, 0xffff # Get length
addi $1, zero, RSP_TASK_OFFSET # Set taskp
addi return, zero, TASKBASELO # Wiat DMA & Jump to ucode top
#endif
#--------------------------------
# DMA 待ち 4 insts.
#
.name tmp, $11
DMAwait:
mfc0 tmp, DMA_BUSY
bne tmp, zero, DMAwait
nop
jr return
.unname tmp
#--------------------------------
# DMA 処理 11 insts.
#
.name mem_addr, $20
.name dram_addr, $19
.name dma_len, $18
.name iswrite, $17
.name tmp, $11
DMAread: add iswrite, zero, zero
DMAproc: mfc0 tmp, DMA_FULL
bne tmp, zero, DMAproc
nop
# set DMA registers:
mtc0 mem_addr, DMA_CACHE
# handle writes:
bgtz iswrite, DMAWrite
mtc0 dram_addr, DMA_DRAM
jr return
mtc0 dma_len, DMA_READ_LENGTH
DMAWrite:
jr return
mtc0 dma_len, DMA_WRITE_LENGTH
.unname mem_addr
.unname dram_addr
.unname dma_len
.unname iswrite
.unname tmp