Annotation of frontvm/hardware/m68000.c, revision 1.1.1.1

1.1       root        1: /*
                      2:   Hatari - m68000.c
                      3: 
                      4:   This file is distributed under the GNU Public License, version 2 or at
                      5:   your option any later version. Read the file gpl.txt for details.
                      6: 
                      7:   These routines originally (in WinSTon) handled exceptions as well as some
                      8:   few OpCode's such as Line-F and Line-A. In Hatari it has mainly become a
                      9:   wrapper between the WinSTon sources and the UAE CPU code.
                     10: */
                     11: 
                     12: #include <SDL.h>
                     13: #include "main.h"
                     14: #include "decode.h"
                     15: #include "hatari-glue.h"
                     16: #include "int.h"
                     17: #include "m68000.h"
                     18: #include "stMemory.h"
                     19: #include "disasm.h"
                     20: 
                     21: unsigned long ExceptionVector;
                     22: short int PendingInterruptFlag;
                     23: void *PendingInterruptFunction;
                     24: short int PendingInterruptCount;
                     25: Uint32 BusAddressLocation;       /* Stores the offending address for bus-/address errors */
                     26: Uint32 BusErrorPC;               /* Value of the PC when bus error occurs */
                     27: Uint16 BusErrorOpcode;           /* Opcode of faulting instruction */
                     28: 
                     29: 
                     30: /*-----------------------------------------------------------------------*/
                     31: /*
                     32:   Reset CPU 68000 variables
                     33: */
                     34: void M68000_Reset(BOOL bCold)
                     35: {
                     36:   int i;
                     37: 
                     38:   /* Clear registers */
                     39:   if (bCold)
                     40:   {
                     41:     for(i=0; i<(16+1); i++)
                     42:       Regs[i] = 0;
                     43:   }
                     44: 
                     45:   PendingInterruptFlag = 0;     /* Clear pending flag */
                     46: 
                     47:   /* Now directly reset the UAE CPU core: */
                     48:   m68k_reset();
                     49: }
                     50: 
                     51: static void dump_registers ()
                     52: {
                     53:        int i;
                     54:        for (i=0; i<8; i++) {
                     55:                fprintf (stderr, "D%d: 0x%08x\t\tA%d: 0x%08x\n", i, Regs[i], i, Regs[i+8]);
                     56:        }
                     57: }
                     58: 
                     59: void M68000_Crash (int exception)
                     60: {
                     61:        int pc = m68k_getpc();
                     62:        
                     63:        fprintf(stderr, "Exception (-> %i bombs) at 0x%x!\n\n", exception, pc);
                     64:        dump_registers ();
                     65:        dump_code (pc, 32);
                     66:        SDL_Quit ();
                     67:        exit (-2);
                     68: }
                     69: 
                     70: /*-----------------------------------------------------------------------*/
                     71: /*
                     72:   Exception handler
                     73: */
                     74: void M68000_Exception(void)
                     75: {
                     76:   int exceptionNr = ExceptionVector/4;
                     77: 
                     78:   if(exceptionNr>24 && exceptionNr<32)  /* 68k autovector interrupt? */
                     79:   {
                     80:     /* Handle autovector interrupts the UAE's way
                     81:      * (see intlev() and do_specialties() in UAE CPU core) */
                     82: #if 1
                     83:     if(requestedInterrupt != -1)
                     84:       fprintf(stderr,"Warning: Overriding interrupt %d with %d\n",
                     85:               requestedInterrupt, exceptionNr-24);
                     86: #endif
                     87:     requestedInterrupt = exceptionNr - 24;
                     88:     set_special(SPCFLAG_INT);
                     89:   }
                     90:   else
                     91:   {
                     92:     /* Was the CPU stopped, i.e. by a STOP instruction? */
                     93:     regs.stopped = 0;
                     94:     unset_special(SPCFLAG_STOP);        /* All is go,go,go! */
                     95: 
                     96:     /* 68k exceptions are handled by Exception() of the UAE CPU core */
                     97:     Exception(exceptionNr, m68k_getpc());
                     98: 
                     99:     MakeSR();
                    100:     /* Set Status Register so interrupt can ONLY be stopped by another interrupt
                    101:      * of higher priority! */
                    102: #if 0  /* VBL and HBL are handled in the UAE CPU core (see above). */
                    103:     if (ExceptionVector==EXCEPTION_VBLANK)
                    104:       SR = (SR&SR_CLEAR_IPL)|0x0400;  /* VBL, level 4 */
                    105:     else if (ExceptionVector==EXCEPTION_HBLANK)
                    106:       SR = (SR&SR_CLEAR_IPL)|0x0200;  /* HBL, level 2 */
                    107:     else
                    108: #endif
                    109:     MakeFromSR();
                    110:   }
                    111: }
                    112: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.