]> git.sesse.net Git - rdpsrv/blob - Xserver/include/extensions/syncstr.h
Support RDP5 logon packets.
[rdpsrv] / Xserver / include / extensions / syncstr.h
1 /* $XConsortium: syncstr.h,v 1.4 94/04/17 20:11:27 rws Exp $ */
2 /*
3
4 Copyright (c) 1991, 1993, 1994  X Consortium
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
26
27 */
28
29 /***********************************************************
30 Copyright 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts,
31 and Olivetti Research Limited, Cambridge, England.
32
33                         All Rights Reserved
34
35 Permission to use, copy, modify, and distribute this software and its 
36 documentation for any purpose and without fee is hereby granted, 
37 provided that the above copyright notice appear in all copies and that
38 both that copyright notice and this permission notice appear in 
39 supporting documentation, and that the names of Digital or Olivetti
40 not be used in advertising or publicity pertaining to distribution of the
41 software without specific, written prior permission.  
42
43 DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
44 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
45 FITNESS, IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
46 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
47 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
48 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
49 PERFORMANCE OF THIS SOFTWARE.
50
51 ******************************************************************/
52
53 #include "sync.h"
54
55 #ifndef _SYNC_OS
56
57 /* cover up types from sync.h to make sure they're the right size for
58  * protocol packaging.  These will be undef'ed after all the protocol
59  * structures are defined.
60  */
61 #define XSyncCounter CARD32
62 #define XSyncAlarm   CARD32
63
64 /*
65  * Initialize
66  */
67 typedef struct _xSyncInitialize {
68     CARD8       reqType;
69     CARD8       syncReqType;
70     CARD16      length B16;
71     CARD8       majorVersion;
72     CARD8       minorVersion;
73     CARD16      pad B16;
74 } xSyncInitializeReq;
75 #define sz_xSyncInitializeReq           8
76
77 typedef struct {
78     BYTE        type;
79     CARD8       unused;
80     CARD16      sequenceNumber B16;
81     CARD32      length B32;
82     CARD8       majorVersion;
83     CARD8       minorVersion;
84     CARD16      pad B16;
85     CARD32      pad0 B32;
86     CARD32      pad1 B32;
87     CARD32      pad2 B32;
88     CARD32      pad3 B32;
89     CARD32      pad4 B32;
90 } xSyncInitializeReply;
91 #define sz_xSyncInitializeReply 32
92
93 /*
94  * ListSystemCounters
95  */
96 typedef struct _xSyncListSystemCounters
97 {
98     CARD8       reqType;
99     CARD8       syncReqType;
100     CARD16      length B16;
101 } xSyncListSystemCountersReq;
102 #define sz_xSyncListSystemCountersReq   4
103
104 typedef struct {
105     BYTE        type;
106     CARD8       unused;
107     CARD16      sequenceNumber B16;
108     CARD32      length B32;
109     INT32       nCounters B32;
110     CARD32      pad0 B32;
111     CARD32      pad1 B32;
112     CARD32      pad2 B32;
113     CARD32      pad3 B32;
114     CARD32      pad4 B32;
115 } xSyncListSystemCountersReply;
116 #define sz_xSyncListSystemCountersReply 32
117
118 typedef struct {
119     XSyncCounter counter B32;
120     INT32       resolution_hi B32;
121     CARD32      resolution_lo B32;
122     CARD16      name_length B16;
123 } xSyncSystemCounter;
124 #define sz_xSyncSystemCounter 14
125
126 /*
127  * Create Counter
128  */
129 typedef struct _xSyncCreateCounterReq {
130     CARD8       reqType;
131     CARD8       syncReqType;
132     CARD16      length B16;
133     XSyncCounter cid B32;
134     INT32       initial_value_hi B32;
135     CARD32      initial_value_lo B32;
136 } xSyncCreateCounterReq;
137 #define sz_xSyncCreateCounterReq        16
138
139 /*
140  * Change Counter
141  */
142 typedef struct _xSyncChangeCounterReq {
143     CARD8       reqType;
144     CARD8       syncReqType;
145     CARD16      length B16;
146     XSyncCounter cid B32;
147     INT32       value_hi B32;
148     CARD32      value_lo B32;
149 } xSyncChangeCounterReq;
150 #define sz_xSyncChangeCounterReq        16
151
152 /*
153  * Set Counter
154  */
155 typedef struct _xSyncSetCounterReq {
156     CARD8       reqType;
157     CARD8       syncReqType;
158     CARD16      length B16;
159     XSyncCounter cid B32;
160     INT32       value_hi B32;
161     CARD32      value_lo B32;
162 } xSyncSetCounterReq;
163 #define sz_xSyncSetCounterReq   16
164
165 /*
166  * Destroy Counter
167  */
168 typedef struct _xSyncDestroyCounterReq {
169     CARD8       reqType;
170     CARD8       syncReqType;
171     CARD16      length B16;
172     XSyncCounter counter B32;
173 } xSyncDestroyCounterReq;
174 #define sz_xSyncDestroyCounterReq       8
175
176 /*
177  * Query Counter
178  */
179 typedef struct _xSyncQueryCounterReq {
180     CARD8       reqType;
181     CARD8       syncReqType;
182     CARD16      length B16;
183     XSyncCounter counter B32;
184 } xSyncQueryCounterReq;
185 #define sz_xSyncQueryCounterReq         8
186
187
188 typedef struct {
189     BYTE        type;
190     CARD8       unused;
191     CARD16      sequenceNumber B16;
192     CARD32      length B32;
193     INT32       value_hi B32;
194     CARD32      value_lo B32;
195     CARD32      pad0 B32;
196     CARD32      pad1 B32;
197     CARD32      pad2 B32;
198     CARD32      pad3 B32;
199 } xSyncQueryCounterReply;
200 #define sz_xSyncQueryCounterReply       32
201
202 /*
203  * Await
204  */
205 typedef struct _xSyncAwaitReq {
206     CARD8       reqType;
207     CARD8       syncReqType;
208     CARD16      length B16;
209 } xSyncAwaitReq;
210 #define sz_xSyncAwaitReq                4
211
212 typedef struct _xSyncWaitCondition {
213     XSyncCounter counter B32;
214     CARD32      value_type B32;
215     INT32       wait_value_hi B32;
216     CARD32      wait_value_lo B32;
217     CARD32      test_type B32;
218     INT32       event_threshold_hi B32;
219     CARD32      event_threshold_lo B32;
220 } xSyncWaitCondition;
221 #define sz_xSyncWaitCondition           28
222
223 /*
224  * Create Alarm
225  */
226 typedef struct _xSyncCreateAlarmReq {
227     CARD8       reqType;
228     CARD8       syncReqType;
229     CARD16      length B16;
230     XSyncAlarm  id B32;
231     CARD32      valueMask B32;
232 } xSyncCreateAlarmReq;
233 #define sz_xSyncCreateAlarmReq          12
234
235 /*
236  * Destroy Alarm
237  */
238 typedef struct _xSyncDestroyAlarmReq {
239     CARD8       reqType;
240     CARD8       syncReqType;
241     CARD16      length B16;
242     XSyncAlarm  alarm B32;
243 } xSyncDestroyAlarmReq;
244 #define sz_xSyncDestroyAlarmReq         8
245
246 /*
247  * Query Alarm
248  */
249 typedef struct _xSyncQueryAlarmReq {
250     CARD8       reqType;
251     CARD8       syncReqType;
252     CARD16      length B16;
253     XSyncAlarm  alarm B32;
254 } xSyncQueryAlarmReq;
255 #define sz_xSyncQueryAlarmReq           8
256
257 typedef struct {
258     BYTE        type;
259     CARD8       unused;
260     CARD16      sequenceNumber B16;
261     CARD32      length B32;
262     XSyncCounter counter B32;
263     CARD32      value_type B32;
264     INT32       wait_value_hi B32;
265     CARD32      wait_value_lo B32;
266     CARD32      test_type      B32;
267     INT32       delta_hi B32;
268     CARD32      delta_lo B32;
269     BOOL        events;
270     BYTE        state;
271     BYTE        pad0;
272     BYTE        pad1;
273 } xSyncQueryAlarmReply;
274 #define sz_xSyncQueryAlarmReply         40
275
276 /*
277  * Change Alarm
278  */
279 typedef struct _xSyncChangeAlarmReq {
280     CARD8       reqType;
281     CARD8       syncReqType;
282     CARD16      length B16;
283     XSyncAlarm  alarm B32;
284     CARD32      valueMask B32;
285 } xSyncChangeAlarmReq;
286 #define sz_xSyncChangeAlarmReq          12
287
288 /*
289  * SetPriority
290  */
291 typedef struct _xSyncSetPriority{
292     CARD8       reqType;
293     CARD8       syncReqType;
294     CARD16      length B16;
295     CARD32      id B32;
296     INT32       priority B32;
297 } xSyncSetPriorityReq;
298 #define sz_xSyncSetPriorityReq          12
299
300 /*
301  * Get Priority
302  */
303 typedef struct _xSyncGetPriority{
304     CARD8       reqType;
305     CARD8       syncReqType;
306     CARD16      length B16;
307     CARD32      id B32; /*XXX XID? */
308 } xSyncGetPriorityReq;
309 #define sz_xSyncGetPriorityReq           8
310
311 typedef struct {
312     BYTE        type;
313     CARD8       unused;
314     CARD16      sequenceNumber B16;
315     CARD32      length B32;
316     INT32       priority B32;
317     CARD32      pad0 B32;
318     CARD32      pad1 B32;
319     CARD32      pad2 B32;
320     CARD32      pad3 B32;
321     CARD32      pad4 B32;
322 } xSyncGetPriorityReply;
323 #define sz_xSyncGetPriorityReply        32
324
325 /*
326  * Events
327  */
328
329 typedef struct _xSyncCounterNotifyEvent {
330     BYTE        type;
331     BYTE        kind;
332     CARD16      sequenceNumber B16;
333     XSyncCounter counter B32;
334     INT32       wait_value_hi B32;
335     CARD32      wait_value_lo B32;
336     INT32       counter_value_hi B32;
337     CARD32      counter_value_lo B32;
338     CARD32      time B32;
339     CARD16      count B16;
340     BOOL        destroyed;
341     BYTE        pad0;
342 } xSyncCounterNotifyEvent;
343
344 typedef struct _xSyncAlarmNotifyEvent {
345     BYTE        type;
346     BYTE        kind;
347     CARD16      sequenceNumber B16;
348     XSyncAlarm  alarm B32;
349     INT32       counter_value_hi B32;
350     CARD32      counter_value_lo B32;
351     INT32       alarm_value_hi B32;
352     CARD32      alarm_value_lo B32;
353     CARD32      time B32;
354     CARD8       state;
355     BYTE        pad0;
356     BYTE        pad1;
357     BYTE        pad2;
358 } xSyncAlarmNotifyEvent;
359
360 #undef XSyncCounter
361 #undef XSyncAlarm
362
363 #endif /* _SYNC_OS */
364
365 #ifdef _SYNC_SERVER
366
367 #define CARD64 XSyncValue /* XXX temporary! need real 64 bit values for Alpha */
368
369 typedef struct _SyncCounter {
370     ClientPtr           client; /* Owning client. 0 for system counters */
371     XSyncCounter        id;             /* resource ID */
372     CARD64              value;          /* counter value */
373     struct _SyncTriggerList *pTriglist; /* list of triggers */
374     Bool                beingDestroyed; /* in process of going away */
375     struct _SysCounterInfo *pSysCounterInfo; /* NULL if not a system counter */
376 } SyncCounter;
377
378 /*
379  * The System Counter interface
380  */
381
382 typedef enum {
383     XSyncCounterNeverChanges,
384     XSyncCounterNeverIncreases,
385     XSyncCounterNeverDecreases,
386     XSyncCounterUnrestricted
387 } SyncCounterType;
388
389 typedef struct _SysCounterInfo {
390     char        *name;
391     CARD64      resolution;
392     CARD64      bracket_greater;
393     CARD64      bracket_less;
394     SyncCounterType counterType;  /* how can this counter change */
395     void        (*QueryValue)(
396 #if NeedNestedPrototypes
397                               pointer /*pCounter*/,
398                               CARD64 * /*freshvalue*/
399 #endif
400 );
401     void        (*BracketValues)(
402 #if NeedNestedPrototypes
403                                  pointer /*pCounter*/,
404                                  CARD64 * /*lessthan*/,
405                                  CARD64 * /*greaterthan*/
406 #endif
407 );
408 } SysCounterInfo;
409
410
411
412 typedef struct _SyncTrigger {
413     SyncCounter *pCounter;
414     CARD64      wait_value;     /* wait value */
415     unsigned int value_type;     /* Absolute or Relative */
416     unsigned int test_type;     /* transition or Comparision type */
417     CARD64      test_value;     /* trigger event threshold value */
418     Bool        (*CheckTrigger)(
419 #if NeedNestedPrototypes
420                                 struct _SyncTrigger * /*pTrigger*/,
421                                 CARD64 /*newval*/
422 #endif
423                                 );
424     void        (*TriggerFired)(
425 #if NeedNestedPrototypes
426                                 struct _SyncTrigger * /*pTrigger*/
427 #endif
428                                 );
429     void        (*CounterDestroyed)(
430 #if NeedNestedPrototypes
431                                 struct _SyncTrigger * /*pTrigger*/
432 #endif
433                                     );
434 } SyncTrigger;
435
436 typedef struct _SyncTriggerList {
437     SyncTrigger *pTrigger;
438     struct _SyncTriggerList *next;
439 } SyncTriggerList;
440
441 typedef struct _SyncAlarmClientList {
442     ClientPtr   client;
443     XID         delete_id;
444     struct _SyncAlarmClientList *next;
445 } SyncAlarmClientList;
446
447 typedef struct _SyncAlarm {
448     SyncTrigger trigger;
449     ClientPtr   client;
450     XSyncAlarm  alarm_id;
451     CARD64      delta;
452     int         events;
453     int         state;
454     SyncAlarmClientList *pEventClients;
455 } SyncAlarm;
456
457 typedef struct {
458     ClientPtr   client;
459     CARD32      delete_id;
460     int         num_waitconditions;
461 } SyncAwaitHeader;
462
463 typedef struct {
464     SyncTrigger trigger;
465     CARD64      event_threshold;
466     SyncAwaitHeader *pHeader;
467 } SyncAwait;
468
469 typedef union {
470     SyncAwaitHeader header;
471     SyncAwait       await;
472 } SyncAwaitUnion;
473
474
475 extern pointer SyncCreateSystemCounter(
476 #if NeedFunctionPrototypes
477     char *      /* name */,
478     CARD64      /* inital_value */,
479     CARD64      /* resolution */,
480     SyncCounterType /* change characterization */,
481     void        (* /*QueryValue*/ ) (), /* XXX prototype */
482     void        (* /*BracketValues*/) ()
483 #endif
484 );
485
486 extern void SyncChangeCounter(
487 #if NeedFunctionPrototypes
488     SyncCounter *       /* pCounter*/,
489     CARD64              /* new_value */
490 #endif
491 );
492
493 extern void SyncDestroySystemCounter(
494 #if NeedFunctionPrototypes
495     pointer pCounter
496 #endif
497 );
498 extern void InitServertime();
499
500 #endif /* _SYNC_SERVER */