home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / oclsrc15.zip / OCL / Include / OMemu.h < prev    next >
C/C++ Source or Header  |  1996-08-12  |  14KB  |  280 lines

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // (c) Glenn Brew, Cook, Benjamin Stein 1995
  4. // All Rights Reserved
  5. // OMemu.h
  6.  
  7. /*
  8.  * Redistribution and use in source and binary forms, with or without
  9.  * modification, are permitted provided that the following conditions
  10.  * are met:
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  14.  *    endorse or promote products derived from this software
  15.  *    without specific prior written permission.
  16.  * 3. See OCL.INF for a detailed copyright notice.
  17.  *
  18.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  19.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  22.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28.  * SUCH DAMAGE.
  29.  */
  30.  
  31. // $Header: W:/Projects/OCL/Include/rcs/OMemu.h 1.50 1996/08/11 23:47:20 B.STEIN Release $
  32.  
  33. #ifndef OMEMU_H_INCLUDED
  34.   #define OMEMU_H_INCLUDED
  35.  
  36.  
  37. // The following information is taken from OS20MEMU.H
  38. // written by Glenn Brew & Ross Cook and delivered with OS2-MEMU 1.02.
  39. // OMemu uses 32bit calls rather than their 16bit counterparts
  40. // documented by the authors of OS2-MEMU.
  41.  
  42.  
  43. // Purpose:  Header file and definition of variables returned from the       
  44. //           OS20MEMU dynalink - OS20MEMU.DLL                                 
  45. //  Author:  Glenn Brew & Ross Cook                                            
  46.  
  47.  
  48. #pragma pack(1)
  49.  
  50. #define OS20MEMU_VERSION        0x0001  // Version Number
  51. #define ERROR_UNKNOWN_KERNEL    0xffff
  52. #define ERROR_FAULT_OCCURRED    0xfffe  // A fault occurred while scanning
  53.                                         // the OS/2 system control blocks.    
  54.                                         // The request should be reissued.    
  55. struct gi_process_data_s 
  56. {
  57.  USHORT  pd_pid;              // process id
  58.  USHORT  pd_ppid;             // parent process id
  59.  ULONG   pd_cpriv_im;         // count of private pages in memory
  60.  ULONG   pd_cpriv_od;         // count of private pages on disk
  61.  ULONG   pd_cpriv_nt;         // count of private pages not accessed
  62.  ULONG   pd_cshr_im;          // count of shared pages in memory for process
  63.  ULONG   pd_cshr_od;          // count of shared pages on disk for process
  64.  ULONG   pd_cshr_nt;          // count of shared pages not accessed for proc.
  65.  UCHAR   pd_name[14];         // name of process
  66. };
  67. typedef gi_process_data_s *pgi_process_data_s;
  68.  
  69.  
  70. struct os20memu_general_info 
  71. {
  72.  ULONG   gi_version;          // version
  73.  ULONG   gi_phys_mem;         // amount of physical storage, in pages
  74.  ULONG   gi_free_mem;         // count of free pages
  75.  ULONG   gi_tot_res;          // total resident (fixed) memory not including locked
  76.  ULONG   gi_res_sys_mem;      // total number of resident pages contained within the system arena
  77.  ULONG   gi_swp_sys_mem;      // total number of swapped out pages that
  78.                               //  reside in the system arena
  79.                               //  NOTE: subset of gi_ondisk_swp
  80.  ULONG   gi_swappable_sys_mem;// total number of swappable pages that are
  81.                               //  currently in memory that are located
  82.                               //  within the system arena
  83.                               //  NOTE: subset of gi_inmem_swp
  84.  ULONG   gi_inmem_swp;        // total number of swappable pages that are
  85.                               //  currently in memory includes both
  86.                               //  system and user pages
  87.  ULONG   gi_inmem_dsc;        // total number of discardable pages that are
  88.                               //  currently in memory includes both
  89.                               //  system and user pages
  90.  ULONG   gi_ondisk_dsc;       // total number of discardable pages that are
  91.                               //  not in memory
  92.  ULONG   gi_ondisk_swp;       // total number of swappable pages that are
  93.                               //  not in memory
  94.  ULONG   gi_notacc_swp;       // total number of swappable pages that were
  95.                               //  allocated (with the commit bit set) but
  96.                               //  have never been accessed
  97.  ULONG   gi_slock_swp;        // short term locks on swappable pages, in pgs
  98.                               //  NOTE: subset of inmem_swp
  99.  ULONG   gi_slock_dsc;        // short term locks on discardable pages, in pgs
  100.                               //  NOTE: subset of inmem_dsc
  101.  ULONG   gi_llock_swp;        // long term locks on swappable pages, in pages
  102.                               //  NOTE: subset of inmem_swp
  103.  ULONG   gi_llock_dsc;        // long term locks on discardable pages, in pgs
  104.                               //  NOTE: subset of inmem_dsc
  105.  ULONG   gi_swapfile_size;    // size of swapfile in pages
  106.  ULONG   gi_swapfile_inuse;   // number of pages with valid information
  107.  ULONG   gi_swapfile_max_inuse;// maximum inuse page
  108.  
  109.  ULONG   gi_app_sys_mem_res;  // total amount of resident system memory
  110.                               //  used to run all processes (IN BYTES)
  111.                               //  NOTE: subset of res_sys_mem
  112.  ULONG   gi_app_sys_mem_im;   // total amount of in memory system storage
  113.                               //  used to run all processes (IN BYTES)
  114.                               //  NOTE: subset of swappable_sys_mem
  115.  ULONG   gi_app_sys_mem_od;   // total amount of swapped system storage
  116.                               //  used to run all processes (IN BYTES)
  117.                               //  NOTE: subset of swp_sys_mem
  118. // shared arena info
  119.  ULONG   gi_shr_sys_mem_res;  // total amount of resident system memory
  120.  ULONG   gi_shr_sys_mem_im;   // total number of shared pages in memory
  121.  ULONG   gi_shr_sys_mem_od;   // total number of shared pages in memory
  122.  ULONG   gi_cshr_im;          // total number of shared pages in memory
  123.                               //  NOTE: subset of inmem_swp and inmem_dsc
  124.  ULONG   gi_cshr_od;          // total number of shared pages on disk
  125.                               //  NOTE: subset of ondisk_swp and ondisk_dsc
  126.  ULONG   gi_cshr_nt;          // total number of shared pages not accessed
  127.                               //  NOTE: subset of notacc_swp
  128.  ULONG   gi_cpids;            // count of processes in gi_process_data array
  129.  // per process info
  130.  struct  gi_process_data_s gi_process_data[1]; // array of process records
  131.                               // The number of entries in this array is
  132.                               // variable and its contents is complete only
  133.                               // if its size is => gi_cpids.
  134. };
  135. typedef os20memu_general_info *pos20memu_general_info;
  136.  
  137.  
  138. //   Structure of the detail record of a memory object.                       
  139. //   An array of these structures is returned at the last entry of the        
  140. //   os20memu_process_details; see pi_object_data.                            
  141. //   That array is variable length and its size should be set = the sum of    
  142. //   pi_cprivate + pi_cshared.                                                
  143.  
  144.  
  145. struct pi_object_data_s 
  146. {
  147.  ULONG   od_linaddr;          // linear address of object
  148.  ULONG   od_flags;            // object flags
  149.  ULONG   od_size;             // size of object in pages
  150.  ULONG   od_inmem;            // number of pages in memory
  151.  ULONG   od_ondisk;           // number of pages on  disk
  152.  ULONG   od_notacc;           // number of pages that were not accessed
  153.  UCHAR   od_owner_name[14];   // name of executable that allocated the object
  154. };
  155. typedef pi_object_data_s *ppi_object_data_s;
  156.  
  157.  
  158. struct os20memu_process_details 
  159. {
  160.  ULONG   pi_sys_memory_used_res; // current amount of resident system
  161.                                  //  memory being used to run this process
  162.                                  //  (IN BYTES)
  163.  ULONG   pi_sys_memory_used_im;  // current amount of in memory swappable
  164.                                  //  system storage being used to run
  165.                                  //  this process (IN BYTES)
  166.  ULONG   pi_sys_memory_used_od;  // current amount of swapped system memory
  167.                                  //  being used to run this process
  168.                                  //  (IN BYTES)
  169.  USHORT  pi_cprivate;            // On return, this value will reflect the
  170.                                  // number of objects in the private arena
  171.                                  // This variable must be set to the number of
  172.                                  // entries in the pi_object_data array before
  173.                                  // issuing an EP16_GET_PROCESS_INFO request.
  174.  USHORT  pi_cshared;             // number of objects in the shared arena
  175.  
  176.  struct pi_object_data_s pi_object_data[1]; // array of object data records
  177.                                  // The number of entries in this array is
  178.                                  // variable and its contents is complete only
  179.                                  // if its size is => the sum of
  180.                                  // pi_cprivate + pi_cshared.
  181. };
  182. typedef os20memu_process_details *pos20memu_process_details;
  183.  
  184.  
  185. #define OB_DISCARDABLE 0x40000  // Discardable Object
  186. #define OB_SWAPPABLE   0x20000  // Swappable Object
  187. #define OB_RESIDENT    0x10000  // Resident Object
  188.  
  189. #define OB_LALIAS       0x1000  // Object has aliases
  190. #define OB_SHARED       0x0800  // Object's contents are shared
  191. #define OB_UVIRT        0x0400  // UVirt object
  192. #define OB_ZEROINIT     0x0200  // Object is zero-initialized
  193. #define OB_RES_INIT     0x0100  // Initial allocation was resident
  194. #define OB_LOWMEM       0x0040  // Object is in low memory
  195.  
  196. #define OB_GUARD        0x0080  // Page attribute/permission flags
  197. #define OB_EXEC         0x0020
  198. #define OB_READ         0x0010
  199. #define OB_USER         0x0008
  200. #define OB_WRITE        0x0004
  201.  
  202.  
  203. #ifdef __cplusplus
  204.   extern "C" {
  205. #endif
  206.  
  207.     /**************************************************************************/
  208.     /* The EP16_GET_GENERAL_INFO function returns a snapshot of memory.       */
  209.     /*                                                                        */
  210.     /* It should be called at any time it is felt the state of system memory  */
  211.     /* has changed such as following the allocation/reallocation of any       */
  212.     /* private data segments.  Also, when programs have started or stopped.   */
  213.     /*                                                                        */
  214.     /* The only parameter to this function is a pointer to a structure of     */
  215.     /* type 'os20memu_general_info'.                                          */
  216.     /*                                                                        */
  217.     /**************************************************************************/
  218.  
  219. #if ( (defined (__BCPLUSPLUS__)) || (defined (__WATCOM_CPLUSPLUS__)) )
  220.   USHORT APIENTRY16 EP16_GET_GENERAL_INFO(pos20memu_general_info __far16 pgi);
  221. #else
  222.   USHORT APIENTRY16 EP16_GET_GENERAL_INFO(pos20memu_general_info _Seg16 pgi);
  223. #endif
  224. APIRET APIENTRY   EP_get_general_info(pos20memu_general_info pgi);
  225.  
  226.     /**************************************************************************/
  227.     /* The EP16_GET_PROCESS_INFO function returns detailed data for a process.*/
  228.     /*                                                                        */
  229.     /* It may be called at any time to obtain several data items for a        */
  230.     /* particular process.                                                    */
  231.     /*                                                                        */
  232.     /* The input to this function is a process ID.  Typically, this would be  */
  233.     /* a process ID returned on a previous call to EP16_GET_GENERAL_INFO.     */
  234.     /* The process must be active or an error will be returned.               */
  235.     /*                                                                        */
  236.     /* The output from this function is described in the structure of type    */
  237.     /* 'os20memu_process_details'.                                            */
  238.     /*                                                                        */
  239.     /**************************************************************************/
  240.  
  241. #if ( (defined (__BCPLUSPLUS__)) || (defined (__WATCOM_CPLUSPLUS__)) )
  242.   USHORT APIENTRY16 EP16_GET_PROCESS_INFO(USHORT pid, pos20memu_process_details __far16 ppi);
  243. #else
  244.   USHORT APIENTRY16 EP16_GET_PROCESS_INFO(USHORT pid, pos20memu_process_details _Seg16 ppi);
  245. #endif
  246. APIRET APIENTRY   EP_get_process_info(ULONG pid, pos20memu_process_details ppi);
  247.  
  248.  
  249. #if ( (defined (__BCPLUSPLUS__)) || (defined (__WATCOM_CPLUSPLUS__)) )
  250.  typedef USHORT (APIENTRY16 MEMU16_GGI)(pos20memu_general_info __far16 pgi);
  251. #else
  252.  typedef USHORT (APIENTRY16 MEMU16_GGI)(pos20memu_general_info _Seg16 pgi);
  253. #endif
  254. typedef MEMU16_GGI *PMEMU16_GGI;
  255.  
  256. typedef APIRET (APIENTRY MEMU_GGI)(pos20memu_general_info pgi);
  257. typedef MEMU_GGI *PMEMU_GGI;
  258.  
  259. #if ( (defined (__BCPLUSPLUS__)) || (defined (__WATCOM_CPLUSPLUS__)) )
  260.  typedef USHORT (APIENTRY16 MEMU16_GPI)(USHORT pid, pos20memu_process_details __far16 ppi);
  261. #else
  262.  typedef USHORT (APIENTRY16 MEMU16_GPI)(USHORT pid, pos20memu_process_details _Seg16 ppi);
  263. #endif
  264. typedef MEMU16_GPI *PMEMU16_GPI;
  265.  
  266. typedef APIRET (APIENTRY MEMU_GPI)(ULONG pid, pos20memu_process_details ppi);
  267. typedef MEMU_GPI *PMEMU_GPI;
  268.  
  269. #ifdef __cplusplus
  270.   }
  271. #endif
  272.  
  273.  
  274. #pragma pack()
  275.  
  276. #endif // OMEMU_H_INCLUDED
  277.  
  278.  
  279. // end of source
  280.