Search
lxdream.org :: lxdream/src/sh4/ia64asm.s :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/ia64asm.s
changeset 571:9bc09948d0f2
author nkeynes
date Tue Jan 15 11:07:32 2008 +0000 (16 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change Handle sh4 aborts/reset within the translator
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/sh4/ia64asm.s Tue Jan 15 11:07:32 2008 +0000
1.3 @@ -0,0 +1,34 @@
1.4 +#
1.5 +# Scan back through the stack until we hit the currently executing
1.6 +# translation block, and find the call return address to that block.
1.7 +#
1.8 +# Implementation: iterate back through each stack frame until we find
1.9 +# a frame that has a saved %ebp == sh4r (setup by the xlat blocks).
1.10 +# The return address is then the stack value immediately before the
1.11 +# saved %ebp.
1.12 +#
1.13 +# At most 8 stack frames are checked, to prevent infinite looping on a
1.14 +# corrupt stack.
1.15 +
1.16 +.global xlat_get_native_pc
1.17 +xlat_get_native_pc:
1.18 + mov %rbp, %rax
1.19 + mov $0x8, %ecx
1.20 + mov $sh4r, %rdx
1.21 +
1.22 +frame_loop:
1.23 + test %rax, %rax
1.24 + je frame_not_found
1.25 + cmpq (%rax), %rdx
1.26 + je frame_found
1.27 + sub $0x1, %ecx
1.28 + je frame_not_found
1.29 + movq (%rax), %rax
1.30 + jmp frame_loop
1.31 +
1.32 +frame_found:
1.33 + movl 0x4(%rax), %rax
1.34 + ret
1.35 +frame_not_found:
1.36 + xor %rax, %rax
1.37 + ret
.