PMD.LST 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. Listing:
  2. 1 (* Release 3.00 *)
  3. 2
  4. 3 (* Copyright (C) 1987..1991 Jensen & Partners International *)
  5. 4
  6. 5 (*# call(seg_name=>null) *)
  7. 6 (*# name(prefix=>c) *)
  8. 7 (*# module(implementation=>off) *)
  9. 8 (*# check(stack=>off,
  10. 9 index=>off,
  11. 10 range=>off,
  12. 11 overflow=>off,
  13. 12 nil_ptr=>off) *)
  14. 13
  15. 14 IMPLEMENTATION MODULE PMD;
  16. 15
  17. 16 (*%F _OS2 *)
  18. 17 IMPORT Str, CoreSig, CoreIO, CorePMD, CoreMain;
  19. 18 (*%E *)
  20. 19 (*%T _OS2 *)
  21. 20 IMPORT Str, Dos, CoreSig, CoreIO, CorePMD, CoreMain;
  22. 21 (*%E *)
  23. 22
  24. 23 TYPE SegHeader = RECORD
  25. 24 frame: CARDINAL;
  26. 25 SegSize: CARDINAL;
  27. 26 FilePos: LONGCARD;
  28. ***** ^ undeclared identifier
  29. 27 BucketSizes: ARRAY [0..15] OF CARDINAL;
  30. ***** ^ not supported yet
  31. ***** ^ not supported yet
  32. 28 END;
  33. ***** ^ not supported yet
  34. 29
  35. 30 (*%T _OS2 *)
  36. 31 SelInfo = RECORD
  37. 32 selector, size: CARDINAL;
  38. 33 END;
  39. ***** ^ not supported yet
  40. 34
  41. 35 CONST
  42. 36 MAX_SELS = 256;
  43. 37 VAR
  44. 38 selectors: ARRAY [0..MAX_SELS] OF SelInfo;
  45. ***** ^ not supported yet
  46. ***** ^ not supported yet
  47. 39 (*%E *)
  48. 40
  49. 41 CONST
  50. 42 ErrMsg ="Runtime Error - Creating PM_DUMP.$$$";
  51. ***** ^ not supported yet
  52. 43
  53. 44 (*%T _OS2 *)
  54. 45 PROCEDURE Os2Write(handle: CARDINAL; buffer: FarADDRESS; count: CARDINAL): CARDINAL;
  55. ***** ^ undeclared identifier
  56. 46
  57. 47 VAR
  58. 48 NumWrit: CARDINAL;
  59. 49 BEGIN
  60. 50 IF Dos.Write(handle, buffer, count, NumWrit) = 0 THEN
  61. ***** ^ not supported yet
  62. ***** ^ not supported yet
  63. ***** ^ not supported yet
  64. ***** ^ not supported yet
  65. 51 RETURN NumWrit;
  66. 52 END;
  67. 53 RETURN MAX(CARDINAL);
  68. ***** ^ undeclared identifier
  69. ***** ^ not supported yet
  70. 54 END Os2Write;
  71. ***** ^ not supported yet
  72. 55
  73. 56 PROCEDURE GetSelectors(): CARDINAL;
  74. 57
  75. 58 VAR
  76. 59 CurSel: CARDINAL;
  77. 60 attempt, size: CARDINAL;
  78. 61 BEGIN
  79. 62 CurSel:=0;
  80. 63 attempt:=0FH;
  81. 64 WHILE attempt # 0FFFFH DO
  82. 65 size := CorePMD.lsl(attempt);
  83. ***** ^ not supported yet
  84. ***** ^ not supported yet
  85. ***** ^ not supported yet
  86. 66 IF size # 0 THEN
  87. 67 selectors[CurSel].size:=size+1;
  88. ***** ^ not supported yet
  89. ***** ^ not supported yet
  90. ***** ^ not supported yet
  91. 68 selectors[CurSel].selector:=attempt;
  92. ***** ^ not supported yet
  93. ***** ^ not supported yet
  94. ***** ^ not supported yet
  95. 69 INC(CurSel);
  96. ***** ^ undeclared identifier
  97. ***** ^ not supported yet
  98. 70 IF CurSel = MAX_SELS THEN
  99. 71 RETURN CurSel;
  100. 72 END;
  101. 73 END;
  102. 74 INC(attempt, 10H);
  103. ***** ^ undeclared identifier
  104. ***** ^ not supported yet
  105. 75 END;
  106. 76 attempt:=07H;
  107. 77 WHILE attempt # 0FFF7H DO
  108. 78 size := CorePMD.lsl(attempt);
  109. ***** ^ not supported yet
  110. ***** ^ not supported yet
  111. ***** ^ not supported yet
  112. 79 IF size # 0 THEN
  113. 80 selectors[CurSel].size:=size+1;
  114. ***** ^ not supported yet
  115. ***** ^ not supported yet
  116. ***** ^ not supported yet
  117. 81 selectors[CurSel].selector:=attempt;
  118. ***** ^ not supported yet
  119. ***** ^ not supported yet
  120. ***** ^ not supported yet
  121. 82 INC(CurSel);
  122. ***** ^ undeclared identifier
  123. ***** ^ not supported yet
  124. 83 IF CurSel = MAX_SELS THEN
  125. 84 RETURN CurSel;
  126. 85 END;
  127. 86 END;
  128. 87 INC(attempt, 10H);
  129. ***** ^ undeclared identifier
  130. ***** ^ not supported yet
  131. 88 END;
  132. 89 RETURN CurSel;
  133. 90 END GetSelectors;
  134. ***** ^ not supported yet
  135. 91
  136. 92 PROCEDURE WriteStruct(VAR State: ProcessState; fh: INTEGER): INTEGER;
  137. ***** ^ undeclared identifier
  138. 93
  139. 94 BEGIN
  140. 95 IF Os2Write(fh, FarADR(State), SIZE(ProcessState)) # SIZE(ProcessState) THEN
  141. ***** ^ not supported yet
  142. ***** ^ undeclared identifier
  143. ***** ^ not supported yet
  144. ***** ^ undeclared identifier
  145. ***** ^ undeclared identifier
  146. ***** ^ undeclared identifier
  147. ***** ^ undeclared identifier
  148. 96 RETURN -1;
  149. 97 END;
  150. 98 RETURN 0;
  151. 99 END WriteStruct;
  152. ***** ^ not supported yet
  153. 100 (*%E *)
  154. 101
  155. 102 (*%F _OS2 *)
  156. 103 PROCEDURE WriteStruct(VAR State: ProcessState; fh: INTEGER): INTEGER;
  157. 104
  158. 105 BEGIN
  159. 106 IF CoreIO._write(fh, ADR(State), SIZE(ProcessState)) # SIZE(ProcessState) THEN
  160. 107 RETURN -1;
  161. 108 END;
  162. 109 RETURN 0;
  163. 110 END WriteStruct;
  164. 111 (*%E *)
  165. 112
  166. 113 PROCEDURE compress(VAR header: SegHeader; fh: INTEGER): INTEGER;
  167. 114
  168. 115 VAR
  169. 116 SegSize: LONGINT;
  170. 117 offset: CARDINAL;
  171. 118 OutSize, BucketNo, BucketSize, NumWritize, NumWrit: CARDINAL;
  172. 119 BEGIN
  173. 120 SegSize:= LONGCARD(header.SegSize);
  174. ***** ^ undeclared identifier
  175. ***** ^ not supported yet
  176. ***** ^ not supported yet
  177. 121 IF SegSize = 0 THEN
  178. 122 SegSize:=10000H;
  179. 123 END;
  180. 124 offset:=0;
  181. 125 BucketNo:=0;
  182. 126 WHILE SegSize > 0 DO
  183. 127 IF SegSize > 1000H THEN
  184. 128 OutSize:=1000H;
  185. 129 ELSE
  186. 130 OutSize:= CARDINAL(SegSize);
  187. ***** ^ not supported yet
  188. 131 END;
  189. 132 BucketSize:= CorePMD._Pack(OutSize, [header.frame: offset]);
  190. ***** ^ not supported yet
  191. ***** ^ not supported yet
  192. ***** ^ not supported yet
  193. ***** ^ not supported yet
  194. ***** ^ not supported yet
  195. ***** ^ not supported yet
  196. 133 header.BucketSizes[BucketNo]:=BucketSize;
  197. ***** ^ not supported yet
  198. ***** ^ not supported yet
  199. ***** ^ not supported yet
  200. 134 (*%F _OS2 *)
  201. 135 IF CoreIO._dos_write(fh, FarADR(CorePMD._p), BucketSize, NumWrit) # 0 THEN
  202. 136 (*%E *)
  203. 137 (*%T _OS2 *)
  204. 138 IF Os2Write(fh, FarADR(CorePMD._p), BucketSize) # BucketSize THEN
  205. ***** ^ not supported yet
  206. ***** ^ undeclared identifier
  207. ***** ^ not supported yet
  208. ***** ^ not supported yet
  209. ***** ^ not supported yet
  210. 139 (*%E *)
  211. 140 RETURN -1;
  212. 141 END;
  213. 142 DEC(SegSize, 1000H);
  214. ***** ^ undeclared identifier
  215. ***** ^ not supported yet
  216. 143 INC(offset, 1000H);
  217. ***** ^ undeclared identifier
  218. ***** ^ not supported yet
  219. 144 INC(BucketNo);
  220. ***** ^ undeclared identifier
  221. ***** ^ not supported yet
  222. 145 END;
  223. 146 RETURN 0;
  224. 147 END compress;
  225. ***** ^ not supported yet
  226. 148
  227. 149 (*%F _OS2 *)
  228. 150 PROCEDURE WriteCore(fh: INTEGER; top, bottom: CARDINAL);
  229. 151
  230. 152 VAR
  231. 153 h: SegHeader;
  232. 154 TotalParas: CARDINAL;
  233. 155 Segment: CARDINAL;
  234. 156 SegTotal: CARDINAL;
  235. 157 SegNum: CARDINAL;
  236. 158 NumToWrite: CARDINAL;
  237. 159 BEGIN
  238. 160 Segment:=bottom;
  239. 161 SegNum:=0;
  240. 162 TotalParas:=top-bottom;
  241. 163 SegTotal:=(TotalParas+0FFFH) DIV 01000H;
  242. 164 IF CoreIO.lseek(fh, LONGCARD((SIZE(ProcessState)+SIZE(CARDINAL)+(SIZE(SegHeader)*SegTotal))-1), 0) # 0 THEN END;
  243. 165 CoreIO._write(fh, ADR(Segment), 1);
  244. 166 LOOP
  245. 167 IF TotalParas = 0 THEN EXIT END;
  246. 168 h.frame:=Segment;
  247. 169 IF TotalParas < 1000H THEN
  248. 170 NumToWrite:=TotalParas
  249. 171 ELSE
  250. 172 NumToWrite:= 1000H;
  251. 173 END;
  252. 174 h.SegSize:=NumToWrite<<4;
  253. 175 h.FilePos:=CoreIO.lseek(fh, 0, 2);
  254. 176 IF compress(h, fh) = -1 THEN
  255. 177 SegTotal:=0;
  256. 178 EXIT;
  257. 179 END;
  258. 180 IF CoreIO.lseek(fh, LONGCARD(SIZE(ProcessState)+SIZE(CARDINAL)+SIZE(SegHeader)*SegNum), 0) # 0 THEN END;
  259. 181 INC(SegNum);
  260. 182 CoreIO._write(fh, ADR(h), SIZE(SegHeader));
  261. 183 INC(Segment, NumToWrite);
  262. 184 DEC(TotalParas, NumToWrite);
  263. 185 END;
  264. 186 IF CoreIO.lseek(fh, (SIZE(ProcessState)), 0) # 0 THEN END;
  265. 187 CoreIO._write(fh, ADR(SegTotal), SIZE(CARDINAL));
  266. 188 RETURN;
  267. 189 END WriteCore;
  268. 190
  269. 191 PROCEDURE _PMDbody(VAR state: ProcessState);
  270. 192
  271. 193 TYPE
  272. 194 A2 = ARRAY [0..1] OF CHAR;
  273. 195 VAR
  274. 196 fh: INTEGER;
  275. 197 Ln: A2;
  276. 198 BEGIN
  277. 199 Ln[0]:= CHAR(0DH);
  278. 200 Ln[1]:= CHAR(0AH); (* NB *)
  279. 201 IF CoreMain._argc # 0 THEN
  280. 202 Str.Copy(state.ProgName, CoreMain._argv[0]^);
  281. 203 END;
  282. 204 fh:=CoreIO._creat_trunc("PM_DUMP.$$$", 0);
  283. 205 IF fh >= 0 THEN
  284. 206 IF CoreIO._write(2, ADR(ErrMsg), Str.Length(ErrMsg)) # 0 THEN END;
  285. 207 IF CoreIO._write(2, ADR(Ln), 2) # 0 THEN END;
  286. 208 IF WriteStruct(state, fh) = 0 THEN
  287. 209 WriteCore(fh, state.TopLim, state.PSP);
  288. 210 END;
  289. 211 IF CoreIO._close(fh) # 0 THEN END;
  290. 212 END;
  291. 213 RETURN;
  292. 214 END _PMDbody;
  293. 215 (*%E *)
  294. 216
  295. 217 (*%T _OS2 *)
  296. 218 PROCEDURE WriteCore(fh: INTEGER);
  297. 219
  298. 220 VAR
  299. 221 h: SegHeader;
  300. ***** ^ not supported yet
  301. 222 Segment, SegTotal: CARDINAL;
  302. 223
  303. 224 BEGIN
  304. 225 Segment:=0;
  305. 226 SegTotal:=GetSelectors();
  306. ***** ^ not supported yet
  307. ***** ^ not supported yet
  308. 227 IF CoreIO.lseek(fh, LONGCARD((SIZE(ProcessState)+SIZE(CARDINAL)+(SIZE(SegHeader)*SegTotal))-1), 0) # 0 THEN END;
  309. ***** ^ not supported yet
  310. ***** ^ not supported yet
  311. ***** ^ undeclared identifier
  312. ***** ^ undeclared identifier
  313. ***** ^ undeclared identifier
  314. ***** ^ undeclared identifier
  315. ***** ^ not supported yet
  316. ***** ^ undeclared identifier
  317. ***** ^ not supported yet
  318. ***** ^ not supported yet
  319. ***** ^ not supported yet
  320. 228 IF Os2Write(fh, FarADR(Segment), 1) # 0 THEN END;
  321. ***** ^ not supported yet
  322. ***** ^ undeclared identifier
  323. ***** ^ not supported yet
  324. ***** ^ not supported yet
  325. 229 LOOP
  326. 230 IF Segment = SegTotal THEN EXIT END;
  327. 231 h.frame:=selectors[Segment].selector;
  328. ***** ^ not supported yet
  329. ***** ^ not supported yet
  330. ***** ^ not supported yet
  331. ***** ^ not supported yet
  332. ***** ^ not supported yet
  333. 232 h.SegSize:=selectors[Segment].size;
  334. ***** ^ not supported yet
  335. ***** ^ not supported yet
  336. ***** ^ not supported yet
  337. ***** ^ not supported yet
  338. ***** ^ not supported yet
  339. 233 h.FilePos:=CoreIO.lseek(fh, 0, 2);
  340. ***** ^ not supported yet
  341. ***** ^ not supported yet
  342. ***** ^ not supported yet
  343. ***** ^ not supported yet
  344. ***** ^ not supported yet
  345. 234 IF compress(h, fh) = -1 THEN
  346. ***** ^ not supported yet
  347. ***** ^ not supported yet
  348. ***** ^ not supported yet
  349. 235 SegTotal:=0;
  350. 236 EXIT;
  351. 237 END;
  352. 238 IF CoreIO.lseek(fh, LONGCARD(SIZE(ProcessState)+SIZE(CARDINAL)+SIZE(SegHeader)*Segment), 0) # 0 THEN END;
  353. ***** ^ not supported yet
  354. ***** ^ not supported yet
  355. ***** ^ undeclared identifier
  356. ***** ^ undeclared identifier
  357. ***** ^ undeclared identifier
  358. ***** ^ undeclared identifier
  359. ***** ^ not supported yet
  360. ***** ^ undeclared identifier
  361. ***** ^ not supported yet
  362. ***** ^ not supported yet
  363. ***** ^ not supported yet
  364. 239 IF Os2Write(fh, FarADR(h), SIZE(SegHeader)) # 0 THEN END;
  365. ***** ^ not supported yet
  366. ***** ^ undeclared identifier
  367. ***** ^ not supported yet
  368. ***** ^ undeclared identifier
  369. ***** ^ not supported yet
  370. 240 INC(Segment);
  371. ***** ^ undeclared identifier
  372. ***** ^ not supported yet
  373. 241 END;
  374. 242 IF CoreIO.lseek(fh, (SIZE(ProcessState)), 0) # 0 THEN END;
  375. ***** ^ not supported yet
  376. ***** ^ not supported yet
  377. ***** ^ undeclared identifier
  378. ***** ^ undeclared identifier
  379. ***** ^ not supported yet
  380. 243 IF Os2Write(fh, FarADR(SegTotal), SIZE(CARDINAL)) # 0 THEN END;
  381. ***** ^ not supported yet
  382. ***** ^ undeclared identifier
  383. ***** ^ not supported yet
  384. ***** ^ undeclared identifier
  385. ***** ^ not supported yet
  386. 244 RETURN;
  387. 245 END WriteCore;
  388. ***** ^ not supported yet
  389. 246
  390. 247 PROCEDURE _PMDbody(VAR state: ProcessState);
  391. ***** ^ undeclared identifier
  392. 248
  393. 249 TYPE
  394. 250 A2 = ARRAY [0..1] OF CHAR;
  395. ***** ^ not supported yet
  396. ***** ^ not supported yet
  397. 251 VAR
  398. 252 fh: CARDINAL;
  399. 253 action: CARDINAL;
  400. 254 Ln: A2;
  401. ***** ^ not supported yet
  402. 255 BEGIN
  403. 256 Ln[0]:= CHAR(0DH);
  404. ***** ^ not supported yet
  405. ***** ^ not supported yet
  406. ***** ^ not supported yet
  407. 257 Ln[1]:= CHAR(0AH); (* NB *)
  408. ***** ^ not supported yet
  409. ***** ^ not supported yet
  410. ***** ^ not supported yet
  411. 258 IF CoreMain._argc # 0 THEN
  412. ***** ^ not supported yet
  413. ***** ^ not supported yet
  414. 259 Str.Copy(state.ProgName, CoreMain._argv[0]^);
  415. ***** ^ not supported yet
  416. ***** ^ not supported yet
  417. ***** ^ not supported yet
  418. ***** ^ not supported yet
  419. ***** ^ not supported yet
  420. ***** ^ not supported yet
  421. ***** ^ not supported yet
  422. 260 END;
  423. 261 IF Dos.Open("PM_DUMP.$$$", fh, action, LONGCARD(0),
  424. ***** ^ not supported yet
  425. ***** ^ not supported yet
  426. ***** ^ not supported yet
  427. ***** ^ undeclared identifier
  428. ***** ^ not supported yet
  429. 262 0, 012H, 012H, LONGCARD(0)) = 0 THEN
  430. ***** ^ undeclared identifier
  431. ***** ^ not supported yet
  432. 263 IF Os2Write(2, FarADR(ErrMsg), Str.Length(ErrMsg)) # 0 THEN END;
  433. ***** ^ not supported yet
  434. ***** ^ undeclared identifier
  435. ***** ^ not supported yet
  436. ***** ^ not supported yet
  437. ***** ^ not supported yet
  438. ***** ^ not supported yet
  439. 264 IF Os2Write(2, FarADR(Ln), 2) # 0 THEN END;
  440. ***** ^ not supported yet
  441. ***** ^ undeclared identifier
  442. ***** ^ not supported yet
  443. ***** ^ not supported yet
  444. 265 IF WriteStruct(state, fh) = 0 THEN
  445. ***** ^ not supported yet
  446. ***** ^ not supported yet
  447. ***** ^ not supported yet
  448. 266 WriteCore(fh);
  449. ***** ^ not supported yet
  450. ***** ^ not supported yet
  451. 267 END;
  452. 268 IF CoreIO._close(fh) # 0 THEN END;
  453. ***** ^ not supported yet
  454. ***** ^ not supported yet
  455. ***** ^ not supported yet
  456. 269 END;
  457. 270 RETURN;
  458. 271 END _PMDbody;
  459. ***** ^ not supported yet
  460. 272 (*%E *)
  461. 273
  462. 274 PROCEDURE UserFatalError(ErrorCode: CARDINAL);
  463. 275
  464. 276 BEGIN
  465. 277 CoreSig._FatalError(CoreSig._FatalErrorPos(), ErrorCode);
  466. ***** ^ not supported yet
  467. ***** ^ not supported yet
  468. ***** ^ not supported yet
  469. ***** ^ not supported yet
  470. ***** ^ not supported yet
  471. ***** ^ not supported yet
  472. 278 END UserFatalError;
  473. ***** ^ not supported yet
  474. 279
  475. 280
  476. 281 BEGIN
  477. 282 includePMD:=1;
  478. ***** ^ undeclared identifier
  479. 283 END PMD.
  480. ***** ^ not supported yet
  481. 196 errors