Listing: 1 IMPLEMENTATION MODULE VStorage; 2 (* 3 * REPERTOIRE 4 * Release 1.6 5 * By Charles Bradford and Cole Brecheen 6 * (c) Copyright 1985-1992 PMI 7 * Green Bay, Wisconsin 8 * All rights reserved 9 * (414) 468-6040 10 * 11 * $Header: D:/logfiles/mods/vstorage.mov 1.6 10 Mar 1991 15:32:48 coleb $ 12 * 13 *) 14 15 16 IMPORT ErrorManager; 17 IMPORT LowLevel; 18 IMPORT Numbers; 19 IMPORT StringIO; 20 IMPORT SYSTEM; 21 IMPORT FAPI; 22 IMPORT Storage; 23 24 25 VAR 26 Initialized : BOOLEAN; 27 28 29 TYPE 30 MemHandle = POINTER TO SYSTEM.ADDRESS; ***** ^ not supported yet 31 32 VAR 33 LockedHandles: CARDINAL; 34 35 36 PROCEDURE MemAvail(within: CARDINAL) : CARDINAL; 37 VAR 38 lasttry, lowtry, try : CARDINAL; 39 BEGIN 40 lasttry := 65535; 41 try := 65535; 42 lowtry := 0; 43 LOOP 44 WHILE (NOT DosAvail(try)) AND (try>16) DO ***** ^ undeclared identifier ***** ^ not supported yet 45 lasttry := try; 46 try := lowtry + (try-lowtry) DIV 2; 47 END; 48 IF ((lasttry-try) > within) AND (try>16) THEN 49 lowtry := try; 50 try := try + (lasttry-try) DIV 2; 51 ELSE 52 EXIT; 53 END; 54 END; 55 IF try<=16 THEN 56 RETURN 0; 57 ELSE 58 RETURN try; 59 END; 60 END MemAvail; ***** ^ not supported yet 61 62 63 64 PROCEDURE AvailDOS(): LONGINT; 65 (* Returns the # of bytes of DOS memory currently available; the 66 standard Storage module doesn't have such a function.*) 67 BEGIN 68 RETURN Numbers.Lc( MemAvail( 50) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 69 END AvailDOS; ***** ^ not supported yet 70 71 72 PROCEDURE IsAvailDOS( NumOfBytes: CARDINAL ): BOOLEAN; 73 BEGIN 74 RETURN DosAvail( NumOfBytes ); ***** ^ undeclared identifier ***** ^ not supported yet 75 END IsAvailDOS; ***** ^ not supported yet 76 77 PROCEDURE AllocDOS( VAR handle: MemHandle; size: CARDINAL): BOOLEAN; 78 (* Allocate a block of DOS memory of given size in bytes, and 79 return a handle to that memory. *) 80 BEGIN 81 IF NOT DosAvail( size) THEN ***** ^ undeclared identifier ***** ^ not supported yet 82 RETURN FALSE; 83 ELSE 84 DosAlloc( handle, size); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 85 RETURN TRUE; 86 END; 87 END AllocDOS; ***** ^ not supported yet 88 89 PROCEDURE DeallocDOS( handle: MemHandle; size: CARDINAL); 90 (* Deallocate the block of DOS memory of specified size 91 associated with the given handle. *) 92 BEGIN 93 DosDealloc( handle, size); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 94 END DeallocDOS; ***** ^ not supported yet 95 96 PROCEDURE LockDOS( handle: MemHandle): SYSTEM.ADDRESS; ***** ^ not supported yet 97 (* Locks the DOS memory associated with the given handle into 98 real memory and returns the real starting address. *) 99 BEGIN 100 INC( LockedHandles ); ***** ^ undeclared identifier ***** ^ not supported yet 101 IF LockedHandles > 4 THEN 102 ErrorManager.WARN( "Danger. More than 4 handles locked"); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 103 END; 104 RETURN handle; ***** ^ not supported yet 105 END LockDOS; ***** ^ not supported yet 106 107 PROCEDURE UnLockDOS( handle: MemHandle); 108 (* Unlock the DOS memory associated with the given handle. *) 109 BEGIN 110 (* we don't need to do anything to unlock DOS memory *) 111 IF LockedHandles = 0 THEN 112 ErrorManager.WARN( "Handle not locked"); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 113 ELSE 114 DEC( LockedHandles ); ***** ^ undeclared identifier ***** ^ not supported yet 115 END; 116 END UnLockDOS; ***** ^ not supported yet 117 118 PROCEDURE ReadDOS( handle: MemHandle; offset: CARDINAL; 119 dest: SYSTEM.ADDRESS; size: CARDINAL); ***** ^ not supported yet 120 (* Moves size bytes starting at offset bytes from the beginning 121 of virtual memory for handle to real memory address dest. *) 122 BEGIN 123 LowLevel.Move( LowLevel.AddAddr(SYSTEM.ADDRESS( handle), ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 124 offset), dest, size); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 125 END ReadDOS; ***** ^ not supported yet 126 127 PROCEDURE WriteDOS( handle: MemHandle; offset: CARDINAL; 128 source: SYSTEM.ADDRESS; size: CARDINAL); ***** ^ not supported yet 129 (* Moves size bytes from real memory address source to offset 130 bytes from the beginning of virtual memory for handle. *) 131 BEGIN 132 LowLevel.Move( source, LowLevel.AddAddr(SYSTEM.ADDRESS( ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 133 handle), offset), size); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 134 END WriteDOS; ***** ^ not supported yet 135 136 PROCEDURE NotInEms( TheHandle: MemHandle ): BOOLEAN; 137 BEGIN 138 RETURN FALSE; 139 END NotInEms; ***** ^ not supported yet 140 141 PROCEDURE NotUsing(): BOOLEAN; 142 BEGIN 143 RETURN FALSE; 144 END NotUsing; ***** ^ not supported yet 145 146 PROCEDURE NilHandle( VAR TheHandle: MemHandle ); 147 BEGIN 148 TheHandle := NIL; ***** ^ not supported yet 149 END NilHandle; ***** ^ not supported yet 150 151 PROCEDURE SameHandle( handle1, handle2: MemHandle ): BOOLEAN; 152 BEGIN 153 RETURN handle1 = handle2; ***** ^ not supported yet ***** ^ not supported yet 154 END SameHandle; ***** ^ not supported yet 155 156 PROCEDURE Reminder1( dumc: CARDINAL): BOOLEAN; 157 BEGIN 158 StringIO.WriteStr( StringIO.outp, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 159 "Please assign VStorage.DosAvail (IMPORT Init...;)."); ***** ^ not supported yet 160 HALT; ***** ^ undeclared identifier 161 RETURN FALSE; 162 END Reminder1; ***** ^ not supported yet 163 164 PROCEDURE Reminder2( VAR dumadr: SYSTEM.ADDRESS; dumsize: CARDINAL ); ***** ^ not supported yet 165 BEGIN 166 StringIO.WriteStr( StringIO.outp, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 167 "Please assign a DOS memory allocator to VStorage.DosAlloc (IMPORT Init...;)."); ***** ^ not supported yet 168 HALT; ***** ^ undeclared identifier 169 END Reminder2; ***** ^ not supported yet 170 171 PROCEDURE Reminder3( VAR dumadr: SYSTEM.ADDRESS; dumsize: CARDINAL ); ***** ^ not supported yet 172 BEGIN 173 StringIO.WriteStr( StringIO.outp, "Please assign VStorage.DosDealloc."); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 174 HALT; ***** ^ undeclared identifier 175 END Reminder3; ***** ^ not supported yet 176 177 PROCEDURE AvailShell( dumc: CARDINAL): BOOLEAN; 178 VAR 179 errcode: CARDINAL; 180 machineMode:CARDINAL; 181 BEGIN 182 machineMode:=0; 183 errcode := FAPI.DOSGETMACHINEMODE(SYSTEM.ADR(machineMode)); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 184 IF machineMode = FAPI.MODE_REAL THEN ***** ^ not supported yet ***** ^ not supported yet 185 RETURN Storage.Available( dumc ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 186 ELSE 187 RETURN TRUE; 188 END; 189 END AvailShell; ***** ^ not supported yet 190 191 PROCEDURE AllocShell( VAR dumadr: SYSTEM.ADDRESS; dumsize: CARDINAL ); ***** ^ not supported yet 192 BEGIN 193 Storage.ALLOCATE( dumadr, dumsize ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 194 END AllocShell; ***** ^ not supported yet 195 196 PROCEDURE DeallocShell( VAR dumadr: SYSTEM.ADDRESS; dumsize: CARDINAL ); ***** ^ not supported yet 197 BEGIN 198 Storage.DEALLOCATE( dumadr, dumsize ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 199 END DeallocShell; ***** ^ not supported yet 200 201 202 PROCEDURE Init(); 203 BEGIN 204 IF Initialized THEN 205 RETURN; 206 ELSE 207 Initialized := TRUE; 208 END; 209 210 ErrorManager.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 211 LowLevel.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 212 Numbers.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 213 StringIO.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 214 (*EntryDiag: 215 StringIO.WriteEol( 1, 'Entering VStorage' ); 216 :EntryDiag*) 217 218 LockedHandles := 0; 219 AvailMem := AvailDOS; ***** ^ undeclared identifier ***** ^ not supported yet 220 InEms := NotInEms; ***** ^ undeclared identifier ***** ^ not supported yet 221 IsAvailable := IsAvailDOS; ***** ^ undeclared identifier ***** ^ not supported yet 222 AllocMem := AllocDOS; ***** ^ undeclared identifier ***** ^ not supported yet 223 DeallocMem := DeallocDOS; ***** ^ undeclared identifier ***** ^ not supported yet 224 LockMem := LockDOS; ***** ^ undeclared identifier ***** ^ not supported yet 225 UnLockMem := UnLockDOS; ***** ^ undeclared identifier ***** ^ not supported yet 226 ReadMem := ReadDOS; ***** ^ undeclared identifier ***** ^ not supported yet 227 WriteMem := WriteDOS; ***** ^ undeclared identifier ***** ^ not supported yet 228 UsingEms := NotUsing; ***** ^ undeclared identifier ***** ^ not supported yet 229 DosAvail := AvailShell; ***** ^ undeclared identifier ***** ^ not supported yet 230 DosAlloc := AllocShell; ***** ^ undeclared identifier ***** ^ not supported yet 231 DosDealloc := DeallocShell; ***** ^ undeclared identifier ***** ^ not supported yet 232 233 (*EntryDiag: 234 StringIO.WriteEol( 1, 'Exiting VStorage' ); 235 :EntryDiag*) 236 237 END Init; ***** ^ not supported yet 238 239 BEGIN 240 Initialized := FALSE; 241 Init(); ***** ^ not supported yet ***** ^ not supported yet 242 END VStorage. ***** ^ not supported yet 155 errors