DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/cpu/core_full.cpp
00001 /*
00002  *  Copyright (C) 2002-2020  The DOSBox Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License along
00015  *  with this program; if not, write to the Free Software Foundation, Inc.,
00016  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #include "dosbox.h"
00020 
00021 #include "pic.h"
00022 #include "regs.h"
00023 #include "cpu.h"
00024 #include "lazyflags.h"
00025 #include "paging.h"
00026 #include "fpu.h"
00027 #include "debug.h"
00028 #include "inout.h"
00029 #include "callback.h"
00030 
00031 extern bool ignore_opcode_63;
00032 
00033 #define CPU_CORE CPU_ARCHTYPE_386
00034 
00035 typedef PhysPt EAPoint;
00036 #define SegBase(c)      SegPhys(c)
00037 
00038 #define LoadMb(off) mem_readb_inline(off)
00039 #define LoadMw(off) mem_readw_inline(off)
00040 #define LoadMd(off) mem_readd_inline(off)
00041 
00042 #define LoadMbs(off) (Bit8s)(LoadMb(off))
00043 #define LoadMws(off) (Bit16s)(LoadMw(off))
00044 #define LoadMds(off) (Bit32s)(LoadMd(off))
00045 
00046 #define SaveMb(off,val) mem_writeb_inline(off,val)
00047 #define SaveMw(off,val) mem_writew_inline(off,val)
00048 #define SaveMd(off,val) mem_writed_inline(off,val)
00049 
00050 #define LoadD(reg) reg
00051 #define SaveD(reg,val)  reg=val
00052 
00053 
00054 
00055 #include "core_full/loadwrite.h"
00056 #include "core_full/support.h"
00057 #include "core_full/optable.h"
00058 #include "instructions.h"
00059 
00060 #define EXCEPTION(blah)                                                                         \
00061         {                                                                                                               \
00062                 Bit8u new_num=blah;                                                                     \
00063                 CPU_Exception(new_num,0);                                                       \
00064                 continue;                                                                                       \
00065         }
00066 
00067 Bits CPU_Core_Normal_Trap_Run(void);
00068 
00069 Bits CPU_Core_Full_Run(void) {
00070         static bool tf_warn=false;
00071         FullData inst;
00072 
00073         if (CPU_Cycles <= 0)
00074                 return CBRET_NONE;
00075 
00076         while (CPU_Cycles-->0) {
00077                 cycle_count++;
00078 
00079                 /* this core isn't written to emulate the Trap Flag. at least
00080                  * let the user know. some demos (Second Reality, Future Crew)
00081                  * use the Trap Flag to self-decrypt on execute, which is why
00082                  * they normally crash when run under core=full */
00083                 if (GETFLAG(TF)) {
00084                         if (!tf_warn) {
00085                                 tf_warn = true;
00086                                 LOG(LOG_CPU,LOG_WARN)("Trap Flag single-stepping not supported by full core. Using normal core for TF emulation.");
00087                         }
00088 
00089                         return CPU_Core_Normal_Trap_Run();
00090                 }
00091                 else {
00092                         tf_warn = false;
00093                 }
00094 
00095 #if C_DEBUG             
00096 #if C_HEAVY_DEBUG
00097                 if (DEBUG_HeavyIsBreakpoint()) {
00098                         FillFlags();
00099                         return (Bits)debugCallback;
00100                 }
00101 #endif
00102 #endif
00103 
00104                 LoadIP();
00105                 inst.entry=cpu.code.big*(Bitu)0x200u;
00106                 inst.prefix=cpu.code.big;
00107 restartopcode:
00108                 inst.entry=(inst.entry & 0xffffff00u) | Fetchb();
00109                 inst.code=OpCodeTable[inst.entry];
00110         Bitu old_flags = reg_flags;
00111                 Bit32u old_esp = reg_esp; // always restore stack pointer on page fault
00112                 try {
00113                         #include "core_full/load.h"
00114                         #include "core_full/op.h"
00115                         #include "core_full/save.h"
00116                 }
00117                 catch (const GuestPageFaultException &pf) {
00118                         (void)pf;
00119                         reg_flags = old_flags; /* core_full/op.h may have modified flags */
00120                         reg_esp = old_esp;
00121                         throw;
00122                 }
00123 nextopcode:;
00124                 SaveIP();
00125                 continue;
00126 illegalopcode:
00127 #if C_DEBUG     
00128                 {
00129                         bool ignore=false;
00130                         Bitu len=(GetIP()-reg_eip);
00131                         LoadIP();
00132                         if (len>16) len=16;
00133                         char tempcode[16*2+1];char * writecode=tempcode;
00134                         if (ignore_opcode_63 && mem_readb(inst.cseip) == 0x63)
00135                                 ignore = true;
00136                         for (;len>0;len--) {
00137                                 sprintf(writecode,"%02X",mem_readb(inst.cseip++));
00138                                 writecode+=2;
00139                         }
00140                         if (!ignore)
00141                                 LOG(LOG_CPU,LOG_NORMAL)("Illegal/Unhandled opcode %s",tempcode);
00142                 }
00143 #endif
00144                 CPU_Exception(0x6,0);
00145         }
00146         FillFlags();
00147         return CBRET_NONE;
00148 }
00149 
00150 
00151 void CPU_Core_Full_Init(void) {
00152 
00153 }