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. */
22 /* Dummy Co-processors. */
25 NoCoPro3R (ARMul_State * state ATTRIBUTE_UNUSED,
26 unsigned a ATTRIBUTE_UNUSED,
27 ARMword b ATTRIBUTE_UNUSED)
33 NoCoPro4R (ARMul_State * state ATTRIBUTE_UNUSED,
34 unsigned a ATTRIBUTE_UNUSED,
35 ARMword b ATTRIBUTE_UNUSED,
36 ARMword c ATTRIBUTE_UNUSED)
42 NoCoPro4W (ARMul_State * state ATTRIBUTE_UNUSED,
43 unsigned a ATTRIBUTE_UNUSED,
44 ARMword b ATTRIBUTE_UNUSED,
45 ARMword * c ATTRIBUTE_UNUSED)
50 /* The XScale Co-processors. */
52 /* Coprocessor 15: System Control. */
54 /* There are two sets of registers for copro 15.
55 One set is available when opcode_2 is 0 and
56 the other set when opcode_2 >= 1. */
57 static ARMword XScale_cp15_opcode_2_is_0_Regs[16];
58 static ARMword XScale_cp15_opcode_2_is_not_0_Regs[16];
59 /* There are also a set of breakpoint registers
60 which are accessed via CRm instead of opcode_2. */
61 static ARMword XScale_cp15_DBR1;
62 static ARMword XScale_cp15_DBCON;
63 static ARMword XScale_cp15_IBCR0;
64 static ARMword XScale_cp15_IBCR1;
67 XScale_cp15_init (ARMul_State * state ATTRIBUTE_UNUSED)
73 XScale_cp15_opcode_2_is_0_Regs[i] = 0;
74 XScale_cp15_opcode_2_is_not_0_Regs[i] = 0;
77 /* Initialise the processor ID. */
78 XScale_cp15_opcode_2_is_0_Regs[0] = 0x69052000;
80 /* Initialise the cache type. */
81 XScale_cp15_opcode_2_is_not_0_Regs[0] = 0x0B1AA1AA;
83 /* Initialise the ARM Control Register. */
84 XScale_cp15_opcode_2_is_0_Regs[1] = 0x00000078;
88 /* Check an access to a register. */
91 check_cp15_access (ARMul_State * state,
97 /* Do not allow access to these register in USER mode. */
98 if (state->Mode == USER26MODE || state->Mode == USER32MODE)
101 /* Opcode_1should be zero. */
105 /* Different register have different access requirements. */
110 /* CRm must be 0. Opcode_2 can be anything. */
116 /* CRm must be 0. Opcode_2 must be zero. */
117 if ((CRm != 0) || (opcode_2 != 0))
121 /* Access not allowed. */
125 /* Opcode_2 must be zero. CRm must be 0. */
126 if ((CRm != 0) || (opcode_2 != 0))
130 /* Permissable combinations:
143 default: return ARMul_CANT;
144 case 6: if (CRm != 5) return ARMul_CANT; break;
145 case 5: if (CRm != 2) return ARMul_CANT; break;
146 case 4: if (CRm != 10) return ARMul_CANT; break;
147 case 1: if ((CRm != 5) && (CRm != 6) && (CRm != 10)) return ARMul_CANT; break;
148 case 0: if ((CRm < 5) || (CRm > 7)) return ARMul_CANT; break;
153 /* Permissable combinations:
162 if ((CRm < 5) || (CRm > 7))
164 if (opcode_2 == 1 && CRm == 7)
168 /* Opcode_2 must be zero or one. CRm must be 1 or 2. */
169 if ( ((CRm != 0) && (CRm != 1))
170 || ((opcode_2 != 1) && (opcode_2 != 2)))
174 /* Opcode_2 must be zero or one. CRm must be 4 or 8. */
175 if ( ((CRm != 0) && (CRm != 1))
176 || ((opcode_2 != 4) && (opcode_2 != 8)))
180 /* Access not allowed. */
183 /* Access not allowed. */
186 /* Opcode_2 must be zero. CRm must be 0. */
187 if ((CRm != 0) || (opcode_2 != 0))
191 /* Opcode_2 must be 0. CRm must be 0, 3, 4, 8 or 9. */
195 if ((CRm != 0) && (CRm != 3) && (CRm != 4) && (CRm != 8) && (CRm != 9))
199 /* Opcode_2 must be zero. CRm must be 1. */
200 if ((CRm != 1) || (opcode_2 != 0))
204 /* Should never happen. */
211 /* Store a value into one of coprocessor 15's registers. */
214 write_cp15_reg (unsigned reg, unsigned opcode_2, unsigned CRm, ARMword value)
220 case 0: /* Cache Type. */
221 /* Writes are not allowed. */
224 case 1: /* Auxillary Control. */
225 /* Only BITS (5, 4) and BITS (1, 0) can be written. */
233 XScale_cp15_opcode_2_is_not_0_Regs [reg] = value;
240 /* Writes are not allowed. */
243 case 1: /* ARM Control. */
244 /* Only BITS (13, 11), BITS (9, 7) and BITS (2, 0) can be written.
245 BITS (31, 14) and BIT (10) write as zero, BITS (6, 3) write as one. */
250 case 2: /* Translation Table Base. */
251 /* Only BITS (31, 14) can be written. */
255 case 3: /* Domain Access Control. */
256 /* All bits writable. */
259 case 5: /* Fault Status Register. */
260 /* BITS (10, 9) and BITS (7, 0) can be written. */
264 case 6: /* Fault Address Register. */
265 /* All bits writable. */
268 case 7: /* Cache Functions. */
269 case 8: /* TLB Operations. */
270 case 10: /* TLB Lock Down. */
274 case 9: /* Data Cache Lock. */
275 /* Only BIT (0) can be written. */
279 case 13: /* Process ID. */
280 /* Only BITS (31, 25) are writable. */
284 case 14: /* DBR0, DBR1, DBCON, IBCR0, IBCR1 */
285 /* All bits can be written. Which register is accessed is
286 dependent upon CRm. */
292 XScale_cp15_DBR1 = value;
295 XScale_cp15_DBCON = value;
298 XScale_cp15_IBCR0 = value;
301 XScale_cp15_IBCR1 = value;
308 case 15: /* Coprpcessor Access Register. */
309 /* Access is only valid if CRm == 1. */
313 /* Only BITS (13, 0) may be written. */
321 XScale_cp15_opcode_2_is_0_Regs [reg] = value;
327 /* Return the value in a cp13 register. */
330 read_cp15_reg (unsigned reg, unsigned opcode_2, unsigned CRm)
334 if (reg == 15 && CRm != 1)
341 case 3: return XScale_cp15_DBR1;
342 case 4: return XScale_cp15_DBCON;
343 case 8: return XScale_cp15_IBCR0;
344 case 9: return XScale_cp15_IBCR1;
350 return XScale_cp15_opcode_2_is_0_Regs [reg];
353 return XScale_cp15_opcode_2_is_not_0_Regs [reg];
359 XScale_cp15_LDC (ARMul_State * state, unsigned type, ARMword instr, ARMword data)
361 unsigned reg = BITS (12, 15);
364 result = check_cp15_access (state, reg, 0, 0, 0);
366 if (result == ARMul_DONE && type == ARMul_DATA)
367 write_cp15_reg (reg, 0, 0, data);
373 XScale_cp15_STC (ARMul_State * state, unsigned type, ARMword instr, ARMword * data)
375 unsigned reg = BITS (12, 15);
378 result = check_cp15_access (state, reg, 0, 0, 0);
380 if (result == ARMul_DONE && type == ARMul_DATA)
381 * data = read_cp15_reg (reg, 0, 0);
387 XScale_cp15_MRC (ARMul_State * state,
388 unsigned type ATTRIBUTE_UNUSED,
392 unsigned opcode_2 = BITS (5, 7);
393 unsigned CRm = BITS (0, 3);
394 unsigned reg = BITS (16, 19);
397 result = check_cp15_access (state, reg, CRm, BITS (21, 23), opcode_2);
399 if (result == ARMul_DONE)
400 * value = read_cp15_reg (reg, opcode_2, CRm);
406 XScale_cp15_MCR (ARMul_State * state,
407 unsigned type ATTRIBUTE_UNUSED,
411 unsigned opcode_2 = BITS (5, 7);
412 unsigned CRm = BITS (0, 3);
413 unsigned reg = BITS (16, 19);
416 result = check_cp15_access (state, reg, CRm, BITS (21, 23), opcode_2);
418 if (result == ARMul_DONE)
419 write_cp15_reg (reg, opcode_2, CRm, value);
425 XScale_cp15_read_reg (ARMul_State * state ATTRIBUTE_UNUSED,
429 /* FIXME: Not sure what to do about the alternative register set
430 here. For now default to just accessing CRm == 0 registers. */
431 * value = read_cp15_reg (reg, 0, 0);
437 XScale_cp15_write_reg (ARMul_State * state ATTRIBUTE_UNUSED,
441 /* FIXME: Not sure what to do about the alternative register set
442 here. For now default to just accessing CRm == 0 registers. */
443 write_cp15_reg (reg, 0, 0, value);
448 /* Coprocessor 13: Interrupt Controller and Bus Controller. */
450 /* There are two sets of registers for copro 13.
451 One set (of three registers) is available when CRm is 0
452 and the other set (of six registers) when CRm is 1. */
454 static ARMword XScale_cp13_CR0_Regs[16];
455 static ARMword XScale_cp13_CR1_Regs[16];
458 XScale_cp13_init (ARMul_State * state ATTRIBUTE_UNUSED)
464 XScale_cp13_CR0_Regs[i] = 0;
465 XScale_cp13_CR1_Regs[i] = 0;
469 /* Check an access to a register. */
472 check_cp13_access (ARMul_State * state,
478 /* Do not allow access to these register in USER mode. */
479 if (state->Mode == USER26MODE || state->Mode == USER32MODE)
482 /* The opcodes should be zero. */
483 if ((opcode_1 != 0) || (opcode_2 != 0))
486 /* Do not allow access to these register if bit 13 of coprocessor
487 15's register 15 is zero. */
488 if ((XScale_cp15_opcode_2_is_0_Regs[15] & (1 << 13)) == 0)
491 /* Registers 0, 4 and 8 are defined when CRm == 0.
492 Registers 0, 4, 5, 6, 7, 8 are defined when CRm == 1.
493 For all other CRm values undefined behaviour results. */
496 if (reg == 0 || reg == 4 || reg == 8)
501 if (reg == 0 || (reg >= 4 && reg <= 8))
508 /* Store a value into one of coprocessor 13's registers. */
511 write_cp13_reg (unsigned reg, unsigned CRm, ARMword value)
519 /* Only BITS (3:0) can be written. */
524 /* No bits may be written. */
528 /* Only BITS (1:0) can be written. */
533 /* Should not happen. Ignore any writes to unimplemented registers. */
537 XScale_cp13_CR0_Regs [reg] = value;
544 /* Only BITS (30:28) and BITS (3:0) can be written.
545 BIT(31) is write ignored. */
547 value |= XScale_cp13_CR1_Regs[0] & (1UL << 31);
554 /* No bits can be written. */
558 /* Only BITS (7:0) can be written. */
563 /* Should not happen. Ignore any writes to unimplemented registers. */
567 XScale_cp13_CR1_Regs [reg] = value;
571 /* Should not happen. */
578 /* Return the value in a cp13 register. */
581 read_cp13_reg (unsigned reg, unsigned CRm)
584 return XScale_cp13_CR0_Regs [reg];
586 return XScale_cp13_CR1_Regs [reg];
592 XScale_cp13_LDC (ARMul_State * state, unsigned type, ARMword instr, ARMword data)
594 unsigned reg = BITS (12, 15);
597 result = check_cp13_access (state, reg, 0, 0, 0);
599 if (result == ARMul_DONE && type == ARMul_DATA)
600 write_cp13_reg (reg, 0, data);
606 XScale_cp13_STC (ARMul_State * state, unsigned type, ARMword instr, ARMword * data)
608 unsigned reg = BITS (12, 15);
611 result = check_cp13_access (state, reg, 0, 0, 0);
613 if (result == ARMul_DONE && type == ARMul_DATA)
614 * data = read_cp13_reg (reg, 0);
620 XScale_cp13_MRC (ARMul_State * state,
621 unsigned type ATTRIBUTE_UNUSED,
625 unsigned CRm = BITS (0, 3);
626 unsigned reg = BITS (16, 19);
629 result = check_cp13_access (state, reg, CRm, BITS (21, 23), BITS (5, 7));
631 if (result == ARMul_DONE)
632 * value = read_cp13_reg (reg, CRm);
638 XScale_cp13_MCR (ARMul_State * state,
639 unsigned type ATTRIBUTE_UNUSED,
643 unsigned CRm = BITS (0, 3);
644 unsigned reg = BITS (16, 19);
647 result = check_cp13_access (state, reg, CRm, BITS (21, 23), BITS (5, 7));
649 if (result == ARMul_DONE)
650 write_cp13_reg (reg, CRm, value);
658 ARMul_State * state ATTRIBUTE_UNUSED,
663 /* FIXME: Not sure what to do about the alternative register set
664 here. For now default to just accessing CRm == 0 registers. */
665 * value = read_cp13_reg (reg, 0);
671 XScale_cp13_write_reg
673 ARMul_State * state ATTRIBUTE_UNUSED,
678 /* FIXME: Not sure what to do about the alternative register set
679 here. For now default to just accessing CRm == 0 registers. */
680 write_cp13_reg (reg, 0, value);
685 /* Coprocessor 14: Performance Monitoring, Clock and Power management,
688 static ARMword XScale_cp14_Regs[16];
691 XScale_cp14_init (ARMul_State * state ATTRIBUTE_UNUSED)
696 XScale_cp14_Regs[i] = 0;
699 /* Check an access to a register. */
702 check_cp14_access (ARMul_State * state,
708 /* Not allowed to access these register in USER mode. */
709 if (state->Mode == USER26MODE || state->Mode == USER32MODE)
712 /* CRm should be zero. */
716 /* OPcodes should be zero. */
717 if (opcode1 != 0 || opcode2 != 0)
720 /* Accessing registers 4 or 5 has unpredicatable results. */
721 if (reg >= 4 && reg <= 5)
727 /* Store a value into one of coprocessor 14's registers. */
730 write_cp14_reg (unsigned reg, ARMword value)
735 /* Only BITS (27:12), BITS (10:8) and BITS (6:0) can be written. */
741 /* We should not normally reach this code. The debugger interface
742 can bypass the normal checks though, so it could happen. */
746 case 6: /* CCLKCFG */
747 /* Only BITS (3:0) can be written. */
751 case 7: /* PWRMODE */
752 /* Although BITS (1:0) can be written with non-zero values, this would
753 have the side effect of putting the processor to sleep. Thus in
754 order for the register to be read again, it would have to go into
755 ACTIVE mode, which means that any read will see these bits as zero.
757 Rather than trying to implement complex reset-to-zero-upon-read logic
758 we just override the write value with zero. */
763 /* Only BITS (31:30), BITS (23:22), BITS (20:16) and BITS (5:0) can
769 /* No writes are permitted. */
773 case 14: /* TXRXCTRL */
774 /* Only BITS (31:30) can be written. */
779 /* All bits can be written. */
783 XScale_cp14_Regs [reg] = value;
786 /* Return the value in a cp14 register. Not a static function since
787 it is used by the code to emulate the BKPT instruction in armemu.c. */
790 read_cp14_reg (unsigned reg)
792 return XScale_cp14_Regs [reg];
796 XScale_cp14_LDC (ARMul_State * state, unsigned type, ARMword instr, ARMword data)
798 unsigned reg = BITS (12, 15);
801 result = check_cp14_access (state, reg, 0, 0, 0);
803 if (result == ARMul_DONE && type == ARMul_DATA)
804 write_cp14_reg (reg, data);
810 XScale_cp14_STC (ARMul_State * state, unsigned type, ARMword instr, ARMword * data)
812 unsigned reg = BITS (12, 15);
815 result = check_cp14_access (state, reg, 0, 0, 0);
817 if (result == ARMul_DONE && type == ARMul_DATA)
818 * data = read_cp14_reg (reg);
827 unsigned type ATTRIBUTE_UNUSED,
832 unsigned reg = BITS (16, 19);
835 result = check_cp14_access (state, reg, BITS (0, 3), BITS (21, 23), BITS (5, 7));
837 if (result == ARMul_DONE)
838 * value = read_cp14_reg (reg);
847 unsigned type ATTRIBUTE_UNUSED,
852 unsigned reg = BITS (16, 19);
855 result = check_cp14_access (state, reg, BITS (0, 3), BITS (21, 23), BITS (5, 7));
857 if (result == ARMul_DONE)
858 write_cp14_reg (reg, value);
866 ARMul_State * state ATTRIBUTE_UNUSED,
871 * value = read_cp14_reg (reg);
877 XScale_cp14_write_reg
879 ARMul_State * state ATTRIBUTE_UNUSED,
884 write_cp14_reg (reg, value);
889 /* Here's ARMulator's MMU definition. A few things to note:
890 1) It has eight registers, but only two are defined.
891 2) You can only access its registers with MCR and MRC.
892 3) MMU Register 0 (ID) returns 0x41440110
893 4) Register 1 only has 4 bits defined. Bits 0 to 3 are unused, bit 4
894 controls 32/26 bit program space, bit 5 controls 32/26 bit data space,
895 bit 6 controls late abort timimg and bit 7 controls big/little endian. */
897 static ARMword MMUReg[8];
900 MMUInit (ARMul_State * state)
902 MMUReg[1] = state->prog32Sig << 4 |
903 state->data32Sig << 5 | state->lateabtSig << 6 | state->bigendSig << 7;
905 ARMul_ConsolePrint (state, ", MMU present");
911 MMUMRC (ARMul_State * state ATTRIBUTE_UNUSED,
912 unsigned type ATTRIBUTE_UNUSED,
916 int reg = BITS (16, 19) & 7;
921 *value = MMUReg[reg];
927 MMUMCR (ARMul_State * state,
928 unsigned type ATTRIBUTE_UNUSED,
932 int reg = BITS (16, 19) & 7;
940 p = state->prog32Sig;
941 d = state->data32Sig;
942 l = state->lateabtSig;
943 b = state->bigendSig;
945 state->prog32Sig = value >> 4 & 1;
946 state->data32Sig = value >> 5 & 1;
947 state->lateabtSig = value >> 6 & 1;
948 state->bigendSig = value >> 7 & 1;
950 if ( p != state->prog32Sig
951 || d != state->data32Sig
952 || l != state->lateabtSig
953 || b != state->bigendSig)
954 /* Force ARMulator to notice these now. */
955 state->Emulate = CHANGEMODE;
962 MMURead (ARMul_State * state ATTRIBUTE_UNUSED, unsigned reg, ARMword * value)
967 *value = MMUReg[reg];
973 MMUWrite (ARMul_State * state, unsigned reg, ARMword value)
982 p = state->prog32Sig;
983 d = state->data32Sig;
984 l = state->lateabtSig;
985 b = state->bigendSig;
987 state->prog32Sig = value >> 4 & 1;
988 state->data32Sig = value >> 5 & 1;
989 state->lateabtSig = value >> 6 & 1;
990 state->bigendSig = value >> 7 & 1;
992 if ( p != state->prog32Sig
993 || d != state->data32Sig
994 || l != state->lateabtSig
995 || b != state->bigendSig)
996 /* Force ARMulator to notice these now. */
997 state->Emulate = CHANGEMODE;
1004 /* What follows is the Validation Suite Coprocessor. It uses two
1005 co-processor numbers (4 and 5) and has the follwing functionality.
1006 Sixteen registers. Both co-processor nuimbers can be used in an MCR
1007 and MRC to access these registers. CP 4 can LDC and STC to and from
1008 the registers. CP 4 and CP 5 CDP 0 will busy wait for the number of
1009 cycles specified by a CP register. CP 5 CDP 1 issues a FIQ after a
1010 number of cycles (specified in a CP register), CDP 2 issues an IRQW
1011 in the same way, CDP 3 and 4 turn of the FIQ and IRQ source, and CDP 5
1012 stores a 32 bit time value in a CP register (actually it's the total
1013 number of N, S, I, C and F cyles). */
1015 static ARMword ValReg[16];
1018 ValLDC (ARMul_State * state ATTRIBUTE_UNUSED,
1023 static unsigned words;
1025 if (type != ARMul_DATA)
1029 ValReg[BITS (12, 15)] = data;
1032 /* It's a long access, get two words. */
1041 ValSTC (ARMul_State * state ATTRIBUTE_UNUSED,
1046 static unsigned words;
1048 if (type != ARMul_DATA)
1052 * data = ValReg[BITS (12, 15)];
1055 /* It's a long access, get two words. */
1064 ValMRC (ARMul_State * state ATTRIBUTE_UNUSED,
1065 unsigned type ATTRIBUTE_UNUSED,
1069 *value = ValReg[BITS (16, 19)];
1075 ValMCR (ARMul_State * state ATTRIBUTE_UNUSED,
1076 unsigned type ATTRIBUTE_UNUSED,
1080 ValReg[BITS (16, 19)] = value;
1086 ValCDP (ARMul_State * state, unsigned type, ARMword instr)
1088 static unsigned long finish = 0;
1090 if (BITS (20, 23) != 0)
1093 if (type == ARMul_FIRST)
1097 howlong = ValReg[BITS (0, 3)];
1099 /* First cycle of a busy wait. */
1100 finish = ARMul_Time (state) + howlong;
1102 return howlong == 0 ? ARMul_DONE : ARMul_BUSY;
1104 else if (type == ARMul_BUSY)
1106 if (ARMul_Time (state) >= finish)
1116 DoAFIQ (ARMul_State * state)
1118 state->NfiqSig = LOW;
1124 DoAIRQ (ARMul_State * state)
1126 state->NirqSig = LOW;
1132 IntCDP (ARMul_State * state, unsigned type, ARMword instr)
1134 static unsigned long finish;
1137 howlong = ValReg[BITS (0, 3)];
1139 switch ((int) BITS (20, 23))
1142 if (type == ARMul_FIRST)
1144 /* First cycle of a busy wait. */
1145 finish = ARMul_Time (state) + howlong;
1147 return howlong == 0 ? ARMul_DONE : ARMul_BUSY;
1149 else if (type == ARMul_BUSY)
1151 if (ARMul_Time (state) >= finish)
1160 ARMul_Abort (state, ARMul_FIQV);
1162 ARMul_ScheduleEvent (state, howlong, DoAFIQ);
1167 ARMul_Abort (state, ARMul_IRQV);
1169 ARMul_ScheduleEvent (state, howlong, DoAIRQ);
1173 state->NfiqSig = HIGH;
1178 state->NirqSig = HIGH;
1183 ValReg[BITS (0, 3)] = ARMul_Time (state);
1190 /***************************************************************************\
1191 * Install co-processor instruction handlers in this routine *
1192 \***************************************************************************/
1195 ARMul_CoProInit (ARMul_State * state)
1199 /* Initialise tham all first. */
1200 for (i = 0; i < 16; i++)
1201 ARMul_CoProDetach (state, i);
1203 /* Install CoPro Instruction handlers here.
1205 ARMul_CoProAttach (state, CP Number,
1206 Init routine, Exit routine
1207 LDC routine, STC routine,
1208 MRC routine, MCR routine,
1210 Read Reg routine, Write Reg routine). */
1211 ARMul_CoProAttach (state, 4, NULL, NULL,
1212 ValLDC, ValSTC, ValMRC, ValMCR, ValCDP, NULL, NULL);
1214 ARMul_CoProAttach (state, 5, NULL, NULL,
1215 NULL, NULL, ValMRC, ValMCR, IntCDP, NULL, NULL);
1217 ARMul_CoProAttach (state, 15, MMUInit, NULL,
1218 NULL, NULL, MMUMRC, MMUMCR, NULL, MMURead, MMUWrite);
1220 ARMul_CoProAttach (state, 13, XScale_cp13_init, NULL,
1221 XScale_cp13_LDC, XScale_cp13_STC, XScale_cp13_MRC,
1222 XScale_cp13_MCR, NULL, XScale_cp13_read_reg,
1223 XScale_cp13_write_reg);
1225 ARMul_CoProAttach (state, 14, XScale_cp14_init, NULL,
1226 XScale_cp14_LDC, XScale_cp14_STC, XScale_cp14_MRC,
1227 XScale_cp14_MCR, NULL, XScale_cp14_read_reg,
1228 XScale_cp14_write_reg);
1230 ARMul_CoProAttach (state, 15, XScale_cp15_init, NULL,
1231 NULL, NULL, XScale_cp15_MRC, XScale_cp15_MCR,
1232 NULL, XScale_cp15_read_reg, XScale_cp15_write_reg);
1234 /* No handlers below here. */
1236 /* Call all the initialisation routines. */
1237 for (i = 0; i < 16; i++)
1238 if (state->CPInit[i])
1239 (state->CPInit[i]) (state);
1244 /***************************************************************************\
1245 * Install co-processor finalisation routines in this routine *
1246 \***************************************************************************/
1249 ARMul_CoProExit (ARMul_State * state)
1251 register unsigned i;
1253 for (i = 0; i < 16; i++)
1254 if (state->CPExit[i])
1255 (state->CPExit[i]) (state);
1257 for (i = 0; i < 16; i++) /* Detach all handlers. */
1258 ARMul_CoProDetach (state, i);
1261 /***************************************************************************\
1262 * Routines to hook Co-processors into ARMulator *
1263 \***************************************************************************/
1266 ARMul_CoProAttach (ARMul_State * state,
1268 ARMul_CPInits * init,
1269 ARMul_CPExits * exit,
1275 ARMul_CPReads * read,
1276 ARMul_CPWrites * write)
1279 state->CPInit[number] = init;
1281 state->CPExit[number] = exit;
1283 state->LDC[number] = ldc;
1285 state->STC[number] = stc;
1287 state->MRC[number] = mrc;
1289 state->MCR[number] = mcr;
1291 state->CDP[number] = cdp;
1293 state->CPRead[number] = read;
1295 state->CPWrite[number] = write;
1299 ARMul_CoProDetach (ARMul_State * state, unsigned number)
1301 ARMul_CoProAttach (state, number, NULL, NULL,
1302 NoCoPro4R, NoCoPro4W, NoCoPro4W, NoCoPro4R,
1303 NoCoPro3R, NULL, NULL);
1305 state->CPInit[number] = NULL;
1306 state->CPExit[number] = NULL;
1307 state->CPRead[number] = NULL;
1308 state->CPWrite[number] = NULL;