| 1 | /* $Id: FastInfoBlocks.h,v 1.2 2003-04-07 18:40:06 sandervl Exp $ | 
|---|
| 2 | * | 
|---|
| 3 | * Fast InfoBlock Access. | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright (c) 2003 knut st. osmundsen <bird@anduin.net> | 
|---|
| 6 | * | 
|---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT. | 
|---|
| 8 | * | 
|---|
| 9 | */ | 
|---|
| 10 |  | 
|---|
| 11 | #ifndef __FastInfoBlocks_h__ | 
|---|
| 12 | #define __FastInfoBlocks_h__ | 
|---|
| 13 |  | 
|---|
| 14 | #ifdef __cplusplus | 
|---|
| 15 | extern "C" { | 
|---|
| 16 | #endif | 
|---|
| 17 |  | 
|---|
| 18 |  | 
|---|
| 19 | /******************************************************************************* | 
|---|
| 20 | *   Defined Constants And Macros                                               * | 
|---|
| 21 | *******************************************************************************/ | 
|---|
| 22 |  | 
|---|
| 23 | /** | 
|---|
| 24 | * Gets the current Process ID. | 
|---|
| 25 | */ | 
|---|
| 26 | #if 0 | 
|---|
| 27 | #define fibGetPid()             (_gpfibPIB->pib_ulpid) | 
|---|
| 28 | #else | 
|---|
| 29 | #define fibGetPid()             (_gpfibLIS->pidCurrent) | 
|---|
| 30 | #endif | 
|---|
| 31 |  | 
|---|
| 32 | /** | 
|---|
| 33 | * Gets the current Thread ID. | 
|---|
| 34 | */ | 
|---|
| 35 | #define fibGetTid()             (_gpfibLIS->tidCurrent) | 
|---|
| 36 |  | 
|---|
| 37 | /** | 
|---|
| 38 | * Gets the handle of the executable of this process. | 
|---|
| 39 | */ | 
|---|
| 40 | #if 1 | 
|---|
| 41 | #define fibGetExeHandle()       (_gpfibPIB->pib_hmte) | 
|---|
| 42 | #else | 
|---|
| 43 | #define fibGetExeHandle()       (_gpfibLIS->hmod) | 
|---|
| 44 | #endif | 
|---|
| 45 |  | 
|---|
| 46 | /** | 
|---|
| 47 | * Gets the Environment Selector. | 
|---|
| 48 | */ | 
|---|
| 49 | #define fibGetEnvSel()          (_gpfibLIS->selEnv) | 
|---|
| 50 |  | 
|---|
| 51 | /** | 
|---|
| 52 | * Gets the Environment Selector. | 
|---|
| 53 | */ | 
|---|
| 54 | #define fibGetCmdLineOff()      (_gpfibLIS->offCmdLine) | 
|---|
| 55 |  | 
|---|
| 56 | /** | 
|---|
| 57 | * Gets the Environment Pointer (32bit FLAT pointer). | 
|---|
| 58 | */ | 
|---|
| 59 | #if 1 | 
|---|
| 60 | #define fibGetEnv()             (_gpfibPIB->pib_pchenv) | 
|---|
| 61 | #else | 
|---|
| 62 | #define fibGetEnv()             ( ((fibGetEnvSel() & ~7) << 13) ) | 
|---|
| 63 | #endif | 
|---|
| 64 |  | 
|---|
| 65 | /** | 
|---|
| 66 | * Gets the Commandline Pointer (32bit FLAT pointer). | 
|---|
| 67 | */ | 
|---|
| 68 | #if 1 | 
|---|
| 69 | #define fibGetCmdLine()         (_gpfibPIB->pib_pchcmd) | 
|---|
| 70 | #else | 
|---|
| 71 | #define fibGetCmdLine()         ( ((fibGetEnvSel() & ~7) << 13) | fibGetCmdLineOff() ) | 
|---|
| 72 | #endif | 
|---|
| 73 |  | 
|---|
| 74 |  | 
|---|
| 75 | /** | 
|---|
| 76 | * Gets the Process Status. | 
|---|
| 77 | */ | 
|---|
| 78 | #define fibGetProcessStatus()   (_gpfibLIS->rfProcStatus) | 
|---|
| 79 | /** Is this process in an exit list? */ | 
|---|
| 80 | #define fibIsInExitList()       (fibGetProcessStatus() & 1) | 
|---|
| 81 |  | 
|---|
| 82 |  | 
|---|
| 83 | /** | 
|---|
| 84 | * Gets the Process Type. | 
|---|
| 85 | */ | 
|---|
| 86 | #define fibGetProcessType()     (_gpfibLIS->typeProcess) | 
|---|
| 87 |  | 
|---|
| 88 | /** Is this a Detached (daemon) process? */ | 
|---|
| 89 | #define fibIsDetachedProcess()  (fibGetProcessType() == 4) | 
|---|
| 90 | /** Is this a PM process? */ | 
|---|
| 91 | #define fibIsPMProcess()        (fibGetProcessType() == 3) | 
|---|
| 92 | /** Is this a VIO (windowed console) process? */ | 
|---|
| 93 | #define fibIsVIOProcess()       (fibGetProcessType() == 2) | 
|---|
| 94 | /** Is this a VDM (Virtual Dos Mode) process? */ | 
|---|
| 95 | #define fibIsVDMProcess()       (fibGetProcessType() == 1) | 
|---|
| 96 | /** Is this a full screen process? */ | 
|---|
| 97 | #define fibIsFullScreeProcess() (fibGetProcessType() == 0) | 
|---|
| 98 |  | 
|---|
| 99 |  | 
|---|
| 100 | /** | 
|---|
| 101 | * System stuff | 
|---|
| 102 | */ | 
|---|
| 103 | #define fibGetMsCount()         (_gpfibGIS->SIS_MsCount) | 
|---|
| 104 |  | 
|---|
| 105 |  | 
|---|
| 106 |  | 
|---|
| 107 | /******************************************************************************* | 
|---|
| 108 | *   Global Variables                                                           * | 
|---|
| 109 | *******************************************************************************/ | 
|---|
| 110 | #pragma pack(1) | 
|---|
| 111 |  | 
|---|
| 112 | /** | 
|---|
| 113 | * Local Info Segment (per process). | 
|---|
| 114 | */ | 
|---|
| 115 | extern struct fibLIS | 
|---|
| 116 | { | 
|---|
| 117 | unsigned short  pidCurrent;  /* Current process ID */ | 
|---|
| 118 | unsigned short  pidParent;  /* Process ID of parent */ | 
|---|
| 119 | unsigned short  prtyCurrent; /* Current thread priority */ | 
|---|
| 120 | unsigned short  tidCurrent;  /* Current thread ID */ | 
|---|
| 121 | unsigned short  sgCurrent; /* Screengroup */ | 
|---|
| 122 | unsigned char   rfProcStatus; /* Process status bits */ | 
|---|
| 123 | unsigned char   LIS_fillbyte1;  /* filler byte */ | 
|---|
| 124 | unsigned short  fFoureground;       /* Current process is in foreground */ | 
|---|
| 125 | unsigned char   typeProcess;   /* Current process type */ | 
|---|
| 126 | unsigned char   LIS_fillbyte2;  /* filler byte */ | 
|---|
| 127 |  | 
|---|
| 128 | unsigned short  selEnv;     /* @@V1 Environment selector */ | 
|---|
| 129 | unsigned short  offCmdLine;    /* @@V1 Offset of command line start */ | 
|---|
| 130 | unsigned short  cbDataSegment;/* @@V1 Length of Data Segment */ | 
|---|
| 131 | unsigned short  cbStack;  /* @@V1 STACKSIZE from the .EXE file */ | 
|---|
| 132 | unsigned short  cbHeap;   /* @@V1 HEAPSIZE  from the .EXE file */ | 
|---|
| 133 | unsigned short  hmod;    /* @@V1 Module handle of the application */ | 
|---|
| 134 | unsigned short  selDS;   /* @@V1 Data Segment Handle of application */ | 
|---|
| 135 |  | 
|---|
| 136 | unsigned short  LIS_PackSel;    /* First tiled selector in this EXE */ | 
|---|
| 137 | unsigned short  LIS_PackShrSel; /* First selector above shared arena */ | 
|---|
| 138 | unsigned short  LIS_PackPckSel; /* First selector above packed arena */ | 
|---|
| 139 | }  * _gpfibLIS; | 
|---|
| 140 |  | 
|---|
| 141 | /** | 
|---|
| 142 | * Global Info Segment (system) | 
|---|
| 143 | */ | 
|---|
| 144 | extern struct fibGIS | 
|---|
| 145 | { | 
|---|
| 146 | /* Time (offset 0x00) */ | 
|---|
| 147 | unsigned long   SIS_BigTime;    /* Time from 1-1-1970 in seconds */ | 
|---|
| 148 | unsigned long   SIS_MsCount;    /* Freerunning milliseconds counter */ | 
|---|
| 149 | unsigned char   SIS_HrsTime;    /* Hours */ | 
|---|
| 150 | unsigned char   SIS_MinTime;    /* Minutes */ | 
|---|
| 151 | unsigned char   SIS_SecTime;    /* Seconds */ | 
|---|
| 152 | unsigned char   SIS_HunTime;    /* Hundredths of seconds */ | 
|---|
| 153 | unsigned short  SIS_TimeZone;   /* Timezone in min from GMT (Set to EST) */ | 
|---|
| 154 | unsigned short  SIS_ClkIntrvl;  /* Timer interval (units=0.0001 secs) */ | 
|---|
| 155 |  | 
|---|
| 156 | /* Date (offset 0x10) */ | 
|---|
| 157 | unsigned char   SIS_DayDate;    /* Day-of-month (1-31) */ | 
|---|
| 158 | unsigned char   SIS_MonDate;    /* Month (1-12) */ | 
|---|
| 159 | unsigned short  SIS_YrsDate;    /* Year (>= 1980) */ | 
|---|
| 160 | unsigned char   SIS_DOWDate;    /* Day-of-week (1-1-80 = Tues = 3) */ | 
|---|
| 161 |  | 
|---|
| 162 | /* Version (offset 0x15) */ | 
|---|
| 163 | unsigned char   SIS_VerMajor;   /* Major version number */ | 
|---|
| 164 | unsigned char   SIS_VerMinor;   /* Minor version number */ | 
|---|
| 165 | unsigned char   SIS_RevLettr;   /* Revision letter */ | 
|---|
| 166 |  | 
|---|
| 167 | /* System Status (offset 0x18) */ | 
|---|
| 168 | unsigned char   SIS_CurScrnGrp; /* Fgnd screen group # */ | 
|---|
| 169 | unsigned char   SIS_MaxScrnGrp; /* Maximum number of screen groups */ | 
|---|
| 170 | unsigned char   SIS_HugeShfCnt; /* Shift count for huge segments */ | 
|---|
| 171 | unsigned char   SIS_ProtMdOnly; /* Protect-mode-only indicator */ | 
|---|
| 172 | unsigned short  SIS_FgndPID;    /* Foreground process ID */ | 
|---|
| 173 |  | 
|---|
| 174 | /* Scheduler Parms (offset 0x1E) */ | 
|---|
| 175 | unsigned char   SIS_Dynamic;    /* Dynamic variation flag (1=enabled) */ | 
|---|
| 176 | unsigned char   SIS_MaxWait;    /* Maxwait (seconds) */ | 
|---|
| 177 | unsigned short  SIS_MinSlice;   /* Minimum timeslice (milliseconds) */ | 
|---|
| 178 | unsigned short  SIS_MaxSlice;   /* Maximum timeslice (milliseconds) */ | 
|---|
| 179 |  | 
|---|
| 180 | /* Boot Drive (offset 0x24) */ | 
|---|
| 181 | unsigned short  SIS_BootDrv;    /* Drive from which system was booted */ | 
|---|
| 182 |  | 
|---|
| 183 | /* RAS Major Event Code Table (offset 0x26) */ | 
|---|
| 184 | unsigned char   SIS_mec_table[32]; /* Table of RAS Major Event Codes (MECs) */ | 
|---|
| 185 |  | 
|---|
| 186 | /* Additional Session Data (offset 0x46) */ | 
|---|
| 187 | unsigned char   SIS_MaxVioWinSG;  /* Max. no. of VIO windowable SG's */ | 
|---|
| 188 | unsigned char   SIS_MaxPresMgrSG; /* Max. no. of Presentation Manager SG's */ | 
|---|
| 189 |  | 
|---|
| 190 | /* Error logging Information (offset 0x48) */ | 
|---|
| 191 | unsigned short  SIS_SysLog;     /* Error Logging Status */ | 
|---|
| 192 |  | 
|---|
| 193 | /* Additional RAS Information (offset 0x4A) */ | 
|---|
| 194 | unsigned short  SIS_MMIOBase;   /* Memory mapped I/O selector */ | 
|---|
| 195 | unsigned long   SIS_MMIOAddr;   /* Memory mapped I/O address  */ | 
|---|
| 196 |  | 
|---|
| 197 | /* Additional 2.0 Data (offset 0x50) */ | 
|---|
| 198 | unsigned char   SIS_MaxVDMs;      /* Max. no. of Virtual DOS machines */ | 
|---|
| 199 | unsigned char   SIS_Reserved; | 
|---|
| 200 | }  * _gpfibGIS; | 
|---|
| 201 |  | 
|---|
| 202 |  | 
|---|
| 203 | /** | 
|---|
| 204 | * Process Info Block. | 
|---|
| 205 | */ | 
|---|
| 206 | extern struct ProcessInformationBlock | 
|---|
| 207 | { | 
|---|
| 208 | unsigned long   pib_ulpid;          /* Process I.D. */ | 
|---|
| 209 | unsigned long   pib_ulppid;         /* Parent process I.D. */ | 
|---|
| 210 | unsigned long   pib_hmte;           /* Program (.EXE) module handle */ | 
|---|
| 211 | char *          pib_pchcmd;         /* Command line pointer */ | 
|---|
| 212 | char *          pib_pchenv;         /* Environment pointer */ | 
|---|
| 213 | unsigned long   pib_flstatus;       /* Process' status bits */ | 
|---|
| 214 | unsigned long   pib_ultype;         /* Process' type code */ | 
|---|
| 215 | }   * _gpfibPIB; | 
|---|
| 216 |  | 
|---|
| 217 | #pragma pack() | 
|---|
| 218 |  | 
|---|
| 219 |  | 
|---|
| 220 | /******************************************************************************* | 
|---|
| 221 | *   Functions                                                                  * | 
|---|
| 222 | *******************************************************************************/ | 
|---|
| 223 | int     fibInit(void); | 
|---|
| 224 | void    fibDumpAll(void); | 
|---|
| 225 |  | 
|---|
| 226 |  | 
|---|
| 227 | #ifdef __cplusplus | 
|---|
| 228 | } | 
|---|
| 229 | #endif | 
|---|
| 230 | #endif | 
|---|