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.

420 lines
9.1 KiB

  1. /*++
  2. Copyright (c) 1990-2000 Microsoft Corporation
  3. Module Name:
  4. vpdata.c
  5. Abstract:
  6. Global data module for the video port
  7. Author:
  8. Andre Vachon (andreva) 12-Jul-1997
  9. Environment:
  10. kernel mode only
  11. Notes:
  12. This module is a driver which implements OS dependant functions on the
  13. behalf of the video drivers
  14. Revision History:
  15. --*/
  16. #include "videoprt.h"
  17. //
  18. //
  19. // Data that is NOT pageable
  20. //
  21. //
  22. //
  23. // Globals to support HwResetHw function
  24. //
  25. VP_RESET_HW HwResetHw[6];
  26. //
  27. // Globals array of Fdos for debugging purpose
  28. //
  29. PFDO_EXTENSION FdoList[8];
  30. //
  31. // Head of Fdo list
  32. //
  33. PFDO_EXTENSION FdoHead = NULL;
  34. //
  35. // Debug Level for output routine (not pageable because VideoDebugPrint
  36. // can be called at raised irql.
  37. //
  38. ULONG VideoDebugLevel = 0;
  39. //
  40. // Variable used to so int10 support.
  41. //
  42. PEPROCESS CsrProcess = NULL;
  43. //
  44. // DEVOBJ for the device which caused the bugcheck EA
  45. //
  46. PDEVICE_OBJECT VpBugcheckDeviceObject = NULL;
  47. //
  48. // Bugcheck Reason Callback support
  49. //
  50. KBUGCHECK_REASON_CALLBACK_RECORD VpCallbackRecord;
  51. //
  52. // Pointer to bugcheck data buffer
  53. //
  54. PVOID VpBugcheckData;
  55. //
  56. // Variable to allow developers to disable EA recovery feature when debugging.
  57. //
  58. // NOTE: This is non-paged solely to make it easier for developers to edit
  59. // this value.
  60. BOOLEAN VpDisableRecovery = FALSE;
  61. //
  62. //
  63. // Data that IS pageable
  64. //
  65. //
  66. #if defined(ALLOC_PRAGMA)
  67. #pragma data_seg("PAGE_DATA")
  68. #endif
  69. //
  70. // Global videoprt lock
  71. //
  72. KMUTEX VpGlobalLock;
  73. //
  74. // Are we running setup ? This will never change once set.
  75. //
  76. ULONG VpSetupTypeAtBoot = 0;
  77. //
  78. // Are we running setup ? This may change when we start I/O.
  79. //
  80. ULONG VpSetupType = 0;
  81. //
  82. // Used to do first time initialization of the video port.
  83. //
  84. BOOLEAN VPFirstTime = TRUE;
  85. //
  86. // Callbacks to win32k
  87. //
  88. PVIDEO_WIN32K_CALLOUT Win32kCallout = NULL;
  89. //
  90. // Disable USWC is case the machine does not work properly with it.
  91. //
  92. BOOLEAN EnableUSWC = TRUE;
  93. //
  94. // Maximal total amount of memory we'll lock down.
  95. //
  96. ULONG VideoPortMaxDmaSize = 0;
  97. //
  98. // Count to determine the number of video devices
  99. //
  100. ULONG VideoDeviceNumber = 0;
  101. ULONG VideoChildDevices = 0;
  102. //
  103. // Registry Class in which all video information is stored.
  104. //
  105. PWSTR VideoClassString = L"VIDEO";
  106. UNICODE_STRING VideoClassName = {10,12,L"VIDEO"};
  107. //
  108. // Global variables used to keep track of where controllers or peripherals
  109. // are found by IoQueryDeviceDescription
  110. //
  111. CONFIGURATION_TYPE VpQueryDeviceControllerType = DisplayController;
  112. CONFIGURATION_TYPE VpQueryDevicePeripheralType = MonitorPeripheral;
  113. ULONG VpQueryDeviceControllerNumber = 0;
  114. ULONG VpQueryDevicePeripheralNumber = 0;
  115. //
  116. // Global used to determine if we are running in BASEVIDEO mode.
  117. //
  118. // If we are, we don't want to generate a conflict for the VGA driver resources
  119. // if there is one.
  120. // We also want to write a volatile key in the registry indicating we booted
  121. // in beasevideo so the display driver loading code can handle it properly
  122. //
  123. BOOLEAN VpBaseVideo = FALSE;
  124. //
  125. // Global used to determine if we are running in NOVESA mode.
  126. //
  127. // This value is only of use to mini-drivers and indicates that they should
  128. // not rely on VESA functions or resources exposed by the BIOS.
  129. //
  130. BOOLEAN VpNoVesa = FALSE;
  131. //
  132. // Pointer to physical memory. It is created during driver initialization
  133. // and is only closed when the driver is closed.
  134. //
  135. PVOID PhysicalMemorySection = NULL;
  136. //
  137. // Variable to determine if there is a ROM at physical address C0000 on which
  138. // we can do the int 10
  139. //
  140. ULONG VpC0000Compatible = 0;
  141. //
  142. // HwDeviceExtension of the VGA miniport driver, if it is loaded.
  143. //
  144. PVOID VgaHwDeviceExtension = NULL;
  145. //
  146. // Pointer to list of bus addresses for devices which have been assigned
  147. // resources.
  148. //
  149. PDEVICE_ADDRESS gDeviceAddressList;
  150. //
  151. // Store the amount of physical memory in the machine.
  152. //
  153. ULONGLONG VpSystemMemorySize;
  154. //
  155. // Store the device object that is the LCD panel for dimming and for
  156. // lid closure purposes.
  157. //
  158. PDEVICE_OBJECT LCDPanelDevice = NULL;
  159. //
  160. // LCD Panel Device Object Mutex
  161. //
  162. KMUTEX LCDPanelMutex;
  163. //
  164. // Int10 Mutex
  165. //
  166. KMUTEX VpInt10Mutex;
  167. //
  168. // Handle to PowerState callback
  169. //
  170. PVOID PowerStateCallbackHandle = NULL;
  171. //
  172. // Handle to Dock/Undock callback
  173. //
  174. PVOID DockCallbackHandle = NULL;
  175. //
  176. // Keep track of the number of devices which have started
  177. //
  178. ULONG NumDevicesStarted = 0;
  179. //
  180. // Use the new way of generating the registry path
  181. //
  182. BOOLEAN EnableNewRegistryKey = FALSE;
  183. //
  184. // We want to use the VGA driver during setup. We don't want any pre-installed
  185. // driver to work until after the VGA driver has been initialized. This way
  186. // if there is a bad PNP driver which won't work on the current OS, we have
  187. // time to replace it before trying to start it.
  188. //
  189. BOOLEAN VpSetupAllowDriversToStart = FALSE;
  190. //
  191. // Lets track whether or not any devices have had HwInitialize called on them
  192. // so that we can force legacy drivers to start after the system is initialized.
  193. //
  194. BOOLEAN VpSystemInitialized = FALSE;
  195. //
  196. // This structure describes to which ports access is required.
  197. //
  198. #define MEM_VGA 0xA0000
  199. #define MEM_VGA_SIZE 0x20000
  200. #define VGA_BASE_IO_PORT 0x000003B0
  201. #define VGA_START_BREAK_PORT 0x000003BB
  202. #define VGA_END_BREAK_PORT 0x000003C0
  203. #define VGA_MAX_IO_PORT 0x000003DF
  204. PVIDEO_ACCESS_RANGE VgaAccessRanges = NULL;
  205. ULONG NumVgaAccessRanges = 0;
  206. PDEVICE_OBJECT DeviceOwningVga = NULL;
  207. VIDEO_ACCESS_RANGE VgaLegacyResources[NUM_VGA_LEGACY_RESOURCES] = {
  208. {
  209. VGA_BASE_IO_PORT, 0x00000000,
  210. VGA_START_BREAK_PORT - VGA_BASE_IO_PORT+ 1,
  211. 1,
  212. 1,
  213. 1
  214. },
  215. {
  216. VGA_END_BREAK_PORT, 0x00000000,
  217. VGA_MAX_IO_PORT - VGA_END_BREAK_PORT + 1,
  218. 1,
  219. 1,
  220. 1
  221. },
  222. {
  223. MEM_VGA, 0x00000000,
  224. MEM_VGA_SIZE,
  225. 0,
  226. 1,
  227. 1
  228. }
  229. };
  230. //
  231. // Control Whether or not the bottom MEG of the CSR address space has
  232. // already been committed.
  233. //
  234. ULONG ServerBiosAddressSpaceInitialized = 0;
  235. BOOLEAN Int10BufferAllocated = FALSE;
  236. #if defined(_IA64_) || defined(_AMD64_)
  237. PUCHAR BiosTransferArea = NULL;
  238. #endif
  239. #if DBG
  240. CHAR *BusType[] = { "Internal",
  241. "Isa",
  242. "Eisa",
  243. "MicroChannel",
  244. "TurboChannel",
  245. "PCIBus",
  246. "VMEBus",
  247. "NuBus",
  248. "PCMCIABus",
  249. "CBus",
  250. "MPIBus",
  251. "MPSABus",
  252. "ProcessorInternal",
  253. "InternalPowerBus",
  254. "PNPISABus",
  255. "MaximumInterfaceType"
  256. };
  257. #endif
  258. PROC_ADDRESS VideoPortEntryPoints[] =
  259. {
  260. PROC(VideoPortDDCMonitorHelper),
  261. PROC(VideoPortDoDma),
  262. PROC(VideoPortGetCommonBuffer),
  263. PROC(VideoPortGetMdl),
  264. PROC(VideoPortLockPages),
  265. PROC(VideoPortSignalDmaComplete),
  266. PROC(VideoPortUnlockPages),
  267. PROC(VideoPortAssociateEventsWithDmaHandle),
  268. PROC(VideoPortGetBytesUsed),
  269. PROC(VideoPortSetBytesUsed),
  270. PROC(VideoPortGetDmaContext),
  271. PROC(VideoPortSetDmaContext),
  272. PROC(VideoPortMapDmaMemory),
  273. PROC(VideoPortUnmapDmaMemory),
  274. PROC(VideoPortGetAgpServices),
  275. PROC(VideoPortAllocateContiguousMemory),
  276. PROC(VideoPortGetRomImage),
  277. PROC(VideoPortGetAssociatedDeviceExtension),
  278. PROC(VideoPortGetAssociatedDeviceID),
  279. PROC(VideoPortAcquireDeviceLock),
  280. PROC(VideoPortReleaseDeviceLock),
  281. PROC(VideoPortAllocateBuffer),
  282. PROC(VideoPortFreeCommonBuffer),
  283. PROC(VideoPortMapDmaMemory),
  284. PROC(VideoPortReleaseBuffer),
  285. PROC(VideoPortInterlockedIncrement),
  286. PROC(VideoPortInterlockedDecrement),
  287. PROC(VideoPortInterlockedExchange),
  288. PROC(VideoPortGetVgaStatus),
  289. PROC(VideoPortQueueDpc),
  290. PROC(VideoPortEnumerateChildren),
  291. PROC(VideoPortQueryServices),
  292. PROC(VideoPortGetDmaAdapter),
  293. PROC(VideoPortPutDmaAdapter),
  294. PROC(VideoPortAllocateCommonBuffer),
  295. PROC(VideoPortReleaseCommonBuffer),
  296. PROC(VideoPortLockBuffer),
  297. PROC(VideoPortUnlockBuffer),
  298. PROC(VideoPortStartDma),
  299. PROC(VideoPortCompleteDma),
  300. PROC(VideoPortCreateEvent),
  301. PROC(VideoPortDeleteEvent),
  302. PROC(VideoPortSetEvent),
  303. PROC(VideoPortClearEvent),
  304. PROC(VideoPortReadStateEvent),
  305. PROC(VideoPortWaitForSingleObject),
  306. PROC(VideoPortAllocatePool),
  307. PROC(VideoPortFreePool),
  308. PROC(VideoPortCreateSpinLock),
  309. PROC(VideoPortDeleteSpinLock),
  310. PROC(VideoPortAcquireSpinLock),
  311. PROC(VideoPortAcquireSpinLockAtDpcLevel),
  312. PROC(VideoPortReleaseSpinLock),
  313. PROC(VideoPortReleaseSpinLockFromDpcLevel),
  314. PROC(VideoPortCheckForDeviceExistence),
  315. PROC(VideoPortCreateSecondaryDisplay),
  316. PROC(VideoPortFlushRegistry),
  317. PROC(VideoPortQueryPerformanceCounter),
  318. PROC(VideoPortGetVersion),
  319. PROC(VideoPortRegisterBugcheckCallback),
  320. {NULL, NULL}
  321. };