armcopro.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427
  1. /* armcopro.c -- co-processor interface: ARM6 Instruction Emulator.
  2. Copyright (C) 1994, 2000 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 3 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, see <http://www.gnu.org/licenses/>. */
  13. #include "armdefs.h"
  14. #include "armos.h"
  15. #include "armemu.h"
  16. #include "ansidecl.h"
  17. #include "iwmmxt.h"
  18. /* Dummy Co-processors. */
  19. static unsigned
  20. NoCoPro3R (ARMul_State * state ATTRIBUTE_UNUSED,
  21. unsigned a ATTRIBUTE_UNUSED,
  22. ARMword b ATTRIBUTE_UNUSED)
  23. {
  24. return ARMul_CANT;
  25. }
  26. static unsigned
  27. NoCoPro4R (ARMul_State * state ATTRIBUTE_UNUSED,
  28. unsigned a ATTRIBUTE_UNUSED,
  29. ARMword b ATTRIBUTE_UNUSED,
  30. ARMword c ATTRIBUTE_UNUSED)
  31. {
  32. return ARMul_CANT;
  33. }
  34. static unsigned
  35. NoCoPro4W (ARMul_State * state ATTRIBUTE_UNUSED,
  36. unsigned a ATTRIBUTE_UNUSED,
  37. ARMword b ATTRIBUTE_UNUSED,
  38. ARMword * c ATTRIBUTE_UNUSED)
  39. {
  40. return ARMul_CANT;
  41. }
  42. /* The XScale Co-processors. */
  43. /* Coprocessor 15: System Control. */
  44. static void write_cp14_reg (unsigned, ARMword);
  45. static ARMword read_cp14_reg (unsigned);
  46. /* There are two sets of registers for copro 15.
  47. One set is available when opcode_2 is 0 and
  48. the other set when opcode_2 >= 1. */
  49. static ARMword XScale_cp15_opcode_2_is_0_Regs[16];
  50. static ARMword XScale_cp15_opcode_2_is_not_0_Regs[16];
  51. /* There are also a set of breakpoint registers
  52. which are accessed via CRm instead of opcode_2. */
  53. static ARMword XScale_cp15_DBR1;
  54. static ARMword XScale_cp15_DBCON;
  55. static ARMword XScale_cp15_IBCR0;
  56. static ARMword XScale_cp15_IBCR1;
  57. static unsigned
  58. XScale_cp15_init (ARMul_State * state ATTRIBUTE_UNUSED)
  59. {
  60. int i;
  61. for (i = 16; i--;)
  62. {
  63. XScale_cp15_opcode_2_is_0_Regs[i] = 0;
  64. XScale_cp15_opcode_2_is_not_0_Regs[i] = 0;
  65. }
  66. /* Initialise the processor ID. */
  67. XScale_cp15_opcode_2_is_0_Regs[0] = 0x69052000;
  68. /* Initialise the cache type. */
  69. XScale_cp15_opcode_2_is_not_0_Regs[0] = 0x0B1AA1AA;
  70. /* Initialise the ARM Control Register. */
  71. XScale_cp15_opcode_2_is_0_Regs[1] = 0x00000078;
  72. return TRUE;
  73. }
  74. /* Check an access to a register. */
  75. static unsigned
  76. check_cp15_access (ARMul_State * state,
  77. unsigned reg,
  78. unsigned CRm,
  79. unsigned opcode_1,
  80. unsigned opcode_2)
  81. {
  82. /* Do not allow access to these register in USER mode. */
  83. if (state->Mode == USER26MODE || state->Mode == USER32MODE)
  84. return ARMul_CANT;
  85. /* Opcode_1should be zero. */
  86. if (opcode_1 != 0)
  87. return ARMul_CANT;
  88. /* Different register have different access requirements. */
  89. switch (reg)
  90. {
  91. case 0:
  92. case 1:
  93. /* CRm must be 0. Opcode_2 can be anything. */
  94. if (CRm != 0)
  95. return ARMul_CANT;
  96. break;
  97. case 2:
  98. case 3:
  99. /* CRm must be 0. Opcode_2 must be zero. */
  100. if ((CRm != 0) || (opcode_2 != 0))
  101. return ARMul_CANT;
  102. break;
  103. case 4:
  104. /* Access not allowed. */
  105. return ARMul_CANT;
  106. case 5:
  107. case 6:
  108. /* Opcode_2 must be zero. CRm must be 0. */
  109. if ((CRm != 0) || (opcode_2 != 0))
  110. return ARMul_CANT;
  111. break;
  112. case 7:
  113. /* Permissable combinations:
  114. Opcode_2 CRm
  115. 0 5
  116. 0 6
  117. 0 7
  118. 1 5
  119. 1 6
  120. 1 10
  121. 4 10
  122. 5 2
  123. 6 5 */
  124. switch (opcode_2)
  125. {
  126. default: return ARMul_CANT;
  127. case 6: if (CRm != 5) return ARMul_CANT; break;
  128. case 5: if (CRm != 2) return ARMul_CANT; break;
  129. case 4: if (CRm != 10) return ARMul_CANT; break;
  130. case 1: if ((CRm != 5) && (CRm != 6) && (CRm != 10)) return ARMul_CANT; break;
  131. case 0: if ((CRm < 5) || (CRm > 7)) return ARMul_CANT; break;
  132. }
  133. break;
  134. case 8:
  135. /* Permissable combinations:
  136. Opcode_2 CRm
  137. 0 5
  138. 0 6
  139. 0 7
  140. 1 5
  141. 1 6 */
  142. if (opcode_2 > 1)
  143. return ARMul_CANT;
  144. if ((CRm < 5) || (CRm > 7))
  145. return ARMul_CANT;
  146. if (opcode_2 == 1 && CRm == 7)
  147. return ARMul_CANT;
  148. break;
  149. case 9:
  150. /* Opcode_2 must be zero or one. CRm must be 1 or 2. */
  151. if ( ((CRm != 0) && (CRm != 1))
  152. || ((opcode_2 != 1) && (opcode_2 != 2)))
  153. return ARMul_CANT;
  154. break;
  155. case 10:
  156. /* Opcode_2 must be zero or one. CRm must be 4 or 8. */
  157. if ( ((CRm != 0) && (CRm != 1))
  158. || ((opcode_2 != 4) && (opcode_2 != 8)))
  159. return ARMul_CANT;
  160. break;
  161. case 11:
  162. /* Access not allowed. */
  163. return ARMul_CANT;
  164. case 12:
  165. /* Access not allowed. */
  166. return ARMul_CANT;
  167. case 13:
  168. /* Opcode_2 must be zero. CRm must be 0. */
  169. if ((CRm != 0) || (opcode_2 != 0))
  170. return ARMul_CANT;
  171. break;
  172. case 14:
  173. /* Opcode_2 must be 0. CRm must be 0, 3, 4, 8 or 9. */
  174. if (opcode_2 != 0)
  175. return ARMul_CANT;
  176. if ((CRm != 0) && (CRm != 3) && (CRm != 4) && (CRm != 8) && (CRm != 9))
  177. return ARMul_CANT;
  178. break;
  179. case 15:
  180. /* Opcode_2 must be zero. CRm must be 1. */
  181. if ((CRm != 1) || (opcode_2 != 0))
  182. return ARMul_CANT;
  183. break;
  184. default:
  185. /* Should never happen. */
  186. return ARMul_CANT;
  187. }
  188. return ARMul_DONE;
  189. }
  190. /* Store a value into one of coprocessor 15's registers. */
  191. static void
  192. write_cp15_reg (ARMul_State * state,
  193. unsigned reg,
  194. unsigned opcode_2,
  195. unsigned CRm,
  196. ARMword value)
  197. {
  198. if (opcode_2)
  199. {
  200. switch (reg)
  201. {
  202. case 0: /* Cache Type. */
  203. /* Writes are not allowed. */
  204. return;
  205. case 1: /* Auxillary Control. */
  206. /* Only BITS (5, 4) and BITS (1, 0) can be written. */
  207. value &= 0x33;
  208. break;
  209. default:
  210. return;
  211. }
  212. XScale_cp15_opcode_2_is_not_0_Regs [reg] = value;
  213. }
  214. else
  215. {
  216. switch (reg)
  217. {
  218. case 0: /* ID. */
  219. /* Writes are not allowed. */
  220. return;
  221. case 1: /* ARM Control. */
  222. /* Only BITS (13, 11), BITS (9, 7) and BITS (2, 0) can be written.
  223. BITS (31, 14) and BIT (10) write as zero, BITS (6, 3) write as one. */
  224. value &= 0x00003b87;
  225. value |= 0x00000078;
  226. /* Change the endianness if necessary. */
  227. if ((value & ARMul_CP15_R1_ENDIAN) !=
  228. (XScale_cp15_opcode_2_is_0_Regs [reg] & ARMul_CP15_R1_ENDIAN))
  229. {
  230. state->bigendSig = value & ARMul_CP15_R1_ENDIAN;
  231. /* Force ARMulator to notice these now. */
  232. state->Emulate = CHANGEMODE;
  233. }
  234. break;
  235. case 2: /* Translation Table Base. */
  236. /* Only BITS (31, 14) can be written. */
  237. value &= 0xffffc000;
  238. break;
  239. case 3: /* Domain Access Control. */
  240. /* All bits writable. */
  241. break;
  242. case 5: /* Fault Status Register. */
  243. /* BITS (10, 9) and BITS (7, 0) can be written. */
  244. value &= 0x000006ff;
  245. break;
  246. case 6: /* Fault Address Register. */
  247. /* All bits writable. */
  248. break;
  249. case 7: /* Cache Functions. */
  250. case 8: /* TLB Operations. */
  251. case 10: /* TLB Lock Down. */
  252. /* Ignore writes. */
  253. return;
  254. case 9: /* Data Cache Lock. */
  255. /* Only BIT (0) can be written. */
  256. value &= 0x1;
  257. break;
  258. case 13: /* Process ID. */
  259. /* Only BITS (31, 25) are writable. */
  260. value &= 0xfe000000;
  261. break;
  262. case 14: /* DBR0, DBR1, DBCON, IBCR0, IBCR1 */
  263. /* All bits can be written. Which register is accessed is
  264. dependent upon CRm. */
  265. switch (CRm)
  266. {
  267. case 0: /* DBR0 */
  268. break;
  269. case 3: /* DBR1 */
  270. XScale_cp15_DBR1 = value;
  271. break;
  272. case 4: /* DBCON */
  273. XScale_cp15_DBCON = value;
  274. break;
  275. case 8: /* IBCR0 */
  276. XScale_cp15_IBCR0 = value;
  277. break;
  278. case 9: /* IBCR1 */
  279. XScale_cp15_IBCR1 = value;
  280. break;
  281. default:
  282. return;
  283. }
  284. break;
  285. case 15: /* Coprpcessor Access Register. */
  286. /* Access is only valid if CRm == 1. */
  287. if (CRm != 1)
  288. return;
  289. /* Only BITS (13, 0) may be written. */
  290. value &= 0x00003fff;
  291. break;
  292. default:
  293. return;
  294. }
  295. XScale_cp15_opcode_2_is_0_Regs [reg] = value;
  296. }
  297. return;
  298. }
  299. /* Return the value in a cp15 register. */
  300. ARMword
  301. read_cp15_reg (unsigned reg, unsigned opcode_2, unsigned CRm)
  302. {
  303. if (opcode_2 == 0)
  304. {
  305. if (reg == 15 && CRm != 1)
  306. return 0;
  307. if (reg == 14)
  308. {
  309. switch (CRm)
  310. {
  311. case 3: return XScale_cp15_DBR1;
  312. case 4: return XScale_cp15_DBCON;
  313. case 8: return XScale_cp15_IBCR0;
  314. case 9: return XScale_cp15_IBCR1;
  315. default:
  316. break;
  317. }
  318. }
  319. return XScale_cp15_opcode_2_is_0_Regs [reg];
  320. }
  321. else
  322. return XScale_cp15_opcode_2_is_not_0_Regs [reg];
  323. return 0;
  324. }
  325. static unsigned
  326. XScale_cp15_MRC (ARMul_State * state,
  327. unsigned type ATTRIBUTE_UNUSED,
  328. ARMword instr,
  329. ARMword * value)
  330. {
  331. unsigned opcode_2 = BITS (5, 7);
  332. unsigned CRm = BITS (0, 3);
  333. unsigned reg = BITS (16, 19);
  334. unsigned result;
  335. result = check_cp15_access (state, reg, CRm, BITS (21, 23), opcode_2);
  336. if (result == ARMul_DONE)
  337. * value = read_cp15_reg (reg, opcode_2, CRm);
  338. return result;
  339. }
  340. static unsigned
  341. XScale_cp15_MCR (ARMul_State * state,
  342. unsigned type ATTRIBUTE_UNUSED,
  343. ARMword instr,
  344. ARMword value)
  345. {
  346. unsigned opcode_2 = BITS (5, 7);
  347. unsigned CRm = BITS (0, 3);
  348. unsigned reg = BITS (16, 19);
  349. unsigned result;
  350. result = check_cp15_access (state, reg, CRm, BITS (21, 23), opcode_2);
  351. if (result == ARMul_DONE)
  352. write_cp15_reg (state, reg, opcode_2, CRm, value);
  353. return result;
  354. }
  355. static unsigned
  356. XScale_cp15_read_reg (ARMul_State * state ATTRIBUTE_UNUSED,
  357. unsigned reg,
  358. ARMword * value)
  359. {
  360. /* FIXME: Not sure what to do about the alternative register set
  361. here. For now default to just accessing CRm == 0 registers. */
  362. * value = read_cp15_reg (reg, 0, 0);
  363. return TRUE;
  364. }
  365. static unsigned
  366. XScale_cp15_write_reg (ARMul_State * state ATTRIBUTE_UNUSED,
  367. unsigned reg,
  368. ARMword value)
  369. {
  370. /* FIXME: Not sure what to do about the alternative register set
  371. here. For now default to just accessing CRm == 0 registers. */
  372. write_cp15_reg (state, reg, 0, 0, value);
  373. return TRUE;
  374. }
  375. /* Check for special XScale memory access features. */
  376. void
  377. XScale_check_memacc (ARMul_State * state, ARMword * address, int store)
  378. {
  379. ARMword dbcon, r0, r1;
  380. int e1, e0;
  381. if (!state->is_XScale)
  382. return;
  383. /* Check for PID-ification.
  384. XXX BTB access support will require this test failing. */
  385. r0 = (read_cp15_reg (13, 0, 0) & 0xfe000000);
  386. if (r0 && (* address & 0xfe000000) == 0)
  387. * address |= r0;
  388. /* Check alignment fault enable/disable. */
  389. if ((read_cp15_reg (1, 0, 0) & ARMul_CP15_R1_ALIGN) && (* address & 3))
  390. {
  391. /* Set the FSR and FAR.
  392. Do not use XScale_set_fsr_far as this checks the DCSR register. */
  393. write_cp15_reg (state, 5, 0, 0, ARMul_CP15_R5_MMU_EXCPT);
  394. write_cp15_reg (state, 6, 0, 0, * address);
  395. ARMul_Abort (state, ARMul_DataAbortV);
  396. }
  397. if (XScale_debug_moe (state, -1))
  398. return;
  399. /* Check the data breakpoint registers. */
  400. dbcon = read_cp15_reg (14, 0, 4);
  401. r0 = read_cp15_reg (14, 0, 0);
  402. r1 = read_cp15_reg (14, 0, 3);
  403. e0 = dbcon & ARMul_CP15_DBCON_E0;
  404. if (dbcon & ARMul_CP15_DBCON_M)
  405. {
  406. /* r1 is a inverse mask. */
  407. if (e0 != 0 && ((store && e0 != 3) || (!store && e0 != 1))
  408. && ((* address & ~r1) == (r0 & ~r1)))
  409. {
  410. XScale_debug_moe (state, ARMul_CP14_R10_MOE_DB);
  411. ARMul_OSHandleSWI (state, SWI_Breakpoint);
  412. }
  413. }
  414. else
  415. {
  416. if (e0 != 0 && ((store && e0 != 3) || (!store && e0 != 1))
  417. && ((* address & ~3) == (r0 & ~3)))
  418. {
  419. XScale_debug_moe (state, ARMul_CP14_R10_MOE_DB);
  420. ARMul_OSHandleSWI (state, SWI_Breakpoint);
  421. }
  422. e1 = (dbcon & ARMul_CP15_DBCON_E1) >> 2;
  423. if (e1 != 0 && ((store && e1 != 3) || (!store && e1 != 1))
  424. && ((* address & ~3) == (r1 & ~3)))
  425. {
  426. XScale_debug_moe (state, ARMul_CP14_R10_MOE_DB);
  427. ARMul_OSHandleSWI (state, SWI_Breakpoint);
  428. }
  429. }
  430. }
  431. /* Set the XScale FSR and FAR registers. */
  432. void
  433. XScale_set_fsr_far (ARMul_State * state, ARMword fsr, ARMword far)
  434. {
  435. if (!state->is_XScale || (read_cp14_reg (10) & (1UL << 31)) == 0)
  436. return;
  437. write_cp15_reg (state, 5, 0, 0, fsr);
  438. write_cp15_reg (state, 6, 0, 0, far);
  439. }
  440. /* Set the XScale debug `method of entry' if it is enabled. */
  441. int
  442. XScale_debug_moe (ARMul_State * state, int moe)
  443. {
  444. ARMword value;
  445. if (!state->is_XScale)
  446. return 1;
  447. value = read_cp14_reg (10);
  448. if (value & (1UL << 31))
  449. {
  450. if (moe != -1)
  451. {
  452. value &= ~0x1c;
  453. value |= moe;
  454. write_cp14_reg (10, value);
  455. }
  456. return 1;
  457. }
  458. return 0;
  459. }
  460. /* Coprocessor 13: Interrupt Controller and Bus Controller. */
  461. /* There are two sets of registers for copro 13.
  462. One set (of three registers) is available when CRm is 0
  463. and the other set (of six registers) when CRm is 1. */
  464. static ARMword XScale_cp13_CR0_Regs[16];
  465. static ARMword XScale_cp13_CR1_Regs[16];
  466. static unsigned
  467. XScale_cp13_init (ARMul_State * state ATTRIBUTE_UNUSED)
  468. {
  469. int i;
  470. for (i = 16; i--;)
  471. {
  472. XScale_cp13_CR0_Regs[i] = 0;
  473. XScale_cp13_CR1_Regs[i] = 0;
  474. }
  475. return TRUE;
  476. }
  477. /* Check an access to a register. */
  478. static unsigned
  479. check_cp13_access (ARMul_State * state,
  480. unsigned reg,
  481. unsigned CRm,
  482. unsigned opcode_1,
  483. unsigned opcode_2)
  484. {
  485. /* Do not allow access to these registers in USER mode. */
  486. if (state->Mode == USER26MODE || state->Mode == USER32MODE)
  487. return ARMul_CANT;
  488. /* The opcodes should be zero. */
  489. if ((opcode_1 != 0) || (opcode_2 != 0))
  490. return ARMul_CANT;
  491. /* Do not allow access to these register if bit
  492. 13 of coprocessor 15's register 15 is zero. */
  493. if (! CP_ACCESS_ALLOWED (state, 13))
  494. return ARMul_CANT;
  495. /* Registers 0, 4 and 8 are defined when CRm == 0.
  496. Registers 0, 1, 4, 5, 6, 7, 8 are defined when CRm == 1.
  497. For all other CRm values undefined behaviour results. */
  498. if (CRm == 0)
  499. {
  500. if (reg == 0 || reg == 4 || reg == 8)
  501. return ARMul_DONE;
  502. }
  503. else if (CRm == 1)
  504. {
  505. if (reg == 0 || reg == 1 || (reg >= 4 && reg <= 8))
  506. return ARMul_DONE;
  507. }
  508. return ARMul_CANT;
  509. }
  510. /* Store a value into one of coprocessor 13's registers. */
  511. static void
  512. write_cp13_reg (unsigned reg, unsigned CRm, ARMword value)
  513. {
  514. switch (CRm)
  515. {
  516. case 0:
  517. switch (reg)
  518. {
  519. case 0: /* INTCTL */
  520. /* Only BITS (3:0) can be written. */
  521. value &= 0xf;
  522. break;
  523. case 4: /* INTSRC */
  524. /* No bits may be written. */
  525. return;
  526. case 8: /* INTSTR */
  527. /* Only BITS (1:0) can be written. */
  528. value &= 0x3;
  529. break;
  530. default:
  531. /* Should not happen. Ignore any writes to unimplemented registers. */
  532. return;
  533. }
  534. XScale_cp13_CR0_Regs [reg] = value;
  535. break;
  536. case 1:
  537. switch (reg)
  538. {
  539. case 0: /* BCUCTL */
  540. /* Only BITS (30:28) and BITS (3:0) can be written.
  541. BIT(31) is write ignored. */
  542. value &= 0x7000000f;
  543. value |= XScale_cp13_CR1_Regs[0] & (1UL << 31);
  544. break;
  545. case 1: /* BCUMOD */
  546. /* Only bit 0 is accecssible. */
  547. value &= 1;
  548. value |= XScale_cp13_CR1_Regs[1] & ~ 1;
  549. break;
  550. case 4: /* ELOG0 */
  551. case 5: /* ELOG1 */
  552. case 6: /* ECAR0 */
  553. case 7: /* ECAR1 */
  554. /* No bits can be written. */
  555. return;
  556. case 8: /* ECTST */
  557. /* Only BITS (7:0) can be written. */
  558. value &= 0xff;
  559. break;
  560. default:
  561. /* Should not happen. Ignore any writes to unimplemented registers. */
  562. return;
  563. }
  564. XScale_cp13_CR1_Regs [reg] = value;
  565. break;
  566. default:
  567. /* Should not happen. */
  568. break;
  569. }
  570. return;
  571. }
  572. /* Return the value in a cp13 register. */
  573. static ARMword
  574. read_cp13_reg (unsigned reg, unsigned CRm)
  575. {
  576. if (CRm == 0)
  577. return XScale_cp13_CR0_Regs [reg];
  578. else if (CRm == 1)
  579. return XScale_cp13_CR1_Regs [reg];
  580. return 0;
  581. }
  582. static unsigned
  583. XScale_cp13_LDC (ARMul_State * state, unsigned type, ARMword instr, ARMword data)
  584. {
  585. unsigned reg = BITS (12, 15);
  586. unsigned result;
  587. result = check_cp13_access (state, reg, 0, 0, 0);
  588. if (result == ARMul_DONE && type == ARMul_DATA)
  589. write_cp13_reg (reg, 0, data);
  590. return result;
  591. }
  592. static unsigned
  593. XScale_cp13_STC (ARMul_State * state, unsigned type, ARMword instr, ARMword * data)
  594. {
  595. unsigned reg = BITS (12, 15);
  596. unsigned result;
  597. result = check_cp13_access (state, reg, 0, 0, 0);
  598. if (result == ARMul_DONE && type == ARMul_DATA)
  599. * data = read_cp13_reg (reg, 0);
  600. return result;
  601. }
  602. static unsigned
  603. XScale_cp13_MRC (ARMul_State * state,
  604. unsigned type ATTRIBUTE_UNUSED,
  605. ARMword instr,
  606. ARMword * value)
  607. {
  608. unsigned CRm = BITS (0, 3);
  609. unsigned reg = BITS (16, 19);
  610. unsigned result;
  611. result = check_cp13_access (state, reg, CRm, BITS (21, 23), BITS (5, 7));
  612. if (result == ARMul_DONE)
  613. * value = read_cp13_reg (reg, CRm);
  614. return result;
  615. }
  616. static unsigned
  617. XScale_cp13_MCR (ARMul_State * state,
  618. unsigned type ATTRIBUTE_UNUSED,
  619. ARMword instr,
  620. ARMword value)
  621. {
  622. unsigned CRm = BITS (0, 3);
  623. unsigned reg = BITS (16, 19);
  624. unsigned result;
  625. result = check_cp13_access (state, reg, CRm, BITS (21, 23), BITS (5, 7));
  626. if (result == ARMul_DONE)
  627. write_cp13_reg (reg, CRm, value);
  628. return result;
  629. }
  630. static unsigned
  631. XScale_cp13_read_reg (ARMul_State * state ATTRIBUTE_UNUSED,
  632. unsigned reg,
  633. ARMword * value)
  634. {
  635. /* FIXME: Not sure what to do about the alternative register set
  636. here. For now default to just accessing CRm == 0 registers. */
  637. * value = read_cp13_reg (reg, 0);
  638. return TRUE;
  639. }
  640. static unsigned
  641. XScale_cp13_write_reg (ARMul_State * state ATTRIBUTE_UNUSED,
  642. unsigned reg,
  643. ARMword value)
  644. {
  645. /* FIXME: Not sure what to do about the alternative register set
  646. here. For now default to just accessing CRm == 0 registers. */
  647. write_cp13_reg (reg, 0, value);
  648. return TRUE;
  649. }
  650. /* Coprocessor 14: Performance Monitoring, Clock and Power management,
  651. Software Debug. */
  652. static ARMword XScale_cp14_Regs[16];
  653. static unsigned
  654. XScale_cp14_init (ARMul_State * state ATTRIBUTE_UNUSED)
  655. {
  656. int i;
  657. for (i = 16; i--;)
  658. XScale_cp14_Regs[i] = 0;
  659. return TRUE;
  660. }
  661. /* Check an access to a register. */
  662. static unsigned
  663. check_cp14_access (ARMul_State * state,
  664. unsigned reg,
  665. unsigned CRm,
  666. unsigned opcode1,
  667. unsigned opcode2)
  668. {
  669. /* Not allowed to access these register in USER mode. */
  670. if (state->Mode == USER26MODE || state->Mode == USER32MODE)
  671. return ARMul_CANT;
  672. /* CRm should be zero. */
  673. if (CRm != 0)
  674. return ARMul_CANT;
  675. /* OPcodes should be zero. */
  676. if (opcode1 != 0 || opcode2 != 0)
  677. return ARMul_CANT;
  678. /* Accessing registers 4 or 5 has unpredicatable results. */
  679. if (reg >= 4 && reg <= 5)
  680. return ARMul_CANT;
  681. return ARMul_DONE;
  682. }
  683. /* Store a value into one of coprocessor 14's registers. */
  684. static void
  685. write_cp14_reg (unsigned reg, ARMword value)
  686. {
  687. switch (reg)
  688. {
  689. case 0: /* PMNC */
  690. /* Only BITS (27:12), BITS (10:8) and BITS (6:0) can be written. */
  691. value &= 0x0ffff77f;
  692. /* Reset the clock counter if necessary. */
  693. if (value & ARMul_CP14_R0_CLKRST)
  694. XScale_cp14_Regs [1] = 0;
  695. break;
  696. case 4:
  697. case 5:
  698. /* We should not normally reach this code. The debugger interface
  699. can bypass the normal checks though, so it could happen. */
  700. value = 0;
  701. break;
  702. case 6: /* CCLKCFG */
  703. /* Only BITS (3:0) can be written. */
  704. value &= 0xf;
  705. break;
  706. case 7: /* PWRMODE */
  707. /* Although BITS (1:0) can be written with non-zero values, this would
  708. have the side effect of putting the processor to sleep. Thus in
  709. order for the register to be read again, it would have to go into
  710. ACTIVE mode, which means that any read will see these bits as zero.
  711. Rather than trying to implement complex reset-to-zero-upon-read logic
  712. we just override the write value with zero. */
  713. value = 0;
  714. break;
  715. case 10: /* DCSR */
  716. /* Only BITS (31:30), BITS (23:22), BITS (20:16) and BITS (5:0) can
  717. be written. */
  718. value &= 0xc0df003f;
  719. break;
  720. case 11: /* TBREG */
  721. /* No writes are permitted. */
  722. value = 0;
  723. break;
  724. case 14: /* TXRXCTRL */
  725. /* Only BITS (31:30) can be written. */
  726. value &= 0xc0000000;
  727. break;
  728. default:
  729. /* All bits can be written. */
  730. break;
  731. }
  732. XScale_cp14_Regs [reg] = value;
  733. }
  734. /* Return the value in a cp14 register. Not a static function since
  735. it is used by the code to emulate the BKPT instruction in armemu.c. */
  736. ARMword
  737. read_cp14_reg (unsigned reg)
  738. {
  739. return XScale_cp14_Regs [reg];
  740. }
  741. static unsigned
  742. XScale_cp14_LDC (ARMul_State * state, unsigned type, ARMword instr, ARMword data)
  743. {
  744. unsigned reg = BITS (12, 15);
  745. unsigned result;
  746. result = check_cp14_access (state, reg, 0, 0, 0);
  747. if (result == ARMul_DONE && type == ARMul_DATA)
  748. write_cp14_reg (reg, data);
  749. return result;
  750. }
  751. static unsigned
  752. XScale_cp14_STC (ARMul_State * state, unsigned type, ARMword instr, ARMword * data)
  753. {
  754. unsigned reg = BITS (12, 15);
  755. unsigned result;
  756. result = check_cp14_access (state, reg, 0, 0, 0);
  757. if (result == ARMul_DONE && type == ARMul_DATA)
  758. * data = read_cp14_reg (reg);
  759. return result;
  760. }
  761. static unsigned
  762. XScale_cp14_MRC
  763. (
  764. ARMul_State * state,
  765. unsigned type ATTRIBUTE_UNUSED,
  766. ARMword instr,
  767. ARMword * value
  768. )
  769. {
  770. unsigned reg = BITS (16, 19);
  771. unsigned result;
  772. result = check_cp14_access (state, reg, BITS (0, 3), BITS (21, 23), BITS (5, 7));
  773. if (result == ARMul_DONE)
  774. * value = read_cp14_reg (reg);
  775. return result;
  776. }
  777. static unsigned
  778. XScale_cp14_MCR
  779. (
  780. ARMul_State * state,
  781. unsigned type ATTRIBUTE_UNUSED,
  782. ARMword instr,
  783. ARMword value
  784. )
  785. {
  786. unsigned reg = BITS (16, 19);
  787. unsigned result;
  788. result = check_cp14_access (state, reg, BITS (0, 3), BITS (21, 23), BITS (5, 7));
  789. if (result == ARMul_DONE)
  790. write_cp14_reg (reg, value);
  791. return result;
  792. }
  793. static unsigned
  794. XScale_cp14_read_reg
  795. (
  796. ARMul_State * state ATTRIBUTE_UNUSED,
  797. unsigned reg,
  798. ARMword * value
  799. )
  800. {
  801. * value = read_cp14_reg (reg);
  802. return TRUE;
  803. }
  804. static unsigned
  805. XScale_cp14_write_reg
  806. (
  807. ARMul_State * state ATTRIBUTE_UNUSED,
  808. unsigned reg,
  809. ARMword value
  810. )
  811. {
  812. write_cp14_reg (reg, value);
  813. return TRUE;
  814. }
  815. /* Here's ARMulator's MMU definition. A few things to note:
  816. 1) It has eight registers, but only two are defined.
  817. 2) You can only access its registers with MCR and MRC.
  818. 3) MMU Register 0 (ID) returns 0x41440110
  819. 4) Register 1 only has 4 bits defined. Bits 0 to 3 are unused, bit 4
  820. controls 32/26 bit program space, bit 5 controls 32/26 bit data space,
  821. bit 6 controls late abort timimg and bit 7 controls big/little endian. */
  822. static ARMword MMUReg[8];
  823. static unsigned
  824. MMUInit (ARMul_State * state)
  825. {
  826. MMUReg[1] = state->prog32Sig << 4 |
  827. state->data32Sig << 5 | state->lateabtSig << 6 | state->bigendSig << 7;
  828. ARMul_ConsolePrint (state, ", MMU present");
  829. return TRUE;
  830. }
  831. static unsigned
  832. MMUMRC (ARMul_State * state ATTRIBUTE_UNUSED,
  833. unsigned type ATTRIBUTE_UNUSED,
  834. ARMword instr,
  835. ARMword * value)
  836. {
  837. int reg = BITS (16, 19) & 7;
  838. if (reg == 0)
  839. *value = 0x41440110;
  840. else
  841. *value = MMUReg[reg];
  842. return ARMul_DONE;
  843. }
  844. static unsigned
  845. MMUMCR (ARMul_State * state,
  846. unsigned type ATTRIBUTE_UNUSED,
  847. ARMword instr,
  848. ARMword value)
  849. {
  850. int reg = BITS (16, 19) & 7;
  851. MMUReg[reg] = value;
  852. if (reg == 1)
  853. {
  854. ARMword p,d,l,b;
  855. p = state->prog32Sig;
  856. d = state->data32Sig;
  857. l = state->lateabtSig;
  858. b = state->bigendSig;
  859. state->prog32Sig = value >> 4 & 1;
  860. state->data32Sig = value >> 5 & 1;
  861. state->lateabtSig = value >> 6 & 1;
  862. state->bigendSig = value >> 7 & 1;
  863. if ( p != state->prog32Sig
  864. || d != state->data32Sig
  865. || l != state->lateabtSig
  866. || b != state->bigendSig)
  867. /* Force ARMulator to notice these now. */
  868. state->Emulate = CHANGEMODE;
  869. }
  870. return ARMul_DONE;
  871. }
  872. static unsigned
  873. MMURead (ARMul_State * state ATTRIBUTE_UNUSED, unsigned reg, ARMword * value)
  874. {
  875. if (reg == 0)
  876. *value = 0x41440110;
  877. else if (reg < 8)
  878. *value = MMUReg[reg];
  879. return TRUE;
  880. }
  881. static unsigned
  882. MMUWrite (ARMul_State * state, unsigned reg, ARMword value)
  883. {
  884. if (reg < 8)
  885. MMUReg[reg] = value;
  886. if (reg == 1)
  887. {
  888. ARMword p,d,l,b;
  889. p = state->prog32Sig;
  890. d = state->data32Sig;
  891. l = state->lateabtSig;
  892. b = state->bigendSig;
  893. state->prog32Sig = value >> 4 & 1;
  894. state->data32Sig = value >> 5 & 1;
  895. state->lateabtSig = value >> 6 & 1;
  896. state->bigendSig = value >> 7 & 1;
  897. if ( p != state->prog32Sig
  898. || d != state->data32Sig
  899. || l != state->lateabtSig
  900. || b != state->bigendSig)
  901. /* Force ARMulator to notice these now. */
  902. state->Emulate = CHANGEMODE;
  903. }
  904. return TRUE;
  905. }
  906. /* What follows is the Validation Suite Coprocessor. It uses two
  907. co-processor numbers (4 and 5) and has the follwing functionality.
  908. Sixteen registers. Both co-processor nuimbers can be used in an MCR
  909. and MRC to access these registers. CP 4 can LDC and STC to and from
  910. the registers. CP 4 and CP 5 CDP 0 will busy wait for the number of
  911. cycles specified by a CP register. CP 5 CDP 1 issues a FIQ after a
  912. number of cycles (specified in a CP register), CDP 2 issues an IRQW
  913. in the same way, CDP 3 and 4 turn of the FIQ and IRQ source, and CDP 5
  914. stores a 32 bit time value in a CP register (actually it's the total
  915. number of N, S, I, C and F cyles). */
  916. static ARMword ValReg[16];
  917. static unsigned
  918. ValLDC (ARMul_State * state ATTRIBUTE_UNUSED,
  919. unsigned type,
  920. ARMword instr,
  921. ARMword data)
  922. {
  923. static unsigned words;
  924. if (type != ARMul_DATA)
  925. words = 0;
  926. else
  927. {
  928. ValReg[BITS (12, 15)] = data;
  929. if (BIT (22))
  930. /* It's a long access, get two words. */
  931. if (words++ != 4)
  932. return ARMul_INC;
  933. }
  934. return ARMul_DONE;
  935. }
  936. static unsigned
  937. ValSTC (ARMul_State * state ATTRIBUTE_UNUSED,
  938. unsigned type,
  939. ARMword instr,
  940. ARMword * data)
  941. {
  942. static unsigned words;
  943. if (type != ARMul_DATA)
  944. words = 0;
  945. else
  946. {
  947. * data = ValReg[BITS (12, 15)];
  948. if (BIT (22))
  949. /* It's a long access, get two words. */
  950. if (words++ != 4)
  951. return ARMul_INC;
  952. }
  953. return ARMul_DONE;
  954. }
  955. static unsigned
  956. ValMRC (ARMul_State * state ATTRIBUTE_UNUSED,
  957. unsigned type ATTRIBUTE_UNUSED,
  958. ARMword instr,
  959. ARMword * value)
  960. {
  961. *value = ValReg[BITS (16, 19)];
  962. return ARMul_DONE;
  963. }
  964. static unsigned
  965. ValMCR (ARMul_State * state ATTRIBUTE_UNUSED,
  966. unsigned type ATTRIBUTE_UNUSED,
  967. ARMword instr,
  968. ARMword value)
  969. {
  970. ValReg[BITS (16, 19)] = value;
  971. return ARMul_DONE;
  972. }
  973. static unsigned
  974. ValCDP (ARMul_State * state, unsigned type, ARMword instr)
  975. {
  976. static unsigned long finish = 0;
  977. if (BITS (20, 23) != 0)
  978. return ARMul_CANT;
  979. if (type == ARMul_FIRST)
  980. {
  981. ARMword howlong;
  982. howlong = ValReg[BITS (0, 3)];
  983. /* First cycle of a busy wait. */
  984. finish = ARMul_Time (state) + howlong;
  985. return howlong == 0 ? ARMul_DONE : ARMul_BUSY;
  986. }
  987. else if (type == ARMul_BUSY)
  988. {
  989. if (ARMul_Time (state) >= finish)
  990. return ARMul_DONE;
  991. else
  992. return ARMul_BUSY;
  993. }
  994. return ARMul_CANT;
  995. }
  996. static unsigned
  997. DoAFIQ (ARMul_State * state)
  998. {
  999. state->NfiqSig = LOW;
  1000. state->Exception++;
  1001. return 0;
  1002. }
  1003. static unsigned
  1004. DoAIRQ (ARMul_State * state)
  1005. {
  1006. state->NirqSig = LOW;
  1007. state->Exception++;
  1008. return 0;
  1009. }
  1010. static unsigned
  1011. IntCDP (ARMul_State * state, unsigned type, ARMword instr)
  1012. {
  1013. static unsigned long finish;
  1014. ARMword howlong;
  1015. howlong = ValReg[BITS (0, 3)];
  1016. switch ((int) BITS (20, 23))
  1017. {
  1018. case 0:
  1019. if (type == ARMul_FIRST)
  1020. {
  1021. /* First cycle of a busy wait. */
  1022. finish = ARMul_Time (state) + howlong;
  1023. return howlong == 0 ? ARMul_DONE : ARMul_BUSY;
  1024. }
  1025. else if (type == ARMul_BUSY)
  1026. {
  1027. if (ARMul_Time (state) >= finish)
  1028. return ARMul_DONE;
  1029. else
  1030. return ARMul_BUSY;
  1031. }
  1032. return ARMul_DONE;
  1033. case 1:
  1034. if (howlong == 0)
  1035. ARMul_Abort (state, ARMul_FIQV);
  1036. else
  1037. ARMul_ScheduleEvent (state, howlong, DoAFIQ);
  1038. return ARMul_DONE;
  1039. case 2:
  1040. if (howlong == 0)
  1041. ARMul_Abort (state, ARMul_IRQV);
  1042. else
  1043. ARMul_ScheduleEvent (state, howlong, DoAIRQ);
  1044. return ARMul_DONE;
  1045. case 3:
  1046. state->NfiqSig = HIGH;
  1047. state->Exception--;
  1048. return ARMul_DONE;
  1049. case 4:
  1050. state->NirqSig = HIGH;
  1051. state->Exception--;
  1052. return ARMul_DONE;
  1053. case 5:
  1054. ValReg[BITS (0, 3)] = ARMul_Time (state);
  1055. return ARMul_DONE;
  1056. }
  1057. return ARMul_CANT;
  1058. }
  1059. /* Install co-processor instruction handlers in this routine. */
  1060. unsigned
  1061. ARMul_CoProInit (ARMul_State * state)
  1062. {
  1063. unsigned int i;
  1064. /* Initialise tham all first. */
  1065. for (i = 0; i < 16; i++)
  1066. ARMul_CoProDetach (state, i);
  1067. /* Install CoPro Instruction handlers here.
  1068. The format is:
  1069. ARMul_CoProAttach (state, CP Number, Init routine, Exit routine
  1070. LDC routine, STC routine, MRC routine, MCR routine,
  1071. CDP routine, Read Reg routine, Write Reg routine). */
  1072. if (state->is_ep9312)
  1073. {
  1074. ARMul_CoProAttach (state, 4, NULL, NULL, DSPLDC4, DSPSTC4,
  1075. DSPMRC4, DSPMCR4, DSPCDP4, NULL, NULL);
  1076. ARMul_CoProAttach (state, 5, NULL, NULL, DSPLDC5, DSPSTC5,
  1077. DSPMRC5, DSPMCR5, DSPCDP5, NULL, NULL);
  1078. ARMul_CoProAttach (state, 6, NULL, NULL, NULL, NULL,
  1079. DSPMRC6, DSPMCR6, DSPCDP6, NULL, NULL);
  1080. }
  1081. else
  1082. {
  1083. ARMul_CoProAttach (state, 4, NULL, NULL, ValLDC, ValSTC,
  1084. ValMRC, ValMCR, ValCDP, NULL, NULL);
  1085. ARMul_CoProAttach (state, 5, NULL, NULL, NULL, NULL,
  1086. ValMRC, ValMCR, IntCDP, NULL, NULL);
  1087. }
  1088. if (state->is_XScale)
  1089. {
  1090. ARMul_CoProAttach (state, 13, XScale_cp13_init, NULL,
  1091. XScale_cp13_LDC, XScale_cp13_STC, XScale_cp13_MRC,
  1092. XScale_cp13_MCR, NULL, XScale_cp13_read_reg,
  1093. XScale_cp13_write_reg);
  1094. ARMul_CoProAttach (state, 14, XScale_cp14_init, NULL,
  1095. XScale_cp14_LDC, XScale_cp14_STC, XScale_cp14_MRC,
  1096. XScale_cp14_MCR, NULL, XScale_cp14_read_reg,
  1097. XScale_cp14_write_reg);
  1098. ARMul_CoProAttach (state, 15, XScale_cp15_init, NULL,
  1099. NULL, NULL, XScale_cp15_MRC, XScale_cp15_MCR,
  1100. NULL, XScale_cp15_read_reg, XScale_cp15_write_reg);
  1101. }
  1102. else
  1103. {
  1104. ARMul_CoProAttach (state, 15, MMUInit, NULL, NULL, NULL,
  1105. MMUMRC, MMUMCR, NULL, MMURead, MMUWrite);
  1106. }
  1107. if (state->is_iWMMXt)
  1108. {
  1109. ARMul_CoProAttach (state, 0, NULL, NULL, IwmmxtLDC, IwmmxtSTC,
  1110. NULL, NULL, IwmmxtCDP, NULL, NULL);
  1111. ARMul_CoProAttach (state, 1, NULL, NULL, NULL, NULL,
  1112. IwmmxtMRC, IwmmxtMCR, IwmmxtCDP, NULL, NULL);
  1113. }
  1114. /* No handlers below here. */
  1115. /* Call all the initialisation routines. */
  1116. for (i = 0; i < 16; i++)
  1117. if (state->CPInit[i])
  1118. (state->CPInit[i]) (state);
  1119. return TRUE;
  1120. }
  1121. /* Install co-processor finalisation routines in this routine. */
  1122. void
  1123. ARMul_CoProExit (ARMul_State * state)
  1124. {
  1125. register unsigned i;
  1126. for (i = 0; i < 16; i++)
  1127. if (state->CPExit[i])
  1128. (state->CPExit[i]) (state);
  1129. for (i = 0; i < 16; i++) /* Detach all handlers. */
  1130. ARMul_CoProDetach (state, i);
  1131. }
  1132. /* Routines to hook Co-processors into ARMulator. */
  1133. void
  1134. ARMul_CoProAttach (ARMul_State * state,
  1135. unsigned number,
  1136. ARMul_CPInits * init,
  1137. ARMul_CPExits * exit,
  1138. ARMul_LDCs * ldc,
  1139. ARMul_STCs * stc,
  1140. ARMul_MRCs * mrc,
  1141. ARMul_MCRs * mcr,
  1142. ARMul_CDPs * cdp,
  1143. ARMul_CPReads * read,
  1144. ARMul_CPWrites * write)
  1145. {
  1146. if (init != NULL)
  1147. state->CPInit[number] = init;
  1148. if (exit != NULL)
  1149. state->CPExit[number] = exit;
  1150. if (ldc != NULL)
  1151. state->LDC[number] = ldc;
  1152. if (stc != NULL)
  1153. state->STC[number] = stc;
  1154. if (mrc != NULL)
  1155. state->MRC[number] = mrc;
  1156. if (mcr != NULL)
  1157. state->MCR[number] = mcr;
  1158. if (cdp != NULL)
  1159. state->CDP[number] = cdp;
  1160. if (read != NULL)
  1161. state->CPRead[number] = read;
  1162. if (write != NULL)
  1163. state->CPWrite[number] = write;
  1164. }
  1165. void
  1166. ARMul_CoProDetach (ARMul_State * state, unsigned number)
  1167. {
  1168. ARMul_CoProAttach (state, number, NULL, NULL,
  1169. NoCoPro4R, NoCoPro4W, NoCoPro4W, NoCoPro4R,
  1170. NoCoPro3R, NULL, NULL);
  1171. state->CPInit[number] = NULL;
  1172. state->CPExit[number] = NULL;
  1173. state->CPRead[number] = NULL;
  1174. state->CPWrite[number] = NULL;
  1175. }