armemu.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. /* armemu.h -- ARMulator emulation macros: ARM6 Instruction Emulator.
  2. Copyright (C) 1994 Advanced RISC Machines Ltd.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  14. #ifndef __ARMEMU_H__
  15. #define __ARMEMU_H__
  16. #include "common/common.h"
  17. #include "armdefs.h"
  18. //#include "skyeye.h"
  19. extern ARMword isize;
  20. /* Condition code values. */
  21. #define EQ 0
  22. #define NE 1
  23. #define CS 2
  24. #define CC 3
  25. #define MI 4
  26. #define PL 5
  27. #define VS 6
  28. #define VC 7
  29. #define HI 8
  30. #define LS 9
  31. #define GE 10
  32. #define LT 11
  33. #define GT 12
  34. #define LE 13
  35. #define AL 14
  36. #define NV 15
  37. /* Shift Opcodes. */
  38. #define LSL 0
  39. #define LSR 1
  40. #define ASR 2
  41. #define ROR 3
  42. /* Macros to twiddle the status flags and mode. */
  43. #define NBIT ((unsigned)1L << 31)
  44. #define ZBIT (1L << 30)
  45. #define CBIT (1L << 29)
  46. #define VBIT (1L << 28)
  47. #define SBIT (1L << 27)
  48. #define IBIT (1L << 7)
  49. #define FBIT (1L << 6)
  50. #define IFBITS (3L << 6)
  51. #define R15IBIT (1L << 27)
  52. #define R15FBIT (1L << 26)
  53. #define R15IFBITS (3L << 26)
  54. #define POS(i) ( (~(i)) >> 31 )
  55. #define NEG(i) ( (i) >> 31 )
  56. #ifdef MODET /* Thumb support. */
  57. /* ??? This bit is actually in the low order bit of the PC in the hardware.
  58. It isn't clear if the simulator needs to model that or not. */
  59. #define TBIT (1L << 5)
  60. #define TFLAG state->TFlag
  61. #define SETT state->TFlag = 1
  62. #define CLEART state->TFlag = 0
  63. #define ASSIGNT(res) state->TFlag = res
  64. #define INSN_SIZE (TFLAG ? 2 : 4)
  65. #else
  66. #define TBIT (1L << 5)
  67. #define INSN_SIZE 4
  68. #define TFLAG 0
  69. #endif
  70. /*add armv6 CPSR feature*/
  71. #define EFLAG state->EFlag
  72. #define SETE state->EFlag = 1
  73. #define CLEARE state->EFlag = 0
  74. #define ASSIGNE(res) state->NFlag = res
  75. #define AFLAG state->AFlag
  76. #define SETA state->AFlag = 1
  77. #define CLEARA state->AFlag = 0
  78. #define ASSIGNA(res) state->NFlag = res
  79. #define QFLAG state->QFlag
  80. #define SETQ state->QFlag = 1
  81. #define CLEARQ state->AFlag = 0
  82. #define ASSIGNQ(res) state->QFlag = res
  83. /* add end */
  84. #define NFLAG state->NFlag
  85. #define SETN state->NFlag = 1
  86. #define CLEARN state->NFlag = 0
  87. #define ASSIGNN(res) state->NFlag = res
  88. #define ZFLAG state->ZFlag
  89. #define SETZ state->ZFlag = 1
  90. #define CLEARZ state->ZFlag = 0
  91. #define ASSIGNZ(res) state->ZFlag = res
  92. #define CFLAG state->CFlag
  93. #define SETC state->CFlag = 1
  94. #define CLEARC state->CFlag = 0
  95. #define ASSIGNC(res) state->CFlag = res
  96. #define VFLAG state->VFlag
  97. #define SETV state->VFlag = 1
  98. #define CLEARV state->VFlag = 0
  99. #define ASSIGNV(res) state->VFlag = res
  100. #define SFLAG state->SFlag
  101. #define SETS state->SFlag = 1
  102. #define CLEARS state->SFlag = 0
  103. #define ASSIGNS(res) state->SFlag = res
  104. #define IFLAG (state->IFFlags >> 1)
  105. #define FFLAG (state->IFFlags & 1)
  106. #define IFFLAGS state->IFFlags
  107. #define ASSIGNINT(res) state->IFFlags = (((res) >> 6) & 3)
  108. #define ASSIGNR15INT(res) state->IFFlags = (((res) >> 26) & 3) ;
  109. #define PSR_FBITS (0xff000000L)
  110. #define PSR_SBITS (0x00ff0000L)
  111. #define PSR_XBITS (0x0000ff00L)
  112. #define PSR_CBITS (0x000000ffL)
  113. #if defined MODE32 || defined MODET
  114. #define CCBITS (0xf8000000L)
  115. #else
  116. #define CCBITS (0xf0000000L)
  117. #endif
  118. #define INTBITS (0xc0L)
  119. #if defined MODET && defined MODE32
  120. #define PCBITS (0xffffffffL)
  121. #else
  122. #define PCBITS (0xfffffffcL)
  123. #endif
  124. #define MODEBITS (0x1fL)
  125. #define R15INTBITS (3L << 26)
  126. #if defined MODET && defined MODE32
  127. #define R15PCBITS (0x03ffffffL)
  128. #else
  129. #define R15PCBITS (0x03fffffcL)
  130. #endif
  131. #define R15PCMODEBITS (0x03ffffffL)
  132. #define R15MODEBITS (0x3L)
  133. #ifdef MODE32
  134. #define PCMASK PCBITS
  135. #define PCWRAP(pc) (pc)
  136. #else
  137. #define PCMASK R15PCBITS
  138. #define PCWRAP(pc) ((pc) & R15PCBITS)
  139. #endif
  140. #define R15CCINTMODE (state->Reg[15] & (CCBITS | R15INTBITS | R15MODEBITS))
  141. #define R15INT (state->Reg[15] & R15INTBITS)
  142. #define R15INTPC (state->Reg[15] & (R15INTBITS | R15PCBITS))
  143. #define R15INTPCMODE (state->Reg[15] & (R15INTBITS | R15PCBITS | R15MODEBITS))
  144. #define R15INTMODE (state->Reg[15] & (R15INTBITS | R15MODEBITS))
  145. #define R15PC (state->Reg[15] & R15PCBITS)
  146. #define R15PCMODE (state->Reg[15] & (R15PCBITS | R15MODEBITS))
  147. #define R15MODE (state->Reg[15] & R15MODEBITS)
  148. #define ECC ((NFLAG << 31) | (ZFLAG << 30) | (CFLAG << 29) | (VFLAG << 28) | (SFLAG << 27))
  149. #define EINT (IFFLAGS << 6)
  150. #define ER15INT (IFFLAGS << 26)
  151. #define EMODE (state->Mode)
  152. //#ifdef MODET
  153. //#define CPSR (ECC | EINT | EMODE | (TFLAG << 5))
  154. //#else
  155. //#define CPSR (ECC | EINT | EMODE)
  156. //#endif
  157. #ifdef MODE32
  158. #define PATCHR15
  159. #else
  160. #define PATCHR15 state->Reg[15] = ECC | ER15INT | EMODE | R15PC
  161. #endif
  162. #define GETSPSR(bank) (ARMul_GetSPSR (state, EMODE))
  163. #define SETPSR_F(d,s) d = ((d) & ~PSR_FBITS) | ((s) & PSR_FBITS)
  164. #define SETPSR_S(d,s) d = ((d) & ~PSR_SBITS) | ((s) & PSR_SBITS)
  165. #define SETPSR_X(d,s) d = ((d) & ~PSR_XBITS) | ((s) & PSR_XBITS)
  166. #define SETPSR_C(d,s) d = ((d) & ~PSR_CBITS) | ((s) & PSR_CBITS)
  167. #define SETR15PSR(s) \
  168. do \
  169. { \
  170. if (state->Mode == USER26MODE) \
  171. { \
  172. state->Reg[15] = ((s) & CCBITS) | R15PC | ER15INT | EMODE; \
  173. ASSIGNN ((state->Reg[15] & NBIT) != 0); \
  174. ASSIGNZ ((state->Reg[15] & ZBIT) != 0); \
  175. ASSIGNC ((state->Reg[15] & CBIT) != 0); \
  176. ASSIGNV ((state->Reg[15] & VBIT) != 0); \
  177. } \
  178. else \
  179. { \
  180. state->Reg[15] = R15PC | ((s) & (CCBITS | R15INTBITS | R15MODEBITS)); \
  181. ARMul_R15Altered (state); \
  182. } \
  183. } \
  184. while (0)
  185. #define SETABORT(i, m, d) \
  186. do \
  187. { \
  188. int SETABORT_mode = (m); \
  189. \
  190. ARMul_SetSPSR (state, SETABORT_mode, ARMul_GetCPSR (state)); \
  191. ARMul_SetCPSR (state, ((ARMul_GetCPSR (state) & ~(EMODE | TBIT)) \
  192. | (i) | SETABORT_mode)); \
  193. state->Reg[14] = temp - (d); \
  194. } \
  195. while (0)
  196. #define SETABORT_SKIPBRANCH(i, m, d) \
  197. do \
  198. { \
  199. int SETABORT_mode = (m); \
  200. \
  201. ARMul_SetSPSR (state, SETABORT_mode, ARMul_GetCPSR (state)); \
  202. ARMul_SetCPSR (state, ((ARMul_GetCPSR (state) & ~(EMODE | TBIT)) \
  203. | (i) | SETABORT_mode)); \
  204. } \
  205. while (0)
  206. //#ifndef MODE32
  207. #define VECTORS 0x20
  208. #define LEGALADDR 0x03ffffff
  209. #define VECTORACCESS(address) (address < VECTORS && ARMul_MODE26BIT && state->prog32Sig)
  210. #define ADDREXCEPT(address) (address > LEGALADDR && !state->data32Sig)
  211. //#endif
  212. #define INTERNALABORT(address) \
  213. do \
  214. { \
  215. if (address < VECTORS) \
  216. state->Aborted = ARMul_DataAbortV; \
  217. else \
  218. state->Aborted = ARMul_AddrExceptnV; \
  219. } \
  220. while (0)
  221. #ifdef MODE32
  222. #define TAKEABORT ARMul_Abort (state, ARMul_DataAbortV)
  223. #else
  224. #define TAKEABORT \
  225. do \
  226. { \
  227. if (state->Aborted == ARMul_AddrExceptnV) \
  228. ARMul_Abort (state, ARMul_AddrExceptnV); \
  229. else \
  230. ARMul_Abort (state, ARMul_DataAbortV); \
  231. } \
  232. while (0)
  233. #endif
  234. #define CPTAKEABORT \
  235. do \
  236. { \
  237. if (!state->Aborted) \
  238. ARMul_Abort (state, ARMul_UndefinedInstrV); \
  239. else if (state->Aborted == ARMul_AddrExceptnV) \
  240. ARMul_Abort (state, ARMul_AddrExceptnV); \
  241. else \
  242. ARMul_Abort (state, ARMul_DataAbortV); \
  243. } \
  244. while (0);
  245. /* Different ways to start the next instruction. */
  246. #define SEQ 0
  247. #define NONSEQ 1
  248. #define PCINCEDSEQ 2
  249. #define PCINCEDNONSEQ 3
  250. #define PRIMEPIPE 4
  251. #define RESUME 8
  252. /************************************/
  253. /* shenoubang 2012-3-11 */
  254. /* for armv7 DBG DMB DSB instr*/
  255. /************************************/
  256. #define MBReqTypes_Writes 0
  257. #define MBReqTypes_All 1
  258. #define NORMALCYCLE state->NextInstr = 0
  259. #define BUSUSEDN state->NextInstr |= 1 /* The next fetch will be an N cycle. */
  260. #define BUSUSEDINCPCS \
  261. do \
  262. { \
  263. if (! state->is_v4) \
  264. { \
  265. /* A standard PC inc and an S cycle. */ \
  266. state->Reg[15] += isize; \
  267. state->NextInstr = (state->NextInstr & 0xff) | 2; \
  268. } \
  269. } \
  270. while (0)
  271. #define BUSUSEDINCPCN \
  272. do \
  273. { \
  274. if (state->is_v4) \
  275. BUSUSEDN; \
  276. else \
  277. { \
  278. /* A standard PC inc and an N cycle. */ \
  279. state->Reg[15] += isize; \
  280. state->NextInstr |= 3; \
  281. } \
  282. } \
  283. while (0)
  284. #define INCPC \
  285. do \
  286. { \
  287. /* A standard PC inc. */ \
  288. state->Reg[15] += isize; \
  289. state->NextInstr |= 2; \
  290. } \
  291. while (0)
  292. #define FLUSHPIPE state->NextInstr |= PRIMEPIPE
  293. /* Cycle based emulation. */
  294. #define OUTPUTCP(i,a,b)
  295. #define NCYCLE
  296. #define SCYCLE
  297. #define ICYCLE
  298. #define CCYCLE
  299. #define NEXTCYCLE(c)
  300. /* Macros to extract parts of instructions. */
  301. #define DESTReg (BITS (12, 15))
  302. #define LHSReg (BITS (16, 19))
  303. #define RHSReg (BITS ( 0, 3))
  304. #define DEST (state->Reg[DESTReg])
  305. #ifdef MODE32
  306. #ifdef MODET
  307. #define LHS ((LHSReg == 15) ? (state->Reg[15] & 0xFFFFFFFC) : (state->Reg[LHSReg]))
  308. #define RHS ((RHSReg == 15) ? (state->Reg[15] & 0xFFFFFFFC) : (state->Reg[RHSReg]))
  309. #else
  310. #define LHS (state->Reg[LHSReg])
  311. #define RHS (state->Reg[RHSReg])
  312. #endif
  313. #else
  314. #define LHS ((LHSReg == 15) ? R15PC : (state->Reg[LHSReg]))
  315. #define RHS ((RHSReg == 15) ? R15PC : (state->Reg[RHSReg]))
  316. #endif
  317. #define MULDESTReg (BITS (16, 19))
  318. #define MULLHSReg (BITS ( 0, 3))
  319. #define MULRHSReg (BITS ( 8, 11))
  320. #define MULACCReg (BITS (12, 15))
  321. #define DPImmRHS (ARMul_ImmedTable[BITS(0, 11)])
  322. #define DPSImmRHS temp = BITS(0,11) ; \
  323. rhs = ARMul_ImmedTable[temp] ; \
  324. if (temp > 255) /* There was a shift. */ \
  325. ASSIGNC (rhs >> 31) ;
  326. #ifdef MODE32
  327. #define DPRegRHS ((BITS (4,11) == 0) ? state->Reg[RHSReg] \
  328. : GetDPRegRHS (state, instr))
  329. #define DPSRegRHS ((BITS (4,11) == 0) ? state->Reg[RHSReg] \
  330. : GetDPSRegRHS (state, instr))
  331. #else
  332. #define DPRegRHS ((BITS (0, 11) < 15) ? state->Reg[RHSReg] \
  333. : GetDPRegRHS (state, instr))
  334. #define DPSRegRHS ((BITS (0, 11) < 15) ? state->Reg[RHSReg] \
  335. : GetDPSRegRHS (state, instr))
  336. #endif
  337. #define LSBase state->Reg[LHSReg]
  338. #define LSImmRHS (BITS(0,11))
  339. #ifdef MODE32
  340. #define LSRegRHS ((BITS (4, 11) == 0) ? state->Reg[RHSReg] \
  341. : GetLSRegRHS (state, instr))
  342. #else
  343. #define LSRegRHS ((BITS (0, 11) < 15) ? state->Reg[RHSReg] \
  344. : GetLSRegRHS (state, instr))
  345. #endif
  346. #define LSMNumRegs ((ARMword) ARMul_BitList[BITS (0, 7)] + \
  347. (ARMword) ARMul_BitList[BITS (8, 15)] )
  348. #define LSMBaseFirst ((LHSReg == 0 && BIT (0)) || \
  349. (BIT (LHSReg) && BITS (0, LHSReg - 1) == 0))
  350. #define SWAPSRC (state->Reg[RHSReg])
  351. #define LSCOff (BITS (0, 7) << 2)
  352. #define CPNum BITS (8, 11)
  353. /* Determine if access to coprocessor CP is permitted.
  354. The XScale has a register in CP15 which controls access to CP0 - CP13. */
  355. //chy 2003-09-03, new CP_ACCESS_ALLOWED
  356. /*
  357. #define CP_ACCESS_ALLOWED(STATE, CP) \
  358. ( ((CP) >= 14) \
  359. || (! (STATE)->is_XScale) \
  360. || (read_cp15_reg (15, 0, 1) & (1 << (CP))))
  361. */
  362. //#define CP_ACCESS_ALLOWED(STATE, CP) \
  363. // (((CP) >= 14) \
  364. // || (!(STATE)->is_XScale) \
  365. // || (xscale_cp15_cp_access_allowed(STATE, 15, CP)))
  366. #define CP_ACCESS_ALLOWED(STATE, CP) false // Disabled coprocessor shit /bunnei
  367. /* Macro to rotate n right by b bits. */
  368. #define ROTATER(n, b) (((n) >> (b)) | ((n) << (32 - (b))))
  369. /* Macros to store results of instructions. */
  370. #define WRITEDEST(d) \
  371. do \
  372. { \
  373. if (DESTReg == 15) \
  374. WriteR15 (state, d); \
  375. else \
  376. DEST = d; \
  377. } \
  378. while (0)
  379. #define WRITESDEST(d) \
  380. do \
  381. { \
  382. if (DESTReg == 15) \
  383. WriteSR15 (state, d); \
  384. else \
  385. { \
  386. DEST = d; \
  387. ARMul_NegZero (state, d); \
  388. } \
  389. } \
  390. while (0)
  391. #define WRITEDESTB(d) \
  392. do \
  393. { \
  394. if (DESTReg == 15){ \
  395. WriteR15Branch (state, d); \
  396. } \
  397. else{ \
  398. DEST = d; \
  399. } \
  400. } \
  401. while (0)
  402. #define BYTETOBUS(data) ((data & 0xff) | \
  403. ((data & 0xff) << 8) | \
  404. ((data & 0xff) << 16) | \
  405. ((data & 0xff) << 24))
  406. #define BUSTOBYTE(address, data) \
  407. do \
  408. { \
  409. if (state->bigendSig) \
  410. temp = (data >> (((address ^ 3) & 3) << 3)) & 0xff; \
  411. else \
  412. temp = (data >> ((address & 3) << 3)) & 0xff; \
  413. } \
  414. while (0)
  415. #define LOADMULT(instr, address, wb) LoadMult (state, instr, address, wb)
  416. #define LOADSMULT(instr, address, wb) LoadSMult (state, instr, address, wb)
  417. #define STOREMULT(instr, address, wb) StoreMult (state, instr, address, wb)
  418. #define STORESMULT(instr, address, wb) StoreSMult (state, instr, address, wb)
  419. #define POSBRANCH ((instr & 0x7fffff) << 2)
  420. #define NEGBRANCH ((0xff000000 |(instr & 0xffffff)) << 2)
  421. /* Values for Emulate. */
  422. #define STOP 0 /* stop */
  423. #define CHANGEMODE 1 /* change mode */
  424. #define ONCE 2 /* execute just one interation */
  425. #define RUN 3 /* continuous execution */
  426. /* Stuff that is shared across modes. */
  427. extern unsigned ARMul_MultTable[]; /* Number of I cycles for a mult. */
  428. extern ARMword ARMul_ImmedTable[]; /* Immediate DP LHS values. */
  429. extern char ARMul_BitList[]; /* Number of bits in a byte table. */
  430. #define EVENTLISTSIZE 1024L
  431. /* Thumb support. */
  432. typedef enum
  433. {
  434. t_undefined, /* Undefined Thumb instruction. */
  435. t_decoded, /* Instruction decoded to ARM equivalent. */
  436. t_branch /* Thumb branch (already processed). */
  437. }
  438. tdstate;
  439. /*********************************************************************************
  440. * Check all the possible undef or unpredict behavior, Some of them probably is
  441. * out-of-updated with the newer ISA.
  442. * -- Michael.Kang
  443. ********************************************************************************/
  444. #define UNDEF_WARNING ERROR_LOG(ARM11, "undefined or unpredicted behavior for arm instruction.\n");
  445. /* Macros to scrutinize instructions. */
  446. #define UNDEF_Test UNDEF_WARNING
  447. //#define UNDEF_Test
  448. //#define UNDEF_Shift UNDEF_WARNING
  449. #define UNDEF_Shift
  450. //#define UNDEF_MSRPC UNDEF_WARNING
  451. #define UNDEF_MSRPC
  452. //#define UNDEF_MRSPC UNDEF_WARNING
  453. #define UNDEF_MRSPC
  454. #define UNDEF_MULPCDest UNDEF_WARNING
  455. //#define UNDEF_MULPCDest
  456. #define UNDEF_MULDestEQOp1 UNDEF_WARNING
  457. //#define UNDEF_MULDestEQOp1
  458. //#define UNDEF_LSRBPC UNDEF_WARNING
  459. #define UNDEF_LSRBPC
  460. //#define UNDEF_LSRBaseEQOffWb UNDEF_WARNING
  461. #define UNDEF_LSRBaseEQOffWb
  462. //#define UNDEF_LSRBaseEQDestWb UNDEF_WARNING
  463. #define UNDEF_LSRBaseEQDestWb
  464. //#define UNDEF_LSRPCBaseWb UNDEF_WARNING
  465. #define UNDEF_LSRPCBaseWb
  466. //#define UNDEF_LSRPCOffWb UNDEF_WARNING
  467. #define UNDEF_LSRPCOffWb
  468. //#define UNDEF_LSMNoRegs UNDEF_WARNING
  469. #define UNDEF_LSMNoRegs
  470. //#define UNDEF_LSMPCBase UNDEF_WARNING
  471. #define UNDEF_LSMPCBase
  472. //#define UNDEF_LSMUserBankWb UNDEF_WARNING
  473. #define UNDEF_LSMUserBankWb
  474. //#define UNDEF_LSMBaseInListWb UNDEF_WARNING
  475. #define UNDEF_LSMBaseInListWb
  476. #define UNDEF_SWPPC UNDEF_WARNING
  477. //#define UNDEF_SWPPC
  478. #define UNDEF_CoProHS UNDEF_WARNING
  479. //#define UNDEF_CoProHS
  480. #define UNDEF_MCRPC UNDEF_WARNING
  481. //#define UNDEF_MCRPC
  482. //#define UNDEF_LSCPCBaseWb UNDEF_WARNING
  483. #define UNDEF_LSCPCBaseWb
  484. #define UNDEF_UndefNotBounced UNDEF_WARNING
  485. //#define UNDEF_UndefNotBounced
  486. #define UNDEF_ShortInt UNDEF_WARNING
  487. //#define UNDEF_ShortInt
  488. #define UNDEF_IllegalMode UNDEF_WARNING
  489. //#define UNDEF_IllegalMode
  490. #define UNDEF_Prog32SigChange UNDEF_WARNING
  491. //#define UNDEF_Prog32SigChange
  492. #define UNDEF_Data32SigChange UNDEF_WARNING
  493. //#define UNDEF_Data32SigChange
  494. /* Prototypes for exported functions. */
  495. extern unsigned ARMul_NthReg (ARMword, unsigned);
  496. extern int AddOverflow (ARMword, ARMword, ARMword);
  497. extern int SubOverflow (ARMword, ARMword, ARMword);
  498. /* Prototypes for exported functions. */
  499. #ifdef __cplusplus
  500. extern "C" {
  501. #endif
  502. extern ARMword ARMul_Emulate26 (ARMul_State *);
  503. extern ARMword ARMul_Emulate32 (ARMul_State *);
  504. #ifdef __cplusplus
  505. }
  506. #endif
  507. extern unsigned IntPending (ARMul_State *);
  508. extern void ARMul_CPSRAltered (ARMul_State *);
  509. extern void ARMul_R15Altered (ARMul_State *);
  510. extern ARMword ARMul_GetPC (ARMul_State *);
  511. extern ARMword ARMul_GetNextPC (ARMul_State *);
  512. extern ARMword ARMul_GetR15 (ARMul_State *);
  513. extern ARMword ARMul_GetCPSR (ARMul_State *);
  514. extern void ARMul_EnvokeEvent (ARMul_State *);
  515. extern unsigned int ARMul_Time (ARMul_State *);
  516. extern void ARMul_NegZero (ARMul_State *, ARMword);
  517. extern void ARMul_SetPC (ARMul_State *, ARMword);
  518. extern void ARMul_SetR15 (ARMul_State *, ARMword);
  519. extern void ARMul_SetCPSR (ARMul_State *, ARMword);
  520. extern ARMword ARMul_GetSPSR (ARMul_State *, ARMword);
  521. extern void ARMul_Abort26 (ARMul_State *, ARMword);
  522. extern void ARMul_Abort32 (ARMul_State *, ARMword);
  523. extern ARMword ARMul_MRC (ARMul_State *, ARMword);
  524. extern void ARMul_MRRC (ARMul_State *, ARMword, ARMword *, ARMword *);
  525. extern void ARMul_CDP (ARMul_State *, ARMword);
  526. extern void ARMul_LDC (ARMul_State *, ARMword, ARMword);
  527. extern void ARMul_STC (ARMul_State *, ARMword, ARMword);
  528. extern void ARMul_MCR (ARMul_State *, ARMword, ARMword);
  529. extern void ARMul_MCRR (ARMul_State *, ARMword, ARMword, ARMword);
  530. extern void ARMul_SetSPSR (ARMul_State *, ARMword, ARMword);
  531. extern ARMword ARMul_SwitchMode (ARMul_State *, ARMword, ARMword);
  532. extern ARMword ARMul_Align (ARMul_State *, ARMword, ARMword);
  533. extern ARMword ARMul_SwitchMode (ARMul_State *, ARMword, ARMword);
  534. extern void ARMul_MSRCpsr (ARMul_State *, ARMword, ARMword);
  535. extern void ARMul_SubOverflow (ARMul_State *, ARMword, ARMword, ARMword);
  536. extern void ARMul_AddOverflow (ARMul_State *, ARMword, ARMword, ARMword);
  537. extern void ARMul_SubCarry (ARMul_State *, ARMword, ARMword, ARMword);
  538. extern void ARMul_AddCarry (ARMul_State *, ARMword, ARMword, ARMword);
  539. extern tdstate ARMul_ThumbDecode (ARMul_State *, ARMword, ARMword, ARMword *);
  540. extern ARMword ARMul_GetReg (ARMul_State *, unsigned, unsigned);
  541. extern void ARMul_SetReg (ARMul_State *, unsigned, unsigned, ARMword);
  542. extern void ARMul_ScheduleEvent (ARMul_State *, unsigned int,
  543. unsigned (*)(ARMul_State *));
  544. /* Coprocessor support functions. */
  545. extern unsigned ARMul_CoProInit (ARMul_State *);
  546. extern void ARMul_CoProExit (ARMul_State *);
  547. extern void ARMul_CoProAttach (ARMul_State *, unsigned, ARMul_CPInits *,
  548. ARMul_CPExits *, ARMul_LDCs *, ARMul_STCs *,
  549. ARMul_MRCs *, ARMul_MCRs *, ARMul_MRRCs *, ARMul_MCRRs *,
  550. ARMul_CDPs *, ARMul_CPReads *, ARMul_CPWrites *);
  551. extern void ARMul_CoProDetach (ARMul_State *, unsigned);
  552. extern ARMword read_cp15_reg (unsigned, unsigned, unsigned);
  553. extern unsigned DSPLDC4 (ARMul_State *, unsigned, ARMword, ARMword);
  554. extern unsigned DSPMCR4 (ARMul_State *, unsigned, ARMword, ARMword);
  555. extern unsigned DSPMRC4 (ARMul_State *, unsigned, ARMword, ARMword *);
  556. extern unsigned DSPSTC4 (ARMul_State *, unsigned, ARMword, ARMword *);
  557. extern unsigned DSPCDP4 (ARMul_State *, unsigned, ARMword);
  558. extern unsigned DSPMCR5 (ARMul_State *, unsigned, ARMword, ARMword);
  559. extern unsigned DSPMRC5 (ARMul_State *, unsigned, ARMword, ARMword *);
  560. extern unsigned DSPLDC5 (ARMul_State *, unsigned, ARMword, ARMword);
  561. extern unsigned DSPSTC5 (ARMul_State *, unsigned, ARMword, ARMword *);
  562. extern unsigned DSPCDP5 (ARMul_State *, unsigned, ARMword);
  563. extern unsigned DSPMCR6 (ARMul_State *, unsigned, ARMword, ARMword);
  564. extern unsigned DSPMRC6 (ARMul_State *, unsigned, ARMword, ARMword *);
  565. extern unsigned DSPCDP6 (ARMul_State *, unsigned, ARMword);
  566. #endif