User Tools

Site Tools


ibm:vm370-lib:cms:dmsfre.assemble_src

DMSFRE Source

References

Source Listing

DMSFRE.ASSEMBLE.txt
  1. FRE TITLE 'DMSFRE (CMS) VM/370 - RELEASE 6' 00001000
  2. SPACE 2 00002000
  3. *. 00003000
  4. * MODULE NAME: 00010000
  5. * 00011000
  6. * DMSFRE (FREE AND FRET) 00012000
  7. * 00013000
  8. * FUNCTION: 00014000
  9. * 00015000
  10. * MANAGEMENT OF FREE STORAGE. 00016000
  11. * 00017000
  12. * ATTRIBUTES: 00018000
  13. * 00019000
  14. * NUCLEUS RESIDENT, RE-ENTRANT 00020000
  15. * 00021000
  16. * ENTRY POINTS: 00022000
  17. * 00023000
  18. * DMSFREB -- CALLED AS A RESULT OF THE 'DMSFREE' AND 'DMSFRET' 00024000
  19. * MACRO CALLS 00025000
  20. * 00026000
  21. * DMSFREES -- CALLED AS A RESULT OF THE 'SVCFREE' MACRO CALL. 00027000
  22. * 00028000
  23. * DMSFRETS -- CALLED AS A RESULT OF THE 'SVCFRET' MACRO CALL. 00029000
  24. * 00030000
  25. * DMSFREEX -- CALLED AS THE RESULT OF A BALR TO THE ADDRESS IN 00031000
  26. * THE 'NUCON' LOCATION 'AFREE' 00032000
  27. * 00033000
  28. * DMSFRETX -- CALLED AS THE RESULT OF A BALR TO THE ADDRESS IN 00034000
  29. * THE 'NUCON' LOCATION 'AFRET' 00035000
  30. * 00036000
  31. * DMSFRES -- CALLED AS THE RESULT OF EXECUTION OF THE 'DMSFRES' 00037000
  32. * MACRO 00038000
  33. * 00039000
  34. * ENTRY CONDITIONS: 00040000
  35. * 00041000
  36. * DMSFREB -- CODE203 IN NUCON CONTAINS THE HALFWORD CODE 00042000
  37. * COMPUTED BY THE DMSFREE OR DMSFRET MACROS, DEPENDING 00043000
  38. * UPON THE OPTIONS SPECIFIED IN THOSE MACROS. 00044000
  39. * 00045000
  40. * DMSFREES -- R1 POINTS TO A PLIST: 00046000
  41. * DC CL8'SVCFREE' 00047000
  42. * DC A(LENGTH) LENGTH OF REQUESTED BLOCK IN 00048000
  43. * DOUBLEWORDS 00049000
  44. * DC A(0) ADDRESS OF BLOCK, FILLED IN BY 00050000
  45. * THIS ROUTINE 00051000
  46. * 00052000
  47. * DMSFRETS -- R1 POINTS TO A PLIST: 00053000
  48. * DC CL8'SVCFRET' 00054000
  49. * DC A(LENGTH) LENGTH OF BLOCK BEING RELEASED, 00055000
  50. * IN DOUBLEWORDS 00056000
  51. * DC A(ADDRESS) ADDRESS OF BLOCK BEING RELEASED 00057000
  52. * 00058000
  53. * DMSFREEX -- R0 CONTAINS REQUESTED LENGTH 00059000
  54. * 00060000
  55. * DMSFRETX -- R1 CONTAINS THE ADDRESS OF THE BLOCK BEING 00061000
  56. * RELEASED, AND R0 ITS SIZE IN DOUBLEWORDS. 00062000
  57. * 00063000
  58. * DMSFRES -- CODE203 IN NUCON CONTAINS THE HALFWORD CODE 00064000
  59. * COMPUTED BY THE DMSFREE OR DMSFRET MACROS, DEPENDING 00065000
  60. * UPON THE PARTICULAR SERVICE ROUTINE BEING REQUESTED. 00066000
  61. * 00067000
  62. * EXIT CONDITIONS: 00068000
  63. * 00069000
  64. * NORMAL: 00070000
  65. * 00071000
  66. * FOR ALLOCATION, REGISTER 1 IS SET TO THE ADDRESS OF THE 00072000
  67. * ALLOCATED BLOCK. 00073000
  68. * REGISTER 15 IS SET TO THE RETURN CODE, ZERO. 00074000
  69. * 00075000
  70. * ERROR: 00076000
  71. * RC = 1: NO FREE STORAGE AVAILABLE. 00077000
  72. * RC = 2: USER STORAGE POINTERS CLOBBERED. 00078000
  73. * RC = 3: NUCLEUS STORAGE POINTERS CLOBBERED. 00079000
  74. * RC = 4: (FREE) REQUESTED SIZE NOT POSITIVE, OR MIN GREATER 00080000
  75. * THAN MAX FOR VARIABLE REQUEST. 00081000
  76. * RC = 5: (FRET) RETURNED SIZE NOT POSITIVE 00082000
  77. * RC = 6: (FRET) BLOCK WAS IMPROPERLY RETURNED (OVERLAPS TWO 00083000
  78. * AREAS, OR ANOTHER BLOCK, OR OUT OF RANGE) 00084000
  79. * RC = 7: (FRET) RETURNED BLOCK IS NOT DOUBLE-WORD ALIGNED. 00085000
  80. * RC = 8: (DMSFRES) ILLEGAL CODE OR ARGUMENT 00086000
  81. * 00087000
  82. * EXTERNAL REFERENCES: 00088000
  83. * 00089000
  84. * DMSNUCU -- USER NUCON PAGE 00090000
  85. * DMSNUCE -- END OF NUCON 00091000
  86. * TRANSAR -- ADDRESS OF TRANSIENT AREA 00092000
  87. * TRANSEND -- END OF TRANSIENT AREA 00093000
  88. * DMSFRT -- DMSFRE WORK AREA, DESCRIBED BY DMSFRT MACRO 00094000
  89. * 00095000
  90. * CALLS TO OTHER ROUTINES: 00096000
  91. * 00097000
  92. * DMSERR -- TO TYPE OUT ERROR MESSAGES 00098000
  93. * 00099000
  94. * TABLES/WORKAREAS: 00100000
  95. * 00101000
  96. * DMSFRT -- DMSFRE WORK AREA 00102000
  97. * 00103000
  98. * REGISTER USAGE: 00104000
  99. * 00105000
  100. * R2 = SCRATCH REGISTER 00106000
  101. * R3 = CHAIN HEADER POINTER 00107000
  102. * R4 = CURRENT CHAIN ELEMENT POINTER 00108000
  103. * R5 = PREVIOUS CHAIN ELEMENT POINTER 00109000
  104. * R6 = ADDRESS OF BLOCK BEING EXAMINED 00110000
  105. * R7 = SIZE OF BLOCK BEING EXAMINED OR SEARCHED FOR 00111000
  106. * R8 = COUNTING REGISTER 00112000
  107. * R9 = SCRATCH REGISTER 00113000
  108. * R10 = INTERNAL SUBROUTINE RETURN REGISTER 00114000
  109. * R11 = BASE REGISTER 00115000
  110. * R12 = SECOND BASE REGISTER 00116000
  111. * R13 = POINTER TO WORK AREA, DMSFRT 00117000
  112. * 00118000
  113. * OPERATION: 00119000
  114. * 00120000
  115. * DMSFREB -- ALLOCATES OR RELEASES A BLOCK OF STORAGE DEPENDING 00121000
  116. * UPON THE CODE IN NUCON LOCATION 'CODE203'. THE EXACT 00122000
  117. * METHOD OF OPERATION IS DESCRIBED IN THE PLM, IN THE 00123000
  118. * SECTION ON FREE STORAGE MANAGEMENT. 00124000
  119. * 00125000
  120. * DMSFREES -- THE SIZE IS LOADED FROM THE PLIST, AND A DMSFREE 00126000
  121. * MACRO IS EXECUTED. UPON RETURN, THE ADDRESS OF THE 00127000
  122. * ALLOCATED BLOCK IS STORED INTO THE PLIST. 00128000
  123. * 00129000
  124. * DMSFRETS -- THE SIZE AND ADDRESS OF THE BLOCK TO BE RELEASED 00130000
  125. * ARE LOADED FROM THE PLIST, AND A DMSFRET MACRO IS 00131000
  126. * EXECUTED. 00132000
  127. * 00133000
  128. * DMSFREEX -- A DMSFREE MACRO IS EXECUTED. 00134000
  129. * 00135000
  130. * DMSFRETX -- A DMSFRET MACRO IS EXECUTED. 00136000
  131. * 00137000
  132. * DMSFRES -- THE FOLLOWING SERVICE ROUTINES ARE EXECUTED: 00138000
  133. * 00139000
  134. * CKON: TURN ON FLAG WHICH CAUSES 'CHECK' TO BE EXECUTED WITH 00140000
  135. * EACH CALL TO DMSFRE. 00141000
  136. * 00142000
  137. * CKOFF: TURN OFF THIS FLAG. 00143000
  138. * 00144000
  139. * INIT1: FIRST DMSFRE INITIALIZATION ROUTINE. THIS ROUTINE 00145000
  140. * INITIALIZES FREE STORAGE IN A TEMPORARY WAY, SO THAT 00146000
  141. * THE SYSTEM DISK CAN BE LOGGED IN. 00147000
  142. * 00148000
  143. * INIT2: SECOND DMSFRE INITIALIZATION ROUTINE. THIS ROUTINE 00149000
  144. * IS CALLED AFTER THE SIZE OF VIRTUAL MEMORY IS KNOWN, 00150000
  145. * TO PREPARE STORAGE FOR THE USUAL ACTIVITY IN FREE 00151000
  146. * STORAGE ALLOCATION. ANY HIGH-CORE POINTERS ARE CLEARED, 00152000
  147. * THE 'FREETAB' FREE STORAGE TABLE IS ALLOCATED (THIS 00153000
  148. * TABLE CONTAINS ONE BYTE FOR EACH PAGE OF VIRTUAL 00154000
  149. * MEMORY, WHICH INDICATES THE USE OF THAT PAGE), ALL 00155000
  150. * STORAGE KEYS ARE INITIALIZED, AND THE CHAINS ARE 00156000
  151. * CLEANED UP. 00157000
  152. * 00158000
  153. * CHECKS: CAUSE ALL CHAINS TO BE CHECKED FOR VALIDITY. 00159000
  154. * 00160000
  155. * UREC: RECOVERY ROUTINE CALLED BY DMSABN. ALL USER FREE 00161000
  156. * STORAGE BLOCKS ARE RELEASED. 00162000
  157. * 00163000
  158. * CALOC: COMPUTATION ROUTINE CALLED BY DMSABN. THIS ROUTINE 00164000
  159. * COMPUTES THE SIZE OF ALLOCATED STORAGE. 00165000
  160. *. 00166000
  161. MACRO 00173000
  162. &NM CLEANUP &COND,&CHAIN 00174000
  163. &NM REVB &COND,*+12 00175000
  164. OI FREEFLG2,FRF2CL 00176000
  165. AIF ('&CHAIN' NE '').NOC 00177000
  166. OI FLAGS(CHR),FLCLN+FLPA 00178000
  167. MEXIT 00179000
  168. .NOC OI FREE&CHAIN+FLAGS,FLCLN+FLPA 00180000
  169. MEND 00181000
  170. SPACE 5 00182000
  171. MACRO 00183000
  172. &NM REVB &C,&J 00184000
  173. LCLC &CT 00185000
  174. AIF ('&C' EQ '').MEND 00186000
  175. AIF ('&C'(1,1) EQ 'N').N 00187000
  176. &NM BN&C &J 00188000
  177. MEXIT 00189000
  178. .N ANOP 00190000
  179. &CT SETC '&C'(2,8) 00191000
  180. &NM B&CT &J 00192000
  181. .MEND MEND 00193000
  182. EJECT 00194000
  183. MACRO 00195000
  184. &NM DGEN &LIST 00196000
  185. LCLA &I LOOP VARIABLE 00197000
  186. &NM DC 0H'0',AL2(&LIST-&NM) 00198000
  187. .LOOP ANOP 00199000
  188. DC AL2(&SYSLIST(&I+2)-&NM) 00200000
  189. &I SETA &I+1 00201000
  190. AIF (&I+2 LE N'&SYSLIST).LOOP 00202000
  191. MEND 00203000
  192. SPACE 5 00204000
  193. MACRO 00205000
  194. ROUND &TYPE,&R 00206000
  195. .* ROUND SIZE VALUE UP OR DOWN TO 4K MULTIPLE 00207000
  196. AIF ('&TYPE' NE 'UP').D 00208000
  197. LA &R,4096-1(,&R) ADD (PAGE-1) VALUE 00209000
  198. .D N &R,=X'00FFF000' TRUNCATE TO PAGE BOUNDARY 00210000
  199. MEND 00211000
  200. SPACE 3 00212000
  201. MACRO 00213000
  202. CVDB &R,&ERR= CONVERT DOUBLEWORDS TO BYTES 00214000
  203. AR &R,&R MULTIPLY BY 8 00215000
  204. AR &R,&R 00216000
  205. AR &R,&R 00217000
  206. SPACE 00218000
  207. * ERROR RETURN IF RESULT IS NEGATIVE 00219000
  208. RTN NP,&ERR,FINIS 00220000
  209. C &R,=X'00FF0000' COMPARE RESULT WITH MAXIMUM 00221000
  210. BNH *+8 SKIP IF SMALLER 00222000
  211. L &R,=X'00FF0000' LOAD MAXIMUM VALUE 00223000
  212. MEND 00224000
  213. EJECT 00225000
  214. MACRO 00226000
  215. RTN &COND,&CODE,&FINIS 00227000
  216. LCLA &J 00228000
  217. LCLB &CB,&FB 00229000
  218. &CB SETB ('&CODE' NE '0') 00230000
  219. &FB SETB ('&FINIS' NE '') 00231000
  220. &J SETA (1-&CB)*(2*&FB+8)+12*&CB COMPUTE JUMP LENGTH 00232000
  221. REVB &COND,*+&J 00233000
  222. AIF (&CB).NCB1 00234000
  223. SR R15,R15 ZERO RETURN CODE 00235000
  224. AGO .RET 00236000
  225. .NCB1 ANOP 00237000
  226. LA R15,CODE&CODE SET RETURN CODE 00238000
  227. AIF (&CODE LT 20).LC 00239000
  228. CODE&CODE EQU &CODE (DOCUMENTATION) 00240000
  229. .LC ANOP 00241000
  230. AIF (&FB).RET 00242000
  231. LTR R15,R15 SET CONDITION CODE 00243000
  232. .RET ANOP 00244000
  233. AIF (&FB).B 00245000
  234. BR RR RETURN TO CALLER 00246000
  235. MEXIT 00247000
  236. .B B RTN&FINIS 00248000
  237. MEND 00249000
  238. * REGISTER DEFINITIONS 00251000
  239. DMSFRE START 0 00252000
  240. R0 EQU 0 00253000
  241. R1 EQU 1 00254000
  242. R2 EQU 2 00255000
  243. R3 EQU 3 00256000
  244. R4 EQU 4 00257000
  245. R5 EQU 5 00258000
  246. R6 EQU 6 00259000
  247. R7 EQU 7 00260000
  248. R8 EQU 8 00261000
  249. R9 EQU 9 00262000
  250. R10 EQU 10 00263000
  251. R11 EQU 11 00264000
  252. R12 EQU 12 00265000
  253. R13 EQU 13 00266000
  254. R14 EQU 14 00267000
  255. R15 EQU 15 00268000
  256. SPACE 5 00269000
  257. XR2 EQU R2 SCRATCH -- MUST BE PRESERVED BY *00270000
  258. LOW-LEVEL SUBROUTINES 00271000
  259. CHR EQU R3 CHAIN HEADER POINTER 00272000
  260. PTR EQU R4 CURRENT CHAIN ELEMENT POINTER 00273000
  261. PPTR EQU R5 PREVIOUS CHAIN ELEMENT POINTER 00274000
  262. BLR EQU R6 ADDRESS OF BLOCK BEING EXAMINED 00275000
  263. SR EQU R7 SIZE OF BLOCK BE SEARCHED FOR 00276000
  264. CR EQU R8 COUNTING REGISTER 00277000
  265. XR EQU R9 SCRATCH REGISTER -- MUST BE ODD 00278000
  266. RR EQU R10 INTERNAL SUBROUTINE RETURN REG 00279000
  267. BR EQU R11 BASE REGISTER 00280000
  268. BR2 EQU R12 00281000
  269. TR EQU R13 POINTER TO WORK AREA 00282000
  270. SPACE 3 00283000
  271. * NOTE: CR = (XR-1): HIGH BYTE WILL BE CLOBBERED BY MVCL AND CLCL. 00284000
  272. EJECT 00285000
  273. * THE FOLLOWING NAME CHANGES WERE MADE IN GOING FROM CMS/67 TO CMS/370 00286000
  274. SPACE 00287000
  275. * OLD NAME NEW NAME 00288000
  276. * ----------- ----------- 00289000
  277. * SVCFREE DMSFREES 00290000
  278. * SVCFRET DMSFRETS 00291000
  279. * FREE DMSFREEX 00292000
  280. * FRET DMSFRETX 00293000
  281. SPACE 3 00294000
  282. USING DMSFRE,BR,BR2 00295000
  283. USING NUCON,R0 00296000
  284. USING FRDSECT,TR 00297000
  285. SPACE 3 00298000
  286. ENTRY DMSFREB,DMSFREES,DMSFRETS,DMSFREEX,DMSFRETX 00299000
  287. ENTRY DMSFRES DMSFRE SERVICE ROUTINES 00300000
  288. ENTRY FREE,FRET,SVCFREE,SVCFRET ***** REMOVE ***** 00301000
  289. EJECT 00302000
  290. * LIST OF INTERNAL RETURN CODES 00303000
  291. CODE1 EQU 1 NO STORAGE AVAILABLE -- FREE *00304000
  292. REQUEST CANNOT BE SATISFIED 00305000
  293. CODE2 EQU 2 USER STORAGE POINTERS CLOBBERED 00306000
  294. CODE3 EQU 3 NUC STORAGE POINTERS CLOBBERED 00307000
  295. CODE4 EQU 4 FREE: REQUESTED SIZE <= 0 OR *00308000
  296. MIN > MAX FOR VARIABLE REQUEST 00309000
  297. CODE5 EQU 5 FRET: RETURNED SIZE <= 0 00310000
  298. CODE6 EQU 6 FRET: BLOCK WAS IMPROPERLY *00311000
  299. RETURNED (OVERLAPS TWO AREAS OR *00312000
  300. ANOTHER BLOCK, OR OUT OF RANGE) 00313000
  301. CODE7 EQU 7 FRET: RETURNED BLOCK IS NOT *00314000
  302. DOUBLE-WORD ALIGNED 00315000
  303. CODE8 EQU 8 DMSFRES: ILLEGAL CODE OR ARG 00316000
  304. CODE9 EQU 9 ANY: UNEXPECTED INTERNAL ERROR 00317000
  305. SPACE 00318000
  306. * 20 OR HIGHER: UNEXPECTED INTERNAL ERRORS 00319000
  307. INIT1 EQU * 00321000
  308. * FIRST INITIALIZATION ROUTINE 00322000
  309. * PUT ALL STORAGE ON NUCLEUS CHAIN AND ROUTINE. 00323000
  310. * TURN ON AN 'UN-INITIALIZED' FLAG TO INDICATE THAT SECOND INIT 00324000
  311. * ROUTINE HAS NOT YET BEEN CALLED. 00325000
  312. * UNTIL SECOND ROUTINE IS CALLED, NO USER STORAGE MAY BE ALLOCATED. 00326000
  313. * IN THE BEGINNING, THERE IS ONLY ONE LOW-CORE BLOCK ON THE FREE 00327000
  314. * CHAIN. 00328000
  315. L XR,=V(DMSNUCE) ADDR OF BEGINNING OF BLOCK 00329000
  316. ST XR,FREELN+POINTER STORE POINTER IN CHAIN HEADER 00330000
  317. XC POINTER(4,XR),POINTER(XR) ZERO 'NEXT BLOCK' POINTER 00331000
  318. L XR2,=V(TRANSAR) END OF BLOCK 00332000
  319. SR XR2,XR SIZE OF BLOCK 00333000
  320. ST XR2,FREELN+MAX SET MAX FOR CHAIN 00334000
  321. ST XR2,SIZE(,XR) STORE SIZE OF BLOCK 00335000
  322. MVI FREELN+(NUM+3),1 ONE BLOCK IN CHAIN 00336000
  323. MVI FREEFLG2,FRF2NOI INITIALIZE FLAG BYTE 00337000
  324. RTN ,0,FINIS RETURN 00338000
  325. * SECOND INITIALIZATION ROUTINE 00340000
  326. * ALLOCATE BYTE TABLE, DEPENDING ON STORAGE SIZE. 00341000
  327. * SET UP BYTES TO INIDICATE ALLOCATED STORAGE. 00342000
  328. * SET CLEANUP FLAG FOR NUCLEUS LOW-CORE CHAIN 00343000
  329. * TURN OFF 'UN-INITIALIZED' FLAG SET BY FIRST INITIALIZATION ROUTINE. 00344000
  330. * BRANCH TO RETURN, TO ALLOW CLEANUP. 00345000
  331. INIT2 EQU * 00346000
  332. MVC FREELOW1,FREELOWE SAVE CURRENT VALUE OF FREELOWE 00347000
  333. L XR2,FREELOWE SAVE CURRENT VALUE OF FREELOWE 00348000
  334. SPACE 00349000
  335. * WIPE OUT ALL HIGH-CORE NUCLEUS STORAGE. 00350000
  336. XC FREEHN(12),FREEHN CLEAR HIGH CORE POINTERS 00351000
  337. L SR,VMSIZE GET CORE SIZE 00352000
  338. SRA SR,12 NUMBER BYTES NEEDED IN FREETAB 00353000
  339. LA SR,7(,SR) ROUND SR UP TO DOUBLE WORD 00354000
  340. N SR,=X'00FFFFF8' 00355000
  341. LA CHR,FREELN POINT TO LOW-CORE NUCLEUS CHAIN 00356000
  342. BAL RR,SCHFIX ALLOCATE TABLE 00357000
  343. BZ INIT2A GO IT SUCCESSFUL 00358000
  344. SPACE 00359000
  345. * OTHERWISE, ALLOCATE FROM TOP OF CORE STORAGE. 00360000
  346. LR R1,SR SAVE FREETAB SIZE 00361000
  347. ROUND UP,SR ROUND UP TO NUMBER OF PAGES 00362000
  348. BAL RR,GEXT GET EXTEND STORAGE 00363000
  349. LA CHR,FREEHN POINT TO HIGH-CORE NUCLEUS CHAIN 00364000
  350. BAL RR,SFRT PUT ON HIGH NUCLEUS CHAIN 00365000
  351. LR SR,R1 GET SIZE NEEDED 00366000
  352. BAL RR,SCHFIX GO ALLOCATE IT 00367000
  353. RTN NZ,23,FINIS ALLOCATION ERROR IS IMPOSSIBLE 00368000
  354. SPACE 00369000
  355. * WHEN CONTROL REACHES THIS POINT, THE FREETAB TABLE HAS BEEN 00370000
  356. * ALLOCATED, AND ITS ADDRESS IS IN REGISTER BLR. 00371000
  357. INIT2A EQU * 00372000
  358. ST BLR,AFREETAB SAVE ADDRESS IN NUCON 00373000
  359. NI FREEFLG2,X'FF'-FRF2NOI TURN OFF 'NOT INITIALIZED' FLAG 00374000
  360. SPACE 00375000
  361. * WE MUST NOW INITIALIZE THE ASSIGNED CODES AND STORAGE KEYS FOR ALL 00376000
  362. * OF CORE STORAGE. 00377000
  363. SPACE 00378000
  364. * FIRST, WE INITIALIZE EVERYTHING TO NUCLEUS KEY AND SYSTEM CODE. 00379000
  365. SR BLR,BLR BLOCK STARTS AT LOCATION ZERO 00380000
  366. L SR,VMSIZE GET SIZE OF VIRTUAL MEMORY 00381000
  367. LA XR,NUCKEY NUCLEUS KEY 00382000
  368. BAL RR,SETKEYI SET STORAGE KEY 00383000
  369. LA XR,SYSCODE SET SYSTEM CODE 00384000
  370. BAL RR,SETCODEI 00385000
  371. SPACE 00386000
  372. * CHANGE KEY IN USER HALF-PAGE IN NUCON 00387000
  373. L BLR,=V(DMSNUCU) POINT TO USER HALF-PAGE 00388000
  374. LA XR,USERKEY USER STORAGE KEY 00389000
  375. SSK XR,BLR SET STORAGE KEY 00390000
  376. SPACE 00391000
  377. * THE LOW-CORE FREE STORAGE AREA SHOULD HAVE NUCLEUS FREE STORAGE CODE. 00392000
  378. L BLR,=V(DMSNUCE) BEGINNING OF BLOCK 00393000
  379. ROUND DOWN,BLR ROUND DOWN TO PAGE BOUNDARY 00394000
  380. L SR,=V(TRANSAR) END OF BLOCK 00395000
  381. SLR SR,BLR SIZE OF BLOCK IN BYTES 00396000
  382. LA XR,NUCCODE SET NUCLEUS CODE 00397000
  383. BAL RR,SETCODEI 00398000
  384. SPACE 00399000
  385. * THE TRANSIENT AREA IS SET TO TRANSIENT CODE, AND USER STORAGE KEY. 00400000
  386. L BLR,=V(TRANSAR) BEGINNING OF TRANSIENT AREA 00401000
  387. L SR,=V(TRANSEND) END OF TRANSIENT AREA 00402000
  388. SLR SR,BLR SIZE OF TRANSIENT AREA 00403000
  389. LA XR,TRNCODE TRANSIENT AREA CODE 00404000
  390. BAL RR,SETCODEI SET CODE IN FREETAB TABLE 00405000
  391. LA XR,USERKEY USER STORAGE KEY 00406000
  392. BAL RR,SETKEYI SET STORAGE KEY 00407000
  393. SPACE 00408000
  394. * THE USER AREA IS SET TO USER AREA CODE, AND USER STORAGE KEY. 00409000
  395. L BLR,AUSRAREA BEGINNING OF USER AREA 00410000
  396. L SR,FREELOWE END OF USER AREA 00411000
  397. SLR SR,BLR SIZE OF USER AREA 00412000
  398. LA XR,USARCODE USER AREA CODE 00413000
  399. BAL RR,SETCODEI PUT INTO FREETAB 00414000
  400. LA XR,USERKEY USER STORAGE KEY 00415000
  401. BAL RR,SETKEYI SET STORAGE KEY 00416000
  402. SPACE 00417000
  403. * FINALLY, ANY HIGH CORE FREE AREA SHOULD HAVE NUCLEUS FREE STORAGE 00418000
  404. * CODE. ANY SUCH AREA MAY HAVE BEEN ALLOCATE ONLY FOR FREETAB. 00419000
  405. L BLR,FREELOWE BEGINNING OF HIGH CORE FREE AREA 00420000
  406. L SR,FREELOW1 END OF AREA 00421000
  407. SLR SR,BLR SIZE OF AREA 00422000
  408. BZ INIT2B NOTHING TO DO IF ZERO 00423000
  409. LA XR,NUCCODE SET NUCLEUS CODE 00424000
  410. BAL RR,SETCODEI PUT INTO FREETAB 00425000
  411. SPACE 00426000
  412. INIT2B EQU * 00427000
  413. CLEANUP ,LN CLEAN UP LOW CORE NUCLEUS CHAIN 00428000
  414. CLEANUP ,HN CLEAN UP HIGH CORE NUC CHAIN 00429000
  415. RTN ,0,FINIS GO CLEAN UP AND RETURN (RC=0) 00430000
  416. * SVCFREE ENTRY 00432000
  417. USING *,R15 00433000
  418. DMSFREES EQU * 00434000
  419. SVCFREE EQU * ***** REMOVE ***** 00435000
  420. LR R2,R1 SAVE PARAMETER LIST POINTER 00436000
  421. L R0,8(,R1) LOAD BLOCK SIZE INTO R0 00437000
  422. DMSFREE DWORDS=(0),ERR=*,TYPE=USER ALLOCATE BLOCK 00438000
  423. ST R1,12(,R2) STORE ADDRESS IN PARAM LIST 00439000
  424. BR R14 RETURN TO CALLER 00440000
  425. SPACE 5 00441000
  426. * SVCFRET ENTRY 00442000
  427. USING *,R15 00443000
  428. DMSFRETS EQU * 00444000
  429. SVCFRET EQU * ***** REMOVE ***** 00445000
  430. LR R2,R1 SAVE PARAMETER LIST POINTER 00446000
  431. LM R0,R1,8(R1) LOAD LENGTH/ADDR INTO R0/R1 00447000
  432. DMSFRET DWORDS=(0),LOC=(1),ERR=* RETURN BLOCK 00448000
  433. BR R14 00449000
  434. * DMSFREEX IS POINTED TO BY NUCON FIELD AFREE. 00451000
  435. DMSFREEX EQU * 00452000
  436. FREE EQU * ******* REMOVE ******* 00453000
  437. DMSFREE DWORDS=(0),TYPCALL=SVC,TYPE=USER 00454000
  438. BR R14 00455000
  439. SPACE 2 00456000
  440. * DMSFRETX IS POINTED TO BY AFRET 00457000
  441. DMSFRETX EQU * 00458000
  442. FRET EQU * ******* REMOVE ******* 00459000
  443. DMSFRET DWORDS=(0),LOC=(1),TYPCALL=SVC 00460000
  444. BR R14 00461000
  445. * ENTRY POINT FOR SVC 203 CALLS 00463000
  446. USING *,R15 00464000
  447. DMSFREB EQU * 00465000
  448. STM R0,R15,FREESAVE SAVE REGISTERS IN NUCON 00466000
  449. LM BR,BR2,=A(DMSFRE,DMSFRE+4096) SET BASE REGISTERS 00467000
  450. DROP R15 00468000
  451. L TR,=V(DMSFRT) POINT TO WORK AREA 00469000
  452. SPACE 00470000
  453. * NUCON LOCATION CODE203 CONTAINS THE HALFWORD CODE USED IN 00471000
  454. * CONJUNCTION WITH SVC 203. IF THIS VALUE IS NEGATIVE, THEN 00472000
  455. * THIS IS A CONDITIONAL REQUEST. THIS MEANS THAT WE WILL NOT ABEND IF 00473000
  456. * THE REQUEST CANNOT BE SATISFIED. 00474000
  457. * THE ACTUAL ROUTINE CODE IS IN THE SECOND BYTE OF THE ABSOLUTE VALUE 00475000
  458. * OF THE CODE. THIS LEAVES SEVEN FLAGS BITS IN THE FIRST BYTE OF THE 00476000
  459. * CODE, AND THESE BECOME THE FREEFLG1 FLAG BITS. 00477000
  460. LH R14,CODE203 GET SVC 203 CODE VALUE 00478000
  461. LPR R15,R14 GET ABSOLUTE VALUE 00479000
  462. SRL R15,8 GET FLAG BYTE 00480000
  463. STC R15,FREEFLG1 AND STORE IN FLAG BYTE 00481000
  464. LTR R14,R14 WAS ORIGINAL CODE NEGATIVE? 00482000
  465. BP *+8 SKIP IF NOT 00483000
  466. OI FREEFLG1,FRF1C SET 'CONDITIONAL' FLAG 00484000
  467. TM FREEFLG2,FRF2CKE TEXT 'CHECK EACH TIME' FLAG 00485000
  468. BZ *+8 SKIP IF OFF 00486000
  469. OI FREEFLG2,FRF2CKT SET 'CHECK THIS TIME' FLAG 00487000
  470. TM FREEFLG1,FRF1E WAS THIS A 'FREE' CALL? 00488000
  471. BZ FRETUN GO IF A FRET CALL 00489000
  472. SPACE 00490000
  473. * OTHERWISE, IT'S A 'FREE' CALL 00491000
  474. TM FREEFLG1,FRF1N 'NUCLEUS' STORAGE? 00492000
  475. BO NFREE GO IF SO 00493000
  476. B UFREE USER STORAGE IF NOT 00494000
  477. EJECT 00495000
  478. * ENTRY POINT FOR DMSFRES MACRO CALLS -- DMSFRE FREE STORAGE SERVICE 00496000
  479. * ROUTINES. 00497000
  480. USING *,R15 00498000
  481. DMSFRES EQU * 00499000
  482. STM R0,R15,FREESAVE SAVE REGISTERS 00500000
  483. LM BR,BR2,=A(DMSFRE,DMSFRE+4096) 00501000
  484. DROP R15 00502000
  485. L TR,=V(DMSFRT) POINT TO WORK AREA 00503000
  486. MVI FREEFLG1,FRF1C+FRF1M SET FREEFLG1 FOR EXIT LOGIC 00504000
  487. LH R14,CODE203 GET HALFWORD CODE WITH SVC 203 00505000
  488. LPR R14,R14 TAKE ABSOLUTE VALUE 00506000
  489. SRL R14,8 GET LEFTMOST BYTE 00507000
  490. AR R14,R14 MULTIPLY BY 4 00508000
  491. AR R14,R14 00509000
  492. RTN Z,8,FINIS ILLEGAL ARGUMENT IF ZERO 00510000
  493. C R14,FRESTAB COMPARE WITH MAX VALUE 00511000
  494. RTN H,8,FINIS ILLEGAL ARG IF GREATER 00512000
  495. L R14,FRESTAB(R14) GET BRANCH ADDRESS 00513000
  496. BR R14 GO TO IT 00514000
  497. SPACE 5 00515000
  498. * FRESTAB TABLE CONTAINS THE ADDRESSES OF THE VARIOUS DMSFRE 00516000
  499. * FREE STORAGE SERVICE ROUTINES. 00517000
  500. FRESTAB DC A(FRESTABE-FRESTAB) SIZE OF TABLE 00518000
  501. DC A(CKON) 1 00519000
  502. DC A(CKOFF) 2 00520000
  503. DC A(INIT1) 3 00521000
  504. DC A(INIT2) 4 00522000
  505. DC A(CHECKS) 5 00523000
  506. DC A(UREC) 6 00524000
  507. DC A(CALOC) 7 00525000
  508. FRESTABE EQU * 00526000
  509. SPACE 3 00527000
  510. LTORG 00528000
  511. * FRET, USER OR NUCLEUS 00530000
  512. FRETUN EQU * 00531000
  513. SPACE 00532000
  514. * R0 CONTAINS THE NUMBER OF DOUBLE WORDS BEING RETURNED, AND R1 00533000
  515. * CONTAINS THE ADDRESS OF THE BLOCK BEING RETURNED. 00534000
  516. SPACE 00535000
  517. * FIRST, WE CONVERT THE SIZE FROM DOUBLEWORDS TO BYTES. 00536000
  518. CVDB R0,ERR=5 CONVERT DOUBLEWORDS TO BYTES 00537000
  519. LR SR,R0 SR CONTAINS SIZE IN BYTES 00538000
  520. LA R1,0(,R1) CLEAR HIGH-ORDER BYTE P3015 00539000
  521. LR BLR,R1 BLR CONTAINS ADDRESS OF BLOCK 00540000
  522. SPACE 00541000
  523. * CALL FINDCHN SUBROUTINE TO DETERMINE WHICH OF THE FOUR CHAINS THE 00542000
  524. * BLOCK BELONGS ON. FINDCHN ALSO DOES SOME ERROR CHECKING TO SEE IF 00543000
  525. * THE BLOCK IS DOUBLE-WORD ALIGNED AND IT'S ENTIRELY WITHIN ONE AREA 00544000
  526. * (NUCLEUS OR USER, LOW- OR HIGH-CORE). 00545000
  527. BAL RR,FINDCHN FIND CHAIN FOR THE BLOCK 00546000
  528. SPACE 00547000
  529. * CONTROL RETURNS TO THIS POINT WHEN A NUCLEUS FRET RESULTS IN A WHOLE 00548000
  530. * PAGE BEING FREED. THIS POINT IS BRANCHED TO TO PUT THE PAGE(S) ON 00549000
  531. * THE USER CHAIN. 00550000
  532. FRETR EQU * 00551000
  533. BAL RR,SFRT PUT BLOCK ONTO CHAIN 00552000
  534. SPACE 00553000
  535. * SFRT RETURNS (IN BLR AND SR) THE ADDRESS AND SIZE OF THE ENTIRE BLOCK 00554000
  536. * WHICH IS ON THE CHAIN WHICH CONTAINS THE FRETTED BLOCK. (I.E., IF 00555000
  537. * THE FRETTED BLOCK WAS COMBINED WITH ANOTHER BLOCK ALREADY ON THE FREE 00556000
  538. * CHAIN, THEN SFRT RETURNS THE ADDR AND SIZE OF THE ENTIRE BLOCK OF 00557000
  539. * COMBINED STORAGE.) 00558000
  540. * WE CHECK TO SEE WHETHER THIS BLOCK CONTAINS AN EMBEDDED PAGE. 00559000
  541. CL SR,PAGESIZE BLOCKSIZE >= A PAGE? 00560000
  542. BL RETURN NOTHING TO DO IF NOT 00561000
  543. TM FREEFLG2,FRF2NOI SECOND INIT ROUTINE TAKEN PLACE? 00562000
  544. BO RETURN RETURN IF IT HAS NOT 00563000
  545. CL BLR,FREELOWE ADDRESS = ADDR OF LOW EXTEND? 00564000
  546. BNE FRET1 TO FRET1 IF NOT 00565000
  547. SPACE 00566000
  548. * OTHERWISE, WE ARE FRETTING A BLOCK AT LOW EXTEND, SO THAT WE MAY 00567000
  549. * MOVE THE LOW EXTEND POINTER UP. 00568000
  550. ROUND DOWN,SR ROUND DOWN BLOCKSIZE TO PAGE *00569000
  551. SIZE 00570000
  552. BAL RR,SETKEYN SET KEY TO 'UNASSIGNED' 00571000
  553. BAL RR,SETCODEN SET TABLE CODE TO 'UNASSIGNED' 00572000
  554. BAL RR,ALOC REMOVE BLOCK FROM CHAIN 00573000
  555. AR BLR,SR POINT TO END OF BLOCK 00574000
  556. ST BLR,FREELOWE THIS IS NEW LOW EXTEND VALUE 00575000
  557. TM FLAGS(CHR),FLHC THIS HAD BETTER BE HIGH-CORE CHN 00576000
  558. RTN NO,40,CLOB STORAGE CLOBBERED IF NOT 00577000
  559. SPACE 00578000
  560. * IF THIS IS THE NUCLEUS CHAIN, THEN THE HIGH-CORE USER CHAIN MAY 00579000
  561. * CONTAIN PAGES WHICH CAN FURTHER AFFECT FREELOWE (LOW EXTEND). FOR 00580000
  562. * THIS REASON, WE MUST SET CLEANUP FLAG FOR FREEHU IN THIS CASE. 00581000
  563. TM FLAGS(CHR),FLNU HIGH-CORE NUC CHAIN? 00582000
  564. CLEANUP O,HU CLEANUP HIGH-CORE USER CHN IF SO 00583000
  565. RTN ,0,FINIS NORMAL RETURN 00584000
  566. SPACE 2 00585000
  567. * CONTROL COMES HERE IF THE BLOCK IS A PAGE WHOSE ADDRESS IS NOT AT 00586000
  568. * LOW-EXTEND. IF THIS IS A NUCLEUS CHAIN, THEN WE MUST TRANSFER THE 00587000
  569. * PAGE(S) TO THE CORRESPONDING USER CHAIN. 00588000
  570. FRET1 EQU * 00589000
  571. TM FLAGS(CHR),FLNU NUCLEUS CHAIN? 00590000
  572. BZ FRETUP GO IF NOT 00591000
  573. TM FREEFLG2,FRF2NOI SECOND INIT TAKEN PLACE? 00592000
  574. BO FRETUP GO IF NOT 00593000
  575. LR XR,SR SIZE OF BLOCK 00594000
  576. AR XR,BLR XR -> END OF BLOCK 00595000
  577. ROUND UP,BLR BLR -> ADDRESS OF EMBEDDED PAGE 00596000
  578. ROUND DOWN,XR XR -> END OF EMBEDDED PAGE BLOCK 00597000
  579. CLR BLR,XR ARE THE TWO EQUAL? 00598000
  580. RTN NL,0,FINIS IF SO, THEN IT WASN'T REALLY *00599000
  581. A PAGE 00600000
  582. LR SR,XR SR CONTAINS END PAGE ADDRESS 00601000
  583. SR SR,BLR SR = NO BYTES IN PAGE BLOCK 00602000
  584. BAL RR,ALOC REMOVE PAGE BLOCK FROM CHAIN 00603000
  585. LA CHR,BLOCKLEN(,CHR) POINT TO CORRESPONDING USER CHN 00604000
  586. BAL RR,SETKEY SET KEY TO USER KEY 00605000
  587. BAL RR,SETCODE SET TABLE CODE TO USER CODE 00606000
  588. B FRETR RETURN TO CODE ABOVE TO PUT *00607000
  589. BLOCK ONTO USER CHAIN 00608000
  590. SPACE 2 00609000
  591. * COME HERE IF PAGE FOUND ON USER CHAIN (OR ON NUCLEUS CHAIN IF 00610000
  592. * SECOND INITIALIZATION HAS NOT YET TAKEN PLACE) 00611000
  593. FRETUP EQU * 00612000
  594. OI FLAGS(CHR),FLPA SET 'PAGE AVAILABLE' FLAG 00613000
  595. RTN ,0,FINIS AND GIVE NORMAL RETURN 00614000
  596. * UFREE -- USER FREE STORAGE REQUEST. 00616000
  597. * R0 CONTAINS THE SIZE OF THE REQUEST IN DOUBLE WORDS. IF THE 00617000
  598. * REQUEST IS VARIABLE, THEN R1 CONTAINS THE MINIMUM SIZE OF THE 00618000
  599. * REQUEST. 00619000
  600. UFREE EQU * 00620000
  601. SPACE 00621000
  602. * IF THE SECOND INITIALIZATION ROUTINE HAS NOT YET BEEN INVOKED, THEN 00622000
  603. * ALL USER STORAGE REQUESTS BECOME NUCLEUS STORAGE REQUESTS. 00623000
  604. TM FREEFLG2,FRF2NOI NO SECOND INITIALIZATION? 00624000
  605. BNO *+12 SKIP 2 INSTR'S IF THERE WAS ONE 00625000
  606. OI FREEFLG1,FRF1N SET 'NUCLEUS' REQUEST BIT 00626000
  607. B NFREE AND GO TO NUCLEUS FREE ROUTINE 00627000
  608. SPACE 00628000
  609. * WE FIRST CONVERT THE NUMBER IN R0 TO BYTES. 00629000
  610. CVDB R0,ERR=4 CONVERT DOUBLEWORDS TO BYTES 00630000
  611. LR SR,R0 SR CONTAINS SIZE OF REQUEST 00631000
  612. LA CHR,FREELU POINT TO USER LOW-CORE CHAIN 00632000
  613. SPACE 00633000
  614. * IF THE USER SPECIFIED 'AREA=HIGH', THEN LOW-CORE STORAGE MAY NOT 00634000
  615. * BE USED. 00635000
  616. TM FREEFLG1,FRF1L LOW-CORE STORAGE PERMITTED? 00636000
  617. BZ UFREEH GO IF NOT 00637000
  618. BAL RR,SCHFIX ALLOCATE FROM USER LOW-CORE CHN 00638000
  619. BZ RETURN RETURN IF ALLOCATION SUCCESSFUL 00639000
  620. SPACE 00640000
  621. * CONTROL COMES HERE IF NO ALLOCATION CAN BE MADE FROM THE LOW-CORE 00641000
  622. * CHAIN. 00642000
  623. UFREEH EQU * 00643000
  624. LA CHR,FREEHU POINT TO HIGHCORE USER CHAIN 00644000
  625. TM FREEFLG1,FRF1H IS AREA=HIGH PERMITTED? 00645000
  626. BZ UFREEV GO IF NOT 00646000
  627. BAL RR,SCHFIX TRY TO ALLOCATE FROM HIGHCORE 00647000
  628. BZ RETURN RETURN (RC=0) IF SUCCESSFUL 00648000
  629. SPACE 00649000
  630. * THERE IS NO SPACE AVAILABLE ON EITHER HIGH CORE OR LOW CORE CHAIN. 00650000
  631. * WE ATTEMPT TO EXTEND DOWN INTO USER CORE BY ADDING ONE OR MORE 00651000
  632. * PAGES FROM BELOW THE 'LOW EXTEND' AREA TO THE USER HIGH CORE CHAIN. 00652000
  633. ROUND UP,SR ROUND UP SIZE TO PAGE MULTIPLE 00653000
  634. CL SR,PAGESIZE BLOCKSIZE > 1 PAGE? 00654000
  635. CLEANUP H CLEAN UP LATER IF SO 00655000
  636. BAL RR,GEXT GET EXTEND STORAGE 00656000
  637. BNZ UFREEV GO IF NONE AVAILABLE 00657000
  638. BAL RR,SETKEY SET USER STORAGE KEY 00658000
  639. BAL RR,SETCODE SET USER-ASSIGNED TABLE CODE 00659000
  640. BAL RR,SFRT PUT NEW STORAGE ONTO CHAIN 00660000
  641. LR SR,R0 RESTORE R0 = REQUEST SIZE--BYTES 00661000
  642. B UFREEH GO ALLOCATE AGAIN FROM HIGH CHN 00662000
  643. SPACE 2 00663000
  644. * COME HERE IF THERE IS NO HOPE OF ALLOCATING THE REQUEST BLOCKSIZE. 00664000
  645. * AT THIS POINT WE MUST TRY TO SATISFY A VARIABLE REQUEST, IF HE ALLOWS 00665000
  646. * ONE. IF HE DOES, THEN REGISTER 1 CONTAINS THE MINIMUM SIZE WHICH 00666000
  647. * HE WILL ACCEPT. 00667000
  648. UFREEV EQU * 00668000
  649. TM FREEFLG1,FRF1V VARIABLE REQUEST? 00669000
  650. RTN Z,1,FINIS IF NOT, RETURN RC=1 (NO CORE) 00670000
  651. SPACE 00671000
  652. * CONVERT DOUBLE WORD SIZE IN R1 TO BYTES. 00672000
  653. CVDB R1,ERR=4 CONVERT DOUBLEWORDS TO BYTES 00673000
  654. CLR R1,R0 COMPARE WITH MAXIMUM 00674000
  655. RTN H,4,FINIS ILLEGAL ARG IF GREATER 00675000
  656. TM FREEFLG1,FRF1H AREA=HIGH ALLOWED? 00676000
  657. BZ UFREEV1 NO -- NO NEED TO GET EXTEND 00677000
  658. BAL RR,AEXT GET ALL AVAILABLE EXTEND STOR 00678000
  659. BNZ UFREEV1 GO IF NONE AVAILABLE 00679000
  660. LA CHR,FREEHU POINT TO HIGH CORE USER CHN 00680000
  661. BAL RR,SETKEY SET USER CORE KEY 00681000
  662. BAL RR,SETCODE SET USER-ASSIGNED TABLE CODE 00682000
  663. BAL RR,SFRT PUT EXTEND STORAGE ON CHAIN 00683000
  664. CLEANUP , SET CLEANUP FLAG FOR HU CHAIN 00684000
  665. LR SR,R0 RESTORE REAL MAX REQUEST @VM01316 00684100
  666. BAL RR,SCHFIX AND CHECK IT AGAIN... @VM01316 00684200
  667. BZ RETURN RETURN IF SATISFIED @VM01316 00684300
  668. SPACE 2 00685000
  669. * WE NOW SEARCH BOTH USER CHAINS FOR THE LARGEST AVAILABLE BLOCK 00686000
  670. * WHICH IS GREATER THAN THE MINIMUM. 00687000
  671. UFREEV1 EQU * 00688000
  672. LR SR,R1 GET MINIMUM SIZE 00689000
  673. SR BLR,BLR NO BLOCK ALLOCATED YET 00690000
  674. LA CHR,FREELU POINT TO LOW CORE USER CHAIN 00691000
  675. TM FREEFLG1,FRF1L AREA=LOW ALLOWED? 00692000
  676. BZ *+8 SKIP CALL IF NOT 00693000
  677. BAL RR,SCHVAR SEARCH FOR LARGEST BLOCK 00694000
  678. LR XR2,BLR SAVE RESULT FROM LOWCORE SEARCH 00695000
  679. LA CHR,FREEHU POINT TO HIGHCORE CHAIN 00696000
  680. TM FREEFLG1,FRF1H AREA=HIGH ALLOWED? 00697000
  681. BZ *+8 SKIP IF NOT 00698000
  682. BAL RR,SCHVAR SEARCH FOR LARGEST BLOCK 00699000
  683. LTR BLR,BLR WAS ANY BLOCK FOUND EITHER TIME? 00700000
  684. RTN Z,1,FINIS RETURN RC=1 IF NOT (NO CORE) 00701000
  685. CR SR,R1 BLOCKSIZE >= MIN SIZE? 00702000
  686. RTN L,35,FINIS IMPOSSIBLE IF NOT 00703000
  687. CR SR,R0 BLOCKSIZE < MAX SIZE? 00704000
  688. RTN NL,36,FINIS IMPOSSIBLE IF NOT 00705000
  689. CLR BLR,XR2 WAS BLOCK ALLOCATED IN LOWCORE? 00706000
  690. BNE *+8 SKIP IF NOT 00707000
  691. LA CHR,FREELU POINT TO LOW CORE CHAIN IF SO 00708000
  692. BAL RR,ALOC REMOVE THE BLOCK FROM THE CHAIN 00709000
  693. RTN ,0,FINIS RETURN RC=0 -- WE'RE THROUGH 00710000
  694. * NFREE -- NUCLEUS FREE STORAGE REQUEST 00712000
  695. NFREE EQU * 00713000
  696. CVDB R0,ERR=4 CONVERT DOUBLEWORDS TO BYTES 00714000
  697. LR SR,R0 SR = SIZE REQUESTED (IN BYTES) 00715000
  698. LA CHR,FREELN POINT TO LOWCORE NUCLEUS CHAIN 00716000
  699. SPACE 00717000
  700. * THE USER MAY HAVE SPECIFIED AREA=HIGH, IN WHICH CASE AREA=LOW IS NOT 00718000
  701. * PERMITTED. 00719000
  702. TM FREEFLG1,FRF1L AREA=LOW PERMITTED? 00720000
  703. BZ NFREEN GO IF NOT 00721000
  704. SPACE 00722000
  705. * IF THE ATTEMPT TO ALLOCATE THE BLOCK FROM FREELN FAILS, THEN CONTROL 00723000
  706. * WILL LATER RETURN TO THIS POINT WITH CHR POINTING TO THE NUCLEUS 00724000
  707. * HIGH CORE CHAIN. 00725000
  708. * ALSO, CONTROL WILL RETURN HERE TO RE-ATTEMPT AN ALLOCATION FROM 00726000
  709. * THE SAME CHAIN. 00727000
  710. NFREER EQU * 00728000
  711. LR SR,R0 GET REQUESTED SIZE 00729000
  712. BAL RR,SCHFIX ATTEMPT TO ALLOCATE FROM CHAIN 00730000
  713. BZ RETURN RETURN RC=0 IF ALLOCATION *00731000
  714. IS SUCCESSFUL 00732000
  715. LR XR2,CHR SAVE CHAIN PTR TEMPORARILY 00733000
  716. LA CHR,BLOCKLEN(,CHR) POINT TO CORRESPONDING USER CHN 00734000
  717. L SR,PAGESIZE SIZE OF A PAGE 00735000
  718. BAL RR,SCHPAGE ALLOCATE A PAGE FROM USER CHAIN 00736000
  719. LR CHR,XR2 RESTORE CHR 00737000
  720. BNZ NFREEN GO IF NOT SUCCESSFUL 00738000
  721. SPACE 00739000
  722. * CONTROL COMES HERE TO PUT A PAGE BLOCK ON THE CHAIN POINTED TO BY 00740000
  723. * CHR. 00741000
  724. NFREEB EQU * 00742000
  725. BAL RR,SETKEY SET NUC STORAGE KEY FOR BLKP3026 00743000
  726. CL R0,PAGESIZE IS REQUESTED SIZE > 1 PAGE? 00744000
  727. CLEANUP H SET CLEANUP FLAG IF SO 00745000
  728. BAL RR,SETCODE SET NUCLEUS-ASSIGNED CODE 00746000
  729. BAL RR,SFRT PUT BLOCK ONTO NUCLEUS CHAIN 00747000
  730. B NFREER GO RE-ATTEMPT ALLOCATION 00748000
  731. SPACE 00749000
  732. * IF THE ALLOCATION FOR THE GIVEN CHAIN FAILS, THEN CONTROL COMES 00750000
  733. * HERE. THE FIRST TIME CONTROL COMES HERE, WE POINT TO THE HIGHCORE 00751000
  734. * CHAIN AND RETURN TO NFREER TO ATTEMPT ALLOCATION FROM THAT CHAIN. 00752000
  735. * THE NEXT TIME, WE MUST TRY EXTEND STORAGE. 00753000
  736. NFREEN EQU * 00754000
  737. TM FREEFLG1,FRF1H AREA=HIGH ALLOWED? 00755000
  738. BZ NFREEV GO TRY VARIABLE IF NOT 00756000
  739. SPACE 00757000
  740. * CHECK TO SEE IF WE HAVE ALREADY LOOKED AT THE HIGHCORE NUC CHAIN. 00758000
  741. TM FLAGS(CHR),FLHC HIGHCORE CHAIN? 00759000
  742. LA CHR,FREEHN POINT TO HIGHCORE CHAIN 00760000
  743. BNO NFREER GO TRY HIGHCORE CHAIN 00761000
  744. L SR,PAGESIZE PUT PAGESIZE INTO SR 00762000
  745. BAL RR,GEXT GET EXTEND STORAGE 00763000
  746. BZ NFREEB PUT STORAGE ONTO NUC CHAIN, *00764000
  747. IF AVAILABLE 00765000
  748. SPACE 2 00766000
  749. * CONTROL COMES HERE IF THE FIXED REQUEST CANNOT BE SATISFIED. 00767000
  750. * AT THIS POINT, ALL AVAILABLE PAGES ARE ON THE NUCLEUS CHAIN. 00768000
  751. * WE TRY FOR A VARIABLE REQUEST. 00769000
  752. NFREEV EQU * 00770000
  753. TM FREEFLG1,FRF1V VARIABLE REQUEST MADE? 00771000
  754. RTN Z,1,FINIS RETURN RC=1 (NO CORE) IF NOT 00772000
  755. SPACE 00773000
  756. * MIN SIZE ALLOWED IS IN R1 IN DOUBLEWORDS. CONVERT TO BYTES. 00774000
  757. CVDB R1,ERR=4 CONVERT R1 FROM DWORDS TO BYTES 00775000
  758. CR R1,R0 COMPARE WITH MAX REQUEST 00776000
  759. RTN H,4,FINIS ILLEGAL ARG IF LARGER 00777000
  760. LR SR,R1 GET MIN SIZE ALLOWED 00778000
  761. BCTR SR,0 DECREMENT FOR SCHVAR ROUTINE 00779000
  762. SR BLR,BLR NO BLOCK FOUND YET 00780000
  763. LA CHR,FREELN POINT TO LOW-CORE NUC CHAIN 00781000
  764. TM FREEFLG1,FRF1L AREA=LOW ALLOWED? 00782000
  765. BZ *+8 SKIP CALL IF NOT 00783000
  766. SPACE 00784000
  767. * SCHVAR WILL FIND THE LARGEST BLOCK ON THE CHAIN WHOSE SIZE IS 00785000
  768. * LARGER THAN THE VALUE IN REGISTER SR. 00786000
  769. BAL RR,SCHVAR FIND LARGEST BLOCK. 00787000
  770. LR XR2,BLR SAVE RETURNED VALUE TEMPORARILY 00788000
  771. LA CHR,FREEHN POINT TO HIGHCORE BLOCK 00789000
  772. TM FREEFLG1,FRF1H AREA=HIGH ALLOWED? 00790000
  773. BZ *+8 SKIP CALL TO SCHVAR IF NOT 00791000
  774. BAL RR,SCHVAR FIND ANY LARGER BLOCK 00792000
  775. LTR BLR,BLR ANY BLOCK FOUND WHATSOEVER? 00793000
  776. RTN Z,1,FINIS RETURN RC=1 (NO CORE) IF NONE 00794000
  777. CR SR,R1 BLOCK LARGER THAN MIN SIZE? 00795000
  778. RTN L,33,FINIS IMPOSSIBLE IF NOT 00796000
  779. CR SR,R0 BLOCK SMALLER THAN MAX SIZE? 00797000
  780. RTN NL,34,FINIS 00798000
  781. CLR BLR,XR2 WAS BLOCK ALLOCATED FROM *00799000
  782. LOW CORE CHAIN? 00800000
  783. BNE *+8 SKIP IF NOT 00801000
  784. LA CHR,FREELN POINT TO LOWCORE CHAIN 00802000
  785. BAL RR,ALOC ALLOCATE BLOCK FROM CHAIN 00803000
  786. B RETURN RETURN TO CALLER 00804000
  787. AEXT EQU * 00806000
  788. SPACE 00807000
  789. * ALLOCATE ALL AVAILABLE EXTEND STORAGE. 00808000
  790. SPACE 00809000
  791. * NORMAL RETURN: 00810000
  792. * BLR -> BLOCK OF ALL REMAINING EXTEND STORAGE 00811000
  793. * SR CONTAINS THE SIZE OF THIS BLOCK. 00812000
  794. SPACE 00813000
  795. * ERROR RETURN: 00814000
  796. * RC = 1 (NO STORAGE AVAILABLE) 00815000
  797. SPACE 2 00816000
  798. * THE LOWEST POSSIBLE EXTEND AREA ADDRESS IS EQUAL TO THE MAXIMUM 00817000
  799. * OF MAINHIGH, LOCCNT, AND AUSRAREA. 00818000
  800. L BLR,MAINHIGH GET MAINHIGH 00819000
  801. CL BLR,LOCCNT COMPARE WITH LOCCNT 00820000
  802. BH *+8 SKIP IF HIGHER 00821000
  803. L BLR,LOCCNT USE LOCCNT IF HIGHER 00822000
  804. CL BLR,AUSRAREA COMPARE WITH USERAREA ADDR 00823000
  805. BH *+8 SKIP IF HIGHER 00824000
  806. L BLR,AUSRAREA USE IT IF HIGHER 00825000
  807. ROUND UP,BLR ROUND UP TO PAGE BOUNDARY 00826000
  808. CL BLR,FREELOWE LOWER THAN EXISTING LOW EXTEND? 00827000
  809. RTN NL,1 RETURN RC=1 IF NOT (NO CORE) 00828000
  810. L SR,FREELOWE GET OLD LOW EXTEND LOCATION 00829000
  811. SR SR,BLR OBTAIN SIZE OF NEW BLOCK 00830000
  812. ST BLR,FREELOWE STORE NEW LOW EXTEND VALUE 00831000
  813. RTN ,0 RETURN RC=0 TO CALLER 00832000
  814. ALOC EQU * 00834000
  815. SPACE 00835000
  816. * THIS SUBROUTINE ALLOCATES A SPECIFIC BLOCK OF A SPECIFIC SIZE FROM 00836000
  817. * A SPECIFIC CHAIN. 00837000
  818. SPACE 00838000
  819. * AT ENTRY: 00839000
  820. * BLR -> DESIRED BLOCK 00840000
  821. * SR CONTAINS SIZE OF BLOCK 00841000
  822. * CHR -> DESIRED CHAIN HEADER 00842000
  823. SPACE 00843000
  824. * NORMAL RETURN: 00844000
  825. * BLR AND SR ARE UNCHANGED 00845000
  826. * THE BLOCK IS REMOVED FROM THE SPECIFIED CHAIN 00846000
  827. SPACE 00847000
  828. * ERROR RETURN: 00848000
  829. * IF THE BLOCK CANNOT BE ALLOCATED, THEN IT IS ASSUMED THAT 00849000
  830. * THERE IS AN ERROR IN INTERNAL DMSFRE LOGIC, AND THE ROUTINE 00850000
  831. * IS TERMINATED IMMEDIATELY. 00851000
  832. SPACE 3 00852000
  833. * ALOCC ENTRY IS USED TO SAVE TIME IF CURRENT CHAIN ELEMENTS ARE 00853000
  834. * ALREADY KNOWN. 00854000
  835. SPACE 00855000
  836. * ADDITIONAL ENTRY REQUIREMENTS: 00856000
  837. * BLR, SR AND CHR AS ABOVE 00857000
  838. * PTR -> CHAIN ELEMENT CONTAINS DESIRED BLOCK 00858000
  839. * PPTR -> PREVIOUS CHAIN ELEMENT (OR CHAIN HEADER) 00859000
  840. SPACE 3 00860000
  841. * ALOC ENTRY 00861000
  842. L CR,NUM(,CHR) GET NUMBER OF CHAIN ELEMENTS 00862000
  843. LTR CR,CR ANY CHAIN ELEMENTS? 00863000
  844. RTN Z,20,FINIS IMPOSSIBLE IF NONE 00864000
  845. SPACE 00865000
  846. * SET UP TWO REGISTERS TO SAVE TIME IN LOOP 00866000
  847. LA R14,ALOCL FOR LOOP 00867000
  848. LA R15,ALOCF FOR LOOP 00868000
  849. LR PTR,CHR INITIALIZE CHAIN ELEMENT POINTER 00869000
  850. SPACE 00870000
  851. * THE FOLLOWING LOOP SEARCHES FOR THE CHAIN ELEMENT CONTAINING THE 00871000
  852. * DESIRED BLOCK. 00872000
  853. CNOP 0,8 FOR SPEED 00873000
  854. ALOCL EQU * 00874000
  855. LR PPTR,PTR MOVE UP ONE CHAIN ELEMENT 00875000
  856. L PTR,POINTER(,PTR) POINT TO NEXT CHAIN ELEMENT 00876000
  857. CLR PTR,BLR HAVE WE FOUND BLOCK YET? 00877000
  858. BCR 13,R15 (BNH ALOCF) GO IF FOUND 00878000
  859. BCTR CR,R14 (BCT CR,ALOCL) COUNT CHAIN BLOCKS 00879000
  860. RTN ,21,FINIS WE'RE OUT OF THEM -- IMPOSSIBLE 00880000
  861. SPACE 00881000
  862. * COME HERE WHEN THE BLOCK HAS BEEN FOUND. AT THIS POINT, THE 00882000
  863. * REGISTERS ARE SET UP AS FOLLOWS: 00883000
  864. * BLR -> DESIRED BLOCK 00884000
  865. * SR CONTAINS SIZE OF DESIRED BLOCK (IN BYTES) 00885000
  866. * PTR -> CHAINED FREE BLOCK CONTAINING DESIRED BLOCK 00886000
  867. * PPTR -> PREVIOUS BLOCK IN CHAIN 00887000
  868. ALOCF EQU * 00888000
  869. SPACE 00889000
  870. * ALOCC ENTRY. 00890000
  871. * THIS ENTRY POINT IS USED AS AN ALTERNATE ENTRY POINT TO ALOC WHEN 00891000
  872. * THE ABOVE REGISTERS ARE ALREADY SET. 00892000
  873. ALOCC EQU * 00893000
  874. L CR,NUM(,CHR) GET NUMBER OF ELEMENTS IN CHN 00894000
  875. CLR PTR,BLR IS DESIRED BLOCK AT BEGINNING *00895000
  876. OF THIS FREE CHAIN ENTRY? 00896000
  877. BE ALOCT GO IF IT IS 00897000
  878. SPACE 00898000
  879. * OTHERWISE, WE MUST LOP OFF PART OF THE BOTTOM OF THE CHAIN ELEMENT, 00899000
  880. * UP TO THE DESIRED BLOCK. 00900000
  881. * WE DO THAT BY SIMPLY MAKING IT A SEPARATE BLOCK ON THE FREE CHAIN. 00901000
  882. LR R14,BLR R14 -> DESIRED BLOCK 00902000
  883. SR R14,PTR R14 CONTAINS SIZE OF FREE BLOCK *00903000
  884. BELOW DESIRED BLOCK 00904000
  885. L XR,SIZE(,PTR) XR CONTAINS SIZE OF ENTIRE FREE *00905000
  886. ELEMENT CONTAINING DESIRED BLK 00906000
  887. ST R14,SIZE(,PTR) SET SIZE OF NEW LOPPED OFF BLOCK 00907000
  888. SR XR,R14 SIZE REMAINING IN UPPER BLOCK 00908000
  889. ST BLR,POINTER(,PPTR) PUT UPPER BLOCK INTO CHAIN 00909000
  890. ST PTR,POINTER(,BLR) 00910000
  891. ST XR,SIZE(,BLR) STORE SIZE OF UPPER BLOCK 00911000
  892. LA CR,1(,CR) INCREMENT FREE CHAIN ELEMENT *00912000
  893. COUNT 00913000
  894. LR PTR,BLR MAKE UPPER PART THE NEW CURRENT *00914000
  895. BLOCK 00915000
  896. SPACE 2 00916000
  897. * WHEN CONTROL REACHES THIS POINT, THE CURRENT CHAIN ELEMENT (POINTED 00917000
  898. * TO BY PTR) BEGINS AT THE ADDRESS OF THE DESIRED BLOCK. (I.E., 00918000
  899. * PTR = BLR.) 00919000
  900. ALOCT EQU * 00920000
  901. C SR,SIZE(,PTR) COMPARE DESIRED SIZE WITH SIZE *00921000
  902. OF FREE ELEMENT 00922000
  903. BE ALOCE GO IF THEY'RE EQUAL 00923000
  904. SPACE 00924000
  905. * CHECK TO SEE IF THE CHAIN ELEMENT IS LARGE ENOUGH. 00925000
  906. RTN H,22,FINIS NOT LARGE ENOUGH -- IMPOSSIBLE 00926000
  907. SPACE 00927000
  908. * OTHERWISE, THE CHAIN ELEMENT IS LARGER THAN THE DESIRED BLOCK, AND 00928000
  909. * SO A BLOCK MUST BE LOPPED OFF THE TOP OF THE CHAIN ELEMENT. WE 00929000
  910. * SIMPLY MAKE THE TOP PART OF THE BLOCK A SEPARATE CHAIN ELEMENT. 00930000
  911. LR R14,SR R14 CONTAINS SIZE OF DESIRED BLK 00931000
  912. AR R14,PTR R14 -> UPPER BLOCK 00932000
  913. L XR,SIZE(,PTR) XR = SIZE OF ENTIRE FREE ELEMENT 00933000
  914. SR XR,SR SR = SIZE OF UPPER BLOCK 00934000
  915. SPACE 00935000
  916. * WE PLACE THE UPPER BLOCK IN THE CHAIN, REMOVING THE REQUESTED BLOCK. 00936000
  917. ST R14,POINTER(,PPTR) PUT UPPER BLOCK INTO CHAIN 00937000
  918. ST XR,SIZE(,R14) STORE SIZE OF NEW UPPER BLOCK 00938000
  919. MVC POINTER(4,R14),POINTER(PTR) PUT UPPER BLOCK INTO CHAIN 00939000
  920. B ALOCX 00940000
  921. SPACE 2 00941000
  922. * CONTROL COMES HERE IF THE CHAIN ELEMENT IS EXACTLY EQUAL TO THE 00942000
  923. * DESIRED BLOCK. WE SIMPLY REMOVE THIS BLOCK FROM THE CHAIN. 00943000
  924. ALOCE EQU * 00944000
  925. MVC POINTER(4,PPTR),POINTER(PTR) REMOVE FROM CHAIN 00945000
  926. BCTR CR,0 DECREMENT ELEMENT COUNT 00946000
  927. SPACE 00947000
  928. * CONTROL COMES HERE WHEN THE DESIRED BLOCK HAS BEEN REMOVED FROM 00948000
  929. * THE CHAIN, WITH CR CONTAINING THE NEW CHAIN ELEMENT COUNT. 00949000
  930. ALOCX EQU * 00950000
  931. ST CR,NUM(,CHR) STORE ELEMENT COUNT 00951000
  932. RTN ,0 RETURN RC=0 TO CALLER 00952000
  933. FINDCHN EQU * 00954000
  934. SPACE 00955000
  935. * THIS SUBROUTINE IS CALLED BY 'FRET' TO DETERMINE ON WHICH OF THE FOUR 00956000
  936. * CHAINS THE FRETTED BLOCK BELONGS (LOW VS HIGH CORE, USER VS NUCLEUS) 00957000
  937. SPACE 00958000
  938. * INPUT: 00959000
  939. * BLR -> BLOCK 00960000
  940. * SR = SIZE OF BLOCK 00961000
  941. SPACE 00962000
  942. * RESULTS: 00963000
  943. * CHR -> CORRECT CHAIN 00964000
  944. * FREEFLG1 FLAGS ARE SET AS FOLLOWS: 00965000
  945. * FRF1N IF NUCLEUS BLOCK 00966000
  946. * FRF1L IF LOW-CORE BLOCK 00967000
  947. * FRF1H IF HIGH-CORE BLOCK 00968000
  948. SPACE 00969000
  949. * ERROR CHECKING: 00970000
  950. * IF BLOCK DOES NOT BELONG ENTIRELY TO ONE CHAIN, A DIRECT 00971000
  951. * RETURN IS MADE WITH RC=6. 00972000
  952. * IF NOT DOUBLE-WORD ALIGNED, THEN RC=7 00973000
  953. * IF SIZE <= 0 THEN RC=5 00974000
  954. SPACE 2 00975000
  955. LA XR,7 CHECK DOUBLE-WORD ALIGNMENT 00976000
  956. NR XR,BLR 'AND' OUT HIGHORDER BITS 00977000
  957. RTN NZ,7,FINIS RETURN RC=7 IF NOT DOUBLEWORD 00978000
  958. LTR SR,SR CHECK SIZE 00979000
  959. RTN NP,5,FINIS ERROR IF NOT > 0 00980000
  960. C BLR,VMSIZE BLOCK ADDRESS IN MEMORY? P3015 00981000
  961. RTN NL,6,FINIS RETURN CODE 6 IF NOT P3015 00982000
  962. LR R14,BLR R14 -> BLOCK 00983000
  963. ROUND DOWN,R14 ROUND DOWN TO PAGE BOUNDARY 00984000
  964. LR R15,SR R15 = SIZE OF BLOCK 00985000
  965. AR R15,BLR R15 -> END OF BLOCK 00986000
  966. C R15,VMSIZE END OF BLOCK WITHIN MEMORY?P3015 00987000
  967. RTN H,6,FINIS RETURN CODE 6 IF NOT P3015 00988000
  968. ROUND UP,R15 ROUND UP R15 TO PAGE BOUNDARY 00989000
  969. SR R15,R14 LENGTH OF PAGE GROUP CONTAINING *00990000
  970. BLOCK 00991000
  971. SRL R14,12 DIVIDE BY 4096: R14 = PAGE NUM 00992000
  972. SRL R15,12 DIVIDE BY 4096: R15 = NUM PAGES 00993000
  973. SPACE 00994000
  974. * FREETAB CONTAINS ONE BYTE FOR EACH PAGE OF VIRTUAL MEMORY. THAT 00995000
  975. * BYTE INDICATES WHETHER THAT PAGE IS ASSIGNED TO USER FREE/FRET 00996000
  976. * STORAGE, NUCLEUS FREE/FRET STORAGE, OR UNASSIGNED TO FREE/FRET 00997000
  977. * STORAGE. 00998000
  978. * WE CHECK TO SEE IF ALL THE TYPES CORRESPONDING TO THE BLOCK 00999000
  979. * BEING RETURNED ARE THE SAME, EITHER NUCLEUS OR USER. 01000000
  980. AL R14,AFREETAB POINT TO FIRST BYTE IN FREETAB 01001000
  981. SPACE 01002000
  982. * HOWEVER, IF THE SECOND INITIALIZATION HAS NOT YET BEEN INVOKED, THEN 01003000
  983. * FREETAB HAS NOT YET BEEN ALLOCATED. IN THIS CASE, WE SIMPLY POINT 01004000
  984. * R14 TO A DUMMY BYTE CONTAINING THE NUCLEUS CODE. 01005000
  985. TM FREEFLG2,FRF2NOI NO SECOND INITIALIZATION? 01006000
  986. BNO *+8 SKIP IF THERE WAS ONE 01007000
  987. LA R14,=AL1(NUCCODE) POINT TO DUMMY NUCCODE BYTE 01008000
  988. SPACE 01009000
  989. LA CHR,FREELN ASSUME NUCLEUS LOW-CORE CHAIN 01010000
  990. CL BLR,AUSRAREA IS IT HIGH CORE? 01011000
  991. BL *+8 SKIP IF NOT 01012000
  992. LA CHR,FREEHN ASSUME NUCLEUS HIGH-CORE CHAIN 01013000
  993. SPACE 01014000
  994. * WE NOW EXAMINE THE BYTE IN FREETAB. 01015000
  995. CLI 0(R14),MAXCODE GREATER THAN MAXIMUM CODE VALUE? 01016000
  996. RTN H,30,FINIS IMPOSSIBLE IF HIGHER 01017000
  997. CLI 0(R14),0 TEST IF ZERO 01018000
  998. RTN E,31,FINIS IMPOSSIBLE IF SO 01019000
  999. CLI 0(R14),NUCCODE IS IT NUCLEUS CODE? 01020000
  1000. BE FINDCHN1 GO IF NUCLEUS PAGE 01021000
  1001. CLI 0(R14),USERCODE IS IT USER CODE 01022000
  1002. RTN NE,6,FINIS ILLEGAL ARGS IF NOT 01023000
  1003. LA CHR,BLOCKLEN(,CHR) POINT TO CORRESPONDING USER *01024000
  1004. CHAIN IF SO 01025000
  1005. SPACE 01026000
  1006. * WHEN CONTROL REACHES THIS POINT, CHR POINTS TO THE CORRECT CHAIN, 01027000
  1007. * R14 POINTS TO THE FIRST FREETAB BYTE FOR THE GROUP OF PAGES, 01028000
  1008. * AND R15 CONTAINS THE NUMBER OF PAGES. 01029000
  1009. * WE FIRST SET THE FREEFLG1 FLAG BITS. 01030000
  1010. FINDCHN1 EQU * 01031000
  1011. TM FLAGS(CHR),FLNU NUCLEUS CHAIN? 01032000
  1012. BZ *+8 SKIP IF NOT 01033000
  1013. OI FREEFLG1,FRF1N SET NUCLEUS BIT 01034000
  1014. OI FREEFLG1,FRF1L DEFAULT LOW-CORE BIT 01035000
  1015. TM FLAGS(CHR),FLHC HIGH-CORE CHAIN? 01036000
  1016. BZ *+8 SKIP IF NOT 01037000
  1017. XI FREEFLG1,FRF1L+FRF1H SWITCH TO HIGHCORE BIT 01038000
  1018. SPACE 01039000
  1019. * WE NOW CHECK TO SEE IF ALL THE BYTES IN THE FREETAB TABLE FOR THIS 01040000
  1020. * PAGE GROUP ARE EQUAL. 01041000
  1021. SPACE 01042000
  1022. * HOWEVER, IF THE SECOND INITIALIZATION ROUTINE HAS NOT YET BEEN 01043000
  1023. * INVOKED, THEN THERE IS NOTHING MORE TO DO. 01044000
  1024. TM FREEFLG2,FRF2NOI NO SECOND INITIALIZATION? 01045000
  1025. RTN O,0 NORMAL RETURN IF NONE 01046000
  1026. SPACE 01047000
  1027. IC XR,0(R14) GET FIRST BYTE FROM TABLE 01048000
  1028. SLL XR,24 PUT INTO HIGH BYTE OF REG 01049000
  1029. SPACE 01050000
  1030. * NOTE: XR IS AN ODD-NUMBERED REGISTER WHICH CONTAINS A ZERO ADDRESS 01051000
  1031. * AND A PAD CHARARACTER EQUAL TO THE CHARACTER IN THE TABLE. THE 01052000
  1032. * CONTENTS OF REGISTER (XR-1) ARE IRRELEVANT. 01053000
  1033. CLCL R14,XR-1 CHECK TO SEE IF BYTES ARE ALL *01054000
  1034. THE SAME 01055000
  1035. USING FRDSECT,TR 01056000
  1036. RTN E,0 RETURN RC=0 IF THEY ARE 01057000
  1037. RTN ,6,FINIS OTHERWISE, ILLEGAL ARG 01058000
  1038. GEXT EQU * 01060000
  1039. SPACE 01061000
  1040. * ALLOCATE 'EXTEND' PAGE OF PAGES. 01062000
  1041. SPACE 01063000
  1042. * AT ENTRY: 01064000
  1043. * SR = NUMBER OF BYTES REQUIRED (MUST BE PAGE MULTIPLE) 01065000
  1044. SPACE 01066000
  1045. * NORMAL RETURN: 01067000
  1046. * BLR -> ALLOCATED BLOCK OR EXTEND STORAGE 01068000
  1047. * SR IS UNCHANGED (= SIZE OF BLOCK) 01069000
  1048. SPACE 01070000
  1049. * ERROR RETURN: 01071000
  1050. * RC=1 IF REQUEST STORAGE IS NOT AVAILABLE 01072000
  1051. SPACE 2 01073000
  1052. L BLR,FREELOWE LOAD LOW EXTEND POINTER 01074000
  1053. SR BLR,SR TENTATIVE NEW LOW EXTEND VALUE 01075000
  1054. SPACE 01076000
  1055. * THE NEW LOW EXTEND MUST EXCEED MAINHIGH, LOCCNT, AND AUSRAREA. 01077000
  1056. C BLR,MAINHIGH COMPARE WITH END OF GETMAIN AREA 01078000
  1057. RTN L,1 ERROR RETURN IF LOWER 01079000
  1058. TM BATFLAGS,BATLOAD IS BATCH BEING LOADED ? @VA05381 01079330
  1059. BO CKUAREA YES, DON'T CHECK AGAINST LOCCNT @VA05381 01079660
  1060. CL BLR,LOCCNT COMPARE WITH LOADER LOCATION *01080000
  1061. COUNTER 01081000
  1062. RTN L,1 ERROR RETURN IF LOWER 01082000
  1063. CKUAREA EQU * @VA05381 01082500
  1064. CL BLR,AUSRAREA COMPARE WITH USER PROGRAM ADDR 01083000
  1065. RTN L,1 ERROR RETURN IF LOWER 01084000
  1066. ST BLR,FREELOWE STORE NEW LOW EXTEND VALUE 01085000
  1067. RTN ,0 RETURN RC=0 01086000
  1068. SCHFIX EQU * 01088000
  1069. SPACE 01089000
  1070. * SEARCH THE SPECIFIED FREE CHAIN FOR A BLOCK OF THE DESIRED SIZE, AND 01090000
  1071. * ALLOCATE IT AND RETURN ITS ADDRESS. 01091000
  1072. SPACE 01092000
  1073. * AT ENTRY: 01093000
  1074. * SR = SIZE OF DESIRED BLOCK 01094000
  1075. * CHR -> CHAIN HEADER BLOCK OF CHAIN TO BE SEARCHED 01095000
  1076. SPACE 01096000
  1077. * NORMAL RETURN: 01097000
  1078. * SEARCHED CHAIN IS ADJUSTED 01098000
  1079. * BLR -> ALLOCATED BLOCK 01099000
  1080. SPACE 01100000
  1081. * ERROR RETURN: 01101000
  1082. * RC = 1 (NO STORAGE AVAILABLE) 01102000
  1083. * CHAIN IS LEFT UNCHANGED 01103000
  1084. SPACE 2 01104000
  1085. L CR,NUM(,CHR) GET NUM OF ELEMENTS ON CHAIN 01105000
  1086. LTR CR,CR ANY ELEMENTS? 01106000
  1087. RTN Z,1 RETURN RC=1 IF NOTHING TO DO 01107000
  1088. CL SR,MAX(,CHR) SR EXCEED MAX BLOCK ON CHAIN? 01108000
  1089. RTN H,1 IF YES, NO POINT IN EVEN *01109000
  1090. CHECKING -- RETURN RC=1 01110000
  1091. LR PTR,CHR INITIALIZER CHAIN ELEMENT PTR 01111000
  1092. LA R14,SCHFIXL FOR SPEED IN LOOP 01112000
  1093. LA R15,SCHFIXF FOR SPEED IN LOOP 01113000
  1094. SPACE 01114000
  1095. * THE FOLLOWING LOOP SEARCHES FOR THE FIRST FREE ELEMENT IN THE 01115000
  1096. * CHAIN WHICH IS LARGE ENOUGH TO ACCOMODATE THE REQUEST. 01116000
  1097. CNOP 0,8 FOR SPEED 01117000
  1098. SCHFIXL EQU * 01118000
  1099. LR PPTR,PTR ADVANCE ONE CHAIN ELEMENT 01119000
  1100. L PTR,POINTER(,PTR) 01120000
  1101. CL SR,SIZE(,PTR) CHAIN ELEMENT BIG ENOUGH? 01121000
  1102. BCR 13,R15 (BNH SCHFIXF) GO IF YES 01122000
  1103. BCTR CR,R14 (BCT CR,SCHFIXL) COUNT BLOCKS AND LOOP BACK 01123000
  1104. SPACE 01124000
  1105. * COME HERE IF WE'VE RUN OUT OF BLOCKS 01125000
  1106. * FIRST, RESET MAX TO ONE LESS THAN CURRENT SEARCH VALUE. 01126000
  1107. LR XR,SR XR = BLOCK BEING SEARCHED FOR 01127000
  1108. BCTR XR,0 DECREMENT BY ONE 01128000
  1109. ST XR,MAX(,CHR) STORE AS NEW MAX 01129000
  1110. L PTR,POINTER(,PTR) LOAD NEXT POINTER 01130000
  1111. LTR PTR,PTR IT HAD BETTER BE ZERO 01131000
  1112. RTN Z,1 IF SO, RETURN RC=1 (NO CORE) 01132000
  1113. RTN ,55,CLOB CHAIN CLOBBERED IF NOT 01133000
  1114. SPACE 2 01134000
  1115. * COME HERE IF A CHAIN ELEMENT IS BIG ENOUGH. AT THIS POINT, THE 01135000
  1116. * FOLLOWING REGISTERS ARE SET: 01136000
  1117. * PTR -> CURRENT FREE CHAIN ELEMENT 01137000
  1118. * PPTR -> PREVIOUS FREE CHAIN ELEMENT (OR CHAIN HEADER) 01138000
  1119. * CHR -> CHAIN HEADER 01139000
  1120. SPACE 01140000
  1121. * THE CONDITION IS STILL SET FROM THE LASE 'CL SR,SIZE(,PTR)' 01141000
  1122. * INSTRUCTION. 01142000
  1123. SCHFIXF EQU * 01143000
  1124. BE SCHFIXE GO IF CHAIN ELT IS EXACTLY RIGHT 01144000
  1125. SPACE 01145000
  1126. * OTHERWISE, WE MUST LOP OFF THE BOTTOM PART OF THE BLOCK AND ALLOCATE 01146000
  1127. * THE TOP PART OF THE REQUIRED SIZE. 01147000
  1128. L XR,SIZE(,PTR) GET SIZE OF CHAIN ELEMENT 01148000
  1129. SR XR,SR COMPUTE SIZE REMAINING IN *01149000
  1130. BOTTOM PART 01150000
  1131. ST XR,SIZE(,PTR) STORE NEW BLOCK SIZE 01151000
  1132. LA BLR,0(XR,PTR) ADDRESS OF ALLOCATED BLOCK 01152000
  1133. RTN ,0 RETURN RC=0 01153000
  1134. SPACE 2 01154000
  1135. * COME HERE IF THE CHAIN ELEMENT IS EXACTLY THE SIZE REQUESTED. 01155000
  1136. SCHFIXE EQU * 01156000
  1137. MVC 0(4,PPTR),0(PTR) REMOVE CHAIN ELEMENT FROM CHAIN 01157000
  1138. L CR,NUM(,CHR) DECREMENT ELEMENT COUNT 01158000
  1139. BCTR CR,0 01159000
  1140. ST CR,NUM(,CHR) 01160000
  1141. LR BLR,PTR POINT TO ALLOCATED BLOCK 01161000
  1142. RTN ,0 AND RETURN 01162000
  1143. SCHPAGE EQU * 01164000
  1144. SPACE 01165000
  1145. * SEARCH SPECIFIED CHAIN FOR FULL PAGE(S). WILL RETURN BLOCK ONLY 01166000
  1146. * PAGE-ALIGNED AND ONLY A MULTIPLE OF A PAGE. 01167000
  1147. SPACE 01168000
  1148. * INPUT: 01169000
  1149. * CHR -> CHAIN 01170000
  1150. * SR = SIZE OF BLOCK (PAGE MULTIPLE) 01171000
  1151. SPACE 01172000
  1152. * NORMAL RETURN 01173000
  1153. * BLR -> BLOCK, REMOVED FROM CHAIN 01174000
  1154. SPACE 01175000
  1155. * ERROR RETURN 01176000
  1156. * BLR = GARBAGE 01177000
  1157. * RC = 1 (NO CORE AVAILABLE) 01178000
  1158. SPACE 01179000
  1159. NI FREEFLG2,X'FF'-FRF2SVP TURN OFF SCHVPGE FLAG 01180000
  1160. B SCHPC 01181000
  1161. EJECT 01182000
  1162. SCHVPGE EQU * 01183000
  1163. SPACE 01184000
  1164. * SCHVPGE IS LIKE SCHPAGE, EXCEPT THAT IT IS USED FOR VARIABLE 01185000
  1165. * REQUESTS, AND RETURNS AN ENTIRE BLOCK OF PAGES WHICH IS GREATER THAN 01186000
  1166. * OR EQUAL TO THE DESIRED MINIMUM SIZE. 01187000
  1167. SPACE 01188000
  1168. * AT ENTRY: 01189000
  1169. * SR = MINIMUM SIZE IN BYTES (MULTIPLE OF PAGE SIZE) 01190000
  1170. SPACE 01191000
  1171. * NORMAL RETURN: 01192000
  1172. * SR = ACTUAL SIZE ALLOCATED 01193000
  1173. * BLR -> ALLOCATED BLOCK 01194000
  1174. SPACE 01195000
  1175. * ERROR RETURN 01196000
  1176. * RC = 1 (NO STORAGE AVAILABLE) 01197000
  1177. SPACE 2 01198000
  1178. OI FREEFLG2,FRF2SVP SET SCHVPGE FLAG 01199000
  1179. EJECT 01200000
  1180. * COMMON BRANCH POINT FOR SCHPAGE AND SCHVPGE. THE FLAG FRF2SVP 01201000
  1181. * IN FREEFLG2 IS SET IF AND ONLY IF SCHVPGE WAS THE ENTRY POINT. 01202000
  1182. SCHPC EQU * 01203000
  1183. TM FLAGS(CHR),FLPA PAGE AVAILABLE ON CHAIN? 01204000
  1184. RTN Z,1 JUST RETURN (RC=1) IF NOT 01205000
  1185. L CR,NUM(,CHR) GET NUMBER OF BLOCKS 01206000
  1186. LTR CR,CR ANY IN THE CHAIN? 01207000
  1187. RTN Z,1 THEN THERE'S NO USE LOOKING 01208000
  1188. CL SR,MAX(,CHR) DOES ANY BLOCK OF MIN SIZE *01209000
  1189. EXIST IN THE CHAIN? 01210000
  1190. RTN H,1 RETURN RC=1 IF NOT 01211000
  1191. LA R14,SCHPAGL TO SPEED UP LOOP 01212000
  1192. LA R15,SCHPAGF TO SPEED UP LOOP 01213000
  1193. LR PTR,CHR INITIALIZE CHAIN ELEMENT PTR 01214000
  1194. SPACE 01215000
  1195. * WE USE THE HIGH BYTE OF REG RR AS A FLAG BYTE TO INDICATE THAT NO 01216000
  1196. * BLOCK OF THE REQUIRED MINIMUM SIZE WAS FOUND. (OF COURSE, JUST 01217000
  1197. * FINDING A LARGE ENOUGH BLOCK IS NOT ENOUGH. IT MAY BECOME TOO 01218000
  1198. * SMALL WHEN WE ALIGN IT TO PAGE BOUNDARIES.) 01219000
  1199. O RR,=AL1(X'FF',0,0,0) NO BLOCK FOUND YET 01220000
  1200. SPACE 01221000
  1201. * THE FOLLOWING LOOP SEARCHES FOR A BLOCK OF THE REQUIRED MIN SIZE. 01222000
  1202. CNOP 0,8 FOR SPEED 01223000
  1203. SCHPAGL EQU * 01224000
  1204. LR PPTR,PTR MOVE UP ONE CHAIN ELEMENT 01225000
  1205. L PTR,POINTER(,PTR) 01226000
  1206. CL SR,SIZE(,PTR) CHAIN ELEMENT LARGE ENOUGH? 01227000
  1207. BCR 13,R15 (BNH SCHPAGF) GO IF BIG ENOUGH 01228000
  1208. SPACE 01229000
  1209. * A RETURN IS MADE TO SCHPAGLR IF THE BLOCK WHICH IS BIG ENOUGH NOW 01230000
  1210. * TURNS OUT TO BE TOO SMALL WHEN IT IS ROUNDED TO PAGE BOUNDARIES. 01231000
  1211. SCHPAGLR EQU * 01232000
  1212. BCTR CR,R14 (BCT CR,SCHPAGL) COUNT FREE ELEMENTS 01233000
  1213. SPACE 01234000
  1214. * COME HERE WHEN WE'VE RUN OUT OF BLOCKS. 01235000
  1215. LR XR,SR COPY REQUESTED SIZE 01236000
  1216. BCTR XR,0 DECREMENT 01237000
  1217. LTR RR,RR WAS ANY BLOCK FOUND? 01238000
  1218. BNM SCHPAGL1 SKIP RESETTING CODE IF SO 01239000
  1219. ST XR,MAX(,CHR) STORE NEW MAX FIELD 01240000
  1220. CL SR,PAGESIZE SIZE REQUESTED > 1 PAGE? 01241000
  1221. BH *+8 SKIP IF YES 01242000
  1222. NI FLAGS(CHR),X'FF'-FLPA TURN OFF 'PAGE AVAILABLE' FLAG 01243000
  1223. SPACE 01244000
  1224. SCHPAGL1 EQU * 01245000
  1225. L PTR,POINTER(,PTR) LOAD NEXT POINTER 01246000
  1226. LTR PTR,PTR ANYTHING THERE? 01247000
  1227. RTN Z,1 RETURN RC=1 IF NOT 01248000
  1228. RTN ,56,CLOB IMPOSSIBLE CONDITION IF SO 01249000
  1229. SPACE 01250000
  1230. * CONTROL COMES HERE WHEN A BIG ENOUGH BLOCK IS FOUND. WE MUST PAGE 01251000
  1231. * ALIGN THE BLOCK AND SEE IF IT'S STILL BIG ENOUGH. 01252000
  1232. SCHPAGF EQU * 01253000
  1233. LA RR,0(,RR) INDICATE THAT SOME BLOCK WAS FND 01254000
  1234. LR BLR,PTR POINTER TO FREE ELEMENT 01255000
  1235. ROUND UP,BLR ROUND UP TO PAGE BOUNDARY 01256000
  1236. LR XR,PTR POINTER TO FREE ELEMENT 01257000
  1237. A XR,SIZE(,PTR) POINTER TO END OF FREE ELEMENT 01258000
  1238. SR XR,BLR NUMBER OF BYTES BEYOND PAGE *01259000
  1239. BOUNDARY 01260000
  1240. CLR SR,XR STILL BIG ENOUGH? 01261000
  1241. BH SCHPAGLR RE-ENTER SEARCH LOOP IF NOT 01262000
  1242. SPACE 01263000
  1243. * CONTROL COMES HERE IF THE BLOCK AT PTR IS INDEED BIG ENOUGH. 01264000
  1244. * WE NOW MAKE AN ADJUSTMENT, FOR SCHPGE ONLY, IN CASE THERE ARE 01265000
  1245. * MORE PAGES AVAILABLE THAN WE NEED. IN THIS CASE, WE GRAB ONLY THE 01266000
  1246. * HIGHEST PAGES. 01267000
  1247. SPACE 01268000
  1248. * AT THIS POINT, REGISTERS ARE AS FOLLOWS: 01269000
  1249. * PTR -> FREE BLOCK 01270000
  1250. * BLR = PTR ROUNDED UP TO PAGE BOUNDARY 01271000
  1251. * XR = SIZE OF FREE ELEMENT FROM BLR ON UP 01272000
  1252. SPACE 01273000
  1253. * IN ADDITION, THE CONDITION CODE IS STILL SET FROM 'CLR SR,XR'. 01274000
  1254. BE SCHPAGC GO IF REST OF BLOCK = SIZE *01275000
  1255. DESIRED -- JUST TAKE IT. 01276000
  1256. SPACE 01277000
  1257. * OTHERWISE, IT'S TOO BIG. 01278000
  1258. LR R14,XR SIZE OF FREE ELT FROM BLR UP 01279000
  1259. ROUND DOWN,R14 ROUND DOWN TO PAGE BOUNDARY 01280000
  1260. TM FREEFLG2,FRF2SVP SCHVPGE ENTRY? 01281000
  1261. BZ *+10 SKIP TWO IF SCHPAGE 01282000
  1262. LR SR,R14 SR = ENTIRE PAGE BLOCK SIZE 01283000
  1263. B SCHPAGC GO ALLOCATE IT 01284000
  1264. SPACE 01285000
  1265. * MAYBE JUST THE PAGE BLOCK IS THE RIGHT SIZE. 01286000
  1266. CLR R14,SR 01287000
  1267. BE SCHPAGC GO IF IT'S JUST THE RIGHT SIZE 01288000
  1268. SPACE 01289000
  1269. * WE MUST MOVE THE POINTERS UP SO THAT WE ALLOCATE THE HIGHEST PAGES. 01290000
  1270. SR R14,SR R14=NUMBER OF PAGES TO ADVANCE 01291000
  1271. SR XR,R14 UPDATE XR 01292000
  1272. AR BLR,R14 UPDATE BLR 01293000
  1273. SPACE 01294000
  1274. * AT THIS POINT, WE HAVE: 01295000
  1275. * BLR -> BLOCK DESIRED 01296000
  1276. * SR = SIZE DESIRED 01297000
  1277. * PTR -> FREE CHAIN ELEMENT WHICH MUST BE SUB-DIVIDED 01298000
  1278. * PPTR -> PREVIOUS FREE CHAIN ELEMENT 01299000
  1279. SPACE 01300000
  1280. * WE NOW ENTER THE ALOC SUBROUTINE TO ALLOCATE THE THE SUB-BLOCK. 01301000
  1281. SCHPAGC EQU * 01302000
  1282. B ALOCC 01303000
  1283. SCHVAR EQU * 01305000
  1284. SPACE 01306000
  1285. * FOR VARIABLE SEARCHES, SEARCH SPECIFIED CHAIN FOR LARGEST BLOCK 01307000
  1286. * EXCEEDING A GIVEN MINIMUM SIZE. THIS ROUTINE DOES NOT REMOVE THE 01308000
  1287. * BLOCK FROM THE CHAIN. 01309000
  1288. SPACE 01310000
  1289. * AT ENTRY: 01311000
  1290. * SR = MINIMUM SIZE WHICH MUST BE EXCEEDED 01312000
  1291. * CHR -> CHAIN HEADER FOR DESIRED CHAIN 01313000
  1292. SPACE 01314000
  1293. * NORMAL RETURN: 01315000
  1294. * RC = 0 01316000
  1295. * SR = SIZE OF BLOCK FOUND 01317000
  1296. * BLR = ADDRESS OF BLOCK FOUND 01318000
  1297. SPACE 01319000
  1298. * ERROR RETURN (NO BLOCK OF REQUIRED MINIMUM SIZE) 01320000
  1299. * RC = 1 (NO STORAGE AVAILABLE) 01321000
  1300. * SR, BLR ARE UNCHANGED 01322000
  1301. SPACE 2 01323000
  1302. L CR,NUM(,CHR) GET FREE ELEMENT COUNT 01324000
  1303. LTR CR,CR ANY ELEMENTS? 01325000
  1304. RTN Z,1 RETURN RC=1 TO CALLER IF NOT 01326000
  1305. CL SR,MAX(,CHR) DESIRED SIZE >= CHAIN MAX? 01327000
  1306. RTN NL,1 RETURN RC=1 TO CALLER IF NOT 01328000
  1307. LR PTR,CHR INITIALIZE PTR 01329000
  1308. SR XR,XR INDICATE NO BLOCK WAS FOUND 01330000
  1309. LA R15,SCHVARF FOR SPEED IN LOOP 01331000
  1310. LA R14,SCHVARL FOR SPEED IN LOOP 01332000
  1311. SPACE 01333000
  1312. * THIS LOOP SEARCHES THE CHAIN FOR A LARGE ENOUGH BLOCK. 01334000
  1313. SCHVARL EQU * 01335000
  1314. LR PPTR,PTR MOVE POINTERS UP ONE ELEMENT 01336000
  1315. L PTR,POINTER(,PTR) 01337000
  1316. CL SR,SIZE(,PTR) BLOCK LARGER THAN MIN SIZE? 01338000
  1317. BCR 11,R15 (BNL SCHVARF) SKIP IF TOO SMALL 01339000
  1318. BCTR XR,0 INDICATE THAT A BLOCK WAS FOUND 01340000
  1319. LR BLR,PTR POINT TO THE BLOCK 01341000
  1320. L SR,SIZE(,BLR) SET NEW MINIMUM SIZE 01342000
  1321. SPACE 01343000
  1322. SCHVARF EQU * 01344000
  1323. BCTR CR,R14 (BCT CR,SCHVARL) COUNT BLOCKS 01345000
  1324. SPACE 01346000
  1325. * COME HERE WHEN THE ENTIRE CHAIN HAS BEEN SEARCHED. 01347000
  1326. ST SR,MAX(,CHR) SET CORRECT MAXIMUM 01348000
  1327. L PTR,POINTER(,PTR) LOOK AT NEXT POINTER 01349000
  1328. LTR PTR,PTR ANYTHING THERE? 01350000
  1329. RTN NZ,57,CLOB CHAIN CLOBBERED IF SO 01351000
  1330. LTR XR,XR ANY BLOCK FOUND? 01352000
  1331. RTN M,0 YES, IF XR < 0 01353000
  1332. RTN ,1 IF NOT, RETURN RC=1 (NO CORE) 01354000
  1333. SETCODE EQU * 01356000
  1334. SPACE 01357000
  1335. * SET CODES IN FREETAB TO INDICATED VALUE. 01358000
  1336. SPACE 01359000
  1337. * AT ENTRY: 01360000
  1338. * BLR -> PAGE BLOCK WHOSE FREETAB BYTES ARE TO BE CHANGED 01361000
  1339. * SR = SIZE OF PAGE BLOCK (PAGE MULTIPLE) 01362000
  1340. * CHR -> CHAIN HEADER, WHOSE 'TCODE' FIELD INDICATES VALUE TO 01363000
  1341. * WHICH THE FREETAB BYTES FOR THIS BLOCK ARE TO BE SET. 01364000
  1342. SPACE 01365000
  1343. * NOTE: NORMAL RETURN IS ALWAYS MADE 01366000
  1344. SPACE 2 01367000
  1345. IC XR,TCODE(,CHR) GET NEW CODE VALUE 01368000
  1346. B SETCODC GO TO COMMON CODE 01369000
  1347. SPACE 5 01370000
  1348. SETCODEN EQU * 01371000
  1349. SPACE 01372000
  1350. * SAME AS SETCODE, BUT CODE IS SET TO 'UNASSIGNED'. 01373000
  1351. LA XR,USARCODE USE USER AREA CODE 01374000
  1352. B SETCODC BRANCH TO COMMON CODE 01375000
  1353. SPACE 3 01376000
  1354. * THE FOLLOWING IS USED BY THE INITIALIZATION ROUTINES -- THE PROPER 01377000
  1355. * CODE IS ALREADY IN XR. 01378000
  1356. SETCODEI EQU * 01379000
  1357. SPACE 5 01380000
  1358. * COMMON BRANCH POINT FOR SETCODE AND SETCODEN. 01381000
  1359. SETCODC EQU * 01382000
  1360. SPACE 01383000
  1361. * IF THE SECOND INITIALIZATION ROUTINE HAS NOT YET BEEN INVOKED, THEN 01384000
  1362. * THERE IS NOTHING TO DO. 01385000
  1363. TM FREEFLG2,FRF2NOI NO SECOND INITIALIZATION? 01386000
  1364. RTN O,0 NORMAL RETURN IF NONE 01387000
  1365. SPACE 01388000
  1366. LR R14,BLR R14 = PAGE BLOCK ADDRESS 01389000
  1367. SRL R14,12 DIVIDE BY 4096 TO GET PAGE NUMB 01390000
  1368. AL R14,AFREETAB POINT TO FIRST BYTE IN FREETAB *01391000
  1369. TO BE MODIFIED 01392000
  1370. LR R15,SR SIZE OF PAGE BLOCK IN BYTES 01393000
  1371. SRL R15,12 DIVIDE BY 4096 TO NUMBER PAGES 01394000
  1372. SLL XR,24 PUT VALUE INTO HIGH ORDER BYTE 01395000
  1373. SPACE 01396000
  1374. * NOTE: XR IS AN ODD-NUMBERED REGISTER WHICH CONTAINS A ZERO ADDRESS 01397000
  1375. * FIELD AND A PAD CHARACTER (IN THE HIGH ORDER BYTE) EQUAL TO THE 01398000
  1376. * CHARACTER TO BE PLACED IN THE TABLE. 01399000
  1377. * THE CONTENTS OF REGISTER (XR-1) ARE IRRELEVANT. 01400000
  1378. MVCL R14,XR-1 FILL IN CHARACTER 01401000
  1379. USING FRDSECT,TR 01402000
  1380. RTN ,0 NORMAL RETURN 01403000
  1381. SETKEY EQU * 01405000
  1382. SPACE 01406000
  1383. * SET STORAGE KEYS 01407000
  1384. SPACE 01408000
  1385. * AT ENTRY: 01409000
  1386. * BLR -> BLOCK OF STORAGE FOR WHICH STORAGE KEYS ARE TO BE 01410000
  1387. * CHANGED (PAGE-ALIGNED) 01411000
  1388. * SR = SIZE OF BLOCK (MULTIPLE OF PAGE SIZE) 01412000
  1389. * CHR -> CHAIN HEADER, WHOSE 'SKEY' FIELD CONTAINS THE NEW 01413000
  1390. * STORAGE KEY VALUE FOR THESE PAGES 01414000
  1391. SPACE 01415000
  1392. * NOTE: NORMAL RETURN IS ALWAYS MADE 01416000
  1393. SPACE 2 01417000
  1394. IC XR,SKEY(,CHR) GET STORAGE KEY 01418000
  1395. B SETKEYG GO TO COMMON CODE 01419000
  1396. SPACE 5 01420000
  1397. SETKEYN EQU * 01421000
  1398. SPACE 01422000
  1399. * SAME AS SETKEY, EXCEPT THAT 'UNASSIGNED' STORAGE KEY IS SET. 01423000
  1400. LA XR,USERKEY SET USER KEY 01424000
  1401. B SETKEYG GO TO COMMON CODE 01425000
  1402. SPACE 3 01426000
  1403. SETKEYI EQU * 01427000
  1404. SPACE 5 01428000
  1405. * COMMON BRANCH POINT FOR SETKEY AND SETKEYN 01429000
  1406. SETKEYG EQU * 01430000
  1407. LR R14,BLR POINTER TO PAGE BLOCK 01431000
  1408. LR R15,SR SIZE OF PAGE BLOCK 01432000
  1409. SPACE 01433000
  1410. * SSK LOOP 01434000
  1411. SETKEYL EQU * 01435000
  1412. SSK XR,R14 SET STORAGE KEY OF 1ST HALF OF *01436000
  1413. PAGE 01437000
  1414. LA R14,2048(,R14) ADVANCE POINTER TO SECOND HALF 01438000
  1415. SSK XR,R14 SET STORAGE KEY OF SECOND HALF 01439000
  1416. LA R14,2048(,R14) ADVANCE TO NEXT PAGE 01440000
  1417. S R15,PAGESIZE SUBTRACT PAGESIZE FROM TOTAL *01441000
  1418. SIZE 01442000
  1419. BP SETKEYL LOOP IF THERE IS MORE TO DO 01443000
  1420. BM *+8 @VA00980 01444100
  1421. SETKEYR SR R15,R15 @VA00980 01444200
  1422. BR RR @VA00980 01444300
  1423. RTN ,24,FINIS IMPOSSIBLE CONDITION IF NEGATIVE 01445000
  1424. SFRT EQU * 01447000
  1425. SPACE 01448000
  1426. * FRET SUBROUTINE -- ADD A BLOCK TO A SPECIFIED CHAIN. 01449000
  1427. SPACE 01450000
  1428. * AT ENTRY: 01451000
  1429. * CHR -> CHAIN HEADER FOR CHAIN TO BE MODIFIED 01452000
  1430. * BLR -> BLOCK TO BE ADDED TO CHAIN 01453000
  1431. * SR = SIZE OF BLOCK TO BE ADDED TO CHAIN 01454000
  1432. SPACE 01455000
  1433. * AT RETURN: 01456000
  1434. * BLR AND SR ARE SET UP TO INDICATE THE BLOCK ON THE CHAIN 01457000
  1435. * WHICH CONTAINS THE BLOCK WHICH WAS RETURNED. THAT IS, 01458000
  1436. * IF THE RETURNED BLOCK DID NOT COMBINE WITH ANY OTHER BLOCK, 01459000
  1437. * THEN BLR AND SR INDICATE THE RETURNED BLOCK. IF THE RETURNED 01460000
  1438. * BLOCK DID COMBINE, THEN BLR AND SR INDICATE THE TOTAL BLOCK 01461000
  1439. * ON THE FREE CHAIN. 01462000
  1440. * BLR -> BLOCK ON FREE CHAIN CONTAINING RETURNED BLOCK 01463000
  1441. * SR = SIZE OF THIS BLOCK 01464000
  1442. SPACE 01465000
  1443. ST SR,SIZE(,BLR) SET SIZE FIELD OF RETURNED BLOCK 01466000
  1444. LR XR,SR XR = SIZE OF RETURNED BLOCK 01467000
  1445. AR XR,BLR XR -> END OF RETURNED BLOCK 01468000
  1446. LR PTR,CHR INITIALIZE CHAIN POINTER 01469000
  1447. LA R15,SFRTL FOR SPEED IN LOOP 01470000
  1448. SPACE 01471000
  1449. * SEARCH LOOP -- FINDS THE PLACE WHERE THE NEW BLOCK BELONGS. 01472000
  1450. CNOP 0,8 FOR SPEED 01473000
  1451. SFRTL EQU * 01474000
  1452. LR PPTR,PTR MOVE POINTERS AHEAD ONE BLOCK 01475000
  1453. L PTR,POINTER(,PTR) 01476000
  1454. CLR XR,PTR END OF NEW BLOCK ABOVE OLD BLK? 01477000
  1455. BCR 4,R15 (BL SFRTL) YES -- LOOP BACK AND CONTINUE 01478000
  1456. SPACE 01479000
  1457. * WE DROP THROUGH THE LOOP WHEN WE HAVE FOUND THE POSITION IN 01480000
  1458. * THE CHAIN WHERE THE BLOCK BELONGS. 01481000
  1459. * WHEN CONTROL COMES TO THIS POINT, THEN REGISTERS ARE AS FOLLOWS: 01482000
  1460. SPACE 01483000
  1461. * BLR -> NEW BLOCK 01484000
  1462. * XR -> END OF NEW BLOCK 01485000
  1463. * SR = SIZE OF NEW BLOCK (= XR - BLR) 01486000
  1464. SPACE 01487000
  1465. * PTR AND PPTR -> CHAIN ELEMENTS SUCH THAT ONE OF THE FOLLOWING 01488000
  1466. * IS TRUE: 01489000
  1467. SPACE 01490000
  1468. * CASE 1. 01491000
  1469. * XR = PTR 01492000
  1470. * BLR > POINTER(,PTR) + SIZE OF BLOCK BELOW NEW BLOCK 01493000
  1471. * IN THIS CASE, THE NEW BLOCK COMBINES WITH THE PTR BLOCK 01494000
  1472. * ABOVE IT, BUT LIES ABOVE THE POINTER(,PTR) BLOCK AND 01495000
  1473. * DOES NOT COMBINE WITH IT. 01496000
  1474. SPACE 01497000
  1475. * CASE 2. 01498000
  1476. * XR = PTR 01499000
  1477. * BLR = POINTER(,PTR) + SIZE OF BLOCK BELOW NEW BLOCK 01500000
  1478. * IN THIS CASE, THE NEW BLOCK COMBINES WITH THE PTR BLOCK 01501000
  1479. * ABOVE IT AND WITH THE POINTER(,PTR) BLOCK BELOW. 01502000
  1480. SPACE 01503000
  1481. * CASE 3. 01504000
  1482. * XR > PTR 01505000
  1483. * BLR = PTR + SIZE(,PTR) 01506000
  1484. * IN THIS CASE, THE NEW BLOCK CAN BE COMBINED WITH THE 01507000
  1485. * PTR BLOCK BELOW IT. 01508000
  1486. SPACE 01509000
  1487. * CASE 4. 01510000
  1488. * XR > PTR 01511000
  1489. * BLR > PTR + SIZE(,PTR) 01512000
  1490. * IN THIS CASE, THE NEW BLOCK LIES STRICTLY BETWEEN THE 01513000
  1491. * PTR BLOCK AND THE PPTR BLOCK, AND DOES NOT COMBINE WITH 01514000
  1492. * ANYTHING. (THIS CASE ALSO ARISES IF PTR = 0 -- THE NEW 01515000
  1493. * BLOCK GOES ON THE END OF THE CHAIN.) 01516000
  1494. SPACE 01517000
  1495. * IN ADDITION, THE CONDITION CODE IS STILL SET FROM THE 01518000
  1496. * INSTRUCTION 'CLR XR, PTR' 01519000
  1497. SFRTLO EQU * 01520000
  1498. L CR,NUM(,CHR) GET NUMBER OF ELEMENTS ON CHAIN 01521000
  1499. BE SFRTC123 GO IF CASES 1 OR 2 01522000
  1500. SPACE 01523000
  1501. * CASES 3 OR 4; ALSO CASES 1 AND 2 AFTER LOADING NEXT LOWER PTR 01524000
  1502. SFRTC34 EQU * 01525000
  1503. LTR R14,PTR ANY PTR POINTER? 01526000
  1504. BZ SFRTC4 CASE 4 IF NOT 01527000
  1505. AL R14,SIZE(,PTR) R14 -> END OF PTR BLOCK 01528000
  1506. CLR R14,BLR COMBINE BLR AND PTR BLOCKS? 01529000
  1507. RTN H,6,FINIS NEW BLOCK OVERLAPS PTR BLOCK 01530000
  1508. BL SFRTC4 FINISHED IF BLOCKS ARE NON-CONTIGUOUS @VA08663 01531000
  1509. SPACE 01532000
  1510. * COME HERE ON CASES 1, 2 OR 3 -- THE BLR BLOCK IS TO BE COMBINED WITH 01533000
  1511. * THE PTR BLOCK EITHER FROM ABOVE OR FROM BELOW. 01534000
  1512. SFRTC123 EQU * 01535000
  1513. AL SR,SIZE(,PTR) SIZE OF COMBINED BLOCKS 01536000
  1514. CLR BLR,PTR WHICH BLOCK IS LOWER IN CORE? 01537000
  1515. BL *+6 SKIP IF CASES 1 OR 2 01538000
  1516. LR BLR,PTR CASE 3 01539000
  1517. SPACE 01540000
  1518. * AT THIS POINT, BLR POINTS TO COMBINED BLOCK. 01541000
  1519. ST SR,SIZE(,BLR) STORE SIZE OF COMBINED BLOCK. 01542000
  1520. L PTR,POINTER(,PTR) POINT TO BLOCK FOLLOWING OLD PTR 01543000
  1521. BCTR CR,0 DECREMENT COUNT, BECAUSE OF *01544000
  1522. COMBINING JUST PERFORMED 01545000
  1523. ST PTR,POINTER(,PPTR) 01546000
  1524. SPACE 01547000
  1525. * NOW EVERYTHING IS SET UP FOR CASE 1 OR 2 AS IF FOR CASE 3 OR 4, WITH 01548000
  1526. * BLR NOW POINTING TO THE COMBINED BLOCK, AND PTR POINTING TO WHAT USED 01549000
  1527. * TO BE POINTER(,PTR). ALSO, CONDITION CODE FROM LAST CLR INSTRUCTION 01550000
  1528. * IS STILL SET. 01551000
  1529. BL SFRTC34 GO HANDLE FINISH-UP @VA08663 01552000
  1530. SFRTC4 EQU * 01554000
  1531. ST BLR,POINTER(,PPTR) PUT NEW BLOCK ONTO CHAIN 01555000
  1532. ST PTR,POINTER(,BLR) 01556000
  1533. LA CR,1(,CR) INCREMENT COUNT, SINCE WE HAVE *01557000
  1534. ADDED A BLOCK 01558000
  1535. SPACE 01559000
  1536. * AT THIS POINT, ALL THE BLOCKS ARE PROPERLY CHAINED, AND REGISTERS 01560000
  1537. * BLR AND SR ARE PROPERLY SET UP FOR EXIT. NOW WE NEED ONLY STORE THE 01561000
  1538. * NEW CHAIN HEADER VALUES, AND EXIT. 01562000
  1539. ST CR,NUM(,CHR) STORE NUMBER OF BLOCKS 01563000
  1540. CL SR,MAX(,CHR) SHOULD MAX BE UPDATED? 01564000
  1541. BL *+8 SKIP IF NOT 01565000
  1542. ST SR,MAX(,CHR) STORE IF SO 01566000
  1543. RTN ,0 NORMAL RETURN (RC=0) 01567000
  1544. RTNFINIS EQU * 01569000
  1545. RTNCLOB EQU * 01570000
  1546. RETURN EQU * 01571000
  1547. ST R15,FREESAVE+R15*4 STORE RETURN CODE IN SAVE AREA 01572000
  1548. LTR R15,R15 ANY RETURN CODE? 01573000
  1549. BNZ ERRORET GO HANDLE IT 01574000
  1550. SPACE 01575000
  1551. RETURN1 EQU * 01576000
  1552. TM FREEFLG1,FRF1E WAS THIS FREE CALL (NOT FRET) 01577000
  1553. BZ RETURN2 GO IF IT WAS FRET 01578000
  1554. ST BLR,FREESAVE+R1*4 STORE ALLOCATED BLOCK LOCATION 01579000
  1555. TM FREEFLG1,FRF1V+FRF1E WAS IT VARIABLE REQUEST? 01580000
  1556. BNO RETURN2 SKIP IF NOT 01581000
  1557. SRA SR,3 CONVERT SIZE TO DOUBLEWORDS 01582000
  1558. ST SR,FREESAVE+R0*4 AND STORE IN SAVE AREA 01583000
  1559. SPACE 01584000
  1560. RETURN2 EQU * 01585000
  1561. TM FREEFLG2,FRF2CL CLEAN-UP FLAG SET? 01586000
  1562. BO CLEANUP YES -- GO CLEAN UP 01587000
  1563. SPACE 01588000
  1564. RETURN3 EQU * 01589000
  1565. TM FREEFLG2,FRF2CKT CHECK FLAG SET? 01590000
  1566. BO CHECK YES -- GO CHECK 01591000
  1567. SPACE 01592000
  1568. RETURN4 EQU * 01593000
  1569. SPACE 01594000
  1570. RETURNE EQU * 01595000
  1571. LM R0,R15,FREESAVE RESTORE GENERAL REGISTERS 01596000
  1572. BR R14 AND RETURN TO CALLER 01597000
  1573. * PUT CONSTANTS AND LITERALS HERE TO KEEP HEAVILY USED PARTS 01599000
  1574. * OF ROUTINE IN ONE PAGE. 01600000
  1575. PAGESIZE DC A(4096) SIZE OF A PAGE IN BYTES 01601000
  1576. SPACE 2 01602000
  1577. LTORG 01603000
  1578. DS 0H 01604000
  1579. SPACE 01605000
  1580. * THIS ENDS THE HEAVILY USED PORTION OF DMSFRE. 01606000
  1581. SPACE 01607000
  1582. CLEANUP EQU * 01609000
  1583. SPACE 01610000
  1584. * THE CLEANUP ROUTINE IS ENTERED WHEN THE FRF2CL FLAG IS SET IN 01611000
  1585. * FREEFLG2. 01612000
  1586. * CLEANUP WILL TAKE PLACE FOR ALL CHAINS WHOSE HEADERS HAVE FLCLN FLAG 01613000
  1587. * ON IN THE 'FLAGS' BYTE. 01614000
  1588. SPACE 01615000
  1589. * THERE ARE TWO TYPES OF CLEANUP: 01616000
  1590. * 1. FOR NUCLEUS CHAINS, ANY FULL PAGES MUST BE REMOVED AND 01617000
  1591. * PLACED ON THE CORRESPONDING USER CHAINS. 01618000
  1592. * 2. FOR THE HIGH-CORE USER CHAIN, IT MAY BE POSSIBLE TO 01619000
  1593. * REMOVE STORAGE FROM CHAIN AND MOVE UP 'LOW EXTEND' POINTER. 01620000
  1594. SPACE 2 01621000
  1595. LA XR,4 NUMBER OF CHAINS 01622000
  1596. LA CHR,FREELN POINT TO FIRST HEADER BLOCK 01623000
  1597. SH CHR,=AL2(BLOCKLEN) AND BACK UP BY LENGTH OF ONE 01624000
  1598. BALR R14,0 (LA R14,CLEANUPL) SET R14 FOR SPEED IN LOOP 01625000
  1599. SPACE 01626000
  1600. CLEANUPL EQU * 01627000
  1601. LA CHR,BLOCKLEN(,CHR) POINT TO NEXT CHAIN HEADER BLK 01628000
  1602. TM FLAGS(CHR),FLCLN 'CLEANUP' FLAG SET? 01629000
  1603. BO CL GO CLEAN UP IF SO 01630000
  1604. BCTR XR,R14 (BCT XR,CLEANUPL) COUNT CHAINS 01631000
  1605. NI FREEFLG2,X'FF'-FRF2CL TURN OFF MAJOR CLEANUP FLAG 01632000
  1606. B RETURN3 AND RE-ENTER RETURN CODE 01633000
  1607. SPACE 2 01634000
  1608. * COME HERE IF A CHAIN HEADER BLOCK WITH THE CLEANUP FLAG ON IS 01635000
  1609. * FOUND. 01636000
  1610. CL EQU * 01637000
  1611. TM FLAGS(CHR),FLNU NUCLEUS CHAIN? 01638000
  1612. BO CLN GO HANDLE IT 01639000
  1613. SPACE 01640000
  1614. CL1 EQU * 01641000
  1615. TM FLAGS(CHR),FLHC HIGH-CORE CHAIN? 01642000
  1616. BO CLH GO HANDLE IT 01643000
  1617. SPACE 01644000
  1618. CL2 EQU * 01645000
  1619. NI FLAGS(CHR),X'FF'-FLCLN TURN OFF CLEANUP FLAG 01646000
  1620. B CLEANUP AND SEARCH FOR MORE DIRTY CHAINS 01647000
  1621. SPACE 01648000
  1622. * COME HERE TO CLEAN UP A NUCLEUS CHAIN. IT IS NECESSARY TO REMOVE 01649000
  1623. * COMPLETE PAGES FROM THE CHAIN. 01650000
  1624. CLN EQU * 01651000
  1625. TM FREEFLG2,FRF2NOI 2ND INITIALIZATION TAKEN PLACE? 01652000
  1626. BO CL1 NO -- NOTHING TO DO 01653000
  1627. L SR,PAGESIZE GET PAGE SIZE 01654000
  1628. BAL RR,SCHVPGE FIND ANY PAGES ON CHAIN 01655000
  1629. BNZ CL1 FINISHED IF NO FULL PAGES 01656000
  1630. TM FLAGS(CHR),FLHC IS THIS A HIGH-CORE CHAIN? 01657000
  1631. BZ CLN1 GO IF NOT HIGH CORE 01658000
  1632. CL BLR,FREELOWE IS THE BLOCK AT LOW EXTEND? 01659000
  1633. BNE CLN1 GO IF NOT 01660000
  1634. SPACE 01661000
  1635. * OTHERWISE, WE CAN INCREASE THE LOW EXTEND POINTER. 01662000
  1636. BAL RR,SETCODEN SET CODE TO UNASSIGNED 01663000
  1637. BAL RR,SETKEYN SET KEY TO UNASSIGNED 01664000
  1638. AR BLR,SR FIND END OF BLOCK 01665000
  1639. ST BLR,FREELOWE STORE NEW LOW EXTEND PTR 01666000
  1640. SPACE 01667000
  1641. * IT IS NOW POSSIBLE THAT THE HIGH-CORE USER CHAIN MAY NEED CLEANING 01668000
  1642. * UP, SINCE LOW EXTEND HAS BEEN CHANGED. 01669000
  1643. CLEANUP ,HU 01670000
  1644. B CL2 ALL FINISHED WITH THIS CHAIN 01671000
  1645. SPACE 01672000
  1646. * COME HERE IF THERE IS A PAGE BLOCK TO BE MOVED TO THE 01673000
  1647. * CORRESPONDING USER CHAIN. 01674000
  1648. CLN1 EQU * 01675000
  1649. LA CHR,BLOCKLEN(,CHR) POINT TO CORRESPONDING USER CHN 01676000
  1650. BAL RR,SETCODE SET USER CODE IN FREETAB 01677000
  1651. BAL RR,SETKEY SET USER STORAGE KEY 01678000
  1652. BAL RR,SFRT PUT PAGE BLOCK ON THAT CHAIN 01679000
  1653. OI FLAGS(CHR),FLPA SET PAGE AVAILABLE FLAG 01680000
  1654. SH CHR,=AL2(BLOCKLEN) POINT BACK TO NUC CHAIN 01681000
  1655. B CLN AND LOOK FOR MORE PAGES 01682000
  1656. SPACE 01683000
  1657. * FOR HIGH-CORE USER CHAIN, WE NEED ONLY SEE IF IT CAN BE 01684000
  1658. * DIS-EXTENDED. 01685000
  1659. CLH EQU * 01686000
  1660. TM FLAGS(CHR),FLPA PAGE AVAILABLE ON CHAIN? 01687000
  1661. BZ CL2 NOTHING TO DO IF NOT 01688000
  1662. L CR,NUM(,CHR) GET NUMBER OF BLOCKS ON CHAIN 01689000
  1663. LTR CR,CR ANY BLOCKS? 01690000
  1664. BZ CL2 GO IF NOT 01691000
  1665. L SR,PAGESIZE SIZE OF A PAGE 01692000
  1666. CL SR,MAX(,CHR) COMPARE WITH MAX SIZE ON CHAIN 01693000
  1667. BH CL2 WE'RE ALL THROUGH IF MAX TOO *01694000
  1668. SMALL 01695000
  1669. LA R14,CLHL FOR SPEED IN LOOP 01696000
  1670. LR PTR,CHR INITIALIZE PTR 01697000
  1671. SPACE 01698000
  1672. * THE FOLLOWING LOOP SIMPLY SEARCHES FOR THE LAST BLOCK IN THE 01699000
  1673. * CHAIN. 01700000
  1674. CNOP 0,8 FOR SPEED IN LOOP 01701000
  1675. CLHL EQU * 01702000
  1676. LR PPTR,PTR MOVE POINTERS AHEAD ONE BLOCK 01703000
  1677. L PTR,POINTER(,PTR) 01704000
  1678. BCTR CR,R14 (BCT CR,CLHL) COUNT BLOCKS 01705000
  1679. CLC =F'0',POINTER(PTR) CHECK FOR CLOBBERED CHAIN 01706000
  1680. RTN NE,61,CLOB CLOBBERED IF NONZERO 01707000
  1681. L SR,SIZE(,PTR) GET SIZE OF LAST BLOCK 01708000
  1682. ROUND DOWN,SR ROUND DOWN TO PAGE BOUNDARY 01709000
  1683. LTR SR,SR ANYTHING LEFT? 01710000
  1684. BZ CL2 WE'RE THROUGH IF NOT 01711000
  1685. LR BLR,PTR POINT TO BLOCK 01712000
  1686. CL BLR,FREELOWE IS IT A LOW-EXTEND? 01713000
  1687. BNE CL2 WE'RE THROUGH IF NOT 01714000
  1688. BAL RR,ALOCC ALLOCATE BLOCK 01715000
  1689. BAL RR,SETCODEN SET UNASSIGNED CODE 01716000
  1690. BAL RR,SETKEYN SET UNASSIGNED STORAGE KEY 01717000
  1691. ALR BLR,SR POINT TO END OF BLOCK 01718000
  1692. ST BLR,FREELOWE THAT'S THE NEW LOW-EXTEND VALUE 01719000
  1693. B CL2 AND WE'RE THROUGH 01720000
  1694. CHECK EQU * 01722000
  1695. SPACE 01723000
  1696. * CHECK TO SEE IF ALL CHAINS ARE CONSISTENT. 01724000
  1697. SPACE 01725000
  1698. * THIS ROUTINE DOES NOT MAKE ANY CHANGES TO THE CHAINS (NOT EVEN MAX). 01726000
  1699. * IT JUST CHECKS TO SEE IF EVERYTHING'S LEGAL. 01727000
  1700. SPACE 01728000
  1701. * IT WILL BE ENTERED IF THE 'FRF2CKT' FLAG IN FREEFLG2 IS SET. 01729000
  1702. SPACE 2 01730000
  1703. * THE FOLLOWING FLAG INDICATES THAT THE CHECK ROUTINE IS BEING 01731000
  1704. * EXECUTED. 01732000
  1705. OI FREEFLG2,FRF2CKX SET 'IN CHECK' FLAG 01733000
  1706. L XR,FREELOWE GET CURRENT LOW EXTEND VALUE 01734000
  1707. C XR,VMSIZE GREATER THAN SIZE OF STORAGE? 01735000
  1708. RTN H,84,CHKP CLOBBERED IF IT IS 01736000
  1709. C XR,AUSRAREA BELOW USER PROGRAM AREA? 01737000
  1710. RTN L,85,CHKP CLOBBERED IF IT IS 01738000
  1711. L SR,VMSIZE GET SIZE OF STORAGE 01739000
  1712. SRA SR,12 SR = SIZE OF FREETAB IN BYTES 01740000
  1713. L BLR,AFREETAB BLR -> FREETABL 01741000
  1714. LA R14,256 01742000
  1715. SPACE 01743000
  1716. * THE FOLLOWING LOOP CHECKS ALL THE BYTES IN FREETAB TO SEE IF THEY 01744000
  1717. * ARE WITHIN LEGAL RANGE. NOTE, FOR THE PURPOSES OF THE TRT USED 01745000
  1718. * IN THE LOOP, THAT XR2 = R2, SO THAT NOTHING IMPORTANT IS BEING 01746000
  1719. * CLOBBERED IN REGISTER 2. 01747000
  1720. CHECKF EQU * 01748000
  1721. LTR R15,SR ANY BYTES LEFT TO CHECK? 01749000
  1722. BZ CHECKF1 ALL THROUGH CHECKING IF NOT 01750000
  1723. CLR R15,R14 MORE THAN 256 BYTES LEFT? 01751000
  1724. BL *+6 SKIP IF NOT 01752000
  1725. LR R15,R14 USE 256 PER TRT, IF SO 01753000
  1726. SR SR,R15 SUBTRACT THIS NUMBER FROM TOTAL 01754000
  1727. BCTR R15,0 DECREMENT COUNT FOR EX 01755000
  1728. EX R15,CHECKFI DO THE TRT ON FREETAB 01756000
  1729. RTN NZ,86,CHKP ERROR IF NOT ALL ZERO 01757000
  1730. * FUNCTION VALUES 01758000
  1731. LA BLR,256(,BLR) INCREMENT POINTER INTO FREETAB 01759000
  1732. B CHECKF LOOP BACK FOR NEXT 256 BYTES 01760000
  1733. SPACE 01761000
  1734. CHECKFI TRT 0(0,BLR),CHECKFT LENGTH FIELD FILLED IN BY EX 01762000
  1735. SPACE 01763000
  1736. * THE FOLLOWING TRANSLATE TABLE SHOULD REALLY BE 256 BYTES LONG. 01764000
  1737. * HOWEVER, SINCE THE TABLE IS FOLLOWED BY EXECUTABLE CODE, THERE WILL 01765000
  1738. * NOT BE VERY MANY NON-ZERO BYTES IN THE STORAGE FOLLOWING IT. AS A 01766000
  1739. * RESULT, IT WILL BE SUFFICIENT FOR OUR PURPOSES. 01767000
  1740. CHECKFT DC AL1(1),(5)AL1(0) 01768000
  1741. DS 0H 01769000
  1742. EJECT 01770000
  1743. * WE NOW BEGIN THE MAIN WORK OF CHECKING ALL CHAINS FOR 01771000
  1744. * CONSISTENCY. 01772000
  1745. CHECKF1 EQU * 01773000
  1746. LA CHR,FREELN POINT TO LOW NUCLEUS CHAIN 01774000
  1747. B CHECKB GO ENTER OUTER LOOP AND CHECK IT 01775000
  1748. SPACE 01776000
  1749. * COME HERE EACH TIME A NEW CHAIN IS TO BE STARTED. 01777000
  1750. CHECKA EQU * 01778000
  1751. LR XR,CHR SAVE OLD CHAIN POINTER 01779000
  1752. LA CHR,BLOCKLEN(,CHR) ADVANCE TO NEXT CHAIN POINTER 01780000
  1753. TM FLAGS(XR),FLHC HAVE WE EXAMINED HIGH-CORE YET? 01781000
  1754. BZ CHECKB GO HANDLE NEXT CHAIN IF NOT 01782000
  1755. TM FLAGS(XR),FLNU WAS IT HIGH-CORE USER CHAIN? 01783000
  1756. BO CHECKB GO HANDLE HIGH USER CHAIN IF NOT 01784000
  1757. SPACE 01785000
  1758. * WE HAVE CHECKED ALL FOUR CHAINS 01786000
  1759. SPACE 01787000
  1760. * THE FOLLOWING TURNS OFF THE 'CHECK IN USE' AND THE 'ENTER CHECK 01788000
  1761. * THIS TIME' FLAGS 01789000
  1762. NI FREEFLG2,X'FF'-FRF2CKT-FRF2CKX TURN OFF FLAGS 01790000
  1763. SPACE 01791000
  1764. * IF THERE HAS BEEN AN ERROR, WE GO TO THE ERROR HANDLING CODE. 01792000
  1765. * OTHERWISE, WE JUST RETURN. 01793000
  1766. CLC =F'0',FREESAVE+4*R15 HAS THERE BEEN AN ERROR 01794000
  1767. BE RETURN4 JUST RETURN IF NOT 01795000
  1768. B ERCHK GO FINISH UP IF THERE HAS 01796000
  1769. SPACE 2 01797000
  1770. * COME HERE TO BEGIN PROCESSING A NEW CHAIN 01798000
  1771. * FIRST, CHECK TO SEE IF ANY HIGH BYTES HAVE BEEN CLOBBERED. 01799000
  1772. CHECKB EQU * 01800000
  1773. CLI POINTER(CHR),0 HIGH BYTE OF POINTER CLOBBERED? 01801000
  1774. RTN NE,82,CHK CLOBBERED IF NONZERO 01802000
  1775. CLI MAX(CHR),0 HIGH BYTE OF MAX CLOBBERED? 01803000
  1776. RTN NE,83,CHK CLOBBERED IF NONZERO 01804000
  1777. L CR,NUM(,CHR) NUMBER OF ELEMENTS IN CHAIN 01805000
  1778. LA CR,1(,CR) INCREMENT BY 1 FOR LOOP LOGIC 01806000
  1779. LR PTR,CHR INITIALIZE PTR 01807000
  1780. B CHECKLE ENTER LOOP AT THE END 01808000
  1781. SPACE 01809000
  1782. * THIS IS THE RETURN BRANCH POINT IN THE LOOP 01810000
  1783. CHECKL EQU * 01811000
  1784. LR PPTR,PTR MOVE UP POINTERS ONE BLOCK 01812000
  1785. L PTR,POINTER(,PTR) 01813000
  1786. LTR PTR,PTR DOES POINTER = 0? 01814000
  1787. RTN Z,70,CHK CHAIN CLOBBERED IF SO 01815000
  1788. LR BLR,PTR BLR -> CURRENT BLOCK 01816000
  1789. SPACE 01817000
  1790. * CHECK FOR DOUBLE WORD ALIGNED BLOCK. 01818000
  1791. L XR,=AL1(255,0,0,7) 01819000
  1792. NR XR,PTR ZERO OUT HIGHORDER BITS 01820000
  1793. RTN NZ,71,CHK IF NONZERO, THEN NOT ALIGNED 01821000
  1794. SPACE 01822000
  1795. * CHECK FOR DOUBLEWORD ALIGNED SIZE 01823000
  1796. L SR,SIZE(,PTR) GET SIZE OF BLOCK 01824000
  1797. L XR,=AL1(255,0,0,7) 01825000
  1798. NR XR,SR ZERO OUT HIGHORDER BITS 01826000
  1799. RTN NZ,72,CHK IF NONZERO, THEN NOT ALIGNED 01827000
  1800. SPACE 01828000
  1801. CLR PPTR,CHR IS THIS THE FIRST BLOCK ON THE *01829000
  1802. CHAIN? 01830000
  1803. BE CHECKLA YES -- SKIP NEXT TEST 01831000
  1804. LA XR,0(SR,BLR) XR -> END OF BLOCK 01832000
  1805. CLR XR,PPTR SEE IF BLOCKS ARE IN CORRECT *01833000
  1806. ORDER 01834000
  1807. RTN NL,73,CHK BLOCKS OVERLAP OR NOT CHAINED *01835000
  1808. IN ORDER 01836000
  1809. SPACE 01837000
  1810. CHECKLA EQU * 01838000
  1811. SPACE 01839000
  1812. * CHECK TO SEE IF BLOCKSIZE IS GREATER THAN MAX FOR THIS CHAIN. 01840000
  1813. CL SR,MAX(,CHR) COMPARE WITH MAX 01841000
  1814. RTN H,74,CHK CLOBBERED IF SIZE > MAX 01842000
  1815. SPACE 01843000
  1816. * WE CALL FINDCHN TO PERFORM THE CHECK TO SEE IF THE FREETAB TABLE IS 01844000
  1817. * CORRECT. THIS ROUTINE WILL ALSO CHECK TO MAKE SURE THAT THE BLOCK 01845000
  1818. * DOES NOT OVERLAP STORAGE ASSIGNED TO ANOTHER CHAIN. 01846000
  1819. LR XR2,CHR SAVE CHAIN POINTER 01847000
  1820. BAL RR,FINDCHN FIND CORRECT CHAIN POINTER 01848000
  1821. RTN NZ,75,CHK ERROR RETURN -> CLOBBERED 01849000
  1822. CLR XR2,CHR DID WE END UP WITH SAME CHAIN? 01850000
  1823. RTN NE,76,CHK BLOCK ON WRONG CHAIN 01851000
  1824. SPACE 01852000
  1825. * IF THE BLOCK CONTAINS A FULL PAGE, WE CHECK TO SEE IF: 01853000
  1826. * 1. THE 'PAGE AVAILABLE' (FLPA) FLAG IS ON IN THE FLAGS BYTE. 01854000
  1827. * 2. IF FREELOWE CAN BE DIS-EXTENDED. 01855000
  1828. * 3. IF THE CHAIN IS A NUCLEUS CHAIN (IN WHICH CASE, A FULL PAGE 01856000
  1829. * IS ILLEGAL) 01857000
  1830. CL SR,PAGESIZE COMPARE BLOCK SIZE WITH PAGESIZE 01858000
  1831. BL CHECKLB NOTHING TO DO IF SMALLER 01859000
  1832. LA XR,0(SR,BLR) XR -> END OF BLOCK 01860000
  1833. ROUND UP,BLR BLR -> BEGINNING OF EMBEDDED PGE 01861000
  1834. ROUND DOWN,XR XR -> END OF EMBEDDED PAGE BLOCK 01862000
  1835. CLR BLR,XR ARE THE TWO EQUAL? 01863000
  1836. BNL CHECKLB THEN THERE IS NO EMBEDDED PAGE 01864000
  1837. TM FLAGS(CHR),FLPA PAGE AVAILABLE FLAG ON? 01865000
  1838. RTN Z,77,CHK CHAIN CLOBBERED IF NOT 01866000
  1839. CL BLR,FREELOWE BLOCK AT LOW-EXTEND? 01867000
  1840. RTN E,78,CHK THAT SHOULDN'T HAVE HAPPENED 01868000
  1841. SPACE 01869000
  1842. * A FULL PAGE CANNOT APPEAR ON A NUCLEUS CHAIN, UNLESS THE SECOND 01870000
  1843. * INITIALIZATION HAS NOT YET TAKEN PLACE. 01871000
  1844. TM FLAGS(CHR),FLNU NUCLEUS CHAIN? 01872000
  1845. BZ CHECKLB OK IF NOT 01873000
  1846. TM FREEFLG2,FRF2NOI SECOND INIT TAKEN PLACE? 01874000
  1847. RTN NO,79,CHK CHAIN CLOBBERED IF IT HAS 01875000
  1848. SPACE 01876000
  1849. * WE CHECK THE VALIDITY OF THE FREELOWE POINTER. IF THIS IS A HIGH 01877000
  1850. * CORE CHAIN, THEN THIS BLOCK SHOULD LIE ABOVE FREELOWE, THE LOW 01878000
  1851. * EXTEND POINTER. 01879000
  1852. CHECKLB EQU * 01880000
  1853. LR BLR,PTR RESTORE BLR 01881000
  1854. CL BLR,FREELOWE COMPARE WITH LOW EXTEND 01882000
  1855. BNL CHECKLC IF HIGH OR EQUAL, THEN IT'S OK 01883000
  1856. TM FLAGS(CHR),FLHC IS THIS A HIGH-CORE CHAIN? 01884000
  1857. RTN O,80,CHK FREELOWE CLOBBERED IF SO 01885000
  1858. SPACE 01886000
  1859. CHECKLC EQU * 01887000
  1860. SPACE 01888000
  1861. * COME HERE AT END OF CHECKING EACH CHAIN. 01889000
  1862. CHECKLE EQU * 01890000
  1863. BCT CR,CHECKL COUNT BLOCKS ON CHAIN 01891000
  1864. CLC =F'0',POINTER(PTR) LAST POINTER = 0? 01892000
  1865. RTN NE,81,CHK COUNT IS WRONG IF NOT 01893000
  1866. B CHECKA 01894000
  1867. * THE CKON SERVICE ROUTINE TURNS ON A FLAG, SO THAT FROM THIS POINT 01896000
  1868. * ON A 'CHECK' WILL TAKE PLACE WITH EACH CALL TO DMSFRE. 01897000
  1869. CKON EQU * 01898000
  1870. OI FREEFLG2,FRF2CKE+FRF2CKT TURN ON FLAGS 01899000
  1871. RTN ,0,FINIS RETURN TO CALLER 01900000
  1872. SPACE 3 01901000
  1873. * THE CKOFF SERVICE ROUTINE TURNS OFF THIS FLAG. 01902000
  1874. CKOFF EQU * 01903000
  1875. NI FREEFLG2,X'FF'-FRF2CKE 01904000
  1876. RTN ,0,FINIS RETURN TO CALLER 01905000
  1877. SPACE 3 01906000
  1878. * THE CHECK SERVICE ROUTINE CAUSES A 'CHECK' TO BE PERFORMED. THIS 01907000
  1879. * WILL INVOLVE A COMPLETE CHECK OF ALL FREE CHAINS FOR IRREGULARITIES. 01908000
  1880. CHECKS EQU * 01909000
  1881. OI FREEFLG2,FRF2CKT SIGNAL A CHECK 01910000
  1882. RTN ,0,FINIS RETURN TO CALLER 01911000
  1883. * USER FREE STORAGE RECOVERY SERVICE ROUTINE. 01913000
  1884. * THIS ROUTINE IS CALLED BY THE DMSABN ABEND RECOVERY ROUTINE. IT 01914000
  1885. * RELEASES ALL STORAGE ALLOCATED AS 'USER' STORAGE. 01915000
  1886. UREC EQU * 01916000
  1887. XC FREELU(12),FREELU ZERO OUT LOWCORE POINTERS 01917000
  1888. XC FREEHU(12),FREEHU ZERO OUT HIGHCORE POINTERS 01918000
  1889. L R1,AFREETAB POINT TO FREE STORAGE BYTE TABLE 01919000
  1890. SR XR2,XR2 POINT TO CURRENT PAGE (PAGE 0) 01920000
  1891. L R0,AUSRAREA BEGINNING OF HIGH CORE 01921000
  1892. SRA R0,12 NUMBER OF PAGES IN LOW CORE 01922000
  1893. LA CHR,FREELU POINT TO LOW-CORE USER CHAIN 01923000
  1894. SPACE 01924000
  1895. * THE FOLLOWING LOOP SEARCHES THROUGH THE FREETAB TABLE, LOOKING FOR 01925000
  1896. * BYTES CORRESPONDING TO USER PAGES. THESE PAGES ARE PUT BACK ONTO 01926000
  1897. * THE USER FREE STORAGE CHAIN. 01927000
  1898. URECL EQU * 01928000
  1899. CLI 0(R1),USERCODE IS THIS A USER PAGE? 01929000
  1900. BNE URECLE SKIP IT IF NOT 01930000
  1901. LR BLR,XR2 BLR -> CURRENT PAGE 01931000
  1902. L SR,PAGESIZE LOAD BLOCKSIZE REG WITH PAGESIZE 01932000
  1903. SPACE 01933000
  1904. * WE LOOP THRU FREETAB TO FIND THE FIRST NON-USER BYTE. 01934000
  1905. URECG EQU * 01935000
  1906. CLI 1(R1),USERCODE IS THE NEXT ONE FOR USER? 01936000
  1907. BNE URECF GO IF NOT 01937000
  1908. LA R1,1(,R1) OTHERWISE, INCREMENT REGS 01938000
  1909. A XR2,PAGESIZE 01939000
  1910. A SR,PAGESIZE 01940000
  1911. BCT R0,URECG AND GO TRY AGAIN 01941000
  1912. SPACE 01942000
  1913. * AT THIS POINT, WE CALL SFRT TO PUT THE BLOCK ONTO THE FREE CHAIN. 01943000
  1914. URECF EQU * 01944000
  1915. BAL RR,SFRT 01945000
  1916. OI FLAGS(CHR),FLPA SET 'PAGE AVAILABLE' FLAG 01946000
  1917. SPACE 01947000
  1918. URECLE EQU * 01948000
  1919. LA R1,1(,R1) INCREMENT FREETAB POINTER 01949000
  1920. A XR2,PAGESIZE INCREMENT PAGE POINTER 01950000
  1921. BCT R0,URECL COUNT PAGES 01951000
  1922. SPACE 01952000
  1923. * WHEN WE REACH THIS POINT FOR THE FIRST TIME, WE WILL HAVE CHECKED 01953000
  1924. * ONLY THE LOW-CORE PAGES. SO WE NOW SET THINGS UP TO CHECK THE 01954000
  1925. * HIGH CORE PAGES. 01955000
  1926. C XR2,AUSRAREA ARE WE AT BEGINNING OF USER AREA 01956000
  1927. BNE URECB WE'RE ALL THROUGH IF NOT 01957000
  1928. SPACE 01958000
  1929. * OTHERWISE, WE COMPUTE THE NUMBER OF PAGES IN HIGH CORE. 01959000
  1930. L R0,VMSIZE SIZE OF VIRTUAL MEMORY 01960000
  1931. S R0,AUSRAREA SIZE OF HIGH CORE 01961000
  1932. SRA R0,12 AND CONVERT TO NUMBER OF PAGES 01962000
  1933. LA CHR,FREEHU POINT TO HIGH-CORE USER CHAIN 01963000
  1934. B URECL GO BACK AND RE-ENTER LOOP 01964000
  1935. SPACE 01965000
  1936. * COME HERE WHEN WE'RE ALL THROUGH 01966000
  1937. URECB EQU * 01967000
  1938. C XR2,VMSIZE XR2 -> END OF CORE? 01968000
  1939. RTN NE,41,FINIS IMPOSSIBLE IF NOT 01969000
  1940. CLEANUP ,HU CLEAN UP HIGH-CORE USER CHAIN 01970000
  1941. OI FREEFLG2,FRF2CKT FORCE A CHECK OF ALL CHAINS 01971000
  1942. RTN ,0,FINIS RETURN TO CALLER 01972000
  1943. * CALOC SERVICE ROUTINE. 01974000
  1944. * THIS ROUTINE IS CALLED BY DMSABN, THE ABEND RECOVERY ROUTINE. 01975000
  1945. * THIS ROUTINE COMPUTES THE TOTAL AMOUNT OF FREE STORAGE WHICH IS 01976000
  1946. * NOT ON THE FREE CHAIN. THE FIGURE DOES NOT INCLUDE SPACE OCCUPIED 01977000
  1947. * BY THE SYSTEM DISK FILE DIRECTORY (SSTAT), NOR DOES IT INCLUDE 01978000
  1948. * THE FREETAB TABLE. 01979000
  1949. CALOC EQU * 01980000
  1950. SPACE 01981000
  1951. * FIRST, WE COMPUTE THE SIZE OF ALL PAGES ALLOCATED TO FREE STORAGE. 01982000
  1952. SPACE 01983000
  1953. * LOW CORE RUNS FROM NUCEND TO SSTAT. 01984000
  1954. * NOTE THAT SSTAT IS LOCATED IN THE HIGHEST PART OF WHAT WAS 01985000
  1955. * ORIGINALLY THE LOW-CORE FREE STORAGE REGION (FROM NUCEND TO TRANSAR) 01986000
  1956. L SR,ASSTAT POINT TO SSTAT 01987000
  1957. S SR,=V(DMSNUCE) GET SIZE OF LOWCORE REGION 01988000
  1958. SPACE 01989000
  1959. * HIGH CORE RUNS FROM FREELOWE TO FREELOW1 (THE LATTER WAS SET BY 01990000
  1960. * INIT2 AS THE ORIGINAL VALUE OF FREELOWE) 01991000
  1961. A SR,FREELOW1 ADD FREELOW1 01992000
  1962. S SR,FREELOWE NET SIZE OF HIGH CORE REGION 01993000
  1963. SPACE 01994000
  1964. * WE NOW LOOP THROUGH ALL FOUR CHAINS, AND SUBTRACT THE SIZE OF EACH 01995000
  1965. * BLOCK ON THE FREE CHAIN FROM SR. 01996000
  1966. LA XR,4 NUMBER OF CHAINS 01997000
  1967. LA CHR,FREELN POINT TO LOW-CORE NUCLEUS CHAIN 01998000
  1968. SH CHR,=AL2(BLOCKLEN) BACK UP BY ONE BLOCK LENGTH 01999000
  1969. SPACE 02000000
  1970. * COME HERE TO EXAMINE THE NEXT CHAIN 02001000
  1971. CALOCC EQU * 02002000
  1972. LA CHR,BLOCKLEN(,CHR) POINT TO NEXT CHAIN HEADER 02003000
  1973. L CR,NUM(,CHR) GET NUMBER OF BLOCKS ON CHAIN 02004000
  1974. LTR CR,CR ARE THERE ANY? 02005000
  1975. BZ CALOCE NOTHING TO DO IF NOT 02006000
  1976. LR PTR,CHR POINT TO CHAIN HEADER 02007000
  1977. SPACE 02008000
  1978. * POINT TO EACH BLOCK, AND SUBTRACT ITS SIZE FROM SR. 02009000
  1979. CALOCB EQU * 02010000
  1980. L PTR,POINTER(,PTR) POINT TO NEXT CHAIN ELEMENT 02011000
  1981. S SR,SIZE(,PTR) SUBTRACT ITS SIZE FROM SR 02012000
  1982. BCT CR,CALOCB COUNT BLOCKS 02013000
  1983. SPACE 02014000
  1984. * COME HERE AT THE END OF EACH CHAIN 02015000
  1985. CALOCE EQU * 02016000
  1986. BCT XR,CALOCC COUNT CHAINS 02017000
  1987. SPACE 02018000
  1988. * WE NOW SUBTRACT FROM SR THE SIZE OF FREETAB. 02019000
  1989. L XR,VMSIZE SIZE OF MEMORY 02020000
  1990. SRA XR,12 NUMBER OF PAGES = SIZE OF *02021000
  1991. FREETAB 02022000
  1992. SR SR,XR SUBTRACT RESULT FROM SR 02023000
  1993. SRA SR,3 CONVERT TO DOUBLE WORDS 02024000
  1994. ST SR,FREESAVE+R0*4 STORE IN RETURNED REG 0 02025000
  1995. RTN ,0,FINIS RETURN TO CALLER 02026000
  1996. * COME HERE UPON ANY ERROR RETURN FROM OTHER THAN THE 'CHECK' 02028000
  1997. * ROUTINE. 02029000
  1998. ERRORET EQU * 02030000
  1999. TM FREEFLG2,FRF2CKX ARE WE IN 'CHECK' ROUTINE? P3015 02031000
  2000. BO RTNCHK CLOBBERED CHAIN IF SO P3015 02032000
  2001. SPACE 02033000
  2002. * FIRST, WE COMPUTE THE ADDRESS OF THE CALLER. 02034000
  2003. L R14,FREESAVE+4*R14 GET VALUE OF R14 AT ENTRY 02035000
  2004. TM FREEFLG1,FRF1B WAS THIS A 'TYPCALL=BALR' CALL? 02036000
  2005. BO ERRET1 WE HAVE OUR ANSWER IF SO 02037000
  2006. L XR,CURRSAVE GET ADDRESS OF CURRENT SAVE AREA 02038000
  2007. USING SSAVE,XR 02039000
  2008. L R14,CALLER GET ADDRESS OF SVC CALLER 02040000
  2009. DROP XR 02041000
  2010. SPACE 02042000
  2011. ERRET1 EQU * 02043000
  2012. ST R14,ACALL SAVE ADDRESS OF ACALL 02044000
  2013. CH R15,=H'20' IS ERROR CODE > 20? 02045000
  2014. BNL ERRX GO DIRECTLY TO 'ERRX' IF SO 02046000
  2015. SR XR,XR 02047000
  2016. IC XR,ERRTAB(R15) GET JUMP CODE FOR THIS ERROR 02048000
  2017. B *+4(XR) JUMP BASED ON ERROR CODE 02049000
  2018. B ERRX 0 9 < RC < 20 -- CAN'T HAPPEN 02050000
  2019. B ERRCORE 4 RC = 1 -- NO CORE AVAILABLE 02051000
  2020. B ERREERR 8 RC = 4 -- DMSFREE ARGUMENT ERROR 02052000
  2021. B ERRTERR 12 RC = 5, 6 OR 7 -- DMSFRET ARG ER 02053000
  2022. SPACE 02054000
  2023. ERRTAB DC AL1(0,4,0,0,8,12,12,12),13AL1(0) 02055000
  2024. DS 0H 02056000
  2025. EJECT 02057000
  2026. ERRX EQU * 02058000
  2027. LR XR,R15 XR <- IMPOSSIBLE ERROR CODE 02059000
  2028. DMSERR NUM=167,LET=T,TYPCALL=BALR,DISP=SIO, *02060000
  2029. TEXT='FREE STORAGE MANAGEMENT ERROR, INTERNAL ERROR CODE*02061000
  2030. .....', *02062000
  2031. SUB=(DEC,(XR)) 02063000
  2032. B CHECK 02064000
  2033. SPACE 2 02065000
  2034. ERRCORE EQU * 02066000
  2035. TM FREEFLG1,FRF1M MESSAGES SUPPRESSED 02067000
  2036. BZ CHKCLN SKIP MSG, CHECK CLEANUP @VA02373 02068300
  2037. DMSERR NUM=159,LET=T,TYPCALL=BALR,DISP=SIO, *02069000
  2038. SUB=(HEXA,ACALL), *02070000
  2039. TEXT='INSUFFICIENT STORAGE AVAILABLE TO SATISFY DMSFREE *02071000
  2040. REQUEST FROM ......' 02072000
  2041. CHKCLN TM FREEFLG2,FRF2CL CLEANUP REQUIRED? @VA02373 02073200
  2042. BZ CHECK SEE IF ANYTHING IS MESSED UP @VA02373 02073400
  2043. OI FREEFLG2,FRF2CKT CHECK AFTERWARD @VA02373 02073600
  2044. B CLEANUP PUT PAGES ON RIGHT QUEUES @VA02373 02073800
  2045. SPACE 2 02074000
  2046. ERREERR EQU * 02075000
  2047. TM FREEFLG1,FRF1M MESSAGES SUPPRESSED? 02076000
  2048. BZ CHECK DON'T TYPE MESSAGE IF SO 02077000
  2049. DMSERR NUM=160,LET=T,TYPCALL=BALR,DISP=SIO, *02078000
  2050. SUB=(HEXA,ACALL), *02079000
  2051. TEXT='INVALID DMSFREE CALL FROM ......' @V305066 02080000
  2052. B CHECK 02081000
  2053. SPACE 2 02082000
  2054. ERRTERR EQU * 02083000
  2055. TM FREEFLG1,FRF1M MESSAGES SUPPRESSED? 02084000
  2056. BZ CHECK DON'T TYPE MESSAGE IF SO 02085000
  2057. LR XR,R15 GET ACTUAL RETURN CODE 02086000
  2058. DMSERR NUM=161,LET=T,TYPCALL=BALR,MF=(E,'SYS'),DISP=SIO, *02087000
  2059. SUB=(HEXA,ACALL,DEC,(XR)), *02088000
  2060. TEXT='INVALID DMSFRET CALL FROM ......, ERROR NUMBER ...*02089000
  2061. ..' @V305066 02090000
  2062. B CHECK 02091000
  2063. EJECT 02092000
  2064. * CONTROL COMES HERE WHEN A CRITICAL POINTER IS FOUND BY THE 'CHECK' 02093000
  2065. * ROUTINE TO BE MEANINGLESS OR DESTROYED. 02094000
  2066. RTNCHKP EQU * 02095000
  2067. LR XR,R15 GET INTERNAL RETURN CODE 02096000
  2068. DMSERR NUM=162,LET=T,TYPCALL=BALR,DISP=SIO,HALT=YES, *02097000
  2069. TEXT='VITAL FREE STORAGE POINTERS DESTROYED (INTERNAL ER*02098000
  2070. ROR CODE ....), RE-IPL CMS', *02099000
  2071. SUB=(DEC,(XR)) 02100000
  2072. SPACE 02101000
  2073. * WE CONTINUE OPERATION IN CASE HE TURNS OFF THE WAIT STATE BIT AFTER 02102000
  2074. * REPAIRING THE POINTERS. 02103000
  2075. B CHECK 02104000
  2076. EJECT 02105000
  2077. * CONTROL COMES HERE WHEN THE 'CHECK' ROUTINE FINDS THAT ONE OF THE 02106000
  2078. * CHAINS IS CLOBBERED. 02107000
  2079. RTNCHK EQU * 02108000
  2080. LR XR,R15 GET INTERNAL ERROR CODE 02109000
  2081. LA R0,=CL4'LOW' POINT TO WORD 'LOW' 02110000
  2082. TM FLAGS(CHR),FLHC IS THIS THE HIGHCORE CHAIN? 02111000
  2083. BZ *+8 SKIP IF NOT 02112000
  2084. LA R0,=CL4'HIGH' IF SO, THEN POINT TO WORD 'HIGH' 02113000
  2085. TM FLAGS(CHR),FLNU IS THIS A NUCLEUS CHAIN? 02114000
  2086. BO RTNCHKN GO IF IT IS 02115000
  2087. SPACE 2 02116000
  2088. * MESSAGE: DMSFRE163T LOW/HIGH CORE USER CHAIN HAS BEEN DESTROYED. 02117000
  2089. DMSERR NUM=163,LET=T,MF=(E,'SYS'),TYPCALL=BALR,DISP=SIO, *02118000
  2090. TEXTA=RTNCHKT1, *02119000
  2091. SUB=(CHARA,(R0),CHARA,=CL7'USER',DEC,(XR),CHARA, P3071*02120000
  2092. =CL10' ') 02121000
  2093. SPACE 02122000
  2094. * HEADER INFORMATION MESSAGE 02123000
  2095. DMSERR NUM=165,LET=T,MF=(E,'SYS'),TYPCALL=BALR,DISP=SIO, *02124000
  2096. TEXTA=RTNCHKT2,SUB=(HEX,(CHR),HEX4A,(CHR)) 02125000
  2097. XC 0(12,CHR),0(CHR) ZERO OUT HEADER BLOCK 02126000
  2098. RTN ,2,CHKC USER STORAGE POINTERS CLOBBERED 02127000
  2099. SPACE 5 02128000
  2100. * NUCLEUS STORAGE POINTERS HAVE BEEN CLOBBERED. 02129000
  2101. RTNCHKN EQU * 02130000
  2102. DMSERR NUM=164,LET=T,MF=(E,'SYS'),TYPCALL=BALR,DISP=SIO, *02131000
  2103. TEXTA=RTNCHKT1, *02132000
  2104. SUB=(CHARA,(R0),CHARA,=CL7'NUCLEUS',DEC,(XR), P3071*02133000
  2105. CHARA,=C'RE-IPL CMS') 02134000
  2106. DMSERR NUM=165,LET=T,MF=(E,'SYS'),TYPCALL=BALR, *02135000
  2107. DISP=SIO,TEXTA=RTNCHKT2, *02136000
  2108. SUB=(HEX,(CHR),HEX4A,(CHR)) 02137000
  2109. XC 0(12,CHR),0(CHR) ZERO OUT HEADER POINTER 02138000
  2110. LPSW =A(X'20000',RTNCHKN1) LOAD DISABLED WAIT STATE TO DIE 02139000
  2111. SPACE 3 02140000
  2112. * WE CONTINUE OPERATION, IN CASE HE TURNS OFF THE WAIT STATE BIT. 02141000
  2113. RTNCHKN1 EQU * 02142000
  2114. RTN ,3,CHKC NUCLEUS STORAGE POINTERS CLOBBED 02143000
  2115. SPACE 2 02144000
  2116. * TEXT FOR THE TWO ERROR MESSAGES. 02145000
  2117. RTNCHKT1 DC AL1(RTNCHKL1) 02146000
  2118. DC C'....-CORE ....... STORAGE POINTERS DESTROYED (INTERNAL*02147000
  2119. ERROR CODE ....) ..........' 02148000
  2120. RTNCHKL1 EQU *-RTNCHKT1-1 02149000
  2121. SPACE 02150000
  2122. RTNCHKT2 DC AL1(RTNCHKL2) 02151000
  2123. DC C'CHAIN HEADER AT ......: ..............................*02152000
  2124. .....' 02153000
  2125. RTNCHKL2 EQU *-RTNCHKT2-1 02154000
  2126. DS 0H 02155000
  2127. SPACE 5 02156000
  2128. * COME HERE AFTER THE MESSAGE IS TYPED OUT. WE ZERO OUT THE CHAIN 02157000
  2129. * HEADER BLOCK FOR THE CLOBBERED CHAIN. 02158000
  2130. RTNCHKC EQU * 02159000
  2131. ST R15,FREESAVE+4*R15 SAVE 2/3 RETURN CODE 02160000
  2132. B CHECK GO TO CHECK AGAIN 02161000
  2133. EJECT 02162000
  2134. * COME HERE AFTER THE CHECK ROUTINE HAS COMPLETED, IF ANY ERROR HAS 02163000
  2135. * BEEN DETECTED SINCE DMSFRE WAS ENTERED. 02164000
  2136. ERCHK EQU * 02165000
  2137. CLC =F'20',FREESAVE+4*R15 ERROR CODE STILL > 20? 02166000
  2138. BNL ERCHK1 GO IF NOT 02167000
  2139. SPACE 02168000
  2140. * THAT MEANS THAT WE GOT AN UNEXPECTED ERROR, BUT ALL THE CHAINS 02169000
  2141. * ARE OK. WE TYPE OUT A SPECIAL ERROR MESSAGE FOR THIS. 02170000
  2142. DMSERR NUM=166,LET=T,DISP=SIO,TYPCALL=BALR,HALT=YES, *02171000
  2143. SUB=(DECA,FREESAVE+4*R15), *02172000
  2144. TEXT='UNEXPECTED ERROR IN FREE STORAGE MANAGEMENT ROUTIN*02173000
  2145. E (INTERNAL ERROR CODE ....). RE-IPL CMS' 02174000
  2146. SPACE 02175000
  2147. * CONTINUE PROCESSING IN CASE THE USER TURNS OFF THE WAIT STATE BIT. 02176000
  2148. MVC FREESAVE+4*R15(4),=A(CODE9) SET RETURN CODE TO 9 02177000
  2149. SPACE 2 02178000
  2150. ERCHK1 EQU * 02179000
  2151. TM FREEFLG1,FRF1C WAS THIS A CONDITIONAL CALL? 02180000
  2152. BO RETURNE JUST RETURN TO CALLER IF SO 02181000
  2153. TM FREEFLG1,FRF1B WAS 'TYPCALL=BALR' CODED? 02182000
  2154. BO ERCHK1B GO HANDLE THAT IF SO 02183000
  2155. SPACE 02184000
  2156. * FOR TYPCALL=SVC CALLS, WE SIMPLY SET THE ABEND CODE IN SVCSECT SO 02185000
  2157. * THAT DMSITS WILL ABEND BEFORE RETURNING TO THE CALLER. 02186000
  2158. L XR,ASVCSECT POINT TO SVCSECT 02187000
  2159. USING SVCSECT,XR 02188000
  2160. MVC SVCAB,=X'00F7' SET ABEND CODE TO 0F7 02189000
  2161. B RETURN AND JUST RETURN 02190000
  2162. SPACE 02191000
  2163. * FOR TYPCALL=BALR CALLS TO DMSFRE, WE ABEND BY PASSING CONTROL TO 02192000
  2164. * DMSABNGO. 02193000
  2165. ERCHK1B EQU * 02194000
  2166. L XR,=V(DMSABW) POINT TO DMSABN WORKSPACE 02195000
  2167. USING ABWSECT,XR 02196000
  2168. MVC ABNPSW(4),=A(X'0F8') SET ABEND CODE TO 0F8 02197000
  2169. MVC ABNPSW+4(4),FREESAVE+4*R14 PUT RETURN ADDR INTO PSW 02198000
  2170. MVC ABNREGS(4*16),FREESAVE COPY ABEND REGISTERS 02199000
  2171. LA R0,X'0F8' PUT ABEND CODE INTO REG 0 02200000
  2172. L R15,=V(DMSABNGO) POINT TO ABEND ROUTINE 02201000
  2173. BALR R14,R15 AND BRANCH TO IT 02202000
  2174. DC 4H'0' DMSABNGO SHOULDN'T RETURN 02203000
  2175. LTORG 02205000
  2176. DMSFRT 02207000
  2177. NUCON 02209000
  2178. DMSABW 02210000
  2179. SVCSAVE 02211000
  2180. SVCSECT 02212000
  2181. END 02213000
ibm/vm370-lib/cms/dmsfre.assemble_src.txt ยท Last modified: 2023/08/06 13:35 by Site Administrator