VSTORAGE.LST 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. Listing:
  2. 1 IMPLEMENTATION MODULE VStorage;
  3. 2 (*
  4. 3 * REPERTOIRE
  5. 4 * Release 1.6
  6. 5 * By Charles Bradford and Cole Brecheen
  7. 6 * (c) Copyright 1985-1992 PMI
  8. 7 * Green Bay, Wisconsin
  9. 8 * All rights reserved
  10. 9 * (414) 468-6040
  11. 10 *
  12. 11 * $Header: D:/logfiles/mods/vstorage.mov 1.6 10 Mar 1991 15:32:48 coleb $
  13. 12 *
  14. 13 *)
  15. 14
  16. 15
  17. 16 IMPORT ErrorManager;
  18. 17 IMPORT LowLevel;
  19. 18 IMPORT Numbers;
  20. 19 IMPORT StringIO;
  21. 20 IMPORT SYSTEM;
  22. 21 IMPORT FAPI;
  23. 22 IMPORT Storage;
  24. 23
  25. 24
  26. 25 VAR
  27. 26 Initialized : BOOLEAN;
  28. 27
  29. 28
  30. 29 TYPE
  31. 30 MemHandle = POINTER TO SYSTEM.ADDRESS;
  32. ***** ^ not supported yet
  33. 31
  34. 32 VAR
  35. 33 LockedHandles: CARDINAL;
  36. 34
  37. 35
  38. 36 PROCEDURE MemAvail(within: CARDINAL) : CARDINAL;
  39. 37 VAR
  40. 38 lasttry, lowtry, try : CARDINAL;
  41. 39 BEGIN
  42. 40 lasttry := 65535;
  43. 41 try := 65535;
  44. 42 lowtry := 0;
  45. 43 LOOP
  46. 44 WHILE (NOT DosAvail(try)) AND (try>16) DO
  47. ***** ^ undeclared identifier
  48. ***** ^ not supported yet
  49. 45 lasttry := try;
  50. 46 try := lowtry + (try-lowtry) DIV 2;
  51. 47 END;
  52. 48 IF ((lasttry-try) > within) AND (try>16) THEN
  53. 49 lowtry := try;
  54. 50 try := try + (lasttry-try) DIV 2;
  55. 51 ELSE
  56. 52 EXIT;
  57. 53 END;
  58. 54 END;
  59. 55 IF try<=16 THEN
  60. 56 RETURN 0;
  61. 57 ELSE
  62. 58 RETURN try;
  63. 59 END;
  64. 60 END MemAvail;
  65. ***** ^ not supported yet
  66. 61
  67. 62
  68. 63
  69. 64 PROCEDURE AvailDOS(): LONGINT;
  70. 65 (* Returns the # of bytes of DOS memory currently available; the
  71. 66 standard Storage module doesn't have such a function.*)
  72. 67 BEGIN
  73. 68 RETURN Numbers.Lc( MemAvail( 50) );
  74. ***** ^ not supported yet
  75. ***** ^ not supported yet
  76. ***** ^ not supported yet
  77. ***** ^ not supported yet
  78. 69 END AvailDOS;
  79. ***** ^ not supported yet
  80. 70
  81. 71
  82. 72 PROCEDURE IsAvailDOS( NumOfBytes: CARDINAL ): BOOLEAN;
  83. 73 BEGIN
  84. 74 RETURN DosAvail( NumOfBytes );
  85. ***** ^ undeclared identifier
  86. ***** ^ not supported yet
  87. 75 END IsAvailDOS;
  88. ***** ^ not supported yet
  89. 76
  90. 77 PROCEDURE AllocDOS( VAR handle: MemHandle; size: CARDINAL): BOOLEAN;
  91. 78 (* Allocate a block of DOS memory of given size in bytes, and
  92. 79 return a handle to that memory. *)
  93. 80 BEGIN
  94. 81 IF NOT DosAvail( size) THEN
  95. ***** ^ undeclared identifier
  96. ***** ^ not supported yet
  97. 82 RETURN FALSE;
  98. 83 ELSE
  99. 84 DosAlloc( handle, size);
  100. ***** ^ undeclared identifier
  101. ***** ^ not supported yet
  102. ***** ^ not supported yet
  103. 85 RETURN TRUE;
  104. 86 END;
  105. 87 END AllocDOS;
  106. ***** ^ not supported yet
  107. 88
  108. 89 PROCEDURE DeallocDOS( handle: MemHandle; size: CARDINAL);
  109. 90 (* Deallocate the block of DOS memory of specified size
  110. 91 associated with the given handle. *)
  111. 92 BEGIN
  112. 93 DosDealloc( handle, size);
  113. ***** ^ undeclared identifier
  114. ***** ^ not supported yet
  115. ***** ^ not supported yet
  116. 94 END DeallocDOS;
  117. ***** ^ not supported yet
  118. 95
  119. 96 PROCEDURE LockDOS( handle: MemHandle): SYSTEM.ADDRESS;
  120. ***** ^ not supported yet
  121. 97 (* Locks the DOS memory associated with the given handle into
  122. 98 real memory and returns the real starting address. *)
  123. 99 BEGIN
  124. 100 INC( LockedHandles );
  125. ***** ^ undeclared identifier
  126. ***** ^ not supported yet
  127. 101 IF LockedHandles > 4 THEN
  128. 102 ErrorManager.WARN( "Danger. More than 4 handles locked");
  129. ***** ^ not supported yet
  130. ***** ^ not supported yet
  131. ***** ^ not supported yet
  132. 103 END;
  133. 104 RETURN handle;
  134. ***** ^ not supported yet
  135. 105 END LockDOS;
  136. ***** ^ not supported yet
  137. 106
  138. 107 PROCEDURE UnLockDOS( handle: MemHandle);
  139. 108 (* Unlock the DOS memory associated with the given handle. *)
  140. 109 BEGIN
  141. 110 (* we don't need to do anything to unlock DOS memory *)
  142. 111 IF LockedHandles = 0 THEN
  143. 112 ErrorManager.WARN( "Handle not locked");
  144. ***** ^ not supported yet
  145. ***** ^ not supported yet
  146. ***** ^ not supported yet
  147. 113 ELSE
  148. 114 DEC( LockedHandles );
  149. ***** ^ undeclared identifier
  150. ***** ^ not supported yet
  151. 115 END;
  152. 116 END UnLockDOS;
  153. ***** ^ not supported yet
  154. 117
  155. 118 PROCEDURE ReadDOS( handle: MemHandle; offset: CARDINAL;
  156. 119 dest: SYSTEM.ADDRESS; size: CARDINAL);
  157. ***** ^ not supported yet
  158. 120 (* Moves size bytes starting at offset bytes from the beginning
  159. 121 of virtual memory for handle to real memory address dest. *)
  160. 122 BEGIN
  161. 123 LowLevel.Move( LowLevel.AddAddr(SYSTEM.ADDRESS( handle),
  162. ***** ^ not supported yet
  163. ***** ^ not supported yet
  164. ***** ^ not supported yet
  165. ***** ^ not supported yet
  166. ***** ^ not supported yet
  167. ***** ^ not supported yet
  168. ***** ^ not supported yet
  169. 124 offset), dest, size);
  170. ***** ^ not supported yet
  171. ***** ^ not supported yet
  172. ***** ^ not supported yet
  173. 125 END ReadDOS;
  174. ***** ^ not supported yet
  175. 126
  176. 127 PROCEDURE WriteDOS( handle: MemHandle; offset: CARDINAL;
  177. 128 source: SYSTEM.ADDRESS; size: CARDINAL);
  178. ***** ^ not supported yet
  179. 129 (* Moves size bytes from real memory address source to offset
  180. 130 bytes from the beginning of virtual memory for handle. *)
  181. 131 BEGIN
  182. 132 LowLevel.Move( source, LowLevel.AddAddr(SYSTEM.ADDRESS(
  183. ***** ^ not supported yet
  184. ***** ^ not supported yet
  185. ***** ^ not supported yet
  186. ***** ^ not supported yet
  187. ***** ^ not supported yet
  188. ***** ^ not supported yet
  189. ***** ^ not supported yet
  190. 133 handle), offset), size);
  191. ***** ^ not supported yet
  192. ***** ^ not supported yet
  193. ***** ^ not supported yet
  194. 134 END WriteDOS;
  195. ***** ^ not supported yet
  196. 135
  197. 136 PROCEDURE NotInEms( TheHandle: MemHandle ): BOOLEAN;
  198. 137 BEGIN
  199. 138 RETURN FALSE;
  200. 139 END NotInEms;
  201. ***** ^ not supported yet
  202. 140
  203. 141 PROCEDURE NotUsing(): BOOLEAN;
  204. 142 BEGIN
  205. 143 RETURN FALSE;
  206. 144 END NotUsing;
  207. ***** ^ not supported yet
  208. 145
  209. 146 PROCEDURE NilHandle( VAR TheHandle: MemHandle );
  210. 147 BEGIN
  211. 148 TheHandle := NIL;
  212. ***** ^ not supported yet
  213. 149 END NilHandle;
  214. ***** ^ not supported yet
  215. 150
  216. 151 PROCEDURE SameHandle( handle1, handle2: MemHandle ): BOOLEAN;
  217. 152 BEGIN
  218. 153 RETURN handle1 = handle2;
  219. ***** ^ not supported yet
  220. ***** ^ not supported yet
  221. 154 END SameHandle;
  222. ***** ^ not supported yet
  223. 155
  224. 156 PROCEDURE Reminder1( dumc: CARDINAL): BOOLEAN;
  225. 157 BEGIN
  226. 158 StringIO.WriteStr( StringIO.outp,
  227. ***** ^ not supported yet
  228. ***** ^ not supported yet
  229. ***** ^ not supported yet
  230. ***** ^ not supported yet
  231. 159 "Please assign VStorage.DosAvail (IMPORT Init...;).");
  232. ***** ^ not supported yet
  233. 160 HALT;
  234. ***** ^ undeclared identifier
  235. 161 RETURN FALSE;
  236. 162 END Reminder1;
  237. ***** ^ not supported yet
  238. 163
  239. 164 PROCEDURE Reminder2( VAR dumadr: SYSTEM.ADDRESS; dumsize: CARDINAL );
  240. ***** ^ not supported yet
  241. 165 BEGIN
  242. 166 StringIO.WriteStr( StringIO.outp,
  243. ***** ^ not supported yet
  244. ***** ^ not supported yet
  245. ***** ^ not supported yet
  246. ***** ^ not supported yet
  247. 167 "Please assign a DOS memory allocator to VStorage.DosAlloc (IMPORT Init...;).");
  248. ***** ^ not supported yet
  249. 168 HALT;
  250. ***** ^ undeclared identifier
  251. 169 END Reminder2;
  252. ***** ^ not supported yet
  253. 170
  254. 171 PROCEDURE Reminder3( VAR dumadr: SYSTEM.ADDRESS; dumsize: CARDINAL );
  255. ***** ^ not supported yet
  256. 172 BEGIN
  257. 173 StringIO.WriteStr( StringIO.outp, "Please assign VStorage.DosDealloc.");
  258. ***** ^ not supported yet
  259. ***** ^ not supported yet
  260. ***** ^ not supported yet
  261. ***** ^ not supported yet
  262. ***** ^ not supported yet
  263. 174 HALT;
  264. ***** ^ undeclared identifier
  265. 175 END Reminder3;
  266. ***** ^ not supported yet
  267. 176
  268. 177 PROCEDURE AvailShell( dumc: CARDINAL): BOOLEAN;
  269. 178 VAR
  270. 179 errcode: CARDINAL;
  271. 180 machineMode:CARDINAL;
  272. 181 BEGIN
  273. 182 machineMode:=0;
  274. 183 errcode := FAPI.DOSGETMACHINEMODE(SYSTEM.ADR(machineMode));
  275. ***** ^ not supported yet
  276. ***** ^ not supported yet
  277. ***** ^ not supported yet
  278. ***** ^ not supported yet
  279. ***** ^ not supported yet
  280. 184 IF machineMode = FAPI.MODE_REAL THEN
  281. ***** ^ not supported yet
  282. ***** ^ not supported yet
  283. 185 RETURN Storage.Available( dumc );
  284. ***** ^ not supported yet
  285. ***** ^ not supported yet
  286. ***** ^ not supported yet
  287. 186 ELSE
  288. 187 RETURN TRUE;
  289. 188 END;
  290. 189 END AvailShell;
  291. ***** ^ not supported yet
  292. 190
  293. 191 PROCEDURE AllocShell( VAR dumadr: SYSTEM.ADDRESS; dumsize: CARDINAL );
  294. ***** ^ not supported yet
  295. 192 BEGIN
  296. 193 Storage.ALLOCATE( dumadr, dumsize );
  297. ***** ^ not supported yet
  298. ***** ^ not supported yet
  299. ***** ^ not supported yet
  300. ***** ^ not supported yet
  301. 194 END AllocShell;
  302. ***** ^ not supported yet
  303. 195
  304. 196 PROCEDURE DeallocShell( VAR dumadr: SYSTEM.ADDRESS; dumsize: CARDINAL );
  305. ***** ^ not supported yet
  306. 197 BEGIN
  307. 198 Storage.DEALLOCATE( dumadr, dumsize );
  308. ***** ^ not supported yet
  309. ***** ^ not supported yet
  310. ***** ^ not supported yet
  311. ***** ^ not supported yet
  312. 199 END DeallocShell;
  313. ***** ^ not supported yet
  314. 200
  315. 201
  316. 202 PROCEDURE Init();
  317. 203 BEGIN
  318. 204 IF Initialized THEN
  319. 205 RETURN;
  320. 206 ELSE
  321. 207 Initialized := TRUE;
  322. 208 END;
  323. 209
  324. 210 ErrorManager.Init();
  325. ***** ^ not supported yet
  326. ***** ^ not supported yet
  327. ***** ^ not supported yet
  328. 211 LowLevel.Init();
  329. ***** ^ not supported yet
  330. ***** ^ not supported yet
  331. ***** ^ not supported yet
  332. 212 Numbers.Init();
  333. ***** ^ not supported yet
  334. ***** ^ not supported yet
  335. ***** ^ not supported yet
  336. 213 StringIO.Init();
  337. ***** ^ not supported yet
  338. ***** ^ not supported yet
  339. ***** ^ not supported yet
  340. 214 (*EntryDiag:
  341. 215 StringIO.WriteEol( 1, 'Entering VStorage' );
  342. 216 :EntryDiag*)
  343. 217
  344. 218 LockedHandles := 0;
  345. 219 AvailMem := AvailDOS;
  346. ***** ^ undeclared identifier
  347. ***** ^ not supported yet
  348. 220 InEms := NotInEms;
  349. ***** ^ undeclared identifier
  350. ***** ^ not supported yet
  351. 221 IsAvailable := IsAvailDOS;
  352. ***** ^ undeclared identifier
  353. ***** ^ not supported yet
  354. 222 AllocMem := AllocDOS;
  355. ***** ^ undeclared identifier
  356. ***** ^ not supported yet
  357. 223 DeallocMem := DeallocDOS;
  358. ***** ^ undeclared identifier
  359. ***** ^ not supported yet
  360. 224 LockMem := LockDOS;
  361. ***** ^ undeclared identifier
  362. ***** ^ not supported yet
  363. 225 UnLockMem := UnLockDOS;
  364. ***** ^ undeclared identifier
  365. ***** ^ not supported yet
  366. 226 ReadMem := ReadDOS;
  367. ***** ^ undeclared identifier
  368. ***** ^ not supported yet
  369. 227 WriteMem := WriteDOS;
  370. ***** ^ undeclared identifier
  371. ***** ^ not supported yet
  372. 228 UsingEms := NotUsing;
  373. ***** ^ undeclared identifier
  374. ***** ^ not supported yet
  375. 229 DosAvail := AvailShell;
  376. ***** ^ undeclared identifier
  377. ***** ^ not supported yet
  378. 230 DosAlloc := AllocShell;
  379. ***** ^ undeclared identifier
  380. ***** ^ not supported yet
  381. 231 DosDealloc := DeallocShell;
  382. ***** ^ undeclared identifier
  383. ***** ^ not supported yet
  384. 232
  385. 233 (*EntryDiag:
  386. 234 StringIO.WriteEol( 1, 'Exiting VStorage' );
  387. 235 :EntryDiag*)
  388. 236
  389. 237 END Init;
  390. ***** ^ not supported yet
  391. 238
  392. 239 BEGIN
  393. 240 Initialized := FALSE;
  394. 241 Init();
  395. ***** ^ not supported yet
  396. ***** ^ not supported yet
  397. 242 END VStorage.
  398. ***** ^ not supported yet
  399. 155 errors