|
|
1.1 root 1: /*
2: Hatari
3:
1.1.1.5 ! root 4: M68000 - CPU. This originally (in WinSTon) handled exceptions as well as some
! 5: few OpCode's such as Line-F and Line-A. In Hatari it has mainly become a
! 6: wrapper between the WinSTon sources and the UAE CPU code.
1.1 root 7: */
8:
9: #include "main.h"
10: #include "bios.h"
11: #include "cart.h"
12: #include "debug.h"
13: #include "decode.h"
14: #include "fdc.h"
15: #include "gemdos.h"
16: #include "ikbd.h"
17: #include "int.h"
18: #include "m68000.h"
19: #include "memAlloc.h"
20: #include "memorySnapShot.h"
21: #include "mfp.h"
22: #include "misc.h"
23: #include "psg.h"
24: #include "screen.h"
25: #include "stMemory.h"
26: #include "tos.h"
27: #include "vdi.h"
28: #include "xbios.h"
29:
30:
31: unsigned long ExceptionVector;
32: short int PendingInterruptFlag;
33: void *PendingInterruptFunction;
34: short int PendingInterruptCount;
35: unsigned long BusAddressLocation;
36:
37:
38:
1.1.1.3 root 39: /*-----------------------------------------------------------------------*/
1.1 root 40: /*
41: Reset CPU 68000 variables
42: */
43: void M68000_Reset(BOOL bCold)
44: {
45: int i;
46:
1.1.1.3 root 47: /* Clear registers, set PC, SR and stack pointers */
1.1.1.5 ! root 48: if (bCold)
! 49: {
1.1 root 50: for(i=0; i<(16+1); i++)
51: Regs[i] = 0;
52: }
53: PC = TOSAddress; /* Start of TOS image, 0xfc0000 or 0xe00000 */
54: SR = 0x2700; /* Starting status register */
1.1.1.3 root 55: MakeFromSR();
1.1.1.2 root 56: PendingInterruptFlag = 0; /* Clear pending flag */
1.1 root 57:
1.1.1.4 root 58: /* Now directly reset the UAE CPU core: */
59: m68k_reset();
1.1 root 60: }
61:
1.1.1.3 root 62:
63: /*-----------------------------------------------------------------------*/
1.1 root 64: /*
65: Save/Restore snapshot of local variables('MemorySnapShot_Store' handles type)
66: */
67: void M68000_MemorySnapShot_Capture(BOOL bSave)
68: {
1.1.1.3 root 69: /* Save/Restore details */
1.1.1.4 root 70: /*MemorySnapShot_Store(&bDoTraceException,sizeof(bDoTraceException));*/
1.1 root 71: }
72:
1.1.1.3 root 73:
74: /*-----------------------------------------------------------------------*/
1.1 root 75: /*
76: Save/Restore snapshot of local variables('MemorySnapShot_Store' handles type)
77: This is for 'decode.asm' variables - as cannot use 'decode.c' as will overwrite assembler .obj file!
78: */
79: void M68000_Decode_MemorySnapShot_Capture(BOOL bSave)
80: {
81: int ID;
82:
1.1.1.3 root 83: /* Save/Restore details */
1.1 root 84: MemorySnapShot_Store(Regs,sizeof(Regs));
85: MemorySnapShot_Store(&STRamEnd,sizeof(STRamEnd));
86: MemorySnapShot_Store(&STRamEnd_BusErr,sizeof(STRamEnd_BusErr));
87: MemorySnapShot_Store(&PendingInterruptCount,sizeof(PendingInterruptCount));
88: MemorySnapShot_Store(&PendingInterruptFlag,sizeof(PendingInterruptFlag));
1.1.1.5 ! root 89: if (bSave)
! 90: {
1.1.1.3 root 91: /* Convert function to ID */
1.1 root 92: ID = Int_HandlerFunctionToID(PendingInterruptFunction);
93: MemorySnapShot_Store(&ID,sizeof(int));
94: }
1.1.1.5 ! root 95: else
! 96: {
1.1.1.3 root 97: /* Convert ID to function */
1.1 root 98: MemorySnapShot_Store(&ID,sizeof(int));
99: PendingInterruptFunction = Int_IDToHandlerFunction(ID);
100: }
101: MemorySnapShot_Store(&PC,sizeof(PC));
102: MemorySnapShot_Store(&SR,sizeof(SR));
1.1.1.4 root 103: /*MemorySnapShot_Store(&bInSuperMode,sizeof(bInSuperMode));*/
1.1.1.2 root 104: /*MemorySnapShot_Store(&Reg_SuperSP,sizeof(Reg_SuperSP));*//*FIXME*/
105: /*MemorySnapShot_Store(&Reg_UserSP,sizeof(Reg_UserSP));*/
1.1.1.4 root 106: /*MemorySnapShot_Store(&EmuCCode,sizeof(EmuCCode));*/
1.1 root 107: MemorySnapShot_Store(&ExceptionVector,sizeof(ExceptionVector));
108: }
109:
110:
1.1.1.3 root 111: /*-----------------------------------------------------------------------*/
1.1 root 112: /*
113: BUSERROR - Access outside valid memory range
114: */
115: void M68000_BusError(unsigned long addr)
116: {
1.1.1.5 ! root 117: if(BusAddressLocation!=0xff8a00 && BusAddressLocation!=0xff8900
! 118: && BusAddressLocation!=0xfffa40 && BusAddressLocation!=0xff8400
! 119: && BusAddressLocation!=0xff8282 && BusAddressLocation!=0xff8961)
! 120: {
! 121: /* Print bus errors (except TOS' tests for blitter and DMA sound etc.) */
! 122: fprintf(stderr, "M68000_BusError at address $%lx\n", (long)addr);
! 123: }
! 124:
1.1.1.3 root 125: BusAddressLocation=addr; /* Store for exception frame */
126: ExceptionVector = EXCEPTION_BUSERROR; /* Handler */
127: M68000_Exception(); /* Cause trap */
1.1 root 128: }
129:
1.1.1.3 root 130:
131: /*-----------------------------------------------------------------------*/
1.1 root 132: /*
133: ADDRESSERROR - Access incorrect memory boundary, eg byte offset for a word access
134: */
135: void M68000_AddressError(unsigned long addr)
136: {
1.1.1.3 root 137: fprintf(stderr, "M68000_AddressError at address $%lx\n", (long)addr);
138: BusAddressLocation=addr; /* Store for exception frame */
139: ExceptionVector=EXCEPTION_ADDRERROR; /* Handler */
140: M68000_Exception(); /* Cause trap */
1.1 root 141: }
142:
1.1.1.3 root 143:
144: /*-----------------------------------------------------------------------*/
1.1 root 145: /*
146: Exception handler
147: */
148: void M68000_Exception(void)
149: {
1.1.1.2 root 150: /* Was the CPU stopped, i.e. by a STOP instruction? */
151: regs.stopped = 0;
152: unset_special (SPCFLAG_STOP); /* All is go,go,go! */
153:
1.1 root 154: /* At the moment, this functions ist just a wrapper to Exception() of the UAE CPU - Thothy */
155: Exception(ExceptionVector/4, m68k_getpc());
156: }
157:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.