home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l350 / 3.ddi / EXAMPLES / WINDOWS / DPMITELL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-04  |  4.2 KB  |  126 lines

  1. /* 
  2. DPMITELL.C
  3.  
  4. C:\WINDOC\EXAMPLES>dpmitell
  5. DPMI version number........................0.90
  6. DOS mode...................................Virtual 8086
  7. Virtual memory.............................Yes
  8. Master PIC base interrupt..................08
  9. Slave PIC base interrupt...................70
  10. Processor..................................80386
  11. Size of the linear address space...........11772K bytes
  12. Amount of free linear address space........6916K bytes
  13. Size of largest free linear block..........6616K bytes
  14. Size of the virtual memory swap file.......11772K bytes
  15. Total amount of physical memory............3884K bytes
  16. Amount of free physical memory.............1788K bytes
  17. */ 
  18.  
  19. #include <stdlib.h> 
  20. #include <stdio.h> 
  21. #include <string.h>
  22. #include <dos.h> 
  23. #include <pharlap.h>
  24. #include <pldos32.h>    // prototypes for _dos_ routines in DOS32.LIB
  25.  
  26. #ifdef __WATCOMC__
  27. #define _REGS REGS
  28. #define _int86 int386
  29. // Names of regs in _REGS union are nonstandard
  30. #define ax              eax 
  31. #define bx              ebx 
  32. #define di              edi 
  33. #endif
  34.  
  35. #define CLEAR(x)    memset(&x, 0, sizeof(x)) 
  36.  
  37. typedef struct 
  38.     unsigned dpmi_largest;      /* Largest available free block */ 
  39.     unsigned dpmi_unlock_max;   /* Max. unlock page count */ 
  40.     unsigned dpmi_lock_max;     /* Max. lock page count */ 
  41.     unsigned dpmi_lin_size;     /* Size in bytes of linear address space */ 
  42.     unsigned dpmi_unlock_count; /* Number of unlocked pages */ 
  43.     unsigned dpmi_fpage_count;  /* Number of free pages */ 
  44.     unsigned dpmi_ppage_count;  /* Number of physical pages */ 
  45.     unsigned dpmi_lin_free;     /* Free linear address page count */ 
  46.     unsigned dpmi_swapf_size;   /* Size of swap file in pages */ 
  47.     unsigned dpmi_rsrv[3]; 
  48. } DPMI_FREEMEM;  
  49.  
  50. int dpmi_present(void) 
  51.     CONFIG_INF config; 
  52.     UCHAR vmmname[256]; 
  53.     _dx_config_inf(&config, vmmname); 
  54.     return config.c_dpmif; 
  55.  
  56. void dpmi_version(unsigned *pmaj, unsigned *pmin,  
  57.                   unsigned *pflags, unsigned *pproc,  
  58.                   unsigned *ppicm, unsigned *ppics) 
  59.     union _REGS r; 
  60.     CLEAR(r); 
  61.     r.x.ax = 0x0400; 
  62.     _int86(0x31, &r, &r); 
  63.     *pmaj = (unsigned) r.h.ah; 
  64.     *pmin = (unsigned) r.h.al; 
  65.     *pflags = (unsigned) r.x.bx; 
  66.     *pproc = (unsigned) r.h.cl; 
  67.     *ppicm = (unsigned) r.h.dh; 
  68.     *ppics = (unsigned) r.h.dl; 
  69.  
  70. void dpmi_getmeminfo(DPMI_FREEMEM *pinfo) 
  71.     union _REGS r; 
  72.     CLEAR(r); 
  73.     r.x.di = (unsigned) pinfo; 
  74.     r.x.ax = 0x0500; 
  75.     _int86(0x31, &r, &r); 
  76.  
  77. void dpmi_info(void) 
  78.     DPMI_FREEMEM info; 
  79.     unsigned major, minor, mpic, spic, proc, flags; 
  80.  
  81.     dpmi_version(&major, &minor, &flags, &proc, &mpic, &spic); 
  82.     printf("DPMI version number........................%d.%d\n", 
  83.            major, minor); 
  84.     printf("DOS mode...................................%s\n", 
  85.            (flags & 0x2) ? "Real" : "Virtual 8086"); 
  86.     printf("Virtual memory.............................%s\n", 
  87.            (flags & 0x4) ? "Yes" : "No"); 
  88.     printf("Master PIC base interrupt..................%02X\n", 
  89.            mpic); 
  90.     printf("Slave PIC base interrupt...................%02X\n", 
  91.            spic); 
  92.     printf("Processor..................................80%d86\n", 
  93.            proc); 
  94.  
  95.     dpmi_getmeminfo(&info); 
  96.     printf("Size of the linear address space...........%ldK bytes\n", 
  97.            (info.dpmi_lin_size * 4096) / 1024); 
  98.     printf("Amount of free linear address space........%ldK bytes\n", 
  99.            (info.dpmi_lin_free * 4096) / 1024); 
  100.     printf("Size of largest free linear block..........%ldK bytes\n", 
  101.            info.dpmi_largest / 1024); 
  102.     printf("Size of the virtual memory swap file.......%ldK bytes\n", 
  103.            (info.dpmi_swapf_size * 4096) / 1024); 
  104.     printf("Total amount of physical memory............%ldK bytes\n", 
  105.            (info.dpmi_ppage_count * 4096) / 1024); 
  106.     printf("Amount of free physical memory.............%ldK bytes\n", 
  107.            (info.dpmi_fpage_count * 4096) / 1024); 
  108.  
  109. main() 
  110.     if (dpmi_present()) 
  111.         dpmi_info(); 
  112.     else 
  113.         puts("This program requires DPMI"); 
  114.     return 0; 
  115.