source: trunk/src/emx/include/InnoTekLIBC/FastInfoBlocks.h@ 1971

Last change on this file since 1971 was 1666, checked in by bird, 21 years ago

initial coding / borrowing.

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
1/* $Id: FastInfoBlocks.h 1666 2004-11-22 22:32:54Z bird $ */
2/** @file
3 *
4 * Fast InfoBlock Access.
5 *
6 * Copyright (c) 2003-2004 knut st. osmundsen <[email protected]>
7 *
8 *
9 * This file is part of InnoTek LIBC.
10 *
11 * InnoTek LIBC is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published
13 * by the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * InnoTek LIBC is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with InnoTek LIBC; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27#ifndef __InnoTekLIBC_FastInfoBlocks_h__
28#define __InnoTekLIBC_FastInfoBlocks_h__
29
30#include <sys/cdefs.h>
31
32__BEGIN_DECLS
33
34
35/**
36 * Gets the current Process ID.
37 */
38#if 0
39#define fibGetPid() (__libc_GpFIBPIB->pib_ulpid)
40#else
41#define fibGetPid() (__libc_GpFIBLIS->pidCurrent)
42#endif
43
44/**
45 * Gets the Parent Process ID.
46 */
47#if 0
48#define fibGetPPid() (__libc_GpFIBPIB->pib_ulppid)
49#else
50#define fibGetPPid() (__libc_GpFIBLIS->pidParent)
51#endif
52
53/**
54 * Gets the current Thread ID.
55 */
56#define fibGetTid() (__libc_GpFIBLIS->tidCurrent)
57
58/**
59 * Gets the current Thread ID plus the current PID.
60 * Very suitable for identifying global owernships.
61 */
62#define fibGetTidPid() ((unsigned)__libc_GpFIBLIS->tidCurrent | ((unsigned)__libc_GpFIBLIS->pidCurrent << 16))
63
64/**
65 * Gets the handle of the executable of this process.
66 */
67#if 1
68#define fibGetExeHandle() (__libc_GpFIBPIB->pib_hmte)
69#else
70#define fibGetExeHandle() (__libc_GpFIBLIS->hmod)
71#endif
72
73/**
74 * Gets the Environment Selector.
75 */
76#define fibGetEnvSel() (__libc_GpFIBLIS->selEnv)
77
78/**
79 * Gets the Environment Selector.
80 */
81#define fibGetCmdLineOff() (__libc_GpFIBLIS->offCmdLine)
82
83/**
84 * Gets the Environment Pointer (32bit FLAT pointer).
85 */
86#if 1
87#define fibGetEnv() (__libc_GpFIBPIB->pib_pchenv)
88#else
89#define fibGetEnv() ( ((fibGetEnvSel() & ~7) << 13) )
90#endif
91
92/**
93 * Gets the Commandline Pointer (32bit FLAT pointer).
94 */
95#if 1
96#define fibGetCmdLine() (__libc_GpFIBPIB->pib_pchcmd)
97#else
98#define fibGetCmdLine() ( ((fibGetEnvSel() & ~7) << 13) | fibGetCmdLineOff() )
99#endif
100
101
102/**
103 * Gets the Process Status.
104 */
105#define fibGetProcessStatus() ((volatile unsigned char)__libc_GpFIBLIS->rfProcStatus)
106/** Is this process in an exit list? */
107#define fibIsInExitList() (fibGetProcessStatus() & 1)
108/** Is the process exitting. */
109#define fibIsInExit() (fibGetProcessStatus() & (0x40/*dying*/ | 0x04/*exiting all*/ | 0x02/*Exiting Thread 1*/ | 0x01/* ExitList */))
110
111
112/**
113 * Gets the Process Type.
114 */
115#define fibGetProcessType() (__libc_GpFIBLIS->typeProcess)
116
117/** Is this a Detached (daemon) process? */
118#define fibIsDetachedProcess() (fibGetProcessType() == 4)
119/** Is this a PM process? */
120#define fibIsPMProcess() (fibGetProcessType() == 3)
121/** Is this a VIO (windowed console) process? */
122#define fibIsVIOProcess() (fibGetProcessType() == 2)
123/** Is this a VDM (Virtual Dos Mode) process? */
124#define fibIsVDMProcess() (fibGetProcessType() == 1)
125/** Is this a full screen process? */
126#define fibIsFullScreeProcess() (fibGetProcessType() == 0)
127
128
129/**
130 * System stuff
131 */
132#define fibGetMsCount() (__libc_GpFIBGIS->SIS_MsCount)
133
134
135
136/*******************************************************************************
137* Global Variables *
138*******************************************************************************/
139#pragma pack(1)
140
141/**
142 * Local Info Segment (per process).
143 */
144extern struct __libc_GpFIBLIS_s
145{
146 unsigned short pidCurrent; /* Current process ID */
147 unsigned short pidParent; /* Process ID of parent */
148 unsigned short prtyCurrent; /* Current thread priority */
149 unsigned short tidCurrent; /* Current thread ID */
150 unsigned short sgCurrent; /* Screengroup */
151 unsigned char rfProcStatus; /* Process status bits */
152 unsigned char LIS_fillbyte1; /* filler byte */
153 unsigned short fFoureground; /* Current process is in foreground */
154 unsigned char typeProcess; /* Current process type */
155 unsigned char LIS_fillbyte2; /* filler byte */
156
157 unsigned short selEnv; /* @@V1 Environment selector */
158 unsigned short offCmdLine; /* @@V1 Offset of command line start */
159 unsigned short cbDataSegment; /* @@V1 Length of Data Segment */
160 unsigned short cbStack; /* @@V1 STACKSIZE from the .EXE file */
161 unsigned short cbHeap; /* @@V1 HEAPSIZE from the .EXE file */
162 unsigned short hmod; /* @@V1 Module handle of the application */
163 unsigned short selDS; /* @@V1 Data Segment Handle of application */
164
165 unsigned short LIS_PackSel; /* First tiled selector in this EXE */
166 unsigned short LIS_PackShrSel; /* First selector above shared arena */
167 unsigned short LIS_PackPckSel; /* First selector above packed arena */
168} * __libc_GpFIBLIS;
169
170/**
171 * Global Info Segment (system)
172 */
173extern struct __libc_GpFIBGIS_s
174{
175 /* Time (offset 0x00) */
176 unsigned long SIS_BigTime; /* Time from 1-1-1970 in seconds */
177 unsigned long SIS_MsCount; /* Freerunning milliseconds counter */
178 unsigned char SIS_HrsTime; /* Hours */
179 unsigned char SIS_MinTime; /* Minutes */
180 unsigned char SIS_SecTime; /* Seconds */
181 unsigned char SIS_HunTime; /* Hundredths of seconds */
182 unsigned short SIS_TimeZone; /* Timezone in min from GMT (Set to EST) */
183 unsigned short SIS_ClkIntrvl; /* Timer interval (units=0.0001 secs) */
184
185 /* Date (offset 0x10) */
186 unsigned char SIS_DayDate; /* Day-of-month (1-31) */
187 unsigned char SIS_MonDate; /* Month (1-12) */
188 unsigned short SIS_YrsDate; /* Year (>= 1980) */
189 unsigned char SIS_DOWDate; /* Day-of-week (1-1-80 = Tues = 3) */
190
191 /* Version (offset 0x15) */
192 unsigned char SIS_VerMajor; /* Major version number */
193 unsigned char SIS_VerMinor; /* Minor version number */
194 unsigned char SIS_RevLettr; /* Revision letter */
195
196 /* System Status (offset 0x18) */
197 unsigned char SIS_CurScrnGrp; /* Fgnd screen group # */
198 unsigned char SIS_MaxScrnGrp; /* Maximum number of screen groups */
199 unsigned char SIS_HugeShfCnt; /* Shift count for huge segments */
200 unsigned char SIS_ProtMdOnly; /* Protect-mode-only indicator */
201 unsigned short SIS_FgndPID; /* Foreground process ID */
202
203 /* Scheduler Parms (offset 0x1E) */
204 unsigned char SIS_Dynamic; /* Dynamic variation flag (1=enabled) */
205 unsigned char SIS_MaxWait; /* Maxwait (seconds) */
206 unsigned short SIS_MinSlice; /* Minimum timeslice (milliseconds) */
207 unsigned short SIS_MaxSlice; /* Maximum timeslice (milliseconds) */
208
209 /* Boot Drive (offset 0x24) */
210 unsigned short SIS_BootDrv; /* Drive from which system was booted */
211
212 /* RAS Major Event Code Table (offset 0x26) */
213 unsigned char SIS_mec_table[32]; /* Table of RAS Major Event Codes (MECs) */
214
215 /* Additional Session Data (offset 0x46) */
216 unsigned char SIS_MaxVioWinSG; /* Max. no. of VIO windowable SG's */
217 unsigned char SIS_MaxPresMgrSG; /* Max. no. of Presentation Manager SG's */
218
219 /* Error logging Information (offset 0x48) */
220 unsigned short SIS_SysLog; /* Error Logging Status */
221
222 /* Additional RAS Information (offset 0x4A) */
223 unsigned short SIS_MMIOBase; /* Memory mapped I/O selector */
224 unsigned long SIS_MMIOAddr; /* Memory mapped I/O address */
225
226 /* Additional 2.0 Data (offset 0x50) */
227 unsigned char SIS_MaxVDMs; /* Max. no. of Virtual DOS machines */
228 unsigned char SIS_Reserved;
229} * __libc_GpFIBGIS;
230
231
232/**
233 * Process Info Block.
234 */
235extern struct __libc_GpFIBPIB_s
236{
237 unsigned long pib_ulpid; /* Process I.D. */
238 unsigned long pib_ulppid; /* Parent process I.D. */
239 unsigned long pib_hmte; /* Program (.EXE) module handle */
240 char * pib_pchcmd; /* Command line pointer */
241 char * pib_pchenv; /* Environment pointer */
242 unsigned long pib_flstatus; /* Process' status bits */
243 unsigned long pib_ultype; /* Process' type code */
244} * __libc_GpFIBPIB;
245
246#pragma pack()
247
248
249int __libc_back_fibInit(int fForced);
250void __libc_Back_fibDumpAll(void);
251
252
253__END_DECLS
254
255#endif
256
Note: See TracBrowser for help on using the repository browser.