Search
lxdream.org :: lxdream :: r580:508dc852a8eb
lxdream 0.9.1
released Jun 29
Download Now
changeset580:508dc852a8eb lxdream-mmu
parent579:e76fa1a58d0a
child581:430515437e55
authornkeynes
dateTue Jan 15 02:20:30 2008 +0000 (16 years ago)
branchlxdream-mmu
Fix x86-64 support for mmu changes
src/sh4/ia64abi.h
src/sh4/xltcache.c
src/sh4/xltcache.h
1.1 --- a/src/sh4/ia64abi.h Mon Jan 14 10:37:02 2008 +0000
1.2 +++ b/src/sh4/ia64abi.h Tue Jan 15 02:20:30 2008 +0000
1.3 @@ -20,6 +20,7 @@
1.4 #ifndef __lxdream_x86_64abi_H
1.5 #define __lxdream_x86_64abi_H 1
1.6
1.7 +#include <unwind.h>
1.8
1.9 #define load_ptr( reg, ptr ) load_imm64( reg, (uint64_t)ptr );
1.10
1.11 @@ -159,7 +160,7 @@
1.12 ADD_sh4r_r32( R_PC, R_ECX );
1.13 store_spreg( R_ECX, REG_OFFSET(pc) ); // 3
1.14 if( IS_IN_ICACHE(pc) ) {
1.15 - MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5
1.16 + REXW(); MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5
1.17 } else if( sh4_x86.tlb_on ) {
1.18 call_func1(xlat_get_code_by_vma,R_ECX);
1.19 } else {
1.20 @@ -235,27 +236,24 @@
1.21 }
1.22 }
1.23
1.24 +_Unwind_Reason_Code xlat_check_frame( struct _Unwind_Context *context, void *arg )
1.25 +{
1.26 + void *rbp = (void *)_Unwind_GetGR(context, 6);
1.27 + if( rbp == (void *)&sh4r ) {
1.28 + void **result = (void **)arg;
1.29 + *result = (void *)_Unwind_GetIP(context);
1.30 + return _URC_NORMAL_STOP;
1.31 + }
1.32 +
1.33 + return _URC_NO_REASON;
1.34 +}
1.35
1.36 void *xlat_get_native_pc()
1.37 {
1.38 + struct _Unwind_Exception exc;
1.39 +
1.40 void *result = NULL;
1.41 - asm(
1.42 - "mov %%rbp, %%rax\n\t"
1.43 - "mov $0x8, %%ecx\n\t"
1.44 - "mov %1, %%rdx\n"
1.45 -"frame_loop: test %%rax, %%rax\n\t"
1.46 - "je frame_not_found\n\t"
1.47 - "cmpq (%%rax), %%rdx\n\t"
1.48 - "je frame_found\n\t"
1.49 - "sub $0x1, %%ecx\n\t"
1.50 - "je frame_not_found\n\t"
1.51 - "movq (%%rax), %%rax\n\t"
1.52 - "jmp frame_loop\n"
1.53 -"frame_found: movq 0x4(%%rax), %0\n"
1.54 -"frame_not_found:"
1.55 - : "=r" (result)
1.56 - : "r" (&sh4r)
1.57 - : "rax", "rcx", "rdx" );
1.58 + _Unwind_Backtrace( xlat_check_frame, &result );
1.59 return result;
1.60 }
1.61
2.1 --- a/src/sh4/xltcache.c Mon Jan 14 10:37:02 2008 +0000
2.2 +++ b/src/sh4/xltcache.c Tue Jan 15 02:20:30 2008 +0000
2.3 @@ -220,14 +220,14 @@
2.4 return NULL;
2.5 }
2.6 for( posn=count-1; posn > 0; posn-- ) {
2.7 - if( records[posn-1].xlat_pc <= (uintptr_t)native_pc ) {
2.8 + if( records[posn-1].xlat_pc < (uintptr_t)native_pc ) {
2.9 return &records[posn];
2.10 }
2.11 }
2.12 return &records[0]; // shouldn't happen
2.13 } else {
2.14 for( posn = 1; posn < count; posn++ ) {
2.15 - if( records[posn].xlat_pc > (uintptr_t)native_pc ) {
2.16 + if( records[posn].xlat_pc >= (uintptr_t)native_pc ) {
2.17 return &records[posn-1];
2.18 }
2.19 }
3.1 --- a/src/sh4/xltcache.h Mon Jan 14 10:37:02 2008 +0000
3.2 +++ b/src/sh4/xltcache.h Tue Jan 15 02:20:30 2008 +0000
3.3 @@ -37,14 +37,16 @@
3.4 // (0 = first instruction, 1 = second instruction, ... )
3.5 } *xlat_recovery_record_t;
3.6
3.7 -typedef struct xlat_cache_block {
3.8 +struct xlat_cache_block {
3.9 int active; /* 0 = deleted, 1 = normal. 2 = accessed (temp-space only) */
3.10 uint32_t size;
3.11 void **lut_entry; /* For deletion */
3.12 xlat_recovery_record_t recover_table;
3.13 uint32_t recover_table_size;
3.14 unsigned char code[0];
3.15 -} *xlat_cache_block_t;
3.16 +} __attribute__((packed));
3.17 +
3.18 +typedef struct xlat_cache_block *xlat_cache_block_t;
3.19
3.20 /**
3.21 * Initialize the translation cache
.