tm_imem_boot.s
1.63 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
/*
* tm_imem_boot.s: Bootstrap file which loads tm_imem into rsp imem memory
* from the standard gload point within ramrom. We always
* load 0x400 bytes for simplicity of implementation.
*/
#include "regdef.h"
#include "asm.h"
#include <R4300.h>
#include <rcp.h>
#include "tinymon.h"
#define IMEM_LOAD_ADDRESS 0x04001000
#define RAMROM_SRC_ADDRESS 0x10002000
#define TINYMON_IMEM_SIZE 0x00000400
LEAF (tm_imem_boot) # Address = 0xB0000400.
.set noreorder
li t1, SR_BEV|SR_CU0 # Initialize SR
mtc0 t1, C0_SR # Clear Status Register.
.set reorder
# Load the tinymon program from 0x10002000 in ramrom to 0x04001000 in rsp dmem.
# (We use 0xB0002000 and 0xa4001000, since K1 seg guarantees uncached access).
la t0, PHYS_TO_K1(RAMROM_SRC_ADDRESS)
la t1, PHYS_TO_K1(IMEM_LOAD_ADDRESS)
la t2, PHYS_TO_K1(RAMROM_SRC_ADDRESS)
addiu t2, TINYMON_IMEM_SIZE
send:
lw t3, 0(t0) # load monitor from ramrom
sw t3, 0(t1) # store monitor to imem
/*
jal waitForIdle
*/
addiu t0, 4 # add monitor address
addiu t1, 4 # add imem adress
bne t0, t2, send
# Jump to the loaded program in imem.
la t4, PHYS_TO_K1(IMEM_LOAD_ADDRESS)
jr t4
/*
* General purpose subroutine which spins, waiting for the PI controller to
* become idle. Should be called after each RAMROM cartridge interface request
* (for either memory or registers).
*/
.set noreorder
waitForIdle:
lui t4, PI_BASE_REG_UPPER_K1
waitLoop:
lw t5, PI_STATUS_REG_OFFSET(t4)
nop
andi t6, t5, (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)
bne t6, zero, waitLoop
nop
jr ra
nop
.set reorder
END (tm_imem_boot)