OpenCores
URL https://opencores.org/ocsvn/ion/ion/trunk

Subversion Repositories ion

[/] [ion/] [trunk/] [src/] [memtest/] [memtest.s] - Diff between revs 66 and 78

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 66 Rev 78
Line 105... Line 105...
    nop
    nop
    .endif
    .endif
    b       end_test
    b       end_test
    nop
    nop
 
 
end_test:                       # test done, ramtop+1 in $t0, #KB in $t4
end_test:                       # test done, ramtop+4 in $t0, #KB in $t4
 
 
 
 
    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
 
    addi    $sp,$sp,-4
    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
 
 
$DONE:
    # FIXME now we should so some strong test on the RAM to see if it's wired
    j       $DONE               # ...and freeze here
    # correctly, using the right timing, etc.
    nop
 
 
 
 
    # Ok, now we know we have some RAM and stack space we can do some further
 
    # testing.
 
    # dump the first few words of FLASH
 
 
#---- Functions ----------------------------------------------------------------
    la      $a0,msg2
# WARNING: Not for general use!
    jal     puts
# All parameters in $a0..$a4, stack unused. No attempt to comply with any ABI
 
# has been made.
 
# 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.
 
 
 
# void puts(char *s) -- print zero-terminated string
 
puts:
 
    la      $s0,UART_BASE       # UART base address
 
puts_loop:
 
    lb      $v0,0($a0)
 
    beqz    $v0,puts_end
 
    addiu   $a0,1
 
puts_wait_tx_rdy:
 
    lw      $v1,UART_STATUS($s0)
 
    andi    $v1,$v1,0x02
 
    beqz    $v1,puts_wait_tx_rdy
 
    nop
    nop
    sw      $v0,UART_TX($s0)
 
    b       puts_loop
    # FIXME flash base address is hardcoded
 
    li      $a0,0xb0000000
 
    jal     put_hex
 
    ori     $a1,$zero,8
 
 
 
    la      $a0,crlf
 
    jal     puts
    nop
    nop
 
 
puts_end:
    la      $a0,crlf
    jr      $ra
    jal     puts
    nop
    nop
 
 
# void put_hex(int n, int d) -- print integer as d-digit hex
    li      $a0,0xb0000000
put_hex:
    jal     dump_hex
    la      $s0,UART_BASE
    ori     $a1,$zero,24
    la      $s1,put_hex_table
 
    addi    $a1,-1
 
    add     $a1,$a1,$a1
$DONE:
    add     $a1,$a1,$a1
    j       $DONE               # ...and freeze here
 
 
put_hex_loop:
 
    srlv    $v0,$a0,$a1
 
    andi    $v0,$v0,0x0f
 
    addu    $s2,$s1,$v0
 
    lb      $v0,0($s2)
 
put_hex_wait_tx_rdy:
 
    lw      $v1,UART_STATUS($s0)
 
    andi    $v1,$v1,0x02
 
    beqz    $v1,put_hex_wait_tx_rdy
 
    nop
    nop
    sw      $v0,UART_TX($s0)
 
 
 
    bnez    $a1,put_hex_loop
 
    addi    $a1,-4
 
 
 
    jr      $ra
#---- Functions ----------------------------------------------------------------
 
 
 
# void dump_hex(int *address, int len)
 
dump_hex:
 
    move    $t7,$a0
 
    move    $t8,$a1
 
    sw      $ra,0($sp)
 
    addi    $sp,$sp,-4
 
 
 
dump_hex_loop:
 
    lw      $a0,0($t7)
 
    jal     put_hex
 
    li      $a1,8
 
 
 
    la      $a0,space
 
    jal     puts
 
    addi    $t7,4
 
 
 
    addi    $t8,$t8,-1
 
    bnez    $t8,dump_hex_loop
    nop
    nop
 
 
 
    lw      $ra,4($sp)
 
    jr      $ra
 
    addi    $sp,$sp,4
 
 
 
 
 
#--- Special functions that do not use any RAM ---------------------------------
 
# WARNING: Not for general use!
 
# All parameters in $a0..$a4, stack unused. No attempt to comply with any ABI
 
# has been made.
 
# 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.
 
 
 
# void puts(char *s) -- print zero-terminated string
 
puts:
 
    la      $a2,UART_BASE       # UART base address
 
puts_loop:
 
    lb      $v0,0($a0)
 
    beqz    $v0,puts_end
 
    addiu   $a0,1
 
puts_wait_tx_rdy:
 
    lw      $v1,UART_STATUS($a2)
 
    andi    $v1,$v1,0x02
 
    beqz    $v1,puts_wait_tx_rdy
 
    nop
 
    sw      $v0,UART_TX($a2)
 
    b       puts_loop
 
    nop
 
 
 
puts_end:
 
    jr      $ra
 
    nop
 
 
 
# void put_hex(int n, int d) -- print integer as d-digit hex
 
put_hex:
 
    la      $a2,UART_BASE
 
    la      $a3,put_hex_table
 
    addi    $a1,-1
 
    add     $a1,$a1,$a1
 
    add     $a1,$a1,$a1
 
 
 
put_hex_loop:
 
    srlv    $v0,$a0,$a1
 
    andi    $v0,$v0,0x0f
 
    addu    $s2,$a3,$v0
 
    lb      $v0,0($s2)
 
put_hex_wait_tx_rdy:
 
    lw      $v1,UART_STATUS($a2)
 
    andi    $v1,$v1,0x02
 
    beqz    $v1,put_hex_wait_tx_rdy
 
    nop
 
    sw      $v0,UART_TX($a2)
 
 
 
    bnez    $a1,put_hex_loop
 
    addi    $a1,-4
 
 
 
    jr      $ra
 
    nop
 
 
 
 
 
#---- Constant data (note we keep it in the text section) ----------------------
 
 
#---- Constant data (note we keep it in the text section) ----------------------
put_hex_table:
 
    .ascii  "0123456789abcdef"
 
 
put_hex_table:
msg0:
    .ascii  "0123456789abcdef"
    .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"
 
 
msg0:
    .set    reorder
    .ascii  "\n\r"
    .end    entry
    .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"
 
 
 
    .set    reorder
 
    .end    entry
 
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.