Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6449 lines
222 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // IA64 machine implementation.
  4. //
  5. // Copyright (C) Microsoft Corporation, 2000-2002.
  6. // Copyright (C) Intel Corporation, 1995.
  7. //
  8. //----------------------------------------------------------------------------
  9. #include "ntsdp.hpp"
  10. #include "ia64_dis.h"
  11. //
  12. // Define saved register masks.
  13. //
  14. #define SAVED_FLOATING_MASK 0xfff00000 // saved floating registers
  15. #define SAVED_INTEGER_MASK 0xf3ffff02 // saved integer registers
  16. //
  17. // Number of Data Breakpoints available under IA64
  18. //
  19. // XXX olegk - increase to 4 in future
  20. // (and then remove appropriate check at MapDbgSlotIa64ToX86)
  21. #define IA64_REG_MAX_DATA_BREAKPOINTS 2
  22. //
  23. // This parallels ntreg.h. Symbol assignment models ksia64.h
  24. //
  25. CHAR szDBI0[] = "dbi0";
  26. CHAR szDBI1[] = "dbi1";
  27. CHAR szDBI2[] = "dbi2";
  28. CHAR szDBI3[] = "dbi3";
  29. CHAR szDBI4[] = "dbi4";
  30. CHAR szDBI5[] = "dbi5";
  31. CHAR szDBI6[] = "dbi6";
  32. CHAR szDBI7[] = "dbi7";
  33. CHAR szDBD0[] = "dbd0";
  34. CHAR szDBD1[] = "dbd1";
  35. CHAR szDBD2[] = "dbd2";
  36. CHAR szDBD3[] = "dbd3";
  37. CHAR szDBD4[] = "dbd4";
  38. CHAR szDBD5[] = "dbd5";
  39. CHAR szDBD6[] = "dbd6";
  40. CHAR szDBD7[] = "dbd7";
  41. CHAR szF32[] = "f32"; // High floating point temporary (scratch) registers
  42. CHAR szF33[] = "f33";
  43. CHAR szF34[] = "f34";
  44. CHAR szF35[] = "f35";
  45. CHAR szF36[] = "f36";
  46. CHAR szF37[] = "f37";
  47. CHAR szF38[] = "f38";
  48. CHAR szF39[] = "f39";
  49. CHAR szF40[] = "f40";
  50. CHAR szF41[] = "f41";
  51. CHAR szF42[] = "f42";
  52. CHAR szF43[] = "f43";
  53. CHAR szF44[] = "f44";
  54. CHAR szF45[] = "f45";
  55. CHAR szF46[] = "f46";
  56. CHAR szF47[] = "f47";
  57. CHAR szF48[] = "f48";
  58. CHAR szF49[] = "f49";
  59. CHAR szF50[] = "f50";
  60. CHAR szF51[] = "f51";
  61. CHAR szF52[] = "f52";
  62. CHAR szF53[] = "f53";
  63. CHAR szF54[] = "f54";
  64. CHAR szF55[] = "f55";
  65. CHAR szF56[] = "f56";
  66. CHAR szF57[] = "f57";
  67. CHAR szF58[] = "f58";
  68. CHAR szF59[] = "f59";
  69. CHAR szF60[] = "f60";
  70. CHAR szF61[] = "f61";
  71. CHAR szF62[] = "f62";
  72. CHAR szF63[] = "f63";
  73. CHAR szF64[] = "f64";
  74. CHAR szF65[] = "f65";
  75. CHAR szF66[] = "f66";
  76. CHAR szF67[] = "f67";
  77. CHAR szF68[] = "f68";
  78. CHAR szF69[] = "f69";
  79. CHAR szF70[] = "f70";
  80. CHAR szF71[] = "f71";
  81. CHAR szF72[] = "f72";
  82. CHAR szF73[] = "f73";
  83. CHAR szF74[] = "f74";
  84. CHAR szF75[] = "f75";
  85. CHAR szF76[] = "f76";
  86. CHAR szF77[] = "f77";
  87. CHAR szF78[] = "f78";
  88. CHAR szF79[] = "f79";
  89. CHAR szF80[] = "f80";
  90. CHAR szF81[] = "f81";
  91. CHAR szF82[] = "f82";
  92. CHAR szF83[] = "f83";
  93. CHAR szF84[] = "f84";
  94. CHAR szF85[] = "f85";
  95. CHAR szF86[] = "f86";
  96. CHAR szF87[] = "f87";
  97. CHAR szF88[] = "f88";
  98. CHAR szF89[] = "f89";
  99. CHAR szF90[] = "f90";
  100. CHAR szF91[] = "f91";
  101. CHAR szF92[] = "f92";
  102. CHAR szF93[] = "f93";
  103. CHAR szF94[] = "f94";
  104. CHAR szF95[] = "f95";
  105. CHAR szF96[] = "f96";
  106. CHAR szF97[] = "f97";
  107. CHAR szF98[] = "f98";
  108. CHAR szF99[] = "f99";
  109. CHAR szF100[] = "f100";
  110. CHAR szF101[] = "f101";
  111. CHAR szF102[] = "f102";
  112. CHAR szF103[] = "f103";
  113. CHAR szF104[] = "f104";
  114. CHAR szF105[] = "f105";
  115. CHAR szF106[] = "f106";
  116. CHAR szF107[] = "f107";
  117. CHAR szF108[] = "f108";
  118. CHAR szF109[] = "f109";
  119. CHAR szF110[] = "f110";
  120. CHAR szF111[] = "f111";
  121. CHAR szF112[] = "f112";
  122. CHAR szF113[] = "f113";
  123. CHAR szF114[] = "f114";
  124. CHAR szF115[] = "f115";
  125. CHAR szF116[] = "f116";
  126. CHAR szF117[] = "f117";
  127. CHAR szF118[] = "f118";
  128. CHAR szF119[] = "f119";
  129. CHAR szF120[] = "f120";
  130. CHAR szF121[] = "f121";
  131. CHAR szF122[] = "f122";
  132. CHAR szF123[] = "f123";
  133. CHAR szF124[] = "f124";
  134. CHAR szF125[] = "f125";
  135. CHAR szF126[] = "f126";
  136. CHAR szF127[] = "f127";
  137. CHAR szFPSR[] = "fpsr";
  138. CHAR szFSR[] = "fsr";
  139. CHAR szFIR[] = "fir";
  140. CHAR szFDR[] = "fdr";
  141. CHAR szFCR[] = "fcr";
  142. CHAR szGP[] = "gp"; // global pointer
  143. CHAR szSP[] = "sp"; // stack pointer
  144. CHAR szR32[] = "r32";
  145. CHAR szR33[] = "r33";
  146. CHAR szR34[] = "r34";
  147. CHAR szR35[] = "r35";
  148. CHAR szR36[] = "r36";
  149. CHAR szR37[] = "r37";
  150. CHAR szR38[] = "r38";
  151. CHAR szR39[] = "r39";
  152. CHAR szR40[] = "r40";
  153. CHAR szR41[] = "r41";
  154. CHAR szR42[] = "r42";
  155. CHAR szR43[] = "r43";
  156. CHAR szR44[] = "r44";
  157. CHAR szR45[] = "r45";
  158. CHAR szR46[] = "r46";
  159. CHAR szR47[] = "r47";
  160. CHAR szR48[] = "r48";
  161. CHAR szR49[] = "r49";
  162. CHAR szR50[] = "r50";
  163. CHAR szR51[] = "r51";
  164. CHAR szR52[] = "r52";
  165. CHAR szR53[] = "r53";
  166. CHAR szR54[] = "r54";
  167. CHAR szR55[] = "r55";
  168. CHAR szR56[] = "r56";
  169. CHAR szR57[] = "r57";
  170. CHAR szR58[] = "r58";
  171. CHAR szR59[] = "r59";
  172. CHAR szR60[] = "r60";
  173. CHAR szR61[] = "r61";
  174. CHAR szR62[] = "r62";
  175. CHAR szR63[] = "r63";
  176. CHAR szR64[] = "r64";
  177. CHAR szR65[] = "r65";
  178. CHAR szR66[] = "r66";
  179. CHAR szR67[] = "r67";
  180. CHAR szR68[] = "r68";
  181. CHAR szR69[] = "r69";
  182. CHAR szR70[] = "r70";
  183. CHAR szR71[] = "r71";
  184. CHAR szR72[] = "r72";
  185. CHAR szR73[] = "r73";
  186. CHAR szR74[] = "r74";
  187. CHAR szR75[] = "r75";
  188. CHAR szR76[] = "r76";
  189. CHAR szR77[] = "r77";
  190. CHAR szR78[] = "r78";
  191. CHAR szR79[] = "r79";
  192. CHAR szR80[] = "r80";
  193. CHAR szR81[] = "r81";
  194. CHAR szR82[] = "r82";
  195. CHAR szR83[] = "r83";
  196. CHAR szR84[] = "r84";
  197. CHAR szR85[] = "r85";
  198. CHAR szR86[] = "r86";
  199. CHAR szR87[] = "r87";
  200. CHAR szR88[] = "r88";
  201. CHAR szR89[] = "r89";
  202. CHAR szR90[] = "r90";
  203. CHAR szR91[] = "r91";
  204. CHAR szR92[] = "r92";
  205. CHAR szR93[] = "r93";
  206. CHAR szR94[] = "r94";
  207. CHAR szR95[] = "r95";
  208. CHAR szR96[] = "r96";
  209. CHAR szR97[] = "r97";
  210. CHAR szR98[] = "r98";
  211. CHAR szR99[] = "r99";
  212. CHAR szR100[] = "r100";
  213. CHAR szR101[] = "r101";
  214. CHAR szR102[] = "r102";
  215. CHAR szR103[] = "r103";
  216. CHAR szR104[] = "r104";
  217. CHAR szR105[] = "r105";
  218. CHAR szR106[] = "r106";
  219. CHAR szR107[] = "r107";
  220. CHAR szR108[] = "r108";
  221. CHAR szR109[] = "r109";
  222. CHAR szR110[] = "r110";
  223. CHAR szR111[] = "r111";
  224. CHAR szR112[] = "r112";
  225. CHAR szR113[] = "r113";
  226. CHAR szR114[] = "r114";
  227. CHAR szR115[] = "r115";
  228. CHAR szR116[] = "r116";
  229. CHAR szR117[] = "r117";
  230. CHAR szR118[] = "r118";
  231. CHAR szR119[] = "r119";
  232. CHAR szR120[] = "r120";
  233. CHAR szR121[] = "r121";
  234. CHAR szR122[] = "r122";
  235. CHAR szR123[] = "r123";
  236. CHAR szR124[] = "r124";
  237. CHAR szR125[] = "r125";
  238. CHAR szR126[] = "r126";
  239. CHAR szR127[] = "r127";
  240. CHAR szINTNATS[] = "intnats";
  241. CHAR szPREDS[] = "preds";
  242. CHAR szB0[] = "b0"; // branch return pointer
  243. CHAR szB1[] = "b1"; // branch saved (preserved)
  244. CHAR szB2[] = "b2";
  245. CHAR szB3[] = "b3";
  246. CHAR szB4[] = "b4";
  247. CHAR szB5[] = "b5";
  248. CHAR szB6[] = "b6"; // branch temporary (scratch) registers
  249. CHAR szB7[] = "b7";
  250. CHAR szCSD[] = "csd"; // iA32 CS descriptor
  251. CHAR szSSD[] = "ssd"; // iA32 SS descriptor
  252. CHAR szAPUNAT[] = "unat";
  253. CHAR szAPLC[] = "lc";
  254. CHAR szAPEC[] = "ec";
  255. CHAR szAPCCV[] = "ccv";
  256. CHAR szAPDCR[] = "dcr";
  257. CHAR szRSPFS[] = "pfs";
  258. CHAR szRSBSP[] = "bsp";
  259. CHAR szRSBSPSTORE[] = "bspstore";
  260. CHAR szRSRSC[] = "rsc";
  261. CHAR szRSRNAT[] = "rnat";
  262. CHAR szEFLAG[] = "eflag"; // iA32 Eflag
  263. CHAR szCFLAG[] = "cflag"; // iA32 Cflag
  264. CHAR szSTIPSR[] = "ipsr";
  265. CHAR szSTIIP[] = "iip";
  266. CHAR szSTIFS[] = "ifs";
  267. CHAR szKDBI0[] = "kdbi0";
  268. CHAR szKDBI1[] = "kdbi1";
  269. CHAR szKDBI2[] = "kdbi2";
  270. CHAR szKDBI3[] = "kdbi3";
  271. CHAR szKDBI4[] = "kdbi4";
  272. CHAR szKDBI5[] = "kdbi5";
  273. CHAR szKDBI6[] = "kdbi6";
  274. CHAR szKDBI7[] = "kdbi7";
  275. CHAR szKDBD0[] = "kdbd0";
  276. CHAR szKDBD1[] = "kdbd1";
  277. CHAR szKDBD2[] = "kdbd2";
  278. CHAR szKDBD3[] = "kdbd3";
  279. CHAR szKDBD4[] = "kdbd4";
  280. CHAR szKDBD5[] = "kdbd5";
  281. CHAR szKDBD6[] = "kdbd6";
  282. CHAR szKDBD7[] = "kdbd7";
  283. CHAR szKPFC0[] = "kpfc0";
  284. CHAR szKPFC1[] = "kpfc1";
  285. CHAR szKPFC2[] = "kpfc2";
  286. CHAR szKPFC3[] = "kpfc3";
  287. CHAR szKPFC4[] = "kpfc4";
  288. CHAR szKPFC5[] = "kpfc5";
  289. CHAR szKPFC6[] = "kpfc6";
  290. CHAR szKPFC7[] = "kpfc7";
  291. CHAR szKPFD0[] = "kpfd0";
  292. CHAR szKPFD1[] = "kpfd1";
  293. CHAR szKPFD2[] = "kpfd2";
  294. CHAR szKPFD3[] = "kpfd3";
  295. CHAR szKPFD4[] = "kpfd4";
  296. CHAR szKPFD5[] = "kpfd5";
  297. CHAR szKPFD6[] = "kpfd6";
  298. CHAR szKPFD7[] = "kpfd7";
  299. CHAR szH16[] = "h16"; // kernel bank shadow (hidden) registers
  300. CHAR szH17[] = "h17";
  301. CHAR szH18[] = "h18";
  302. CHAR szH19[] = "h19";
  303. CHAR szH20[] = "h20";
  304. CHAR szH21[] = "h21";
  305. CHAR szH22[] = "h22";
  306. CHAR szH23[] = "h23";
  307. CHAR szH24[] = "h24";
  308. CHAR szH25[] = "h25";
  309. CHAR szH26[] = "h26";
  310. CHAR szH27[] = "h27";
  311. CHAR szH28[] = "h28";
  312. CHAR szH29[] = "h29";
  313. CHAR szH30[] = "h30";
  314. CHAR szH31[] = "h31";
  315. CHAR szACPUID0[] = "cpuid0";
  316. CHAR szACPUID1[] = "cpuid1";
  317. CHAR szACPUID2[] = "cpuid2";
  318. CHAR szACPUID3[] = "cpuid3";
  319. CHAR szACPUID4[] = "cpuid4";
  320. CHAR szACPUID5[] = "cpuid5";
  321. CHAR szACPUID6[] = "cpuid6";
  322. CHAR szACPUID7[] = "cpuid7";
  323. CHAR szAPKR0[] = "kr0";
  324. CHAR szAPKR1[] = "kr1";
  325. CHAR szAPKR2[] = "kr2";
  326. CHAR szAPKR3[] = "kr3";
  327. CHAR szAPKR4[] = "kr4";
  328. CHAR szAPKR5[] = "kr5";
  329. CHAR szAPKR6[] = "kr6";
  330. CHAR szAPKR7[] = "kr7";
  331. CHAR szAPITC[] = "itc";
  332. CHAR szAPITM[] = "itm";
  333. CHAR szAPIVA[] = "iva";
  334. CHAR szAPPTA[] = "pta";
  335. CHAR szAPGPTA[] = "apgta";
  336. CHAR szSTISR[] = "isr";
  337. CHAR szSTIDA[] = "ifa";
  338. CHAR szSTIDTR[] = "idtr";
  339. CHAR szSTIITR[] = "itir";
  340. CHAR szSTIIPA[] = "iipa";
  341. CHAR szSTIIM[] = "iim";
  342. CHAR szSTIHA[] = "iha";
  343. CHAR szSALID[] = "lid";
  344. CHAR szSAIVR[] = "ivr";
  345. CHAR szSATPR[] = "tpr";
  346. CHAR szSAEOI[] = "eoi";
  347. CHAR szSAIRR0[] = "irr0";
  348. CHAR szSAIRR1[] = "irr1";
  349. CHAR szSAIRR2[] = "irr2";
  350. CHAR szSAIRR3[] = "irr3";
  351. CHAR szSAITV[] = "itv";
  352. CHAR szSAPMV[] = "pmv";
  353. CHAR szSALRR0[] = "lrr0";
  354. CHAR szSALRR1[] = "lrr1";
  355. CHAR szSACMCV[] = "cmcv";
  356. CHAR szRR0[] = "rr0";
  357. CHAR szRR1[] = "rr1";
  358. CHAR szRR2[] = "rr2";
  359. CHAR szRR3[] = "rr3";
  360. CHAR szRR4[] = "rr4";
  361. CHAR szRR5[] = "rr5";
  362. CHAR szRR6[] = "rr6";
  363. CHAR szRR7[] = "rr7";
  364. CHAR szPKR0[] = "pkr0";
  365. CHAR szPKR1[] = "pkr1";
  366. CHAR szPKR2[] = "pkr2";
  367. CHAR szPKR3[] = "pkr3";
  368. CHAR szPKR4[] = "pkr4";
  369. CHAR szPKR5[] = "pkr5";
  370. CHAR szPKR6[] = "pkr6";
  371. CHAR szPKR7[] = "pkr7";
  372. CHAR szPKR8[] = "pkr8";
  373. CHAR szPKR9[] = "pkr9";
  374. CHAR szPKR10[] = "pkr10";
  375. CHAR szPKR11[] = "pkr11";
  376. CHAR szPKR12[] = "pkr12";
  377. CHAR szPKR13[] = "pkr13";
  378. CHAR szPKR14[] = "pkr14";
  379. CHAR szPKR15[] = "pkr15";
  380. CHAR szTRI0[] = "tri0";
  381. CHAR szTRI1[] = "tri1";
  382. CHAR szTRI2[] = "tri2";
  383. CHAR szTRI3[] = "tri3";
  384. CHAR szTRI4[] = "tri4";
  385. CHAR szTRI5[] = "tri5";
  386. CHAR szTRI6[] = "tri6";
  387. CHAR szTRI7[] = "tri7";
  388. CHAR szTRD0[] = "trd0";
  389. CHAR szTRD1[] = "trd1";
  390. CHAR szTRD2[] = "trd2";
  391. CHAR szTRD3[] = "trd3";
  392. CHAR szTRD4[] = "trd4";
  393. CHAR szTRD5[] = "trd5";
  394. CHAR szTRD6[] = "trd6";
  395. CHAR szTRD7[] = "trd7";
  396. CHAR szSMSR0[] = "SMSR0";
  397. CHAR szSMSR1[] = "SMSR1";
  398. CHAR szSMSR2[] = "SMSR2";
  399. CHAR szSMSR3[] = "SMSR3";
  400. CHAR szSMSR4[] = "SMSR4";
  401. CHAR szSMSR5[] = "SMSR5";
  402. CHAR szSMSR6[] = "SMSR6";
  403. CHAR szSMSR7[] = "SMSR7";
  404. // IPSR flags
  405. CHAR szIPSRBN[] = "ipsr.bn";
  406. CHAR szIPSRED[] = "ipsr.ed";
  407. CHAR szIPSRRI[] = "ipsr.ri";
  408. CHAR szIPSRSS[] = "ipsr.ss";
  409. CHAR szIPSRDD[] = "ipsr.dd";
  410. CHAR szIPSRDA[] = "ipsr.da";
  411. CHAR szIPSRID[] = "ipsr.id";
  412. CHAR szIPSRIT[] = "ipsr.it";
  413. CHAR szIPSRME[] = "ipsr.me";
  414. CHAR szIPSRIS[] = "ipsr.is";
  415. CHAR szIPSRCPL[] = "ipsr.cpl";
  416. CHAR szIPSRRT[] = "ipsr.rt";
  417. CHAR szIPSRTB[] = "ipsr.tb";
  418. CHAR szIPSRLP[] = "ipsr.lp";
  419. CHAR szIPSRDB[] = "ipsr.db";
  420. CHAR szIPSRSI[] = "ipsr.si";
  421. CHAR szIPSRDI[] = "ipsr.di";
  422. CHAR szIPSRPP[] = "ipsr.pp";
  423. CHAR szIPSRSP[] = "ipsr.sp";
  424. CHAR szIPSRDFH[] = "ipsr.dfh";
  425. CHAR szIPSRDFL[] = "ipsr.dfl";
  426. CHAR szIPSRDT[] = "ipsr.dt";
  427. CHAR szIPSRPK[] = "ipsr.pk";
  428. CHAR szIPSRI[] = "ipsr.i";
  429. CHAR szIPSRIC[] = "ipsr.ic";
  430. CHAR szIPSRAC[] = "ipsr.ac";
  431. CHAR szIPSRUP[] = "ipsr.up";
  432. CHAR szIPSRBE[] = "ipsr.be";
  433. CHAR szIPSROR[] = "ipsr.or";
  434. // FPSR flags
  435. CHAR szFPSRMDH[] = "fpsr.mdh";
  436. CHAR szFPSRMDL[] = "fpsr.mdl";
  437. CHAR szFPSRSF3[] = "fpsr.sf3";
  438. CHAR szFPSRSF2[] = "fpsr.sf2";
  439. CHAR szFPSRSF1[] = "fpsr.sf1";
  440. CHAR szFPSRSF0[] = "fpsr.sf0";
  441. CHAR szFPSRTRAPID[] = "fpsr.id";
  442. CHAR szFPSRTRAPUD[] = "fpsr.ud";
  443. CHAR szFPSRTRAPOD[] = "fpsr.od";
  444. CHAR szFPSRTRAPZD[] = "fpsr.zd";
  445. CHAR szFPSRTRAPDD[] = "fpsr.dd";
  446. CHAR szFPSRTRAPVD[] = "fpsr.vd";
  447. // Predicate registers
  448. //CHAR szPR0[] = "p0";
  449. CHAR szPR1[] = "p1";
  450. CHAR szPR2[] = "p2";
  451. CHAR szPR3[] = "p3";
  452. CHAR szPR4[] = "p4";
  453. CHAR szPR5[] = "p5";
  454. CHAR szPR6[] = "p6";
  455. CHAR szPR7[] = "p7";
  456. CHAR szPR8[] = "p8";
  457. CHAR szPR9[] = "p9";
  458. CHAR szPR10[] = "p10";
  459. CHAR szPR11[] = "p11";
  460. CHAR szPR12[] = "p12";
  461. CHAR szPR13[] = "p13";
  462. CHAR szPR14[] = "p14";
  463. CHAR szPR15[] = "p15";
  464. CHAR szPR16[] = "p16";
  465. CHAR szPR17[] = "p17";
  466. CHAR szPR18[] = "p18";
  467. CHAR szPR19[] = "p19";
  468. CHAR szPR20[] = "p20";
  469. CHAR szPR21[] = "p21";
  470. CHAR szPR22[] = "p22";
  471. CHAR szPR23[] = "p23";
  472. CHAR szPR24[] = "p24";
  473. CHAR szPR25[] = "p25";
  474. CHAR szPR26[] = "p26";
  475. CHAR szPR27[] = "p27";
  476. CHAR szPR28[] = "p28";
  477. CHAR szPR29[] = "p29";
  478. CHAR szPR30[] = "p30";
  479. CHAR szPR31[] = "p31";
  480. CHAR szPR32[] = "p32";
  481. CHAR szPR33[] = "p33";
  482. CHAR szPR34[] = "p34";
  483. CHAR szPR35[] = "p35";
  484. CHAR szPR36[] = "p36";
  485. CHAR szPR37[] = "p37";
  486. CHAR szPR38[] = "p38";
  487. CHAR szPR39[] = "p39";
  488. CHAR szPR40[] = "p40";
  489. CHAR szPR41[] = "p41";
  490. CHAR szPR42[] = "p42";
  491. CHAR szPR43[] = "p43";
  492. CHAR szPR44[] = "p44";
  493. CHAR szPR45[] = "p45";
  494. CHAR szPR46[] = "p46";
  495. CHAR szPR47[] = "p47";
  496. CHAR szPR48[] = "p48";
  497. CHAR szPR49[] = "p49";
  498. CHAR szPR50[] = "p50";
  499. CHAR szPR51[] = "p51";
  500. CHAR szPR52[] = "p52";
  501. CHAR szPR53[] = "p53";
  502. CHAR szPR54[] = "p54";
  503. CHAR szPR55[] = "p55";
  504. CHAR szPR56[] = "p56";
  505. CHAR szPR57[] = "p57";
  506. CHAR szPR58[] = "p58";
  507. CHAR szPR59[] = "p59";
  508. CHAR szPR60[] = "p60";
  509. CHAR szPR61[] = "p61";
  510. CHAR szPR62[] = "p62";
  511. CHAR szPR63[] = "p63";
  512. // Aliases: allow aliases to general purpose registers that are
  513. // known by more than one name, eg r12 = rsp.
  514. CHAR szR1GP[] = "r1";
  515. CHAR szR12SP[] = "r12";
  516. CHAR szRA[] = "ra";
  517. CHAR szRP[] = "rp";
  518. CHAR szRET0[] = "ret0";
  519. CHAR szRET1[] = "ret1";
  520. CHAR szRET2[] = "ret2";
  521. CHAR szRET3[] = "ret3";
  522. CHAR szFARG0[] = "farg0";
  523. CHAR szFARG1[] = "farg1";
  524. CHAR szFARG2[] = "farg2";
  525. CHAR szFARG3[] = "farg3";
  526. CHAR szFARG4[] = "farg4";
  527. CHAR szFARG5[] = "farg5";
  528. CHAR szFARG6[] = "farg6";
  529. CHAR szFARG7[] = "farg7";
  530. REGDEF IA64Regs[] =
  531. {
  532. szDBI0, REGDBI0, szDBI1, REGDBI1, szDBI2, REGDBI2, szDBI3, REGDBI3,
  533. szDBI4, REGDBI4, szDBI5, REGDBI5, szDBI6, REGDBI6, szDBI7, REGDBI7,
  534. szDBD0, REGDBD0, szDBD1, REGDBD1, szDBD2, REGDBD2, szDBD3, REGDBD3,
  535. szDBD4, REGDBD4, szDBD5, REGDBD5, szDBD6, REGDBD6, szDBD7, REGDBD7,
  536. // g_F0, FLTZERO, g_F1, FLTONE,
  537. g_F2, FLTS0, g_F3, FLTS1,
  538. g_F4, FLTS2, g_F5, FLTS3, g_F6, FLTT0, g_F7, FLTT1,
  539. g_F8, FLTT2, g_F9, FLTT3, g_F10, FLTT4, g_F11, FLTT5,
  540. g_F12, FLTT6, g_F13, FLTT7, g_F14, FLTT8, g_F15, FLTT9,
  541. g_F16, FLTS4, g_F17, FLTS5, g_F18, FLTS6, g_F19, FLTS7,
  542. g_F20, FLTS8, g_F21, FLTS9, g_F22, FLTS10, g_F23, FLTS11,
  543. g_F24, FLTS12, g_F25, FLTS13, g_F26, FLTS14, g_F27, FLTS15,
  544. g_F28, FLTS16, g_F29, FLTS17, g_F30, FLTS18, g_F31, FLTS19,
  545. szF32, FLTF32, szF33, FLTF33, szF34, FLTF34, szF35, FLTF35,
  546. szF36, FLTF36, szF37, FLTF37, szF38, FLTF38, szF39, FLTF39,
  547. szF40, FLTF40, szF41, FLTF41, szF42, FLTF42, szF43, FLTF43,
  548. szF44, FLTF44, szF45, FLTF45, szF46, FLTF46, szF47, FLTF47,
  549. szF48, FLTF48, szF49, FLTF49, szF50, FLTF50, szF51, FLTF51,
  550. szF52, FLTF52, szF53, FLTF53, szF54, FLTF54, szF55, FLTF55,
  551. szF56, FLTF56, szF57, FLTF57, szF58, FLTF58, szF59, FLTF59,
  552. szF60, FLTF60, szF61, FLTF61, szF62, FLTF62, szF63, FLTF63,
  553. szF64, FLTF64, szF65, FLTF65, szF66, FLTF66, szF67, FLTF67,
  554. szF68, FLTF68, szF69, FLTF69, szF70, FLTF70, szF71, FLTF71,
  555. szF72, FLTF72, szF73, FLTF73, szF74, FLTF74, szF75, FLTF75,
  556. szF76, FLTF76, szF77, FLTF77, szF78, FLTF78, szF79, FLTF79,
  557. szF80, FLTF80, szF81, FLTF81, szF82, FLTF82, szF83, FLTF83,
  558. szF84, FLTF84, szF85, FLTF85, szF86, FLTF86, szF87, FLTF87,
  559. szF88, FLTF88, szF89, FLTF89, szF90, FLTF90, szF91, FLTF91,
  560. szF92, FLTF92, szF93, FLTF93, szF94, FLTF94, szF95, FLTF95,
  561. szF96, FLTF96, szF97, FLTF97, szF98, FLTF98, szF99, FLTF99,
  562. szF100, FLTF100, szF101, FLTF101, szF102, FLTF102, szF103, FLTF103,
  563. szF104, FLTF104, szF105, FLTF105, szF106, FLTF106, szF107, FLTF107,
  564. szF108, FLTF108, szF109, FLTF109, szF110, FLTF110, szF111, FLTF111,
  565. szF112, FLTF112, szF113, FLTF113, szF114, FLTF114, szF115, FLTF115,
  566. szF116, FLTF116, szF117, FLTF117, szF118, FLTF118, szF119, FLTF119,
  567. szF120, FLTF120, szF121, FLTF121, szF122, FLTF122, szF123, FLTF123,
  568. szF124, FLTF124, szF125, FLTF125, szF126, FLTF126, szF127, FLTF127,
  569. szFPSR, STFPSR,
  570. // g_R0, INTZERO,
  571. szGP, INTGP, g_R2, INTT0, g_R3, INTT1,
  572. g_R4, INTS0, g_R5, INTS1, g_R6, INTS2, g_R7, INTS3,
  573. g_R8, INTV0, g_R9, INTT2, g_R10, INTT3, g_R11, INTT4,
  574. szSP, INTSP, g_R13, INTTEB, g_R14, INTT5, g_R15, INTT6,
  575. g_R16, INTT7, g_R17, INTT8, g_R18, INTT9, g_R19, INTT10,
  576. g_R20, INTT11, g_R21, INTT12, g_R22, INTT13, g_R23, INTT14,
  577. g_R24, INTT15, g_R25, INTT16, g_R26, INTT17, g_R27, INTT18,
  578. g_R28, INTT19, g_R29, INTT20, g_R30, INTT21, g_R31, INTT22,
  579. szINTNATS, INTNATS,
  580. szR32, INTR32, szR33, INTR33, szR34, INTR34, szR35, INTR35,
  581. szR36, INTR36, szR37, INTR37, szR38, INTR38, szR39, INTR39,
  582. szR40, INTR40, szR41, INTR41, szR42, INTR42, szR42, INTR42,
  583. szR43, INTR43, szR44, INTR44, szR45, INTR45, szR46, INTR46,
  584. szR47, INTR47, szR48, INTR48, szR49, INTR49, szR50, INTR50,
  585. szR51, INTR51, szR52, INTR52, szR53, INTR53, szR54, INTR54,
  586. szR55, INTR55, szR56, INTR56, szR57, INTR57, szR58, INTR58,
  587. szR59, INTR59, szR60, INTR60, szR61, INTR61, szR62, INTR62,
  588. szR63, INTR63, szR64, INTR64, szR65, INTR65, szR66, INTR66,
  589. szR67, INTR67, szR68, INTR68, szR69, INTR69, szR70, INTR70,
  590. szR71, INTR71, szR72, INTR72, szR73, INTR73, szR74, INTR74,
  591. szR75, INTR75, szR76, INTR76, szR77, INTR77, szR78, INTR78,
  592. szR79, INTR79, szR80, INTR80, szR81, INTR81, szR82, INTR82,
  593. szR83, INTR83, szR84, INTR84, szR85, INTR85, szR86, INTR86,
  594. szR87, INTR87, szR88, INTR88, szR89, INTR89, szR90, INTR90,
  595. szR91, INTR91, szR92, INTR92, szR93, INTR93, szR94, INTR94,
  596. szR95, INTR95, szR96, INTR96, szR97, INTR97, szR98, INTR98,
  597. szR99, INTR99, szR100, INTR100, szR101, INTR101, szR102, INTR102,
  598. szR103, INTR103, szR104, INTR104, szR105, INTR105, szR106, INTR106,
  599. szR107, INTR107, szR108, INTR108, szR109, INTR109, szR110, INTR110,
  600. szR111, INTR111, szR112, INTR112, szR113, INTR113, szR114, INTR114,
  601. szR115, INTR115, szR116, INTR116, szR117, INTR117, szR118, INTR118,
  602. szR119, INTR119, szR120, INTR120, szR121, INTR121, szR122, INTR122,
  603. szR123, INTR123, szR124, INTR124, szR125, INTR125, szR126, INTR126,
  604. szR127, INTR127,
  605. szPREDS, PREDS,
  606. szB0, BRRP, szB1, BRS0, szB2, BRS1, szB3, BRS2,
  607. szB4, BRS3, szB5, BRS4, szB6, BRT0, szB7, BRT1,
  608. szAPUNAT, APUNAT, szAPLC, APLC,
  609. szAPEC, APEC, szAPCCV, APCCV, szAPDCR, APDCR, szRSPFS, RSPFS,
  610. szRSBSP, RSBSP, szRSBSPSTORE, RSBSPSTORE, szRSRSC, RSRSC, szRSRNAT, RSRNAT,
  611. szSTIPSR, STIPSR, szSTIIP, STIIP, szSTIFS, STIFS,
  612. szFCR, StFCR,
  613. szEFLAG, Eflag,
  614. szCSD, SegCSD,
  615. szSSD, SegSSD,
  616. szCFLAG, Cflag,
  617. szFSR, STFSR,
  618. szFIR, STFIR,
  619. szFDR, STFDR,
  620. // IPSR flags
  621. szIPSRBN, IPSRBN,
  622. szIPSRED, IPSRED, szIPSRRI, IPSRRI, szIPSRSS, IPSRSS, szIPSRDD, IPSRDD,
  623. szIPSRDA, IPSRDA, szIPSRID, IPSRID, szIPSRIT, IPSRIT, szIPSRME, IPSRME,
  624. szIPSRIS, IPSRIS, szIPSRCPL, IPSRCPL, szIPSRRT, IPSRRT, szIPSRTB, IPSRTB,
  625. szIPSRLP, IPSRLP, szIPSRDB, IPSRDB, szIPSRSI, IPSRSI, szIPSRDI, IPSRDI,
  626. szIPSRPP, IPSRPP, szIPSRSP, IPSRSP, szIPSRDFH, IPSRDFH, szIPSRDFL, IPSRDFL,
  627. szIPSRDT, IPSRDT, szIPSRPK, IPSRPK, szIPSRI, IPSRI, szIPSRIC, IPSRIC,
  628. szIPSRAC, IPSRAC, szIPSRUP, IPSRUP, szIPSRBE, IPSRBE, szIPSROR, IPSROR,
  629. // FPSR flags
  630. szFPSRMDH, FPSRMDH, szFPSRMDL, FPSRMDL,
  631. szFPSRSF3, FPSRSF3, szFPSRSF2, FPSRSF2,
  632. szFPSRSF1, FPSRSF1, szFPSRSF0, FPSRSF0,
  633. szFPSRTRAPID, FPSRTRAPID, szFPSRTRAPUD, FPSRTRAPUD,
  634. szFPSRTRAPOD, FPSRTRAPOD, szFPSRTRAPZD, FPSRTRAPZD,
  635. szFPSRTRAPDD, FPSRTRAPDD, szFPSRTRAPVD, FPSRTRAPVD,
  636. // Predicate registers
  637. // szPR0, PR0,
  638. szPR1, PR1, szPR2, PR2, szPR3, PR3,
  639. szPR4, PR4, szPR5, PR5, szPR6, PR6, szPR7, PR7,
  640. szPR8, PR8, szPR9, PR9, szPR10, PR10, szPR11, PR11,
  641. szPR12, PR12, szPR13, PR13, szPR14, PR14, szPR15, PR15,
  642. szPR16, PR16, szPR17, PR17, szPR18, PR18, szPR19, PR19,
  643. szPR20, PR20, szPR21, PR21, szPR22, PR22, szPR23, PR23,
  644. szPR24, PR24, szPR25, PR25, szPR26, PR26, szPR27, PR27,
  645. szPR28, PR28, szPR29, PR29, szPR30, PR30, szPR31, PR31,
  646. szPR32, PR32, szPR33, PR33, szPR34, PR34, szPR35, PR35,
  647. szPR36, PR36, szPR37, PR37, szPR38, PR38, szPR39, PR39,
  648. szPR40, PR40, szPR41, PR41, szPR42, PR42, szPR43, PR43,
  649. szPR44, PR44, szPR45, PR45, szPR46, PR46, szPR47, PR47,
  650. szPR48, PR48, szPR49, PR49, szPR50, PR50, szPR51, PR51,
  651. szPR52, PR52, szPR53, PR53, szPR54, PR54, szPR55, PR55,
  652. szPR56, PR56, szPR57, PR57, szPR58, PR58, szPR59, PR59,
  653. szPR60, PR60, szPR61, PR61, szPR62, PR62, szPR63, PR63,
  654. // Aliases
  655. szR1GP, INTGP, szR12SP, INTSP, szRA, BRRP, szRP, BRRP,
  656. szRET0, INTV0, szRET1, INTT2, szRET2, INTT3, szRET3, INTT4,
  657. szFARG0, FLTT2, szFARG1, FLTT3, szFARG2, FLTT4, szFARG3, FLTT5,
  658. szFARG4, FLTT6, szFARG5, FLTT7, szFARG6, FLTT8, szFARG7, FLTT9,
  659. NULL, 0,
  660. };
  661. REGDEF g_Ia64KernelRegs[] =
  662. {
  663. szKDBI0, KRDBI0, szKDBI1, KRDBI1, szKDBI2, KRDBI2, szKDBI3, KRDBI3,
  664. szKDBI4, KRDBI4, szKDBI5, KRDBI5, szKDBI6, KRDBI6, szKDBI7, KRDBI7,
  665. szKDBD0, KRDBD0, szKDBD1, KRDBD1, szKDBD2, KRDBD2, szKDBD3, KRDBD3,
  666. szKDBD4, KRDBD4, szKDBD5, KRDBD5, szKDBD6, KRDBD6, szKDBD7, KRDBD7,
  667. szKPFC0, KRPFC0, szKPFC1, KRPFC1, szKPFC2, KRPFC2, szKPFC3, KRPFC3,
  668. szKPFC4, KRPFC4, szKPFC5, KRPFC5, szKPFC6, KRPFC6, szKPFC7, KRPFC7,
  669. szKPFD0, KRPFD0, szKPFD1, KRPFD1, szKPFD2, KRPFD2, szKPFD3, KRPFD3,
  670. szKPFD4, KRPFD4, szKPFD5, KRPFD5, szKPFD6, KRPFD6, szKPFD7, KRPFD7,
  671. szH16, INTH16, szH17, INTH17, szH18, INTH18, szH19, INTH19,
  672. szH20, INTH20, szH21, INTH21, szH22, INTH22, szH23, INTH23,
  673. szH24, INTH24, szH25, INTH25, szH26, INTH26, szH27, INTH27,
  674. szH28, INTH28, szH29, INTH29, szH30, INTH30, szH31, INTH31,
  675. szACPUID0, ACPUID0, szACPUID1, ACPUID1, szACPUID2, ACPUID2, szACPUID3, ACPUID3,
  676. szACPUID4, ACPUID4, szACPUID5, ACPUID5, szACPUID6, ACPUID6, szACPUID7, ACPUID7,
  677. szAPKR0, APKR0, szAPKR1, APKR1, szAPKR2, APKR2, szAPKR3, APKR3,
  678. szAPKR4, APKR4, szAPKR5, APKR5, szAPKR6, APKR6, szAPKR7, APKR7,
  679. szAPITC, APITC, szAPITM, APITM, szAPIVA, APIVA,
  680. szAPPTA, APPTA, szAPGPTA, APGPTA,
  681. szSTISR, STISR, szSTIDA, STIDA,
  682. szSTIITR, STIITR, szSTIIPA, STIIPA, szSTIIM, STIIM, szSTIHA, STIHA,
  683. szSALID, SALID,
  684. szSAIVR, SAIVR, szSATPR, SATPR, szSAEOI, SAEOI, szSAIRR0, SAIRR0,
  685. szSAIRR1, SAIRR1, szSAIRR2, SAIRR2, szSAIRR3, SAIRR3, szSAITV, SAITV,
  686. szSAPMV, SAPMV, szSACMCV, SACMCV, szSALRR0, SALRR0, szSALRR1, SALRR1,
  687. szRR0, SRRR0, szRR1, SRRR1, szRR2, SRRR2, szRR3, SRRR3,
  688. szRR4, SRRR4, szRR5, SRRR5, szRR6, SRRR6, szRR7, SRRR7,
  689. szPKR0, SRPKR0, szPKR1, SRPKR1, szPKR2, SRPKR2, szPKR3, SRPKR3,
  690. szPKR4, SRPKR4, szPKR5, SRPKR5, szPKR6, SRPKR6, szPKR7, SRPKR7,
  691. szPKR8, SRPKR8, szPKR9, SRPKR9, szPKR10, SRPKR10, szPKR11, SRPKR11,
  692. szPKR12, SRPKR12, szPKR13, SRPKR13, szPKR14, SRPKR14, szPKR15, SRPKR15,
  693. szTRI0, SRTRI0, szTRI1, SRTRI1, szTRI2, SRTRI2, szTRI3, SRTRI3,
  694. szTRI4, SRTRI4, szTRI5, SRTRI5, szTRI6, SRTRI6, szTRI7, SRTRI7,
  695. szTRD0, SRTRD0, szTRD1, SRTRD1, szTRD2, SRTRD2, szTRD3, SRTRD3,
  696. szTRD4, SRTRD4, szTRD5, SRTRD5, szTRD6, SRTRD6, szTRD7, SRTRD7,
  697. szSMSR0, SMSR0, szSMSR1, SMSR1, szSMSR2, SMSR2, szSMSR3, SMSR3,
  698. szSMSR4, SMSR4, szSMSR5, SMSR5, szSMSR6, SMSR6, szSMSR7, SMSR7,
  699. NULL, 0,
  700. };
  701. REGSUBDEF IA64SubRegs[] =
  702. {
  703. // IPSR flags
  704. { IPSRBN, STIPSR, 44, 1 }, // BN Register bank #
  705. { IPSRED, STIPSR, 43, 1 }, // ED Exception deferal
  706. { IPSRRI, STIPSR, 41, 0x3 }, // RI Restart instruction
  707. { IPSRSS, STIPSR, 40, 1 }, // SS Single step enable
  708. { IPSRDD, STIPSR, 39, 1 }, // DD Data debug fault disable
  709. { IPSRDA, STIPSR, 38, 1 }, // DA Disable access and dirty-bit faults
  710. { IPSRID, STIPSR, 37, 1 }, // ID Instruction debug fault disable
  711. { IPSRIT, STIPSR, 36, 1 }, // IT Instruction address translation
  712. { IPSRME, STIPSR, 35, 1 }, // ME Machine check abort mamsk
  713. { IPSRIS, STIPSR, 34, 1 }, // IS Instruction set
  714. { IPSRCPL,STIPSR, 32, 0x3 }, // CPL Current privilege level
  715. { IPSRRT, STIPSR, 27, 1 }, // RT Rigister stack translation
  716. { IPSRTB, STIPSR, 26, 1 }, // TB Taaaaken branch trap
  717. { IPSRLP, STIPSR, 25, 1 }, // LP Lower privilege transfer trap
  718. { IPSRDB, STIPSR, 24, 1 }, // DB Debug breakpoint fault
  719. { IPSRSI, STIPSR, 23, 1 }, // SI Secure interval timer(ITC)
  720. { IPSRDI, STIPSR, 22, 1 }, // DI Disable instruction set transition
  721. { IPSRPP, STIPSR, 21, 1 }, // PP Privileged performance monitor enable
  722. { IPSRSP, STIPSR, 20, 1 }, // SP Secure performance monitors
  723. { IPSRDFH,STIPSR, 19, 1 }, // DFH Disabled floating-point high register set, f16-f127
  724. { IPSRDFL,STIPSR, 18, 1 }, // DFL Disabled floating-point low register set, f0-f15
  725. { IPSRDT, STIPSR, 17, 1 }, // DT Data address translation
  726. // { ?, STIPSR, 16, 1 }, // (reserved)
  727. { IPSRPK, STIPSR, 15, 1 }, // PK Protection key enabled
  728. { IPSRI, STIPSR, 14, 1 }, // I Interrupt unmask
  729. { IPSRIC, STIPSR, 13, 1 }, // IC Interruption collection
  730. { IPSRAC, STIPSR, 3, 1 }, // AC Alignment check
  731. { IPSRUP, STIPSR, 2, 1 }, // UP User performance monitor enabled
  732. { IPSRBE, STIPSR, 1, 1 }, // BE Big-Endian
  733. { IPSROR, STIPSR, 0, 1 }, // OR Ordered memory reference
  734. // FPSR flags
  735. { FPSRMDH, STFPSR, 63, 1 }, // MDH Upper floating point register written
  736. { FPSRMDL, STFPSR, 62, 1 }, // MDL Lower floating point register written
  737. { FPSRSF3, STFPSR, 45, 0x1fff }, // SF3 Alternate status field 3
  738. { FPSRSF2, STFPSR, 32, 0x1fff }, // SF2 Alternate status field 2
  739. { FPSRSF1, STFPSR, 19, 0x1fff }, // SF1 Alternate status field 1
  740. { FPSRSF0, STFPSR, 6, 0x1fff }, // SF0 Main status field
  741. { FPSRTRAPID, STFPSR, 5, 1 }, // TRAPID Inexact floating point trap
  742. { FPSRTRAPUD, STFPSR, 4, 1 }, // TRAPUD Underflow floating point trap
  743. { FPSRTRAPOD, STFPSR, 3, 1 }, // TRAPOD Overflow flating point trap
  744. { FPSRTRAPZD, STFPSR, 2, 1 }, // TRAPZD Zero devide floating point trap
  745. { FPSRTRAPDD, STFPSR, 1, 1 }, // TRAPDD Denormal/Unnormal operand floating point trap
  746. { FPSRTRAPVD, STFPSR, 0, 1 }, // TRAPVD Invalid operation floating point trap
  747. // Predicate registers
  748. // { PR0, PREDS, 0, 1 },
  749. { PR1, PREDS, 1, 1 },
  750. { PR2, PREDS, 2, 1 },
  751. { PR3, PREDS, 3, 1 },
  752. { PR4, PREDS, 4, 1 },
  753. { PR5, PREDS, 5, 1 },
  754. { PR6, PREDS, 6, 1 },
  755. { PR7, PREDS, 7, 1 },
  756. { PR8, PREDS, 8, 1 },
  757. { PR9, PREDS, 9, 1 },
  758. { PR10, PREDS, 10, 1 },
  759. { PR11, PREDS, 11, 1 },
  760. { PR12, PREDS, 12, 1 },
  761. { PR13, PREDS, 13, 1 },
  762. { PR14, PREDS, 14, 1 },
  763. { PR15, PREDS, 15, 1 },
  764. { PR16, PREDS, 16, 1 },
  765. { PR17, PREDS, 17, 1 },
  766. { PR18, PREDS, 18, 1 },
  767. { PR19, PREDS, 19, 1 },
  768. { PR20, PREDS, 20, 1 },
  769. { PR21, PREDS, 21, 1 },
  770. { PR22, PREDS, 22, 1 },
  771. { PR23, PREDS, 23, 1 },
  772. { PR24, PREDS, 24, 1 },
  773. { PR25, PREDS, 25, 1 },
  774. { PR26, PREDS, 26, 1 },
  775. { PR27, PREDS, 27, 1 },
  776. { PR28, PREDS, 28, 1 },
  777. { PR29, PREDS, 29, 1 },
  778. { PR30, PREDS, 30, 1 },
  779. { PR31, PREDS, 31, 1 },
  780. { PR32, PREDS, 32, 1 },
  781. { PR33, PREDS, 33, 1 },
  782. { PR34, PREDS, 34, 1 },
  783. { PR35, PREDS, 35, 1 },
  784. { PR36, PREDS, 36, 1 },
  785. { PR37, PREDS, 37, 1 },
  786. { PR38, PREDS, 38, 1 },
  787. { PR39, PREDS, 39, 1 },
  788. { PR40, PREDS, 40, 1 },
  789. { PR41, PREDS, 41, 1 },
  790. { PR42, PREDS, 42, 1 },
  791. { PR43, PREDS, 43, 1 },
  792. { PR44, PREDS, 44, 1 },
  793. { PR45, PREDS, 45, 1 },
  794. { PR46, PREDS, 46, 1 },
  795. { PR47, PREDS, 47, 1 },
  796. { PR48, PREDS, 48, 1 },
  797. { PR49, PREDS, 49, 1 },
  798. { PR50, PREDS, 50, 1 },
  799. { PR51, PREDS, 51, 1 },
  800. { PR52, PREDS, 52, 1 },
  801. { PR53, PREDS, 53, 1 },
  802. { PR54, PREDS, 54, 1 },
  803. { PR55, PREDS, 55, 1 },
  804. { PR56, PREDS, 56, 1 },
  805. { PR57, PREDS, 57, 1 },
  806. { PR58, PREDS, 58, 1 },
  807. { PR59, PREDS, 59, 1 },
  808. { PR60, PREDS, 60, 1 },
  809. { PR61, PREDS, 61, 1 },
  810. { PR62, PREDS, 62, 1 },
  811. { PR63, PREDS, 63, 1 },
  812. { 0, 0, 0 }
  813. };
  814. #define REGALL_HIGHFLOAT REGALL_EXTRA0
  815. #define REGALL_DREG REGALL_EXTRA1
  816. REGALLDESC IA64ExtraDesc[] =
  817. {
  818. REGALL_HIGHFLOAT, "High floating pointer registers (f32-f127)",
  819. REGALL_DREG, "User debug registers",
  820. 0, NULL,
  821. };
  822. #define REGALL_SPECIALREG REGALL_EXTRA2
  823. REGALLDESC g_Ia64KernelExtraDesc[] =
  824. {
  825. REGALL_SPECIALREG, "KSPECIAL_REGISTERS",
  826. 0, NULL,
  827. };
  828. RegisterGroup g_Ia64BaseGroup =
  829. {
  830. 0, IA64Regs, IA64SubRegs, IA64ExtraDesc
  831. };
  832. RegisterGroup g_Ia64KernelGroup =
  833. {
  834. 0, g_Ia64KernelRegs, NULL, g_Ia64KernelExtraDesc
  835. };
  836. // First ExecTypes entry must be the actual processor type.
  837. ULONG g_Ia64ExecTypes[] =
  838. {
  839. IMAGE_FILE_MACHINE_IA64, IMAGE_FILE_MACHINE_I386
  840. };
  841. // This array must be sorted by CV reg value.
  842. CvRegMap g_Ia64CvRegMap[] =
  843. {
  844. // Branch Registers
  845. { CV_IA64_Br0, BRRP},
  846. { CV_IA64_Br1, BRS0},
  847. { CV_IA64_Br2, BRS1},
  848. { CV_IA64_Br3, BRS2},
  849. { CV_IA64_Br4, BRS3},
  850. { CV_IA64_Br5, BRS4},
  851. { CV_IA64_Br6, BRT0},
  852. { CV_IA64_Br7, BRT1},
  853. // Predicate Registers
  854. { CV_IA64_Preds, PREDS},
  855. // Banked General Registers
  856. /*
  857. { CV_IA64_IntH0, IntH0},
  858. { CV_IA64_IntH1, IntH1},
  859. { CV_IA64_IntH2, IntH2},
  860. { CV_IA64_IntH3, IntH3},
  861. { CV_IA64_IntH4, IntH4},
  862. { CV_IA64_IntH5, IntH5},
  863. { CV_IA64_IntH6, IntH6},
  864. { CV_IA64_IntH7, IntH7},
  865. { CV_IA64_IntH8, IntH8},
  866. { CV_IA64_IntH9, IntH9},
  867. { CV_IA64_IntH10, IntH10},
  868. { CV_IA64_IntH11, IntH11},
  869. { CV_IA64_IntH12, IntH12},
  870. { CV_IA64_IntH13, IntH13},
  871. { CV_IA64_IntH14, IntH14},
  872. { CV_IA64_IntH15, IntH15},
  873. // Special Registers
  874. { CV_IA64_Ip, Ip},
  875. { CV_IA64_Umask, Umask},
  876. { CV_IA64_Cfm, Cfm},
  877. { CV_IA64_Psr, Psr},
  878. // Banked General Registers
  879. { CV_IA64_Nats, Nats},
  880. { CV_IA64_Nats2, Nats2},
  881. { CV_IA64_Nats3, Nats3},
  882. */
  883. // General-Purpose Registers
  884. // INTEGER REGISTER
  885. // { CV_IA64_IntR0, IntZero},
  886. { CV_IA64_IntR1, INTGP},
  887. { CV_IA64_IntR2, INTT0},
  888. { CV_IA64_IntR3, INTT1},
  889. { CV_IA64_IntR4, INTS0},
  890. { CV_IA64_IntR5, INTS1},
  891. { CV_IA64_IntR6, INTS2},
  892. { CV_IA64_IntR7, INTS3},
  893. { CV_IA64_IntR8, INTV0},
  894. // { CV_IA64_IntR9, INTAP},
  895. { CV_IA64_IntR10, INTT2},
  896. { CV_IA64_IntR11, INTT3},
  897. { CV_IA64_IntR12, INTSP},
  898. { CV_IA64_IntR13, INTT4},
  899. { CV_IA64_IntR14, INTT5},
  900. { CV_IA64_IntR15, INTT6},
  901. { CV_IA64_IntR16, INTT7},
  902. { CV_IA64_IntR17, INTT8},
  903. { CV_IA64_IntR18, INTT9},
  904. { CV_IA64_IntR19, INTT10},
  905. { CV_IA64_IntR20, INTT11},
  906. { CV_IA64_IntR21, INTT12},
  907. { CV_IA64_IntR22, INTT13},
  908. { CV_IA64_IntR23, INTT14},
  909. { CV_IA64_IntR24, INTT15},
  910. { CV_IA64_IntR25, INTT16},
  911. { CV_IA64_IntR26, INTT17},
  912. { CV_IA64_IntR27, INTT18},
  913. { CV_IA64_IntR28, INTT19},
  914. { CV_IA64_IntR29, INTT20},
  915. { CV_IA64_IntR30, INTT21},
  916. { CV_IA64_IntR31, INTT22},
  917. // Register Stack
  918. { CV_IA64_IntR32, INTR32},
  919. { CV_IA64_IntR33, INTR33},
  920. { CV_IA64_IntR34, INTR34},
  921. { CV_IA64_IntR35, INTR35},
  922. { CV_IA64_IntR36, INTR36},
  923. { CV_IA64_IntR37, INTR37},
  924. { CV_IA64_IntR38, INTR38},
  925. { CV_IA64_IntR39, INTR39},
  926. { CV_IA64_IntR40, INTR40},
  927. { CV_IA64_IntR41, INTR41},
  928. { CV_IA64_IntR42, INTR42},
  929. { CV_IA64_IntR43, INTR43},
  930. { CV_IA64_IntR44, INTR44},
  931. { CV_IA64_IntR45, INTR45},
  932. { CV_IA64_IntR46, INTR46},
  933. { CV_IA64_IntR47, INTR47},
  934. { CV_IA64_IntR48, INTR48},
  935. { CV_IA64_IntR49, INTR49},
  936. { CV_IA64_IntR50, INTR50},
  937. { CV_IA64_IntR51, INTR51},
  938. { CV_IA64_IntR52, INTR52},
  939. { CV_IA64_IntR53, INTR53},
  940. { CV_IA64_IntR54, INTR54},
  941. { CV_IA64_IntR55, INTR55},
  942. { CV_IA64_IntR56, INTR56},
  943. { CV_IA64_IntR57, INTR57},
  944. { CV_IA64_IntR58, INTR58},
  945. { CV_IA64_IntR59, INTR59},
  946. { CV_IA64_IntR60, INTR60},
  947. { CV_IA64_IntR61, INTR61},
  948. { CV_IA64_IntR62, INTR62},
  949. { CV_IA64_IntR63, INTR63},
  950. { CV_IA64_IntR64, INTR64},
  951. { CV_IA64_IntR65, INTR65},
  952. { CV_IA64_IntR66, INTR66},
  953. { CV_IA64_IntR67, INTR67},
  954. { CV_IA64_IntR68, INTR68},
  955. { CV_IA64_IntR69, INTR69},
  956. { CV_IA64_IntR70, INTR70},
  957. { CV_IA64_IntR71, INTR71},
  958. { CV_IA64_IntR72, INTR72},
  959. { CV_IA64_IntR73, INTR73},
  960. { CV_IA64_IntR74, INTR74},
  961. { CV_IA64_IntR75, INTR75},
  962. { CV_IA64_IntR76, INTR76},
  963. { CV_IA64_IntR77, INTR77},
  964. { CV_IA64_IntR78, INTR78},
  965. { CV_IA64_IntR79, INTR79},
  966. { CV_IA64_IntR80, INTR80},
  967. { CV_IA64_IntR81, INTR81},
  968. { CV_IA64_IntR82, INTR82},
  969. { CV_IA64_IntR83, INTR83},
  970. { CV_IA64_IntR84, INTR84},
  971. { CV_IA64_IntR85, INTR85},
  972. { CV_IA64_IntR86, INTR86},
  973. { CV_IA64_IntR87, INTR87},
  974. { CV_IA64_IntR88, INTR88},
  975. { CV_IA64_IntR89, INTR89},
  976. { CV_IA64_IntR90, INTR90},
  977. { CV_IA64_IntR91, INTR91},
  978. { CV_IA64_IntR92, INTR92},
  979. { CV_IA64_IntR93, INTR93},
  980. { CV_IA64_IntR94, INTR94},
  981. { CV_IA64_IntR95, INTR95},
  982. { CV_IA64_IntR96, INTR96},
  983. { CV_IA64_IntR97, INTR97},
  984. { CV_IA64_IntR98, INTR98},
  985. { CV_IA64_IntR99, INTR99},
  986. { CV_IA64_IntR100, INTR100},
  987. { CV_IA64_IntR101, INTR101},
  988. { CV_IA64_IntR102, INTR102},
  989. { CV_IA64_IntR103, INTR103},
  990. { CV_IA64_IntR104, INTR104},
  991. { CV_IA64_IntR105, INTR105},
  992. { CV_IA64_IntR106, INTR106},
  993. { CV_IA64_IntR107, INTR107},
  994. { CV_IA64_IntR108, INTR108},
  995. { CV_IA64_IntR109, INTR109},
  996. { CV_IA64_IntR110, INTR110},
  997. { CV_IA64_IntR111, INTR111},
  998. { CV_IA64_IntR112, INTR112},
  999. { CV_IA64_IntR113, INTR113},
  1000. { CV_IA64_IntR114, INTR114},
  1001. { CV_IA64_IntR115, INTR115},
  1002. { CV_IA64_IntR116, INTR116},
  1003. { CV_IA64_IntR117, INTR117},
  1004. { CV_IA64_IntR118, INTR118},
  1005. { CV_IA64_IntR119, INTR119},
  1006. { CV_IA64_IntR120, INTR120},
  1007. { CV_IA64_IntR121, INTR121},
  1008. { CV_IA64_IntR122, INTR122},
  1009. { CV_IA64_IntR123, INTR123},
  1010. { CV_IA64_IntR124, INTR124},
  1011. { CV_IA64_IntR125, INTR125},
  1012. { CV_IA64_IntR126, INTR126},
  1013. { CV_IA64_IntR127, INTR127},
  1014. // Floating-Point Registers
  1015. // Low Floating Point Registers
  1016. // { CV_IA64_FltF0, FltZero},
  1017. // { CV_IA64_FltF1, FltOne},
  1018. { CV_IA64_FltF2, FLTS0},
  1019. { CV_IA64_FltF3, FLTS1},
  1020. { CV_IA64_FltF4, FLTS2},
  1021. { CV_IA64_FltF5, FLTS3},
  1022. { CV_IA64_FltF6, FLTT0},
  1023. { CV_IA64_FltF7, FLTT1},
  1024. { CV_IA64_FltF8, FLTT2},
  1025. { CV_IA64_FltF9, FLTT3},
  1026. { CV_IA64_FltF10, FLTT4},
  1027. { CV_IA64_FltF11, FLTT5},
  1028. { CV_IA64_FltF12, FLTT6},
  1029. { CV_IA64_FltF13, FLTT7},
  1030. { CV_IA64_FltF14, FLTT8},
  1031. { CV_IA64_FltF15, FLTT9},
  1032. { CV_IA64_FltF16, FLTS4},
  1033. { CV_IA64_FltF17, FLTS5},
  1034. { CV_IA64_FltF18, FLTS6},
  1035. { CV_IA64_FltF19, FLTS7},
  1036. { CV_IA64_FltF20, FLTS8},
  1037. { CV_IA64_FltF21, FLTS9},
  1038. { CV_IA64_FltF22, FLTS10},
  1039. { CV_IA64_FltF23, FLTS11},
  1040. { CV_IA64_FltF24, FLTS12},
  1041. { CV_IA64_FltF25, FLTS13},
  1042. { CV_IA64_FltF26, FLTS14},
  1043. { CV_IA64_FltF27, FLTS15},
  1044. { CV_IA64_FltF28, FLTS16},
  1045. { CV_IA64_FltF29, FLTS17},
  1046. { CV_IA64_FltF30, FLTS18},
  1047. { CV_IA64_FltF31, FLTS19},
  1048. // High Floating POINT REGISters
  1049. { CV_IA64_FltF32, FLTF32},
  1050. { CV_IA64_FltF33, FLTF33},
  1051. { CV_IA64_FltF34, FLTF34},
  1052. { CV_IA64_FltF35, FLTF35},
  1053. { CV_IA64_FltF36, FLTF36},
  1054. { CV_IA64_FltF37, FLTF37},
  1055. { CV_IA64_FltF38, FLTF38},
  1056. { CV_IA64_FltF39, FLTF39},
  1057. { CV_IA64_FltF40, FLTF40},
  1058. { CV_IA64_FltF41, FLTF41},
  1059. { CV_IA64_FltF42, FLTF42},
  1060. { CV_IA64_FltF43, FLTF43},
  1061. { CV_IA64_FltF44, FLTF44},
  1062. { CV_IA64_FltF45, FLTF45},
  1063. { CV_IA64_FltF46, FLTF46},
  1064. { CV_IA64_FltF47, FLTF47},
  1065. { CV_IA64_FltF48, FLTF48},
  1066. { CV_IA64_FltF49, FLTF49},
  1067. { CV_IA64_FltF50, FLTF50},
  1068. { CV_IA64_FltF51, FLTF51},
  1069. { CV_IA64_FltF52, FLTF52},
  1070. { CV_IA64_FltF53, FLTF53},
  1071. { CV_IA64_FltF54, FLTF54},
  1072. { CV_IA64_FltF55, FLTF55},
  1073. { CV_IA64_FltF56, FLTF56},
  1074. { CV_IA64_FltF57, FLTF57},
  1075. { CV_IA64_FltF58, FLTF58},
  1076. { CV_IA64_FltF59, FLTF59},
  1077. { CV_IA64_FltF60, FLTF60},
  1078. { CV_IA64_FltF61, FLTF61},
  1079. { CV_IA64_FltF62, FLTF62},
  1080. { CV_IA64_FltF63, FLTF63},
  1081. { CV_IA64_FltF64, FLTF64},
  1082. { CV_IA64_FltF65, FLTF65},
  1083. { CV_IA64_FltF66, FLTF66},
  1084. { CV_IA64_FltF67, FLTF67},
  1085. { CV_IA64_FltF68, FLTF68},
  1086. { CV_IA64_FltF69, FLTF69},
  1087. { CV_IA64_FltF70, FLTF70},
  1088. { CV_IA64_FltF71, FLTF71},
  1089. { CV_IA64_FltF72, FLTF72},
  1090. { CV_IA64_FltF73, FLTF73},
  1091. { CV_IA64_FltF74, FLTF74},
  1092. { CV_IA64_FltF75, FLTF75},
  1093. { CV_IA64_FltF76, FLTF76},
  1094. { CV_IA64_FltF77, FLTF77},
  1095. { CV_IA64_FltF78, FLTF78},
  1096. { CV_IA64_FltF79, FLTF79},
  1097. { CV_IA64_FltF80, FLTF80},
  1098. { CV_IA64_FltF81, FLTF81},
  1099. { CV_IA64_FltF82, FLTF82},
  1100. { CV_IA64_FltF83, FLTF83},
  1101. { CV_IA64_FltF84, FLTF84},
  1102. { CV_IA64_FltF85, FLTF85},
  1103. { CV_IA64_FltF86, FLTF86},
  1104. { CV_IA64_FltF87, FLTF87},
  1105. { CV_IA64_FltF88, FLTF88},
  1106. { CV_IA64_FltF89, FLTF89},
  1107. { CV_IA64_FltF90, FLTF90},
  1108. { CV_IA64_FltF91, FLTF91},
  1109. { CV_IA64_FltF92, FLTF92},
  1110. { CV_IA64_FltF93, FLTF93},
  1111. { CV_IA64_FltF94, FLTF94},
  1112. { CV_IA64_FltF95, FLTF95},
  1113. { CV_IA64_FltF96, FLTF96},
  1114. { CV_IA64_FltF97, FLTF97},
  1115. { CV_IA64_FltF98, FLTF98},
  1116. { CV_IA64_FltF99, FLTF99},
  1117. { CV_IA64_FltF100, FLTF100},
  1118. { CV_IA64_FltF101, FLTF101},
  1119. { CV_IA64_FltF102, FLTF102},
  1120. { CV_IA64_FltF103, FLTF103},
  1121. { CV_IA64_FltF104, FLTF104},
  1122. { CV_IA64_FltF105, FLTF105},
  1123. { CV_IA64_FltF106, FLTF106},
  1124. { CV_IA64_FltF107, FLTF107},
  1125. { CV_IA64_FltF108, FLTF108},
  1126. { CV_IA64_FltF109, FLTF109},
  1127. { CV_IA64_FltF110, FLTF110},
  1128. { CV_IA64_FltF111, FLTF111},
  1129. { CV_IA64_FltF112, FLTF112},
  1130. { CV_IA64_FltF113, FLTF113},
  1131. { CV_IA64_FltF114, FLTF114},
  1132. { CV_IA64_FltF115, FLTF115},
  1133. { CV_IA64_FltF116, FLTF116},
  1134. { CV_IA64_FltF117, FLTF117},
  1135. { CV_IA64_FltF118, FLTF118},
  1136. { CV_IA64_FltF119, FLTF119},
  1137. { CV_IA64_FltF120, FLTF120},
  1138. { CV_IA64_FltF121, FLTF121},
  1139. { CV_IA64_FltF122, FLTF122},
  1140. { CV_IA64_FltF123, FLTF123},
  1141. { CV_IA64_FltF124, FLTF124},
  1142. { CV_IA64_FltF125, FLTF125},
  1143. { CV_IA64_FltF126, FLTF126},
  1144. { CV_IA64_FltF127, FLTF127},
  1145. // Application Registers
  1146. { CV_IA64_ApKR0, APKR0},
  1147. { CV_IA64_ApKR1, APKR1},
  1148. { CV_IA64_ApKR2, APKR2},
  1149. { CV_IA64_ApKR3, APKR3},
  1150. { CV_IA64_ApKR4, APKR4},
  1151. { CV_IA64_ApKR5, APKR5},
  1152. { CV_IA64_ApKR6, APKR6},
  1153. { CV_IA64_ApKR7, APKR7},
  1154. /* { CV_IA64_AR8, AR8},
  1155. { CV_IA64_AR9, AR9},
  1156. { CV_IA64_AR10, AR10},
  1157. { CV_IA64_AR11, AR11},
  1158. { CV_IA64_AR12, AR12},
  1159. { CV_IA64_AR13, AR13},
  1160. { CV_IA64_AR14, AR14},
  1161. { CV_IA64_AR15, AR15},*/
  1162. { CV_IA64_RsRSC, RSRSC},
  1163. { CV_IA64_RsBSP, RSBSP},
  1164. { CV_IA64_RsBSPSTORE, RSBSPSTORE},
  1165. { CV_IA64_RsRNAT, RSRNAT},
  1166. // { CV_IA64_AR20, AR20},
  1167. { CV_IA64_StFCR, StFCR},
  1168. // { CV_IA64_AR22, AR22},
  1169. // { CV_IA64_AR23, AR23},
  1170. { CV_IA64_EFLAG, Eflag},
  1171. { CV_IA64_CSD, SegCSD},
  1172. { CV_IA64_SSD, SegSSD},
  1173. { CV_IA64_CFLG, Cflag},
  1174. { CV_IA64_StFSR, STFSR},
  1175. { CV_IA64_StFIR, STFIR},
  1176. { CV_IA64_StFDR, STFDR},
  1177. // { CV_IA64_AR31, AR31},
  1178. { CV_IA64_ApCCV, APCCV},
  1179. // { CV_IA64_AR33, AR33},
  1180. // { CV_IA64_AR34, AR34},
  1181. // { CV_IA64_AR35, AR35},
  1182. { CV_IA64_ApUNAT, APUNAT},
  1183. // { CV_IA64_AR37, AR37},
  1184. // { CV_IA64_AR38, AR38},
  1185. // { CV_IA64_AR39, AR39},
  1186. { CV_IA64_StFPSR, STFPSR},
  1187. // { CV_IA64_AR41, AR41},
  1188. // { CV_IA64_AR42, AR42},
  1189. // { CV_IA64_AR43, AR43},
  1190. { CV_IA64_ApITC, APITC},
  1191. /* { CV_IA64_AR45, AR45},
  1192. { CV_IA64_AR46, AR46},
  1193. { CV_IA64_AR47, AR47},
  1194. { CV_IA64_AR48, AR48},
  1195. { CV_IA64_AR49, AR49},
  1196. { CV_IA64_AR50, AR50},
  1197. { CV_IA64_AR51, AR51},
  1198. { CV_IA64_AR52, AR52},
  1199. { CV_IA64_AR53, AR53},
  1200. { CV_IA64_AR54, AR54},
  1201. { CV_IA64_AR55, AR55},
  1202. { CV_IA64_AR56, AR56},
  1203. { CV_IA64_AR57, AR57},
  1204. { CV_IA64_AR58, AR58},
  1205. { CV_IA64_AR59, AR59},
  1206. { CV_IA64_AR60, AR60},
  1207. { CV_IA64_AR61, AR61},
  1208. { CV_IA64_AR62, AR62},
  1209. { CV_IA64_AR63, AR63},*/
  1210. { CV_IA64_RsPFS, RSPFS},
  1211. { CV_IA64_ApLC, APLC},
  1212. { CV_IA64_ApEC, APEC},
  1213. /* { CV_IA64_AR67, AR67},
  1214. { CV_IA64_AR68, AR68},
  1215. { CV_IA64_AR69, AR69},
  1216. { CV_IA64_AR70, AR70},
  1217. { CV_IA64_AR71, AR71},
  1218. { CV_IA64_AR72, AR72},
  1219. { CV_IA64_AR73, AR73},
  1220. { CV_IA64_AR74, AR74},
  1221. { CV_IA64_AR75, AR75},
  1222. { CV_IA64_AR76, AR76},
  1223. { CV_IA64_AR77, AR77},
  1224. { CV_IA64_AR78, AR78},
  1225. { CV_IA64_AR79, AR79},
  1226. { CV_IA64_AR80, AR80},
  1227. { CV_IA64_AR81, AR81},
  1228. { CV_IA64_AR82, AR82},
  1229. { CV_IA64_AR83, AR83},
  1230. { CV_IA64_AR84, AR84},
  1231. { CV_IA64_AR85, AR85},
  1232. { CV_IA64_AR86, AR86},
  1233. { CV_IA64_AR87, AR87},
  1234. { CV_IA64_AR88, AR88},
  1235. { CV_IA64_AR89, AR89},
  1236. { CV_IA64_AR90, AR90},
  1237. { CV_IA64_AR91, AR91},
  1238. { CV_IA64_AR92, AR92},
  1239. { CV_IA64_AR93, AR93},
  1240. { CV_IA64_AR94, AR94},
  1241. { CV_IA64_AR95, AR95},
  1242. { CV_IA64_AR96, AR96},
  1243. { CV_IA64_AR97, AR97},
  1244. { CV_IA64_AR98, AR98},
  1245. { CV_IA64_AR99, AR99},
  1246. { CV_IA64_AR100, AR100},
  1247. { CV_IA64_AR101, AR101},
  1248. { CV_IA64_AR102, AR102},
  1249. { CV_IA64_AR103, AR103},
  1250. { CV_IA64_AR104, AR104},
  1251. { CV_IA64_AR105, AR105},
  1252. { CV_IA64_AR106, AR106},
  1253. { CV_IA64_AR107, AR107},
  1254. { CV_IA64_AR108, AR108},
  1255. { CV_IA64_AR109, AR109},
  1256. { CV_IA64_AR110, AR110},
  1257. { CV_IA64_AR111, AR111},
  1258. { CV_IA64_AR112, AR112},
  1259. { CV_IA64_AR113, AR113},
  1260. { CV_IA64_AR114, AR114},
  1261. { CV_IA64_AR115, AR115},
  1262. { CV_IA64_AR116, AR116},
  1263. { CV_IA64_AR117, AR117},
  1264. { CV_IA64_AR118, AR118},
  1265. { CV_IA64_AR119, AR119},
  1266. { CV_IA64_AR120, AR120},
  1267. { CV_IA64_AR121, AR121},
  1268. { CV_IA64_AR122, AR122},
  1269. { CV_IA64_AR123, AR123},
  1270. { CV_IA64_AR124, AR124},
  1271. { CV_IA64_AR125, AR125},
  1272. { CV_IA64_AR126, AR126},
  1273. { CV_IA64_AR127, AR127},
  1274. */
  1275. // Control RegisteRS
  1276. { CV_IA64_ApDCR, APDCR},
  1277. { CV_IA64_ApITM, APITM},
  1278. { CV_IA64_ApIVA, APIVA},
  1279. // { CV_IA64_CR3, CR3},
  1280. // { CV_IA64_CR4, CR4},
  1281. // { CV_IA64_CR5, CR5},
  1282. // { CV_IA64_CR6, CR6},
  1283. // { CV_IA64_CR7, CR7},
  1284. { CV_IA64_ApPTA, APPTA},
  1285. // { CV_IA64_CR9, CR9},
  1286. // { CV_IA64_CR10, CR10},
  1287. // { CV_IA64_CR11, CR11},
  1288. // { CV_IA64_CR12, CR12},
  1289. // { CV_IA64_CR13, CR13},
  1290. // { CV_IA64_CR14, CR14},
  1291. // { CV_IA64_CR15, CR15},
  1292. { CV_IA64_StIPSR, STIPSR},
  1293. { CV_IA64_StISR, STISR},
  1294. { CV_IA64_CR18, STIDA},
  1295. { CV_IA64_StIIP, STIIP},
  1296. // { CV_IA64_StIDTR, STIDTR},
  1297. { CV_IA64_StIFA, STIITR},
  1298. { CV_IA64_StIIPA, STIIPA},
  1299. { CV_IA64_StIFS, STIFS},
  1300. { CV_IA64_StIIM, STIIM},
  1301. { CV_IA64_StIHA, STIHA},
  1302. /* { CV_IA64_CR26, CR26},
  1303. { CV_IA64_CR27, CR27},
  1304. { CV_IA64_CR28, CR28},
  1305. { CV_IA64_CR29, CR29},
  1306. { CV_IA64_CR30, CR30},
  1307. { CV_IA64_CR31, CR31},
  1308. { CV_IA64_CR32, CR32},
  1309. { CV_IA64_CR33, CR33},
  1310. { CV_IA64_CR34, CR34},
  1311. { CV_IA64_CR35, CR35},
  1312. { CV_IA64_CR36, CR36},
  1313. { CV_IA64_CR37, CR37},
  1314. { CV_IA64_CR38, CR38},
  1315. { CV_IA64_CR39, CR39},
  1316. { CV_IA64_CR40, CR40},
  1317. { CV_IA64_CR41, CR41},
  1318. { CV_IA64_CR42, CR42},
  1319. { CV_IA64_CR43, CR43},
  1320. { CV_IA64_CR44, CR44},
  1321. { CV_IA64_CR45, CR45},
  1322. { CV_IA64_CR46, CR46},
  1323. { CV_IA64_CR47, CR47},
  1324. { CV_IA64_CR48, CR48},
  1325. { CV_IA64_CR49, CR49},
  1326. { CV_IA64_CR50, CR50},
  1327. { CV_IA64_CR51, CR51},
  1328. { CV_IA64_CR52, CR52},
  1329. { CV_IA64_CR53, CR53},
  1330. { CV_IA64_CR54, CR54},
  1331. { CV_IA64_CR55, CR55},
  1332. { CV_IA64_CR56, CR56},
  1333. { CV_IA64_CR57, CR57},
  1334. { CV_IA64_CR58, CR58},
  1335. { CV_IA64_CR59, CR59},
  1336. { CV_IA64_CR60, CR60},
  1337. { CV_IA64_CR61, CR61},
  1338. { CV_IA64_CR62, CR62},
  1339. { CV_IA64_CR63, CR63},
  1340. { CV_IA64_CR64, CR64},
  1341. { CV_IA64_CR65, CR65},*/
  1342. { CV_IA64_SaLID, SALID},
  1343. // { CV_IA64_CR67, CR67},
  1344. // { CV_IA64_CR68, CR68},
  1345. // { CV_IA64_CR69, CR69},
  1346. // { CV_IA64_CR70, CR70},
  1347. { CV_IA64_SaIVR, SAIVR},
  1348. { CV_IA64_SaTPR, SATPR},
  1349. // { CV_IA64_CR73, CR73},
  1350. // { CV_IA64_CR74, CR74},
  1351. { CV_IA64_SaEOI, SAEOI},
  1352. /* { CV_IA64_CR76, CR76},
  1353. { CV_IA64_CR77, CR77},
  1354. { CV_IA64_CR78, CR78},
  1355. { CV_IA64_CR79, CR79},
  1356. { CV_IA64_CR80, CR80},
  1357. { CV_IA64_CR81, CR81},
  1358. { CV_IA64_CR82, CR82},
  1359. { CV_IA64_CR83, CR83},
  1360. { CV_IA64_CR84, CR84},
  1361. { CV_IA64_CR85, CR85},
  1362. { CV_IA64_CR86, CR86},
  1363. { CV_IA64_CR87, CR87},
  1364. { CV_IA64_CR88, CR88},
  1365. { CV_IA64_CR89, CR89},
  1366. { CV_IA64_CR90, CR90},
  1367. { CV_IA64_CR91, CR91},
  1368. { CV_IA64_CR92, CR92},
  1369. { CV_IA64_CR93, CR93},
  1370. { CV_IA64_CR94, CR94},
  1371. { CV_IA64_CR95, CR95},*/
  1372. { CV_IA64_SaIRR0, SAIRR0},
  1373. // { CV_IA64_CR97, CR97},
  1374. { CV_IA64_SaIRR1, SAIRR1},
  1375. // { CV_IA64_CR99, CR99},
  1376. { CV_IA64_SaIRR2, SAIRR2},
  1377. // { CV_IA64_CR101, CR101},
  1378. { CV_IA64_SaIRR3, SAIRR3},
  1379. /* { CV_IA64_CR103, CR103},
  1380. { CV_IA64_CR104, CR104},
  1381. { CV_IA64_CR105, CR105},
  1382. { CV_IA64_CR106, CR106},
  1383. { CV_IA64_CR107, CR107},
  1384. { CV_IA64_CR108, CR108},
  1385. { CV_IA64_CR109, CR109},
  1386. { CV_IA64_CR110, CR110},
  1387. { CV_IA64_CR111, CR111},
  1388. { CV_IA64_CR112, CR112},
  1389. { CV_IA64_CR113, CR113},*/
  1390. { CV_IA64_SaITV, SAITV},
  1391. // { CV_IA64_CR115, CR115},
  1392. { CV_IA64_SaPMV, SAPMV},
  1393. { CV_IA64_SaLRR0, SALRR0},
  1394. { CV_IA64_SaLRR1, SALRR1},
  1395. { CV_IA64_SaCMCV, SACMCV},
  1396. // { CV_IA64_CR120, CR120},
  1397. // { CV_IA64_CR121, CR121},
  1398. // { CV_IA64_CR122, CR122},
  1399. // { CV_IA64_CR123, CR123},
  1400. // { CV_IA64_CR124, CR124},
  1401. // { CV_IA64_CR125, CR125},
  1402. // { CV_IA64_CR126, CR126},
  1403. // { CV_IA64_CR127, CR127},
  1404. // Protection Key Registers
  1405. { CV_IA64_Pkr0, SRPKR0},
  1406. { CV_IA64_Pkr1, SRPKR1},
  1407. { CV_IA64_Pkr2, SRPKR2},
  1408. { CV_IA64_Pkr3, SRPKR3},
  1409. { CV_IA64_Pkr4, SRPKR4},
  1410. { CV_IA64_Pkr5, SRPKR5},
  1411. { CV_IA64_Pkr6, SRPKR6},
  1412. { CV_IA64_Pkr7, SRPKR7},
  1413. { CV_IA64_Pkr8, SRPKR8},
  1414. { CV_IA64_Pkr9, SRPKR9},
  1415. { CV_IA64_Pkr10, SRPKR10},
  1416. { CV_IA64_Pkr11, SRPKR11},
  1417. { CV_IA64_Pkr12, SRPKR12},
  1418. { CV_IA64_Pkr13, SRPKR13},
  1419. { CV_IA64_Pkr14, SRPKR14},
  1420. { CV_IA64_Pkr15, SRPKR15},
  1421. // REGION REGISTERS
  1422. { CV_IA64_Rr0, SRRR0},
  1423. { CV_IA64_Rr1, SRRR1},
  1424. { CV_IA64_Rr2, SRRR2},
  1425. { CV_IA64_Rr3, SRRR3},
  1426. { CV_IA64_Rr4, SRRR4},
  1427. { CV_IA64_Rr5, SRRR5},
  1428. { CV_IA64_Rr6, SRRR6},
  1429. { CV_IA64_Rr7, SRRR7},
  1430. // PERFORMANCE MONITOR DATA REGISTERS
  1431. { CV_IA64_PFD0, KRPFD0},
  1432. { CV_IA64_PFD1, KRPFD1},
  1433. { CV_IA64_PFD2, KRPFD2},
  1434. { CV_IA64_PFD3, KRPFD3},
  1435. { CV_IA64_PFD4, KRPFD4},
  1436. { CV_IA64_PFD5, KRPFD5},
  1437. { CV_IA64_PFD6, KRPFD6},
  1438. { CV_IA64_PFD7, KRPFD7},
  1439. // PERFORMANCE MONITOR CONFIG REGISTERS
  1440. { CV_IA64_PFC0, KRPFC0},
  1441. { CV_IA64_PFC1, KRPFC1},
  1442. { CV_IA64_PFC2, KRPFC2},
  1443. { CV_IA64_PFC3, KRPFC3},
  1444. { CV_IA64_PFC4, KRPFC4},
  1445. { CV_IA64_PFC5, KRPFC5},
  1446. { CV_IA64_PFC6, KRPFC6},
  1447. { CV_IA64_PFC7, KRPFC7},
  1448. // INSTRUCTION TRANSLATION REGISTERS
  1449. { CV_IA64_TrI0, SRTRI0},
  1450. { CV_IA64_TrI1, SRTRI1},
  1451. { CV_IA64_TrI2, SRTRI2},
  1452. { CV_IA64_TrI3, SRTRI3},
  1453. { CV_IA64_TrI4, SRTRI4},
  1454. { CV_IA64_TrI5, SRTRI5},
  1455. { CV_IA64_TrI6, SRTRI6},
  1456. { CV_IA64_TrI7, SRTRI7},
  1457. // DATA TRANSLATION REGISTERS
  1458. { CV_IA64_TrD0, SRTRD0},
  1459. { CV_IA64_TrD1, SRTRD1},
  1460. { CV_IA64_TrD2, SRTRD2},
  1461. { CV_IA64_TrD3, SRTRD3},
  1462. { CV_IA64_TrD4, SRTRD4},
  1463. { CV_IA64_TrD5, SRTRD5},
  1464. { CV_IA64_TrD6, SRTRD6},
  1465. { CV_IA64_TrD7, SRTRD7},
  1466. // INSTRUCTION BREAKPOINT REGISTERS
  1467. { CV_IA64_DbI0, KRDBI0},
  1468. { CV_IA64_DbI1, KRDBI1},
  1469. { CV_IA64_DbI2, KRDBI2},
  1470. { CV_IA64_DbI3, KRDBI3},
  1471. { CV_IA64_DbI4, KRDBI4},
  1472. { CV_IA64_DbI5, KRDBI5},
  1473. { CV_IA64_DbI6, KRDBI6},
  1474. { CV_IA64_DbI7, KRDBI7},
  1475. // DATA BREAKPOINT REGISTERS
  1476. { CV_IA64_DbD0, KRDBD0},
  1477. { CV_IA64_DbD1, KRDBD1},
  1478. { CV_IA64_DbD2, KRDBD2},
  1479. { CV_IA64_DbD3, KRDBD3},
  1480. { CV_IA64_DbD4, KRDBD4},
  1481. { CV_IA64_DbD5, KRDBD5},
  1482. { CV_IA64_DbD6, KRDBD6},
  1483. { CV_IA64_DbD7, KRDBD7},
  1484. };
  1485. BOOL
  1486. SplitIa64Pc(ULONG64 Pc, ULONG64* Bundle, ULONG64* Slot)
  1487. {
  1488. ULONG64 SlotVal = Pc & 0xf;
  1489. switch (SlotVal)
  1490. {
  1491. case 0:
  1492. case 4:
  1493. case 8:
  1494. SlotVal >>= 2;
  1495. break;
  1496. default:
  1497. return FALSE;
  1498. }
  1499. if (Slot)
  1500. {
  1501. *Slot = SlotVal;
  1502. }
  1503. if (Bundle)
  1504. {
  1505. *Bundle = Pc & ~(ULONG64)0xf;
  1506. }
  1507. return TRUE;
  1508. }
  1509. ULONG
  1510. RotateGr(ULONG Reg, ULONG64 FrameMarker)
  1511. {
  1512. DBG_ASSERT(Reg >= INTR32 && Reg <= INTR127);
  1513. ULONG SorGr = (ULONG)IA64_FM_SOR(FrameMarker) * 8;
  1514. // Rotation only occurs within the defined rotating area.
  1515. if ((Reg - INTR32) >= SorGr)
  1516. {
  1517. return Reg;
  1518. }
  1519. ULONG Rot = (ULONG)IA64_FM_RRB_GR(FrameMarker) % SorGr;
  1520. if (!Rot)
  1521. {
  1522. return Reg;
  1523. }
  1524. return ((Reg - INTR32) + Rot) % SorGr + INTR32;
  1525. }
  1526. ULONG
  1527. RotateFr(ULONG Reg, ULONG64 FrameMarker)
  1528. {
  1529. // The size of the rotating FP area is fixed.
  1530. const ULONG SorFr = 96;
  1531. ULONG Rot = (ULONG)IA64_FM_RRB_FR(FrameMarker) % SorFr;
  1532. // Rotation only occurs within the defined rotating area.
  1533. if (!Rot || Reg < FLTF32)
  1534. {
  1535. return Reg;
  1536. }
  1537. DBG_ASSERT(Reg <= FLTF127);
  1538. // FP register indices are padded with duplicates to
  1539. // make context indexing by 64-bits work out, so
  1540. // condense and reexpand when rotating.
  1541. return ((Reg - FLTF32) / 2 + Rot) % SorFr * 2 + FLTF32;
  1542. }
  1543. ULONG64
  1544. RotatePr(ULONG64 Val, ULONG64 FrameMarker, BOOL Get)
  1545. {
  1546. // The size of the rotating predicate area is fixed.
  1547. const ULONG SorPr = 48;
  1548. ULONG64 FixedBits;
  1549. ULONG64 RotBits;
  1550. ULONG Rot;
  1551. ULONG64 MaskLow, MaskHigh;
  1552. Rot = (ULONG)IA64_FM_RRB_PR(FrameMarker) % SorPr;
  1553. if (!Rot)
  1554. {
  1555. return Val;
  1556. }
  1557. FixedBits = Val & 0xffff;
  1558. RotBits = Val >> 16;
  1559. if (Get)
  1560. {
  1561. //
  1562. // Rotate bits from underlying positions into rotated positions.
  1563. // This is a rotate-to-lower-bit-position by Rot.
  1564. //
  1565. MaskLow = (1UI64 << Rot) - 1;
  1566. MaskHigh = ((1UI64 << SorPr) - 1) & ~MaskLow;
  1567. return FixedBits |
  1568. ((((RotBits & MaskLow) << (SorPr - Rot)) |
  1569. ((RotBits & MaskHigh) >> Rot)) << 16);
  1570. }
  1571. else
  1572. {
  1573. //
  1574. // Rotate bits from rotated positions into underlying positions.
  1575. // This is a rotate-to-higher-bit-position by Rot.
  1576. //
  1577. MaskHigh = ((1UI64 << Rot) - 1) << (SorPr - Rot);
  1578. MaskLow = ((1UI64 << SorPr) - 1) & ~MaskHigh;
  1579. return FixedBits |
  1580. ((((RotBits & MaskLow) << Rot) |
  1581. ((RotBits & MaskHigh) >> (SorPr - Rot))) << 16);
  1582. }
  1583. }
  1584. Ia64MachineInfo::Ia64MachineInfo(TargetInfo* Target)
  1585. : MachineInfo(Target)
  1586. {
  1587. m_FullName = "Intel IA64";
  1588. m_AbbrevName = "ia64";
  1589. m_PageSize = IA64_PAGE_SIZE;
  1590. m_PageShift = IA64_PAGE_SHIFT;
  1591. m_NumExecTypes = 2;
  1592. m_ExecTypes = g_Ia64ExecTypes;
  1593. m_Ptr64 = TRUE;
  1594. m_RetRegIndex = INTV0;
  1595. m_AllMask = REGALL_INT64 | REGALL_DREG,
  1596. m_MaxDataBreakpoints = IA64_REG_MAX_DATA_BREAKPOINTS;
  1597. m_SymPrefix = NULL;
  1598. m_SizeCanonicalContext = sizeof(IA64_CONTEXT);
  1599. m_SverCanonicalContext = NT_SVER_XP;
  1600. m_CvRegMapSize = DIMA(g_Ia64CvRegMap);
  1601. m_CvRegMap = g_Ia64CvRegMap;
  1602. m_KernPageDir = 0;
  1603. m_IfsOverride = 0;
  1604. m_BspOverride = 0;
  1605. }
  1606. HRESULT
  1607. Ia64MachineInfo::Initialize(void)
  1608. {
  1609. m_Groups[0] = &g_Ia64BaseGroup;
  1610. m_NumGroups = 1;
  1611. if (IS_KERNEL_TARGET(m_Target))
  1612. {
  1613. m_Groups[m_NumGroups] = &g_Ia64KernelGroup;
  1614. m_NumGroups++;
  1615. }
  1616. return MachineInfo::Initialize();
  1617. }
  1618. void
  1619. Ia64MachineInfo::GetSystemTypeInfo(PSYSTEM_TYPE_INFO Info)
  1620. {
  1621. Info->TriagePrcbOffset = IA64_TRIAGE_PRCB_ADDRESS;
  1622. Info->SizeTargetContext = sizeof(IA64_CONTEXT);
  1623. Info->OffsetTargetContextFlags = FIELD_OFFSET(IA64_CONTEXT, ContextFlags);
  1624. Info->SizeControlReport = sizeof(IA64_DBGKD_CONTROL_REPORT);
  1625. Info->OffsetSpecialRegisters = IA64_DEBUG_CONTROL_SPACE_KSPECIAL;
  1626. Info->SizeKspecialRegisters = sizeof(IA64_KSPECIAL_REGISTERS);
  1627. Info->SizePageFrameNumber = sizeof(ULONG64);
  1628. Info->SizePte = sizeof(ULONG64);
  1629. Info->SizeDynamicFunctionTable = sizeof(IA64_DYNAMIC_FUNCTION_TABLE);
  1630. Info->SizeRuntimeFunction = sizeof(IMAGE_IA64_RUNTIME_FUNCTION_ENTRY);
  1631. Info->SharedUserDataOffset = 0;
  1632. Info->UmSharedUserDataOffset = 0;
  1633. Info->UmSharedSysCallOffset = 0;
  1634. Info->UmSharedSysCallSize = 0;
  1635. if (m_Target->m_PlatformId == VER_PLATFORM_WIN32_NT)
  1636. {
  1637. Info->SharedUserDataOffset = IS_KERNEL_TARGET(m_Target) ?
  1638. IA64_KI_USER_SHARED_DATA : MM_SHARED_USER_DATA_VA;
  1639. Info->UmSharedUserDataOffset = MM_SHARED_USER_DATA_VA;
  1640. }
  1641. }
  1642. void
  1643. Ia64MachineInfo::GetDefaultKdData(PKDDEBUGGER_DATA64 KdData)
  1644. {
  1645. //
  1646. // Parts of the data block may already be filled out
  1647. // so don't destroy anything that's already set.
  1648. //
  1649. // The MmVirtualTranslationBase field was added post-XP.
  1650. // The address used for Merced XP is well-known, though,
  1651. // so set the appropriate constant. We aren't actually
  1652. // checking for Merced because the processor ID isn't
  1653. // initialized and can't be initialized until KiProcessorBlock
  1654. // is located, which is long after this.
  1655. if (!KdData->MmVirtualTranslationBase)
  1656. {
  1657. KdData->MmVirtualTranslationBase = 0x1ffffe0000000000;
  1658. }
  1659. if (!KdData->OffsetKThreadApcProcess)
  1660. {
  1661. KdData->SizePrcb = IA64_KPRCB_SIZE;
  1662. KdData->OffsetKThreadInitialStack = IA64_KTHREAD_INITSTACK_OFFSET;
  1663. KdData->OffsetEprocessPeb = IA64_PEB_IN_EPROCESS;
  1664. KdData->OffsetKThreadApcProcess = IA64_KTHREAD_APCPROCESS_OFFSET;
  1665. KdData->OffsetKThreadTeb = IA64_KTHREAD_TEB_OFFSET;
  1666. KdData->OffsetKThreadKernelStack = IA64_KTHREAD_KERNELSTACK_OFFSET;
  1667. KdData->OffsetKThreadState = IA64_KTHREAD_STATE_OFFSET;
  1668. KdData->OffsetKThreadNextProcessor = IA64_KTHREAD_NEXTPROCESSOR_OFFSET;
  1669. KdData->OffsetKThreadBStore = IA64_KTHREAD_BSTORE_OFFSET;
  1670. KdData->OffsetKThreadBStoreLimit = IA64_KTHREAD_BSTORELIMIT_OFFSET;
  1671. KdData->OffsetEprocessParentCID = IA64_PCID_IN_EPROCESS;
  1672. KdData->OffsetEprocessDirectoryTableBase =
  1673. IA64_DIRECTORY_TABLE_BASE_IN_EPROCESS;
  1674. KdData->SizeEProcess = IA64_EPROCESS_SIZE;
  1675. KdData->SizePrcb = IA64_KPRCB_SIZE;
  1676. KdData->OffsetPrcbCurrentThread = DEF_KPRCB_CURRENT_THREAD_OFFSET_64;
  1677. KdData->OffsetPrcbMhz = IA64_2462_KPRCB_MHZ;
  1678. KdData->OffsetPrcbCpuType = IA64_KPRCB_PROCESSOR_MODEL;
  1679. KdData->OffsetPrcbVendorString = IA64_KPRCB_VENDOR_STRING;
  1680. KdData->OffsetPrcbProcStateContext = IA64_KPRCB_CONTEXT;
  1681. KdData->OffsetPrcbNumber = IA64_KPRCB_NUMBER;
  1682. KdData->SizeEThread = IA64_ETHREAD_SIZE;
  1683. if (m_Target->m_BuildNumber > 3558)
  1684. {
  1685. KdData->OffsetEprocessPeb =
  1686. IA64_3555_PEB_IN_EPROCESS;
  1687. KdData->OffsetKThreadApcProcess =
  1688. IA64_3555_KTHREAD_APCPROCESS_OFFSET;
  1689. KdData->OffsetKThreadTeb =
  1690. IA64_3555_KTHREAD_TEB_OFFSET;
  1691. KdData->OffsetKThreadKernelStack =
  1692. IA64_3555_KTHREAD_KERNELSTACK_OFFSET;
  1693. KdData->OffsetKThreadState =
  1694. IA64_3555_KTHREAD_STATE_OFFSET;
  1695. KdData->OffsetKThreadNextProcessor =
  1696. IA64_3555_KTHREAD_NEXTPROCESSOR_OFFSET;
  1697. KdData->OffsetKThreadBStore =
  1698. IA64_3555_KTHREAD_BSTORE_OFFSET;
  1699. KdData->OffsetKThreadBStoreLimit =
  1700. IA64_3555_KTHREAD_BSTORELIMIT_OFFSET;
  1701. KdData->SizeEThread =
  1702. IA64_3555_ETHREAD_SIZE;
  1703. }
  1704. }
  1705. if (!KdData->SizePcr)
  1706. {
  1707. KdData->SizePcr = IA64_KPCR_SIZE;
  1708. KdData->OffsetPcrSelfPcr = 0;
  1709. KdData->OffsetPcrCurrentPrcb = IA64_KPCR_PRCB;
  1710. KdData->OffsetPcrContainedPrcb = 0;
  1711. KdData->OffsetPcrInitialBStore = IA64_KPCR_INITIAL_BSTORE;
  1712. KdData->OffsetPcrBStoreLimit = IA64_KPCR_BSTORE_LIMIT;
  1713. KdData->OffsetPcrInitialStack = IA64_KPCR_INITIAL_STACK;
  1714. KdData->OffsetPcrStackLimit = IA64_KPCR_STACK_LIMIT;
  1715. KdData->OffsetPrcbPcrPage = IA64_KPRCB_PCR_PAGE;
  1716. KdData->OffsetPrcbProcStateSpecialReg = IA64_KPRCB_SPECIAL_REG;
  1717. }
  1718. }
  1719. void
  1720. Ia64MachineInfo::
  1721. InitializeContext(ULONG64 Pc,
  1722. PDBGKD_ANY_CONTROL_REPORT ControlReport)
  1723. {
  1724. if (Pc)
  1725. {
  1726. ULONG Slot;
  1727. m_ContextState = MCTX_PC;
  1728. Slot = (ULONG)(Pc & 0xc) >> 2;
  1729. m_Context.IA64Context.StIIP = Pc & ~(0xf);
  1730. m_Context.IA64Context.StIPSR &= ~(IPSR_RI_MASK);
  1731. m_Context.IA64Context.StIPSR |= (ULONGLONG)Slot << PSR_RI;
  1732. }
  1733. else
  1734. {
  1735. m_Context.IA64Context.StIIP = Pc;
  1736. }
  1737. if (Pc && ControlReport != NULL)
  1738. {
  1739. CacheReportInstructions
  1740. (Pc, ControlReport->IA64ControlReport.InstructionCount,
  1741. ControlReport->IA64ControlReport.InstructionStream);
  1742. }
  1743. }
  1744. HRESULT
  1745. Ia64MachineInfo::KdGetContextState(ULONG State)
  1746. {
  1747. HRESULT Status;
  1748. if (State >= MCTX_CONTEXT && m_ContextState < MCTX_CONTEXT)
  1749. {
  1750. Status = m_Target->GetContext(m_Target->m_RegContextThread->m_Handle,
  1751. &m_Context);
  1752. if (Status != S_OK)
  1753. {
  1754. return Status;
  1755. }
  1756. m_ContextState = MCTX_CONTEXT;
  1757. }
  1758. if (State >= MCTX_FULL && m_ContextState < MCTX_FULL)
  1759. {
  1760. Status = m_Target->GetTargetSpecialRegisters
  1761. (m_Target->m_RegContextThread->m_Handle,
  1762. (PCROSS_PLATFORM_KSPECIAL_REGISTERS)&m_Special.IA64Special);
  1763. if (Status != S_OK)
  1764. {
  1765. return Status;
  1766. }
  1767. m_ContextState = MCTX_FULL;
  1768. }
  1769. return S_OK;
  1770. }
  1771. HRESULT
  1772. Ia64MachineInfo::KdSetContext(void)
  1773. {
  1774. HRESULT Status;
  1775. // XP's kernel checks the context DBD and DBI registers
  1776. // to see if it should be setting IPSR.DB. It needs to
  1777. // check the special registers instead, as that's where
  1778. // the kernel-specific settings are. The context controls
  1779. // the user mode state. Just copy over the
  1780. // user state so that kernel processor breakpoints work.
  1781. // The kernel was fixed for XP server and is not necessary.
  1782. if (m_Target->m_BuildNumber < 3555)
  1783. {
  1784. memcpy(&m_Context.IA64Context.DbI0, &m_Special.IA64Special.KernelDbI0,
  1785. 16 * sizeof(ULONG64));
  1786. }
  1787. Status = m_Target->SetContext(m_Target->m_RegContextThread->m_Handle,
  1788. &m_Context);
  1789. if (Status != S_OK)
  1790. {
  1791. return Status;
  1792. }
  1793. Status = m_Target->SetTargetSpecialRegisters
  1794. (m_Target->m_RegContextThread->m_Handle,
  1795. (PCROSS_PLATFORM_KSPECIAL_REGISTERS)&m_Special.IA64Special);
  1796. if (Status != S_OK)
  1797. {
  1798. return Status;
  1799. }
  1800. return S_OK;
  1801. }
  1802. HRESULT
  1803. Ia64MachineInfo::ConvertContextFrom(PCROSS_PLATFORM_CONTEXT Context,
  1804. ULONG FromSver, ULONG FromSize, PVOID From)
  1805. {
  1806. if (FromSize < sizeof(IA64_CONTEXT))
  1807. {
  1808. return E_INVALIDARG;
  1809. }
  1810. memcpy(Context, From, sizeof(IA64_CONTEXT));
  1811. return S_OK;
  1812. }
  1813. HRESULT
  1814. Ia64MachineInfo::ConvertContextTo(PCROSS_PLATFORM_CONTEXT Context,
  1815. ULONG ToSver, ULONG ToSize, PVOID To)
  1816. {
  1817. if (ToSize < sizeof(IA64_CONTEXT))
  1818. {
  1819. return E_INVALIDARG;
  1820. }
  1821. memcpy(To, Context, sizeof(IA64_CONTEXT));
  1822. return S_OK;
  1823. }
  1824. void
  1825. Ia64MachineInfo::InitializeContextFlags(PCROSS_PLATFORM_CONTEXT Context,
  1826. ULONG Version)
  1827. {
  1828. Context->IA64Context.ContextFlags =
  1829. IA64_CONTEXT_FULL | IA64_CONTEXT_DEBUG;
  1830. }
  1831. HRESULT
  1832. Ia64MachineInfo::GetContextFromThreadStack(ULONG64 ThreadBase,
  1833. PCROSS_PLATFORM_CONTEXT Context,
  1834. ULONG64 Stack)
  1835. {
  1836. HRESULT Status;
  1837. IA64_KSWITCH_FRAME SwitchFrame;
  1838. if ((Status = m_Target->ReadAllVirtual(m_Target->m_ProcessHead,
  1839. Stack +
  1840. IA64_STACK_SCRATCH_AREA,
  1841. &SwitchFrame,
  1842. sizeof(SwitchFrame))) != S_OK)
  1843. {
  1844. return Status;
  1845. }
  1846. ZeroMemory(Context, sizeof(*Context));
  1847. Context->IA64Context.IntSp = Stack;
  1848. Context->IA64Context.Preds = SwitchFrame.SwitchPredicates;
  1849. Context->IA64Context.StIIP = SwitchFrame.SwitchRp;
  1850. Context->IA64Context.StFPSR = SwitchFrame.SwitchFPSR;
  1851. Context->IA64Context.BrRp = SwitchFrame.SwitchRp;
  1852. Context->IA64Context.RsPFS = SwitchFrame.SwitchPFS;
  1853. Context->IA64Context.StIFS = SwitchFrame.SwitchPFS;
  1854. SHORT BsFrameSize =
  1855. (SHORT)(SwitchFrame.SwitchPFS >> IA64_PFS_SIZE_SHIFT) &
  1856. IA64_PFS_SIZE_MASK;
  1857. SHORT TempFrameSize =
  1858. BsFrameSize - (SHORT)((SwitchFrame.SwitchBsp >> 3) &
  1859. IA64_NAT_BITS_PER_RNAT_REG);
  1860. while (TempFrameSize > 0)
  1861. {
  1862. BsFrameSize++;
  1863. TempFrameSize -= IA64_NAT_BITS_PER_RNAT_REG;
  1864. }
  1865. Context->IA64Context.RsBSP =
  1866. SwitchFrame.SwitchBsp - (BsFrameSize * sizeof(ULONGLONG));
  1867. Context->IA64Context.FltS0 = SwitchFrame.SwitchExceptionFrame.FltS0;
  1868. Context->IA64Context.FltS1 = SwitchFrame.SwitchExceptionFrame.FltS1;
  1869. Context->IA64Context.FltS2 = SwitchFrame.SwitchExceptionFrame.FltS2;
  1870. Context->IA64Context.FltS3 = SwitchFrame.SwitchExceptionFrame.FltS3;
  1871. Context->IA64Context.FltS4 = SwitchFrame.SwitchExceptionFrame.FltS4;
  1872. Context->IA64Context.FltS5 = SwitchFrame.SwitchExceptionFrame.FltS5;
  1873. Context->IA64Context.FltS6 = SwitchFrame.SwitchExceptionFrame.FltS6;
  1874. Context->IA64Context.FltS7 = SwitchFrame.SwitchExceptionFrame.FltS7;
  1875. Context->IA64Context.FltS8 = SwitchFrame.SwitchExceptionFrame.FltS8;
  1876. Context->IA64Context.FltS9 = SwitchFrame.SwitchExceptionFrame.FltS9;
  1877. Context->IA64Context.FltS10 = SwitchFrame.SwitchExceptionFrame.FltS10;
  1878. Context->IA64Context.FltS11 = SwitchFrame.SwitchExceptionFrame.FltS11;
  1879. Context->IA64Context.FltS12 = SwitchFrame.SwitchExceptionFrame.FltS12;
  1880. Context->IA64Context.FltS13 = SwitchFrame.SwitchExceptionFrame.FltS13;
  1881. Context->IA64Context.FltS14 = SwitchFrame.SwitchExceptionFrame.FltS14;
  1882. Context->IA64Context.FltS15 = SwitchFrame.SwitchExceptionFrame.FltS15;
  1883. Context->IA64Context.FltS16 = SwitchFrame.SwitchExceptionFrame.FltS16;
  1884. Context->IA64Context.FltS17 = SwitchFrame.SwitchExceptionFrame.FltS17;
  1885. Context->IA64Context.FltS18 = SwitchFrame.SwitchExceptionFrame.FltS18;
  1886. Context->IA64Context.FltS19 = SwitchFrame.SwitchExceptionFrame.FltS19;
  1887. Context->IA64Context.IntS0 = SwitchFrame.SwitchExceptionFrame.IntS0;
  1888. Context->IA64Context.IntS1 = SwitchFrame.SwitchExceptionFrame.IntS1;
  1889. Context->IA64Context.IntS2 = SwitchFrame.SwitchExceptionFrame.IntS2;
  1890. Context->IA64Context.IntS3 = SwitchFrame.SwitchExceptionFrame.IntS3;
  1891. Context->IA64Context.IntNats = SwitchFrame.SwitchExceptionFrame.IntNats;
  1892. Context->IA64Context.BrS0 = SwitchFrame.SwitchExceptionFrame.BrS0;
  1893. Context->IA64Context.BrS1 = SwitchFrame.SwitchExceptionFrame.BrS1;
  1894. Context->IA64Context.BrS2 = SwitchFrame.SwitchExceptionFrame.BrS2;
  1895. Context->IA64Context.BrS3 = SwitchFrame.SwitchExceptionFrame.BrS3;
  1896. Context->IA64Context.BrS4 = SwitchFrame.SwitchExceptionFrame.BrS4;
  1897. Context->IA64Context.ApEC = SwitchFrame.SwitchExceptionFrame.ApEC;
  1898. Context->IA64Context.ApLC = SwitchFrame.SwitchExceptionFrame.ApLC;
  1899. return S_OK;
  1900. }
  1901. HRESULT
  1902. Ia64MachineInfo::GetContextFromFiber(ProcessInfo* Process,
  1903. ULONG64 FiberBase,
  1904. PCROSS_PLATFORM_CONTEXT Context,
  1905. BOOL Verbose)
  1906. {
  1907. HRESULT Status;
  1908. IA64_FIBER Fiber;
  1909. if ((Status = m_Target->
  1910. ReadAllVirtual(Process, FiberBase, &Fiber, sizeof(Fiber))) != S_OK)
  1911. {
  1912. if (Verbose)
  1913. {
  1914. ErrOut("Unable to read fiber data at %s\n",
  1915. FormatMachineAddr64(this, FiberBase));
  1916. }
  1917. return Status;
  1918. }
  1919. if ((Status = ConvertContextFrom(Context, m_Target->m_SystemVersion,
  1920. m_Target->m_TypeInfo.SizeTargetContext,
  1921. &Fiber.FiberContext)) != S_OK)
  1922. {
  1923. if (Verbose)
  1924. {
  1925. ErrOut("Unable to convert context to canonical form\n");
  1926. }
  1927. return Status;
  1928. }
  1929. if (Verbose)
  1930. {
  1931. dprintf("Fiber at %s Fiber data: %s\n",
  1932. FormatMachineAddr64(this, FiberBase),
  1933. FormatMachineAddr64(this, Fiber.FiberData));
  1934. dprintf(" Stack base: %s Stack limit: %s\n",
  1935. FormatMachineAddr64(this, Fiber.StackBase),
  1936. FormatMachineAddr64(this, Fiber.StackLimit));
  1937. dprintf(" Backing store base: %s Backing store limit: %s\n",
  1938. FormatMachineAddr64(this, Fiber.DeallocationBStore),
  1939. FormatMachineAddr64(this, Fiber.BStoreLimit));
  1940. }
  1941. return S_OK;
  1942. }
  1943. HRESULT
  1944. Ia64MachineInfo::GetContextFromTrapFrame(ULONG64 TrapBase,
  1945. PCROSS_PLATFORM_CONTEXT Context,
  1946. BOOL Verbose)
  1947. {
  1948. HRESULT Status;
  1949. IA64_KTRAP_FRAME TrapContents;
  1950. DWORD64 Bsp;
  1951. ULONG SizeOfFrame;
  1952. SHORT temp;
  1953. if ((Status = m_Target->ReadAllVirtual(m_Target->m_ProcessHead,
  1954. TrapBase, &TrapContents,
  1955. sizeof(TrapContents))) != S_OK)
  1956. {
  1957. if (Verbose)
  1958. {
  1959. ErrOut("Unable to read trap frame at %s\n",
  1960. FormatMachineAddr64(this, TrapBase));
  1961. }
  1962. return Status;
  1963. }
  1964. SizeOfFrame = (ULONG)(TrapContents.StIFS & (IA64_PFS_SIZE_MASK));
  1965. if (TrapContents.PreviousMode == 1 /*UserMode*/)
  1966. {
  1967. ULONG64 RsBSPSTORE = TrapContents.RsBSPSTORE;
  1968. //
  1969. // Calculate where the stacked registers are for the function which trapped.
  1970. // The regisisters are stored in the kernel backing store notCalculated the users.
  1971. // First calculate the start of the kernel store based on trap address, since
  1972. // this is a user mode trap we should start at the begining of the kernel stack
  1973. // so just round up the trap address to a page size. Next calculate the actual
  1974. // BSP for the function. This depends on the BSP and BSPstore at the time of
  1975. // the trap. Note that the trap handle start the kernel backing store on the
  1976. // same alignment as the user's BSPstore.
  1977. //
  1978. //Calculated
  1979. // Round trap address to a page boundary. The should be the Initial kernel BSP.
  1980. //
  1981. Bsp = (TrapBase + IA64_PAGE_SIZE - 1) & ~(DWORD64)(IA64_PAGE_SIZE - 1);
  1982. //
  1983. // Start the actual stack on the same bountry as the users.
  1984. //
  1985. Bsp += RsBSPSTORE & IA64_RNAT_ALIGNMENT;
  1986. //
  1987. // The BSP of the trap handler is right after all the user values have been
  1988. // saved. The unsaved user values is the differenc of BSP and BSPStore.
  1989. //
  1990. Bsp += TrapContents.RsBSP - RsBSPSTORE;
  1991. }
  1992. else
  1993. {
  1994. //
  1995. // For kernel mode the actual BSP is saved.
  1996. //
  1997. Bsp = TrapContents.RsBSP;
  1998. }
  1999. //
  2000. // Now backup by the size of the faulting functions frame.
  2001. //
  2002. Bsp -= (SizeOfFrame * sizeof(ULONGLONG));
  2003. //
  2004. // Adjust for saved RNATs
  2005. //
  2006. temp = (SHORT)(Bsp >> 3) & IA64_NAT_BITS_PER_RNAT_REG;
  2007. temp += (SHORT)SizeOfFrame - IA64_NAT_BITS_PER_RNAT_REG;
  2008. while (temp >= 0)
  2009. {
  2010. Bsp -= sizeof(ULONGLONG);
  2011. temp -= IA64_NAT_BITS_PER_RNAT_REG;
  2012. }
  2013. ZeroMemory(Context, sizeof(*Context));
  2014. #define CPCXT(Fld) Context->IA64Context.Fld = TrapContents.Fld
  2015. CPCXT(BrRp); CPCXT(BrT0); CPCXT(BrT1);
  2016. CPCXT(FltT0); CPCXT(FltT1); CPCXT(FltT2); CPCXT(FltT3); CPCXT(FltT4);
  2017. CPCXT(FltT5); CPCXT(FltT6); CPCXT(FltT7); CPCXT(FltT8); CPCXT(FltT9);
  2018. CPCXT(ApUNAT); CPCXT(ApCCV); CPCXT(ApDCR); CPCXT(Preds);
  2019. CPCXT(RsRSC); CPCXT(RsRNAT); CPCXT(RsBSPSTORE); CPCXT(RsBSP); CPCXT(RsPFS);
  2020. CPCXT(StIPSR); CPCXT(StIIP); CPCXT(StIFS); CPCXT(StFPSR);
  2021. CPCXT(IntSp); CPCXT(IntGp); CPCXT(IntV0); CPCXT(IntTeb); CPCXT(IntNats);
  2022. CPCXT(IntT0); CPCXT(IntT1); CPCXT(IntT2); CPCXT(IntT3); CPCXT(IntT4);
  2023. CPCXT(IntT5); CPCXT(IntT6); CPCXT(IntT7); CPCXT(IntT8); CPCXT(IntT9);
  2024. CPCXT(IntT10); CPCXT(IntT11); CPCXT(IntT12); CPCXT(IntT13); CPCXT(IntT14);
  2025. CPCXT(IntT15); CPCXT(IntT16); CPCXT(IntT17); CPCXT(IntT18); CPCXT(IntT19);
  2026. CPCXT(IntT20); CPCXT(IntT21); CPCXT(IntT22);
  2027. Context->IA64Context.RsBSP = Bsp; // Store the real Bsp
  2028. #undef CPCXT
  2029. return S_OK;
  2030. }
  2031. void
  2032. Ia64MachineInfo::GetScopeFrameFromContext(PCROSS_PLATFORM_CONTEXT Context,
  2033. PDEBUG_STACK_FRAME ScopeFrame)
  2034. {
  2035. ZeroMemory(ScopeFrame, sizeof(*ScopeFrame));
  2036. ScopeFrame->InstructionOffset = Context->IA64Context.StIIP;
  2037. ScopeFrame->StackOffset = Context->IA64Context.IntSp;
  2038. ScopeFrame->FrameOffset = Context->IA64Context.RsBSP;
  2039. }
  2040. HRESULT
  2041. Ia64MachineInfo::GetScopeFrameRegister(ULONG Reg,
  2042. PDEBUG_STACK_FRAME ScopeFrame,
  2043. PULONG64 Value)
  2044. {
  2045. HRESULT Status;
  2046. REGVAL RegVal;
  2047. switch(Reg)
  2048. {
  2049. case INTSP:
  2050. *Value = ScopeFrame->StackOffset;
  2051. return S_OK;
  2052. case RSBSP:
  2053. *Value = ScopeFrame->FrameOffset;
  2054. return S_OK;
  2055. case STIFS:
  2056. *Value = IA64_SAVE_IFS(ScopeFrame);
  2057. return S_OK;
  2058. default:
  2059. m_IfsOverride = IA64_SAVE_IFS(ScopeFrame);
  2060. m_BspOverride = ScopeFrame->FrameOffset;
  2061. Status = FullGetVal(Reg, &RegVal);
  2062. m_IfsOverride = 0;
  2063. m_BspOverride = 0;
  2064. if (Status != S_OK)
  2065. {
  2066. return Status;
  2067. }
  2068. *Value = RegVal.I64;
  2069. return S_OK;
  2070. }
  2071. }
  2072. HRESULT
  2073. Ia64MachineInfo::SetScopeFrameRegister(ULONG Reg,
  2074. PDEBUG_STACK_FRAME ScopeFrame,
  2075. ULONG64 Value)
  2076. {
  2077. REGVAL RegVal;
  2078. HRESULT Status;
  2079. switch(Reg)
  2080. {
  2081. case INTSP:
  2082. ScopeFrame->StackOffset = Value;
  2083. return S_OK;
  2084. case RSBSP:
  2085. ScopeFrame->FrameOffset = Value;
  2086. return S_OK;
  2087. case STIFS:
  2088. IA64_SAVE_IFS(ScopeFrame) = Value;
  2089. return S_OK;
  2090. default:
  2091. m_IfsOverride = IA64_SAVE_IFS(ScopeFrame);
  2092. m_BspOverride = ScopeFrame->FrameOffset;
  2093. RegVal.Type = GetType(Reg);
  2094. RegVal.I64 = Value;
  2095. Status = FullSetVal(Reg, &RegVal);
  2096. m_IfsOverride = 0;
  2097. m_BspOverride = 0;
  2098. return Status;
  2099. }
  2100. }
  2101. HRESULT
  2102. Ia64MachineInfo::GetExdiContext(IUnknown* Exdi, PEXDI_CONTEXT Context,
  2103. EXDI_CONTEXT_TYPE CtxType)
  2104. {
  2105. DBG_ASSERT(CtxType == EXDI_CTX_IA64);
  2106. // Always ask for everything.
  2107. Context->IA64Context.RegGroupSelection.fIntegerRegs = TRUE;
  2108. Context->IA64Context.RegGroupSelection.fBranchRegs = TRUE;
  2109. Context->IA64Context.RegGroupSelection.fLowFloatRegs = TRUE;
  2110. Context->IA64Context.RegGroupSelection.fHighFloatRegs = TRUE;
  2111. Context->IA64Context.RegGroupSelection.fDebugRegs = TRUE;
  2112. Context->IA64Context.RegGroupSelection.fControlRegs = TRUE;
  2113. Context->IA64Context.RegGroupSelection.fSystemRegs = TRUE;
  2114. return ((IeXdiIA64Context*)Exdi)->GetContext(&Context->IA64Context);
  2115. }
  2116. HRESULT
  2117. Ia64MachineInfo::SetExdiContext(IUnknown* Exdi, PEXDI_CONTEXT Context,
  2118. EXDI_CONTEXT_TYPE CtxType)
  2119. {
  2120. DBG_ASSERT(CtxType == EXDI_CTX_IA64);
  2121. // Don't change the existing group selections on the assumption
  2122. // that there was a full get prior to any modifications so
  2123. // all groups are valid.
  2124. return ((IeXdiIA64Context*)Exdi)->SetContext(Context->IA64Context);
  2125. }
  2126. void
  2127. Ia64MachineInfo::ConvertExdiContextFromContext
  2128. (PCROSS_PLATFORM_CONTEXT Context, PEXDI_CONTEXT ExdiContext,
  2129. EXDI_CONTEXT_TYPE CtxType)
  2130. {
  2131. DBG_ASSERT(CtxType == EXDI_CTX_IA64);
  2132. if (Context->IA64Context.ContextFlags & IA64_CONTEXT_INTEGER)
  2133. {
  2134. ExdiContext->IA64Context.IntR1 = Context->IA64Context.IntGp;
  2135. ExdiContext->IA64Context.IntR2 = Context->IA64Context.IntT0;
  2136. ExdiContext->IA64Context.IntR3 = Context->IA64Context.IntT1;
  2137. ExdiContext->IA64Context.IntR4 = Context->IA64Context.IntS0;
  2138. ExdiContext->IA64Context.IntR5 = Context->IA64Context.IntS1;
  2139. ExdiContext->IA64Context.IntR6 = Context->IA64Context.IntS2;
  2140. ExdiContext->IA64Context.IntR7 = Context->IA64Context.IntS3;
  2141. ExdiContext->IA64Context.IntR8 = Context->IA64Context.IntV0;
  2142. ExdiContext->IA64Context.IntR9 = Context->IA64Context.IntT2;
  2143. ExdiContext->IA64Context.IntR10 = Context->IA64Context.IntT3;
  2144. ExdiContext->IA64Context.IntR11 = Context->IA64Context.IntT4;
  2145. ExdiContext->IA64Context.IntR12 = Context->IA64Context.IntSp;
  2146. ExdiContext->IA64Context.IntR13 = Context->IA64Context.IntTeb;
  2147. ExdiContext->IA64Context.IntR14 = Context->IA64Context.IntT5;
  2148. ExdiContext->IA64Context.IntR15 = Context->IA64Context.IntT6;
  2149. ExdiContext->IA64Context.IntR16 = Context->IA64Context.IntT7;
  2150. ExdiContext->IA64Context.IntR17 = Context->IA64Context.IntT8;
  2151. ExdiContext->IA64Context.IntR18 = Context->IA64Context.IntT9;
  2152. ExdiContext->IA64Context.IntR19 = Context->IA64Context.IntT10;
  2153. ExdiContext->IA64Context.IntR20 = Context->IA64Context.IntT11;
  2154. ExdiContext->IA64Context.IntR21 = Context->IA64Context.IntT12;
  2155. ExdiContext->IA64Context.IntR22 = Context->IA64Context.IntT13;
  2156. ExdiContext->IA64Context.IntR23 = Context->IA64Context.IntT14;
  2157. ExdiContext->IA64Context.IntR24 = Context->IA64Context.IntT15;
  2158. ExdiContext->IA64Context.IntR25 = Context->IA64Context.IntT16;
  2159. ExdiContext->IA64Context.IntR26 = Context->IA64Context.IntT17;
  2160. ExdiContext->IA64Context.IntR27 = Context->IA64Context.IntT18;
  2161. ExdiContext->IA64Context.IntR28 = Context->IA64Context.IntT19;
  2162. ExdiContext->IA64Context.IntR29 = Context->IA64Context.IntT20;
  2163. ExdiContext->IA64Context.IntR30 = Context->IA64Context.IntT21;
  2164. ExdiContext->IA64Context.IntR31 = Context->IA64Context.IntT22;
  2165. ExdiContext->IA64Context.IntNats = Context->IA64Context.IntNats;
  2166. ExdiContext->IA64Context.Preds = Context->IA64Context.Preds;
  2167. ExdiContext->IA64Context.Br0 = Context->IA64Context.BrRp;
  2168. ExdiContext->IA64Context.Br1 = Context->IA64Context.BrS0;
  2169. ExdiContext->IA64Context.Br2 = Context->IA64Context.BrS1;
  2170. ExdiContext->IA64Context.Br3 = Context->IA64Context.BrS2;
  2171. ExdiContext->IA64Context.Br4 = Context->IA64Context.BrS3;
  2172. ExdiContext->IA64Context.Br5 = Context->IA64Context.BrS4;
  2173. ExdiContext->IA64Context.Br6 = Context->IA64Context.BrT0;
  2174. ExdiContext->IA64Context.Br7 = Context->IA64Context.BrT1;
  2175. }
  2176. if (Context->IA64Context.ContextFlags & IA64_CONTEXT_LOWER_FLOATING_POINT)
  2177. {
  2178. ExdiContext->IA64Context.StFPSR = Context->IA64Context.StFPSR;
  2179. ExdiContext->IA64Context.FltF2 =
  2180. *(IA64_FLOAT128*)&Context->IA64Context.FltS0;
  2181. ExdiContext->IA64Context.FltF3 =
  2182. *(IA64_FLOAT128*)&Context->IA64Context.FltS1;
  2183. ExdiContext->IA64Context.FltF4 =
  2184. *(IA64_FLOAT128*)&Context->IA64Context.FltS2;
  2185. ExdiContext->IA64Context.FltF5 =
  2186. *(IA64_FLOAT128*)&Context->IA64Context.FltS3;
  2187. ExdiContext->IA64Context.FltF6 =
  2188. *(IA64_FLOAT128*)&Context->IA64Context.FltT0;
  2189. ExdiContext->IA64Context.FltF7 =
  2190. *(IA64_FLOAT128*)&Context->IA64Context.FltT1;
  2191. ExdiContext->IA64Context.FltF8 =
  2192. *(IA64_FLOAT128*)&Context->IA64Context.FltT2;
  2193. ExdiContext->IA64Context.FltF9 =
  2194. *(IA64_FLOAT128*)&Context->IA64Context.FltT3;
  2195. ExdiContext->IA64Context.FltF10 =
  2196. *(IA64_FLOAT128*)&Context->IA64Context.FltT4;
  2197. ExdiContext->IA64Context.FltF11 =
  2198. *(IA64_FLOAT128*)&Context->IA64Context.FltT5;
  2199. ExdiContext->IA64Context.FltF12 =
  2200. *(IA64_FLOAT128*)&Context->IA64Context.FltT6;
  2201. ExdiContext->IA64Context.FltF13 =
  2202. *(IA64_FLOAT128*)&Context->IA64Context.FltT7;
  2203. ExdiContext->IA64Context.FltF14 =
  2204. *(IA64_FLOAT128*)&Context->IA64Context.FltT8;
  2205. ExdiContext->IA64Context.FltF15 =
  2206. *(IA64_FLOAT128*)&Context->IA64Context.FltT9;
  2207. }
  2208. if (Context->IA64Context.ContextFlags &
  2209. IA64_CONTEXT_HIGHER_FLOATING_POINT)
  2210. {
  2211. ExdiContext->IA64Context.StFPSR = Context->IA64Context.StFPSR;
  2212. ExdiContext->IA64Context.FltF16 =
  2213. *(IA64_FLOAT128*)&Context->IA64Context.FltS4;
  2214. ExdiContext->IA64Context.FltF17 =
  2215. *(IA64_FLOAT128*)&Context->IA64Context.FltS5;
  2216. ExdiContext->IA64Context.FltF18 =
  2217. *(IA64_FLOAT128*)&Context->IA64Context.FltS6;
  2218. ExdiContext->IA64Context.FltF19 =
  2219. *(IA64_FLOAT128*)&Context->IA64Context.FltS7;
  2220. ExdiContext->IA64Context.FltF20 =
  2221. *(IA64_FLOAT128*)&Context->IA64Context.FltS8;
  2222. ExdiContext->IA64Context.FltF21 =
  2223. *(IA64_FLOAT128*)&Context->IA64Context.FltS9;
  2224. ExdiContext->IA64Context.FltF22 =
  2225. *(IA64_FLOAT128*)&Context->IA64Context.FltS10;
  2226. ExdiContext->IA64Context.FltF23 =
  2227. *(IA64_FLOAT128*)&Context->IA64Context.FltS11;
  2228. ExdiContext->IA64Context.FltF24 =
  2229. *(IA64_FLOAT128*)&Context->IA64Context.FltS12;
  2230. ExdiContext->IA64Context.FltF25 =
  2231. *(IA64_FLOAT128*)&Context->IA64Context.FltS13;
  2232. ExdiContext->IA64Context.FltF26 =
  2233. *(IA64_FLOAT128*)&Context->IA64Context.FltS14;
  2234. ExdiContext->IA64Context.FltF27 =
  2235. *(IA64_FLOAT128*)&Context->IA64Context.FltS15;
  2236. ExdiContext->IA64Context.FltF28 =
  2237. *(IA64_FLOAT128*)&Context->IA64Context.FltS16;
  2238. ExdiContext->IA64Context.FltF29 =
  2239. *(IA64_FLOAT128*)&Context->IA64Context.FltS17;
  2240. ExdiContext->IA64Context.FltF30 =
  2241. *(IA64_FLOAT128*)&Context->IA64Context.FltS18;
  2242. ExdiContext->IA64Context.FltF31 =
  2243. *(IA64_FLOAT128*)&Context->IA64Context.FltS19;
  2244. ExdiContext->IA64Context.FltF32 =
  2245. *(IA64_FLOAT128*)&Context->IA64Context.FltF32;
  2246. ExdiContext->IA64Context.FltF33 =
  2247. *(IA64_FLOAT128*)&Context->IA64Context.FltF33;
  2248. ExdiContext->IA64Context.FltF34 =
  2249. *(IA64_FLOAT128*)&Context->IA64Context.FltF34;
  2250. ExdiContext->IA64Context.FltF35 =
  2251. *(IA64_FLOAT128*)&Context->IA64Context.FltF35;
  2252. ExdiContext->IA64Context.FltF36 =
  2253. *(IA64_FLOAT128*)&Context->IA64Context.FltF36;
  2254. ExdiContext->IA64Context.FltF37 =
  2255. *(IA64_FLOAT128*)&Context->IA64Context.FltF37;
  2256. ExdiContext->IA64Context.FltF38 =
  2257. *(IA64_FLOAT128*)&Context->IA64Context.FltF38;
  2258. ExdiContext->IA64Context.FltF39 =
  2259. *(IA64_FLOAT128*)&Context->IA64Context.FltF39;
  2260. ExdiContext->IA64Context.FltF40 =
  2261. *(IA64_FLOAT128*)&Context->IA64Context.FltF40;
  2262. ExdiContext->IA64Context.FltF41 =
  2263. *(IA64_FLOAT128*)&Context->IA64Context.FltF41;
  2264. ExdiContext->IA64Context.FltF42 =
  2265. *(IA64_FLOAT128*)&Context->IA64Context.FltF42;
  2266. ExdiContext->IA64Context.FltF43 =
  2267. *(IA64_FLOAT128*)&Context->IA64Context.FltF43;
  2268. ExdiContext->IA64Context.FltF44 =
  2269. *(IA64_FLOAT128*)&Context->IA64Context.FltF44;
  2270. ExdiContext->IA64Context.FltF45 =
  2271. *(IA64_FLOAT128*)&Context->IA64Context.FltF45;
  2272. ExdiContext->IA64Context.FltF46 =
  2273. *(IA64_FLOAT128*)&Context->IA64Context.FltF46;
  2274. ExdiContext->IA64Context.FltF47 =
  2275. *(IA64_FLOAT128*)&Context->IA64Context.FltF47;
  2276. ExdiContext->IA64Context.FltF48 =
  2277. *(IA64_FLOAT128*)&Context->IA64Context.FltF48;
  2278. ExdiContext->IA64Context.FltF49 =
  2279. *(IA64_FLOAT128*)&Context->IA64Context.FltF49;
  2280. ExdiContext->IA64Context.FltF50 =
  2281. *(IA64_FLOAT128*)&Context->IA64Context.FltF50;
  2282. ExdiContext->IA64Context.FltF51 =
  2283. *(IA64_FLOAT128*)&Context->IA64Context.FltF51;
  2284. ExdiContext->IA64Context.FltF52 =
  2285. *(IA64_FLOAT128*)&Context->IA64Context.FltF52;
  2286. ExdiContext->IA64Context.FltF53 =
  2287. *(IA64_FLOAT128*)&Context->IA64Context.FltF53;
  2288. ExdiContext->IA64Context.FltF54 =
  2289. *(IA64_FLOAT128*)&Context->IA64Context.FltF54;
  2290. ExdiContext->IA64Context.FltF55 =
  2291. *(IA64_FLOAT128*)&Context->IA64Context.FltF55;
  2292. ExdiContext->IA64Context.FltF56 =
  2293. *(IA64_FLOAT128*)&Context->IA64Context.FltF56;
  2294. ExdiContext->IA64Context.FltF57 =
  2295. *(IA64_FLOAT128*)&Context->IA64Context.FltF57;
  2296. ExdiContext->IA64Context.FltF58 =
  2297. *(IA64_FLOAT128*)&Context->IA64Context.FltF58;
  2298. ExdiContext->IA64Context.FltF59 =
  2299. *(IA64_FLOAT128*)&Context->IA64Context.FltF59;
  2300. ExdiContext->IA64Context.FltF60 =
  2301. *(IA64_FLOAT128*)&Context->IA64Context.FltF60;
  2302. ExdiContext->IA64Context.FltF61 =
  2303. *(IA64_FLOAT128*)&Context->IA64Context.FltF61;
  2304. ExdiContext->IA64Context.FltF62 =
  2305. *(IA64_FLOAT128*)&Context->IA64Context.FltF62;
  2306. ExdiContext->IA64Context.FltF63 =
  2307. *(IA64_FLOAT128*)&Context->IA64Context.FltF63;
  2308. ExdiContext->IA64Context.FltF64 =
  2309. *(IA64_FLOAT128*)&Context->IA64Context.FltF64;
  2310. ExdiContext->IA64Context.FltF65 =
  2311. *(IA64_FLOAT128*)&Context->IA64Context.FltF65;
  2312. ExdiContext->IA64Context.FltF66 =
  2313. *(IA64_FLOAT128*)&Context->IA64Context.FltF66;
  2314. ExdiContext->IA64Context.FltF67 =
  2315. *(IA64_FLOAT128*)&Context->IA64Context.FltF67;
  2316. ExdiContext->IA64Context.FltF68 =
  2317. *(IA64_FLOAT128*)&Context->IA64Context.FltF68;
  2318. ExdiContext->IA64Context.FltF69 =
  2319. *(IA64_FLOAT128*)&Context->IA64Context.FltF69;
  2320. ExdiContext->IA64Context.FltF70 =
  2321. *(IA64_FLOAT128*)&Context->IA64Context.FltF70;
  2322. ExdiContext->IA64Context.FltF71 =
  2323. *(IA64_FLOAT128*)&Context->IA64Context.FltF71;
  2324. ExdiContext->IA64Context.FltF72 =
  2325. *(IA64_FLOAT128*)&Context->IA64Context.FltF72;
  2326. ExdiContext->IA64Context.FltF73 =
  2327. *(IA64_FLOAT128*)&Context->IA64Context.FltF73;
  2328. ExdiContext->IA64Context.FltF74 =
  2329. *(IA64_FLOAT128*)&Context->IA64Context.FltF74;
  2330. ExdiContext->IA64Context.FltF75 =
  2331. *(IA64_FLOAT128*)&Context->IA64Context.FltF75;
  2332. ExdiContext->IA64Context.FltF76 =
  2333. *(IA64_FLOAT128*)&Context->IA64Context.FltF76;
  2334. ExdiContext->IA64Context.FltF77 =
  2335. *(IA64_FLOAT128*)&Context->IA64Context.FltF77;
  2336. ExdiContext->IA64Context.FltF78 =
  2337. *(IA64_FLOAT128*)&Context->IA64Context.FltF78;
  2338. ExdiContext->IA64Context.FltF79 =
  2339. *(IA64_FLOAT128*)&Context->IA64Context.FltF79;
  2340. ExdiContext->IA64Context.FltF80 =
  2341. *(IA64_FLOAT128*)&Context->IA64Context.FltF80;
  2342. ExdiContext->IA64Context.FltF81 =
  2343. *(IA64_FLOAT128*)&Context->IA64Context.FltF81;
  2344. ExdiContext->IA64Context.FltF82 =
  2345. *(IA64_FLOAT128*)&Context->IA64Context.FltF82;
  2346. ExdiContext->IA64Context.FltF83 =
  2347. *(IA64_FLOAT128*)&Context->IA64Context.FltF83;
  2348. ExdiContext->IA64Context.FltF84 =
  2349. *(IA64_FLOAT128*)&Context->IA64Context.FltF84;
  2350. ExdiContext->IA64Context.FltF85 =
  2351. *(IA64_FLOAT128*)&Context->IA64Context.FltF85;
  2352. ExdiContext->IA64Context.FltF86 =
  2353. *(IA64_FLOAT128*)&Context->IA64Context.FltF86;
  2354. ExdiContext->IA64Context.FltF87 =
  2355. *(IA64_FLOAT128*)&Context->IA64Context.FltF87;
  2356. ExdiContext->IA64Context.FltF88 =
  2357. *(IA64_FLOAT128*)&Context->IA64Context.FltF88;
  2358. ExdiContext->IA64Context.FltF89 =
  2359. *(IA64_FLOAT128*)&Context->IA64Context.FltF89;
  2360. ExdiContext->IA64Context.FltF90 =
  2361. *(IA64_FLOAT128*)&Context->IA64Context.FltF90;
  2362. ExdiContext->IA64Context.FltF91 =
  2363. *(IA64_FLOAT128*)&Context->IA64Context.FltF91;
  2364. ExdiContext->IA64Context.FltF92 =
  2365. *(IA64_FLOAT128*)&Context->IA64Context.FltF92;
  2366. ExdiContext->IA64Context.FltF93 =
  2367. *(IA64_FLOAT128*)&Context->IA64Context.FltF93;
  2368. ExdiContext->IA64Context.FltF94 =
  2369. *(IA64_FLOAT128*)&Context->IA64Context.FltF94;
  2370. ExdiContext->IA64Context.FltF95 =
  2371. *(IA64_FLOAT128*)&Context->IA64Context.FltF95;
  2372. ExdiContext->IA64Context.FltF96 =
  2373. *(IA64_FLOAT128*)&Context->IA64Context.FltF96;
  2374. ExdiContext->IA64Context.FltF97 =
  2375. *(IA64_FLOAT128*)&Context->IA64Context.FltF97;
  2376. ExdiContext->IA64Context.FltF98 =
  2377. *(IA64_FLOAT128*)&Context->IA64Context.FltF98;
  2378. ExdiContext->IA64Context.FltF99 =
  2379. *(IA64_FLOAT128*)&Context->IA64Context.FltF99;
  2380. ExdiContext->IA64Context.FltF100 =
  2381. *(IA64_FLOAT128*)&Context->IA64Context.FltF100;
  2382. ExdiContext->IA64Context.FltF101 =
  2383. *(IA64_FLOAT128*)&Context->IA64Context.FltF101;
  2384. ExdiContext->IA64Context.FltF102 =
  2385. *(IA64_FLOAT128*)&Context->IA64Context.FltF102;
  2386. ExdiContext->IA64Context.FltF103 =
  2387. *(IA64_FLOAT128*)&Context->IA64Context.FltF103;
  2388. ExdiContext->IA64Context.FltF104 =
  2389. *(IA64_FLOAT128*)&Context->IA64Context.FltF104;
  2390. ExdiContext->IA64Context.FltF105 =
  2391. *(IA64_FLOAT128*)&Context->IA64Context.FltF105;
  2392. ExdiContext->IA64Context.FltF106 =
  2393. *(IA64_FLOAT128*)&Context->IA64Context.FltF106;
  2394. ExdiContext->IA64Context.FltF107 =
  2395. *(IA64_FLOAT128*)&Context->IA64Context.FltF107;
  2396. ExdiContext->IA64Context.FltF108 =
  2397. *(IA64_FLOAT128*)&Context->IA64Context.FltF108;
  2398. ExdiContext->IA64Context.FltF109 =
  2399. *(IA64_FLOAT128*)&Context->IA64Context.FltF109;
  2400. ExdiContext->IA64Context.FltF110 =
  2401. *(IA64_FLOAT128*)&Context->IA64Context.FltF110;
  2402. ExdiContext->IA64Context.FltF111 =
  2403. *(IA64_FLOAT128*)&Context->IA64Context.FltF111;
  2404. ExdiContext->IA64Context.FltF112 =
  2405. *(IA64_FLOAT128*)&Context->IA64Context.FltF112;
  2406. ExdiContext->IA64Context.FltF113 =
  2407. *(IA64_FLOAT128*)&Context->IA64Context.FltF113;
  2408. ExdiContext->IA64Context.FltF114 =
  2409. *(IA64_FLOAT128*)&Context->IA64Context.FltF114;
  2410. ExdiContext->IA64Context.FltF115 =
  2411. *(IA64_FLOAT128*)&Context->IA64Context.FltF115;
  2412. ExdiContext->IA64Context.FltF116 =
  2413. *(IA64_FLOAT128*)&Context->IA64Context.FltF116;
  2414. ExdiContext->IA64Context.FltF117 =
  2415. *(IA64_FLOAT128*)&Context->IA64Context.FltF117;
  2416. ExdiContext->IA64Context.FltF118 =
  2417. *(IA64_FLOAT128*)&Context->IA64Context.FltF118;
  2418. ExdiContext->IA64Context.FltF119 =
  2419. *(IA64_FLOAT128*)&Context->IA64Context.FltF119;
  2420. ExdiContext->IA64Context.FltF120 =
  2421. *(IA64_FLOAT128*)&Context->IA64Context.FltF120;
  2422. ExdiContext->IA64Context.FltF121 =
  2423. *(IA64_FLOAT128*)&Context->IA64Context.FltF121;
  2424. ExdiContext->IA64Context.FltF122 =
  2425. *(IA64_FLOAT128*)&Context->IA64Context.FltF122;
  2426. ExdiContext->IA64Context.FltF123 =
  2427. *(IA64_FLOAT128*)&Context->IA64Context.FltF123;
  2428. ExdiContext->IA64Context.FltF124 =
  2429. *(IA64_FLOAT128*)&Context->IA64Context.FltF124;
  2430. ExdiContext->IA64Context.FltF125 =
  2431. *(IA64_FLOAT128*)&Context->IA64Context.FltF125;
  2432. ExdiContext->IA64Context.FltF126 =
  2433. *(IA64_FLOAT128*)&Context->IA64Context.FltF126;
  2434. ExdiContext->IA64Context.FltF127 =
  2435. *(IA64_FLOAT128*)&Context->IA64Context.FltF127;
  2436. }
  2437. if (Context->IA64Context.ContextFlags & IA64_CONTEXT_DEBUG)
  2438. {
  2439. ExdiContext->IA64Context.DbI0 = Context->IA64Context.DbI0;
  2440. ExdiContext->IA64Context.DbI1 = Context->IA64Context.DbI1;
  2441. ExdiContext->IA64Context.DbI2 = Context->IA64Context.DbI2;
  2442. ExdiContext->IA64Context.DbI3 = Context->IA64Context.DbI3;
  2443. ExdiContext->IA64Context.DbI4 = Context->IA64Context.DbI4;
  2444. ExdiContext->IA64Context.DbI5 = Context->IA64Context.DbI5;
  2445. ExdiContext->IA64Context.DbI6 = Context->IA64Context.DbI6;
  2446. ExdiContext->IA64Context.DbI7 = Context->IA64Context.DbI7;
  2447. ExdiContext->IA64Context.DbD0 = Context->IA64Context.DbD0;
  2448. ExdiContext->IA64Context.DbD1 = Context->IA64Context.DbD1;
  2449. ExdiContext->IA64Context.DbD2 = Context->IA64Context.DbD2;
  2450. ExdiContext->IA64Context.DbD3 = Context->IA64Context.DbD3;
  2451. ExdiContext->IA64Context.DbD4 = Context->IA64Context.DbD4;
  2452. ExdiContext->IA64Context.DbD5 = Context->IA64Context.DbD5;
  2453. ExdiContext->IA64Context.DbD6 = Context->IA64Context.DbD6;
  2454. ExdiContext->IA64Context.DbD7 = Context->IA64Context.DbD7;
  2455. }
  2456. if (Context->IA64Context.ContextFlags & IA64_CONTEXT_CONTROL)
  2457. {
  2458. ExdiContext->IA64Context.IntR1 = Context->IA64Context.IntGp;
  2459. ExdiContext->IA64Context.IntR12 = Context->IA64Context.IntSp;
  2460. ExdiContext->IA64Context.Br0 = Context->IA64Context.BrRp;
  2461. ExdiContext->IA64Context.StFPSR = Context->IA64Context.StFPSR;
  2462. ExdiContext->IA64Context.ApUNAT = Context->IA64Context.ApUNAT;
  2463. ExdiContext->IA64Context.ApLC = Context->IA64Context.ApLC;
  2464. ExdiContext->IA64Context.ApEC = Context->IA64Context.ApEC;
  2465. ExdiContext->IA64Context.ApCCV = Context->IA64Context.ApCCV;
  2466. ExdiContext->IA64Context.ApDCR = Context->IA64Context.ApDCR;
  2467. ExdiContext->IA64Context.RsPFS = Context->IA64Context.RsPFS;
  2468. ExdiContext->IA64Context.RsBSP = Context->IA64Context.RsBSP;
  2469. ExdiContext->IA64Context.RsBSPSTORE = Context->IA64Context.RsBSPSTORE;
  2470. ExdiContext->IA64Context.RsRSC = Context->IA64Context.RsRSC;
  2471. ExdiContext->IA64Context.RsRNAT = Context->IA64Context.RsRNAT;
  2472. ExdiContext->IA64Context.StIPSR = Context->IA64Context.StIPSR;
  2473. ExdiContext->IA64Context.StIIP = Context->IA64Context.StIIP;
  2474. ExdiContext->IA64Context.StIFS = Context->IA64Context.StIFS;
  2475. }
  2476. if (Context->IA64Context.ContextFlags & (IA64_CONTEXT_CONTROL |
  2477. IA64_CONTEXT_IA32_CONTROL))
  2478. {
  2479. ExdiContext->IA64Context.StFCR = Context->IA64Context.StFCR;
  2480. ExdiContext->IA64Context.Eflag = Context->IA64Context.Eflag;
  2481. ExdiContext->IA64Context.SegCSD = Context->IA64Context.SegCSD;
  2482. ExdiContext->IA64Context.SegSSD = Context->IA64Context.SegSSD;
  2483. ExdiContext->IA64Context.Cflag = Context->IA64Context.Cflag;
  2484. ExdiContext->IA64Context.StFSR = Context->IA64Context.StFSR;
  2485. ExdiContext->IA64Context.StFIR = Context->IA64Context.StFIR;
  2486. ExdiContext->IA64Context.StFDR = Context->IA64Context.StFDR;
  2487. }
  2488. }
  2489. void
  2490. Ia64MachineInfo::ConvertExdiContextToContext(PEXDI_CONTEXT ExdiContext,
  2491. EXDI_CONTEXT_TYPE CtxType,
  2492. PCROSS_PLATFORM_CONTEXT Context)
  2493. {
  2494. DBG_ASSERT(CtxType == EXDI_CTX_IA64);
  2495. Context->IA64Context.IntGp = ExdiContext->IA64Context.IntR1;
  2496. Context->IA64Context.IntT0 = ExdiContext->IA64Context.IntR2;
  2497. Context->IA64Context.IntT1 = ExdiContext->IA64Context.IntR3;
  2498. Context->IA64Context.IntS0 = ExdiContext->IA64Context.IntR4;
  2499. Context->IA64Context.IntS1 = ExdiContext->IA64Context.IntR5;
  2500. Context->IA64Context.IntS2 = ExdiContext->IA64Context.IntR6;
  2501. Context->IA64Context.IntS3 = ExdiContext->IA64Context.IntR7;
  2502. Context->IA64Context.IntV0 = ExdiContext->IA64Context.IntR8;
  2503. Context->IA64Context.IntT2 = ExdiContext->IA64Context.IntR9;
  2504. Context->IA64Context.IntT3 = ExdiContext->IA64Context.IntR10;
  2505. Context->IA64Context.IntT4 = ExdiContext->IA64Context.IntR11;
  2506. Context->IA64Context.IntSp = ExdiContext->IA64Context.IntR12;
  2507. Context->IA64Context.IntTeb = ExdiContext->IA64Context.IntR13;
  2508. Context->IA64Context.IntT5 = ExdiContext->IA64Context.IntR14;
  2509. Context->IA64Context.IntT6 = ExdiContext->IA64Context.IntR15;
  2510. Context->IA64Context.IntT7 = ExdiContext->IA64Context.IntR16;
  2511. Context->IA64Context.IntT8 = ExdiContext->IA64Context.IntR17;
  2512. Context->IA64Context.IntT9 = ExdiContext->IA64Context.IntR18;
  2513. Context->IA64Context.IntT10 = ExdiContext->IA64Context.IntR19;
  2514. Context->IA64Context.IntT11 = ExdiContext->IA64Context.IntR20;
  2515. Context->IA64Context.IntT12 = ExdiContext->IA64Context.IntR21;
  2516. Context->IA64Context.IntT13 = ExdiContext->IA64Context.IntR22;
  2517. Context->IA64Context.IntT14 = ExdiContext->IA64Context.IntR23;
  2518. Context->IA64Context.IntT15 = ExdiContext->IA64Context.IntR24;
  2519. Context->IA64Context.IntT16 = ExdiContext->IA64Context.IntR25;
  2520. Context->IA64Context.IntT17 = ExdiContext->IA64Context.IntR26;
  2521. Context->IA64Context.IntT18 = ExdiContext->IA64Context.IntR27;
  2522. Context->IA64Context.IntT19 = ExdiContext->IA64Context.IntR28;
  2523. Context->IA64Context.IntT20 = ExdiContext->IA64Context.IntR29;
  2524. Context->IA64Context.IntT21 = ExdiContext->IA64Context.IntR30;
  2525. Context->IA64Context.IntT22 = ExdiContext->IA64Context.IntR31;
  2526. Context->IA64Context.IntNats = ExdiContext->IA64Context.IntNats;
  2527. Context->IA64Context.Preds = ExdiContext->IA64Context.Preds;
  2528. Context->IA64Context.BrRp = ExdiContext->IA64Context.Br0;
  2529. Context->IA64Context.BrS0 = ExdiContext->IA64Context.Br1;
  2530. Context->IA64Context.BrS1 = ExdiContext->IA64Context.Br2;
  2531. Context->IA64Context.BrS2 = ExdiContext->IA64Context.Br3;
  2532. Context->IA64Context.BrS3 = ExdiContext->IA64Context.Br4;
  2533. Context->IA64Context.BrS4 = ExdiContext->IA64Context.Br5;
  2534. Context->IA64Context.BrT0 = ExdiContext->IA64Context.Br6;
  2535. Context->IA64Context.BrT1 = ExdiContext->IA64Context.Br7;
  2536. Context->IA64Context.StFPSR = ExdiContext->IA64Context.StFPSR;
  2537. memcpy(&Context->IA64Context.FltS0, &ExdiContext->IA64Context.FltF2,
  2538. sizeof(IA64_FLOAT128));
  2539. memcpy(&Context->IA64Context.FltS1, &ExdiContext->IA64Context.FltF3,
  2540. sizeof(IA64_FLOAT128));
  2541. memcpy(&Context->IA64Context.FltS2, &ExdiContext->IA64Context.FltF4,
  2542. sizeof(IA64_FLOAT128));
  2543. memcpy(&Context->IA64Context.FltS3, &ExdiContext->IA64Context.FltF5,
  2544. sizeof(IA64_FLOAT128));
  2545. memcpy(&Context->IA64Context.FltT0, &ExdiContext->IA64Context.FltF6,
  2546. sizeof(IA64_FLOAT128));
  2547. memcpy(&Context->IA64Context.FltT1, &ExdiContext->IA64Context.FltF7,
  2548. sizeof(IA64_FLOAT128));
  2549. memcpy(&Context->IA64Context.FltT2, &ExdiContext->IA64Context.FltF8,
  2550. sizeof(IA64_FLOAT128));
  2551. memcpy(&Context->IA64Context.FltT3, &ExdiContext->IA64Context.FltF9,
  2552. sizeof(IA64_FLOAT128));
  2553. memcpy(&Context->IA64Context.FltT4, &ExdiContext->IA64Context.FltF10,
  2554. sizeof(IA64_FLOAT128));
  2555. memcpy(&Context->IA64Context.FltT5, &ExdiContext->IA64Context.FltF11,
  2556. sizeof(IA64_FLOAT128));
  2557. memcpy(&Context->IA64Context.FltT6, &ExdiContext->IA64Context.FltF12,
  2558. sizeof(IA64_FLOAT128));
  2559. memcpy(&Context->IA64Context.FltT7, &ExdiContext->IA64Context.FltF13,
  2560. sizeof(IA64_FLOAT128));
  2561. memcpy(&Context->IA64Context.FltT8, &ExdiContext->IA64Context.FltF14,
  2562. sizeof(IA64_FLOAT128));
  2563. memcpy(&Context->IA64Context.FltT9, &ExdiContext->IA64Context.FltF15,
  2564. sizeof(IA64_FLOAT128));
  2565. Context->IA64Context.StFPSR = ExdiContext->IA64Context.StFPSR;
  2566. memcpy(&Context->IA64Context.FltS4, &ExdiContext->IA64Context.FltF16,
  2567. sizeof(IA64_FLOAT128));
  2568. memcpy(&Context->IA64Context.FltS5, &ExdiContext->IA64Context.FltF17,
  2569. sizeof(IA64_FLOAT128));
  2570. memcpy(&Context->IA64Context.FltS6, &ExdiContext->IA64Context.FltF18,
  2571. sizeof(IA64_FLOAT128));
  2572. memcpy(&Context->IA64Context.FltS7, &ExdiContext->IA64Context.FltF19,
  2573. sizeof(IA64_FLOAT128));
  2574. memcpy(&Context->IA64Context.FltS8, &ExdiContext->IA64Context.FltF20,
  2575. sizeof(IA64_FLOAT128));
  2576. memcpy(&Context->IA64Context.FltS9, &ExdiContext->IA64Context.FltF21,
  2577. sizeof(IA64_FLOAT128));
  2578. memcpy(&Context->IA64Context.FltS10, &ExdiContext->IA64Context.FltF22,
  2579. sizeof(IA64_FLOAT128));
  2580. memcpy(&Context->IA64Context.FltS11, &ExdiContext->IA64Context.FltF23,
  2581. sizeof(IA64_FLOAT128));
  2582. memcpy(&Context->IA64Context.FltS12, &ExdiContext->IA64Context.FltF24,
  2583. sizeof(IA64_FLOAT128));
  2584. memcpy(&Context->IA64Context.FltS13, &ExdiContext->IA64Context.FltF25,
  2585. sizeof(IA64_FLOAT128));
  2586. memcpy(&Context->IA64Context.FltS14, &ExdiContext->IA64Context.FltF26,
  2587. sizeof(IA64_FLOAT128));
  2588. memcpy(&Context->IA64Context.FltS15, &ExdiContext->IA64Context.FltF27,
  2589. sizeof(IA64_FLOAT128));
  2590. memcpy(&Context->IA64Context.FltS16, &ExdiContext->IA64Context.FltF28,
  2591. sizeof(IA64_FLOAT128));
  2592. memcpy(&Context->IA64Context.FltS17, &ExdiContext->IA64Context.FltF29,
  2593. sizeof(IA64_FLOAT128));
  2594. memcpy(&Context->IA64Context.FltS18, &ExdiContext->IA64Context.FltF30,
  2595. sizeof(IA64_FLOAT128));
  2596. memcpy(&Context->IA64Context.FltS19, &ExdiContext->IA64Context.FltF31,
  2597. sizeof(IA64_FLOAT128));
  2598. memcpy(&Context->IA64Context.FltF32, &ExdiContext->IA64Context.FltF32,
  2599. sizeof(IA64_FLOAT128));
  2600. memcpy(&Context->IA64Context.FltF33, &ExdiContext->IA64Context.FltF33,
  2601. sizeof(IA64_FLOAT128));
  2602. memcpy(&Context->IA64Context.FltF34, &ExdiContext->IA64Context.FltF34,
  2603. sizeof(IA64_FLOAT128));
  2604. memcpy(&Context->IA64Context.FltF35, &ExdiContext->IA64Context.FltF35,
  2605. sizeof(IA64_FLOAT128));
  2606. memcpy(&Context->IA64Context.FltF36, &ExdiContext->IA64Context.FltF36,
  2607. sizeof(IA64_FLOAT128));
  2608. memcpy(&Context->IA64Context.FltF37, &ExdiContext->IA64Context.FltF37,
  2609. sizeof(IA64_FLOAT128));
  2610. memcpy(&Context->IA64Context.FltF38, &ExdiContext->IA64Context.FltF38,
  2611. sizeof(IA64_FLOAT128));
  2612. memcpy(&Context->IA64Context.FltF39, &ExdiContext->IA64Context.FltF39,
  2613. sizeof(IA64_FLOAT128));
  2614. memcpy(&Context->IA64Context.FltF40, &ExdiContext->IA64Context.FltF40,
  2615. sizeof(IA64_FLOAT128));
  2616. memcpy(&Context->IA64Context.FltF41, &ExdiContext->IA64Context.FltF41,
  2617. sizeof(IA64_FLOAT128));
  2618. memcpy(&Context->IA64Context.FltF42, &ExdiContext->IA64Context.FltF42,
  2619. sizeof(IA64_FLOAT128));
  2620. memcpy(&Context->IA64Context.FltF43, &ExdiContext->IA64Context.FltF43,
  2621. sizeof(IA64_FLOAT128));
  2622. memcpy(&Context->IA64Context.FltF44, &ExdiContext->IA64Context.FltF44,
  2623. sizeof(IA64_FLOAT128));
  2624. memcpy(&Context->IA64Context.FltF45, &ExdiContext->IA64Context.FltF45,
  2625. sizeof(IA64_FLOAT128));
  2626. memcpy(&Context->IA64Context.FltF46, &ExdiContext->IA64Context.FltF46,
  2627. sizeof(IA64_FLOAT128));
  2628. memcpy(&Context->IA64Context.FltF47, &ExdiContext->IA64Context.FltF47,
  2629. sizeof(IA64_FLOAT128));
  2630. memcpy(&Context->IA64Context.FltF48, &ExdiContext->IA64Context.FltF48,
  2631. sizeof(IA64_FLOAT128));
  2632. memcpy(&Context->IA64Context.FltF49, &ExdiContext->IA64Context.FltF49,
  2633. sizeof(IA64_FLOAT128));
  2634. memcpy(&Context->IA64Context.FltF50, &ExdiContext->IA64Context.FltF50,
  2635. sizeof(IA64_FLOAT128));
  2636. memcpy(&Context->IA64Context.FltF51, &ExdiContext->IA64Context.FltF51,
  2637. sizeof(IA64_FLOAT128));
  2638. memcpy(&Context->IA64Context.FltF52, &ExdiContext->IA64Context.FltF52,
  2639. sizeof(IA64_FLOAT128));
  2640. memcpy(&Context->IA64Context.FltF53, &ExdiContext->IA64Context.FltF53,
  2641. sizeof(IA64_FLOAT128));
  2642. memcpy(&Context->IA64Context.FltF54, &ExdiContext->IA64Context.FltF54,
  2643. sizeof(IA64_FLOAT128));
  2644. memcpy(&Context->IA64Context.FltF55, &ExdiContext->IA64Context.FltF55,
  2645. sizeof(IA64_FLOAT128));
  2646. memcpy(&Context->IA64Context.FltF56, &ExdiContext->IA64Context.FltF56,
  2647. sizeof(IA64_FLOAT128));
  2648. memcpy(&Context->IA64Context.FltF57, &ExdiContext->IA64Context.FltF57,
  2649. sizeof(IA64_FLOAT128));
  2650. memcpy(&Context->IA64Context.FltF58, &ExdiContext->IA64Context.FltF58,
  2651. sizeof(IA64_FLOAT128));
  2652. memcpy(&Context->IA64Context.FltF59, &ExdiContext->IA64Context.FltF59,
  2653. sizeof(IA64_FLOAT128));
  2654. memcpy(&Context->IA64Context.FltF60, &ExdiContext->IA64Context.FltF60,
  2655. sizeof(IA64_FLOAT128));
  2656. memcpy(&Context->IA64Context.FltF61, &ExdiContext->IA64Context.FltF61,
  2657. sizeof(IA64_FLOAT128));
  2658. memcpy(&Context->IA64Context.FltF62, &ExdiContext->IA64Context.FltF62,
  2659. sizeof(IA64_FLOAT128));
  2660. memcpy(&Context->IA64Context.FltF63, &ExdiContext->IA64Context.FltF63,
  2661. sizeof(IA64_FLOAT128));
  2662. memcpy(&Context->IA64Context.FltF64, &ExdiContext->IA64Context.FltF64,
  2663. sizeof(IA64_FLOAT128));
  2664. memcpy(&Context->IA64Context.FltF65, &ExdiContext->IA64Context.FltF65,
  2665. sizeof(IA64_FLOAT128));
  2666. memcpy(&Context->IA64Context.FltF66, &ExdiContext->IA64Context.FltF66,
  2667. sizeof(IA64_FLOAT128));
  2668. memcpy(&Context->IA64Context.FltF67, &ExdiContext->IA64Context.FltF67,
  2669. sizeof(IA64_FLOAT128));
  2670. memcpy(&Context->IA64Context.FltF68, &ExdiContext->IA64Context.FltF68,
  2671. sizeof(IA64_FLOAT128));
  2672. memcpy(&Context->IA64Context.FltF69, &ExdiContext->IA64Context.FltF69,
  2673. sizeof(IA64_FLOAT128));
  2674. memcpy(&Context->IA64Context.FltF70, &ExdiContext->IA64Context.FltF70,
  2675. sizeof(IA64_FLOAT128));
  2676. memcpy(&Context->IA64Context.FltF71, &ExdiContext->IA64Context.FltF71,
  2677. sizeof(IA64_FLOAT128));
  2678. memcpy(&Context->IA64Context.FltF72, &ExdiContext->IA64Context.FltF72,
  2679. sizeof(IA64_FLOAT128));
  2680. memcpy(&Context->IA64Context.FltF73, &ExdiContext->IA64Context.FltF73,
  2681. sizeof(IA64_FLOAT128));
  2682. memcpy(&Context->IA64Context.FltF74, &ExdiContext->IA64Context.FltF74,
  2683. sizeof(IA64_FLOAT128));
  2684. memcpy(&Context->IA64Context.FltF75, &ExdiContext->IA64Context.FltF75,
  2685. sizeof(IA64_FLOAT128));
  2686. memcpy(&Context->IA64Context.FltF76, &ExdiContext->IA64Context.FltF76,
  2687. sizeof(IA64_FLOAT128));
  2688. memcpy(&Context->IA64Context.FltF77, &ExdiContext->IA64Context.FltF77,
  2689. sizeof(IA64_FLOAT128));
  2690. memcpy(&Context->IA64Context.FltF78, &ExdiContext->IA64Context.FltF78,
  2691. sizeof(IA64_FLOAT128));
  2692. memcpy(&Context->IA64Context.FltF79, &ExdiContext->IA64Context.FltF79,
  2693. sizeof(IA64_FLOAT128));
  2694. memcpy(&Context->IA64Context.FltF80, &ExdiContext->IA64Context.FltF80,
  2695. sizeof(IA64_FLOAT128));
  2696. memcpy(&Context->IA64Context.FltF81, &ExdiContext->IA64Context.FltF81,
  2697. sizeof(IA64_FLOAT128));
  2698. memcpy(&Context->IA64Context.FltF82, &ExdiContext->IA64Context.FltF82,
  2699. sizeof(IA64_FLOAT128));
  2700. memcpy(&Context->IA64Context.FltF83, &ExdiContext->IA64Context.FltF83,
  2701. sizeof(IA64_FLOAT128));
  2702. memcpy(&Context->IA64Context.FltF84, &ExdiContext->IA64Context.FltF84,
  2703. sizeof(IA64_FLOAT128));
  2704. memcpy(&Context->IA64Context.FltF85, &ExdiContext->IA64Context.FltF85,
  2705. sizeof(IA64_FLOAT128));
  2706. memcpy(&Context->IA64Context.FltF86, &ExdiContext->IA64Context.FltF86,
  2707. sizeof(IA64_FLOAT128));
  2708. memcpy(&Context->IA64Context.FltF87, &ExdiContext->IA64Context.FltF87,
  2709. sizeof(IA64_FLOAT128));
  2710. memcpy(&Context->IA64Context.FltF88, &ExdiContext->IA64Context.FltF88,
  2711. sizeof(IA64_FLOAT128));
  2712. memcpy(&Context->IA64Context.FltF89, &ExdiContext->IA64Context.FltF89,
  2713. sizeof(IA64_FLOAT128));
  2714. memcpy(&Context->IA64Context.FltF90, &ExdiContext->IA64Context.FltF90,
  2715. sizeof(IA64_FLOAT128));
  2716. memcpy(&Context->IA64Context.FltF91, &ExdiContext->IA64Context.FltF91,
  2717. sizeof(IA64_FLOAT128));
  2718. memcpy(&Context->IA64Context.FltF92, &ExdiContext->IA64Context.FltF92,
  2719. sizeof(IA64_FLOAT128));
  2720. memcpy(&Context->IA64Context.FltF93, &ExdiContext->IA64Context.FltF93,
  2721. sizeof(IA64_FLOAT128));
  2722. memcpy(&Context->IA64Context.FltF94, &ExdiContext->IA64Context.FltF94,
  2723. sizeof(IA64_FLOAT128));
  2724. memcpy(&Context->IA64Context.FltF95, &ExdiContext->IA64Context.FltF95,
  2725. sizeof(IA64_FLOAT128));
  2726. memcpy(&Context->IA64Context.FltF96, &ExdiContext->IA64Context.FltF96,
  2727. sizeof(IA64_FLOAT128));
  2728. memcpy(&Context->IA64Context.FltF97, &ExdiContext->IA64Context.FltF97,
  2729. sizeof(IA64_FLOAT128));
  2730. memcpy(&Context->IA64Context.FltF98, &ExdiContext->IA64Context.FltF98,
  2731. sizeof(IA64_FLOAT128));
  2732. memcpy(&Context->IA64Context.FltF99, &ExdiContext->IA64Context.FltF99,
  2733. sizeof(IA64_FLOAT128));
  2734. memcpy(&Context->IA64Context.FltF100, &ExdiContext->IA64Context.FltF100,
  2735. sizeof(IA64_FLOAT128));
  2736. memcpy(&Context->IA64Context.FltF101, &ExdiContext->IA64Context.FltF101,
  2737. sizeof(IA64_FLOAT128));
  2738. memcpy(&Context->IA64Context.FltF102, &ExdiContext->IA64Context.FltF102,
  2739. sizeof(IA64_FLOAT128));
  2740. memcpy(&Context->IA64Context.FltF103, &ExdiContext->IA64Context.FltF103,
  2741. sizeof(IA64_FLOAT128));
  2742. memcpy(&Context->IA64Context.FltF104, &ExdiContext->IA64Context.FltF104,
  2743. sizeof(IA64_FLOAT128));
  2744. memcpy(&Context->IA64Context.FltF105, &ExdiContext->IA64Context.FltF105,
  2745. sizeof(IA64_FLOAT128));
  2746. memcpy(&Context->IA64Context.FltF106, &ExdiContext->IA64Context.FltF106,
  2747. sizeof(IA64_FLOAT128));
  2748. memcpy(&Context->IA64Context.FltF107, &ExdiContext->IA64Context.FltF107,
  2749. sizeof(IA64_FLOAT128));
  2750. memcpy(&Context->IA64Context.FltF108, &ExdiContext->IA64Context.FltF108,
  2751. sizeof(IA64_FLOAT128));
  2752. memcpy(&Context->IA64Context.FltF109, &ExdiContext->IA64Context.FltF109,
  2753. sizeof(IA64_FLOAT128));
  2754. memcpy(&Context->IA64Context.FltF110, &ExdiContext->IA64Context.FltF110,
  2755. sizeof(IA64_FLOAT128));
  2756. memcpy(&Context->IA64Context.FltF111, &ExdiContext->IA64Context.FltF111,
  2757. sizeof(IA64_FLOAT128));
  2758. memcpy(&Context->IA64Context.FltF112, &ExdiContext->IA64Context.FltF112,
  2759. sizeof(IA64_FLOAT128));
  2760. memcpy(&Context->IA64Context.FltF113, &ExdiContext->IA64Context.FltF113,
  2761. sizeof(IA64_FLOAT128));
  2762. memcpy(&Context->IA64Context.FltF114, &ExdiContext->IA64Context.FltF114,
  2763. sizeof(IA64_FLOAT128));
  2764. memcpy(&Context->IA64Context.FltF115, &ExdiContext->IA64Context.FltF115,
  2765. sizeof(IA64_FLOAT128));
  2766. memcpy(&Context->IA64Context.FltF116, &ExdiContext->IA64Context.FltF116,
  2767. sizeof(IA64_FLOAT128));
  2768. memcpy(&Context->IA64Context.FltF117, &ExdiContext->IA64Context.FltF117,
  2769. sizeof(IA64_FLOAT128));
  2770. memcpy(&Context->IA64Context.FltF118, &ExdiContext->IA64Context.FltF118,
  2771. sizeof(IA64_FLOAT128));
  2772. memcpy(&Context->IA64Context.FltF119, &ExdiContext->IA64Context.FltF119,
  2773. sizeof(IA64_FLOAT128));
  2774. memcpy(&Context->IA64Context.FltF120, &ExdiContext->IA64Context.FltF120,
  2775. sizeof(IA64_FLOAT128));
  2776. memcpy(&Context->IA64Context.FltF121, &ExdiContext->IA64Context.FltF121,
  2777. sizeof(IA64_FLOAT128));
  2778. memcpy(&Context->IA64Context.FltF122, &ExdiContext->IA64Context.FltF122,
  2779. sizeof(IA64_FLOAT128));
  2780. memcpy(&Context->IA64Context.FltF123, &ExdiContext->IA64Context.FltF123,
  2781. sizeof(IA64_FLOAT128));
  2782. memcpy(&Context->IA64Context.FltF124, &ExdiContext->IA64Context.FltF124,
  2783. sizeof(IA64_FLOAT128));
  2784. memcpy(&Context->IA64Context.FltF125, &ExdiContext->IA64Context.FltF125,
  2785. sizeof(IA64_FLOAT128));
  2786. memcpy(&Context->IA64Context.FltF126, &ExdiContext->IA64Context.FltF126,
  2787. sizeof(IA64_FLOAT128));
  2788. memcpy(&Context->IA64Context.FltF127, &ExdiContext->IA64Context.FltF127,
  2789. sizeof(IA64_FLOAT128));
  2790. Context->IA64Context.DbI0 = ExdiContext->IA64Context.DbI0;
  2791. Context->IA64Context.DbI1 = ExdiContext->IA64Context.DbI1;
  2792. Context->IA64Context.DbI2 = ExdiContext->IA64Context.DbI2;
  2793. Context->IA64Context.DbI3 = ExdiContext->IA64Context.DbI3;
  2794. Context->IA64Context.DbI4 = ExdiContext->IA64Context.DbI4;
  2795. Context->IA64Context.DbI5 = ExdiContext->IA64Context.DbI5;
  2796. Context->IA64Context.DbI6 = ExdiContext->IA64Context.DbI6;
  2797. Context->IA64Context.DbI7 = ExdiContext->IA64Context.DbI7;
  2798. Context->IA64Context.DbD0 = ExdiContext->IA64Context.DbD0;
  2799. Context->IA64Context.DbD1 = ExdiContext->IA64Context.DbD1;
  2800. Context->IA64Context.DbD2 = ExdiContext->IA64Context.DbD2;
  2801. Context->IA64Context.DbD3 = ExdiContext->IA64Context.DbD3;
  2802. Context->IA64Context.DbD4 = ExdiContext->IA64Context.DbD4;
  2803. Context->IA64Context.DbD5 = ExdiContext->IA64Context.DbD5;
  2804. Context->IA64Context.DbD6 = ExdiContext->IA64Context.DbD6;
  2805. Context->IA64Context.DbD7 = ExdiContext->IA64Context.DbD7;
  2806. Context->IA64Context.IntGp = ExdiContext->IA64Context.IntR1;
  2807. Context->IA64Context.IntSp = ExdiContext->IA64Context.IntR12;
  2808. Context->IA64Context.BrRp = ExdiContext->IA64Context.Br0;
  2809. Context->IA64Context.StFPSR = ExdiContext->IA64Context.StFPSR;
  2810. Context->IA64Context.ApUNAT = ExdiContext->IA64Context.ApUNAT;
  2811. Context->IA64Context.ApLC = ExdiContext->IA64Context.ApLC;
  2812. Context->IA64Context.ApEC = ExdiContext->IA64Context.ApEC;
  2813. Context->IA64Context.ApCCV = ExdiContext->IA64Context.ApCCV;
  2814. Context->IA64Context.ApDCR = ExdiContext->IA64Context.ApDCR;
  2815. Context->IA64Context.RsPFS = ExdiContext->IA64Context.RsPFS;
  2816. Context->IA64Context.RsBSP = ExdiContext->IA64Context.RsBSP;
  2817. Context->IA64Context.RsBSPSTORE = ExdiContext->IA64Context.RsBSPSTORE;
  2818. Context->IA64Context.RsRSC = ExdiContext->IA64Context.RsRSC;
  2819. Context->IA64Context.RsRNAT = ExdiContext->IA64Context.RsRNAT;
  2820. Context->IA64Context.StIPSR = ExdiContext->IA64Context.StIPSR;
  2821. Context->IA64Context.StIIP = ExdiContext->IA64Context.StIIP;
  2822. Context->IA64Context.StIFS = ExdiContext->IA64Context.StIFS;
  2823. Context->IA64Context.StFCR = ExdiContext->IA64Context.StFCR;
  2824. Context->IA64Context.Eflag = ExdiContext->IA64Context.Eflag;
  2825. Context->IA64Context.SegCSD = ExdiContext->IA64Context.SegCSD;
  2826. Context->IA64Context.SegSSD = ExdiContext->IA64Context.SegSSD;
  2827. Context->IA64Context.Cflag = ExdiContext->IA64Context.Cflag;
  2828. Context->IA64Context.StFSR = ExdiContext->IA64Context.StFSR;
  2829. Context->IA64Context.StFIR = ExdiContext->IA64Context.StFIR;
  2830. Context->IA64Context.StFDR = ExdiContext->IA64Context.StFDR;
  2831. }
  2832. void
  2833. Ia64MachineInfo::ConvertExdiContextToSegDescs(PEXDI_CONTEXT ExdiContext,
  2834. EXDI_CONTEXT_TYPE CtxType,
  2835. ULONG Start, ULONG Count,
  2836. PDESCRIPTOR64 Descs)
  2837. {
  2838. DBG_ASSERT(CtxType == EXDI_CTX_IA64);
  2839. while (Count-- > 0)
  2840. {
  2841. Descs->Flags = SEGDESC_INVALID;
  2842. Descs++;
  2843. }
  2844. }
  2845. void
  2846. Ia64MachineInfo::ConvertExdiContextFromSpecial
  2847. (PCROSS_PLATFORM_KSPECIAL_REGISTERS Special,
  2848. PEXDI_CONTEXT ExdiContext, EXDI_CONTEXT_TYPE CtxType)
  2849. {
  2850. DBG_ASSERT(CtxType == EXDI_CTX_IA64);
  2851. ExdiContext->IA64Context.DbI0 = Special->IA64Special.KernelDbI0;
  2852. ExdiContext->IA64Context.DbI1 = Special->IA64Special.KernelDbI1;
  2853. ExdiContext->IA64Context.DbI2 = Special->IA64Special.KernelDbI2;
  2854. ExdiContext->IA64Context.DbI3 = Special->IA64Special.KernelDbI3;
  2855. ExdiContext->IA64Context.DbI4 = Special->IA64Special.KernelDbI4;
  2856. ExdiContext->IA64Context.DbI5 = Special->IA64Special.KernelDbI5;
  2857. ExdiContext->IA64Context.DbI6 = Special->IA64Special.KernelDbI6;
  2858. ExdiContext->IA64Context.DbI7 = Special->IA64Special.KernelDbI7;
  2859. ExdiContext->IA64Context.DbD0 = Special->IA64Special.KernelDbD0;
  2860. ExdiContext->IA64Context.DbD1 = Special->IA64Special.KernelDbD1;
  2861. ExdiContext->IA64Context.DbD2 = Special->IA64Special.KernelDbD2;
  2862. ExdiContext->IA64Context.DbD3 = Special->IA64Special.KernelDbD3;
  2863. ExdiContext->IA64Context.DbD4 = Special->IA64Special.KernelDbD4;
  2864. ExdiContext->IA64Context.DbD5 = Special->IA64Special.KernelDbD5;
  2865. ExdiContext->IA64Context.DbD6 = Special->IA64Special.KernelDbD6;
  2866. ExdiContext->IA64Context.DbD7 = Special->IA64Special.KernelDbD7;
  2867. ExdiContext->IA64Context.PfC0 = Special->IA64Special.KernelPfC0;
  2868. ExdiContext->IA64Context.PfC1 = Special->IA64Special.KernelPfC1;
  2869. ExdiContext->IA64Context.PfC2 = Special->IA64Special.KernelPfC2;
  2870. ExdiContext->IA64Context.PfC3 = Special->IA64Special.KernelPfC3;
  2871. ExdiContext->IA64Context.PfC4 = Special->IA64Special.KernelPfC4;
  2872. ExdiContext->IA64Context.PfC5 = Special->IA64Special.KernelPfC5;
  2873. ExdiContext->IA64Context.PfC6 = Special->IA64Special.KernelPfC6;
  2874. ExdiContext->IA64Context.PfC7 = Special->IA64Special.KernelPfC7;
  2875. ExdiContext->IA64Context.PfD0 = Special->IA64Special.KernelPfD0;
  2876. ExdiContext->IA64Context.PfD1 = Special->IA64Special.KernelPfD1;
  2877. ExdiContext->IA64Context.PfD2 = Special->IA64Special.KernelPfD2;
  2878. ExdiContext->IA64Context.PfD3 = Special->IA64Special.KernelPfD3;
  2879. ExdiContext->IA64Context.PfD4 = Special->IA64Special.KernelPfD4;
  2880. ExdiContext->IA64Context.PfD5 = Special->IA64Special.KernelPfD5;
  2881. ExdiContext->IA64Context.PfD6 = Special->IA64Special.KernelPfD6;
  2882. ExdiContext->IA64Context.PfD7 = Special->IA64Special.KernelPfD7;
  2883. ExdiContext->IA64Context.IntH16 = Special->IA64Special.IntH16;
  2884. ExdiContext->IA64Context.IntH17 = Special->IA64Special.IntH17;
  2885. ExdiContext->IA64Context.IntH18 = Special->IA64Special.IntH18;
  2886. ExdiContext->IA64Context.IntH19 = Special->IA64Special.IntH19;
  2887. ExdiContext->IA64Context.IntH20 = Special->IA64Special.IntH20;
  2888. ExdiContext->IA64Context.IntH21 = Special->IA64Special.IntH21;
  2889. ExdiContext->IA64Context.IntH22 = Special->IA64Special.IntH22;
  2890. ExdiContext->IA64Context.IntH23 = Special->IA64Special.IntH23;
  2891. ExdiContext->IA64Context.IntH24 = Special->IA64Special.IntH24;
  2892. ExdiContext->IA64Context.IntH25 = Special->IA64Special.IntH25;
  2893. ExdiContext->IA64Context.IntH26 = Special->IA64Special.IntH26;
  2894. ExdiContext->IA64Context.IntH27 = Special->IA64Special.IntH27;
  2895. ExdiContext->IA64Context.IntH28 = Special->IA64Special.IntH28;
  2896. ExdiContext->IA64Context.IntH29 = Special->IA64Special.IntH29;
  2897. ExdiContext->IA64Context.IntH30 = Special->IA64Special.IntH30;
  2898. ExdiContext->IA64Context.IntH31 = Special->IA64Special.IntH31;
  2899. ExdiContext->IA64Context.ApCPUID0 = Special->IA64Special.ApCPUID0;
  2900. ExdiContext->IA64Context.ApCPUID1 = Special->IA64Special.ApCPUID1;
  2901. ExdiContext->IA64Context.ApCPUID2 = Special->IA64Special.ApCPUID2;
  2902. ExdiContext->IA64Context.ApCPUID3 = Special->IA64Special.ApCPUID3;
  2903. ExdiContext->IA64Context.ApCPUID4 = Special->IA64Special.ApCPUID4;
  2904. ExdiContext->IA64Context.ApCPUID5 = Special->IA64Special.ApCPUID5;
  2905. ExdiContext->IA64Context.ApCPUID6 = Special->IA64Special.ApCPUID6;
  2906. ExdiContext->IA64Context.ApCPUID7 = Special->IA64Special.ApCPUID7;
  2907. ExdiContext->IA64Context.ApKR0 = Special->IA64Special.ApKR0;
  2908. ExdiContext->IA64Context.ApKR1 = Special->IA64Special.ApKR1;
  2909. ExdiContext->IA64Context.ApKR2 = Special->IA64Special.ApKR2;
  2910. ExdiContext->IA64Context.ApKR3 = Special->IA64Special.ApKR3;
  2911. ExdiContext->IA64Context.ApKR4 = Special->IA64Special.ApKR4;
  2912. ExdiContext->IA64Context.ApKR5 = Special->IA64Special.ApKR5;
  2913. ExdiContext->IA64Context.ApKR6 = Special->IA64Special.ApKR6;
  2914. ExdiContext->IA64Context.ApKR7 = Special->IA64Special.ApKR7;
  2915. ExdiContext->IA64Context.ApITC = Special->IA64Special.ApITC;
  2916. ExdiContext->IA64Context.ApITM = Special->IA64Special.ApITM;
  2917. ExdiContext->IA64Context.ApIVA = Special->IA64Special.ApIVA;
  2918. ExdiContext->IA64Context.ApPTA = Special->IA64Special.ApPTA;
  2919. ExdiContext->IA64Context.ApGPTA = Special->IA64Special.ApGPTA;
  2920. ExdiContext->IA64Context.StISR = Special->IA64Special.StISR;
  2921. ExdiContext->IA64Context.StIFA = Special->IA64Special.StIFA;
  2922. ExdiContext->IA64Context.StITIR = Special->IA64Special.StITIR;
  2923. ExdiContext->IA64Context.StIIPA = Special->IA64Special.StIIPA;
  2924. ExdiContext->IA64Context.StIIM = Special->IA64Special.StIIM;
  2925. ExdiContext->IA64Context.StIHA = Special->IA64Special.StIHA;
  2926. ExdiContext->IA64Context.SaLID = Special->IA64Special.SaLID;
  2927. ExdiContext->IA64Context.SaIVR = Special->IA64Special.SaIVR;
  2928. ExdiContext->IA64Context.SaTPR = Special->IA64Special.SaTPR;
  2929. ExdiContext->IA64Context.SaEOI = Special->IA64Special.SaEOI;
  2930. ExdiContext->IA64Context.SaIRR0 = Special->IA64Special.SaIRR0;
  2931. ExdiContext->IA64Context.SaIRR1 = Special->IA64Special.SaIRR1;
  2932. ExdiContext->IA64Context.SaIRR2 = Special->IA64Special.SaIRR2;
  2933. ExdiContext->IA64Context.SaIRR3 = Special->IA64Special.SaIRR3;
  2934. ExdiContext->IA64Context.SaITV = Special->IA64Special.SaITV;
  2935. ExdiContext->IA64Context.SaPMV = Special->IA64Special.SaPMV;
  2936. ExdiContext->IA64Context.SaCMCV = Special->IA64Special.SaCMCV;
  2937. ExdiContext->IA64Context.SaLRR0 = Special->IA64Special.SaLRR0;
  2938. ExdiContext->IA64Context.SaLRR1 = Special->IA64Special.SaLRR1;
  2939. ExdiContext->IA64Context.Rr0 = Special->IA64Special.Rr0;
  2940. ExdiContext->IA64Context.Rr1 = Special->IA64Special.Rr1;
  2941. ExdiContext->IA64Context.Rr2 = Special->IA64Special.Rr2;
  2942. ExdiContext->IA64Context.Rr3 = Special->IA64Special.Rr3;
  2943. ExdiContext->IA64Context.Rr4 = Special->IA64Special.Rr4;
  2944. ExdiContext->IA64Context.Rr5 = Special->IA64Special.Rr5;
  2945. ExdiContext->IA64Context.Rr6 = Special->IA64Special.Rr6;
  2946. ExdiContext->IA64Context.Rr7 = Special->IA64Special.Rr7;
  2947. ExdiContext->IA64Context.Pkr0 = Special->IA64Special.Pkr0;
  2948. ExdiContext->IA64Context.Pkr1 = Special->IA64Special.Pkr1;
  2949. ExdiContext->IA64Context.Pkr2 = Special->IA64Special.Pkr2;
  2950. ExdiContext->IA64Context.Pkr3 = Special->IA64Special.Pkr3;
  2951. ExdiContext->IA64Context.Pkr4 = Special->IA64Special.Pkr4;
  2952. ExdiContext->IA64Context.Pkr5 = Special->IA64Special.Pkr5;
  2953. ExdiContext->IA64Context.Pkr6 = Special->IA64Special.Pkr6;
  2954. ExdiContext->IA64Context.Pkr7 = Special->IA64Special.Pkr7;
  2955. ExdiContext->IA64Context.Pkr8 = Special->IA64Special.Pkr8;
  2956. ExdiContext->IA64Context.Pkr9 = Special->IA64Special.Pkr9;
  2957. ExdiContext->IA64Context.Pkr10 = Special->IA64Special.Pkr10;
  2958. ExdiContext->IA64Context.Pkr11 = Special->IA64Special.Pkr11;
  2959. ExdiContext->IA64Context.Pkr12 = Special->IA64Special.Pkr12;
  2960. ExdiContext->IA64Context.Pkr13 = Special->IA64Special.Pkr13;
  2961. ExdiContext->IA64Context.Pkr14 = Special->IA64Special.Pkr14;
  2962. ExdiContext->IA64Context.Pkr15 = Special->IA64Special.Pkr15;
  2963. ExdiContext->IA64Context.TrI0 = Special->IA64Special.TrI0;
  2964. ExdiContext->IA64Context.TrI1 = Special->IA64Special.TrI1;
  2965. ExdiContext->IA64Context.TrI2 = Special->IA64Special.TrI2;
  2966. ExdiContext->IA64Context.TrI3 = Special->IA64Special.TrI3;
  2967. ExdiContext->IA64Context.TrI4 = Special->IA64Special.TrI4;
  2968. ExdiContext->IA64Context.TrI5 = Special->IA64Special.TrI5;
  2969. ExdiContext->IA64Context.TrI6 = Special->IA64Special.TrI6;
  2970. ExdiContext->IA64Context.TrI7 = Special->IA64Special.TrI7;
  2971. ExdiContext->IA64Context.TrD0 = Special->IA64Special.TrD0;
  2972. ExdiContext->IA64Context.TrD1 = Special->IA64Special.TrD1;
  2973. ExdiContext->IA64Context.TrD2 = Special->IA64Special.TrD2;
  2974. ExdiContext->IA64Context.TrD3 = Special->IA64Special.TrD3;
  2975. ExdiContext->IA64Context.TrD4 = Special->IA64Special.TrD4;
  2976. ExdiContext->IA64Context.TrD5 = Special->IA64Special.TrD5;
  2977. ExdiContext->IA64Context.TrD6 = Special->IA64Special.TrD6;
  2978. ExdiContext->IA64Context.TrD7 = Special->IA64Special.TrD7;
  2979. ExdiContext->IA64Context.SrMSR0 = Special->IA64Special.SrMSR0;
  2980. ExdiContext->IA64Context.SrMSR1 = Special->IA64Special.SrMSR1;
  2981. ExdiContext->IA64Context.SrMSR2 = Special->IA64Special.SrMSR2;
  2982. ExdiContext->IA64Context.SrMSR3 = Special->IA64Special.SrMSR3;
  2983. ExdiContext->IA64Context.SrMSR4 = Special->IA64Special.SrMSR4;
  2984. ExdiContext->IA64Context.SrMSR5 = Special->IA64Special.SrMSR5;
  2985. ExdiContext->IA64Context.SrMSR6 = Special->IA64Special.SrMSR6;
  2986. ExdiContext->IA64Context.SrMSR7 = Special->IA64Special.SrMSR7;
  2987. }
  2988. void
  2989. Ia64MachineInfo::ConvertExdiContextToSpecial
  2990. (PEXDI_CONTEXT ExdiContext, EXDI_CONTEXT_TYPE CtxType,
  2991. PCROSS_PLATFORM_KSPECIAL_REGISTERS Special)
  2992. {
  2993. DBG_ASSERT(CtxType == EXDI_CTX_IA64);
  2994. Special->IA64Special.KernelDbI0 = ExdiContext->IA64Context.DbI0;
  2995. Special->IA64Special.KernelDbI1 = ExdiContext->IA64Context.DbI1;
  2996. Special->IA64Special.KernelDbI2 = ExdiContext->IA64Context.DbI2;
  2997. Special->IA64Special.KernelDbI3 = ExdiContext->IA64Context.DbI3;
  2998. Special->IA64Special.KernelDbI4 = ExdiContext->IA64Context.DbI4;
  2999. Special->IA64Special.KernelDbI5 = ExdiContext->IA64Context.DbI5;
  3000. Special->IA64Special.KernelDbI6 = ExdiContext->IA64Context.DbI6;
  3001. Special->IA64Special.KernelDbI7 = ExdiContext->IA64Context.DbI7;
  3002. Special->IA64Special.KernelDbD0 = ExdiContext->IA64Context.DbD0;
  3003. Special->IA64Special.KernelDbD1 = ExdiContext->IA64Context.DbD1;
  3004. Special->IA64Special.KernelDbD2 = ExdiContext->IA64Context.DbD2;
  3005. Special->IA64Special.KernelDbD3 = ExdiContext->IA64Context.DbD3;
  3006. Special->IA64Special.KernelDbD4 = ExdiContext->IA64Context.DbD4;
  3007. Special->IA64Special.KernelDbD5 = ExdiContext->IA64Context.DbD5;
  3008. Special->IA64Special.KernelDbD6 = ExdiContext->IA64Context.DbD6;
  3009. Special->IA64Special.KernelDbD7 = ExdiContext->IA64Context.DbD7;
  3010. Special->IA64Special.KernelPfC0 = ExdiContext->IA64Context.PfC0;
  3011. Special->IA64Special.KernelPfC1 = ExdiContext->IA64Context.PfC1;
  3012. Special->IA64Special.KernelPfC2 = ExdiContext->IA64Context.PfC2;
  3013. Special->IA64Special.KernelPfC3 = ExdiContext->IA64Context.PfC3;
  3014. Special->IA64Special.KernelPfC4 = ExdiContext->IA64Context.PfC4;
  3015. Special->IA64Special.KernelPfC5 = ExdiContext->IA64Context.PfC5;
  3016. Special->IA64Special.KernelPfC6 = ExdiContext->IA64Context.PfC6;
  3017. Special->IA64Special.KernelPfC7 = ExdiContext->IA64Context.PfC7;
  3018. Special->IA64Special.KernelPfD0 = ExdiContext->IA64Context.PfD0;
  3019. Special->IA64Special.KernelPfD1 = ExdiContext->IA64Context.PfD1;
  3020. Special->IA64Special.KernelPfD2 = ExdiContext->IA64Context.PfD2;
  3021. Special->IA64Special.KernelPfD3 = ExdiContext->IA64Context.PfD3;
  3022. Special->IA64Special.KernelPfD4 = ExdiContext->IA64Context.PfD4;
  3023. Special->IA64Special.KernelPfD5 = ExdiContext->IA64Context.PfD5;
  3024. Special->IA64Special.KernelPfD6 = ExdiContext->IA64Context.PfD6;
  3025. Special->IA64Special.KernelPfD7 = ExdiContext->IA64Context.PfD7;
  3026. Special->IA64Special.IntH16 = ExdiContext->IA64Context.IntH16;
  3027. Special->IA64Special.IntH17 = ExdiContext->IA64Context.IntH17;
  3028. Special->IA64Special.IntH18 = ExdiContext->IA64Context.IntH18;
  3029. Special->IA64Special.IntH19 = ExdiContext->IA64Context.IntH19;
  3030. Special->IA64Special.IntH20 = ExdiContext->IA64Context.IntH20;
  3031. Special->IA64Special.IntH21 = ExdiContext->IA64Context.IntH21;
  3032. Special->IA64Special.IntH22 = ExdiContext->IA64Context.IntH22;
  3033. Special->IA64Special.IntH23 = ExdiContext->IA64Context.IntH23;
  3034. Special->IA64Special.IntH24 = ExdiContext->IA64Context.IntH24;
  3035. Special->IA64Special.IntH25 = ExdiContext->IA64Context.IntH25;
  3036. Special->IA64Special.IntH26 = ExdiContext->IA64Context.IntH26;
  3037. Special->IA64Special.IntH27 = ExdiContext->IA64Context.IntH27;
  3038. Special->IA64Special.IntH28 = ExdiContext->IA64Context.IntH28;
  3039. Special->IA64Special.IntH29 = ExdiContext->IA64Context.IntH29;
  3040. Special->IA64Special.IntH30 = ExdiContext->IA64Context.IntH30;
  3041. Special->IA64Special.IntH31 = ExdiContext->IA64Context.IntH31;
  3042. Special->IA64Special.ApCPUID0 = ExdiContext->IA64Context.ApCPUID0;
  3043. Special->IA64Special.ApCPUID1 = ExdiContext->IA64Context.ApCPUID1;
  3044. Special->IA64Special.ApCPUID2 = ExdiContext->IA64Context.ApCPUID2;
  3045. Special->IA64Special.ApCPUID3 = ExdiContext->IA64Context.ApCPUID3;
  3046. Special->IA64Special.ApCPUID4 = ExdiContext->IA64Context.ApCPUID4;
  3047. Special->IA64Special.ApCPUID5 = ExdiContext->IA64Context.ApCPUID5;
  3048. Special->IA64Special.ApCPUID6 = ExdiContext->IA64Context.ApCPUID6;
  3049. Special->IA64Special.ApCPUID7 = ExdiContext->IA64Context.ApCPUID7;
  3050. Special->IA64Special.ApKR0 = ExdiContext->IA64Context.ApKR0;
  3051. Special->IA64Special.ApKR1 = ExdiContext->IA64Context.ApKR1;
  3052. Special->IA64Special.ApKR2 = ExdiContext->IA64Context.ApKR2;
  3053. Special->IA64Special.ApKR3 = ExdiContext->IA64Context.ApKR3;
  3054. Special->IA64Special.ApKR4 = ExdiContext->IA64Context.ApKR4;
  3055. Special->IA64Special.ApKR5 = ExdiContext->IA64Context.ApKR5;
  3056. Special->IA64Special.ApKR6 = ExdiContext->IA64Context.ApKR6;
  3057. Special->IA64Special.ApKR7 = ExdiContext->IA64Context.ApKR7;
  3058. Special->IA64Special.ApITC = ExdiContext->IA64Context.ApITC;
  3059. Special->IA64Special.ApITM = ExdiContext->IA64Context.ApITM;
  3060. Special->IA64Special.ApIVA = ExdiContext->IA64Context.ApIVA;
  3061. Special->IA64Special.ApPTA = ExdiContext->IA64Context.ApPTA;
  3062. Special->IA64Special.ApGPTA = ExdiContext->IA64Context.ApGPTA;
  3063. Special->IA64Special.StISR = ExdiContext->IA64Context.StISR;
  3064. Special->IA64Special.StIFA = ExdiContext->IA64Context.StIFA;
  3065. Special->IA64Special.StITIR = ExdiContext->IA64Context.StITIR;
  3066. Special->IA64Special.StIIPA = ExdiContext->IA64Context.StIIPA;
  3067. Special->IA64Special.StIIM = ExdiContext->IA64Context.StIIM;
  3068. Special->IA64Special.StIHA = ExdiContext->IA64Context.StIHA;
  3069. Special->IA64Special.SaLID = ExdiContext->IA64Context.SaLID;
  3070. Special->IA64Special.SaIVR = ExdiContext->IA64Context.SaIVR;
  3071. Special->IA64Special.SaTPR = ExdiContext->IA64Context.SaTPR;
  3072. Special->IA64Special.SaEOI = ExdiContext->IA64Context.SaEOI;
  3073. Special->IA64Special.SaIRR0 = ExdiContext->IA64Context.SaIRR0;
  3074. Special->IA64Special.SaIRR1 = ExdiContext->IA64Context.SaIRR1;
  3075. Special->IA64Special.SaIRR2 = ExdiContext->IA64Context.SaIRR2;
  3076. Special->IA64Special.SaIRR3 = ExdiContext->IA64Context.SaIRR3;
  3077. Special->IA64Special.SaITV = ExdiContext->IA64Context.SaITV;
  3078. Special->IA64Special.SaPMV = ExdiContext->IA64Context.SaPMV;
  3079. Special->IA64Special.SaCMCV = ExdiContext->IA64Context.SaCMCV;
  3080. Special->IA64Special.SaLRR0 = ExdiContext->IA64Context.SaLRR0;
  3081. Special->IA64Special.SaLRR1 = ExdiContext->IA64Context.SaLRR1;
  3082. Special->IA64Special.Rr0 = ExdiContext->IA64Context.Rr0;
  3083. Special->IA64Special.Rr1 = ExdiContext->IA64Context.Rr1;
  3084. Special->IA64Special.Rr2 = ExdiContext->IA64Context.Rr2;
  3085. Special->IA64Special.Rr3 = ExdiContext->IA64Context.Rr3;
  3086. Special->IA64Special.Rr4 = ExdiContext->IA64Context.Rr4;
  3087. Special->IA64Special.Rr5 = ExdiContext->IA64Context.Rr5;
  3088. Special->IA64Special.Rr6 = ExdiContext->IA64Context.Rr6;
  3089. Special->IA64Special.Rr7 = ExdiContext->IA64Context.Rr7;
  3090. Special->IA64Special.Pkr0 = ExdiContext->IA64Context.Pkr0;
  3091. Special->IA64Special.Pkr1 = ExdiContext->IA64Context.Pkr1;
  3092. Special->IA64Special.Pkr2 = ExdiContext->IA64Context.Pkr2;
  3093. Special->IA64Special.Pkr3 = ExdiContext->IA64Context.Pkr3;
  3094. Special->IA64Special.Pkr4 = ExdiContext->IA64Context.Pkr4;
  3095. Special->IA64Special.Pkr5 = ExdiContext->IA64Context.Pkr5;
  3096. Special->IA64Special.Pkr6 = ExdiContext->IA64Context.Pkr6;
  3097. Special->IA64Special.Pkr7 = ExdiContext->IA64Context.Pkr7;
  3098. Special->IA64Special.Pkr8 = ExdiContext->IA64Context.Pkr8;
  3099. Special->IA64Special.Pkr9 = ExdiContext->IA64Context.Pkr9;
  3100. Special->IA64Special.Pkr10 = ExdiContext->IA64Context.Pkr10;
  3101. Special->IA64Special.Pkr11 = ExdiContext->IA64Context.Pkr11;
  3102. Special->IA64Special.Pkr12 = ExdiContext->IA64Context.Pkr12;
  3103. Special->IA64Special.Pkr13 = ExdiContext->IA64Context.Pkr13;
  3104. Special->IA64Special.Pkr14 = ExdiContext->IA64Context.Pkr14;
  3105. Special->IA64Special.Pkr15 = ExdiContext->IA64Context.Pkr15;
  3106. Special->IA64Special.TrI0 = ExdiContext->IA64Context.TrI0;
  3107. Special->IA64Special.TrI1 = ExdiContext->IA64Context.TrI1;
  3108. Special->IA64Special.TrI2 = ExdiContext->IA64Context.TrI2;
  3109. Special->IA64Special.TrI3 = ExdiContext->IA64Context.TrI3;
  3110. Special->IA64Special.TrI4 = ExdiContext->IA64Context.TrI4;
  3111. Special->IA64Special.TrI5 = ExdiContext->IA64Context.TrI5;
  3112. Special->IA64Special.TrI6 = ExdiContext->IA64Context.TrI6;
  3113. Special->IA64Special.TrI7 = ExdiContext->IA64Context.TrI7;
  3114. Special->IA64Special.TrD0 = ExdiContext->IA64Context.TrD0;
  3115. Special->IA64Special.TrD1 = ExdiContext->IA64Context.TrD1;
  3116. Special->IA64Special.TrD2 = ExdiContext->IA64Context.TrD2;
  3117. Special->IA64Special.TrD3 = ExdiContext->IA64Context.TrD3;
  3118. Special->IA64Special.TrD4 = ExdiContext->IA64Context.TrD4;
  3119. Special->IA64Special.TrD5 = ExdiContext->IA64Context.TrD5;
  3120. Special->IA64Special.TrD6 = ExdiContext->IA64Context.TrD6;
  3121. Special->IA64Special.TrD7 = ExdiContext->IA64Context.TrD7;
  3122. Special->IA64Special.SrMSR0 = ExdiContext->IA64Context.SrMSR0;
  3123. Special->IA64Special.SrMSR1 = ExdiContext->IA64Context.SrMSR1;
  3124. Special->IA64Special.SrMSR2 = ExdiContext->IA64Context.SrMSR2;
  3125. Special->IA64Special.SrMSR3 = ExdiContext->IA64Context.SrMSR3;
  3126. Special->IA64Special.SrMSR4 = ExdiContext->IA64Context.SrMSR4;
  3127. Special->IA64Special.SrMSR5 = ExdiContext->IA64Context.SrMSR5;
  3128. Special->IA64Special.SrMSR6 = ExdiContext->IA64Context.SrMSR6;
  3129. Special->IA64Special.SrMSR7 = ExdiContext->IA64Context.SrMSR7;
  3130. }
  3131. int
  3132. Ia64MachineInfo::GetType(ULONG Reg)
  3133. {
  3134. if (Reg >= IA64_FLTBASE && Reg <= IA64_FLTLAST)
  3135. {
  3136. return REGVAL_FLOAT82;
  3137. }
  3138. else if ((Reg >= INTGP && Reg <= INTT22) ||
  3139. (Reg >= INTR32 && Reg <= INTR127))
  3140. {
  3141. return REGVAL_INT64N;
  3142. }
  3143. else if (Reg < IA64_FLAGBASE)
  3144. {
  3145. return REGVAL_INT64;
  3146. }
  3147. else
  3148. {
  3149. return REGVAL_SUB64;
  3150. }
  3151. }
  3152. HRESULT
  3153. Ia64MachineInfo::GetRotatingRegVal(ULONG Reg,
  3154. ULONG64 Bsp,
  3155. ULONG64 FrameMarker,
  3156. REGVAL* Val)
  3157. {
  3158. if (Reg >= IA64_FLTBASE && Reg <= IA64_FLTLAST)
  3159. {
  3160. Reg = RotateFr(Reg, FrameMarker);
  3161. Val->Type = REGVAL_FLOAT82;
  3162. Val->F16Parts.High = 0;
  3163. memcpy(Val->F82,
  3164. (PULONGLONG)&m_Context.IA64Context.DbI0 + Reg,
  3165. sizeof(Val->F82));
  3166. }
  3167. else if ((Reg >= INTGP) && (Reg <= INTT22))
  3168. {
  3169. Val->Type = REGVAL_INT64N;
  3170. Val->Nat = (UCHAR)
  3171. ((m_Context.IA64Context.IntNats >> (Reg - INTGP + 1)) & 0x1);
  3172. Val->I64 =
  3173. *((PULONGLONG)&m_Context.IA64Context.IntGp + Reg - INTGP);
  3174. }
  3175. else if ((Reg >= INTR32) && (Reg <= INTR127))
  3176. {
  3177. Val->Type = REGVAL_INT64N;
  3178. Reg = RotateGr(Reg, FrameMarker) - INTR32;
  3179. if (Reg >= IA64_FM_SOF(FrameMarker))
  3180. {
  3181. #if 0
  3182. ErrOut("Ia64MachineInfo::GetVal: "
  3183. "out-of-frame register r%ld requested\n",
  3184. Reg + 32);
  3185. return E_INVALIDARG;
  3186. #else
  3187. Val->I64 = 0;
  3188. Val->Nat = TRUE;
  3189. return S_OK;
  3190. #endif
  3191. }
  3192. return GetStackedRegVal(g_Process,
  3193. Bsp,
  3194. FrameMarker,
  3195. m_Context.IA64Context.RsRNAT,
  3196. Reg, Val);
  3197. }
  3198. else if (Reg < IA64_SRBASE)
  3199. {
  3200. Val->Type = REGVAL_INT64;
  3201. Val->I64 = *((PULONGLONG)&m_Context.IA64Context.DbI0 + Reg);
  3202. if (Reg == PREDS)
  3203. {
  3204. Val->I64 = RotatePr(Val->I64, FrameMarker, TRUE);
  3205. }
  3206. }
  3207. else
  3208. {
  3209. return E_NOINTERFACE;
  3210. }
  3211. return S_OK;
  3212. }
  3213. HRESULT
  3214. Ia64MachineInfo::GetVal(ULONG Reg, REGVAL* Val)
  3215. {
  3216. HRESULT Status;
  3217. switch(m_ContextState)
  3218. {
  3219. case MCTX_PC:
  3220. switch (Reg)
  3221. {
  3222. case STIIP:
  3223. Val->Type = REGVAL_INT64;
  3224. Val->I64 = m_Context.IA64Context.StIIP;
  3225. return S_OK;
  3226. }
  3227. goto MctxContext;
  3228. case MCTX_REPORT:
  3229. #if 0
  3230. // place holder for Debug/Segment registers manipulation via
  3231. // Control REPORT message
  3232. switch (Reg)
  3233. {
  3234. case KRDBI0:
  3235. Val->Type = REGVAL_INT64;
  3236. Val->I64 = SpecialRegContext.KernelDbi0;
  3237. return S_OK;
  3238. }
  3239. #endif
  3240. //
  3241. // Requested register was not in MCTX_REPORT - go get the next
  3242. // context level.
  3243. //
  3244. case MCTX_NONE:
  3245. MctxContext:
  3246. if ((Status = GetContextState(MCTX_CONTEXT)) != S_OK)
  3247. {
  3248. return Status;
  3249. }
  3250. // Fallthrough!
  3251. case MCTX_CONTEXT:
  3252. if ((Status =
  3253. GetRotatingRegVal(Reg,
  3254. m_IfsOverride ?
  3255. m_BspOverride :
  3256. m_Context.IA64Context.RsBSP,
  3257. m_IfsOverride ?
  3258. IA64_FM_FROM_FS(m_IfsOverride) :
  3259. IA64_FM_FROM_FS(m_Context.IA64Context.StIFS),
  3260. Val)) != E_NOINTERFACE)
  3261. {
  3262. if (Status != S_OK)
  3263. {
  3264. return Status;
  3265. }
  3266. }
  3267. //
  3268. // The requested register is not in our current context, load up
  3269. // a complete context
  3270. //
  3271. if ((Status = GetContextState(MCTX_FULL)) != S_OK)
  3272. {
  3273. return Status;
  3274. }
  3275. }
  3276. //
  3277. // We must have a complete context...
  3278. //
  3279. if ((Status =
  3280. GetRotatingRegVal(Reg,
  3281. m_IfsOverride ?
  3282. m_BspOverride :
  3283. m_Context.IA64Context.RsBSP,
  3284. m_IfsOverride ?
  3285. IA64_FM_FROM_FS(m_IfsOverride) :
  3286. IA64_FM_FROM_FS(m_Context.IA64Context.StIFS),
  3287. Val)) != E_NOINTERFACE)
  3288. {
  3289. return Status;
  3290. }
  3291. else if (IS_KERNEL_TARGET(m_Target) && Reg <= IA64_SREND)
  3292. {
  3293. Val->Type = REGVAL_INT64;
  3294. Val->I64 = *((PULONGLONG)&m_Special.IA64Special.KernelDbI0 +
  3295. (Reg - IA64_SRBASE));
  3296. return S_OK;
  3297. }
  3298. else
  3299. {
  3300. ErrOut("Ia64MachineInfo::GetVal: "
  3301. "unknown register %lx requested\n", Reg);
  3302. return E_INVALIDARG;
  3303. }
  3304. }
  3305. HRESULT
  3306. Ia64MachineInfo::SetRotatingRegVal(ULONG Reg,
  3307. ULONG64 Bsp,
  3308. ULONG64 FrameMarker,
  3309. REGVAL* Val)
  3310. {
  3311. if (Reg >= IA64_FLTBASE && Reg <= IA64_FLTLAST)
  3312. {
  3313. Reg = RotateFr(Reg, FrameMarker);
  3314. memcpy((PULONGLONG)&m_Context.IA64Context.DbI0 + Reg,
  3315. Val->F82, sizeof(Val->F82));
  3316. }
  3317. else if ((Reg >= INTGP) && (Reg <= INTT22))
  3318. {
  3319. ULONG64 Mask = (0x1i64 << (Reg - INTGP + 1));
  3320. if (Val->Nat)
  3321. {
  3322. m_Context.IA64Context.IntNats |= Mask;
  3323. }
  3324. else
  3325. {
  3326. m_Context.IA64Context.IntNats &= ~Mask;
  3327. *((PULONGLONG)&m_Context.IA64Context.DbI0 + Reg) = Val->I64;
  3328. }
  3329. }
  3330. else if ((Reg >= INTR32) && (Reg <= INTR127))
  3331. {
  3332. Reg = RotateGr(Reg, FrameMarker) - INTR32;
  3333. if (Reg >= IA64_FM_SOF(FrameMarker))
  3334. {
  3335. ErrOut("Ia64MachineInfo::SetVal: "
  3336. "out-of-frame register r%ld requested\n",
  3337. Reg + 32);
  3338. return E_INVALIDARG;
  3339. }
  3340. return SetStackedRegVal(g_Process,
  3341. Bsp,
  3342. FrameMarker,
  3343. &m_Context.IA64Context.RsRNAT,
  3344. Reg, Val);
  3345. }
  3346. else if (Reg < IA64_SRBASE)
  3347. {
  3348. ULONG64 RawVal = Val->I64;
  3349. if (Reg == PREDS)
  3350. {
  3351. RawVal = RotatePr(RawVal, FrameMarker, FALSE);
  3352. }
  3353. *((PULONGLONG)&m_Context.IA64Context.DbI0 + Reg) = RawVal;
  3354. }
  3355. else
  3356. {
  3357. return E_NOINTERFACE;
  3358. }
  3359. return S_OK;
  3360. }
  3361. HRESULT
  3362. Ia64MachineInfo::SetVal(ULONG Reg, REGVAL* Val)
  3363. {
  3364. HRESULT Status;
  3365. if (m_ContextIsReadOnly)
  3366. {
  3367. return HRESULT_FROM_WIN32(ERROR_WRITE_FAULT);
  3368. }
  3369. BOOL Ia32InstructionSet = IsIA32InstructionSet();
  3370. // Optimize away some common cases where registers are
  3371. // set to their current value.
  3372. if ((Reg == STIIP) && (m_ContextState >= MCTX_PC))
  3373. {
  3374. if (Val->Type != REGVAL_INT64)
  3375. {
  3376. return E_INVALIDARG;
  3377. }
  3378. ULONG64 Slot, Bundle;
  3379. if ((Ia32InstructionSet &&
  3380. (m_Context.IA64Context.StIIP == Val->I64)) ||
  3381. ((SplitIa64Pc(Val->I64, &Bundle, &Slot) &&
  3382. (Bundle == m_Context.IA64Context.StIIP) &&
  3383. (Slot == ((m_Context.IA64Context.StIPSR & IPSR_RI_MASK) >>
  3384. PSR_RI)))))
  3385. {
  3386. return S_OK;
  3387. }
  3388. }
  3389. if ((Status = GetContextState(MCTX_DIRTY)) != S_OK)
  3390. {
  3391. return Status;
  3392. }
  3393. if (Reg == STIIP)
  3394. {
  3395. ULONG64 Bundle, Slot;
  3396. if ((Val->Type != REGVAL_INT64) ||
  3397. !(Ia32InstructionSet || SplitIa64Pc(Val->I64, &Bundle, &Slot)))
  3398. {
  3399. return E_INVALIDARG;
  3400. }
  3401. if (Ia32InstructionSet)
  3402. {
  3403. m_Context.IA64Context.StIIP = Val->I64;
  3404. }
  3405. else
  3406. {
  3407. m_Context.IA64Context.StIIP = Bundle;
  3408. (m_Context.IA64Context.StIPSR &= ~(IPSR_RI_MASK)) |=
  3409. (ULONGLONG)Slot << PSR_RI;
  3410. }
  3411. }
  3412. else if ((Status =
  3413. SetRotatingRegVal(Reg,
  3414. m_IfsOverride ?
  3415. m_BspOverride :
  3416. m_Context.IA64Context.RsBSP,
  3417. m_IfsOverride ?
  3418. IA64_FM_FROM_FS(m_IfsOverride) :
  3419. IA64_FM_FROM_FS(m_Context.IA64Context.StIFS),
  3420. Val)) != E_NOINTERFACE)
  3421. {
  3422. if (Status != S_OK)
  3423. {
  3424. return Status;
  3425. }
  3426. }
  3427. else if (IS_KERNEL_TARGET(m_Target) && Reg <= IA64_SREND)
  3428. {
  3429. *((PULONGLONG)&m_Special.IA64Special.KernelDbI0 +
  3430. (Reg - IA64_SRBASE)) = Val->I64;
  3431. }
  3432. else
  3433. {
  3434. ErrOut("Ia64MachineInfo::SetVal: "
  3435. "unknown register %lx requested\n", Reg);
  3436. return E_INVALIDARG;
  3437. }
  3438. NotifyChangeDebuggeeState(DEBUG_CDS_REGISTERS,
  3439. RegCountFromIndex(Reg));
  3440. return S_OK;
  3441. }
  3442. void
  3443. Ia64MachineInfo::GetPC (PADDR Address)
  3444. {
  3445. ULONG64 value, slot;
  3446. // get slot# from IPSR.ri and place them in bit(2-3)
  3447. slot = (GetReg64(STIPSR) >> (PSR_RI - 2)) & 0xc;
  3448. // Do not use ISR.ei which does not contain the restart instruction slot.
  3449. value = GetReg64(STIIP) | slot;
  3450. ADDRFLAT(Address, value);
  3451. }
  3452. void
  3453. Ia64MachineInfo::SetPC (PADDR paddr)
  3454. {
  3455. SetReg64(STIIP, Flat(*paddr));
  3456. }
  3457. void
  3458. Ia64MachineInfo::GetFP(PADDR Address)
  3459. {
  3460. // IA64 software convention has no frame pointer defined.
  3461. // FP_REG need to be derived from virtual unwind of stack.
  3462. DEBUG_STACK_FRAME StackFrame;
  3463. StackTrace( NULL,
  3464. 0, 0, 0, STACK_ALL_DEFAULT, &StackFrame, 1, 0, 0, FALSE );
  3465. ADDRFLAT(Address, StackFrame.FrameOffset);
  3466. }
  3467. void
  3468. Ia64MachineInfo::GetSP(PADDR Address)
  3469. {
  3470. ADDRFLAT(Address, GetReg64(INTSP));
  3471. }
  3472. ULONG64
  3473. Ia64MachineInfo::GetArgReg(void)
  3474. {
  3475. return GetReg64(INTT0);
  3476. }
  3477. ULONG64
  3478. Ia64MachineInfo::GetRetReg(void)
  3479. {
  3480. return GetReg64(INTV0);
  3481. }
  3482. /*** RegOutputAll - output all registers and present instruction
  3483. *
  3484. * Purpose:
  3485. * Function of "r" command.
  3486. *
  3487. * To output the current register state of the processor.
  3488. * All integer registers are output as well as processor status
  3489. * registers in the _CONTEXT record. Important flag fields are
  3490. * also output separately. OutDisCurrent is called to output the
  3491. * current instruction(s).
  3492. *
  3493. * Input:
  3494. * None.
  3495. *
  3496. * Output:
  3497. * None.
  3498. *
  3499. *************************************************************************/
  3500. void
  3501. Ia64MachineInfo::OutputAll(ULONG Mask, ULONG OutMask)
  3502. {
  3503. int RegIndex, Col = 0;
  3504. int LastOut;
  3505. USHORT NumStackReg;
  3506. REGVAL Val;
  3507. ULONG i;
  3508. if (GetContextState(MCTX_FULL) != S_OK)
  3509. {
  3510. ErrOut("Unable to retrieve register information\n");
  3511. return;
  3512. }
  3513. // Output user debug registers
  3514. if (Mask & REGALL_DREG)
  3515. {
  3516. for (RegIndex = IA64_DBBASE;
  3517. RegIndex <= IA64_DBLAST;
  3518. RegIndex++)
  3519. {
  3520. MaskOut(OutMask, "%9s = %16I64x",
  3521. RegNameFromIndex(RegIndex),
  3522. GetReg64(RegIndex));
  3523. if (RegIndex % 2 == 1)
  3524. {
  3525. MaskOut(OutMask, "\n");
  3526. }
  3527. else
  3528. {
  3529. MaskOut(OutMask, "\t");
  3530. }
  3531. }
  3532. MaskOut(OutMask, "\n");
  3533. }
  3534. if (Mask & (REGALL_INT32 | REGALL_INT64))
  3535. {
  3536. if (Mask & REGALL_SPECIALREG)
  3537. {
  3538. // + ARs + DBs + SRs
  3539. LastOut = IA64_SREND + 1;
  3540. }
  3541. else
  3542. {
  3543. // INTs, PREDS, BRs,
  3544. LastOut = IA64_SRBASE;
  3545. }
  3546. NumStackReg = (USHORT)(GetReg64(STIFS) & IA64_PFS_SIZE_MASK);
  3547. // Output all registers, skip INTZERO and floating point registers
  3548. for (RegIndex = IA64_REGBASE; RegIndex < LastOut; RegIndex++)
  3549. {
  3550. if (RegIndex == BRRP || RegIndex == PREDS || RegIndex == APUNAT ||
  3551. RegIndex == IA64_SRBASE || RegIndex == INTR32)
  3552. {
  3553. if (Col % 2 == 1)
  3554. {
  3555. MaskOut(OutMask, "\n");
  3556. }
  3557. MaskOut(OutMask, "\n");
  3558. Col = 0;
  3559. }
  3560. if (INTGP <= RegIndex && RegIndex <= INTT22)
  3561. {
  3562. if (GetVal(RegIndex, &Val) == S_OK)
  3563. {
  3564. MaskOut(OutMask, "%9s = %16I64x %1lx",
  3565. RegNameFromIndex(RegIndex),
  3566. Val.I64, Val.Nat);
  3567. }
  3568. if (Col % 2 == 1)
  3569. {
  3570. MaskOut(OutMask, "\n");
  3571. }
  3572. else
  3573. {
  3574. MaskOut(OutMask, "\t");
  3575. }
  3576. Col++;
  3577. }
  3578. else if (INTR32 <= RegIndex && RegIndex <= INTR127)
  3579. {
  3580. if ((NumStackReg != 0) && GetVal(RegIndex, &Val) == S_OK)
  3581. {
  3582. MaskOut(OutMask, "%9s = %16I64x %1lx",
  3583. RegNameFromIndex(RegIndex),
  3584. Val.I64, Val.Nat);
  3585. NumStackReg--;
  3586. if (Col % 2 == 1)
  3587. {
  3588. MaskOut(OutMask, "\n");
  3589. }
  3590. else
  3591. {
  3592. MaskOut(OutMask, "\t");
  3593. }
  3594. Col++;
  3595. }
  3596. }
  3597. else
  3598. {
  3599. MaskOut(OutMask, "%9s = %16I64x",
  3600. RegNameFromIndex(RegIndex),
  3601. GetReg64(RegIndex));
  3602. if (Col % 2 == 1)
  3603. {
  3604. MaskOut(OutMask, "\n");
  3605. }
  3606. else
  3607. {
  3608. MaskOut(OutMask, "\t");
  3609. }
  3610. Col++;
  3611. }
  3612. }
  3613. MaskOut(OutMask, "\n");
  3614. /*
  3615. // Output IPSR flags
  3616. MaskOut(OutMask, "\n\tipsr:\tbn ed ri ss dd da id it tme is cpl rt tb lp db\n");
  3617. MaskOut(OutMask, "\t\t %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx\n",
  3618. GetSubReg32(IPSRBN),
  3619. GetSubReg32(IPSRED),
  3620. GetSubReg32(IPSRRI),
  3621. GetSubReg32(IPSRSS),
  3622. GetSubReg32(IPSRDD),
  3623. GetSubReg32(IPSRDA),
  3624. GetSubReg32(IPSRID),
  3625. GetSubReg32(IPSRIT),
  3626. GetSubReg32(IPSRME),
  3627. GetSubReg32(IPSRIS),
  3628. GetSubReg32(IPSRCPL),
  3629. GetSubReg32(IPSRRT),
  3630. GetSubReg32(IPSRTB),
  3631. GetSubReg32(IPSRLP),
  3632. GetSubReg32(IPSRDB));
  3633. MaskOut(OutMask, "\t\tsi di pp sp dfh dfl dt bn pk i ic ac up be or\n");
  3634. MaskOut(OutMask, "\t\t %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx %1lx\n",
  3635. GetSubReg32(IPSRSI),
  3636. GetSubReg32(IPSRDI),
  3637. GetSubReg32(IPSRPP),
  3638. GetSubReg32(IPSRSP),
  3639. GetSubReg32(IPSRDFH),
  3640. GetSubReg32(IPSRDFL),
  3641. GetSubReg32(IPSRDT),
  3642. GetSubReg32(IPSRPK),
  3643. GetSubReg32(IPSRI),
  3644. GetSubReg32(IPSRIC),
  3645. GetSubReg32(IPSRAC),
  3646. GetSubReg32(IPSRUP),
  3647. GetSubReg32(IPSRBE),
  3648. GetSubReg32(IPSROR));
  3649. */
  3650. }
  3651. if (Mask & REGALL_FLOAT)
  3652. {
  3653. /*
  3654. // Output FPSR flags
  3655. MaskOut(OutMask, "\n\tfpsr:\tmdh mdl sf3 sf2 sf1 sf0 id ud od zd dd vd\n");
  3656. MaskOut(OutMask, "\t\t %1lx %1lx %04lx %04lx %04lx %04lx %1lx %1lx %1lx %1lx %1lx %1lx\n",
  3657. GetSubReg32(FPSRMDH),
  3658. GetSubReg32(FPSRMDL),
  3659. GetSubReg32(FPSRSF3),
  3660. GetSubReg32(FPSRSF2),
  3661. GetSubReg32(FPSRSF1),
  3662. GetSubReg32(FPSRSF0),
  3663. GetSubReg32(FPSRTRAPID),
  3664. GetSubReg32(FPSRTRAPUD),
  3665. GetSubReg32(FPSRTRAPOD),
  3666. GetSubReg32(FPSRTRAPZD),
  3667. GetSubReg32(FPSRTRAPDD),
  3668. GetSubReg32(FPSRTRAPVD));
  3669. */
  3670. //
  3671. // Print the low floating point register set, skip FLTZERO & FLTONE
  3672. //
  3673. MaskOut(OutMask, "\n");
  3674. for (i = IA64_FLTBASE; i < FLTF32; i += 2)
  3675. {
  3676. GetVal(i, &Val);
  3677. MaskOut(OutMask, "%9s = %I64x %I64x\n", RegNameFromIndex(i),
  3678. Val.F16Parts.High, Val.F16Parts.Low);
  3679. }
  3680. }
  3681. if (Mask & REGALL_HIGHFLOAT)
  3682. {
  3683. //
  3684. // Print the low floating point register set, skip FLTZERO & FLTONE
  3685. //
  3686. MaskOut(OutMask, "\n");
  3687. for (i = FLTF32 ; i <= FLTF127; i += 2)
  3688. {
  3689. GetVal(i, &Val);
  3690. MaskOut(OutMask, "%9s = %I64x %I64x\n", RegNameFromIndex(i),
  3691. Val.F16Parts.High, Val.F16Parts.Low);
  3692. }
  3693. }
  3694. }
  3695. #define HIGH128(x) (((FLOAT128 *)(&x))->HighPart)
  3696. #define LOW128(x) (((FLOAT128 *)(&x))->LowPart)
  3697. #define HIGHANDLOW128(x) HIGH128(x), LOW128(x)
  3698. HRESULT
  3699. Ia64MachineInfo::SetAndOutputTrapFrame(ULONG64 TrapBase,
  3700. PCROSS_PLATFORM_CONTEXT Context)
  3701. {
  3702. HRESULT Status;
  3703. IA64_KTRAP_FRAME TrapContents;
  3704. ULONG64 Address = TrapBase, IntSp;
  3705. DWORD64 DisasmAddr;
  3706. DWORD64 Displacement;
  3707. DWORD64 Bsp, RealBsp;
  3708. DWORD SizeOfFrame;
  3709. DWORD i;
  3710. SHORT temp;
  3711. CHAR Buffer[80];
  3712. ULONG64 StIIP, StISR;
  3713. if ((Status = m_Target->ReadAllVirtual(m_Target->m_ProcessHead,
  3714. Address, &TrapContents,
  3715. sizeof(TrapContents))) != S_OK)
  3716. {
  3717. ErrOut("Unable to read trap frame at %s\n",
  3718. FormatMachineAddr64(this, Address));
  3719. return Status;
  3720. }
  3721. dprintf("f6 (ft0) =\t %016I64x %016I64x\n" , HIGHANDLOW128(TrapContents.FltT0) );
  3722. dprintf("f7 (ft1) =\t %016I64x %016I64x\n" , HIGHANDLOW128(TrapContents.FltT1));
  3723. dprintf("f8 (ft2) =\t %016I64x %016I64x\n" , HIGHANDLOW128(TrapContents.FltT2));
  3724. dprintf("f9 (ft3) =\t %016I64x %016I64x\n" , HIGHANDLOW128(TrapContents.FltT3));
  3725. dprintf("f10 (ft3) =\t %016I64x %016I64x\n" , HIGHANDLOW128(TrapContents.FltT4));
  3726. dprintf("f11 (ft4) =\t %016I64x %016I64x\n" , HIGHANDLOW128(TrapContents.FltT5));
  3727. dprintf("f12 (ft5) =\t %016I64x %016I64x\n" , HIGHANDLOW128(TrapContents.FltT6));
  3728. dprintf("f13 (ft6) =\t %016I64x %016I64x\n" , HIGHANDLOW128(TrapContents.FltT7));
  3729. dprintf("f14 (ft7) =\t %016I64x %016I64x\n" , HIGHANDLOW128(TrapContents.FltT8));
  3730. dprintf("f15 (ft8) =\t %016I64x %016I64x\n" , HIGHANDLOW128(TrapContents.FltT9));
  3731. dprintf("unat =\t %016I64lx\t", TrapContents.ApUNAT);
  3732. dprintf("ccv =\t %016I64lx\n" , TrapContents.ApCCV);
  3733. dprintf("dcr =\t %016I64lx\t" , TrapContents.ApDCR);
  3734. dprintf("preds =\t %016I64lx\n",TrapContents.Preds);
  3735. dprintf("rsc =\t %016I64lx\t", TrapContents.RsRSC);
  3736. SizeOfFrame = (ULONG)(TrapContents.StIFS & (IA64_PFS_SIZE_MASK));
  3737. if (TrapContents.PreviousMode == 1 /*UserMode*/)
  3738. {
  3739. ULONG64 RsBSPSTORE=TrapContents.RsBSPSTORE;
  3740. dprintf("rnat =\t %016I64lx\n", TrapContents.RsRNAT);
  3741. dprintf("bspstore=%016I64lx\n", RsBSPSTORE);
  3742. //
  3743. // Calculate where the stacked registers are for the function which trapped.
  3744. // The regisisters are stored in the kernel backing store notCalculated the users.
  3745. // First calculate the start of the kernel store based on trap address, since
  3746. // this is a user mode trap we should start at the begining of the kernel stack
  3747. // so just round up the trap address to a page size. Next calculate the actual
  3748. // BSP for the function. This depends on the BSP and BSPstore at the time of
  3749. // the trap. Note that the trap handle start the kernel backing store on the
  3750. // same alignment as the user's BSPstore.
  3751. //
  3752. //Calculated
  3753. // Round trap address to a page boundary. The should be the Initial kernel BSP.
  3754. //
  3755. Bsp = (Address + IA64_PAGE_SIZE - 1) & ~(DWORD64)(IA64_PAGE_SIZE - 1);
  3756. //
  3757. // Start the actual stack on the same bountry as the users.
  3758. //
  3759. Bsp += RsBSPSTORE & IA64_RNAT_ALIGNMENT;
  3760. //
  3761. // The BSP of the trap handler is right after all the user values have been
  3762. // saved. The unsaved user values is the differenc of BSP and BSPStore.
  3763. //
  3764. Bsp += TrapContents.RsBSP - RsBSPSTORE;
  3765. }
  3766. else
  3767. {
  3768. dprintf("rnat =\t ???????? ????????\n", TrapContents.RsRNAT);
  3769. dprintf("bspstore=???????? ????????\n", TrapContents.RsBSPSTORE);
  3770. //
  3771. // For kernel mode the actual BSP is saved.
  3772. //
  3773. Bsp = TrapContents.RsBSP;
  3774. }
  3775. //
  3776. // Now backup by the size of the faulting functions frame.
  3777. //
  3778. Bsp -= (SizeOfFrame * sizeof(ULONGLONG));
  3779. //
  3780. // Adjust for saved RNATs
  3781. //
  3782. temp = (SHORT)(Bsp >> 3) & IA64_NAT_BITS_PER_RNAT_REG;
  3783. temp += (SHORT)SizeOfFrame - IA64_NAT_BITS_PER_RNAT_REG;
  3784. while (temp >= 0)
  3785. {
  3786. Bsp -= sizeof(ULONGLONG);
  3787. temp -= IA64_NAT_BITS_PER_RNAT_REG;
  3788. }
  3789. dprintf("bsp =\t %016I64lx\t", TrapContents.RsBSP);
  3790. dprintf("Real bsp = %016I64lx\n", RealBsp = Bsp);
  3791. dprintf("r1 (gp) =\t %016I64lx\t" , TrapContents.IntGp);
  3792. dprintf("r2 (t0) =\t %016I64lx\n" , TrapContents.IntT0);
  3793. dprintf("r3 (t1) =\t %016I64lx\t" , TrapContents.IntT1);
  3794. dprintf("r8 (v0) =\t %016I64lx\n" , TrapContents.IntV0);
  3795. dprintf("r9 (t2) =\t %016I64lx\t" , TrapContents.IntT2);
  3796. dprintf("r10 (t3) =\t %016I64lx\n" , TrapContents.IntT3);
  3797. dprintf("r11 (t4) =\t %016I64lx\t" , TrapContents.IntT4);
  3798. dprintf("r12 (sp) =\t %016I64lx\n" , IntSp = TrapContents.IntSp);
  3799. dprintf("r13 (teb) =\t %016I64lx\t" , TrapContents.IntTeb);
  3800. dprintf("r14 (t5) =\t %016I64lx\n" , TrapContents.IntT5);
  3801. dprintf("r15 (t6) =\t %016I64lx\t" , TrapContents.IntT6);
  3802. dprintf("r16 (t7) =\t %016I64lx\n" , TrapContents.IntT7);
  3803. dprintf("r17 (t8) =\t %016I64lx\t" , TrapContents.IntT8);
  3804. dprintf("r18 (t9) =\t %016I64lx\n" , TrapContents.IntT9);
  3805. dprintf("r19 (t10) =\t %016I64lx\t" , TrapContents.IntT10);
  3806. dprintf("r20 (t11) =\t %016I64lx\n" , TrapContents.IntT11);
  3807. dprintf("r21 (t12) =\t %016I64lx\t" , TrapContents.IntT12);
  3808. dprintf("r22 (t13) =\t %016I64lx\n" , TrapContents.IntT13);
  3809. dprintf("r23 (t14) =\t %016I64lx\t" , TrapContents.IntT14);
  3810. dprintf("r24 (t15) =\t %016I64lx\n" , TrapContents.IntT15);
  3811. dprintf("r25 (t16) =\t %016I64lx\t" , TrapContents.IntT16);
  3812. dprintf("r26 (t17) =\t %016I64lx\n" , TrapContents.IntT17);
  3813. dprintf("r27 (t18) =\t %016I64lx\t" , TrapContents.IntT18);
  3814. dprintf("r28 (t19) =\t %016I64lx\n" , TrapContents.IntT19);
  3815. dprintf("r29 (t20) =\t %016I64lx\t" , TrapContents.IntT20);
  3816. dprintf("r30 (t21) =\t %016I64lx\n" , TrapContents.IntT21);
  3817. dprintf("r31 (t22) =\t %016I64lx\n" , TrapContents.IntT22);
  3818. //
  3819. // Print out the stack registers.
  3820. //
  3821. for ( i = 0; i < SizeOfFrame; Bsp += sizeof(ULONGLONG))
  3822. {
  3823. ULONGLONG reg;
  3824. //
  3825. // Skip the NAT values.
  3826. //
  3827. if ((Bsp & IA64_RNAT_ALIGNMENT) == IA64_RNAT_ALIGNMENT)
  3828. {
  3829. continue;
  3830. }
  3831. if (m_Target->ReadAllVirtual(m_Target->m_ProcessHead,
  3832. Bsp, &reg, sizeof(reg)) != S_OK)
  3833. {
  3834. dprintf("Cannot read backing register store at %16I64x\n", Bsp);
  3835. }
  3836. dprintf("r%d =\t\t %016I64lx", (i + 32), reg);
  3837. if ((i % 2) == 1)
  3838. {
  3839. dprintf("\n");
  3840. }
  3841. else
  3842. {
  3843. dprintf("\t");
  3844. }
  3845. i++;
  3846. }
  3847. dprintf("\n");
  3848. dprintf("b0 (brrp) =\t %016I64lx\n", TrapContents.BrRp);
  3849. dprintf("b6 (brt0) =\t %016I64lx\n", TrapContents.BrT0);
  3850. dprintf("b7 (brt1) =\t %016I64lx\n", TrapContents.BrT1);
  3851. dprintf("nats =\t %016I64lx\n", TrapContents.IntNats);
  3852. dprintf("pfs =\t %016I64lx\n", TrapContents.RsPFS);
  3853. dprintf("ipsr =\t %016I64lx\n", TrapContents.StIPSR);
  3854. dprintf("isr =\t %016I64lx\n" , (StISR = TrapContents.StISR));
  3855. dprintf("ifa =\t %016I64lx\n" , TrapContents.StIFA);
  3856. dprintf("iip =\t %016I64lx\n" , StIIP = TrapContents.StIIP);
  3857. dprintf("iipa =\t %016I64lx\n", TrapContents.StIIPA);
  3858. dprintf("ifs =\t %016I64lx\n" , TrapContents.StIFS);
  3859. dprintf("iim =\t %016I64lx\n" , TrapContents.StIIM);
  3860. dprintf("iha =\t %016I64lx\n" , TrapContents.StIHA);
  3861. dprintf("fpsr =\t\t %08lx\n" , TrapContents.StFPSR);
  3862. // iA32 status info ???
  3863. dprintf("oldirql =\t %08lx\n" , TrapContents.OldIrql);
  3864. dprintf("previousmode =\t %08lx\n" , TrapContents.PreviousMode);
  3865. dprintf("trapframe =\t %08lx\n" , TrapContents.TrapFrame);
  3866. ULONG TrapFrameType = (ULONG)(TrapContents.EOFMarker) & 0xf;
  3867. switch (TrapFrameType)
  3868. {
  3869. case IA64_SYSCALL_FRAME:
  3870. dprintf("Trap Type: syscall\n");
  3871. break;
  3872. case IA64_INTERRUPT_FRAME:
  3873. dprintf("Trap Type: interrupt\n");
  3874. break;
  3875. case IA64_EXCEPTION_FRAME:
  3876. dprintf("Trap Type: exception\n");
  3877. break;
  3878. case IA64_CONTEXT_FRAME:
  3879. dprintf("Trap Type: context\n");
  3880. break;
  3881. default:
  3882. dprintf("Trap Type: unknown\n");
  3883. break;
  3884. }
  3885. DisasmAddr = StIIP;
  3886. //
  3887. // Adjust for the bundle.
  3888. //
  3889. DisasmAddr += ((StISR >> 41) & 3) * 4;
  3890. GetSymbol(DisasmAddr, Buffer, sizeof(Buffer), &Displacement);
  3891. dprintf("\n%s+0x%I64x\n", Buffer, Displacement);
  3892. ADDR tempAddr;
  3893. Type(tempAddr) = ADDR_FLAT | FLAT_COMPUTED;
  3894. Off(tempAddr) = Flat(tempAddr) = DisasmAddr;
  3895. if (Disassemble(m_Target->m_ProcessHead, &tempAddr, Buffer, FALSE))
  3896. {
  3897. dprintf(Buffer);
  3898. }
  3899. else
  3900. {
  3901. dprintf("???????????????\n", DisasmAddr);
  3902. }
  3903. GetScopeFrameFromContext(Context, &g_LastRegFrame);
  3904. SetCurrentScope(&g_LastRegFrame, Context, m_SizeCanonicalContext);
  3905. return S_OK;
  3906. }
  3907. TRACEMODE
  3908. Ia64MachineInfo::GetTraceMode (void)
  3909. {
  3910. if (IS_KERNEL_TARGET(m_Target))
  3911. {
  3912. return m_TraceMode;
  3913. }
  3914. else
  3915. {
  3916. ULONG64 Ipsr = GetReg64(STIPSR);
  3917. if (Ipsr & (1I64 << PSR_SS))
  3918. {
  3919. return TRACE_INSTRUCTION;
  3920. }
  3921. else if (Ipsr & (1I64 << PSR_TB))
  3922. {
  3923. return TRACE_TAKEN_BRANCH;
  3924. }
  3925. else
  3926. {
  3927. return TRACE_NONE;
  3928. }
  3929. }
  3930. }
  3931. void
  3932. Ia64MachineInfo::SetTraceMode (TRACEMODE Mode)
  3933. {
  3934. DBG_ASSERT(Mode == TRACE_NONE ||
  3935. Mode == TRACE_INSTRUCTION ||
  3936. Mode == TRACE_TAKEN_BRANCH);
  3937. if (IS_KERNEL_TARGET(m_Target))
  3938. {
  3939. m_TraceMode = Mode;
  3940. }
  3941. else
  3942. {
  3943. ULONG64 Ipsr, IpsrSave;
  3944. Ipsr = IpsrSave = GetReg64(STIPSR);
  3945. Ipsr &= ~(1I64 << PSR_SS);
  3946. Ipsr &= ~(1I64 << PSR_TB);
  3947. switch (Mode)
  3948. {
  3949. case TRACE_INSTRUCTION:
  3950. Ipsr |= (1I64 << PSR_SS);
  3951. break;
  3952. case TRACE_TAKEN_BRANCH:
  3953. Ipsr |= (1I64 << PSR_TB);
  3954. break;
  3955. }
  3956. if (Ipsr != IpsrSave)
  3957. {
  3958. SetReg64(STIPSR, Ipsr);
  3959. }
  3960. }
  3961. }
  3962. BOOL
  3963. Ia64MachineInfo::IsStepStatusSupported(ULONG Status)
  3964. {
  3965. switch (Status)
  3966. {
  3967. case DEBUG_STATUS_STEP_INTO: // TRACE_INSTRUCTION
  3968. case DEBUG_STATUS_STEP_OVER:
  3969. case DEBUG_STATUS_STEP_BRANCH: // TRACE_TAKEN_BRANCH
  3970. return TRUE;
  3971. default:
  3972. return FALSE;
  3973. }
  3974. }
  3975. void
  3976. Ia64MachineInfo::KdUpdateControlSet
  3977. (PDBGKD_ANY_CONTROL_SET ControlSet)
  3978. {
  3979. switch (GetTraceMode())
  3980. {
  3981. case TRACE_NONE:
  3982. ControlSet->IA64ControlSet.Continue =
  3983. IA64_DBGKD_CONTROL_SET_CONTINUE_NONE;
  3984. break;
  3985. case TRACE_INSTRUCTION:
  3986. ControlSet->IA64ControlSet.Continue =
  3987. IA64_DBGKD_CONTROL_SET_CONTINUE_TRACE_INSTRUCTION;
  3988. break;
  3989. case TRACE_TAKEN_BRANCH:
  3990. ControlSet->IA64ControlSet.Continue =
  3991. IA64_DBGKD_CONTROL_SET_CONTINUE_TRACE_TAKEN_BRANCH;
  3992. break;
  3993. }
  3994. if (!g_WatchFunctions.IsStarted() && g_WatchBeginCurFunc != 1)
  3995. {
  3996. ControlSet->IA64ControlSet.CurrentSymbolStart = 0;
  3997. ControlSet->IA64ControlSet.CurrentSymbolEnd = 0;
  3998. }
  3999. else
  4000. {
  4001. ControlSet->IA64ControlSet.CurrentSymbolStart = g_WatchBeginCurFunc;
  4002. ControlSet->IA64ControlSet.CurrentSymbolEnd = g_WatchEndCurFunc;
  4003. }
  4004. }
  4005. ULONG
  4006. Ia64MachineInfo::ExecutingMachine(void)
  4007. {
  4008. if (IsIA32InstructionSet())
  4009. {
  4010. return IMAGE_FILE_MACHINE_I386;
  4011. }
  4012. return IMAGE_FILE_MACHINE_IA64;
  4013. }
  4014. HRESULT
  4015. Ia64MachineInfo::SetPageDirectory(ThreadInfo* Thread,
  4016. ULONG Idx, ULONG64 PageDir,
  4017. PULONG NextIdx)
  4018. {
  4019. HRESULT Status;
  4020. switch(Idx)
  4021. {
  4022. case PAGE_DIR_USER:
  4023. if (PageDir == 0)
  4024. {
  4025. if ((Status = m_Target->ReadImplicitProcessInfoPointer
  4026. (Thread,
  4027. m_Target->m_KdDebuggerData.OffsetEprocessDirectoryTableBase,
  4028. &PageDir)) != S_OK)
  4029. {
  4030. return Status;
  4031. }
  4032. }
  4033. *NextIdx = PAGE_DIR_SESSION;
  4034. break;
  4035. case PAGE_DIR_SESSION:
  4036. if (PageDir == 0)
  4037. {
  4038. if ((Status = m_Target->
  4039. ReadImplicitProcessInfoPointer
  4040. (Thread,
  4041. m_Target->m_KdDebuggerData.OffsetEprocessDirectoryTableBase +
  4042. 5 * sizeof(ULONG64), &PageDir)) != S_OK)
  4043. {
  4044. return Status;
  4045. }
  4046. }
  4047. *NextIdx = PAGE_DIR_KERNEL;
  4048. break;
  4049. case PAGE_DIR_KERNEL:
  4050. if (PageDir == 0)
  4051. {
  4052. PageDir = m_KernPageDir;
  4053. if (PageDir == 0)
  4054. {
  4055. ErrOut("Invalid IA64 kernel page directory base 0x%I64x\n",
  4056. PageDir);
  4057. return E_FAIL;
  4058. }
  4059. }
  4060. *NextIdx = PAGE_DIR_COUNT;
  4061. break;
  4062. case 4:
  4063. case 5:
  4064. // There's a directly mapped physical section for
  4065. // most of regions 4 and 5 so allow the default to be
  4066. // set for this directory index.
  4067. if (PageDir != 0)
  4068. {
  4069. return E_INVALIDARG;
  4070. }
  4071. *NextIdx = Idx + 1;
  4072. break;
  4073. default:
  4074. return E_INVALIDARG;
  4075. }
  4076. // Sanitize the value.
  4077. m_PageDirectories[Idx] =
  4078. ((PageDir & IA64_VALID_PFN_MASK) >> IA64_VALID_PFN_SHIFT) <<
  4079. IA64_PAGE_SHIFT;
  4080. return S_OK;
  4081. }
  4082. #define IA64_PAGE_FILE_INDEX(Entry) \
  4083. (((ULONG)(Entry) >> 28) & MAX_PAGING_FILE_MASK)
  4084. #define IA64_PAGE_FILE_OFFSET(Entry) \
  4085. (((Entry) >> 32) << IA64_PAGE_SHIFT)
  4086. HRESULT
  4087. Ia64MachineInfo::GetVirtualTranslationPhysicalOffsets(ThreadInfo* Thread,
  4088. ULONG64 Virt,
  4089. PULONG64 Offsets,
  4090. ULONG OffsetsSize,
  4091. PULONG Levels,
  4092. PULONG PfIndex,
  4093. PULONG64 LastVal)
  4094. {
  4095. HRESULT Status;
  4096. *Levels = 0;
  4097. if (m_Translating)
  4098. {
  4099. return E_UNEXPECTED;
  4100. }
  4101. m_Translating = TRUE;
  4102. ULONG Vrn = (ULONG)((Virt & IA64_REGION_MASK) >> IA64_REGION_SHIFT);
  4103. //
  4104. // Reset the page directory in case it was 0
  4105. //
  4106. if (m_PageDirectories[Vrn] == 0)
  4107. {
  4108. if ((Status = SetDefaultPageDirectories(Thread, 1 << Vrn)) != S_OK)
  4109. {
  4110. m_Translating = FALSE;
  4111. return Status;
  4112. }
  4113. }
  4114. KdOut("Ia64VtoP: Virt %s, pagedir %d:%s\n",
  4115. FormatMachineAddr64(this, Virt), Vrn,
  4116. FormatDisp64(m_PageDirectories[Vrn]));
  4117. (*Levels)++;
  4118. if (Offsets != NULL && OffsetsSize > 0)
  4119. {
  4120. *Offsets++ = m_PageDirectories[Vrn];
  4121. OffsetsSize--;
  4122. }
  4123. //
  4124. // Certain ranges of the system are mapped directly.
  4125. //
  4126. if ((Virt >= IA64_PHYSICAL1_START) && (Virt <= IA64_PHYSICAL1_END))
  4127. {
  4128. *LastVal = Virt - IA64_PHYSICAL1_START;
  4129. KdOut("Ia64VtoP: Direct phys 1 %s\n",
  4130. FormatDisp64(*LastVal));
  4131. (*Levels)++;
  4132. if (Offsets != NULL && OffsetsSize > 0)
  4133. {
  4134. *Offsets++ = *LastVal;
  4135. OffsetsSize--;
  4136. }
  4137. m_Translating = FALSE;
  4138. return S_OK;
  4139. }
  4140. if ((Virt >= IA64_PHYSICAL2_START) && (Virt <= IA64_PHYSICAL2_END))
  4141. {
  4142. *LastVal = Virt - IA64_PHYSICAL2_START;
  4143. KdOut("Ia64VtoP: Direct phys 2 %s\n",
  4144. FormatDisp64(*LastVal));
  4145. (*Levels)++;
  4146. if (Offsets != NULL && OffsetsSize > 0)
  4147. {
  4148. *Offsets++ = *LastVal;
  4149. OffsetsSize--;
  4150. }
  4151. m_Translating = FALSE;
  4152. return S_OK;
  4153. }
  4154. if ((Virt >= IA64_PHYSICAL3_START) && (Virt <= IA64_PHYSICAL3_END))
  4155. {
  4156. *LastVal = Virt - IA64_PHYSICAL3_START;
  4157. KdOut("Ia64VtoP: Direct phys 3 %s\n",
  4158. FormatDisp64(*LastVal));
  4159. (*Levels)++;
  4160. if (Offsets != NULL && OffsetsSize > 0)
  4161. {
  4162. *Offsets++ = *LastVal;
  4163. OffsetsSize--;
  4164. }
  4165. m_Translating = FALSE;
  4166. return S_OK;
  4167. }
  4168. // If we're still translating and there's no page
  4169. // directory we have a garbage address.
  4170. if (m_PageDirectories[Vrn] == 0)
  4171. {
  4172. m_Translating = FALSE;
  4173. return HR_PAGE_NOT_AVAILABLE;
  4174. }
  4175. ULONG64 Addr;
  4176. ULONG64 Entry;
  4177. //
  4178. // On IA64 the page tables themselves have special virtual
  4179. // addresses that need to be handled differently when
  4180. // translating. The level within the paging hierarchy
  4181. // must be determined and translation started at the
  4182. // appropriate level.
  4183. //
  4184. if (m_Target->m_KdDebuggerData.MmVirtualTranslationBase)
  4185. {
  4186. ULONG64 Mask = m_Target->m_KdDebuggerData.MmVirtualTranslationBase;
  4187. if ((Virt & Mask) == Mask &&
  4188. (Virt & ~(IA64_REGION_MASK | Mask)) < (1UI64 << IA64_PDE1_SHIFT))
  4189. {
  4190. // PTE VA, skip PDE1 translation.
  4191. KdOut("Ia64VtoP: PTE VA\n");
  4192. Entry = (m_PageDirectories[Vrn] >> IA64_PAGE_SHIFT) <<
  4193. IA64_VALID_PFN_SHIFT;
  4194. goto Pde2Addr;
  4195. }
  4196. Mask |= Mask >> (IA64_PDE1_SHIFT - IA64_PDE2_SHIFT);
  4197. if ((Virt & Mask) == Mask &&
  4198. (Virt & ~(IA64_REGION_MASK | Mask)) < (1UI64 << IA64_PDE2_SHIFT))
  4199. {
  4200. // PDE2 VA, skip PDE1 and PDE2 translation.
  4201. KdOut("Ia64VtoP: PDE2 VA\n");
  4202. Entry = (m_PageDirectories[Vrn] >> IA64_PAGE_SHIFT) <<
  4203. IA64_VALID_PFN_SHIFT;
  4204. goto PteAddr;
  4205. }
  4206. Mask |= Mask >> (IA64_PDE2_SHIFT - IA64_PTE_SHIFT);
  4207. if ((Virt & Mask) == Mask &&
  4208. (Virt & ~(IA64_REGION_MASK | Mask)) < IA64_PAGE_SIZE)
  4209. {
  4210. // PDE1 VA, skip to page offset.
  4211. KdOut("Ia64VtoP: PDE1 VA\n");
  4212. Entry = (m_PageDirectories[Vrn] >> IA64_PAGE_SHIFT) <<
  4213. IA64_VALID_PFN_SHIFT;
  4214. goto PageAddr;
  4215. }
  4216. }
  4217. // Default, normal page VA.
  4218. Addr = (((Virt >> IA64_PDE1_SHIFT) & IA64_PDE_MASK) * sizeof(Entry)) +
  4219. m_PageDirectories[Vrn];
  4220. Status = m_Target->ReadAllPhysical(Addr, &Entry, sizeof(Entry));
  4221. KdOut("Ia64VtoP: PDE1 %s - %016I64x, 0x%X\n",
  4222. FormatDisp64(Addr), Entry, Status);
  4223. (*Levels)++;
  4224. if (Offsets != NULL && OffsetsSize > 0)
  4225. {
  4226. *Offsets++ = Addr;
  4227. OffsetsSize--;
  4228. }
  4229. if (Status != S_OK)
  4230. {
  4231. KdOut("Ia64VtoP: PDE1 read error 0x%X\n", Status);
  4232. m_Translating = FALSE;
  4233. return Status;
  4234. }
  4235. if (Entry == 0)
  4236. {
  4237. KdOut("Ia64VtoP: zero PDE1\n");
  4238. m_Translating = FALSE;
  4239. return HR_PAGE_NOT_AVAILABLE;
  4240. }
  4241. else if (!(Entry & 1))
  4242. {
  4243. Addr = (((Virt >> IA64_PDE2_SHIFT) & IA64_PDE_MASK) *
  4244. sizeof(Entry)) + IA64_PAGE_FILE_OFFSET(Entry);
  4245. KdOut("Ia64VtoP: pagefile PDE2 %d:%s\n",
  4246. IA64_PAGE_FILE_INDEX(Entry), FormatDisp64(Addr));
  4247. if ((Status = m_Target->
  4248. ReadPageFile(IA64_PAGE_FILE_INDEX(Entry), Addr,
  4249. &Entry, sizeof(Entry))) != S_OK)
  4250. {
  4251. KdOut("Ia64VtoP: PDE1 not present, 0x%X\n", Status);
  4252. m_Translating = FALSE;
  4253. return Status;
  4254. }
  4255. }
  4256. else
  4257. {
  4258. Pde2Addr:
  4259. Addr = (((Virt >> IA64_PDE2_SHIFT) & IA64_PDE_MASK) * sizeof(Entry)) +
  4260. (((Entry & IA64_VALID_PFN_MASK) >> IA64_VALID_PFN_SHIFT) <<
  4261. IA64_PAGE_SHIFT);
  4262. Status = m_Target->ReadAllPhysical(Addr, &Entry, sizeof(Entry));
  4263. KdOut("Ia64VtoP: PDE2 %s - %016I64x, 0x%X\n",
  4264. FormatDisp64(Addr), Entry, Status);
  4265. (*Levels)++;
  4266. if (Offsets != NULL && OffsetsSize > 0)
  4267. {
  4268. *Offsets++ = Addr;
  4269. OffsetsSize--;
  4270. }
  4271. if (Status != S_OK)
  4272. {
  4273. KdOut("Ia64VtoP: PDE2 read error 0x%X\n", Status);
  4274. m_Translating = FALSE;
  4275. return Status;
  4276. }
  4277. }
  4278. // Check for a large page. Large pages can
  4279. // never be paged out so also check for the present bit.
  4280. if ((Entry & (IA64_LARGE_PAGE_PDE_MASK | 1)) ==
  4281. (IA64_LARGE_PAGE_PDE_MARK | 1))
  4282. {
  4283. *LastVal = (((Entry & IA64_VALID_PFN_MASK) >> IA64_VALID_PFN_SHIFT) <<
  4284. IA64_PAGE_SHIFT) +
  4285. (Virt & (IA64_LARGE_PAGE_SIZE - 1));
  4286. KdOut("Ia64VtoP: Large page mapped phys %s\n",
  4287. FormatDisp64(*LastVal));
  4288. (*Levels)++;
  4289. if (Offsets != NULL && OffsetsSize > 0)
  4290. {
  4291. *Offsets++ = *LastVal;
  4292. OffsetsSize--;
  4293. }
  4294. m_Translating = FALSE;
  4295. return S_OK;
  4296. }
  4297. if (Entry == 0)
  4298. {
  4299. KdOut("Ia64VtoP: zero PDE2\n");
  4300. m_Translating = FALSE;
  4301. return HR_PAGE_NOT_AVAILABLE;
  4302. }
  4303. else if (!(Entry & 1))
  4304. {
  4305. Addr = (((Virt >> IA64_PTE_SHIFT) & IA64_PTE_MASK) *
  4306. sizeof(Entry)) + IA64_PAGE_FILE_OFFSET(Entry);
  4307. KdOut("Ia64VtoP: pagefile PTE %d:%s\n",
  4308. IA64_PAGE_FILE_INDEX(Entry), FormatDisp64(Addr));
  4309. if ((Status = m_Target->
  4310. ReadPageFile(IA64_PAGE_FILE_INDEX(Entry), Addr,
  4311. &Entry, sizeof(Entry))) != S_OK)
  4312. {
  4313. KdOut("Ia64VtoP: PDE2 not present, 0x%X\n", Status);
  4314. m_Translating = FALSE;
  4315. return Status;
  4316. }
  4317. }
  4318. else
  4319. {
  4320. PteAddr:
  4321. Addr = (((Virt >> IA64_PTE_SHIFT) & IA64_PTE_MASK) * sizeof(Entry)) +
  4322. (((Entry & IA64_VALID_PFN_MASK) >> IA64_VALID_PFN_SHIFT) <<
  4323. IA64_PAGE_SHIFT);
  4324. Status = m_Target->ReadAllPhysical(Addr, &Entry, sizeof(Entry));
  4325. KdOut("Ia64VtoP: PTE %s - %016I64x, 0x%X\n",
  4326. FormatDisp64(Addr), Entry, Status);
  4327. (*Levels)++;
  4328. if (Offsets != NULL && OffsetsSize > 0)
  4329. {
  4330. *Offsets++ = Addr;
  4331. OffsetsSize--;
  4332. }
  4333. if (Status != S_OK)
  4334. {
  4335. KdOut("Ia64VtoP: PTE read error 0x%X\n", Status);
  4336. m_Translating = FALSE;
  4337. return Status;
  4338. }
  4339. }
  4340. if (!(Entry & 0x1) &&
  4341. ((Entry & IA64_MM_PTE_PROTOTYPE_MASK) ||
  4342. !(Entry & IA64_MM_PTE_TRANSITION_MASK)))
  4343. {
  4344. if (Entry == 0)
  4345. {
  4346. KdOut("Ia64VtoP: zero PTE\n");
  4347. Status = HR_PAGE_NOT_AVAILABLE;
  4348. }
  4349. else if (Entry & IA64_MM_PTE_PROTOTYPE_MASK)
  4350. {
  4351. KdOut("Ia64VtoP: prototype PTE\n");
  4352. Status = HR_PAGE_NOT_AVAILABLE;
  4353. }
  4354. else
  4355. {
  4356. *PfIndex = IA64_PAGE_FILE_INDEX(Entry);
  4357. *LastVal = (Virt & (IA64_PAGE_SIZE - 1)) +
  4358. IA64_PAGE_FILE_OFFSET(Entry);
  4359. KdOut("Ia64VtoP: PTE not present, pagefile %d:%s\n",
  4360. *PfIndex, FormatDisp64(*LastVal));
  4361. Status = HR_PAGE_IN_PAGE_FILE;
  4362. }
  4363. m_Translating = FALSE;
  4364. return Status;
  4365. }
  4366. PageAddr:
  4367. //
  4368. // This is a page which is either present or in transition.
  4369. // Return the physical address for the request virtual address.
  4370. //
  4371. *LastVal = (((Entry & IA64_VALID_PFN_MASK) >> IA64_VALID_PFN_SHIFT) <<
  4372. IA64_PAGE_SHIFT) | (Virt & (IA64_PAGE_SIZE - 1));
  4373. KdOut("Ia64VtoP: Mapped phys %s\n", FormatDisp64(*LastVal));
  4374. (*Levels)++;
  4375. if (Offsets != NULL && OffsetsSize > 0)
  4376. {
  4377. *Offsets++ = *LastVal;
  4378. OffsetsSize--;
  4379. }
  4380. m_Translating = FALSE;
  4381. return S_OK;
  4382. }
  4383. HRESULT
  4384. Ia64MachineInfo::GetBaseTranslationVirtualOffset(PULONG64 Offset)
  4385. {
  4386. if (m_Target->m_KdDebuggerData.MmVirtualTranslationBase)
  4387. {
  4388. *Offset = m_Target->m_KdDebuggerData.MmVirtualTranslationBase;
  4389. return S_OK;
  4390. }
  4391. if (IS_LOCAL_KERNEL_TARGET(m_Target))
  4392. {
  4393. CROSS_PLATFORM_KSPECIAL_REGISTERS Special;
  4394. HRESULT Status;
  4395. // We can't actually load a context when
  4396. // local kernel debugging but we can
  4397. // read the special registers and get
  4398. // the PTA value from there.
  4399. if ((Status = m_Target->GetTargetSpecialRegisters
  4400. (VIRTUAL_THREAD_HANDLE(0), &Special)) != S_OK)
  4401. {
  4402. return Status;
  4403. }
  4404. *Offset = Special.IA64Special.ApPTA;
  4405. }
  4406. else
  4407. {
  4408. *Offset = GetReg64(APPTA);
  4409. if (*Offset == 0)
  4410. {
  4411. return E_FAIL;
  4412. }
  4413. }
  4414. m_Target->m_KdDebuggerData.MmVirtualTranslationBase = *Offset;
  4415. return S_OK;
  4416. }
  4417. void
  4418. Ia64MachineInfo::DecodePte(ULONG64 Pte, PULONG64 PageFrameNumber,
  4419. PULONG Flags)
  4420. {
  4421. *PageFrameNumber = (Pte & IA64_VALID_PFN_MASK) >> IA64_VALID_PFN_SHIFT;
  4422. *Flags = (Pte & 1) ? MPTE_FLAG_VALID : 0;
  4423. }
  4424. void
  4425. Ia64MachineInfo::OutputFunctionEntry(PVOID RawEntry)
  4426. {
  4427. PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY Entry =
  4428. (PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY)RawEntry;
  4429. dprintf("BeginAddress = %s\n",
  4430. FormatMachineAddr64(this, Entry->BeginAddress));
  4431. dprintf("EndAddress = %s\n",
  4432. FormatMachineAddr64(this, Entry->EndAddress));
  4433. dprintf("UnwindInfoAddress = %s\n",
  4434. FormatMachineAddr64(this, Entry->UnwindInfoAddress));
  4435. }
  4436. HRESULT
  4437. Ia64MachineInfo::ReadDynamicFunctionTable(ProcessInfo* Process,
  4438. ULONG64 Table,
  4439. PULONG64 NextTable,
  4440. PULONG64 MinAddress,
  4441. PULONG64 MaxAddress,
  4442. PULONG64 BaseAddress,
  4443. PULONG64 TableData,
  4444. PULONG TableSize,
  4445. PWSTR OutOfProcessDll,
  4446. PCROSS_PLATFORM_DYNAMIC_FUNCTION_TABLE RawTable)
  4447. {
  4448. HRESULT Status;
  4449. if ((Status = m_Target->
  4450. ReadAllVirtual(Process, Table, &RawTable->IA64Table,
  4451. sizeof(RawTable->IA64Table))) != S_OK)
  4452. {
  4453. return Status;
  4454. }
  4455. *NextTable = RawTable->IA64Table.Links.Flink;
  4456. *MinAddress = RawTable->IA64Table.MinimumAddress;
  4457. *MaxAddress = RawTable->IA64Table.MaximumAddress;
  4458. *BaseAddress = RawTable->IA64Table.BaseAddress;
  4459. if (RawTable->IA64Table.Type == IA64_RF_CALLBACK)
  4460. {
  4461. ULONG Done;
  4462. *TableData = 0;
  4463. *TableSize = 0;
  4464. if ((Status = m_Target->
  4465. ReadVirtual(Process, RawTable->IA64Table.OutOfProcessCallbackDll,
  4466. OutOfProcessDll, (MAX_PATH - 1) * sizeof(WCHAR),
  4467. &Done)) != S_OK)
  4468. {
  4469. return Status;
  4470. }
  4471. OutOfProcessDll[Done / sizeof(WCHAR)] = 0;
  4472. }
  4473. else
  4474. {
  4475. *TableData = RawTable->IA64Table.FunctionTable;
  4476. *TableSize = RawTable->IA64Table.EntryCount *
  4477. sizeof(IMAGE_IA64_RUNTIME_FUNCTION_ENTRY);
  4478. OutOfProcessDll[0] = 0;
  4479. }
  4480. return S_OK;
  4481. }
  4482. PVOID
  4483. Ia64MachineInfo::FindDynamicFunctionEntry(PCROSS_PLATFORM_DYNAMIC_FUNCTION_TABLE Table,
  4484. ULONG64 Address,
  4485. PVOID TableData,
  4486. ULONG TableSize)
  4487. {
  4488. ULONG i;
  4489. PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY Func;
  4490. static IMAGE_IA64_RUNTIME_FUNCTION_ENTRY s_RetFunc;
  4491. Func = (PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY)TableData;
  4492. for (i = 0; i < TableSize / sizeof(IMAGE_IA64_RUNTIME_FUNCTION_ENTRY); i++)
  4493. {
  4494. if (Address >= IA64_RF_BEGIN_ADDRESS(Table->IA64Table.BaseAddress, Func) &&
  4495. Address < IA64_RF_END_ADDRESS(Table->IA64Table.BaseAddress, Func))
  4496. {
  4497. // The table data is temporary so copy the data into
  4498. // a static buffer for longer-term storage.
  4499. s_RetFunc.BeginAddress = Func->BeginAddress;
  4500. s_RetFunc.EndAddress = Func->EndAddress;
  4501. s_RetFunc.UnwindInfoAddress = Func->UnwindInfoAddress;
  4502. return (PVOID)&s_RetFunc;
  4503. }
  4504. Func++;
  4505. }
  4506. return NULL;
  4507. }
  4508. HRESULT
  4509. Ia64MachineInfo::GetUnwindInfoBounds(ProcessInfo* Process,
  4510. ULONG64 TableBase,
  4511. PVOID RawTableEntries,
  4512. ULONG EntryIndex,
  4513. PULONG64 Start,
  4514. PULONG Size)
  4515. {
  4516. HRESULT Status;
  4517. PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY FuncEnt =
  4518. (PIMAGE_IA64_RUNTIME_FUNCTION_ENTRY)RawTableEntries + EntryIndex;
  4519. IA64_UNWIND_INFO Info;
  4520. *Start = TableBase + FuncEnt->UnwindInfoAddress;
  4521. if ((Status = m_Target->
  4522. ReadAllVirtual(Process, *Start, &Info, sizeof(Info))) != S_OK)
  4523. {
  4524. return Status;
  4525. }
  4526. *Size = sizeof(Info) + Info.DataLength * sizeof(ULONG64);
  4527. return S_OK;
  4528. }
  4529. HRESULT
  4530. Ia64MachineInfo::ReadKernelProcessorId
  4531. (ULONG Processor, PDEBUG_PROCESSOR_IDENTIFICATION_ALL Id)
  4532. {
  4533. HRESULT Status;
  4534. ULONG64 Prcb;
  4535. ULONG Data[4];
  4536. if ((Status = m_Target->
  4537. GetProcessorSystemDataOffset(Processor, DEBUG_DATA_KPRCB_OFFSET,
  4538. &Prcb)) != S_OK)
  4539. {
  4540. return Status;
  4541. }
  4542. if ((Status = m_Target->
  4543. ReadAllVirtual(m_Target->m_ProcessHead,
  4544. Prcb + m_Target->m_KdDebuggerData.OffsetPrcbCpuType,
  4545. Data, sizeof(Data))) != S_OK)
  4546. {
  4547. return Status;
  4548. }
  4549. Id->Ia64.Model = Data[0];
  4550. Id->Ia64.Revision = Data[1];
  4551. Id->Ia64.Family = Data[2];
  4552. Id->Ia64.ArchRev = Data[3];
  4553. if ((Status = m_Target->
  4554. ReadAllVirtual(m_Target->m_ProcessHead, Prcb +
  4555. m_Target->m_KdDebuggerData.OffsetPrcbVendorString,
  4556. Id->Ia64.VendorString,
  4557. sizeof(Id->Ia64.VendorString))) != S_OK)
  4558. {
  4559. return Status;
  4560. }
  4561. return S_OK;
  4562. }
  4563. HRESULT
  4564. Ia64MachineInfo::GetAlternateTriageDumpDataRanges(ULONG64 PrcbBase,
  4565. ULONG64 ThreadBase,
  4566. PADDR_RANGE Ranges)
  4567. {
  4568. HRESULT Status;
  4569. PADDR_RANGE Range = Ranges;
  4570. ULONG64 PcrBase;
  4571. ULONG64 PcrInitialBStore;
  4572. ULONG64 PcrBStoreLimit;
  4573. ULONG64 PcrInitialStack;
  4574. ULONG64 PcrStackLimit;
  4575. ULONG64 ThInitialBStore;
  4576. ULONG64 ThBStoreLimit;
  4577. ULONG64 ThInitialStack;
  4578. ULONG64 ThStackLimit;
  4579. #define MAX_ALT_DATA_SIZE 8192
  4580. //
  4581. // In certain failures there is a switch from
  4582. // the current thread's stack and store to
  4583. // a special stack and store. The PCR contains
  4584. // stack and store pointers which will be different
  4585. // from the current thread's stack and store pointers
  4586. // so save the extra stack and store if they are.
  4587. //
  4588. if ((Status = m_Target->
  4589. GetProcessorSystemDataOffset(CURRENT_PROC,
  4590. DEBUG_DATA_KPCR_OFFSET,
  4591. &PcrBase)) != S_OK ||
  4592. (Status = m_Target->
  4593. ReadAllVirtual(m_Target->m_ProcessHead,
  4594. PcrBase +
  4595. m_Target->m_KdDebuggerData.OffsetPcrInitialBStore,
  4596. &PcrInitialBStore,
  4597. sizeof(PcrInitialBStore))) != S_OK ||
  4598. (Status = m_Target->
  4599. ReadAllVirtual(m_Target->m_ProcessHead,
  4600. PcrBase +
  4601. m_Target->m_KdDebuggerData.OffsetPcrBStoreLimit,
  4602. &PcrBStoreLimit, sizeof(PcrBStoreLimit))) != S_OK ||
  4603. (Status = m_Target->
  4604. ReadAllVirtual(m_Target->m_ProcessHead,
  4605. PcrBase +
  4606. m_Target->m_KdDebuggerData.OffsetPcrInitialStack,
  4607. &PcrInitialStack, sizeof(PcrInitialStack))) != S_OK ||
  4608. (Status = m_Target->
  4609. ReadAllVirtual(m_Target->m_ProcessHead,
  4610. PcrBase +
  4611. m_Target->m_KdDebuggerData.OffsetPcrStackLimit,
  4612. &PcrStackLimit, sizeof(PcrStackLimit))) != S_OK ||
  4613. (Status = m_Target->
  4614. ReadAllVirtual(m_Target->m_ProcessHead,
  4615. ThreadBase +
  4616. m_Target->m_KdDebuggerData.OffsetKThreadInitialStack,
  4617. &ThInitialStack, sizeof(ThInitialStack))) != S_OK ||
  4618. (Status = m_Target->
  4619. ReadAllVirtual(m_Target->m_ProcessHead,
  4620. ThreadBase +
  4621. m_Target->m_KdDebuggerData.OffsetKThreadKernelStack,
  4622. &ThStackLimit, sizeof(ThStackLimit))) != S_OK ||
  4623. (Status = m_Target->
  4624. ReadAllVirtual(m_Target->m_ProcessHead,
  4625. ThreadBase +
  4626. m_Target->m_KdDebuggerData.OffsetKThreadBStore,
  4627. &ThInitialBStore, sizeof(ThInitialBStore))) != S_OK ||
  4628. (Status = m_Target->
  4629. ReadAllVirtual(m_Target->m_ProcessHead,
  4630. ThreadBase +
  4631. m_Target->m_KdDebuggerData.OffsetKThreadBStoreLimit,
  4632. &ThBStoreLimit, sizeof(ThBStoreLimit))) != S_OK)
  4633. {
  4634. return Status;
  4635. }
  4636. if (PcrInitialBStore != ThInitialBStore ||
  4637. PcrBStoreLimit != ThBStoreLimit)
  4638. {
  4639. ULONG FrameSize = GetReg32(STIFS) & IA64_PFS_SIZE_MASK;
  4640. ULONG64 StoreTop = GetReg64(RSBSP);
  4641. // Add in a ULONG64 for every register in the
  4642. // current frame. While doing so, check for
  4643. // spill entries.
  4644. while (FrameSize-- > 0)
  4645. {
  4646. StoreTop += sizeof(ULONG64);
  4647. if ((StoreTop & 0x1f8) == 0x1f8)
  4648. {
  4649. // Spill will be placed at this address so
  4650. // account for it.
  4651. StoreTop += sizeof(ULONG64);
  4652. }
  4653. }
  4654. if (StoreTop < PcrInitialBStore || StoreTop >= PcrBStoreLimit)
  4655. {
  4656. // BSP isn't in the PCR store range so
  4657. // just save the whole thing.
  4658. StoreTop = PcrBStoreLimit;
  4659. }
  4660. Range->Size = (ULONG)(StoreTop - PcrInitialBStore);
  4661. if (Range->Size > MAX_ALT_DATA_SIZE)
  4662. {
  4663. Range->Size = MAX_ALT_DATA_SIZE;
  4664. Range->Base = StoreTop - Range->Size;
  4665. }
  4666. else
  4667. {
  4668. Range->Base = PcrInitialBStore;
  4669. }
  4670. Range++;
  4671. }
  4672. if (PcrInitialStack != ThInitialStack ||
  4673. PcrStackLimit != ThStackLimit)
  4674. {
  4675. Range->Base = GetReg64(INTSP);
  4676. if (Range->Base < PcrStackLimit || Range->Base >= PcrInitialStack)
  4677. {
  4678. // SP isn't in the PCR stack range so
  4679. // just save the whole thing.
  4680. Range->Base = PcrStackLimit;
  4681. }
  4682. Range->Size = (ULONG)(PcrInitialStack - Range->Base);
  4683. if (Range->Size > MAX_ALT_DATA_SIZE)
  4684. {
  4685. Range->Size = MAX_ALT_DATA_SIZE;
  4686. }
  4687. Range++;
  4688. }
  4689. return S_OK;
  4690. }
  4691. BOOL
  4692. Ia64MachineInfo::IsIA32InstructionSet(VOID)
  4693. {
  4694. return ((GetReg64(STIPSR) & (1I64 << PSR_IS)) ? TRUE : FALSE);
  4695. }
  4696. HRESULT
  4697. Ia64MachineInfo::GetStackedRegVal(
  4698. IN ProcessInfo* Process,
  4699. IN ULONG64 RsBSP,
  4700. IN ULONG64 FrameMarker,
  4701. IN ULONG64 RsRNAT,
  4702. IN ULONG Reg,
  4703. OUT REGVAL* Val
  4704. )
  4705. {
  4706. HRESULT Status;
  4707. SHORT Index;
  4708. SHORT Temp;
  4709. SHORT FrameSize = (SHORT)IA64_FM_SOF(FrameMarker);
  4710. ULONG64 TargetAddress;
  4711. ULONG64 TargetNatAddress;
  4712. Index = (SHORT)(RsBSP >> 3) & NAT_BITS_PER_RNAT_REG;
  4713. Temp = Index + FrameSize - NAT_BITS_PER_RNAT_REG;
  4714. while (Temp >= 0)
  4715. {
  4716. FrameSize++;
  4717. Temp -= NAT_BITS_PER_RNAT_REG;
  4718. }
  4719. TargetAddress = RsBSP;
  4720. while (Reg > 0)
  4721. {
  4722. Reg -= 1;
  4723. TargetAddress += 8;
  4724. if ((TargetAddress & 0x1F8) == 0x1F8)
  4725. {
  4726. TargetAddress += 8;
  4727. }
  4728. }
  4729. if ((Status = m_Target->
  4730. ReadAllVirtual(Process,
  4731. TargetAddress, (PUCHAR)&Val->I64, 8)) != S_OK)
  4732. {
  4733. ErrOut("Unable to read memory location %I64x\n", TargetAddress);
  4734. return Status;
  4735. }
  4736. Index = (SHORT)((TargetAddress - (TargetAddress & ~(0x1F8i64))) >> 3);
  4737. TargetNatAddress = TargetAddress | 0x1F8;
  4738. if (TargetNatAddress <= (RsBSP + (FrameSize * sizeof(ULONG64))))
  4739. {
  4740. //
  4741. // update backing store
  4742. //
  4743. if ((Status = m_Target->
  4744. ReadAllVirtual(Process,
  4745. TargetNatAddress, (PUCHAR)&RsRNAT, 8)) != S_OK)
  4746. {
  4747. ErrOut("Unable to read memory location %I64x\n", TargetNatAddress);
  4748. return Status;
  4749. }
  4750. }
  4751. Val->Nat = (UCHAR)(RsRNAT >> Index) & 0x1;
  4752. return S_OK;
  4753. }
  4754. HRESULT
  4755. Ia64MachineInfo::SetStackedRegVal(
  4756. IN ProcessInfo* Process,
  4757. IN ULONG64 RsBSP,
  4758. IN ULONG64 FrameMarker,
  4759. IN ULONG64 *RsRNAT,
  4760. IN ULONG Reg,
  4761. IN REGVAL* Val
  4762. )
  4763. {
  4764. HRESULT Status;
  4765. SHORT Index;
  4766. SHORT Temp;
  4767. SHORT FrameSize = (SHORT)IA64_FM_SOF(FrameMarker);
  4768. ULONG64 Mask;
  4769. ULONG64 LocalRnat;
  4770. ULONG64 TargetAddress;
  4771. ULONG64 TargetNatAddress;
  4772. Index = (SHORT)(RsBSP >> 3) & NAT_BITS_PER_RNAT_REG;
  4773. Temp = Index + FrameSize - NAT_BITS_PER_RNAT_REG;
  4774. while (Temp >= 0)
  4775. {
  4776. FrameSize++;
  4777. Temp -= NAT_BITS_PER_RNAT_REG;
  4778. }
  4779. TargetAddress = RsBSP;
  4780. while (Reg > 0)
  4781. {
  4782. Reg -= 1;
  4783. TargetAddress += 8;
  4784. if ((TargetAddress & 0x1F8) == 0x1F8)
  4785. {
  4786. TargetAddress += 8;
  4787. }
  4788. }
  4789. if ((Status = m_Target->
  4790. WriteAllVirtual(Process, TargetAddress, &Val->I64, 8)) != S_OK)
  4791. {
  4792. ErrOut("Unable to write memory location %I64x\n", TargetAddress);
  4793. return Status;
  4794. }
  4795. Index = (SHORT)((TargetAddress - (TargetAddress & ~(0x1F8i64))) >> 3);
  4796. TargetNatAddress = TargetAddress | 0x1F8;
  4797. Mask = 0x1i64 << Index;
  4798. if (TargetNatAddress <= (RsBSP + (FrameSize * sizeof(ULONG64))))
  4799. {
  4800. if ((Status = m_Target->
  4801. ReadAllVirtual(Process,
  4802. TargetNatAddress, (PUCHAR)&LocalRnat, 8)) != S_OK)
  4803. {
  4804. ErrOut("Unable to read memory location %I64x\n", TargetNatAddress);
  4805. return Status;
  4806. }
  4807. if (Val->Nat)
  4808. {
  4809. LocalRnat |= Mask;
  4810. }
  4811. else
  4812. {
  4813. LocalRnat &= ~Mask;
  4814. }
  4815. if ((Status = m_Target->
  4816. WriteAllVirtual(Process,
  4817. TargetNatAddress, &LocalRnat, 8)) != S_OK)
  4818. {
  4819. ErrOut("Unable to write memory location %I64x\n",TargetNatAddress);
  4820. return Status;
  4821. }
  4822. }
  4823. else
  4824. {
  4825. if (Val->Nat)
  4826. {
  4827. *RsRNAT |= Mask;
  4828. }
  4829. else
  4830. {
  4831. *RsRNAT &= ~Mask;
  4832. }
  4833. }
  4834. return S_OK;
  4835. }
  4836. //----------------------------------------------------------------------------
  4837. //
  4838. // X86OnIa64MachineInfo.
  4839. //
  4840. //----------------------------------------------------------------------------
  4841. X86OnIa64MachineInfo::X86OnIa64MachineInfo(TargetInfo* Target)
  4842. : X86MachineInfo(Target)
  4843. {
  4844. m_MaxDataBreakpoints = min(m_MaxDataBreakpoints,
  4845. IA64_REG_MAX_DATA_BREAKPOINTS);
  4846. }
  4847. HRESULT
  4848. X86OnIa64MachineInfo::UdGetContextState(ULONG State)
  4849. {
  4850. HRESULT Status;
  4851. if ((Status = m_Target->m_Machines[MACHIDX_IA64]->
  4852. UdGetContextState(MCTX_FULL)) != S_OK)
  4853. {
  4854. return Status;
  4855. }
  4856. Ia64ContextToX86(&m_Target->m_Machines[MACHIDX_IA64]->
  4857. m_Context.IA64Context,
  4858. &m_Context.X86Nt5Context);
  4859. m_ContextState = MCTX_FULL;
  4860. return S_OK;
  4861. }
  4862. HRESULT
  4863. X86OnIa64MachineInfo::UdSetContext(void)
  4864. {
  4865. m_Target->m_Machines[MACHIDX_IA64]->
  4866. InitializeContextFlags(&m_Target->m_Machines[MACHIDX_IA64]->m_Context,
  4867. m_Target->m_SystemVersion);
  4868. X86ContextToIa64(&m_Context.X86Nt5Context,
  4869. &m_Target->m_Machines[MACHIDX_IA64]->
  4870. m_Context.IA64Context);
  4871. return m_Target->m_Machines[MACHIDX_IA64]->UdSetContext();
  4872. }
  4873. HRESULT
  4874. X86OnIa64MachineInfo::KdGetContextState(ULONG State)
  4875. {
  4876. HRESULT Status;
  4877. dprintf("The context is partially valid. "
  4878. "Only x86 user-mode context is available.\n");
  4879. if ((Status = m_Target->m_Machines[MACHIDX_IA64]->
  4880. KdGetContextState(MCTX_FULL)) != S_OK)
  4881. {
  4882. return Status;
  4883. }
  4884. Ia64ContextToX86(&m_Target->m_Machines[MACHIDX_IA64]->
  4885. m_Context.IA64Context,
  4886. &m_Context.X86Nt5Context);
  4887. m_ContextState = MCTX_FULL;
  4888. return S_OK;
  4889. }
  4890. HRESULT
  4891. X86OnIa64MachineInfo::KdSetContext(void)
  4892. {
  4893. dprintf("The context is partially valid. "
  4894. "Only x86 user-mode context is available.\n");
  4895. m_Target->m_Machines[MACHIDX_IA64]->
  4896. InitializeContextFlags(&m_Target->m_Machines[MACHIDX_IA64]->m_Context,
  4897. m_Target->m_SystemVersion);
  4898. X86ContextToIa64(&m_Context.X86Nt5Context,
  4899. &m_Target->m_Machines[MACHIDX_IA64]->
  4900. m_Context.IA64Context);
  4901. return m_Target->m_Machines[MACHIDX_IA64]->KdSetContext();
  4902. }
  4903. HRESULT
  4904. X86OnIa64MachineInfo::GetSegRegDescriptor(ULONG SegReg, PDESCRIPTOR64 Desc)
  4905. {
  4906. // XXX drewb - This should probably use the
  4907. // descriptor information embedded in the IA64 context.
  4908. ULONG RegNum = GetSegRegNum(SegReg);
  4909. if (RegNum == 0)
  4910. {
  4911. return E_INVALIDARG;
  4912. }
  4913. return m_Target->EmulateNtX86SelDescriptor(m_Target->m_RegContextThread,
  4914. this, GetIntReg(RegNum), Desc);
  4915. }
  4916. HRESULT
  4917. X86OnIa64MachineInfo::NewBreakpoint(DebugClient* Client,
  4918. ULONG Type,
  4919. ULONG Id,
  4920. Breakpoint** RetBp)
  4921. {
  4922. HRESULT Status;
  4923. switch(Type & (DEBUG_BREAKPOINT_CODE | DEBUG_BREAKPOINT_DATA))
  4924. {
  4925. case DEBUG_BREAKPOINT_CODE:
  4926. *RetBp = new CodeBreakpoint(Client, Id, IMAGE_FILE_MACHINE_I386);
  4927. Status = (*RetBp) ? S_OK : E_OUTOFMEMORY;
  4928. break;
  4929. case DEBUG_BREAKPOINT_DATA:
  4930. *RetBp = new X86OnIa64DataBreakpoint(Client, Id);
  4931. Status = (*RetBp) ? S_OK : E_OUTOFMEMORY;
  4932. break;
  4933. default:
  4934. // Unknown breakpoint type.
  4935. Status = E_NOINTERFACE;
  4936. break;
  4937. }
  4938. return Status;
  4939. }
  4940. ULONG
  4941. X86OnIa64MachineInfo::IsBreakpointOrStepException(PEXCEPTION_RECORD64 Record,
  4942. ULONG FirstChance,
  4943. PADDR BpAddr,
  4944. PADDR RelAddr)
  4945. {
  4946. //
  4947. // XXX olegk - This is pure hack to eliminate need to map unavalable
  4948. // in 64-bit context ISR register to DR6.
  4949. // We using the fact that Code Breakpoint is recognized normally and
  4950. // for Data Breakpoint ISR register is avalable as 5th parameter of
  4951. // exception record.
  4952. //
  4953. ULONG Exbs =
  4954. X86MachineInfo::IsBreakpointOrStepException(Record,
  4955. FirstChance,
  4956. BpAddr, RelAddr);
  4957. if (Exbs == EXBS_BREAKPOINT_CODE)
  4958. {
  4959. return Exbs;
  4960. }
  4961. if (Record->ExceptionCode == STATUS_WX86_SINGLE_STEP)
  4962. {
  4963. ULONG64 Isr = Record->ExceptionInformation[4]; // Trap code is 2 lower bytes
  4964. ULONG TrapCode = ULONG(Isr & ISR_CODE_MASK);
  4965. ULONG Vector = (ULONG)(Isr >> ISR_IA_VECTOR) & 0xff;
  4966. if (Vector != 1)
  4967. {
  4968. return EXBS_NONE;
  4969. }
  4970. if (Isr & (1 << ISR_TB_TRAP))
  4971. {
  4972. ADDRFLAT(RelAddr, Record->ExceptionInformation[3]);
  4973. return EXBS_STEP_BRANCH;
  4974. }
  4975. else if (Isr & (1 << ISR_SS_TRAP))
  4976. {
  4977. return EXBS_STEP_INSTRUCTION;
  4978. }
  4979. else {
  4980. if (Isr & ((ULONG64)1 << ISR_X)) // Exec Data Breakpoint
  4981. {
  4982. return EXBS_BREAKPOINT_DATA;
  4983. }
  4984. else // Data Breakpoint
  4985. {
  4986. for (int i = 0; i < 4; ++i)
  4987. {
  4988. if (TrapCode & (1 << (4 + i)))
  4989. {
  4990. ULONG Addr = GetReg32(X86_DR0 + i);
  4991. if (Addr)
  4992. {
  4993. ADDRFLAT(BpAddr, Addr);
  4994. return EXBS_BREAKPOINT_DATA;
  4995. }
  4996. }
  4997. }
  4998. }
  4999. }
  5000. }
  5001. return EXBS_NONE;
  5002. }
  5003. VOID
  5004. Wow64CopyFpFromIa64Byte16(
  5005. IN PVOID Byte16Fp,
  5006. IN OUT PVOID Byte10Fp,
  5007. IN ULONG NumRegs);
  5008. VOID
  5009. Wow64CopyFpToIa64Byte16(
  5010. IN PVOID Byte10Fp,
  5011. IN OUT PVOID Byte16Fp,
  5012. IN ULONG NumRegs);
  5013. VOID
  5014. Wow64CopyXMMIToIa64Byte16(
  5015. IN PVOID ByteXMMI,
  5016. IN OUT PVOID Byte16Fp,
  5017. IN ULONG NumRegs);
  5018. VOID
  5019. Wow64CopyXMMIFromIa64Byte16(
  5020. IN PVOID Byte16Fp,
  5021. IN OUT PVOID ByteXMMI,
  5022. IN ULONG NumRegs);
  5023. VOID
  5024. Wow64RotateFpTop(
  5025. IN ULONGLONG Ia64_FSR,
  5026. IN OUT FLOAT128 UNALIGNED *ia32FxSave);
  5027. VOID
  5028. Wow64CopyIa64FromSpill(
  5029. IN PFLOAT128 SpillArea,
  5030. IN OUT FLOAT128 UNALIGNED *ia64Fp,
  5031. IN ULONG NumRegs);
  5032. VOID
  5033. Wow64CopyIa64ToFill(
  5034. IN FLOAT128 UNALIGNED *ia64Fp,
  5035. IN OUT PFLOAT128 FillArea,
  5036. IN ULONG NumRegs);
  5037. BOOL
  5038. MapDbgSlotIa64ToX86(
  5039. UINT Slot,
  5040. ULONG64 Ipsr,
  5041. ULONG64 DbD,
  5042. ULONG64 DbD1,
  5043. ULONG64 DbI,
  5044. ULONG64 DbI1,
  5045. ULONG* Dr7,
  5046. ULONG* Dr);
  5047. void
  5048. MapDbgSlotX86ToIa64(
  5049. UINT Slot,
  5050. ULONG Dr7,
  5051. ULONG Dr,
  5052. ULONG64* Ipsr,
  5053. ULONG64* DbD,
  5054. ULONG64* DbD1,
  5055. ULONG64* DbI,
  5056. ULONG64* DbI1);
  5057. void
  5058. X86OnIa64MachineInfo::Ia64ContextToX86(
  5059. PIA64_CONTEXT ContextIa64,
  5060. PX86_NT5_CONTEXT ContextX86)
  5061. {
  5062. FLOAT128 tmpFloat[NUMBER_OF_387_REGS];
  5063. ULONG Ia32ContextFlags = ContextX86->ContextFlags;
  5064. ULONG Tid = GetCurrentThreadId();
  5065. DebugClient* Client;
  5066. for (Client = g_Clients; Client != NULL; Client = Client->m_Next)
  5067. {
  5068. if (Client->m_ThreadId == Tid)
  5069. {
  5070. break;
  5071. }
  5072. }
  5073. DBG_ASSERT((Client!=NULL));
  5074. if (!((Ia64MachineInfo*)m_Target->m_Machines[MACHIDX_IA64])->
  5075. IsIA32InstructionSet())
  5076. {
  5077. if (g_Wow64exts == NULL)
  5078. {
  5079. dprintf("Need to load wow64exts.dll to retrieve context!\n");
  5080. return;
  5081. }
  5082. (*g_Wow64exts)(WOW64EXTS_GET_CONTEXT,
  5083. (ULONG64)Client,
  5084. (ULONG64)ContextX86,
  5085. (ULONG64)NULL);
  5086. return;
  5087. }
  5088. if ((Ia32ContextFlags & VDMCONTEXT_CONTROL) == VDMCONTEXT_CONTROL)
  5089. {
  5090. //
  5091. // And the control stuff
  5092. //
  5093. ContextX86->Ebp = (ULONG)ContextIa64->IntTeb;
  5094. ContextX86->SegCs = X86_KGDT_R3_CODE|3;
  5095. ContextX86->Eip = (ULONG)ContextIa64->StIIP;
  5096. ContextX86->SegSs = X86_KGDT_R3_DATA|3;
  5097. ContextX86->Esp = (ULONG)ContextIa64->IntSp;
  5098. ContextX86->EFlags = (ULONG)ContextIa64->Eflag;
  5099. //
  5100. // Map single step flag (EFlags.tf = EFlags.tf || PSR.ss)
  5101. //
  5102. if (ContextIa64->StIPSR & (1I64 << PSR_SS))
  5103. {
  5104. ContextX86->EFlags |= X86_BIT_FLAGTF;
  5105. }
  5106. }
  5107. if ((Ia32ContextFlags & VDMCONTEXT_INTEGER) == VDMCONTEXT_INTEGER)
  5108. {
  5109. //
  5110. // Now for the integer state...
  5111. //
  5112. ContextX86->Edi = (ULONG)ContextIa64->IntT6;
  5113. ContextX86->Esi = (ULONG)ContextIa64->IntT5;
  5114. ContextX86->Ebx = (ULONG)ContextIa64->IntT4;
  5115. ContextX86->Edx = (ULONG)ContextIa64->IntT3;
  5116. ContextX86->Ecx = (ULONG)ContextIa64->IntT2;
  5117. ContextX86->Eax = (ULONG)ContextIa64->IntV0;
  5118. }
  5119. if ((Ia32ContextFlags & VDMCONTEXT_SEGMENTS) == VDMCONTEXT_SEGMENTS)
  5120. {
  5121. //
  5122. // These are constants (and constants are used on ia32->ia64
  5123. // transition, not saved values) so make our life easy...
  5124. //
  5125. ContextX86->SegGs = 0;
  5126. ContextX86->SegEs = X86_KGDT_R3_DATA|3;
  5127. ContextX86->SegDs = X86_KGDT_R3_DATA|3;
  5128. ContextX86->SegSs = X86_KGDT_R3_DATA|3;
  5129. ContextX86->SegFs = X86_KGDT_R3_TEB|3;
  5130. ContextX86->SegCs = X86_KGDT_R3_CODE|3;
  5131. }
  5132. if ((Ia32ContextFlags & VDMCONTEXT_EXTENDED_REGISTERS) ==
  5133. VDMCONTEXT_EXTENDED_REGISTERS)
  5134. {
  5135. PX86_FXSAVE_FORMAT xmmi =
  5136. (PX86_FXSAVE_FORMAT) ContextX86->ExtendedRegisters;
  5137. xmmi->ControlWord = (USHORT)(ContextIa64->StFCR & 0xffff);
  5138. xmmi->StatusWord = (USHORT)(ContextIa64->StFSR & 0xffff);
  5139. xmmi->TagWord = (USHORT)(ContextIa64->StFSR >> 16) & 0xffff;
  5140. xmmi->ErrorOpcode = (USHORT)(ContextIa64->StFIR >> 48);
  5141. xmmi->ErrorOffset = (ULONG) (ContextIa64->StFIR & 0xffffffff);
  5142. xmmi->ErrorSelector = (ULONG) (ContextIa64->StFIR >> 32);
  5143. xmmi->DataOffset = (ULONG) (ContextIa64->StFDR & 0xffffffff);
  5144. xmmi->DataSelector = (ULONG) (ContextIa64->StFDR >> 32);
  5145. xmmi->MXCsr = (ULONG) (ContextIa64->StFCR >> 32) & 0xffff;
  5146. //
  5147. // Copy over the FP registers. Even though this is the new
  5148. // FXSAVE format with 16-bytes for each register, need to
  5149. // convert from spill/fill format to 80-bit double extended format
  5150. //
  5151. Wow64CopyIa64FromSpill((PFLOAT128) &(ContextIa64->FltT2),
  5152. (PFLOAT128) xmmi->RegisterArea,
  5153. NUMBER_OF_387_REGS);
  5154. //
  5155. // Rotate the registers appropriately
  5156. //
  5157. Wow64RotateFpTop(ContextIa64->StFSR, (PFLOAT128) xmmi->RegisterArea);
  5158. //
  5159. // Finally copy the xmmi registers
  5160. //
  5161. Wow64CopyXMMIFromIa64Byte16(&(ContextIa64->FltS4),
  5162. xmmi->Reserved3,
  5163. NUMBER_OF_XMMI_REGS);
  5164. }
  5165. if ((Ia32ContextFlags & VDMCONTEXT_FLOATING_POINT) ==
  5166. VDMCONTEXT_FLOATING_POINT)
  5167. {
  5168. //
  5169. // Copy over the floating point status/control stuff
  5170. //
  5171. ContextX86->FloatSave.ControlWord = (ULONG)(ContextIa64->StFCR & 0xffff);
  5172. ContextX86->FloatSave.StatusWord = (ULONG)(ContextIa64->StFSR & 0xffff);
  5173. ContextX86->FloatSave.TagWord = (ULONG)(ContextIa64->StFSR >> 16) & 0xffff;
  5174. ContextX86->FloatSave.ErrorOffset = (ULONG)(ContextIa64->StFIR & 0xffffffff);
  5175. ContextX86->FloatSave.ErrorSelector = (ULONG)(ContextIa64->StFIR >> 32);
  5176. ContextX86->FloatSave.DataOffset = (ULONG)(ContextIa64->StFDR & 0xffffffff);
  5177. ContextX86->FloatSave.DataSelector = (ULONG)(ContextIa64->StFDR >> 32);
  5178. //
  5179. // Copy over the FP registers into temporary space
  5180. // Even though this is the new
  5181. // FXSAVE format with 16-bytes for each register, need to
  5182. // convert from spill/fill format to 80-bit double extended format
  5183. //
  5184. Wow64CopyIa64FromSpill((PFLOAT128) &(ContextIa64->FltT2),
  5185. (PFLOAT128) tmpFloat,
  5186. NUMBER_OF_387_REGS);
  5187. //
  5188. // Rotate the registers appropriately
  5189. //
  5190. Wow64RotateFpTop(ContextIa64->StFSR, tmpFloat);
  5191. //
  5192. // And put them in the older FNSAVE format (packed 10 byte values)
  5193. //
  5194. Wow64CopyFpFromIa64Byte16(tmpFloat,
  5195. ContextX86->FloatSave.RegisterArea,
  5196. NUMBER_OF_387_REGS);
  5197. }
  5198. if ((Ia32ContextFlags & VDMCONTEXT_DEBUG_REGISTERS) ==
  5199. VDMCONTEXT_DEBUG_REGISTERS)
  5200. {
  5201. // Ia64 -> X86
  5202. BOOL Valid = TRUE;
  5203. Valid &= MapDbgSlotIa64ToX86(0, ContextIa64->StIPSR, ContextIa64->DbD0, ContextIa64->DbD1, ContextIa64->DbI0, ContextIa64->DbI1, &ContextX86->Dr7, &ContextX86->Dr0);
  5204. Valid &= MapDbgSlotIa64ToX86(1, ContextIa64->StIPSR, ContextIa64->DbD2, ContextIa64->DbD3, ContextIa64->DbI2, ContextIa64->DbI3, &ContextX86->Dr7, &ContextX86->Dr1);
  5205. Valid &= MapDbgSlotIa64ToX86(2, ContextIa64->StIPSR, ContextIa64->DbD4, ContextIa64->DbD5, ContextIa64->DbI4, ContextIa64->DbI5, &ContextX86->Dr7, &ContextX86->Dr2);
  5206. Valid &= MapDbgSlotIa64ToX86(3, ContextIa64->StIPSR, ContextIa64->DbD6, ContextIa64->DbD7, ContextIa64->DbI6, ContextIa64->DbI7, &ContextX86->Dr7, &ContextX86->Dr3);
  5207. if (!Valid)
  5208. {
  5209. WarnOut("Wasn't able to map IA64 debug registers consistently!!!\n");
  5210. }
  5211. //
  5212. // Map single step flag (EFlags.tf = EFlags.tf || PSR.ss)
  5213. //
  5214. if (ContextIa64->StIPSR & (1I64 << PSR_SS))
  5215. {
  5216. ContextX86->EFlags |= X86_BIT_FLAGTF;
  5217. }
  5218. }
  5219. }
  5220. void
  5221. X86OnIa64MachineInfo::X86ContextToIa64(
  5222. PX86_NT5_CONTEXT ContextX86,
  5223. PIA64_CONTEXT ContextIa64)
  5224. {
  5225. FLOAT128 tmpFloat[NUMBER_OF_387_REGS];
  5226. ULONG Ia32ContextFlags = ContextX86->ContextFlags;
  5227. ULONG Tid = GetCurrentThreadId();
  5228. DebugClient* Client;
  5229. for (Client = g_Clients; Client != NULL; Client = Client->m_Next)
  5230. {
  5231. if (Client->m_ThreadId == Tid)
  5232. {
  5233. break;
  5234. }
  5235. }
  5236. DBG_ASSERT((Client!=NULL));
  5237. if (!((Ia64MachineInfo*)m_Target->m_Machines[MACHIDX_IA64])->
  5238. IsIA32InstructionSet())
  5239. {
  5240. if (g_Wow64exts == NULL)
  5241. {
  5242. dprintf("Need to load wow64exts.dll to retrieve context!\n");
  5243. return;
  5244. }
  5245. (*g_Wow64exts)(WOW64EXTS_SET_CONTEXT,
  5246. (ULONG64)Client,
  5247. (ULONG64)ContextX86,
  5248. (ULONG64)NULL);
  5249. return;
  5250. }
  5251. if ((Ia32ContextFlags & VDMCONTEXT_CONTROL) == VDMCONTEXT_CONTROL)
  5252. {
  5253. //
  5254. // And the control stuff
  5255. //
  5256. ContextIa64->IntTeb = ContextX86->Ebp;
  5257. ContextIa64->StIIP = ContextX86->Eip;
  5258. ContextIa64->IntSp = ContextX86->Esp;
  5259. ContextIa64->Eflag = ContextX86->EFlags;
  5260. //
  5261. // Map single step flag (PSR.ss = PSR.ss || EFlags.tf)
  5262. //
  5263. if (ContextX86->EFlags & X86_BIT_FLAGTF)
  5264. {
  5265. ContextIa64->StIPSR |= (1I64 << PSR_SS);
  5266. }
  5267. //
  5268. // The segments (cs and ds) are a constant, so reset them.
  5269. // gr17 has LDT and TSS, so might as well reset
  5270. // all of them while we're at it...
  5271. // These values are forced in during a transition (see simulate.s)
  5272. // so there is no point to trying to get cute and actually
  5273. // pass in the values from the X86 context record
  5274. //
  5275. ContextIa64->IntT8 = ((X86_KGDT_LDT|3) << 32)
  5276. | ((X86_KGDT_R3_DATA|3) << 16)
  5277. | (X86_KGDT_R3_CODE|3);
  5278. }
  5279. if ((Ia32ContextFlags & VDMCONTEXT_INTEGER) == VDMCONTEXT_INTEGER)
  5280. {
  5281. //
  5282. // Now for the integer state...
  5283. //
  5284. ContextIa64->IntT6 = ContextX86->Edi;
  5285. ContextIa64->IntT5 = ContextX86->Esi;
  5286. ContextIa64->IntT4 = ContextX86->Ebx;
  5287. ContextIa64->IntT3 = ContextX86->Edx;
  5288. ContextIa64->IntT2 = ContextX86->Ecx;
  5289. ContextIa64->IntV0 = ContextX86->Eax;
  5290. }
  5291. if ((Ia32ContextFlags & VDMCONTEXT_SEGMENTS) == VDMCONTEXT_SEGMENTS)
  5292. {
  5293. //
  5294. // These are constants (and constants are used on ia32->ia64
  5295. // transition, not saved values) so make our life easy...
  5296. // These values are forced in during a transition (see simulate.s)
  5297. // so there is no point to trying to get cute and actually
  5298. // pass in the values from the X86 context record
  5299. //
  5300. ContextIa64->IntT7 = ((X86_KGDT_R3_TEB|3) << 32)
  5301. | ((X86_KGDT_R3_DATA|3) << 16)
  5302. | (X86_KGDT_R3_DATA|3);
  5303. }
  5304. if ((Ia32ContextFlags & VDMCONTEXT_EXTENDED_REGISTERS) ==
  5305. VDMCONTEXT_EXTENDED_REGISTERS)
  5306. {
  5307. PX86_FXSAVE_FORMAT xmmi =
  5308. (PX86_FXSAVE_FORMAT) ContextX86->ExtendedRegisters;
  5309. //
  5310. // And copy over the floating point status/control stuff
  5311. //
  5312. ContextIa64->StFCR = (ContextIa64->StFCR & 0xffffffffffffe040i64) |
  5313. (xmmi->ControlWord & 0xffff) |
  5314. ((ULONG64)(xmmi->MXCsr & 0xffff) << 32);
  5315. ContextIa64->StFSR = (ContextIa64->StFSR & 0xffffffff00000000i64) |
  5316. (xmmi->StatusWord & 0xffff) |
  5317. ((ULONG64)(xmmi->TagWord & 0xffff) << 16);
  5318. ContextIa64->StFIR = (xmmi->ErrorOffset & 0xffffffff) |
  5319. ((ULONG64)xmmi->ErrorSelector << 32);
  5320. ContextIa64->StFDR = (xmmi->DataOffset & 0xffffffff) |
  5321. ((ULONG64)xmmi->DataSelector << 32);
  5322. //
  5323. // Don't touch the original ia32 context. Make a copy.
  5324. //
  5325. memcpy(tmpFloat, xmmi->RegisterArea,
  5326. NUMBER_OF_387_REGS * sizeof(FLOAT128));
  5327. //
  5328. // Rotate registers back since st0 is not necessarily f8
  5329. //
  5330. {
  5331. ULONGLONG RotateFSR = (NUMBER_OF_387_REGS -
  5332. ((ContextIa64->StFSR >> 11) & 0x7)) << 11;
  5333. Wow64RotateFpTop(RotateFSR, tmpFloat);
  5334. }
  5335. //
  5336. // Copy over the FP registers. Even though this is the new
  5337. // FXSAVE format with 16-bytes for each register, need to
  5338. // convert to spill/fill format from 80-bit double extended format
  5339. //
  5340. Wow64CopyIa64ToFill((PFLOAT128) tmpFloat,
  5341. (PFLOAT128) &(ContextIa64->FltT2),
  5342. NUMBER_OF_387_REGS);
  5343. //
  5344. // Copy over the xmmi registers and convert them into a format
  5345. // that spill/fill can use
  5346. //
  5347. Wow64CopyXMMIToIa64Byte16(xmmi->Reserved3,
  5348. &(ContextIa64->FltS4),
  5349. NUMBER_OF_XMMI_REGS);
  5350. }
  5351. if ((Ia32ContextFlags & VDMCONTEXT_FLOATING_POINT) ==
  5352. VDMCONTEXT_FLOATING_POINT)
  5353. {
  5354. //
  5355. // Copy over the floating point status/control stuff
  5356. // Leave the MXCSR stuff alone
  5357. //
  5358. ContextIa64->StFCR = (ContextIa64->StFCR & 0xffffffffffffe040i64) |
  5359. (ContextX86->FloatSave.ControlWord & 0xffff);
  5360. ContextIa64->StFSR = (ContextIa64->StFSR & 0xffffffff00000000i64) |
  5361. (ContextX86->FloatSave.StatusWord & 0xffff) |
  5362. ((ULONG64)(ContextX86->FloatSave.TagWord & 0xffff) << 16);
  5363. ContextIa64->StFIR = (ContextX86->FloatSave.ErrorOffset & 0xffffffff) |
  5364. ((ULONG64)ContextX86->FloatSave.ErrorSelector << 32);
  5365. ContextIa64->StFDR = (ContextX86->FloatSave.DataOffset & 0xffffffff) |
  5366. ((ULONG64)ContextX86->FloatSave.DataSelector << 32);
  5367. //
  5368. // Copy over the FP registers from packed 10-byte format
  5369. // to 16-byte format
  5370. //
  5371. Wow64CopyFpToIa64Byte16(ContextX86->FloatSave.RegisterArea,
  5372. tmpFloat,
  5373. NUMBER_OF_387_REGS);
  5374. //
  5375. // Rotate registers back since st0 is not necessarily f8
  5376. //
  5377. {
  5378. ULONGLONG RotateFSR = (NUMBER_OF_387_REGS -
  5379. ((ContextIa64->StFSR >> 11) & 0x7)) << 11;
  5380. Wow64RotateFpTop(RotateFSR, tmpFloat);
  5381. }
  5382. //
  5383. // Now convert from 80 bit extended format to fill/spill format
  5384. //
  5385. Wow64CopyIa64ToFill((PFLOAT128) tmpFloat,
  5386. (PFLOAT128) &(ContextIa64->FltT2),
  5387. NUMBER_OF_387_REGS);
  5388. }
  5389. if ((Ia32ContextFlags & VDMCONTEXT_DEBUG_REGISTERS) ==
  5390. VDMCONTEXT_DEBUG_REGISTERS)
  5391. {
  5392. // X86 -> Ia64
  5393. MapDbgSlotX86ToIa64(0, ContextX86->Dr7, ContextX86->Dr0, &ContextIa64->StIPSR, &ContextIa64->DbD0, &ContextIa64->DbD1, &ContextIa64->DbI0, &ContextIa64->DbI1);
  5394. MapDbgSlotX86ToIa64(1, ContextX86->Dr7, ContextX86->Dr1, &ContextIa64->StIPSR, &ContextIa64->DbD2, &ContextIa64->DbD3, &ContextIa64->DbI2, &ContextIa64->DbI3);
  5395. MapDbgSlotX86ToIa64(2, ContextX86->Dr7, ContextX86->Dr2, &ContextIa64->StIPSR, &ContextIa64->DbD4, &ContextIa64->DbD5, &ContextIa64->DbI4, &ContextIa64->DbI5);
  5396. MapDbgSlotX86ToIa64(3, ContextX86->Dr7, ContextX86->Dr3, &ContextIa64->StIPSR, &ContextIa64->DbD6, &ContextIa64->DbD7, &ContextIa64->DbI6, &ContextIa64->DbI7);
  5397. //
  5398. // Map single step flag (PSR.ss = PSR.ss || EFlags.tf)
  5399. //
  5400. if (ContextX86->EFlags & X86_BIT_FLAGTF)
  5401. {
  5402. ContextIa64->StIPSR |= (1I64 << PSR_SS);
  5403. }
  5404. }
  5405. }
  5406. //
  5407. // Helper functions for context conversion
  5408. // --copied from \nt\base\wow64\cpu\context\context.c
  5409. //
  5410. //
  5411. // This allows the compiler to be more efficient in copying 10 bytes
  5412. // without over copying...
  5413. //
  5414. #pragma pack(push, 2)
  5415. typedef struct _ia32fpbytes {
  5416. ULONG significand_low;
  5417. ULONG significand_high;
  5418. USHORT exponent;
  5419. } IA32FPBYTES, *PIA32FPBYTES;
  5420. #pragma pack(pop)
  5421. VOID
  5422. Wow64CopyFpFromIa64Byte16(
  5423. IN PVOID Byte16Fp,
  5424. IN OUT PVOID Byte10Fp,
  5425. IN ULONG NumRegs)
  5426. {
  5427. ULONG i;
  5428. PIA32FPBYTES from, to;
  5429. from = (PIA32FPBYTES) Byte16Fp;
  5430. to = (PIA32FPBYTES) Byte10Fp;
  5431. for (i = 0; i < NumRegs; i++) {
  5432. *to = *from;
  5433. from = (PIA32FPBYTES) (((UINT_PTR) from) + 16);
  5434. to = (PIA32FPBYTES) (((UINT_PTR) to) + 10);
  5435. }
  5436. }
  5437. VOID
  5438. Wow64CopyFpToIa64Byte16(
  5439. IN PVOID Byte10Fp,
  5440. IN OUT PVOID Byte16Fp,
  5441. IN ULONG NumRegs)
  5442. {
  5443. ULONG i;
  5444. PIA32FPBYTES from, to; // UNALIGNED
  5445. from = (PIA32FPBYTES) Byte10Fp;
  5446. to = (PIA32FPBYTES) Byte16Fp;
  5447. for (i = 0; i < NumRegs; i++) {
  5448. *to = *from;
  5449. from = (PIA32FPBYTES) (((UINT_PTR) from) + 10);
  5450. to = (PIA32FPBYTES) (((UINT_PTR) to) + 16);
  5451. }
  5452. }
  5453. //
  5454. // Alas, nothing is easy. The ia32 xmmi instructions use 16 bytes and pack
  5455. // them as nice 16 byte structs. Unfortunately, ia64 handles it as 2 8-byte
  5456. // values (using just the mantissa part). So, another conversion is required
  5457. //
  5458. VOID
  5459. Wow64CopyXMMIToIa64Byte16(
  5460. IN PVOID ByteXMMI,
  5461. IN OUT PVOID Byte16Fp,
  5462. IN ULONG NumRegs)
  5463. {
  5464. ULONG i;
  5465. UNALIGNED ULONGLONG *from;
  5466. ULONGLONG *to;
  5467. from = (PULONGLONG) ByteXMMI;
  5468. to = (PULONGLONG) Byte16Fp;
  5469. //
  5470. // although we have NumRegs xmmi registers, each register is 16 bytes
  5471. // wide. This code does things in 8-byte chunks, so total
  5472. // number of times to do things is 2 * NumRegs...
  5473. //
  5474. NumRegs *= 2;
  5475. for (i = 0; i < NumRegs; i++) {
  5476. *to++ = *from++; // Copy over the mantissa part
  5477. *to++ = 0x1003e; // Force the exponent part
  5478. // (see ia64 eas, ia32 FP section - 6.2.7
  5479. // for where this magic number comes from)
  5480. }
  5481. }
  5482. VOID
  5483. Wow64CopyXMMIFromIa64Byte16(
  5484. IN PVOID Byte16Fp,
  5485. IN OUT PVOID ByteXMMI,
  5486. IN ULONG NumRegs)
  5487. {
  5488. ULONG i;
  5489. ULONGLONG *from;
  5490. UNALIGNED ULONGLONG *to;
  5491. from = (PULONGLONG) Byte16Fp;
  5492. to = (PULONGLONG) ByteXMMI;
  5493. //
  5494. // although we have NumRegs xmmi registers, each register is 16 bytes
  5495. // wide. This code does things in 8-byte chunks, so total
  5496. // number of times to do things is 2 * NumRegs...
  5497. //
  5498. NumRegs *= 2;
  5499. for (i = 0; i < NumRegs; i++) {
  5500. *to++ = *from++; // Copy over the mantissa part
  5501. from++; // Skip over the exponent part
  5502. }
  5503. }
  5504. VOID
  5505. Wow64RotateFpTop(
  5506. IN ULONGLONG Ia64_FSR,
  5507. IN OUT FLOAT128 UNALIGNED *ia32FxSave)
  5508. /*++
  5509. Routine Description:
  5510. On transition from ia64 mode to ia32 (and back), the f8-f15 registers
  5511. contain the st[0] to st[7] fp stack values. Alas, these values don't
  5512. map one-one, so the FSR.top bits are used to determine which ia64
  5513. register has the top of stack. We then need to rotate these registers
  5514. since ia32 context is expecting st[0] to be the first fp register (as
  5515. if FSR.top is zero). This routine only works on full 16-byte ia32
  5516. saved fp data (such as from ExtendedRegisters - the FXSAVE format).
  5517. Other routines can convert this into the older FNSAVE format.
  5518. Arguments:
  5519. Ia64_FSR - The ia64 FSR register. Has the FSR.top needed for this routine
  5520. ia32FxSave - The ia32 fp stack (in FXSAVE format). Each ia32 fp register
  5521. uses 16 bytes.
  5522. Return Value:
  5523. None.
  5524. --*/
  5525. {
  5526. ULONG top = (ULONG) ((Ia64_FSR >> 11) & 0x7);
  5527. if (top) {
  5528. FLOAT128 tmpFloat[NUMBER_OF_387_REGS];
  5529. ULONG i;
  5530. for (i = 0; i < NUMBER_OF_387_REGS; i++) {
  5531. tmpFloat[i] = ia32FxSave[i];
  5532. }
  5533. for (i = 0; i < NUMBER_OF_387_REGS; i++) {
  5534. ia32FxSave[i] = tmpFloat[(i + top) % NUMBER_OF_387_REGS];
  5535. }
  5536. }
  5537. }
  5538. //
  5539. // And now for the final yuck... The ia64 context for floating point
  5540. // is saved/loaded using spill/fill instructions. This format is different
  5541. // than the 10-byte fp format so we need a conversion routine from spill/fill
  5542. // to/from 10byte fp
  5543. //
  5544. VOID
  5545. Wow64CopyIa64FromSpill(
  5546. IN PFLOAT128 SpillArea,
  5547. IN OUT FLOAT128 UNALIGNED *ia64Fp,
  5548. IN ULONG NumRegs)
  5549. /*++
  5550. Routine Description:
  5551. This function copies fp values from the ia64 spill/fill format
  5552. into the ia64 80-bit format. The exponent needs to be adjusted
  5553. according to the EAS (5-12) regarding Memory to Floating Point
  5554. Register Data Translation in the ia64 floating point chapter
  5555. Arguments:
  5556. SpillArea - The ia64 area that has the spill format for fp
  5557. ia64Fp - The location which will get the ia64 fp in 80-bit
  5558. double-extended format
  5559. NumRegs - Number of registers to convert
  5560. Return Value:
  5561. None.
  5562. --*/
  5563. {
  5564. ULONG i;
  5565. for (i = 0; i < NumRegs; i++) {
  5566. ULONG64 Sign = ((SpillArea->HighPart & (1i64 << 17)) != 0);
  5567. ULONG64 Significand = SpillArea->LowPart;
  5568. ULONG64 Exponent = SpillArea->HighPart & 0x1ffff;
  5569. if (Exponent && Significand)
  5570. {
  5571. if (Exponent == 0x1ffff) // NaNs and Infinities
  5572. {
  5573. Exponent = 0x7fff;
  5574. }
  5575. else
  5576. {
  5577. ULONG64 Rebias = 0xffff - 0x3fff;
  5578. Exponent -= Rebias;
  5579. }
  5580. }
  5581. ia64Fp->HighPart = (Sign << 15) | Exponent;
  5582. ia64Fp->LowPart = Significand;
  5583. ia64Fp++;
  5584. SpillArea++;
  5585. }
  5586. }
  5587. VOID
  5588. Wow64CopyIa64ToFill(
  5589. IN FLOAT128 UNALIGNED *ia64Fp,
  5590. IN OUT PFLOAT128 FillArea,
  5591. IN ULONG NumRegs)
  5592. /*++
  5593. Routine Description:
  5594. This function copies fp values from the ia64 80-bit format
  5595. into the fill/spill format used by the os for save/restore
  5596. of the ia64 context. The only magic here is putting back some
  5597. values that get truncated when converting from spill/fill to
  5598. 80-bits. The exponent needs to be adjusted according to the
  5599. EAS (5-12) regarding Memory to Floating Point Register Data
  5600. Translation in the ia64 floating point chapter
  5601. Arguments:
  5602. ia64Fp - The ia64 fp in 80-bit double-extended format
  5603. FillArea - The ia64 area that will get the fill format for fp
  5604. for the copy into the ia64 context area
  5605. NumRegs - Number of registers to convert
  5606. Return Value:
  5607. None.
  5608. --*/
  5609. {
  5610. ULONG i;
  5611. for (i = 0; i < NumRegs; i++) {
  5612. ULONG64 Sign = ((ia64Fp->HighPart & (1i64 << 15)) != 0);
  5613. ULONG64 Significand = ia64Fp->LowPart;
  5614. ULONG64 Exponent = ia64Fp->HighPart & 0x7fff;
  5615. if (Exponent && Significand)
  5616. {
  5617. if (Exponent == 0x7fff) // Infinity
  5618. {
  5619. Exponent = 0x1ffff;
  5620. }
  5621. else
  5622. {
  5623. ULONGLONG Rebias = 0xffff-0x3fff;
  5624. Exponent += Rebias;
  5625. }
  5626. }
  5627. FillArea->LowPart = Significand;
  5628. FillArea->HighPart = (Sign << 17) | Exponent;
  5629. ia64Fp++;
  5630. FillArea++;
  5631. }
  5632. }
  5633. ULONG
  5634. MapDbgSlotIa64ToX86_GetSize(ULONG64 Db1, BOOL* Valid)
  5635. {
  5636. ULONG64 Size = (~Db1 & IA64_DBG_MASK_MASK);
  5637. if (Size > 3)
  5638. {
  5639. *Valid = FALSE;
  5640. }
  5641. return (ULONG)Size;
  5642. }
  5643. void
  5644. MapDbgSlotIa64ToX86_InvalidateAddr(ULONG64 Db, BOOL* Valid)
  5645. {
  5646. if (Db != (ULONG64)(ULONG)Db)
  5647. {
  5648. *Valid = FALSE;
  5649. }
  5650. }
  5651. ULONG
  5652. MapDbgSlotIa64ToX86_ExecTypeSize(
  5653. UINT Slot,
  5654. ULONG64 Db,
  5655. ULONG64 Db1,
  5656. BOOL* Valid)
  5657. {
  5658. ULONG TypeSize;
  5659. if (!(Db1 >> 63))
  5660. {
  5661. *Valid = FALSE;
  5662. }
  5663. TypeSize = (MapDbgSlotIa64ToX86_GetSize(Db1, Valid) << 2);
  5664. MapDbgSlotIa64ToX86_InvalidateAddr(Db, Valid);
  5665. return TypeSize;
  5666. }
  5667. ULONG
  5668. MapDbgSlotIa64ToX86_DataTypeSize(
  5669. UINT Slot,
  5670. ULONG64 Db,
  5671. ULONG64 Db1,
  5672. BOOL* Valid)
  5673. {
  5674. ULONG TypeSize = (ULONG)(Db1 >> 62);
  5675. if ((TypeSize != 1) && (TypeSize != 3))
  5676. {
  5677. *Valid = FALSE;
  5678. }
  5679. TypeSize |= (MapDbgSlotIa64ToX86_GetSize(Db1, Valid) << 2);
  5680. MapDbgSlotIa64ToX86_InvalidateAddr(Db, Valid);
  5681. return TypeSize;
  5682. }
  5683. BOOL
  5684. MapDbgSlotIa64ToX86(
  5685. UINT Slot,
  5686. ULONG64 Ipsr,
  5687. ULONG64 DbD,
  5688. ULONG64 DbD1,
  5689. ULONG64 DbI,
  5690. ULONG64 DbI1,
  5691. ULONG* Dr7,
  5692. ULONG* Dr)
  5693. {
  5694. BOOL DataValid = TRUE, ExecValid = TRUE, Valid = TRUE;
  5695. ULONG DataTypeSize, ExecTypeSize;
  5696. // XXX olegk - remove this after IA64_REG_MAX_DATA_BREAKPOINTS will be changed to 4
  5697. if (Slot >= IA64_REG_MAX_DATA_BREAKPOINTS)
  5698. {
  5699. return TRUE;
  5700. }
  5701. DataTypeSize = MapDbgSlotIa64ToX86_DataTypeSize(Slot, DbD, DbD1, &DataValid);
  5702. ExecTypeSize = MapDbgSlotIa64ToX86_ExecTypeSize(Slot, DbI, DbI1, &ExecValid);
  5703. if (DataValid)
  5704. {
  5705. if (!ExecValid)
  5706. {
  5707. *Dr = (ULONG)DbD;
  5708. *Dr7 |= (X86_DR7_LOCAL_EXACT_ENABLE |
  5709. (1 << Slot * 2) |
  5710. (DataTypeSize << (16 + Slot * 4)));
  5711. return !DbI && !DbI1;
  5712. }
  5713. }
  5714. else if (ExecValid)
  5715. {
  5716. *Dr = (ULONG)DbI;
  5717. *Dr7 |= (X86_DR7_LOCAL_EXACT_ENABLE |
  5718. (1 << Slot * 2) |
  5719. (ExecTypeSize << (16 + Slot * 4)));
  5720. return !DbD && !DbD1;
  5721. }
  5722. *Dr7 &= ~(X86_DR7_LOCAL_EXACT_ENABLE |
  5723. (0xf << (16 + Slot * 4)) |
  5724. (1 << Slot * 2));
  5725. if (!DbD && !DbD1 && !DbI && !DbI1)
  5726. {
  5727. *Dr = 0;
  5728. return TRUE;
  5729. }
  5730. *Dr = ~(ULONG)0;
  5731. return FALSE;
  5732. }
  5733. void
  5734. MapDbgSlotX86ToIa64(
  5735. UINT Slot,
  5736. ULONG Dr7,
  5737. ULONG Dr,
  5738. ULONG64* Ipsr,
  5739. ULONG64* DbD,
  5740. ULONG64* DbD1,
  5741. ULONG64* DbI,
  5742. ULONG64* DbI1)
  5743. {
  5744. UINT TypeSize;
  5745. ULONG64 Control;
  5746. if (!(Dr7 & (1 << Slot * 2)))
  5747. {
  5748. return;
  5749. }
  5750. if (Dr == ~(ULONG)0)
  5751. {
  5752. return;
  5753. }
  5754. TypeSize = Dr7 >> (16 + Slot * 4);
  5755. Control = (IA64_DBG_REG_PLM_USER | IA64_DBG_MASK_MASK) &
  5756. ~(ULONG64)(TypeSize >> 2);
  5757. switch (TypeSize & 0x3)
  5758. {
  5759. case 0x0: // Exec
  5760. *DbI1 = Control | IA64_DBR_EXEC;
  5761. *DbI = Dr;
  5762. break;
  5763. case 0x1: // Write
  5764. *DbD1 = Control | IA64_DBR_WR;
  5765. *DbD = Dr;
  5766. break;
  5767. case 0x3: // Read/Write
  5768. *DbD1 = Control | IA64_DBR_RD | IA64_DBR_WR;
  5769. *DbD = Dr;
  5770. break;
  5771. default:
  5772. return;
  5773. }
  5774. *Ipsr |= (1i64 << PSR_DB);
  5775. }