File: hwcext.h

package info (click to toggle)
glide 2002.04.10ds1-16
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 59,540 kB
  • sloc: ansic: 290,125; asm: 23,305; sh: 8,089; pascal: 3,854; makefile: 1,276; perl: 73
file content (951 lines) | stat: -rw-r--r-- 30,844 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
/*
** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONL
** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGH
** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DF
** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR 
** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 
**
** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT T
** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS I
** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013
** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FA
** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS O
** THE UNITED STATES. 
**
** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVE
*
/
**
** File name:   hwcext.h
**
** Description: Structures for the hwc extensions.
**
** $Header: hwcext.h, 9, 6/19/2000 7:55:50 PM, Adam Briggs
**
** $History: hwcext.h $
** 
** *****************  Version 38  *****************
** User: Doconnell    Date: 9/01/99    Time: 11:16a
** Updated in $/devel/h5/WinNT/Src/Video/Displays/h5
** Move mechanism for checking for O/S support of KNI instructions from
** V3_OEM_100, but change escape number so that it is not in Microsoft
** reserved range.  Also move a few declarations in preparation for moving
** Glide and TvOut changes from V3_OEM_100.
** 
** *****************  Version 37  *****************
** User: Adamb        Date: 8/18/99    Time: 10:14a
** Updated in $/devel/h5/minihwc
** changed glideState[]; extern back to glideState;
** 
** *****************  Version 36  *****************
** User: Sbrooks      Date: 8/17/99    Time: 8:59p
** Updated in $/devel/h3/minihwc
** Added support for HWCEXT2_ glide/driver protocol.
** 
** *****************  Version 34  *****************
** User: Andrew       Date: 8/06/99    Time: 6:22p
** Updated in $/devel/h5/Win9x/dx/dd16
** Added a function to get the slave registers
** 
** *****************  Version 33  *****************
** User: Andrew       Date: 8/06/99    Time: 4:40p
** Updated in $/devel/h5/Win9x/dx/dd16
** Added new members to structures and new Glide PCI Functions
** 
** *****************  Version 32  *****************
** User: Jw           Date: 8/02/99    Time: 12:49p
** Updated in $/devel/h5/WinNT/Src/Video/Displays/h5
** Support both old and new ext_hwc values for Glide.
** 
** *****************  Version 31  *****************
** User: Sbrooks      Date: 6/14/99    Time: 12:35p
** Updated in $/devel/h3/minihwc
** First draft of Version 2 of the HWCEXT (ExtEscape) functions required
** by glide
** 
** *****************  Version 30  *****************
** User: Stb_sbrooks  Date: 6/07/99    Time: 4:08p
** Updated in $/devel/h3/minihwc
** Changed EXT_HWC. Previous value was illegal.
** 
** *****************  Version 29  *****************
** User: Stb_lpost    Date: 6/07/99    Time: 12:00p
** Updated in $/devel/h3/win95/dx/dd16
** V3TV Fixes Initial PLD656 Support
** 
** *****************  Version 28  *****************
** User: Stb_lpost    Date: 5/17/99    Time: 1:43p
** Updated in $/devel/h3/win95/dx/dd16
** V3TV Video Capture fixes for E3 Demo
** 
** *****************  Version 27  *****************
** User: Dow          Date: 4/22/99    Time: 3:40p
** Updated in $/devel/h3/minihwc
** Alt tab on NT
** 
** *****************  Version 26  *****************
** User: Dow          Date: 4/15/99    Time: 5:31p
** Updated in $/devel/h3/minihwc
** Alt-Tab on NT
** 
** *****************  Version 25  *****************
** User: Dow          Date: 4/05/99    Time: 3:48p
** Updated in $/devel/H3/minihwc
** Added hwcExtContextRes_t
** 
** *****************  Version 24  *****************
** User: Sreid        Date: 4/04/99    Time: 4:11p
** Updated in $/devel/h3/minihwc
** Added mechanism to coordinate loss of context between app and DD
** 
** *****************  Version 23  *****************
** User: Xingc        Date: 3/22/99    Time: 2:41p
** Updated in $/devel/h3/Win95/dx/dd16
** Add HWCEXT_OVERLAY_DATA case and hwcExtOVLInforRest_t structure to pass
** overlay informat out.
** 
** *****************  Version 22  *****************
** User: Michael      Date: 2/26/99    Time: 10:21a
** Updated in $/devel/h3/Win95/dx/dd16
** Proxy for KenW - These changes make alt-tab from apps *much*
** more reliable.  I now see no corruption or hangs from glquake or
** heretic2.   NBA98 also worked.  PRS 3320 is possibly associated.  There
** may be others.
** 
** *****************  Version 21  *****************
** User: Stuartb      Date: 1/08/99    Time: 11:05a
** Updated in $/devel/h3/Win95/dx/dd16
** Backed out LCDCTRL changes as advised by KMW.
** 
** *****************  Version 20  *****************
** User: Stuartb      Date: 1/07/99    Time: 12:18p
** Updated in $/devel/h3/Win95/dx/dd16
** Added HWCEXT_LCDCTRL for control panel flat panel ops.
** 
** *****************  Version 19  *****************
** User: Michael      Date: 12/29/98   Time: 1:19p
** Updated in $/devel/h3/Win95/dx/dd16
** Implement the 3Dfx/STB unified header.
**
*/
#ifndef HWCEXT_H
#define HWCEXT_H

#ifndef WINNT

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

/*
** D3D notification function
*/

extern void D3notify(void);

#endif /* WINNT */

/*
**  Constants
*/
#define HWCEXT_PROTOCOLREV              0x1

#define HWCEXT_MAX_BASEADDR             0x9
#define HWCEXT_MAX_COLORBUFFERS         0x3

/* The HWC escape */
#define EXT_HWC                         0x3df3
#define EXT_HWC_OLD                     0xfd3

/*
**  EXT_HWC_SHARE_CPUTYPE
**
**  Share CPU Type with the calling process
**  
*/
#define EXT_HWC_SHARE_CPUTYPE        0x3df4

/********************************************************************
**  Here's the protocol:
*********************************************************************/

/*
**  HWCEXT_GETDRIVERVERION
**
**  INPUT:      Nothing
**  OUTPUT:     Driver Major & Minor Version
*/
#define HWCEXT_GETDRIVERVERSION        0x0
typedef struct hwcExtDriverVersionRes_s {
  FxU32
    major,                      /* Driver major version */
    minor;                      /* Driver minor version */
} hwcExtDriverVersionRes_t;

/* 
**  HWCEXT_ALLOCCONTEXT
**
**  INPUT:      Nothing
**  OUTPUT:     Context ID
*/
#define HWCEXT_ALLOCCONTEXT             0x1


#define HWCEXT_ABAPPTYPE_FSEM           0x0 /* Full-screen app */
#define HWCEXT_ABAPPTYPE_WIND           0x1 /* Windowed app */

/* Given to HWCEXT_ALLOCCONTEXT */
typedef struct hwcExtAllocContextReq_s {
  FxU32
    protocolRev,                /* Revision of this protocol */
    appType;                    /* FSEM or WIND */
} hwcExtAllocContextReq_t;

/* Returned from  HWCEXT_ALLOCCONTEXT*/
typedef struct hwcExtAllocContextRes_s {
  FxU32
    contextID;
} hwcExtAllocContextRes_t;

/* 
**  HWCEXT_GETDEVICECONFIG
**  
**  INPUT:      Device number (0 for first, 1 for second....)
**  OUTPUT:     VendorID, deviceID, fbRAM, chip rev
*/
#define HWCEXT_GETDEVICECONFIG          0x2
/* Given to HWCEXT_GETDEVICECONFIG */
typedef struct hwcExtDeviceConfigReq_s {
  HDC
    dc;                         /* Device context */
  FxU32
    devNo;                      /* Device number (0, 1, ...) */
} hwcExtDeviceConfigReq_t;

/* Returned from HWCEXT_GETDEVICECONFIG */
typedef struct hwcExtDeviceConfigRes_s {
  FxU32
    devNum,                     /* Device Number */
    vendorID,                   /* PCI Vendor ID */
    deviceID,                   /* PCI Device ID */
    fbRam,                      /* How much frame buuffer RAM  */
    chipRev;                    /* Chip Revision */
  FxU32 
    pciStride,                  /* 1024, 2048, 4096, 8192, 16384 */
    hwStride,                   /* hardware x-translation stride  */
    tileMark;                   /* hardware tile addressing watermark */
  FxU32 isMaster;               /* True if device is a Master */
  FxU32 numChips;               /* Number of Chips 1-4 */
} hwcExtDeviceConfigRes_t;

/* 
**  HWCEXT_GETLINEARADDR
**
**  INPUT:      Device number
**  OUTPUT:     Number of base addresses, base address list
*/
#define HWCEXT_GETLINEARADDR            0x3
/* Given to HWCEXT_GETLINEARADDR */
typedef struct hwcExtLinearAddrReq_s {
  FxU32 devNum;                 /* Device Number */
  FxU32 pHandle;                /* Process Handle */
} hwcExtLinearAddrReq_t;

/* Returned from HWCEXT_GETLINEARADDR */
typedef struct hwcExtLinearAddrRes_s {
  FxU32
    numBaseAddrs;               /* # base addresses */
  AnyPtr
    baseAddresses[HWCEXT_MAX_BASEADDR]; /* linear Addresses  */
} hwcExtLinearAddrRes_t;

/*
**  HWCEXT_ALLOCFIFO
**  
** OBSOLTE: Do not use
*/
#define HWCEXT_ALLOCFIFO             0x4

typedef struct hwcExtAllocFIFORes_s {
  FxU32
    commandBuffer,              /* Command buffer */
    commandBufferSz,            /* Size of command buffer */
    psBuffer,                   /* Persistent state buffer */
    psBufferSz;                 /* Size of persistent state buffer */
} hwcExtAllocFIFORes_t;

/*  
**  HWCEXT_EXECUTEFIFO
**
**  INPUT:      ptr to FIFO buffer, fifosize, persistent state FIFO & size
**  OUTPUT:     Status only.
**
*/
#define HWCEXT_EXECUTEFIFO      0x5

/* Given to HWCEXT_EXECUTEFIFO */
typedef struct hwcExtExecuteFifoReq_s {
  /* NB: These fields must be first to support old drivers that do not
   * support multiple fifo types.  
   */
  FxU32
    fifoPtr,        /* Linear address of command stream to execute */
    fifoSize,       /* Size of command stream (DWORDS) */
    statePtr,       /* Linear address of persistent state buffer */
    stateSize;      /* Size of persistent state buffer (DWORDS) */
  
  FxU32
    fifoType;       /* One of HWCEXT_FIFO_XXXX */

  /* These are only necessary if fifoType != HWCEXT_FIFO_HOST */
  FxU32
    fifoOffset,     /* HW relative address of command stream */
    stateOffset,    /* HW relative address of state buffer */
    sentinalOffset, /* HW relative address of buffer to write serialNumber */
    serialNumber;   /* Client specified value to write to indicate that the
                       * current command stream has been committed by the hw.
                       */
#ifdef ENABLE_V3_W2K_GLIDE_CHANGES
    FxU32 procId;
#endif
  
} hwcExtExecuteFifoReq_t;

/* 
**  HWCEXT_QUERYCONTEXT
**
**  INPUT:      Context ID
**  OUTPUT:     Status 
*/
#define HWCEXT_QUERYCONTEXT     0x6

#define HWC_CONTEXT_ACTIVE      0x0
#define HWC_CONTEXT_LOST        0x1

/*
**  HWCEXT_RELEASECONTEXT
**  
**  INPUT:      Context ID
**  OUTPUT:     Status
*/
#define HWCEXT_RELEASECONTEXT   0x7

/* Given to HWCEXT_RELEASECONTEXT */
typedef struct hwcExtReleaseContextReq_s {
  FxU32
    contextID;                  /* duh */
#ifdef ENABLE_V3_W2K_GLIDE_CHANGES
  FxU32
    procID;
#endif
} hwcExtReleaseContextReq_t;

#define HWCEXT_HWCSETEXCLUSIVE  0x8
#define HWCEXT_HWCRLSEXCLUSIVE  0x9

/*
**  HWCEXT_I2C_WRITE_REQ
**
**  INPUT: i2c address, register number, dwValue to write
**  OUTPUT: status   (FXTRUE if OK, FXFALSE if fail, I2C_BUSY if busy)
*/

#define HWCEXT_I2C_WRITE_REQ    0xa

typedef struct hwcExtI2CwriteReq_s {
        FxU32 deviceAddress;    /* bus address of device */
        FxU32 i2c_regNum;       /* sometimes called subaddress */
        FxU32 i2c_regValue;     /* the value to write */
} hwcExtI2CwriteReq_t;

/*
**  HWCEXT_I2C_READ_REQ
**
**  INPUT: i2c address, register number
**  OUTPUT: status   (FXTRUE if OK, FXFALSE if fail, I2C_BUSY if busy)
**          value read: optRes.i2c_ReadRes.i2c_regValue
*/

#define HWCEXT_I2C_READ_REQ     0xb

typedef struct hwcExtI2CreadReq_s {
        FxU32 deviceAddress;    /* bus address of device */
        FxU32 i2c_regNum;       /* sometimes called subaddress */
} hwcExtI2CreadReq_t;

#define HWCEXT_I2C_READ_RES     0xc

typedef struct hwcExtI2CreadRes_s {
        FxU32 i2c_regValue;     /* the value read from reg above */
} hwcExtI2CreadRes_t;

/*
**  HWCEXT_I2C_WRITE_REQ
**
**  INPUT: i2c address, register number, dwValue to write
**  OUTPUT: status   (FXTRUE if OK, FXFALSE if fail, I2C_BUSY if busy)
*/

#define HWCEXT_I2C_MULTI_WRITE_REQ    0xd
typedef struct hwcExtI2CmultiWriteReq_s {
        FxU32 deviceAddress;    /* bus address of device */
        FxU32 i2c_regNum;       /* sometimes called subaddress */
        FxU8  *i2c_regValues;   /* the value to write */
        FxU32 i2c_numBytes;     /* number of bytes to xfer */
} hwcExtI2CmultiWriteReq_t;


/*
**  HWCEXT_GETAGPINFO
**
**  Get the relavent AGP info:  linear address, physical address, size.
*/
#define HWCEXT_GETAGPINFO            0xe
typedef struct hwcExtAGPInfoRes_s {
  FxU32
    lAddr,                      /* Linear Address of AGP memory */
    pAddr,                      /* Physical Address of AGP memory */
    size;                       /* Size */
} hwcExtAGPInfoRes_t;

/*
**  HWCEXT_VIDTIMING
**
**  Send the FxVidTiming structure to the driver.
**
*/
#define HWCEXT_VIDTIMING        0xf
typedef struct hwcExtVidTimingReq_s {
  void *vidTiming;
} hwcExtVidTimingReq_t;

/* HWCEXT_FIFOINFO
 *
 * Find out information about the current physcal location of the
 * current command fifo.  
 */
#define HWCEXT_FIFOINFO         0x10UL

#define HWCEXT_FIFO_INVALID      0x00UL
#define HWCEXT_FIFO_FB           0x01UL /* FIFO in frame buffer */
#define HWCEXT_FIFO_HOST         0x02UL /* FIFO in host memory */
#define HWCEXT_FIFO_AGP          0x03UL /* FIFO in AGP */

typedef struct {
  FxU32 fifoType; 
} hwcExtFifoInfoRes_t;

/* Returns the offset that a linear address is from a given 'base'
 * linear page address. This offset is suitable for use as a hw
 * relative address for buffers etc.
 *
 *  mapAddr: Linear address used to be the 'base' of the physical
 *           address also mapped by remapAddr. 
 *  remapAddr: Target linear addr to compute the offset for.
 */
#define HWCEXT_LINEAR_MAP_OFFSET        0x11UL

typedef struct {
  FxU32
    mapAddr,
    remapAddr;
} hwcExtLinearMapInfoReq_t;

typedef struct {
  FxU32 linAddrOffset;
} hwcExtLinearMapInfoRes_t;

/* HWCEXT_GAMMATABLE_DOWNLOAD
 *
 * Downloads a gamma table from app that is then impressed upon
 * the hardware. This is a transient gamma, and is not preserved
 * in the registry or anywhere in the drivers. There is no answer
 * or status return.
 *
 * INPUT: a pointer to a complete gamma table (256 entries)
 *
 * OUTPUT: none
 */
#define HWCEXT_DOWNLOAD_GAMMA                   0x12UL

typedef struct {
  FxU32 gammaPtr;
  FxI32 numGammaEntries;
} hwcExtDownloadGammaReq_t;


/* HWCEXT_RESTORE_DESKTOP
 *
 * Restores the video settings to those of the desktop before app
 * exclusive mode took over.   We need this because there are cases where
 * we do not get a mode set call (Enable1) when task-switching (e.g., ALT-TAB)
 * out of exclusive mode apps.  We do this by calling the same function
 * that is used to restore the desktop when returning from full screen
 * DOS mode.   This resets video, the cmdfifo, the desktop's cursor, sets
 * some overlay video flags saying that the desktop was reset, etc.
 *
 * INPUT: none
 * OUTPUT: none
 */
#define HWCEXT_RESTORE_DESKTOP                  0x13UL


/* HWCEXT_OVERLAY_DATA
 * Pass overlay address and overlay scale 
 * factors to TVPCI. 
 */
#define HWCEXT_OVERLAY_DATA                             0x14UL
typedef struct hwcExtOVLInfoRes_s {
  FxU32   ovlAddr;          /* Physical address of current overlay */
  FxU32   ovlXScale;
  FxU32   ovlYScale;
} hwcExtOVLInfoRes_t;

/*
** HWCEXT_SHARE_CONTEXT_DWORD
** This entry point gives the driver a place to write a 1 if app
** loses it's context.  App then checks this when it's getting its
** command FIFO information, and does the Right Thing if it isn't
** exclusive any more. 
*/
#define HWCEXT_SHARE_CONTEXT_DWORD          0x15UL
typedef struct hwcExtShareContextDWORDReq_s {
  FxU32 contextDWORD;           /* ring 3 pointer THIS IS FOR NT ONLY! */
} hwcExtShareContextDWORDReq_t;

typedef struct hwcExtShareContextDWORDRes_s {
  FxU32 contextDWORD;           /* ring0/ring3 pointer THIS IS FOR 9X ONLY! */
} hwcExtShareContextDWORDRes_t;

/*
**  HWCEXT_UNMAP_MEMORY
** 
**  This entry point tells the driver to unmap the memory that the app
**  has requested. 
*/
#define HWCEXT_UNMAP_MEMORY             0x16UL
typedef struct hwcExtUnmapMemoryReq_s {
  FxU32 procHandle;             /* Process handle */
} hwcExtUnmapMemoryReq_t;

/*
**  HWCEXT_CONTEXT_DWORD_NT
**
**  Similar to other context DWORD routine but subtly different for
**  differnces between NT and 9X.
*/
#define HWCEXT_CONTEXT_DWORD_NT     0x17UL
typedef struct hwcExtContextDwordNTReq_s {
  FxU32 procId;                 /* handle to current proc */
  FxU32 codeSegment;            /* I know it's 16-bit */
  FxU32 dataSegment;            /* I know it's 16-bit */
} hwcExtContextDwordNTReq_t;

typedef struct hwcExtContextDwordNTRes_s {
  FxU32 dwordOffset;            /* Ofsset of context DWORD in FB */
} hwcExtContextDwordNTRes_t;


#define HWCEXT_PCI_OP 0x18UL
#define HWCEXT_PCI_READ 0x00UL
#define HWCEXT_PCI_WRITE 0x01UL

typedef struct hwcExtPCIOpReq_s {
   FxU32 DeviceId;      /* Device PCI Function Number [0-3] */
   FxU32 Operation;      /* PCI Operation  HWCEXT_PCI_READ | HWCEXT_PCI_WRITE */
   FxU32 Offset;        /* PCI Offset [0-255] */
   FxU32 Value;         /* Used only for Writes */
} hwcExtPCIOpReq_t;

typedef struct hwcExtPCIOpRes_s {
   FxU32 Value;         /* Used only for Reads */
} hwcExtPCIOpRes_t;

#define HWCEXT_GET_SLAVE_REGS 0x19UL
#define HWCEXT_MAX_SLAVE_REGS (4)
typedef struct hwcExtSlaveRegReq_s {
   FxU32 DeviceId;      /* Device PCI Function Number [0-3] */
} hwcExtSlaveRegReq_t;

typedef struct hwcExtSlaveRegRes_s {
   FxU32 Regs[HWCEXT_MAX_SLAVE_REGS];
} hwcExtSlaveRegRes_t;

#ifdef ENABLE_V3_W2K_GLIDE_CHANGES
/*
** HWCEXT_PROTECT_CMD_FIFO
** 
** Called once when we start using the command fifo in order to tell
** NT / W2K to hold off on unmapping that view of the frame buffer and
** then called again once Glide knows it's lost its context so that
** the driver knows that it's now ok to unmap the memory.
*/
#define HWCEXT_PROTECT_CMD_FIFO 0x1A
typedef struct hwcExtProtectCmdFifoReq_s {
  FxU32 procId;                 /* handle to current proc */
  FxU32  linearAddress; /* Linear pointer to command fifo */
  FxBool protect;       /* Does it need protection or not */
} hwcExtProtectCmdFifoReq_t;
#endif

/*
** HWCEXT_SLI_AA_REQUEST
*
** I'm sorry this has to be here but I swear that IT'S NOT MY FAULT
*
** This escape should call into the miniport driver on NT and setup
** the master & slaves for the requested SLI or AA mode.  SLI &/or
** AA is disabled with the same call by setting dwaaEn = 0 && 
** dwsliEn = 0 in the request structure.
** 
** Keen observers may note that the following structures bear a
** remarkable resemblance to those structures that are passed
** to the miniport driver by the display driver to execute the
** same function.  They are duplicated here under different names
** to protect this code in the case that those structures are
** modified.
*/
#define HWCEXT_SLI_AA_REQUEST  0x1B

typedef struct _hwc_sli_aa_chipinfo
{
   DWORD dwChips ;         /* dwChips: Number of chips in multi-chip configuration (1-4) */
   DWORD dwsliEn ;         /* dwsliEn: Sli is to be enabled (0,1) */
   DWORD dwaaEn ;          /* dwaaEn: Anti-aliasing is to be enabled (0,1) */
   DWORD dwaaSampleHigh ;  /* dwaaSampleHigh: 0->Enable 2-sample AA, 1->Enable 4-sample AA */
   DWORD dwsliAaAnalog ;   /* dwsliAaAnalog: 0->Enable digital SLI/AA, 1->Enable analog Sli/AA */
   DWORD dwsli_nlines ;    /* dwsli_nLines: Number of lines owned by each chip in SLI (2-128) */
   DWORD dwCfgSwapAlgorithm ; /* Swap Buffer Algorithm */
}  HWCSLI_AA_CHIPINFO ;

typedef struct _hwc_sli_aa_meminfo
{
   DWORD dwTotalMemory ;
   DWORD dwTileMark ;
   DWORD dwTileCmpMark ;
   DWORD dwaaSecondaryColorBufBegin ;
   DWORD dwaaSecondaryDepthBufBegin ;
   DWORD dwaaSecondaryDepthBufEnd ;
   DWORD dwBpp ;
}  HWCSLI_AA_MEMINFO ; 

typedef struct hwcExtSliAAReq_s
{
   HWCSLI_AA_CHIPINFO ChipInfo ;
   HWCSLI_AA_MEMINFO  MemInfo ;
} hwcExtSliAAReq_t ;

/*
**  The Request structure (given as input data to ExtEscape() )
*/
typedef struct hwcExtRequest_s {
  FxU32
    contextID,                  /* ID of this context */
    which;                      /* Which request */
  union reqOptData {
    hwcExtAllocContextReq_t             allocContextReq;
    hwcExtDeviceConfigReq_t             deviceConfigReq;
    hwcExtLinearAddrReq_t               linearAddrReq;
    hwcExtExecuteFifoReq_t              executeFifoReq;
    hwcExtReleaseContextReq_t           releaseContextReq;
    hwcExtI2CwriteReq_t                 i2c_WriteReq;
    hwcExtI2CreadReq_t                  i2c_ReadReq;
    hwcExtI2CmultiWriteReq_t            i2c_MultiWriteReq;
    hwcExtVidTimingReq_t                vidTimingReq;
    hwcExtLinearMapInfoReq_t            mapInfoReq;
    hwcExtDownloadGammaReq_t            gamma;
    hwcExtShareContextDWORDReq_t        shareContextDWORDReq;
    hwcExtUnmapMemoryReq_t              unmapMemoryReq;
    hwcExtContextDwordNTReq_t           contextDwordNTReq;
    hwcExtPCIOpReq_t                    pciOpReq;
    hwcExtSlaveRegReq_t                 slaveRegReq;
#ifdef ENABLE_V3_W2K_GLIDE_CHANGES
    hwcExtProtectCmdFifoReq_t           protectCmdFifo;
#endif
    hwcExtSliAAReq_t                    sliAAReq ;
  } optData;
} hwcExtRequest_t;

typedef struct hwcExtResult_s {
  FxI32
    resStatus;
  union resOptData {
    hwcExtDriverVersionRes_t    driverVersionRes;
    hwcExtAllocContextRes_t     allocContextRes;
    hwcExtDeviceConfigRes_t     deviceConfigRes;    
    hwcExtLinearAddrRes_t       linearAddressRes;
    hwcExtAllocFIFORes_t        allocFifoRes;
    hwcExtI2CreadRes_t          i2c_ReadRes;
    hwcExtAGPInfoRes_t          agpInfoRes;
    hwcExtFifoInfoRes_t         fifoInfoRes;
    hwcExtLinearMapInfoRes_t    mapInfoRes;
    hwcExtOVLInfoRes_t          ovlInfoRes;
    /* no result for gamma download */
    hwcExtShareContextDWORDRes_t  shareContextDWORDRes;
    hwcExtContextDwordNTRes_t   contextDwordNTRes;
    hwcExtPCIOpRes_t                    pciOpRes;
    hwcExtSlaveRegRes_t          slaveRegRes;
  } optData;
} hwcExtResult_t;

#define HWCEXT2_GETPROTOCOLREVISION 0x100UL

typedef struct hwcExt2ProtocolRevisionRes_s {
  FxU32
    major,                      /* Driver major version */
    minor;                      /* Driver minor version */
} hwcExt2ProtocolRevisionRes_t;

#define HWCEXT2_GETDRIVERVERSION	0x101UL

typedef struct hwcExt2DriverVersionRes_s {
  FxU32
    major,                      /* Driver major version */
    minor;                      /* Driver minor version */
} hwcExt2DriverVersionRes_t;

#define HWCEXT2_ALLOCCONTEXT	0x102UL

#define HWCEXT2_ABAPPTYPE_FSEM           0x0 /* Full-screen app */
#define HWCEXT2_ABAPPTYPE_WIND           0x1 /* Windowed app */

typedef struct hwcExt2AllocContextReq_s {
  FxU32
    protocolRev,                /* Revision of this protocol */
    appType;                    /* FSEM or WIND */
} hwcExt2AllocContextReq_t;

typedef struct hwcExt2AllocContextRes_s {
  FxU32
    contextID;
} hwcExt2AllocContextRes_t;

#define HWCEXT2_GETDEVICECONFIG	0x103UL

typedef struct hwcExt2DeviceConfigReq_s {
  HDC
    dc;                         /* Device context */
  FxU32
    devNo;                      /* Device number (0, 1, ...) */
} hwcExt2DeviceConfigReq_t;

typedef struct hwcExt2DeviceConfigRes_s {
  FxU32
    devNum,                     /* Device Number */
    vendorID,                   /* PCI Vendor ID */
    deviceID,                   /* PCI Device ID */
    fbRam,                      /* How much frame buuffer RAM  */
    chipRev;                    /* Chip Revision */
  FxU32 
    pciStride,                  /* 1024, 2048, 4096, 8192, 16384 */
    hwStride,                   /* hardware x-translation stride  */
    tileMark;                   /* hardware tile addressing watermark */
} hwcExt2DeviceConfigRes_t;

#define HWCEXT2_GETLINEARMAP	0x104UL

typedef struct hwcExt2LinearMapReq_s {
  FxU32 devNum;                 /* Device Number */
  FxU32 pHandle;                /* Process Handle */
} hwcExt2LinearMapReq_t;

# define HWCEXT2_MAX_BASEADDR HWCEXT_MAX_BASEADDR

typedef struct hwcExt2LinearMapRes_s {
  FxU32
    numBaseAddrs,               /* # base addresses */
    baseAddresses[HWCEXT2_MAX_BASEADDR]; /* linear Addresses  */
} hwcExt2LinearMapRes_t;

#define HWCEXT2_EXECUTEFIFO 0x105UL

typedef struct hwcExt2ExecuteFifoReq_s {
  /* NB: These fields must be first to support old drivers that do not
   * support multiple fifo types.  
   */
  FxU32
    fifoPtr,        /* Linear address of command stream to execute */
    fifoSize,       /* Size of command stream (DWORDS) */
    statePtr,       /* Linear address of persistent state buffer */
    stateSize;      /* Size of persistent state buffer (DWORDS) */
  
  FxU32
    fifoType;       /* One of HWCEXT2_FIFO_XXXX */

  /* These are only necessary if fifoType != HWCEXT2_FIFO_HOST */
  FxU32
    fifoOffset,     /* HW relative address of command stream */
    stateOffset,    /* HW relative address of state buffer */
    sentinalOffset, /* HW relative address of buffer to write serialNumber */
    serialNumber;   /* Client specified value to write to indicate that the
                       * current command stream has been committed by the hw.
                       */
} hwcExt2ExecuteFifoReq_t;

#define HWCEXT2_RELEASECONTEXT 0x106UL

typedef struct hwcExt2ReleaseContextReq_s {
  FxU32
    contextID;                  /* duh */
} hwcExt2ReleaseContextReq_t;

#define HWCEXT2_HWCSETEXCLUSIVE  0x8
#define HWCEXT2_HWCRLSEXCLUSIVE  0x9

#define HWCEXT2_GETAGPINFO	0x107UL

typedef struct hwcExt2AGPInfoRes_s {
  FxU32
    lAddr,                      /* Linear Address of AGP memory */
    pAddr,                      /* Physical Address of AGP memory */
    size;                       /* Size */
} hwcExt2AGPInfoRes_t;

#define HWCEXT2_GETFIFOINFO	0x108UL

#define HWCEXT2_FIFO_INVALID      0x00UL
#define HWCEXT2_FIFO_FB           0x01UL /* FIFO in frame buffer */
#define HWCEXT2_FIFO_HOST         0x02UL /* FIFO in host memory */
#define HWCEXT2_FIFO_AGP          0x03UL /* FIFO in AGP */

typedef struct {
  FxU32 fifoType; 
} hwcExt2FifoInfoRes_t;

#define HWCEXT2_LINEAR_MAP_OFFSET	0x109UL

typedef struct {
  FxU32
    mapAddr,
    remapAddr;
} hwcExt2LinearMapInfoReq_t;

typedef struct {
  FxU32 linAddrOffset;
} hwcExt2LinearMapInfoRes_t;

#define HWCEXT2_SHARE_CONTEXT_DATA	0x110UL

typedef struct hwcExt2ShareContextDataRes_s {
  FxU32 contextDWORD;           /* ring0/ring3 pointer */
  FxU32 fifoRoom;			 /* ring0/ring3 pionter */
} hwcExt2ShareContextDataRes_t;

#define HWCEXT2_UNMAP_MEMORY	0x111UL

typedef struct hwcExt2UnmapMemoryReq_s {
  FxU32 procHandle;             /* Process handle */
} hwcExt2UnmapMemoryReq_t;

typedef struct hwcExt2Request_s {
  FxU32
    contextID,                  /* ID of this context */
    which;                      /* Which request */
  union reqOptionalData{
    hwcExt2AllocContextReq_t             allocContextReq;
    hwcExt2DeviceConfigReq_t             deviceConfigReq;
    hwcExt2LinearMapReq_t                linearMapReq;
    hwcExt2ExecuteFifoReq_t              executeFifoReq;
    hwcExt2ReleaseContextReq_t           releaseContextReq;
    hwcExtI2CwriteReq_t                  i2c_WriteReq;
    hwcExtI2CreadReq_t                   i2c_ReadReq;
    hwcExtI2CmultiWriteReq_t			 i2c_MultiWriteReq;
    hwcExt2LinearMapInfoReq_t            mapInfoReq;
    hwcExt2UnmapMemoryReq_t              unmapMemoryReq;
  } optData;
} hwcExt2Request_t;

typedef struct hwcExt2Result_s {
  FxI32
    resStatus;
  union resOptionalData{
    hwcExt2ProtocolRevisionRes_t protocolRevisionRes;
    hwcExt2DriverVersionRes_t    driverVersionRes;
    hwcExt2AllocContextRes_t     allocContextRes;
    hwcExt2DeviceConfigRes_t     deviceConfigRes;    
    hwcExt2LinearMapRes_t       linearMapRes;
    hwcExtI2CreadRes_t          i2c_ReadRes;
    hwcExt2AGPInfoRes_t          agpInfoRes;
    hwcExt2FifoInfoRes_t         fifoInfoRes;
    hwcExt2LinearMapInfoRes_t    mapInfoRes;
    /* no result for gamma download */
    hwcExt2ShareContextDataRes_t   contextDataRes;
  } optData;
} hwcExt2Result_t;


#ifdef WINNT
/*
 * Global structure used to store app state, used by the display driver
 *
 *   This will need changing if one driver supports multiple boards.
 *
 */

#ifdef ENABLE_V3_W2K_GLIDE_CHANGES
#define _GLIDE_TOTAL_COMMAND_FIFOS 0x02
#endif

typedef struct
{
    LONG        glideGDIFlags;  /* For cooperation with GDI.(Exclusive flag) */
    HANDLE      glideProcessHandle; /* Handle of glide process that last mapped membases */
    LONG        glideReferenceCount ; /* this must be zero before the memory is unmapped */
    BYTE*       glideRegBase;           /* Saved glide register base address */
    BYTE*       glideLfbBase;           /* Saved glide Lfb base address - for mapping only */
    BYTE*       glideScreenBase;        /* Saved glide screen base address - used by glide. */
    BYTE*       glideIOBase;
    //ULONG       vidProcCfg
    //ULONG       vidDesktopOverlayStride
#ifdef SLI_AA
    BYTE        *glideSlaveRegBase[HWINFO_SST_MAX_NUM_CHIPS * HWINFO_SST_MAX_CHIP_INDEX];
#endif

#if (_WIN32_WINNT >= 0x0500)
    PDEV        *ppdev;
    ULONG       contextDWORDNTIndex;
    ULONG       fifoType;
    ULONG       lastFifoOffset;
    ULONG       lastFifoSize;
    ULONG       lastStateOffset;
    ULONG       lastStateSize;
#endif

#ifdef ENABLE_V3_W2K_GLIDE_CHANGES
	// flag to indicate that GLIDE has requested its command fifo memory be protected through
	// an unmapping process
	DWORD dwProtectCmdFifo;

	// flag to indicate that the memory previously requested to be unmapped should now
	// be unmapped
	DWORD dwUnMapMemoryLFB;

	// pointer to each of the command fifos in the GLIDE ring-3 address space
	// this will be used to determine if the memory being unmapped is owned by GLIDE
	PVOID pvCommandFifoLinearAddress[ _GLIDE_TOTAL_COMMAND_FIFOS ];

	// structure to store the information necessary to unmap the GLIDE mapping of the frame
	// buffer at a point where GLIDE indicates it should be done
    VIDEO_SHARE_MEMORY sUnMapShareMemory;
#endif

} GLIDESTATE;

extern GLIDESTATE glideState[];

#if (_WIN32_WINNT >= 0x0500)
#define MAX_ADDRESS_TABLE_SIZE    256

typedef struct _LFBMapping
{
  HANDLE  ProcessID;
  DWORD   LFBAddr;
} LFBMAPPING;

extern LFBMAPPING LfbMappings[];
#endif
#endif                                                  /* WINNT */

#endif                          /* HWCEXT_H not defined */