home *** CD-ROM | disk | FTP | other *** search
- //=====================================================================
- //
- // dpmish.h
- //
- // dos protected mode interface manager class
- //
- // Copyright (c) 1994, Kevin Morgan, All rights reserved.
- //
- // Parts of this were loosely based on routines
- // from Al Williams book: "DOS and Windows Protected Mode"
- //
- //=====================================================================
-
- #ifndef __DPMISH_H__
- #define __DPMISH_H__
- // dpmish.h
-
- #ifdef GLOBALS
- #define INIT(x) x
- #define GLOBAL
- #else
- #define INIT(x)
- #define GLOBAL extern
- #endif
-
- const int DPMI_OK = 0;
- const int DPMI_ERR = 1;
-
- typedef void interrupt (far *DpmiInterruptVector)(...);
-
- //---------------------------------------------------------------
- // Structure used with DPMI Simulate Dos Interrupt call
- //---------------------------------------------------------------
- struct DPMI_Regs {
- unsigned long edi;
- unsigned long esi;
- unsigned long ebp;
- unsigned long reserved;
- unsigned long ebx;
- unsigned long edx;
- unsigned long ecx;
- unsigned long eax;
- unsigned flags;
- unsigned es;
- unsigned ds;
- unsigned fs;
- unsigned gs;
- unsigned ip;
- unsigned cs;
- unsigned sp;
- unsigned ss;
- };
-
- //---------------------------------------------------------------
- // 15 | 14 | 13 | 12 | 11 10 9 8 | 7 | 6 5 | 4 | 3 2 1 | 0
- // G | D | 0 | AVL | L L L L | P | DPL. | S | TYPE | A
- // read write 16 bit data:
- // 0 0 0 0 0 0 0 0 1 1 0 1 001 0
- // stack data:
- // 0 0 0 0 0 0 0 0 1 1 0 1 011 0
- // executable code:
- // 0 0 0 0 0 0 0 0 1 1 0 1 101 0
- //---------------------------------------------------------------
-
- #define AccessRightsData 0xf2
- #define AccessRightsStack 0xf6
- #define AccessRightsCode 0xfa
-
- class DpmiApplication
- {
- unsigned errcode;
-
- public:
-
- DpmiApplication() { }
- virtual unsigned lastError() { return errcode; }
- virtual int init();
- virtual int present(void);
-
- virtual DpmiInterruptVector getRealVect(int);
- virtual void setRealVect(int intno, DpmiInterruptVector func);
-
- virtual DpmiInterruptVector getProtVect(int);
- virtual void setProtVect(int intno, DpmiInterruptVector func);
-
- virtual DpmiInterruptVector getExceptionHandler(int);
- virtual void setExceptionHandler(int intno, DpmiInterruptVector func);
-
- virtual int allocateRealCallback(DpmiInterruptVector,DPMI_Regs far *, DpmiInterruptVector&);
-
- virtual int getVersion(int& maj, int& min, int& flags);
- virtual int getCapabilities(char _far *buf, int& aFlags);
- void _far *makeDescriptor(unsigned segaddr);
- virtual int allocateMemory(long sz, long& addr, long & handle);
- virtual int lockMemory(long addr, long sz);
- virtual int unlockMemory(long addr, long sz);
- virtual int allocateLdtDescriptors(int nSelectors, unsigned& baseSelector);
- virtual int createAlias(unsigned csIn, unsigned& dsOut);
- virtual int freeSelector(unsigned selector);
- virtual int getSelectorIncrementValue(unsigned& incr);
- virtual int setSelectorBase(unsigned selector, long addr);
- virtual int setSelectorLimit(unsigned selector, long addr);
- virtual int setAccessRights(unsigned selector, int rights);
- virtual int getMappedMemory(long unsigned memSize, unsigned& selector, unsigned accessRights);
- virtual int simulateRealInterrupt(unsigned intno, DPMI_Regs *regs);
- virtual int allocateDosMemory(unsigned nPara, unsigned& para, unsigned& selector);
- virtual int mapDosMemory(unsigned para, unsigned long sz, unsigned& selector);
- virtual int freeDosMemory(unsigned selector);
- virtual void fail(const char *, ...);
- virtual void dosExit(int);
-
- };
-
-
- extern DpmiApplication Dpmi;
-
- #endif
-