source: trunk/src/win32k/kKrnlLib/include/OS2KSEM.h

Last change on this file was 9514, checked in by bird, 23 years ago

Cleanup/Backup.

File size: 5.9 KB
Line 
1/* $Id: OS2KSEM.h,v 1.5 2002-12-16 02:25:05 bird Exp $
2 *
3 * OS/2 kernel Semaphore functions.
4 *
5 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 *
9 */
10
11
12#ifndef _OS2KSEM_h_
13#define _OS2KSEM_h_
14
15/*******************************************************************************
16* Defined Constants And Macros *
17*******************************************************************************/
18#define KSEM_INDEFINITE_WAIT -1UL
19#define KSEM_IMMEDIATE_RETURN 0UL
20
21/*
22 * Semaphore type. ( Used with the generic KSEM routines. )
23 */
24#define KSEM_EVENT 0
25#define KSEM_MUTEX 1
26#define KSEM_SHARED 2
27
28/*
29 * Sempahore flags. (according to SG24-4640-00)
30 */
31#define KSEM_DEFAULT 0
32#define KSEM_NOINTERRUPT 1
33#define KSEM_WRITE 2
34#define KSEM_DISPLAYID 4
35#define KSEM_NOBLOCKED 8
36
37
38/*******************************************************************************
39* Structures and Typedefs *
40*******************************************************************************/
41/* (This is according to SG24-4640-00.) */
42
43typedef union _KSEMSHR
44{
45 /**
46 * Astrict 16 is byte while retail 12 is bytes.
47 * We'll reserve 20 bytes just to be sure!.
48 */
49 char achDummy[20];
50
51 struct
52 {
53 char ks_achSignature[4];
54 char ks_bFlags;
55 char ks_bType;
56 unsigned short ks_Owner;
57 unsigned short ks_cusPendingWriters;
58 unsigned short ks_cusNest;
59 unsigned short ks_cusReaders;
60 unsigned short ks_cusPendingReaders;
61 } debug;
62
63 struct
64 {
65 char ks_bFlags;
66 char ks_bType;
67 unsigned short ks_Owner;
68 unsigned short ks_cusPendingWriters;
69 unsigned short ks_cusNest;
70 unsigned short ks_cusReaders;
71 unsigned short ks_cusPendingReaders;
72 } release;
73
74} KSEMSHR,
75 *PKSEMSHR,
76 *HKSEMSHR; /* Handle to kernel shared semphore. */
77typedef HKSEMSHR * PHKSEMSHR;
78
79
80typedef union _KSEMMTX
81{
82 /**
83 * Astrict is 12 byte while retail is 8 bytes.
84 * We'll reserve 20 bytes just to be sure!
85 */
86 char achDummy[20];
87
88 struct
89 {
90 char ksem_achSignature[4];
91 char ksem_bFlags;
92 char ksem_bType;
93 unsigned short ksem_Owner;
94 unsigned short ksem_cusPendingWriters;
95 unsigned short ksem_cusNest;
96 }debug;
97 struct
98 {
99 char ksem_bFlags;
100 char ksem_bType;
101 unsigned short ksem_Owner;
102 unsigned short ksem_cusPendingWriters;
103 unsigned short ksem_cusNest;
104 } release;
105} KSEMMTX,
106 *PKSEMMTX,
107 *HKSEMMTX; /* Handle to kernel mutex semaphore. */
108typedef HKSEMMTX * PHKSEMMTX;
109
110
111typedef union _KSEMEVT
112{
113 /**
114 * Astrict is 16 byte while retail is 12 bytes.
115 * We'll reserve 20 bytes just to be sure!
116 */
117 char achDummy[20];
118
119 struct
120 {
121 char kse_achSignature[4];
122 char kse_bFlags;
123 char kse_bType;
124 unsigned short kse_Owner;
125 unsigned short kse_cusPendingWriters;
126 } debug;
127
128 struct
129 {
130 char kse_bFlags;
131 char kse_bType;
132 unsigned short kse_Owner;
133 unsigned short kse_cusPendingWriters;
134 } release;
135
136} KSEMEVT,
137 *PKSEMEVT,
138 *HKSEMEVT; /* Handle to kernel event sempahore. */
139typedef HKSEMEVT * PHKSEMEVT;
140
141
142typedef union _KSEM
143{
144 KSEMSHR shr;
145 KSEMMTX mtx;
146 KSEMEVT evt;
147} KSEM, *PKSEM, *HKSEM; /* Generic kernel semaphore handle. */
148typedef HKSEM * PHKSEM;
149
150
151/*******************************************************************************
152* Exported Functions *
153*******************************************************************************/
154/*
155 * Mutex semaphores.
156 */
157extern ULONG KRNLCALL KSEMRequestMutex(HKSEMMTX hkmtx, ULONG ulTimeout);
158extern ULONG KRNLCALL OrgKSEMRequestMutex(HKSEMMTX hkmtx, ULONG ulTimeout);
159extern void KRNLCALL KSEMReleaseMutex(HKSEMMTX hkmtx);
160extern void KRNLCALL OrgKSEMReleaseMutex(HKSEMMTX hkmtx);
161extern ULONG KRNLCALL KSEMQueryMutex(HKSEMMTX hkmtx, PUSHORT pcusNest);
162extern ULONG KRNLCALL OrgKSEMQueryMutex(HKSEMMTX hkmtx, PUSHORT pcusNest);
163
164
165/*
166 * Event semaphores.
167 */
168extern void KRNLCALL KSEMResetEvent(HKSEMEVT hkev);
169extern void KRNLCALL OrgKSEMResetEvent(HKSEMEVT hkev);
170extern void KRNLCALL KSEMPostEvent(HKSEMEVT hkev);
171extern void KRNLCALL OrgKSEMPostEvent(HKSEMEVT hkev);
172extern ULONG KRNLCALL KSEMWaitEvent(HKSEMEVT hkev, ULONG ulTimeout);
173extern ULONG KRNLCALL OrgKSEMWaitEvent(HKSEMEVT hkev, ULONG ulTimeout);
174
175
176/*
177 * Shared semaphores.
178 */
179extern ULONG KRNLCALL KSEMRequestExclusive(HKSEMSHR hkshr, ULONG ulTimeout);
180extern ULONG KRNLCALL OrgKSEMRequestExclusive(HKSEMSHR hkshr, ULONG ulTimeout);
181extern ULONG KRNLCALL KSEMRequestShared(HKSEMSHR hkshr, ULONG ulTimeout);
182extern ULONG KRNLCALL OrgKSEMRequestShared(HKSEMSHR hkshr, ULONG ulTimeout);
183
184
185/*
186 * Some other KSEM prefixed functions - parameters's not that obvious...
187 */
188#if 0
189extern ULONG KRNLCALL KSEMAlloc(PHKSEM phksem, ULONG p1, ULONG p2);
190extern ULONG KRNLCALL KSEMCreate(PHKSEM phksem, ULONG type);
191extern void KRNLCALL KSEMDestroy(HKSEM hksem);
192#endif
193extern void KRNLCALL KSEMInit(PKSEM pksem, ULONG fulType, ULONG fulFlags);
194extern void KRNLCALL OrgKSEMInit(PKSEM pksem, ULONG fulType, ULONG fulFlags);
195extern void KRNLCALL KSEMRelease(HKSEM hksem);
196extern void KRNLCALL OrgKSEMRelease(HKSEM hksem);
197extern void KRNLCALL KSEMQuery(HKSEM hksem, PULONG pul);
198extern void KRNLCALL OrgKSEMQuery(HKSEM hksem, PULONG pul);
199
200#endif
201
Note: See TracBrowser for help on using the repository browser.