DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
src/cpu/core_full.cpp
00001 /*
00002  *  Copyright (C) 2002-2015  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
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 #define CPU_CORE CPU_ARCHTYPE_386
00032 
00033 typedef PhysPt EAPoint;
00034 #define SegBase(c)      SegPhys(c)
00035 
00036 #define LoadMb(off) mem_readb_inline(off)
00037 #define LoadMw(off) mem_readw_inline(off)
00038 #define LoadMd(off) mem_readd_inline(off)
00039 
00040 #define LoadMbs(off) (Bit8s)(LoadMb(off))
00041 #define LoadMws(off) (Bit16s)(LoadMw(off))
00042 #define LoadMds(off) (Bit32s)(LoadMd(off))
00043 
00044 #define SaveMb(off,val) mem_writeb_inline(off,val)
00045 #define SaveMw(off,val) mem_writew_inline(off,val)
00046 #define SaveMd(off,val) mem_writed_inline(off,val)
00047 
00048 #define LoadD(reg) reg
00049 #define SaveD(reg,val)  reg=val
00050 
00051 
00052 
00053 #include "core_full/loadwrite.h"
00054 #include "core_full/support.h"
00055 #include "core_full/optable.h"
00056 #include "instructions.h"
00057 
00058 #define EXCEPTION(blah)                                                                         \
00059         {                                                                                                               \
00060                 Bit8u new_num=blah;                                                                     \
00061                 CPU_Exception(new_num,0);                                                       \
00062                 continue;                                                                                       \
00063         }
00064 
00065 Bits CPU_Core_Normal_Trap_Run(void);
00066 
00067 Bits CPU_Core_Full_Run(void) {
00068         static bool tf_warn=false;
00069         FullData inst;
00070 
00071         while (CPU_Cycles-->0) {
00072                 cycle_count++;
00073 
00074                 /* this core isn't written to emulate the Trap Flag. at least
00075                  * let the user know. some demos (Second Reality, Future Crew)
00076                  * use the Trap Flag to self-decrypt on execute, which is why
00077                  * they normally crash when run under core=full */
00078                 if (GETFLAG(TF)) {
00079                         if (!tf_warn) {
00080                                 tf_warn = true;
00081                                 LOG(LOG_CPU,LOG_WARN)("Trap Flag single-stepping not supported by full core. Using normal core for TF emulation.");
00082                         }
00083 
00084                         return CPU_Core_Normal_Trap_Run();
00085                 }
00086                 else {
00087                         tf_warn = false;
00088                 }
00089 
00090 #if C_DEBUG             
00091 #if C_HEAVY_DEBUG
00092                 if (DEBUG_HeavyIsBreakpoint()) {
00093                         FillFlags();
00094                         return (Bits)debugCallback;
00095                 };
00096 #endif
00097 #endif
00098 
00099                 LoadIP();
00100                 inst.entry=cpu.code.big*0x200u;
00101                 inst.prefix=cpu.code.big;
00102 restartopcode:
00103                 inst.entry=(inst.entry & 0xffffff00u) | Fetchb();
00104                 inst.code=OpCodeTable[inst.entry];
00105         Bitu old_flags = reg_flags;
00106                 Bitu old_esp = reg_esp; // always restore stack pointer on page fault
00107                 try {
00108                         #include "core_full/load.h"
00109                         #include "core_full/op.h"
00110                         #include "core_full/save.h"
00111                 }
00112                 catch (GuestPageFaultException &pf) {
00113                         (void)pf;
00114                         reg_flags = old_flags; /* core_full/op.h may have modified flags */
00115                         reg_esp = old_esp;
00116                         throw;
00117                 }
00118 nextopcode:;
00119                 SaveIP();
00120                 continue;
00121 illegalopcode:
00122                 LOG(LOG_CPU,LOG_NORMAL)("Illegal opcode");
00123                 CPU_Exception(0x6,0);
00124         }
00125         FillFlags();
00126         return CBRET_NONE;
00127 }
00128 
00129 
00130 void CPU_Core_Full_Init(void) {
00131 
00132 }