Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!lll-lcc!pyramid!amdahl!bnrmtv!connery From: connery@bnrmtv.UUCP Newsgroups: comp.sys.ibm.pc Subject: Re: Creating RAM Disks on the fly. Message-ID: <1585@bnrmtv.UUCP> Date: Tue, 7-Apr-87 22:29:07 EST Article-I.D.: bnrmtv.1585 Posted: Tue Apr 7 22:29:07 1987 Date-Received: Sat, 11-Apr-87 05:00:29 EST References: <3347@vrdxhq.UUCP> Organization: Bell Northern Research, Mtn. View, CA Lines: 63 > > I am looking for a way to generate a RAM disk from within a program, > and then release it prior to exiting the same program. > > Any information on the following would be appreciated : > > 1) How can the last drive assigned be found ? (If A: and B: are > floppies, and C: and D: are the hard drive and an existing RAM disk, > how do I find out that the next available drive is E: ??) > > 2) How can I use this info (#1 above) and allocate RAM to create a > RAM disk (E: in this example) for some arbitrary amount of memory ? > > 3) How do I get rid of the RAM disk and return the RAM to the > system when I am done using it ? > > 4) How do I get the amount of RAM memory available in the system ? > I doubt this is what you really want to do. It would be better in most instances to do the paging/swapping yourself in high memory. However, assuming this is really what you want to do: 1) You can find the value of LASTDRIVE, the last legal drive number by calling INT 21H function 0EH, set default disk drive. If you set AH to the current drive so that it effectively does nothing, it returns AL=LASTDRIVE. ie: mov ah,19h int 21h ; gets al=current drive mov dl,al mov ah,0Eh int 21h ; sets current drive from dl returns AL=LASTDRIVE. It would be E: or 5 if pre-DOS 3.0 or if the user has no LASTDRIVE statement in CONFIG.SYS. Skipping over A: and B: which are always used, you can determine whether a given drive is in use (real or redirected) by calling INT 21H function 36H with DL=the drive number (starting at 1 this time). If the value returned in AX is 0xFFFF then the drive is not in use. This process can take a little bit of time if you have a hard disk, and generally you want to start AFTER any hard disks, which can be obtained through the BIOS equipment check, but this should be enough to get you going. 2) Buy a good book on TSRs. This is much too complex to explain here. Basically you are going to hook the DOS disk stuff and handle it in memory. There is source for VDISK.ASM on the second DOS disk which should give you a start, but it's a device driver which won't do you much good. If you can find source for one of the freeware TSR VDISKs that would probably get you pretty close. 3) See 2) 4) This is easy. Use INT 21H function 62H to get the PSP address. Its returned in BX. This is the paragraph where this program loaded, ie. the start of available memory. At offset 2 in the PSP is a word containing the top of memory segment address. Subtract the two to get the amount of RAM (remember that these are in paragraphs). ...Glenn -- Glenn Connery, Bell Northern Research, Mountain View, CA {hplabs,amdahl,3comvax}!bnrmtv!connery