1 /* armcopro.c -- co-processor interface: ARM6 Instruction Emulator.
2 Copyright (C) 1994, 2000 Advanced RISC Machines Ltd.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 /* Dummy Co-processors. */
26 NoCoPro3R (ARMul_State * state ATTRIBUTE_UNUSED,
27 unsigned a ATTRIBUTE_UNUSED,
28 ARMword b ATTRIBUTE_UNUSED)
34 NoCoPro4R (ARMul_State * state ATTRIBUTE_UNUSED,
35 unsigned a ATTRIBUTE_UNUSED,
36 ARMword b ATTRIBUTE_UNUSED,
37 ARMword c ATTRIBUTE_UNUSED)
43 NoCoPro4W (ARMul_State * state ATTRIBUTE_UNUSED,
44 unsigned a ATTRIBUTE_UNUSED,
45 ARMword b ATTRIBUTE_UNUSED,
46 ARMword * c ATTRIBUTE_UNUSED)
51 /* The XScale Co-processors. */
53 /* Coprocessor 15: System Control. */
55 /* There are two sets of registers for copro 15.
56 One set is available when opcode_2 is 0 and
57 the other set when opcode_2 >= 1. */
58 static ARMword XScale_cp15_opcode_2_is_0_Regs[16];
59 static ARMword XScale_cp15_opcode_2_is_not_0_Regs[16];
60 /* There are also a set of breakpoint registers
61 which are accessed via CRm instead of opcode_2. */
62 static ARMword XScale_cp15_DBR1;
63 static ARMword XScale_cp15_DBCON;
64 static ARMword XScale_cp15_IBCR0;
65 static ARMword XScale_cp15_IBCR1;
68 XScale_cp15_init (ARMul_State * state ATTRIBUTE_UNUSED)
74 XScale_cp15_opcode_2_is_0_Regs[i] = 0;
75 XScale_cp15_opcode_2_is_not_0_Regs[i] = 0;
78 /* Initialise the processor ID. */
79 XScale_cp15_opcode_2_is_0_Regs[0] = 0x69052000;
81 /* Initialise the cache type. */
82 XScale_cp15_opcode_2_is_not_0_Regs[0] = 0x0B1AA1AA;
84 /* Initialise the ARM Control Register. */
85 XScale_cp15_opcode_2_is_0_Regs[1] = 0x00000078;
89 /* Check an access to a register. */
92 check_cp15_access (ARMul_State * state,
98 /* Do not allow access to these register in USER mode. */
99 if (state->Mode == USER26MODE || state->Mode == USER32MODE)
102 /* Opcode_1should be zero. */
106 /* Different register have different access requirements. */
111 /* CRm must be 0. Opcode_2 can be anything. */
117 /* CRm must be 0. Opcode_2 must be zero. */
118 if ((CRm != 0) || (opcode_2 != 0))
122 /* Access not allowed. */
126 /* Opcode_2 must be zero. CRm must be 0. */
127 if ((CRm != 0) || (opcode_2 != 0))
131 /* Permissable combinations:
144 default: return ARMul_CANT;
145 case 6: if (CRm != 5) return ARMul_CANT; break;
146 case 5: if (CRm != 2) return ARMul_CANT; break;
147 case 4: if (CRm != 10) return ARMul_CANT; break;
148 case 1: if ((CRm != 5) && (CRm != 6) && (CRm != 10)) return ARMul_CANT; break;
149 case 0: if ((CRm < 5) || (CRm > 7)) return ARMul_CANT; break;
154 /* Permissable combinations:
163 if ((CRm < 5) || (CRm > 7))
165 if (opcode_2 == 1 && CRm == 7)
169 /* Opcode_2 must be zero or one. CRm must be 1 or 2. */
170 if ( ((CRm != 0) && (CRm != 1))
171 || ((opcode_2 != 1) && (opcode_2 != 2)))
175 /* Opcode_2 must be zero or one. CRm must be 4 or 8. */
176 if ( ((CRm != 0) && (CRm != 1))
177 || ((opcode_2 != 4) && (opcode_2 != 8)))
181 /* Access not allowed. */
184 /* Access not allowed. */
187 /* Opcode_2 must be zero. CRm must be 0. */
188 if ((CRm != 0) || (opcode_2 != 0))
192 /* Opcode_2 must be 0. CRm must be 0, 3, 4, 8 or 9. */
196 if ((CRm != 0) && (CRm != 3) && (CRm != 4) && (CRm != 8) && (CRm != 9))
200 /* Opcode_2 must be zero. CRm must be 1. */
201 if ((CRm != 1) || (opcode_2 != 0))
205 /* Should never happen. */
212 /* Store a value into one of coprocessor 15's registers. */
215 write_cp15_reg (ARMul_State * state, unsigned reg, unsigned opcode_2, unsigned CRm, ARMword value)
221 case 0: /* Cache Type. */
222 /* Writes are not allowed. */
225 case 1: /* Auxillary Control. */
226 /* Only BITS (5, 4) and BITS (1, 0) can be written. */
234 XScale_cp15_opcode_2_is_not_0_Regs [reg] = value;
241 /* Writes are not allowed. */
244 case 1: /* ARM Control. */
245 /* Only BITS (13, 11), BITS (9, 7) and BITS (2, 0) can be written.
246 BITS (31, 14) and BIT (10) write as zero, BITS (6, 3) write as one. */
251 case 2: /* Translation Table Base. */
252 /* Only BITS (31, 14) can be written. */
256 case 3: /* Domain Access Control. */
257 /* All bits writable. */
260 case 5: /* Fault Status Register. */
261 /* BITS (10, 9) and BITS (7, 0) can be written. */
265 case 6: /* Fault Address Register. */
266 /* All bits writable. */
269 case 7: /* Cache Functions. */
270 case 8: /* TLB Operations. */
271 case 10: /* TLB Lock Down. */
275 case 9: /* Data Cache Lock. */
276 /* Only BIT (0) can be written. */
280 case 13: /* Process ID. */
281 /* Only BITS (31, 25) are writable. */
285 case 14: /* DBR0, DBR1, DBCON, IBCR0, IBCR1 */
286 /* All bits can be written. Which register is accessed is
287 dependent upon CRm. */
293 XScale_cp15_DBR1 = value;
296 XScale_cp15_DBCON = value;
299 XScale_cp15_IBCR0 = value;
302 XScale_cp15_IBCR1 = value;
309 case 15: /* Coprpcessor Access Register. */
310 /* Access is only valid if CRm == 1. */
314 /* Only BITS (13, 0) may be written. */
322 XScale_cp15_opcode_2_is_0_Regs [reg] = value;
328 /* Return the value in a cp15 register. */
331 read_cp15_reg (unsigned reg, unsigned opcode_2, unsigned CRm)
335 if (reg == 15 && CRm != 1)
342 case 3: return XScale_cp15_DBR1;
343 case 4: return XScale_cp15_DBCON;
344 case 8: return XScale_cp15_IBCR0;
345 case 9: return XScale_cp15_IBCR1;
351 return XScale_cp15_opcode_2_is_0_Regs [reg];
354 return XScale_cp15_opcode_2_is_not_0_Regs [reg];
360 XScale_cp15_LDC (ARMul_State * state, unsigned type, ARMword instr, ARMword data)
362 unsigned reg = BITS (12, 15);
365 result = check_cp15_access (state, reg, 0, 0, 0);
367 if (result == ARMul_DONE && type == ARMul_DATA)
368 write_cp15_reg (state, reg, 0, 0, data);
374 XScale_cp15_STC (ARMul_State * state, unsigned type, ARMword instr, ARMword * data)
376 unsigned reg = BITS (12, 15);
379 result = check_cp15_access (state, reg, 0, 0, 0);
381 if (result == ARMul_DONE && type == ARMul_DATA)
382 * data = read_cp15_reg (reg, 0, 0);
388 XScale_cp15_MRC (ARMul_State * state,
389 unsigned type ATTRIBUTE_UNUSED,
393 unsigned opcode_2 = BITS (5, 7);
394 unsigned CRm = BITS (0, 3);
395 unsigned reg = BITS (16, 19);
398 result = check_cp15_access (state, reg, CRm, BITS (21, 23), opcode_2);
400 if (result == ARMul_DONE)
401 * value = read_cp15_reg (reg, opcode_2, CRm);
407 XScale_cp15_MCR (ARMul_State * state,
408 unsigned type ATTRIBUTE_UNUSED,
412 unsigned opcode_2 = BITS (5, 7);
413 unsigned CRm = BITS (0, 3);
414 unsigned reg = BITS (16, 19);
417 result = check_cp15_access (state, reg, CRm, BITS (21, 23), opcode_2);
419 if (result == ARMul_DONE)
420 write_cp15_reg (state, reg, opcode_2, CRm, value);
426 XScale_cp15_read_reg (ARMul_State * state ATTRIBUTE_UNUSED,
430 /* FIXME: Not sure what to do about the alternative register set
431 here. For now default to just accessing CRm == 0 registers. */
432 * value = read_cp15_reg (reg, 0, 0);
438 XScale_cp15_write_reg (ARMul_State * state ATTRIBUTE_UNUSED,
442 /* FIXME: Not sure what to do about the alternative register set
443 here. For now default to just accessing CRm == 0 registers. */
444 write_cp15_reg (state, reg, 0, 0, value);
449 /* Coprocessor 13: Interrupt Controller and Bus Controller. */
451 /* There are two sets of registers for copro 13.
452 One set (of three registers) is available when CRm is 0
453 and the other set (of six registers) when CRm is 1. */
455 static ARMword XScale_cp13_CR0_Regs[16];
456 static ARMword XScale_cp13_CR1_Regs[16];
459 XScale_cp13_init (ARMul_State * state ATTRIBUTE_UNUSED)
465 XScale_cp13_CR0_Regs[i] = 0;
466 XScale_cp13_CR1_Regs[i] = 0;
470 /* Check an access to a register. */
473 check_cp13_access (ARMul_State * state,
479 /* Do not allow access to these register in USER mode. */
480 if (state->Mode == USER26MODE || state->Mode == USER32MODE)
483 /* The opcodes should be zero. */
484 if ((opcode_1 != 0) || (opcode_2 != 0))
487 /* Do not allow access to these register if bit 13 of coprocessor
488 15's register 15 is zero. */
489 if ((XScale_cp15_opcode_2_is_0_Regs[15] & (1 << 13)) == 0)
492 /* Registers 0, 4 and 8 are defined when CRm == 0.
493 Registers 0, 4, 5, 6, 7, 8 are defined when CRm == 1.
494 For all other CRm values undefined behaviour results. */
497 if (reg == 0 || reg == 4 || reg == 8)
502 if (reg == 0 || (reg >= 4 && reg <= 8))
509 /* Store a value into one of coprocessor 13's registers. */
512 write_cp13_reg (unsigned reg, unsigned CRm, ARMword value)
520 /* Only BITS (3:0) can be written. */
525 /* No bits may be written. */
529 /* Only BITS (1:0) can be written. */
534 /* Should not happen. Ignore any writes to unimplemented registers. */
538 XScale_cp13_CR0_Regs [reg] = value;
545 /* Only BITS (30:28) and BITS (3:0) can be written.
546 BIT(31) is write ignored. */
548 value |= XScale_cp13_CR1_Regs[0] & (1UL << 31);
555 /* No bits can be written. */
559 /* Only BITS (7:0) can be written. */
564 /* Should not happen. Ignore any writes to unimplemented registers. */
568 XScale_cp13_CR1_Regs [reg] = value;
572 /* Should not happen. */
579 /* Return the value in a cp13 register. */
582 read_cp13_reg (unsigned reg, unsigned CRm)
585 return XScale_cp13_CR0_Regs [reg];
587 return XScale_cp13_CR1_Regs [reg];
593 XScale_cp13_LDC (ARMul_State * state, unsigned type, ARMword instr, ARMword data)
595 unsigned reg = BITS (12, 15);
598 result = check_cp13_access (state, reg, 0, 0, 0);
600 if (result == ARMul_DONE && type == ARMul_DATA)
601 write_cp13_reg (reg, 0, data);
607 XScale_cp13_STC (ARMul_State * state, unsigned type, ARMword instr, ARMword * data)
609 unsigned reg = BITS (12, 15);
612 result = check_cp13_access (state, reg, 0, 0, 0);
614 if (result == ARMul_DONE && type == ARMul_DATA)
615 * data = read_cp13_reg (reg, 0);
621 XScale_cp13_MRC (ARMul_State * state,
622 unsigned type ATTRIBUTE_UNUSED,
626 unsigned CRm = BITS (0, 3);
627 unsigned reg = BITS (16, 19);
630 result = check_cp13_access (state, reg, CRm, BITS (21, 23), BITS (5, 7));
632 if (result == ARMul_DONE)
633 * value = read_cp13_reg (reg, CRm);
639 XScale_cp13_MCR (ARMul_State * state,
640 unsigned type ATTRIBUTE_UNUSED,
644 unsigned CRm = BITS (0, 3);
645 unsigned reg = BITS (16, 19);
648 result = check_cp13_access (state, reg, CRm, BITS (21, 23), BITS (5, 7));
650 if (result == ARMul_DONE)
651 write_cp13_reg (reg, CRm, value);
659 ARMul_State * state ATTRIBUTE_UNUSED,
664 /* FIXME: Not sure what to do about the alternative register set
665 here. For now default to just accessing CRm == 0 registers. */
666 * value = read_cp13_reg (reg, 0);
672 XScale_cp13_write_reg
674 ARMul_State * state ATTRIBUTE_UNUSED,
679 /* FIXME: Not sure what to do about the alternative register set
680 here. For now default to just accessing CRm == 0 registers. */
681 write_cp13_reg (reg, 0, value);
686 /* Coprocessor 14: Performance Monitoring, Clock and Power management,
689 static ARMword XScale_cp14_Regs[16];
692 XScale_cp14_init (ARMul_State * state ATTRIBUTE_UNUSED)
697 XScale_cp14_Regs[i] = 0;
700 /* Check an access to a register. */
703 check_cp14_access (ARMul_State * state,
709 /* Not allowed to access these register in USER mode. */
710 if (state->Mode == USER26MODE || state->Mode == USER32MODE)
713 /* CRm should be zero. */
717 /* OPcodes should be zero. */
718 if (opcode1 != 0 || opcode2 != 0)
721 /* Accessing registers 4 or 5 has unpredicatable results. */
722 if (reg >= 4 && reg <= 5)
728 /* Store a value into one of coprocessor 14's registers. */
731 write_cp14_reg (unsigned reg, ARMword value)
736 /* Only BITS (27:12), BITS (10:8) and BITS (6:0) can be written. */
742 /* We should not normally reach this code. The debugger interface
743 can bypass the normal checks though, so it could happen. */
747 case 6: /* CCLKCFG */
748 /* Only BITS (3:0) can be written. */
752 case 7: /* PWRMODE */
753 /* Although BITS (1:0) can be written with non-zero values, this would
754 have the side effect of putting the processor to sleep. Thus in
755 order for the register to be read again, it would have to go into
756 ACTIVE mode, which means that any read will see these bits as zero.
758 Rather than trying to implement complex reset-to-zero-upon-read logic
759 we just override the write value with zero. */
764 /* Only BITS (31:30), BITS (23:22), BITS (20:16) and BITS (5:0) can
770 /* No writes are permitted. */
774 case 14: /* TXRXCTRL */
775 /* Only BITS (31:30) can be written. */
780 /* All bits can be written. */
784 XScale_cp14_Regs [reg] = value;
787 /* Return the value in a cp14 register. Not a static function since
788 it is used by the code to emulate the BKPT instruction in armemu.c. */
791 read_cp14_reg (unsigned reg)
793 return XScale_cp14_Regs [reg];
797 XScale_cp14_LDC (ARMul_State * state, unsigned type, ARMword instr, ARMword data)
799 unsigned reg = BITS (12, 15);
802 result = check_cp14_access (state, reg, 0, 0, 0);
804 if (result == ARMul_DONE && type == ARMul_DATA)
805 write_cp14_reg (reg, data);
811 XScale_cp14_STC (ARMul_State * state, unsigned type, ARMword instr, ARMword * data)
813 unsigned reg = BITS (12, 15);
816 result = check_cp14_access (state, reg, 0, 0, 0);
818 if (result == ARMul_DONE && type == ARMul_DATA)
819 * data = read_cp14_reg (reg);
828 unsigned type ATTRIBUTE_UNUSED,
833 unsigned reg = BITS (16, 19);
836 result = check_cp14_access (state, reg, BITS (0, 3), BITS (21, 23), BITS (5, 7));
838 if (result == ARMul_DONE)
839 * value = read_cp14_reg (reg);
848 unsigned type ATTRIBUTE_UNUSED,
853 unsigned reg = BITS (16, 19);
856 result = check_cp14_access (state, reg, BITS (0, 3), BITS (21, 23), BITS (5, 7));
858 if (result == ARMul_DONE)
859 write_cp14_reg (reg, value);
867 ARMul_State * state ATTRIBUTE_UNUSED,
872 * value = read_cp14_reg (reg);
878 XScale_cp14_write_reg
880 ARMul_State * state ATTRIBUTE_UNUSED,
885 write_cp14_reg (reg, value);
890 /* Here's ARMulator's MMU definition. A few things to note:
891 1) It has eight registers, but only two are defined.
892 2) You can only access its registers with MCR and MRC.
893 3) MMU Register 0 (ID) returns 0x41440110
894 4) Register 1 only has 4 bits defined. Bits 0 to 3 are unused, bit 4
895 controls 32/26 bit program space, bit 5 controls 32/26 bit data space,
896 bit 6 controls late abort timimg and bit 7 controls big/little endian. */
898 static ARMword MMUReg[8];
901 MMUInit (ARMul_State * state)
903 MMUReg[1] = state->prog32Sig << 4 |
904 state->data32Sig << 5 | state->lateabtSig << 6 | state->bigendSig << 7;
906 ARMul_ConsolePrint (state, ", MMU present");
912 MMUMRC (ARMul_State * state ATTRIBUTE_UNUSED,
913 unsigned type ATTRIBUTE_UNUSED,
917 int reg = BITS (16, 19) & 7;
922 *value = MMUReg[reg];
928 MMUMCR (ARMul_State * state,
929 unsigned type ATTRIBUTE_UNUSED,
933 int reg = BITS (16, 19) & 7;
941 p = state->prog32Sig;
942 d = state->data32Sig;
943 l = state->lateabtSig;
944 b = state->bigendSig;
946 state->prog32Sig = value >> 4 & 1;
947 state->data32Sig = value >> 5 & 1;
948 state->lateabtSig = value >> 6 & 1;
949 state->bigendSig = value >> 7 & 1;
951 if ( p != state->prog32Sig
952 || d != state->data32Sig
953 || l != state->lateabtSig
954 || b != state->bigendSig)
955 /* Force ARMulator to notice these now. */
956 state->Emulate = CHANGEMODE;
963 MMURead (ARMul_State * state ATTRIBUTE_UNUSED, unsigned reg, ARMword * value)
968 *value = MMUReg[reg];
974 MMUWrite (ARMul_State * state, unsigned reg, ARMword value)
983 p = state->prog32Sig;
984 d = state->data32Sig;
985 l = state->lateabtSig;
986 b = state->bigendSig;
988 state->prog32Sig = value >> 4 & 1;
989 state->data32Sig = value >> 5 & 1;
990 state->lateabtSig = value >> 6 & 1;
991 state->bigendSig = value >> 7 & 1;
993 if ( p != state->prog32Sig
994 || d != state->data32Sig
995 || l != state->lateabtSig
996 || b != state->bigendSig)
997 /* Force ARMulator to notice these now. */
998 state->Emulate = CHANGEMODE;
1005 /* What follows is the Validation Suite Coprocessor. It uses two
1006 co-processor numbers (4 and 5) and has the follwing functionality.
1007 Sixteen registers. Both co-processor nuimbers can be used in an MCR
1008 and MRC to access these registers. CP 4 can LDC and STC to and from
1009 the registers. CP 4 and CP 5 CDP 0 will busy wait for the number of
1010 cycles specified by a CP register. CP 5 CDP 1 issues a FIQ after a
1011 number of cycles (specified in a CP register), CDP 2 issues an IRQW
1012 in the same way, CDP 3 and 4 turn of the FIQ and IRQ source, and CDP 5
1013 stores a 32 bit time value in a CP register (actually it's the total
1014 number of N, S, I, C and F cyles). */
1016 static ARMword ValReg[16];
1019 ValLDC (ARMul_State * state ATTRIBUTE_UNUSED,
1024 static unsigned words;
1026 if (type != ARMul_DATA)
1030 ValReg[BITS (12, 15)] = data;
1033 /* It's a long access, get two words. */
1042 ValSTC (ARMul_State * state ATTRIBUTE_UNUSED,
1047 static unsigned words;
1049 if (type != ARMul_DATA)
1053 * data = ValReg[BITS (12, 15)];
1056 /* It's a long access, get two words. */
1065 ValMRC (ARMul_State * state ATTRIBUTE_UNUSED,
1066 unsigned type ATTRIBUTE_UNUSED,
1070 *value = ValReg[BITS (16, 19)];
1076 ValMCR (ARMul_State * state ATTRIBUTE_UNUSED,
1077 unsigned type ATTRIBUTE_UNUSED,
1081 ValReg[BITS (16, 19)] = value;
1087 ValCDP (ARMul_State * state, unsigned type, ARMword instr)
1089 static unsigned long finish = 0;
1091 if (BITS (20, 23) != 0)
1094 if (type == ARMul_FIRST)
1098 howlong = ValReg[BITS (0, 3)];
1100 /* First cycle of a busy wait. */
1101 finish = ARMul_Time (state) + howlong;
1103 return howlong == 0 ? ARMul_DONE : ARMul_BUSY;
1105 else if (type == ARMul_BUSY)
1107 if (ARMul_Time (state) >= finish)
1117 DoAFIQ (ARMul_State * state)
1119 state->NfiqSig = LOW;
1125 DoAIRQ (ARMul_State * state)
1127 state->NirqSig = LOW;
1133 IntCDP (ARMul_State * state, unsigned type, ARMword instr)
1135 static unsigned long finish;
1138 howlong = ValReg[BITS (0, 3)];
1140 switch ((int) BITS (20, 23))
1143 if (type == ARMul_FIRST)
1145 /* First cycle of a busy wait. */
1146 finish = ARMul_Time (state) + howlong;
1148 return howlong == 0 ? ARMul_DONE : ARMul_BUSY;
1150 else if (type == ARMul_BUSY)
1152 if (ARMul_Time (state) >= finish)
1161 ARMul_Abort (state, ARMul_FIQV);
1163 ARMul_ScheduleEvent (state, howlong, DoAFIQ);
1168 ARMul_Abort (state, ARMul_IRQV);
1170 ARMul_ScheduleEvent (state, howlong, DoAIRQ);
1174 state->NfiqSig = HIGH;
1179 state->NirqSig = HIGH;
1184 ValReg[BITS (0, 3)] = ARMul_Time (state);
1191 /***************************************************************************\
1192 * Install co-processor instruction handlers in this routine *
1193 \***************************************************************************/
1196 ARMul_CoProInit (ARMul_State * state)
1200 /* Initialise tham all first. */
1201 for (i = 0; i < 16; i++)
1202 ARMul_CoProDetach (state, i);
1204 /* Install CoPro Instruction handlers here.
1206 ARMul_CoProAttach (state, CP Number,
1207 Init routine, Exit routine
1208 LDC routine, STC routine,
1209 MRC routine, MCR routine,
1211 Read Reg routine, Write Reg routine). */
1212 ARMul_CoProAttach (state, 4, NULL, NULL,
1213 ValLDC, ValSTC, ValMRC, ValMCR, ValCDP, NULL, NULL);
1215 ARMul_CoProAttach (state, 5, NULL, NULL,
1216 NULL, NULL, ValMRC, ValMCR, IntCDP, NULL, NULL);
1218 ARMul_CoProAttach (state, 15, MMUInit, NULL,
1219 NULL, NULL, MMUMRC, MMUMCR, NULL, MMURead, MMUWrite);
1221 ARMul_CoProAttach (state, 13, XScale_cp13_init, NULL,
1222 XScale_cp13_LDC, XScale_cp13_STC, XScale_cp13_MRC,
1223 XScale_cp13_MCR, NULL, XScale_cp13_read_reg,
1224 XScale_cp13_write_reg);
1226 ARMul_CoProAttach (state, 14, XScale_cp14_init, NULL,
1227 XScale_cp14_LDC, XScale_cp14_STC, XScale_cp14_MRC,
1228 XScale_cp14_MCR, NULL, XScale_cp14_read_reg,
1229 XScale_cp14_write_reg);
1231 ARMul_CoProAttach (state, 15, XScale_cp15_init, NULL,
1232 NULL, NULL, XScale_cp15_MRC, XScale_cp15_MCR,
1233 NULL, XScale_cp15_read_reg, XScale_cp15_write_reg);
1235 /* No handlers below here. */
1237 /* Call all the initialisation routines. */
1238 for (i = 0; i < 16; i++)
1239 if (state->CPInit[i])
1240 (state->CPInit[i]) (state);
1245 /***************************************************************************\
1246 * Install co-processor finalisation routines in this routine *
1247 \***************************************************************************/
1250 ARMul_CoProExit (ARMul_State * state)
1252 register unsigned i;
1254 for (i = 0; i < 16; i++)
1255 if (state->CPExit[i])
1256 (state->CPExit[i]) (state);
1258 for (i = 0; i < 16; i++) /* Detach all handlers. */
1259 ARMul_CoProDetach (state, i);
1262 /***************************************************************************\
1263 * Routines to hook Co-processors into ARMulator *
1264 \***************************************************************************/
1267 ARMul_CoProAttach (ARMul_State * state,
1269 ARMul_CPInits * init,
1270 ARMul_CPExits * exit,
1276 ARMul_CPReads * read,
1277 ARMul_CPWrites * write)
1280 state->CPInit[number] = init;
1282 state->CPExit[number] = exit;
1284 state->LDC[number] = ldc;
1286 state->STC[number] = stc;
1288 state->MRC[number] = mrc;
1290 state->MCR[number] = mcr;
1292 state->CDP[number] = cdp;
1294 state->CPRead[number] = read;
1296 state->CPWrite[number] = write;
1300 ARMul_CoProDetach (ARMul_State * state, unsigned number)
1302 ARMul_CoProAttach (state, number, NULL, NULL,
1303 NoCoPro4R, NoCoPro4W, NoCoPro4W, NoCoPro4R,
1304 NoCoPro3R, NULL, NULL);
1306 state->CPInit[number] = NULL;
1307 state->CPExit[number] = NULL;
1308 state->CPRead[number] = NULL;
1309 state->CPWrite[number] = NULL;