home *** CD-ROM | disk | FTP | other *** search
- /*
-
- NOTICE:
-
- This code released into public domain with VEMM.EXE,
- executable version of this and other subroutines.
-
- For evaluation and documentation purposes only.
-
- */
-
- #include "vemm.h"
- #include "regs.h"
-
- /*
-
-
- VCMGR Copyright (C) 1987, Marty Ross
-
-
- This is the VEMM resident manager, using interrupt 0x67
- He intercepts and satisfies a subset of LIM/EMS requests.
-
-
- Functions supported: (function name passed in ah)
-
- bias = 0x3F (this value added to cmd name)
-
- name = (following functions supported)
- (in all cases, AH is return status: CHECK IT!)
-
- 0 - Internal diagnostic. Prints current array(s).
-
- 1 - Get Status. Returns status code in AL.
- 2 - Get Page Frame Address. Returns PFBA in BX.
- 3 - Get Unallocated Page Count. Returns DX=total, BX=free
- 4 - Allocate Pages. Input BX, output DX.
- 5 - Map Handle Page. Input BX, AL, DX.
- 6 - Deallocate Pages. Input is DX.
- 7 - Get EMM Version. Output in AX
-
- 12 - Get EMM Handle Count. Output BX.
- 13 - Get EMM Handle Pages. Input DX, output BX.
- 14 - Get ALL EMM Handle Pages. Input ES:DI, output BX.
-
-
- NOTE: In this version, the memory handle '0' is the 'system pool'
- where all the free pages are stored. Therefore, the user
- will NEVER be handed a memory handle of zero. This is
- NOT the case in an AST RAMPAGE(tm) board: it WILL return
- the first memoryhandle as zero (so don't count on this
- "feature"-- always check the function return code in AH).
- Later, we will mask out our system handle from the user.
-
- */
-
- #define CMD_BIAS 0x3F
- #define CMD_NAME(f) (CMD_BIAS+f)
-
- extern union REGS vr ;
- extern struct SREGS vsr ;
-
- extern struct vopts vo ;
- extern struct vstat vs ;
-
- vcmgr()
- {
-
- if (vo.debug && !vo.quiet) {
- printf("vcmgr(ax=%04x, bx=%04x, dx=%04x):\n", vr.x.ax, vr.x.bx, vr.x.dx);
- }
-
- switch(vr.h.ah) { /* function code is in ah, select on it */
-
- case CMD_NAME(0): /* Print internal map */
- if (vr.h.al==0) vpgmap() ;
- else if (vr.h.al==1) prt_file() ;
- else if (vr.h.al==2) prt_errs() ;
- else if (vr.h.al==3) vpwmap() ;
- else if (vr.h.al==0xff) vrst() ;
- vr.h.ah = (char) 0 ;
- break;
-
- case CMD_NAME(1): /* Get Status */
- vr.h.ah = vs.stat ;
- vs.stat = (char) 0 ; /* Reset also */
- break;
-
- case CMD_NAME(2): /* Get PFBA */
- vr.x.bx = vs.pfba ;
- vr.h.ah = (char) 0 ;
- break;
-
- case CMD_NAME(3): /* Get Unallocate Page Count */
- vr.x.dx = vs.pages ;
- vr.x.bx = vs.vmpgtbl[0][0] ;
- vr.h.ah = (char) 0 ;
- break;
-
- case CMD_NAME(4): /* Allocate Pages */
- vr.h.ah = (char) vcaloc(vr.x.bx, &vr.x.dx) ;
- break;
-
- case CMD_NAME(5): /* Map Handle Pages */
- vr.h.ah = (char)
- vcmap( vr.x.bx, vr.h.al, vr.x.dx ) ;
- break;
-
- case CMD_NAME(6): /* Deallocate Pages */
- vr.h.ah = (char) vcdaloc(vr.x.dx) ;
- break;
-
- case CMD_NAME(7): /* Get EMM Version */
- vr.h.al = vs.ver ;
- vr.h.ah = (char) 0 ;
- break;
-
- case CMD_NAME(12): /* Get EMM Handle Count */
- vr.h.ah = (char)
- gaehp(0, vsr.es, vr.x.di, &vr.x.bx) ;
- break;
-
-
- case CMD_NAME(13): /* Get EMM Handle Pages */
- vr.h.ah = (char) gehp(vr.x.dx,&vr.x.bx) ;
- break;
-
-
- case CMD_NAME(14): /* Get ALL EMM Handle Pages */
- vr.h.ah = (char)
- gaehp(1, vsr.es, vr.x.di, &vr.x.bx) ;
- break;
-
- default: /* Unknown Command */
- if (vo.debug) {
- printf("VEMM: Invalid cmd: %02x.\n",
- vr.h.ah) ;
- }
- vr.h.ah = (char) 0x84 ;
- break;
- }
-
- }
-