Search
lxdream.org :: lxdream/src/test/testsh4x86.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/test/testsh4x86.c
changeset 953:f4a156508ad1
prev925:7cbcc51db63d
next963:1c3a0f67c603
author nkeynes
date Tue Jan 13 11:56:28 2009 +0000 (11 years ago)
permissions -rw-r--r--
last change Merge lxdream-mem branch back to trunk
file annotate diff log raw
1.1 --- a/src/test/testsh4x86.c Sun Dec 14 06:36:49 2008 +0000
1.2 +++ b/src/test/testsh4x86.c Tue Jan 13 11:56:28 2009 +0000
1.3 @@ -35,6 +35,9 @@
1.4
1.5 #define MAX_INS_SIZE 32
1.6
1.7 +
1.8 +struct mem_region_fn **sh4_address_space = (void *)0x12345432;
1.9 +struct mem_region_fn **sh4_user_address_space = (void *)0x12345678;
1.10 char *option_list = "s:o:d:h";
1.11 struct option longopts[1] = { { NULL, 0, 0, 0 } };
1.12
1.13 @@ -44,7 +47,8 @@
1.14 gboolean sh4_starting;
1.15 uint32_t start_addr = 0x8C010000;
1.16 uint32_t sh4_cpu_period = 5;
1.17 -sh4ptr_t sh4_main_ram;
1.18 +unsigned char dc_main_ram[4096];
1.19 +unsigned char dc_boot_rom[4096];
1.20 FILE *in;
1.21
1.22 char *inbuf;
1.23 @@ -52,8 +56,8 @@
1.24 struct x86_symbol local_symbols[] = {
1.25 { "sh4r+128", ((char *)&sh4r)+128 },
1.26 { "sh4_cpu_period", &sh4_cpu_period },
1.27 - { "mmu_vma_to_phys_read", mmu_vma_to_phys_read },
1.28 - { "mmu_vma_to_phys_write", mmu_vma_to_phys_write },
1.29 + { "sh4_address_space", (void *)0x12345432 },
1.30 + { "sh4_user_address_space", (void *)0x12345678 },
1.31 { "sh4_write_fpscr", sh4_write_fpscr },
1.32 { "sh4_write_sr", sh4_write_sr },
1.33 { "sh4_read_sr", sh4_read_sr },
1.34 @@ -63,28 +67,10 @@
1.35 { "sh4_switch_fr_banks", sh4_switch_fr_banks },
1.36 { "sh4_execute_instruction", sh4_execute_instruction },
1.37 { "signsat48", signsat48 },
1.38 - { "sh4_read_byte", sh4_read_byte },
1.39 - { "sh4_read_word", sh4_read_word },
1.40 - { "sh4_read_long", sh4_read_long },
1.41 - { "sh4_write_byte", sh4_write_byte },
1.42 - { "sh4_write_word", sh4_write_word },
1.43 - { "sh4_write_long", sh4_write_long },
1.44 { "xlat_get_code_by_vma", xlat_get_code_by_vma },
1.45 { "xlat_get_code", xlat_get_code }
1.46 };
1.47
1.48 -int32_t FASTCALL sh4_read_byte( uint32_t addr )
1.49 -{
1.50 - return *(uint8_t *)(inbuf+(addr-start_addr));
1.51 -}
1.52 -int32_t FASTCALL sh4_read_word( uint32_t addr )
1.53 -{
1.54 - return *(uint16_t *)(inbuf+(addr-start_addr));
1.55 -}
1.56 -int32_t FASTCALL sh4_read_long( uint32_t addr )
1.57 -{
1.58 - return *(uint32_t *)(inbuf+(addr-start_addr));
1.59 -}
1.60 // Stubs
1.61 gboolean sh4_execute_instruction( ) { return TRUE; }
1.62 void sh4_accept_interrupt() {}
1.63 @@ -92,15 +78,13 @@
1.64 gboolean sh4_clear_breakpoint( uint32_t pc, breakpoint_type_t type ) { return TRUE; }
1.65 gboolean dreamcast_is_running() { return FALSE; }
1.66 int sh4_get_breakpoint( uint32_t pc ) { return 0; }
1.67 +void sh4_finalize_instruction() { }
1.68 void sh4_core_exit( int exit_code ){}
1.69 -void sh4_flush_icache(){}
1.70 void event_execute() {}
1.71 void TMU_run_slice( uint32_t nanos ) {}
1.72 +void CCN_set_cache_control( uint32_t val ) { }
1.73 void PMM_write_control( int ctr, uint32_t val ) { }
1.74 void SCIF_run_slice( uint32_t nanos ) {}
1.75 -void FASTCALL sh4_write_byte( uint32_t addr, uint32_t val ) {}
1.76 -void FASTCALL sh4_write_word( uint32_t addr, uint32_t val ) {}
1.77 -void FASTCALL sh4_write_long( uint32_t addr, uint32_t val ) {}
1.78 void FASTCALL sh4_write_fpscr( uint32_t val ) { }
1.79 void FASTCALL sh4_write_sr( uint32_t val ) { }
1.80 uint32_t FASTCALL sh4_read_sr( void ) { return 0; }
1.81 @@ -114,13 +98,19 @@
1.82 void syscall_invoke( uint32_t val ) { }
1.83 void dreamcast_stop() {}
1.84 void dreamcast_reset() {}
1.85 -gboolean FASTCALL sh4_raise_reset( int exc ) { return TRUE; }
1.86 -gboolean FASTCALL sh4_raise_exception( int exc ) { return TRUE; }
1.87 -gboolean FASTCALL sh4_raise_tlb_exception( int exc ) { return TRUE; }
1.88 -gboolean FASTCALL sh4_raise_trap( int exc ) { return TRUE; }
1.89 +void FASTCALL sh4_raise_reset( int exc ) { }
1.90 +void FASTCALL sh4_raise_exception( int exc ) { }
1.91 +void FASTCALL sh4_raise_tlb_exception( int exc, sh4vma_t vma ) { }
1.92 +void FASTCALL sh4_raise_tlb_multihit( sh4vma_t vma) { }
1.93 +void FASTCALL sh4_raise_trap( int exc ) { }
1.94 +void FASTCALL sh4_flush_store_queue( sh4addr_t addr ) { }
1.95 +void FASTCALL sh4_flush_store_queue_mmu( sh4addr_t addr, void *exc ) { }
1.96 uint32_t sh4_sleep_run_slice(uint32_t nanosecs) { return nanosecs; }
1.97 gboolean gui_error_dialog( const char *fmt, ... ) { return TRUE; }
1.98 +gboolean FASTCALL mmu_update_icache( sh4vma_t addr ) { return TRUE; }
1.99 +void MMU_ldtlb() { }
1.100 struct sh4_icache_struct sh4_icache;
1.101 +struct mem_region_fn mem_region_unmapped;
1.102
1.103 void usage()
1.104 {
1.105 @@ -175,6 +165,8 @@
1.106 mmio_region_MMU.mem = malloc(4096);
1.107 memset( mmio_region_MMU.mem, 0, 4096 );
1.108
1.109 + ((uint32_t *)mmio_region_MMU.mem)[4] = 1;
1.110 +
1.111 in = fopen( input_file, "ro" );
1.112 if( in == NULL ) {
1.113 perror( "Unable to open input file" );
1.114 @@ -192,13 +184,13 @@
1.115 uintptr_t pc;
1.116 uint8_t *buf = sh4_translate_basic_block( start_addr );
1.117 uint32_t buflen = xlat_get_code_size(buf);
1.118 - x86_disasm_init( buf, buf, buflen );
1.119 + x86_disasm_init( (uintptr_t)buf, (uintptr_t)buf, buflen );
1.120 x86_set_symtab( local_symbols, sizeof(local_symbols)/sizeof(struct x86_symbol) );
1.121 for( pc = buf; pc < buf + buflen; ) {
1.122 char buf[256];
1.123 char op[256];
1.124 uintptr_t pc2 = x86_disasm_instruction( pc, buf, sizeof(buf), op );
1.125 - fprintf( stdout, "%s\n", buf );
1.126 + fprintf( stdout, "%08x: %s\n", pc, buf );
1.127 pc = pc2;
1.128 }
1.129 return 0;
.