Line 113... |
Line 113... |
la $a0,msg1 # Print ramtop message...
|
la $a0,msg1 # Print ramtop message...
|
jal puts
|
jal puts
|
nop
|
nop
|
addi $a0,$t0,-4 # substract the +4 offset we added before
|
addi $a0,$t0,-4 # substract the +4 offset we added before
|
move $sp,$t0 # init SP at the top of RAM space
|
move $sp,$t0 # init SP at the top of RAM space
|
addi $sp,$sp,-4
|
addi $sp,$sp,-16
|
li $a1,8
|
li $a1,8
|
jal put_hex
|
jal put_hex
|
nop
|
nop
|
la $a0,crlf
|
la $a0,crlf
|
jal puts
|
jal puts
|
nop
|
nop
|
|
|
# FIXME now we should so some strong test on the RAM to see if it's wired
|
# Test code execution from SRAM. We copy the test_exec_sram routine to
|
# correctly, using the right timing, etc.
|
# the base of the SRAM and then jal to it
|
|
li $a1,64
|
|
li $a0,XRAM_BASE
|
|
la $a3,test_exec_sram
|
|
copy_to_sram:
|
|
lw $a2,0($a3)
|
|
nop
|
|
sw $a2,0($a0)
|
|
addi $a1,$a1,-4
|
|
addi $a3,$a3,4
|
|
bnez $a1,copy_to_sram
|
|
addi $a0,$a0,4
|
|
|
|
.ifgt 0
|
|
li $a0,0
|
|
jal dump_hex
|
|
ori $a1,$zero,16
|
|
.endif
|
|
|
|
li $a0,XRAM_BASE
|
|
jalr $a0
|
|
nop
|
|
|
|
.ifgt 0
|
|
# If all went well in the SRAM we'll have returned here
|
|
|
|
|
|
# FIXME now we should so some strong test on the RAM to see if it's wired
|
|
# correctly, using the right timing, etc.
|
|
|
# Ok, now we know we have some RAM and stack space we can do some further
|
# Ok, now we know we have some RAM and stack space we can do some further
|
# testing.
|
# testing.
|
# dump the first few words of FLASH
|
# dump the first few words of FLASH
|
|
|
la $a0,msg2
|
la $a0,msg2
|
jal puts
|
jal puts
|
nop
|
nop
|
|
|
# FIXME flash base address is hardcoded
|
# FIXME flash base address is hardcoded
|
li $a0,0xb0000000
|
li $a0,0xb0000000
|
jal put_hex
|
jal put_hex
|
ori $a1,$zero,8
|
ori $a1,$zero,8
|
|
|
la $a0,crlf
|
la $a0,crlf
|
jal puts
|
jal puts
|
nop
|
nop
|
|
|
la $a0,crlf
|
la $a0,crlf
|
jal puts
|
jal puts
|
nop
|
nop
|
|
|
li $a0,0xb0000000
|
li $a0,0xb0000000
|
jal dump_hex
|
jal dump_hex
|
ori $a1,$zero,24
|
ori $a1,$zero,24
|
|
.endif
|
|
|
|
$DONE:
|
|
j $DONE # ...and freeze here
|
|
nop
|
|
|
|
|
$DONE:
|
test_exec_sram:
|
j $DONE # ...and freeze here
|
#jr $ra
|
nop
|
#nop
|
|
sw $ra,0($sp)
|
|
addi $sp,$sp,-4
|
|
la $a0,msg3
|
|
la $a1,puts
|
|
jalr $a1
|
|
nop
|
|
lw $ra,4($sp)
|
|
jr $ra
|
|
addi $sp,$sp,4
|
|
test_exec_sram_end:
|
|
|
|
|
#---- Functions ----------------------------------------------------------------
|
|
|
|
# void dump_hex(int *address, int len)
|
#---- Functions ----------------------------------------------------------------
|
dump_hex:
|
|
move $t7,$a0
|
# void dump_hex(int *address, int len)
|
move $t8,$a1
|
dump_hex:
|
sw $ra,0($sp)
|
move $t7,$a0
|
addi $sp,$sp,-4
|
move $t8,$a1
|
|
sw $ra,0($sp)
|
|
addi $sp,$sp,-4
|
|
|
dump_hex_loop:
|
dump_hex_loop:
|
lw $a0,0($t7)
|
lw $a0,0($t7)
|
jal put_hex
|
jal put_hex
|
li $a1,8
|
li $a1,8
|
|
|
la $a0,space
|
la $a0,space
|
jal puts
|
jal puts
|
addi $t7,4
|
addi $t7,4
|
|
|
addi $t8,$t8,-1
|
addi $t8,$t8,-1
|
bnez $t8,dump_hex_loop
|
bnez $t8,dump_hex_loop
|
nop
|
nop
|
|
|
lw $ra,4($sp)
|
lw $ra,4($sp)
|
jr $ra
|
jr $ra
|
addi $sp,$sp,4
|
addi $sp,$sp,4
|
|
|
|
|
#--- Special functions that do not use any RAM ---------------------------------
|
#--- Special functions that do not use any RAM ---------------------------------
|
# WARNING: Not for general use!
|
# WARNING: Not for general use!
|
# All parameters in $a0..$a4, stack unused. No attempt to comply with any ABI
|
# All parameters in $a0..$a4, stack unused. No attempt to comply with any ABI
|
# has been made.
|
# has been made.
|
# Since we can't use any RAM, register have been used liberally with no regard
|
# Since we can't use any RAM, register have been used liberally with no regard
|
# for intended usage -- have to share reg bank with calling function.
|
# for intended usage -- have to share reg bank with calling function.
|
|
|
# void puts(char *s) -- print zero-terminated string
|
# void puts(char *s) -- print zero-terminated string
|
puts:
|
puts:
|
la $a2,UART_BASE # UART base address
|
la $a2,UART_BASE # UART base address
|
puts_loop:
|
puts_loop:
|
lb $v0,0($a0)
|
lb $v0,0($a0)
|
beqz $v0,puts_end
|
beqz $v0,puts_end
|
addiu $a0,1
|
addiu $a0,1
|
puts_wait_tx_rdy:
|
puts_wait_tx_rdy:
|
lw $v1,UART_STATUS($a2)
|
lw $v1,UART_STATUS($a2)
|
andi $v1,$v1,0x02
|
andi $v1,$v1,0x02
|
beqz $v1,puts_wait_tx_rdy
|
beqz $v1,puts_wait_tx_rdy
|
nop
|
nop
|
sw $v0,UART_TX($a2)
|
sw $v0,UART_TX($a2)
|
b puts_loop
|
b puts_loop
|
nop
|
nop
|
|
|
puts_end:
|
puts_end:
|
jr $ra
|
jr $ra
|
nop
|
nop
|
|
|
# void put_hex(int n, int d) -- print integer as d-digit hex
|
# void put_hex(int n, int d) -- print integer as d-digit hex
|
put_hex:
|
put_hex:
|
la $a2,UART_BASE
|
la $a2,UART_BASE
|
la $a3,put_hex_table
|
la $a3,put_hex_table
|
addi $a1,-1
|
addi $a1,-1
|
add $a1,$a1,$a1
|
add $a1,$a1,$a1
|
add $a1,$a1,$a1
|
add $a1,$a1,$a1
|
|
|
put_hex_loop:
|
put_hex_loop:
|
srlv $v0,$a0,$a1
|
srlv $v0,$a0,$a1
|
andi $v0,$v0,0x0f
|
andi $v0,$v0,0x0f
|
addu $s2,$a3,$v0
|
addu $s2,$a3,$v0
|
lb $v0,0($s2)
|
lb $v0,0($s2)
|
put_hex_wait_tx_rdy:
|
put_hex_wait_tx_rdy:
|
lw $v1,UART_STATUS($a2)
|
lw $v1,UART_STATUS($a2)
|
andi $v1,$v1,0x02
|
andi $v1,$v1,0x02
|
beqz $v1,put_hex_wait_tx_rdy
|
beqz $v1,put_hex_wait_tx_rdy
|
nop
|
nop
|
sw $v0,UART_TX($a2)
|
sw $v0,UART_TX($a2)
|
|
|
bnez $a1,put_hex_loop
|
bnez $a1,put_hex_loop
|
addi $a1,-4
|
addi $a1,-4
|
|
|
jr $ra
|
jr $ra
|
nop
|
nop
|
|
|
|
|
#---- Constant data (note we keep it in the text section) ----------------------
|
|
|
|
put_hex_table:
|
#---- Constant data (note we keep it in the text section) ----------------------
|
.ascii "0123456789abcdef"
|
|
|
|
msg0:
|
put_hex_table:
|
.ascii "\n\r"
|
.ascii "0123456789abcdef"
|
.asciz "Scanning external memory at 0x"
|
|
msg1:
|
|
.asciz "Found XRAM top at 0x"
|
|
crlf:
|
|
.asciz "\n\r"
|
|
space:
|
|
.asciz " "
|
|
msg_mirror:
|
|
.asciz "hit mirror!\n\r"
|
|
msg_bad:
|
|
.asciz "bad readback!\n\r"
|
|
msg2:
|
|
.asciz "\n\rDumping the first few words of FLASH at address 0x"
|
|
|
|
.set reorder
|
msg0:
|
.end entry
|
.ascii "\n\r"
|
|
.asciz "Scanning external memory at 0x"
|
|
msg1:
|
|
.asciz "Found XRAM top at 0x"
|
|
crlf:
|
|
.asciz "\n\r"
|
|
space:
|
|
.asciz " "
|
|
msg_mirror:
|
|
.asciz "hit mirror!\n\r"
|
|
msg_bad:
|
|
.asciz "bad readback!\n\r"
|
|
msg2:
|
|
.asciz "\n\rDumping the first few words of FLASH at address 0x"
|
|
msg3:
|
|
.ascii "\n\rTesting code execution from SRAM... "
|
|
.asciz "if you see this, it worked\n\r"
|
|
|
|
.set reorder
|
|
.end entry
|
|
|
No newline at end of file
|
No newline at end of file
|
|
|
No newline at end of file
|
No newline at end of file
|