home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / tvision / dpmi / inc / dpmish.h < prev   
Encoding:
C/C++ Source or Header  |  1994-05-28  |  3.9 KB  |  119 lines

  1. //=====================================================================
  2. //
  3. //  dpmish.h
  4. //
  5. //  dos protected mode interface manager class
  6. //
  7. //  Copyright (c) 1994, Kevin Morgan, All rights reserved.
  8. //
  9. //  Parts of this were loosely based on routines 
  10. //  from Al Williams book: "DOS and Windows Protected Mode"
  11. //
  12. //=====================================================================
  13.  
  14. #ifndef __DPMISH_H__
  15. #define __DPMISH_H__
  16. // dpmish.h
  17.  
  18. #ifdef GLOBALS
  19. #define INIT(x) x
  20. #define GLOBAL
  21. #else
  22. #define INIT(x)
  23. #define GLOBAL  extern
  24. #endif
  25.  
  26. const int DPMI_OK  = 0;
  27. const int DPMI_ERR = 1;
  28.  
  29. typedef void interrupt (far *DpmiInterruptVector)(...);
  30.  
  31. //---------------------------------------------------------------
  32. // Structure used with DPMI Simulate Dos Interrupt call
  33. //---------------------------------------------------------------
  34. struct DPMI_Regs {
  35.     unsigned long edi;
  36.     unsigned long esi;
  37.     unsigned long ebp;
  38.     unsigned long reserved;
  39.     unsigned long ebx;
  40.     unsigned long edx;
  41.     unsigned long ecx;
  42.     unsigned long eax;
  43.     unsigned flags;
  44.     unsigned es;
  45.     unsigned ds;
  46.     unsigned fs;
  47.     unsigned gs;
  48.     unsigned ip;
  49.     unsigned cs;
  50.     unsigned sp;
  51.     unsigned ss;
  52. };
  53.  
  54. //---------------------------------------------------------------
  55. //  15 | 14 | 13 | 12  | 11 10  9  8 |  7 | 6  5 | 4 | 3 2 1 | 0
  56. //   G |  D |  0 | AVL |  L  L  L  L |  P | DPL. | S | TYPE  | A
  57. //  read write 16 bit data:
  58. //    0   0    0   0      0 0 0 0       1   1 0    1   001 0
  59. //  stack data:
  60. //    0   0    0   0      0 0 0 0       1   1 0    1   011 0
  61. //  executable code:
  62. //    0   0    0   0      0 0 0 0       1   1 0    1   101 0
  63. //---------------------------------------------------------------
  64.  
  65. #define AccessRightsData    0xf2
  66. #define AccessRightsStack   0xf6
  67. #define AccessRightsCode    0xfa
  68.  
  69. class DpmiApplication
  70. {
  71.     unsigned errcode;
  72.  
  73.     public:
  74.  
  75.         DpmiApplication() { }
  76.         virtual unsigned lastError() { return errcode; }
  77.         virtual int init();
  78.         virtual int present(void);
  79.  
  80.         virtual DpmiInterruptVector getRealVect(int);
  81.         virtual void setRealVect(int intno, DpmiInterruptVector func);
  82.  
  83.         virtual DpmiInterruptVector getProtVect(int);
  84.         virtual void setProtVect(int intno, DpmiInterruptVector func);
  85.  
  86.         virtual DpmiInterruptVector getExceptionHandler(int);
  87.         virtual void setExceptionHandler(int intno, DpmiInterruptVector func);
  88.  
  89.         virtual int allocateRealCallback(DpmiInterruptVector,DPMI_Regs far *, DpmiInterruptVector&);
  90.  
  91.         virtual int getVersion(int& maj, int& min, int& flags);
  92.         virtual int getCapabilities(char _far *buf, int& aFlags);
  93.         void _far *makeDescriptor(unsigned segaddr);
  94.         virtual int allocateMemory(long sz,  long& addr, long & handle);
  95.         virtual int lockMemory(long addr, long sz);
  96.         virtual int unlockMemory(long addr, long sz);
  97.         virtual int allocateLdtDescriptors(int nSelectors,  unsigned& baseSelector);
  98.         virtual int createAlias(unsigned csIn, unsigned& dsOut);
  99.         virtual int freeSelector(unsigned selector);
  100.         virtual int getSelectorIncrementValue(unsigned& incr);
  101.         virtual int setSelectorBase(unsigned selector,  long addr);
  102.         virtual int setSelectorLimit(unsigned selector,  long addr);
  103.         virtual int setAccessRights(unsigned selector,  int rights);
  104.         virtual int getMappedMemory(long unsigned memSize, unsigned& selector, unsigned accessRights);
  105.         virtual int simulateRealInterrupt(unsigned intno, DPMI_Regs *regs);
  106.         virtual int allocateDosMemory(unsigned nPara, unsigned& para, unsigned& selector);
  107.         virtual int mapDosMemory(unsigned para, unsigned long sz, unsigned& selector);
  108.         virtual int freeDosMemory(unsigned selector);
  109.         virtual void fail(const char *, ...);
  110.         virtual void dosExit(int);
  111.  
  112. };
  113.  
  114.  
  115. extern DpmiApplication Dpmi;
  116.  
  117. #endif
  118.  
  119.