trunk/src/emu/cpu/m68000/m68000.h
| r23946 | r23947 | |
| 16 | 16 | |
| 17 | 17 | #include "../../../lib/softfloat/milieu.h" |
| 18 | 18 | #include "../../../lib/softfloat/softfloat.h" |
| 19 | | #include <setjmp.h> |
| 20 | 19 | |
| 21 | 20 | |
| 22 | 21 | /* MMU constants */ |
| r23946 | r23947 | |
| 28 | 27 | |
| 29 | 28 | |
| 30 | 29 | |
| 31 | | /* Address error */ |
| 32 | | /* sigjmp() on Mac OS X and *BSD in general saves signal contexts and is super-slow, use sigsetjmp() to tell it not to */ |
| 33 | | #ifdef _BSD_SETJMP_H |
| 34 | | #define m68ki_set_address_error_trap(m68k) \ |
| 35 | | if(sigsetjmp(m68k->aerr_trap, 0) != 0) \ |
| 36 | | { \ |
| 37 | | m68ki_exception_address_error(m68k); \ |
| 38 | | if(m68k->stopped) \ |
| 39 | | { \ |
| 40 | | if (m68k->remaining_cycles > 0) \ |
| 41 | | m68k->remaining_cycles = 0; \ |
| 42 | | return; \ |
| 43 | | } \ |
| 44 | | } |
| 45 | | |
| 46 | 30 | #define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \ |
| 47 | 31 | if((ADDR)&1) \ |
| 48 | 32 | { \ |
| 49 | 33 | m68k->aerr_address = ADDR; \ |
| 50 | 34 | m68k->aerr_write_mode = WRITE_MODE; \ |
| 51 | 35 | m68k->aerr_fc = FC; \ |
| 52 | | siglongjmp(m68k->aerr_trap, 1); \ |
| 36 | throw 10; \ |
| 53 | 37 | } |
| 54 | | #else |
| 55 | | #define m68ki_set_address_error_trap(m68k) \ |
| 56 | | SETJMP_GNUC_PROTECT(); \ |
| 57 | | if(setjmp(m68k->aerr_trap) != 0) \ |
| 58 | | { \ |
| 59 | | m68ki_exception_address_error(m68k); \ |
| 60 | | if(m68k->stopped) \ |
| 61 | | { \ |
| 62 | | if (m68k->remaining_cycles > 0) \ |
| 63 | | m68k->remaining_cycles = 0; \ |
| 64 | | return; \ |
| 65 | | } \ |
| 66 | | } |
| 67 | 38 | |
| 68 | | #define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \ |
| 69 | | if((ADDR)&1) \ |
| 70 | | { \ |
| 71 | | m68k->aerr_address = ADDR; \ |
| 72 | | m68k->aerr_write_mode = WRITE_MODE; \ |
| 73 | | m68k->aerr_fc = FC; \ |
| 74 | | longjmp(m68k->aerr_trap, 1); \ |
| 75 | | } |
| 76 | | #endif |
| 77 | 39 | |
| 78 | 40 | |
| 79 | | |
| 80 | 41 | /* There are 7 levels of interrupt to the 68K. |
| 81 | 42 | * A transition from < 7 to 7 will cause a non-maskable interrupt (NMI). |
| 82 | 43 | */ |
| r23946 | r23947 | |
| 286 | 247 | int reset_cycles; |
| 287 | 248 | UINT32 tracing; |
| 288 | 249 | |
| 289 | | #ifdef _BSD_SETJMP_H |
| 290 | | sigjmp_buf aerr_trap; |
| 291 | | #else |
| 292 | | jmp_buf aerr_trap; |
| 293 | | #endif |
| 250 | int m_address_error; |
| 251 | |
| 294 | 252 | UINT32 aerr_address; |
| 295 | 253 | UINT32 aerr_write_mode; |
| 296 | 254 | UINT32 aerr_fc; |
| r23946 | r23947 | |
| 314 | 272 | address_space *program; |
| 315 | 273 | |
| 316 | 274 | |
| 317 | | |
| 318 | 275 | /* Redirect memory calls */ |
| 319 | 276 | |
| 320 | 277 | typedef delegate<UINT8 (offs_t)> m68k_read8_delegate; |
trunk/src/emu/cpu/m68000/m68kcpu.c
| r23946 | r23947 | |
| 769 | 769 | if(!stopped) |
| 770 | 770 | { |
| 771 | 771 | /* Return point if we had an address error */ |
| 772 | | m68ki_set_address_error_trap(this); /* auto-disable (see m68kcpu.h) */ |
| 772 | check_address_error: |
| 773 | if (m_address_error==1) |
| 774 | { |
| 775 | m_address_error = 0; |
| 776 | m68ki_exception_address_error(this); |
| 777 | if(stopped) |
| 778 | { |
| 779 | if (remaining_cycles > 0) |
| 780 | remaining_cycles = 0; |
| 781 | return; |
| 782 | } |
| 783 | } |
| 773 | 784 | |
| 785 | |
| 774 | 786 | /* Main loop. Keep going until we run out of clock cycles */ |
| 775 | 787 | while (remaining_cycles > 0) |
| 776 | 788 | { |
| r23946 | r23947 | |
| 787 | 799 | /* Record previous program counter */ |
| 788 | 800 | REG_PPC(this) = REG_PC(this); |
| 789 | 801 | |
| 802 | try |
| 803 | { |
| 790 | 804 | if (!pmmu_enabled) |
| 791 | 805 | { |
| 792 | 806 | run_mode = RUN_MODE_NORMAL; |
| r23946 | r23947 | |
| 866 | 880 | // remaining_cycles -= cyc_exception[EXCEPTION_BUS_ERROR] - cyc_instruction[ir]; |
| 867 | 881 | } |
| 868 | 882 | } |
| 883 | } |
| 884 | catch (int error) |
| 885 | { |
| 886 | if (error==10) |
| 887 | { |
| 888 | m_address_error = 1; |
| 889 | goto check_address_error; |
| 890 | } |
| 891 | else |
| 892 | throw; |
| 893 | } |
| 869 | 894 | |
| 895 | |
| 870 | 896 | /* Trace m68k_exception, if necessary */ |
| 871 | 897 | m68ki_exception_if_trace(this); /* auto-disable (see m68kcpu.h) */ |
| 872 | 898 | } |
| r23946 | r23947 | |
| 2600 | 2626 | |
| 2601 | 2627 | void m68000_base_device::clear_all() |
| 2602 | 2628 | { |
| 2603 | | |
| 2604 | 2629 | cpu_type= 0; |
| 2605 | 2630 | // dasm_type= 0; |
| 2606 | 2631 | for (int i=0;i<16;i++) |
| r23946 | r23947 | |
| 2659 | 2684 | reset_cycles = 0; |
| 2660 | 2685 | tracing = 0; |
| 2661 | 2686 | |
| 2662 | | // aerr_trap = 0; |
| 2687 | m_address_error = 0; |
| 2663 | 2688 | |
| 2664 | 2689 | aerr_address = 0; |
| 2665 | 2690 | aerr_write_mode = 0; |