Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
5.8 KiB

  1. /******************************Module*Header**********************************\
  2. *
  3. * *****************
  4. * * SAMPLE CODE *
  5. * *****************
  6. *
  7. * Module Name: mini.h
  8. *
  9. * Content: structures and constants for communication with minidriver
  10. *
  11. * Copyright (c) 1994-1998 3Dlabs Inc. Ltd. All rights reserved.
  12. * Copyright (c) 1995-1999 Microsoft Corporation. All rights reserved.
  13. \*****************************************************************************/
  14. #ifndef _MINI_H_
  15. #define _MINI_H_
  16. //-----------------------------------------------------------------------------
  17. //
  18. // structures used in IOCTL calls to miniport
  19. //
  20. //-----------------------------------------------------------------------------
  21. typedef struct tagLINE_DMA_BUFFER { //
  22. LARGE_INTEGER physAddr; // physical address of DMA buffer
  23. PVOID virtAddr; // mapped virtual address
  24. ULONG size; // size in bytes
  25. BOOLEAN cacheEnabled; // Whether buffer is cached
  26. } LINE_DMA_BUFFER, *PLINE_DMA_BUFFER;
  27. typedef struct tagEMULATED_DMA_BUFFER { //
  28. PVOID virtAddr; // virtual address
  29. ULONG size; // size in bytes
  30. ULONG tag; // allocation tag
  31. } EMULATED_DMA_BUFFER, *PEMULATED_DMA_BUFFER;
  32. //-----------------------------------------------------------------------------
  33. //
  34. // shared structures used display driver and miniport
  35. //
  36. //-----------------------------------------------------------------------------
  37. #define P2_ICB_MAGICNUMBER 0xbadabe01
  38. typedef struct tagINTERRUPT_CONTROL_BLOCK {
  39. ULONG ulMagicNo;
  40. volatile ULONG ulControl;
  41. volatile ULONG ulIRQCounter;
  42. LARGE_INTEGER liDMAPhysAddr; // physical start address of DMA buffer
  43. ULONG *pDMABufferStart; // virtual buffer start
  44. ULONG *pDMABufferEnd; // virtual buffer end
  45. volatile ULONG *pDMAActualBufferEnd; // virtual actual buffer end
  46. volatile ULONG *pDMAWriteEnd; // end for next write operation
  47. volatile ULONG *pDMAPrevStart; // previous start address of a DMA
  48. volatile ULONG *pDMANextStart; // next start address of a DMA
  49. volatile ULONG *pDMAWritePos; // current write pointer
  50. // these flags lock the miniport interrupts and the display driver access
  51. // to these data structures. Use InterlockedExchange to lock to make
  52. // sure it works on multiprocessing environments
  53. volatile ULONG ulICBLock; // this lock is set by the display driver
  54. volatile ULONG ulVSIRQCounter; // VS IRQ Counter (if enabled)
  55. volatile ULONG ulLastErrorFlags; // miniport saves value of last Error Interrupt
  56. volatile ULONG ulErrorCounter; // counter for number of errors
  57. // the following variables are only used in the display driver
  58. }INTERRUPT_CONTROL_BLOCK, *PINTERRUPT_CONTROL_BLOCK;
  59. //-----------------------------------------------------------------------------
  60. //
  61. // interrupt status bits set by minidriver IRQ service routine
  62. //
  63. //-----------------------------------------------------------------------------
  64. enum {
  65. DMA_IRQ_AVAILABLE = 0x01, // can use DMA interrupts
  66. VBLANK_IRQ_AVAILABLE = 0x02, // can use VBLANK interrupts
  67. };
  68. //-----------------------------------------------------------------------------
  69. //
  70. // IOCTL codes for minidriver calls
  71. //
  72. //-----------------------------------------------------------------------------
  73. #define IOCTL_VIDEO_QUERY_DEVICE_INFO \
  74. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD2, METHOD_BUFFERED, FILE_ANY_ACCESS)
  75. #define IOCTL_VIDEO_MAP_INTERRUPT_CMD_BUF \
  76. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD3, METHOD_BUFFERED, FILE_ANY_ACCESS)
  77. #define IOCTL_VIDEO_STALL_EXECUTION \
  78. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD4, METHOD_BUFFERED, FILE_ANY_ACCESS)
  79. #define IOCTL_VIDEO_QUERY_REGISTRY_DWORD \
  80. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD5, METHOD_BUFFERED, FILE_ANY_ACCESS)
  81. #define IOCTL_VIDEO_QUERY_INTERLOCKEDEXCHANGE \
  82. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD6, METHOD_BUFFERED, FILE_ANY_ACCESS)
  83. #define IOCTL_VIDEO_REG_SAVE_GAMMA_LUT \
  84. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  85. #define IOCTL_VIDEO_REG_RETRIEVE_GAMMA_LUT \
  86. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  87. #define IOCTL_VIDEO_QUERY_LINE_DMA_BUFFER \
  88. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD9, METHOD_BUFFERED, FILE_ANY_ACCESS)
  89. #define IOCTL_VIDEO_GET_LUT_REGISTERS \
  90. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DDB, METHOD_BUFFERED, FILE_ANY_ACCESS)
  91. #define IOCTL_VIDEO_SET_LUT_REGISTERS \
  92. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DDC, METHOD_BUFFERED, FILE_ANY_ACCESS)
  93. #define IOCTL_VIDEO_SET_SAME_VIDEO_MODE \
  94. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DDD, METHOD_BUFFERED, FILE_ANY_ACCESS)
  95. #define IOCTL_VIDEO_QUERY_EMULATED_DMA_BUFFER \
  96. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DDE, METHOD_BUFFERED, FILE_ANY_ACCESS)
  97. //-----------------------------------------------------------------------------
  98. //
  99. // functions provided by minidriver
  100. //
  101. //-----------------------------------------------------------------------------
  102. BOOL
  103. AllocateDMABuffer( HANDLE hDriver,
  104. PLONG plSize,
  105. PULONG *ppVirtAddr,
  106. LARGE_INTEGER *pPhysAddr);
  107. BOOL
  108. FreeDMABuffer( HANDLE hDriver, PVOID pVirtAddr);
  109. PULONG
  110. AllocateEmulatedDMABuffer(
  111. HANDLE hDriver,
  112. ULONG ulSize,
  113. ULONG ulTag
  114. );
  115. BOOL
  116. FreeEmulatedDMABuffer(
  117. HANDLE hDriver,
  118. PVOID pVirtAddr
  119. );
  120. VOID
  121. StallExecution( HANDLE hDriver, ULONG ulMicroSeconds);
  122. #if defined(_X86_)
  123. PVOID
  124. GetPInterlockedExchange( HANDLE hDriver);
  125. #endif
  126. #endif