DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/cpu/core_dynrec/risc_armv4le-common.h
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 
00020 
00021 /* ARMv4 (little endian) backend by M-HT (common data/functions) */
00022 
00023 
00024 // some configuring defines that specify the capabilities of this architecture
00025 // or aspects of the recompiling
00026 
00027 // protect FC_ADDR over function calls if necessaray
00028 // #define DRC_PROTECT_ADDR_REG
00029 
00030 // try to use non-flags generating functions if possible
00031 #define DRC_FLAGS_INVALIDATION
00032 // try to replace _simple functions by code
00033 #define DRC_FLAGS_INVALIDATION_DCODE
00034 
00035 // type with the same size as a pointer
00036 #define DRC_PTR_SIZE_IM Bit32u
00037 
00038 // calling convention modifier
00039 #define DRC_CALL_CONV   /* nothing */
00040 #define DRC_FC                  /* nothing */
00041 
00042 // use FC_REGS_ADDR to hold the address of "cpu_regs" and to access it using FC_REGS_ADDR
00043 #define DRC_USE_REGS_ADDR
00044 // use FC_SEGS_ADDR to hold the address of "Segs" and to access it using FC_SEGS_ADDR
00045 #define DRC_USE_SEGS_ADDR
00046 
00047 // register mapping
00048 typedef Bit8u HostReg;
00049 
00050 // "lo" registers
00051 #define HOST_r0          0
00052 #define HOST_r1          1
00053 #define HOST_r2          2
00054 #define HOST_r3          3
00055 #define HOST_r4          4
00056 #define HOST_r5          5
00057 #define HOST_r6          6
00058 #define HOST_r7          7
00059 // "hi" registers
00060 #define HOST_r8          8
00061 #define HOST_r9          9
00062 #define HOST_r10        10
00063 #define HOST_r11        11
00064 #define HOST_r12        12
00065 #define HOST_r13        13
00066 #define HOST_r14        14
00067 #define HOST_r15        15
00068 
00069 // register aliases
00070 // "lo" registers
00071 #define HOST_a1 HOST_r0
00072 #define HOST_a2 HOST_r1
00073 #define HOST_a3 HOST_r2
00074 #define HOST_a4 HOST_r3
00075 #define HOST_v1 HOST_r4
00076 #define HOST_v2 HOST_r5
00077 #define HOST_v3 HOST_r6
00078 #define HOST_v4 HOST_r7
00079 // "hi" registers
00080 #define HOST_v5 HOST_r8
00081 #define HOST_v6 HOST_r9
00082 #define HOST_v7 HOST_r10
00083 #define HOST_v8 HOST_r11
00084 #define HOST_ip HOST_r12
00085 #define HOST_sp HOST_r13
00086 #define HOST_lr HOST_r14
00087 #define HOST_pc HOST_r15
00088 
00089 
00090 static void cache_block_closing(Bit8u* block_start,Bitu block_size) {
00091 #ifdef _MSC_VER
00092     //flush cache - Win32 API for MSVC
00093     FlushInstructionCache(GetCurrentProcess(), block_start, block_size);
00094 #else
00095 #if (__ARM_EABI__)
00096         //flush cache - eabi
00097         register unsigned long _beg __asm ("a1") = (unsigned long)(block_start);                                // block start
00098         register unsigned long _end __asm ("a2") = (unsigned long)(block_start+block_size);             // block end
00099         register unsigned long _flg __asm ("a3") = 0;
00100         register unsigned long _par __asm ("r7") = 0xf0002;                                                                             // sys_cacheflush
00101         __asm __volatile ("swi 0x0"
00102                 : // no outputs
00103                 : "r" (_beg), "r" (_end), "r" (_flg), "r" (_par)
00104                 );
00105 #else
00106 // GP2X BEGIN
00107         //flush cache - old abi
00108         register unsigned long _beg __asm ("a1") = (unsigned long)(block_start);                                // block start
00109         register unsigned long _end __asm ("a2") = (unsigned long)(block_start+block_size);             // block end
00110         register unsigned long _flg __asm ("a3") = 0;
00111         __asm __volatile ("swi 0x9f0002         @ sys_cacheflush"
00112                 : // no outputs
00113                 : "r" (_beg), "r" (_end), "r" (_flg)
00114                 );
00115 // GP2X END
00116 #endif
00117 #endif
00118 }