Search
lxdream.org :: lxdream/src/sh4/ia64asm.s
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/ia64asm.s
changeset 571:9bc09948d0f2
author nkeynes
date Thu Jan 10 08:28:37 2008 +0000 (16 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change More MMU work in progess. Much better now...
file annotate diff log raw
nkeynes@571
     1
# 
nkeynes@571
     2
# Scan back through the stack until we hit the currently executing
nkeynes@571
     3
# translation block, and find the call return address to that block.
nkeynes@571
     4
# 
nkeynes@571
     5
# Implementation: iterate back through each stack frame until we find
nkeynes@571
     6
# a frame that has a saved %ebp == sh4r (setup by the xlat blocks).
nkeynes@571
     7
# The return address is then the stack value immediately before the
nkeynes@571
     8
# saved %ebp.
nkeynes@571
     9
#
nkeynes@571
    10
# At most 8 stack frames are checked, to prevent infinite looping on a
nkeynes@571
    11
# corrupt stack.
nkeynes@571
    12
nkeynes@571
    13
.global xlat_get_native_pc
nkeynes@571
    14
xlat_get_native_pc:
nkeynes@571
    15
	mov %rbp, %rax
nkeynes@571
    16
	mov $0x8, %ecx
nkeynes@571
    17
	mov $sh4r, %rdx
nkeynes@571
    18
nkeynes@571
    19
frame_loop:
nkeynes@571
    20
	test %rax, %rax
nkeynes@571
    21
	je frame_not_found
nkeynes@571
    22
	cmpq (%rax), %rdx
nkeynes@571
    23
	je frame_found
nkeynes@571
    24
	sub $0x1, %ecx
nkeynes@571
    25
	je frame_not_found
nkeynes@571
    26
	movq (%rax), %rax
nkeynes@571
    27
	jmp frame_loop
nkeynes@571
    28
nkeynes@571
    29
frame_found:
nkeynes@571
    30
	movl 0x4(%rax), %rax
nkeynes@571
    31
	ret
nkeynes@571
    32
frame_not_found:
nkeynes@571
    33
	xor %rax, %rax
nkeynes@571
    34
	ret
.