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.

2225 lines
47 KiB

  1. /*++
  2. Copyright (c) 1991-2000 Microsoft Corporation
  3. Module Name:
  4. videoprt.h
  5. Abstract:
  6. This module contains the structure definitions private to the video port
  7. driver.
  8. Author:
  9. Andre Vachon (andreva) 02-Dec-1991
  10. Notes:
  11. Revision History:
  12. --*/
  13. #ifndef __VIDEOPRT_H__
  14. #define __VIDEOPRT_H__
  15. #define _NTDRIVER_
  16. #ifndef FAR
  17. #define FAR
  18. #endif
  19. #define _NTOSDEF_
  20. #define INITGUID
  21. #include "dderror.h"
  22. #include "ntosp.h"
  23. #include "wdmguid.h"
  24. #include "stdarg.h"
  25. #include "stdio.h"
  26. #include "zwapi.h"
  27. #include "ntiologc.h"
  28. #include "ntddvdeo.h"
  29. #include "video.h"
  30. #include "ntagp.h"
  31. #include "acpiioct.h"
  32. #include "agp.h"
  33. #include "inbv.h"
  34. #include "ntrtl.h"
  35. #include "ntiodump.h"
  36. //
  37. // Forward declare some basic driver objects.
  38. //
  39. typedef struct _FDO_EXTENSION *PFDO_EXTENSION;
  40. typedef struct _CHILD_PDO_EXTENSION *PCHILD_PDO_EXTENSION;
  41. //
  42. // Debugging Macro
  43. //
  44. //
  45. // When an IO routine is called, we want to make sure the miniport
  46. // in question has reported its IO ports.
  47. // VPResourceReported is TRUE when a miniport has called VideoPort-
  48. // VerifyAccessRanges.
  49. // It is set to FALSE as a default, and set back to FALSE when finishing
  50. // an iteration in the loop of VideoPortInitialize (which will reset
  51. // the default when we exit the loop also).
  52. //
  53. // This flag will also be set to TRUE by the VREATE entry point so that
  54. // the IO functions always work after init.
  55. //
  56. #if DBG
  57. #undef VideoDebugPrint
  58. #define pVideoDebugPrint(arg) VideoPortDebugPrint arg
  59. #else
  60. #define pVideoDebugPrint(arg)
  61. #endif
  62. //
  63. // Useful registry buffer length.
  64. //
  65. #define STRING_LENGTH 60
  66. //
  67. // Queue link for mapped addresses stored for unmapping
  68. //
  69. typedef struct _MAPPED_ADDRESS {
  70. struct _MAPPED_ADDRESS *NextMappedAddress;
  71. PVOID MappedAddress;
  72. PHYSICAL_ADDRESS PhysicalAddress;
  73. ULONG NumberOfUchars;
  74. ULONG RefCount;
  75. UCHAR InIoSpace;
  76. BOOLEAN bNeedsUnmapping;
  77. BOOLEAN bLargePageRequest;
  78. } MAPPED_ADDRESS, *PMAPPED_ADDRESS;
  79. //
  80. // BusDataRegistry variables
  81. //
  82. typedef struct _VP_QUERY_DEVICE {
  83. PVOID MiniportHwDeviceExtension;
  84. PVOID CallbackRoutine;
  85. PVOID MiniportContext;
  86. VP_STATUS MiniportStatus;
  87. ULONG DeviceDataType;
  88. } VP_QUERY_DEVICE, *PVP_QUERY_DEVICE;
  89. //
  90. // Definition of the data passed in for the VideoPortGetRegistryParameters
  91. // function for the DeviceDataType.
  92. //
  93. #define VP_GET_REGISTRY_DATA 0
  94. #define VP_GET_REGISTRY_FILE 1
  95. //
  96. // Int10 Transfer Area
  97. //
  98. #define VDM_TRANSFER_SEGMENT 0x2000
  99. #define VDM_TRANSFER_OFFSET 0x0000
  100. #define VDM_TRANSFER_LENGTH 0x1000
  101. //
  102. // the Extended BIOS data location
  103. //
  104. #define EXTENDED_BIOS_INFO_LOCATION 0x740
  105. //
  106. // Possible values for the InterruptFlags field in the DeviceExtension
  107. //
  108. #define VP_ERROR_LOGGED 0x01
  109. //
  110. // Port driver error logging
  111. //
  112. typedef struct _VP_ERROR_LOG_ENTRY {
  113. PVOID DeviceExtension;
  114. ULONG IoControlCode;
  115. VP_STATUS ErrorCode;
  116. ULONG UniqueId;
  117. } VP_ERROR_LOG_ENTRY, *PVP_ERROR_LOG_ENTRY;
  118. typedef struct _VIDEO_PORT_DRIVER_EXTENSION {
  119. UNICODE_STRING RegistryPath;
  120. VIDEO_HW_INITIALIZATION_DATA HwInitData;
  121. } VIDEO_PORT_DRIVER_EXTENSION, *PVIDEO_PORT_DRIVER_EXTENSION;
  122. //
  123. // PnP Detection flags
  124. //
  125. #define PNP_ENABLED 0x001
  126. #define LEGACY_DETECT 0x002
  127. #define VGA_DRIVER 0x004
  128. #define LEGACY_DRIVER 0x008
  129. #define BOOT_DRIVER 0x010
  130. #define REPORT_DEVICE 0x020
  131. #define UPGRADE_FAIL_START 0x040
  132. #define FINDADAPTER_SUCCEEDED 0x080
  133. #define UPGRADE_FAIL_HWINIT 0x100
  134. #define VGA_DETECT 0x200
  135. //
  136. // Setup flags
  137. //
  138. #define SETUPTYPE_NONE 0
  139. #define SETUPTYPE_FULL 1
  140. #define SETUPTYPE_MINI 2
  141. #define SETUPTYPE_UPGRADE 4
  142. //
  143. // ResetHW Structure
  144. //
  145. typedef struct _VP_RESET_HW {
  146. PVIDEO_HW_RESET_HW ResetFunction;
  147. PVOID HwDeviceExtension;
  148. } VP_RESET_HW, *PVP_RESET_HW;
  149. //
  150. // Videoprt allocation and DEVICE_EXTENSION header tag.
  151. //
  152. #define VP_TAG 0x74725076 // 'vPrt'
  153. //
  154. // Private EVENT support for miniport.
  155. //
  156. //
  157. // This flag indicates that the enveloping VIDEO_PORT_EVENT has a PKEVENT
  158. // field filled in by ObReferenceObjectByHandle(). It cannot be waited on
  159. // at all. Must be consistent with that in pw32kevt.h in gre.
  160. //
  161. #define ENG_EVENT_FLAG_IS_MAPPED_USER 0x1
  162. //
  163. // This flag indicates that the enveloping VIDEO_PORT_EVENT is about to be
  164. // deleted and that the display driver callback is ongoing. Must be consistent
  165. // with that in pw32kevt.h in gre.
  166. //
  167. #define ENG_EVENT_FLAG_IS_INVALID 0x2
  168. //
  169. // NOTE: PVIDEO_PORT_EVENT is a private structure. It must be the same as
  170. // ENG_EVENT in pw32kevt.h for ENG/GDI.
  171. //
  172. typedef struct _VIDEO_PORT_EVENT {
  173. PVOID pKEvent;
  174. ULONG fFlags;
  175. } VIDEO_PORT_EVENT, *PVIDEO_PORT_EVENT;
  176. typedef struct _VIDEO_PORT_SPIN_LOCK {
  177. KSPIN_LOCK Lock;
  178. } VIDEO_PORT_SPIN_LOCK, *PVIDEO_PORT_SPIN_LOCK;
  179. typedef struct _VIDEO_ACPI_EVENT_CONTEXT {
  180. WORK_QUEUE_ITEM workItem;
  181. struct _DEVICE_SPECIFIC_EXTENSION *DoSpecificExtension;
  182. ULONG EventID;
  183. } VIDEO_ACPI_EVENT_CONTEXT, *PVIDEO_ACPI_EVENT_CONTEXT;
  184. //
  185. // The following takes the place of the EDID in the old DEVICE_EXTENSTION. this type
  186. // is private to the video port child enumeration code.
  187. //
  188. #define NO_EDID 0
  189. #define GOOD_EDID 1
  190. #define BAD_EDID 2
  191. #define EDID_BUFFER_SIZE 256
  192. #define NONEDID_SIGNATURE 0x95C3DA76
  193. #define ACPIDDC_EXIST 0x01
  194. #define ACPIDDC_TESTED 0x02
  195. typedef struct __VIDEO_CHILD_DESCRIPTOR {
  196. VIDEO_CHILD_TYPE Type;
  197. ULONG UId;
  198. BOOLEAN bACPIDevice;
  199. UCHAR ACPIDDCFlag;
  200. BOOLEAN ValidEDID;
  201. BOOLEAN bInvalidate;
  202. UCHAR Buffer[EDID_BUFFER_SIZE];
  203. } VIDEO_CHILD_DESCRIPTOR, *PVIDEO_CHILD_DESCRIPTOR;
  204. typedef struct __VP_DMA_ADAPTER {
  205. struct __VP_DMA_ADAPTER *NextVpDmaAdapter;
  206. PDMA_ADAPTER DmaAdapterObject;
  207. ULONG NumberOfMapRegisters;
  208. } VP_DMA_ADAPTER, *PVP_DMA_ADAPTER;
  209. typedef enum _HW_INIT_STATUS
  210. {
  211. HwInitNotCalled, // HwInitialize has not yet been called
  212. HwInitSucceeded, // HwInitialize has been called and succeeded
  213. HwInitFailed // HwInitialize has been called and failed
  214. } HW_INIT_STATUS, *PHW_INIT_STATUS;
  215. typedef enum _EXTENSION_TYPE
  216. {
  217. TypeFdoExtension,
  218. TypePdoExtension,
  219. TypeDeviceSpecificExtension
  220. } EXTENSION_TYPE, *PEXTENSION_TYPE;
  221. #define GET_DSP_EXT(p) ((((PDEVICE_SPECIFIC_EXTENSION)(p)) - 1))
  222. #define GET_FDO_EXT(p) ((((PDEVICE_SPECIFIC_EXTENSION)(p)) - 1)->pFdoExtension)
  223. //
  224. // Define HW_DEVICE_EXTENSION verification macro.
  225. //
  226. #define IS_HW_DEVICE_EXTENSION(p) (((p) != NULL) && (GET_FDO_EXT(p)->HwDeviceExtension == (p)))
  227. #define IS_PDO(p) (((p) != NULL) && \
  228. (((PCHILD_PDO_EXTENSION)(p))->Signature == VP_TAG) && \
  229. (((PCHILD_PDO_EXTENSION)(p))->ExtensionType == TypePdoExtension))
  230. #define IS_FDO(p) (((p) != NULL) && \
  231. (((PFDO_EXTENSION)(p))->Signature == VP_TAG) && \
  232. (((PFDO_EXTENSION)(p))->ExtensionType == TypeFdoExtension))
  233. typedef struct _ALLOC_ENTRY {
  234. PVOID Address;
  235. ULONG Size;
  236. struct _ALLOC_ENTRY *Next;
  237. } *PALLOC_ENTRY, ALLOC_ENTRY;
  238. //
  239. // Device Object Specific Extension
  240. //
  241. // This is data that is allocated for each device object. It contains
  242. // a pointer back to the primary FDO_EXTENSION for the hardware device.
  243. //
  244. #ifdef IOCTL_VIDEO_USE_DEVICE_IN_SESSION
  245. #define VIDEO_DEVICE_INVALID_SESSION -1
  246. #endif IOCTL_VIDEO_USE_DEVICE_IN_SESSION
  247. typedef struct _DEVICE_SPECIFIC_EXTENSION {
  248. //
  249. // VideoPort signature.
  250. //
  251. ULONG Signature;
  252. //
  253. // Indicates the type of the device extension.
  254. //
  255. EXTENSION_TYPE ExtensionType;
  256. //
  257. // Pointer to the hardware specific device extension.
  258. //
  259. PFDO_EXTENSION pFdoExtension;
  260. //
  261. // Location of the miniport device extension.
  262. //
  263. PVOID HwDeviceExtension;
  264. //
  265. // Pointer to the path name indicating the path to the drivers node in
  266. // the registry's current control set
  267. //
  268. PWSTR DriverRegistryPath;
  269. ULONG DriverRegistryPathLength;
  270. //
  271. // Callout support - Physdisp of the device in GDI
  272. //
  273. PVOID PhysDisp;
  274. BOOLEAN bACPI;
  275. ULONG CachedEventID;
  276. ULONG AcpiVideoEventsOutstanding;
  277. //
  278. // Number used to create device object name. (ie. Device\VideoX)
  279. //
  280. ULONG DeviceNumber;
  281. //
  282. // Track whether the device has been opened.
  283. //
  284. BOOLEAN DeviceOpened;
  285. //
  286. // Flags for DualView
  287. //
  288. ULONG DualviewFlags;
  289. //
  290. // Old & New device registry paths
  291. //
  292. PWSTR DriverNewRegistryPath;
  293. ULONG DriverNewRegistryPathLength;
  294. PWSTR DriverOldRegistryPath;
  295. ULONG DriverOldRegistryPathLength;
  296. #ifdef IOCTL_VIDEO_USE_DEVICE_IN_SESSION
  297. //
  298. // Session the device is currently enabled in
  299. //
  300. ULONG SessionId;
  301. #endif IOCTL_VIDEO_USE_DEVICE_IN_SESSION
  302. } DEVICE_SPECIFIC_EXTENSION, *PDEVICE_SPECIFIC_EXTENSION;
  303. //
  304. // Device Extension for the PHYSICAL Driver Object (PDO)
  305. //
  306. typedef struct _CHILD_PDO_EXTENSION {
  307. //
  308. // VideoPort signature.
  309. //
  310. ULONG Signature;
  311. //
  312. // Indicates the type of the device extension.
  313. //
  314. EXTENSION_TYPE ExtensionType;
  315. //
  316. // Pointer to the FDO extension.
  317. // It can also be used to determine if this is the PDO or FDO.
  318. //
  319. PFDO_EXTENSION pFdoExtension;
  320. //
  321. // Location of the miniport device extension.
  322. //
  323. PVOID HwDeviceExtension;
  324. //
  325. // This is only valid because ALL requests are processed synchronously.
  326. // NOTE: this must be consistent with DEVICE_EXTENSIONs.
  327. //
  328. KPROCESSOR_MODE CurrentIrpRequestorMode;
  329. //
  330. // Saved Power state to detect transitions.
  331. //
  332. DEVICE_POWER_STATE DevicePowerState;
  333. //
  334. // Power management mappings.
  335. //
  336. DEVICE_POWER_STATE DeviceMapping[PowerSystemMaximum] ;
  337. BOOLEAN IsMappingReady ;
  338. //
  339. // Event object for pVideoPortDispatch synchronization.
  340. //
  341. KMUTEX SyncMutex;
  342. IO_REMOVE_LOCK RemoveLock;
  343. ////////////////////////////////////////////////////////////////////////////
  344. //
  345. // END common header.
  346. //
  347. ////////////////////////////////////////////////////////////////////////////
  348. //
  349. // Non-paged copy of the UId in the VideoChildDescriptor, so we can do
  350. // power management at raise IRQL.
  351. //
  352. ULONG ChildUId;
  353. //
  354. // Device descriptor (EDID for monitors,etc).
  355. //
  356. PVIDEO_CHILD_DESCRIPTOR VideoChildDescriptor;
  357. //
  358. // Child PDO we created
  359. //
  360. PDEVICE_OBJECT ChildDeviceObject;
  361. //
  362. // Child FDO
  363. //
  364. PDEVICE_OBJECT ChildFdo;
  365. //
  366. // PDEVICE_OBJECT link pointer for enumeration.
  367. //
  368. struct _CHILD_PDO_EXTENSION* NextChild;
  369. //
  370. // BOOLEAN to indicate if this child device has been found
  371. // in the last enumeration.
  372. //
  373. BOOLEAN bIsEnumerated;
  374. //
  375. // Is this a lid override case. If this variable is set to TRUE,
  376. // don't bring the panel out of D3.
  377. //
  378. BOOLEAN PowerOverride;
  379. } CHILD_PDO_EXTENSION;
  380. //
  381. // Device Extension for the FUNCTIONAL Driver Object (FDO)
  382. //
  383. typedef struct _FDO_EXTENSION {
  384. //
  385. // VideoPort signature.
  386. //
  387. ULONG Signature;
  388. //
  389. // Indicates the type of the device extension.
  390. //
  391. EXTENSION_TYPE ExtensionType;
  392. //
  393. // Pointer to the FDO extension.
  394. // It can also be used to determine if this is the PDO or FDO.
  395. //
  396. PFDO_EXTENSION pFdoExtension;
  397. //
  398. // Location of the miniport device extension.
  399. //
  400. PVOID HwDeviceExtension;
  401. //
  402. // RequestorMode of the Currently processed IRP.
  403. // This is only valid because ALL requests are processed synchronously.
  404. // NOTE: this must be consistent with CHILD_PDO_EXTENSIONs.
  405. //
  406. KPROCESSOR_MODE CurrentIrpRequestorMode;
  407. //
  408. // Saved Power state to detect transitions.
  409. //
  410. DEVICE_POWER_STATE DevicePowerState;
  411. //
  412. // Power management mappings.
  413. //
  414. DEVICE_POWER_STATE DeviceMapping[PowerSystemMaximum] ;
  415. BOOLEAN IsMappingReady ;
  416. //
  417. // Monitor power override. If TRUE, always set monitors to D3.
  418. //
  419. BOOLEAN OverrideMonitorPower;
  420. //
  421. // Event object for pVideoPortDispatch synchronization.
  422. //
  423. KMUTEX SyncMutex;
  424. IO_REMOVE_LOCK RemoveLock;
  425. ////////////////////////////////////////////////////////////////////////////
  426. //
  427. // END common header.
  428. //
  429. ////////////////////////////////////////////////////////////////////////////
  430. //
  431. // Adapter device objects
  432. //
  433. PDEVICE_OBJECT FunctionalDeviceObject;
  434. PDEVICE_OBJECT PhysicalDeviceObject;
  435. PDEVICE_OBJECT AttachedDeviceObject;
  436. //
  437. // Point to the next FdoExtension
  438. //
  439. PFDO_EXTENSION NextFdoExtension;
  440. //
  441. // Pointer to the first Child PDO
  442. //
  443. ULONG ChildPdoNumber;
  444. PCHILD_PDO_EXTENSION ChildPdoList;
  445. //
  446. // Pointer to the miniport config info so that the port driver
  447. // can modify it when the miniport is asking for configuration information.
  448. //
  449. PVIDEO_PORT_CONFIG_INFO MiniportConfigInfo;
  450. //
  451. // Miniport exports
  452. //
  453. PVIDEO_HW_FIND_ADAPTER HwFindAdapter;
  454. PVIDEO_HW_INITIALIZE HwInitialize;
  455. PVIDEO_HW_INTERRUPT HwInterrupt;
  456. PVIDEO_HW_START_IO HwStartIO;
  457. PVIDEO_HW_TIMER HwTimer;
  458. PVIDEO_HW_POWER_SET HwSetPowerState;
  459. PVIDEO_HW_POWER_GET HwGetPowerState;
  460. PVIDEO_HW_START_DMA HwStartDma;
  461. PVIDEO_HW_GET_CHILD_DESCRIPTOR HwGetVideoChildDescriptor;
  462. PVIDEO_HW_QUERY_INTERFACE HwQueryInterface;
  463. PVIDEO_HW_CHILD_CALLBACK HwChildCallback;
  464. //
  465. // Legacy resources used by the driver and reported to Plug and Play
  466. // via FILTER_RESOURCE_REQUIREMENTS.
  467. //
  468. PVIDEO_ACCESS_RANGE HwLegacyResourceList;
  469. ULONG HwLegacyResourceCount;
  470. //
  471. // Linked list of all memory mapped io space (done through MmMapIoSpace)
  472. // requested by the miniport driver.
  473. // This list is kept so we can free up those ressources if the driver
  474. // fails to load or if it is unloaded at a later time.
  475. //
  476. PMAPPED_ADDRESS MappedAddressList;
  477. //
  478. // Interrupt object
  479. //
  480. PKINTERRUPT InterruptObject;
  481. //
  482. // Interrupt vector, irql and mode
  483. //
  484. ULONG InterruptVector;
  485. KIRQL InterruptIrql;
  486. KAFFINITY InterruptAffinity;
  487. KINTERRUPT_MODE InterruptMode;
  488. BOOLEAN InterruptsEnabled;
  489. //
  490. // Information about the BUS on which the adapteris located
  491. //
  492. INTERFACE_TYPE AdapterInterfaceType;
  493. ULONG SystemIoBusNumber;
  494. //
  495. // DPC used to log errors.
  496. //
  497. KDPC ErrorLogDpc;
  498. //
  499. // Stores the size and pointer to the EmulatorAccessEntries. These are
  500. // kept since they will be accessed later on when the Emulation must be
  501. // enabled.
  502. //
  503. ULONG NumEmulatorAccessEntries;
  504. PEMULATOR_ACCESS_ENTRY EmulatorAccessEntries;
  505. ULONG_PTR EmulatorAccessEntriesContext;
  506. //
  507. // Size of the miniport device extensions.
  508. //
  509. ULONG HwDeviceExtensionSize;
  510. //
  511. // Determines the size required to save the video hardware state
  512. //
  513. ULONG HardwareStateSize;
  514. //
  515. // Total memory usage of PTEs by a miniport driver.
  516. // This is used to track if the miniport is mapping too much memory
  517. //
  518. ULONG MemoryPTEUsage;
  519. //
  520. // Has the drivers HwInitialize routine been called.
  521. //
  522. HW_INIT_STATUS HwInitStatus;
  523. //
  524. // State set during an Interrupt that must be dealt with afterwards
  525. //
  526. ULONG InterruptFlags;
  527. //
  528. // LogEntry Packet so the information can be save when called from within
  529. // an interrupt.
  530. //
  531. VP_ERROR_LOG_ENTRY ErrorLogEntry;
  532. //
  533. // VDM and int10 support
  534. //
  535. PHYSICAL_ADDRESS VdmPhysicalVideoMemoryAddress;
  536. ULONG VdmPhysicalVideoMemoryLength;
  537. PEPROCESS VdmProcess;
  538. ////////////////////////////////////////////////////////////////////////////
  539. //
  540. // DMA support.
  541. //
  542. ////////////////////////////////////////////////////////////////////////////
  543. PVP_DMA_ADAPTER VpDmaAdapterHead;
  544. //
  545. // Adapter object returned by IoGetDmaAdapter. This is for old DMA stuff
  546. //
  547. PDMA_ADAPTER DmaAdapterObject;
  548. //
  549. // DPC Support
  550. //
  551. KDPC Dpc;
  552. ////////////////////////////////////////////////////////////////////////////
  553. //
  554. // Plug and Play Support
  555. //
  556. ////////////////////////////////////////////////////////////////////////////
  557. PCM_RESOURCE_LIST ResourceList;
  558. PCM_RESOURCE_LIST AllocatedResources; // bus driver list
  559. PCM_RESOURCE_LIST RawResources; // complete list
  560. PCM_RESOURCE_LIST TranslatedResources; // translated complete list
  561. //
  562. // Slot/Function number where the device is located
  563. //
  564. ULONG SlotNumber;
  565. //
  566. // Indicates whether we can enumerate children right away, or if
  567. // we need to wait for HwInitialize to be called first.
  568. //
  569. BOOLEAN AllowEarlyEnumeration;
  570. //
  571. // Interface for communication with our bus driver.
  572. //
  573. BOOLEAN ValidBusInterface;
  574. BUS_INTERFACE_STANDARD BusInterface;
  575. //
  576. // Cache away a pointer to our driver object.
  577. //
  578. PDRIVER_OBJECT DriverObject;
  579. //
  580. // Flags that indicate type of driver (VGA, PNP, etc)
  581. //
  582. ULONG Flags;
  583. //
  584. // ROM Support
  585. //
  586. PVOID RomImage;
  587. //
  588. // AGP Support
  589. //
  590. AGP_BUS_INTERFACE_STANDARD AgpInterface;
  591. //
  592. // Power management variables related to hardware reset
  593. //
  594. BOOLEAN bGDIResetHardware;
  595. //
  596. // Index to be used for the registry path:
  597. // CCS\Control\Video\[GUID]\000x
  598. // The index is used for dual-view and for legacy drivers
  599. //
  600. ULONG RegistryIndex;
  601. //
  602. // Power management vaiable. If set to TRUE the device must
  603. // stay at D0 all the time during the system Shutdown (S5) and
  604. // Hibernation (S4) requests
  605. //
  606. BOOLEAN OnHibernationPath;
  607. //
  608. // Support for bugcheck reason callbacks
  609. //
  610. PVIDEO_BUGCHECK_CALLBACK BugcheckCallback;
  611. ULONG BugcheckDataSize;
  612. } FDO_EXTENSION, *PFDO_EXTENSION;
  613. #define MAXIMUM_MEM_LIMIT_K 64
  614. //
  615. // AGP Data Structures
  616. //
  617. typedef struct _REGION {
  618. ULONG Length;
  619. ULONG NumWords; // number of USHORTs
  620. USHORT BitField[1];
  621. } REGION, *PREGION;
  622. typedef struct _PHYSICAL_RESERVE_CONTEXT
  623. {
  624. ULONG Pages;
  625. VIDEO_PORT_CACHE_TYPE Caching;
  626. PVOID MapHandle;
  627. PHYSICAL_ADDRESS PhysicalAddress;
  628. PREGION Region;
  629. PREGION MapTable;
  630. } PHYSICAL_RESERVE_CONTEXT, *PPHYSICAL_RESERVE_CONTEXT;
  631. typedef struct _VIRTUAL_RESERVE_CONTEXT
  632. {
  633. HANDLE ProcessHandle;
  634. PEPROCESS Process;
  635. PVOID VirtualAddress;
  636. PPHYSICAL_RESERVE_CONTEXT PhysicalReserveContext;
  637. PREGION Region;
  638. PREGION MapTable;
  639. } VIRTUAL_RESERVE_CONTEXT, *PVIRTUAL_RESERVE_CONTEXT;
  640. typedef struct _DEVICE_ADDRESS DEVICE_ADDRESS, *PDEVICE_ADDRESS;
  641. typedef struct _DEVICE_ADDRESS
  642. {
  643. ULONG BusNumber;
  644. ULONG Slot;
  645. PDEVICE_ADDRESS Next;
  646. };
  647. //
  648. // Support for GetProcAddress
  649. //
  650. typedef struct _PROC_ADDRESS
  651. {
  652. PUCHAR FunctionName;
  653. PVOID FunctionAddress;
  654. } PROC_ADDRESS, *PPROC_ADDRESS;
  655. #define PROC(x) #x, x
  656. //
  657. // Power Request Context Block
  658. //
  659. typedef struct tagPOWER_BLOCK
  660. {
  661. PKEVENT Event;
  662. union {
  663. NTSTATUS Status;
  664. ULONG FinalFlag;
  665. } ;
  666. PIRP Irp ;
  667. } POWER_BLOCK, *PPOWER_BLOCK;
  668. //
  669. // PowerState work item
  670. //
  671. typedef struct _POWER_STATE_WORK_ITEM {
  672. WORK_QUEUE_ITEM WorkItem;
  673. PVOID Argument1;
  674. PVOID Argument2;
  675. } POWER_STATE_WORK_ITEM, *PPOWER_STATE_WORK_ITEM;
  676. //
  677. // New registry key
  678. //
  679. #define SZ_GUID L"VideoID"
  680. #define SZ_LEGACY_KEY L"LegacyKey"
  681. #define SZ_VIDEO_DEVICES L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video"
  682. #define SZ_USE_NEW_KEY L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\GraphicsDrivers\\UseNewKey"
  683. #define SZ_INITIAL_SETTINGS L"Settings"
  684. #define SZ_COMMON_SUBKEY L"Video"
  685. #define SZ_SERVICE L"Service"
  686. //
  687. // Global Data
  688. //
  689. #if DBG
  690. extern CHAR *BusType[];
  691. #endif
  692. extern ULONG VpSetupType;
  693. extern ULONG VpSetupTypeAtBoot;
  694. extern BOOLEAN VPFirstTime;
  695. extern PVIDEO_WIN32K_CALLOUT Win32kCallout;
  696. extern BOOLEAN EnableUSWC;
  697. extern ULONG VideoDebugLevel;
  698. extern ULONG VideoPortMaxDmaSize;
  699. extern ULONG VideoDeviceNumber;
  700. extern ULONG VideoChildDevices;
  701. extern PWSTR VideoClassString;
  702. extern UNICODE_STRING VideoClassName;
  703. extern CONFIGURATION_TYPE VpQueryDeviceControllerType;
  704. extern CONFIGURATION_TYPE VpQueryDevicePeripheralType;
  705. extern ULONG VpQueryDeviceControllerNumber;
  706. extern ULONG VpQueryDevicePeripheralNumber;
  707. extern VP_RESET_HW HwResetHw[];
  708. extern PFDO_EXTENSION FdoList[];
  709. extern PFDO_EXTENSION FdoHead;
  710. extern BOOLEAN VpBaseVideo;
  711. extern BOOLEAN VpNoVesa;
  712. extern PVOID PhysicalMemorySection;
  713. extern PEPROCESS CsrProcess;
  714. extern ULONG VpC0000Compatible;
  715. extern PVOID VgaHwDeviceExtension;
  716. extern PVIDEO_ACCESS_RANGE VgaAccessRanges;
  717. extern ULONG NumVgaAccessRanges;
  718. extern PDEVICE_OBJECT DeviceOwningVga;
  719. extern PROC_ADDRESS VideoPortEntryPoints[];
  720. extern VIDEO_ACCESS_RANGE VgaLegacyResources[];
  721. extern PDEVICE_ADDRESS gDeviceAddressList;
  722. extern ULONGLONG VpSystemMemorySize;
  723. extern PDEVICE_OBJECT LCDPanelDevice;
  724. extern KMUTEX LCDPanelMutex;
  725. extern KMUTEX VpInt10Mutex;
  726. extern PVOID PowerStateCallbackHandle;
  727. extern PVOID DockCallbackHandle;
  728. extern ULONG NumDevicesStarted;
  729. extern BOOLEAN EnableNewRegistryKey;
  730. extern BOOLEAN VpSetupAllowDriversToStart;
  731. extern BOOLEAN VpSystemInitialized;
  732. extern ULONG ServerBiosAddressSpaceInitialized;
  733. extern BOOLEAN Int10BufferAllocated;
  734. extern PDEVICE_OBJECT VpBugcheckDeviceObject;
  735. extern KBUGCHECK_REASON_CALLBACK_RECORD VpCallbackRecord;
  736. extern PVOID VpBugcheckData;
  737. extern KMUTEX VpGlobalLock;
  738. extern BOOLEAN VpDisableRecovery;
  739. extern ULONG_PTR KiBugCheckData[5]; // bugcheck data exported from ntoskrnl
  740. // {D00CE1F5-D60C-41c2-AF75-A4370C9976A3}
  741. DEFINE_GUID(VpBugcheckGUID, 0xd00ce1f5, 0xd60c, 0x41c2, 0xaf, 0x75, 0xa4, 0x37, 0xc, 0x99, 0x76, 0xa3);
  742. #if defined(_IA64_) || defined(_AMD64_)
  743. PUCHAR BiosTransferArea;
  744. #endif
  745. typedef
  746. BOOLEAN
  747. (*PSYNCHRONIZE_ROUTINE) (
  748. PKINTERRUPT pInterrupt,
  749. PKSYNCHRONIZE_ROUTINE pkSyncronizeRoutine,
  750. PVOID pSynchContext
  751. );
  752. //
  753. // Number of legacy vga resources
  754. //
  755. #define NUM_VGA_LEGACY_RESOURCES 3
  756. #define DMA_OPERATION(a) (VpDmaAdapter->DmaAdapterObject->DmaOperations->a)
  757. //
  758. // These macros are used to protect threads which will enter the
  759. // miniport. We need to guarantee that only one thread enters
  760. // the miniport at a time.
  761. //
  762. #define ACQUIRE_DEVICE_LOCK(DeviceExtension) \
  763. KeWaitForSingleObject(&DeviceExtension->SyncMutex, \
  764. Executive, \
  765. KernelMode, \
  766. FALSE, \
  767. (PTIME)NULL);
  768. #define RELEASE_DEVICE_LOCK(DeviceExtension) \
  769. KeReleaseMutex(&DeviceExtension->SyncMutex, \
  770. FALSE);
  771. //
  772. // Define macros to stall execution for given number of milli or micro seconds.
  773. // Single call to KeStallExecutionProcessor() can be done for 50us max.
  774. //
  775. #define DELAY_MILLISECONDS(n) \
  776. { \
  777. ULONG d_ulCount; \
  778. ULONG d_ulTotal = 20 * (n); \
  779. \
  780. for (d_ulCount = 0; d_ulCount < d_ulTotal; d_ulCount++) \
  781. KeStallExecutionProcessor(50); \
  782. }
  783. #define DELAY_MICROSECONDS(n) \
  784. { \
  785. ULONG d_ulCount = (n); \
  786. \
  787. while (d_ulCount > 0) \
  788. { \
  789. if (d_ulCount >= 50) \
  790. { \
  791. KeStallExecutionProcessor(50); \
  792. d_ulCount -= 50; \
  793. } \
  794. else \
  795. { \
  796. KeStallExecutionProcessor(d_ulCount); \
  797. d_ulCount = 0; \
  798. } \
  799. } \
  800. }
  801. //
  802. // Max size for secondary dump data
  803. //
  804. #define MAX_SECONDARY_DUMP_SIZE 4000
  805. C_ASSERT(MAX_SECONDARY_DUMP_SIZE <=
  806. (PAGE_SIZE - sizeof(DUMP_BLOB_FILE_HEADER) -
  807. sizeof(DUMP_BLOB_HEADER)));
  808. //
  809. // Added to keep track on incompatible changes of BUGCHECK_DATA_SIZE_RESERVED
  810. // declared at video.h
  811. //
  812. C_ASSERT(BUGCHECK_DATA_SIZE_RESERVED >=
  813. (sizeof(DUMP_BLOB_FILE_HEADER) + sizeof(DUMP_BLOB_HEADER)));
  814. //
  815. // Private function declarations
  816. //
  817. //
  818. // i386\porti386.c
  819. // mips\portmips.c
  820. // alpha\portalpha.c
  821. VOID
  822. pVideoPortInitializeInt10(
  823. IN PFDO_EXTENSION FdoExtension
  824. );
  825. NTSTATUS
  826. pVideoPortEnableVDM(
  827. IN PFDO_EXTENSION FdoExtension,
  828. IN BOOLEAN Enable,
  829. IN PVIDEO_VDM VdmInfo,
  830. IN ULONG VdmInfoSize
  831. );
  832. NTSTATUS
  833. pVideoPortRegisterVDM(
  834. IN PFDO_EXTENSION FdoExtension,
  835. IN PVIDEO_VDM VdmInfo,
  836. IN ULONG VdmInfoSize,
  837. OUT PVIDEO_REGISTER_VDM RegisterVdm,
  838. IN ULONG RegisterVdmSize,
  839. OUT PULONG_PTR OutputSize
  840. );
  841. NTSTATUS
  842. pVideoPortSetIOPM(
  843. IN ULONG NumAccessRanges,
  844. IN PVIDEO_ACCESS_RANGE AccessRange,
  845. IN BOOLEAN Enable,
  846. IN ULONG IOPMNumber
  847. );
  848. VP_STATUS
  849. pVideoPortGetVDMBiosData(
  850. IN PFDO_EXTENSION FdoExtension,
  851. PCHAR Buffer,
  852. ULONG Length
  853. );
  854. NTSTATUS
  855. pVideoPortPutVDMBiosData(
  856. IN PFDO_EXTENSION FdoExtension,
  857. PCHAR Buffer,
  858. ULONG Length
  859. );
  860. //
  861. // acpi.c
  862. //
  863. NTSTATUS
  864. pVideoPortQueryACPIInterface(
  865. PDEVICE_SPECIFIC_EXTENSION FdoExtension
  866. );
  867. NTSTATUS
  868. pVideoPortDockEventCallback (
  869. PVOID NotificationStructure,
  870. PDEVICE_SPECIFIC_EXTENSION DoSpecificExtension
  871. );
  872. VOID
  873. pVideoPortACPIEventCallback(
  874. PDEVICE_SPECIFIC_EXTENSION pFdoObject,
  875. ULONG eventID
  876. );
  877. VOID
  878. pVideoPortACPIEventHandler(
  879. PVIDEO_ACPI_EVENT_CONTEXT EventContext
  880. );
  881. NTSTATUS
  882. pVideoPortACPIIoctl(
  883. IN PDEVICE_OBJECT DeviceObject,
  884. IN ULONG MethodName,
  885. IN PULONG InputParam1,
  886. IN PULONG InputParam2,
  887. IN ULONG OutputBufferSize,
  888. IN PACPI_EVAL_OUTPUT_BUFFER pOutputBuffer
  889. );
  890. VOID
  891. VpRegisterLCDCallbacks(
  892. );
  893. VOID
  894. VpUnregisterLCDCallbacks(
  895. );
  896. VOID
  897. VpRegisterPowerStateCallback(
  898. VOID
  899. );
  900. VOID
  901. VpPowerStateCallback(
  902. IN PVOID CallbackContext,
  903. IN PVOID Argument1,
  904. IN PVOID Argument2
  905. );
  906. VOID
  907. VpDelayedPowerStateCallback(
  908. IN PVOID Context
  909. );
  910. NTSTATUS
  911. VpSetLCDPowerUsage(
  912. IN PDEVICE_OBJECT DeviceObject,
  913. IN BOOLEAN FullPower
  914. );
  915. //
  916. // ddc.c
  917. //
  918. BOOLEAN
  919. DDCReadEdidSegment(
  920. IN PVOID pHwDeviceExtension,
  921. IN PVIDEO_I2C_CONTROL pI2CControl,
  922. IN OUT PUCHAR pucEdidBuffer,
  923. IN ULONG ulEdidBufferSize,
  924. IN UCHAR ucEdidSegment,
  925. IN UCHAR ucEdidOffset,
  926. IN UCHAR ucSetOffsetAddress,
  927. IN UCHAR ucReadAddress,
  928. IN BOOLEAN bEnhancedDDC
  929. );
  930. //
  931. // dma.c
  932. //
  933. #if DBG
  934. VOID
  935. pDumpScatterGather(
  936. PVP_SCATTER_GATHER_LIST SGList
  937. );
  938. #define DUMP_SCATTER_GATHER(SGList) pDumpScatterGather(SGList)
  939. #else
  940. #define DUMP_SCATTER_GATHER(SGList)
  941. #endif
  942. PVOID
  943. VideoPortGetCommonBuffer(
  944. IN PVOID HwDeviceExtension,
  945. IN ULONG DesiredLength,
  946. IN ULONG Alignment,
  947. OUT PPHYSICAL_ADDRESS LogicalAddress,
  948. OUT PULONG ActualLength,
  949. IN BOOLEAN CacheEnabled
  950. );
  951. VOID
  952. VideoPortFreeCommonBuffer(
  953. IN PVOID HwDeviceExtension,
  954. IN ULONG Length,
  955. IN PVOID VirtualAddress,
  956. IN PHYSICAL_ADDRESS LogicalAddress,
  957. IN BOOLEAN CacheEnabled
  958. );
  959. PDMA
  960. VideoPortDoDma(
  961. IN PVOID HwDeviceExtension,
  962. IN PDMA pDma,
  963. IN DMA_FLAGS DmaFlags
  964. );
  965. BOOLEAN
  966. VideoPortLockPages(
  967. IN PVOID HwDeviceExtension,
  968. IN OUT PVIDEO_REQUEST_PACKET pVrp,
  969. IN PEVENT pMappedUserEvent,
  970. IN PEVENT pDisplayEvent,
  971. IN DMA_FLAGS DmaFlags
  972. );
  973. BOOLEAN
  974. VideoPortUnlockPages(
  975. PVOID HwDeviceExtension,
  976. PDMA pDma
  977. );
  978. PVOID
  979. VideoPortGetMdl(
  980. IN PVOID HwDeviceExtension,
  981. IN PDMA pDma
  982. );
  983. VOID
  984. pVideoPortListControl(
  985. IN PDEVICE_OBJECT DeviceObject,
  986. IN PIRP pIrp,
  987. IN PSCATTER_GATHER_LIST ScatterGather,
  988. IN PVOID Context
  989. );
  990. //
  991. // edid.c
  992. //
  993. BOOLEAN
  994. pVideoPortIsValidEDID(
  995. PVOID Edid
  996. );
  997. VOID
  998. pVideoPortGetEDIDId(
  999. PVOID pEdid,
  1000. PWCHAR pwChar
  1001. );
  1002. PVOID
  1003. pVideoPortGetMonitordescription(
  1004. PVOID pEdid
  1005. );
  1006. ULONG
  1007. pVideoPortGetEdidOemID(
  1008. IN PVOID pEdid,
  1009. OUT PUCHAR pBuffer
  1010. );
  1011. //
  1012. // enum.c
  1013. //
  1014. NTSTATUS
  1015. pVideoPnPCapabilities(
  1016. IN PCHILD_PDO_EXTENSION PdoExtension,
  1017. IN PDEVICE_CAPABILITIES Capabilities
  1018. );
  1019. NTSTATUS
  1020. pVideoPnPResourceRequirements(
  1021. IN PCHILD_PDO_EXTENSION PdoExtension,
  1022. OUT PCM_RESOURCE_LIST * ResourceList
  1023. );
  1024. NTSTATUS
  1025. pVideoPnPQueryId(
  1026. IN PDEVICE_OBJECT DeviceObject,
  1027. IN BUS_QUERY_ID_TYPE BusQueryIdType,
  1028. IN OUT PWSTR * BusQueryId
  1029. );
  1030. NTSTATUS
  1031. VpAddPdo(
  1032. PDEVICE_OBJECT DeviceObject,
  1033. PVIDEO_CHILD_DESCRIPTOR VideoChildDescriptor
  1034. );
  1035. NTSTATUS
  1036. pVideoPortEnumerateChildren(
  1037. PDEVICE_OBJECT DeviceObject,
  1038. PIRP Irp
  1039. );
  1040. NTSTATUS
  1041. pVideoPortQueryDeviceText(
  1042. PDEVICE_OBJECT ChildDevice,
  1043. DEVICE_TEXT_TYPE TextType,
  1044. PWSTR * ReturnValue
  1045. );
  1046. NTSTATUS
  1047. pVideoPortCleanUpChildList(
  1048. PFDO_EXTENSION FdoExtension,
  1049. PDEVICE_OBJECT deviceObject
  1050. );
  1051. //
  1052. // i2c.c
  1053. //
  1054. BOOLEAN
  1055. I2CStart(
  1056. IN PVOID pHwDeviceExtension,
  1057. IN PI2C_CALLBACKS pI2CCallbacks
  1058. );
  1059. BOOLEAN
  1060. I2CStop(
  1061. IN PVOID pHwDeviceExtension,
  1062. IN PI2C_CALLBACKS pI2CCallbacks
  1063. );
  1064. BOOLEAN
  1065. I2CWrite(
  1066. IN PVOID pHwDeviceExtension,
  1067. IN PI2C_CALLBACKS pI2CCallbacks,
  1068. IN PUCHAR pucBuffer,
  1069. IN ULONG ulLength
  1070. );
  1071. BOOLEAN
  1072. I2CRead(
  1073. IN PVOID pHwDeviceExtension,
  1074. IN PI2C_CALLBACKS pI2CCallbacks,
  1075. OUT PUCHAR pucBuffer,
  1076. IN ULONG ulLength
  1077. );
  1078. BOOLEAN
  1079. I2CWriteByte(
  1080. IN PVOID pHwDeviceExtension,
  1081. IN PI2C_CALLBACKS pI2CCallbacks,
  1082. IN UCHAR ucByte
  1083. );
  1084. BOOLEAN
  1085. I2CReadByte(
  1086. IN PVOID pHwDeviceExtension,
  1087. IN PI2C_CALLBACKS pI2CCallbacks,
  1088. OUT PUCHAR pucByte,
  1089. IN BOOLEAN bMore
  1090. );
  1091. BOOLEAN
  1092. I2CWaitForClockLineHigh(
  1093. IN PVOID pHwDeviceExtension,
  1094. IN PI2C_CALLBACKS pI2CCallbacks
  1095. );
  1096. //
  1097. // i2c2.c
  1098. //
  1099. BOOLEAN
  1100. I2CStart2(
  1101. IN PVOID pHwDeviceExtension,
  1102. IN PVIDEO_I2C_CONTROL pI2CControl
  1103. );
  1104. BOOLEAN
  1105. I2CStop2(
  1106. IN PVOID pHwDeviceExtension,
  1107. IN PVIDEO_I2C_CONTROL pI2CControl
  1108. );
  1109. BOOLEAN
  1110. I2CWrite2(
  1111. IN PVOID pHwDeviceExtension,
  1112. IN PVIDEO_I2C_CONTROL pI2CControl,
  1113. IN PUCHAR pucBuffer,
  1114. IN ULONG ulLength
  1115. );
  1116. BOOLEAN
  1117. I2CRead2(
  1118. IN PVOID pHwDeviceExtension,
  1119. IN PVIDEO_I2C_CONTROL pI2CControl,
  1120. OUT PUCHAR pucBuffer,
  1121. IN ULONG ulLength,
  1122. IN BOOLEAN bEndOfRead
  1123. );
  1124. BOOLEAN
  1125. I2CWriteByte2(
  1126. IN PVOID pHwDeviceExtension,
  1127. IN PVIDEO_I2C_CONTROL pI2CControl,
  1128. IN UCHAR ucByte
  1129. );
  1130. BOOLEAN
  1131. I2CReadByte2(
  1132. IN PVOID pHwDeviceExtension,
  1133. IN PVIDEO_I2C_CONTROL pI2CControl,
  1134. OUT PUCHAR pucByte,
  1135. IN BOOLEAN bEndOfRead
  1136. );
  1137. BOOLEAN
  1138. I2CWaitForClockLineHigh2(
  1139. IN PVOID pHwDeviceExtension,
  1140. IN PVIDEO_I2C_CONTROL pI2CControl
  1141. );
  1142. //
  1143. // pnp.c
  1144. //
  1145. NTSTATUS
  1146. pVideoPortSendIrpToLowerDevice(
  1147. IN PDEVICE_OBJECT DeviceObject,
  1148. IN PIRP Irp
  1149. );
  1150. NTSTATUS
  1151. pVideoPortPowerCallDownIrpStack(
  1152. PDEVICE_OBJECT AttachedDeviceObject,
  1153. PIRP Irp
  1154. );
  1155. VOID
  1156. pVideoPortHibernateNotify(
  1157. IN PDEVICE_OBJECT Pdo,
  1158. BOOLEAN IsVideoObject
  1159. );
  1160. NTSTATUS
  1161. pVideoPortPnpDispatch(
  1162. IN PDEVICE_OBJECT DeviceObject,
  1163. IN PIRP Irp
  1164. );
  1165. NTSTATUS
  1166. pVideoPortPowerDispatch(
  1167. IN PDEVICE_OBJECT DeviceObject,
  1168. IN PIRP Irp
  1169. );
  1170. VOID
  1171. pVideoPortPowerIrpComplete(
  1172. IN PDEVICE_OBJECT DeviceObject,
  1173. IN UCHAR MinorFunction,
  1174. IN POWER_STATE PowerState,
  1175. IN PVOID Context,
  1176. IN PIO_STATUS_BLOCK IoStatus
  1177. );
  1178. NTSTATUS
  1179. pVideoPortPowerUpComplete(
  1180. IN PDEVICE_OBJECT DeviceObject,
  1181. IN PIRP Irp,
  1182. IN PVOID Context
  1183. );
  1184. //
  1185. // registry.c
  1186. //
  1187. NTSTATUS
  1188. VpGetFlags(
  1189. IN PUNICODE_STRING RegistryPath,
  1190. PVIDEO_HW_INITIALIZATION_DATA HwInitializationData,
  1191. PULONG Flags
  1192. );
  1193. BOOLEAN
  1194. IsMirrorDriver(
  1195. PFDO_EXTENSION FdoExtension
  1196. );
  1197. BOOLEAN
  1198. pOverrideConflict(
  1199. PFDO_EXTENSION FdoExtension,
  1200. BOOLEAN bSetResources
  1201. );
  1202. NTSTATUS
  1203. pVideoPortReportResourceList(
  1204. PDEVICE_SPECIFIC_EXTENSION DoSpecificExtension,
  1205. ULONG NumAccessRanges,
  1206. PVIDEO_ACCESS_RANGE AccessRanges,
  1207. PBOOLEAN Conflict,
  1208. PDEVICE_OBJECT DeviceObject,
  1209. BOOLEAN ClaimUnlistedResources
  1210. );
  1211. VOID
  1212. VpReleaseResources(
  1213. PFDO_EXTENSION FdoExtension
  1214. );
  1215. BOOLEAN
  1216. VpIsDetection(
  1217. PUNICODE_STRING RegistryPath
  1218. );
  1219. NTSTATUS
  1220. VpSetEventCompletion(
  1221. IN PDEVICE_OBJECT DeviceObject,
  1222. IN PIRP Irp,
  1223. IN PKEVENT Event
  1224. );
  1225. VOID
  1226. UpdateRegValue(
  1227. IN PUNICODE_STRING RegistryPath,
  1228. IN PWCHAR RegValue,
  1229. IN ULONG Value
  1230. );
  1231. //
  1232. // videoprt.c
  1233. //
  1234. NTSTATUS
  1235. pVideoPortCreateDeviceName(
  1236. PWSTR DeviceString,
  1237. ULONG DeviceNumber,
  1238. PUNICODE_STRING UnicodeString,
  1239. PWCHAR UnicodeBuffer
  1240. );
  1241. NTSTATUS
  1242. pVideoPortDispatch(
  1243. IN PDEVICE_OBJECT DeviceObject,
  1244. IN PIRP Irp
  1245. );
  1246. NTSTATUS
  1247. pVideoPortSystemControl(
  1248. IN PDEVICE_OBJECT DeviceObject,
  1249. IN PIRP Irp
  1250. );
  1251. PVOID
  1252. pVideoPortFreeDeviceBase(
  1253. IN PVOID HwDeviceExtension,
  1254. IN PVOID MappedAddress
  1255. );
  1256. PVOID
  1257. pVideoPortGetDeviceBase(
  1258. IN PVOID HwDeviceExtension,
  1259. IN PHYSICAL_ADDRESS IoAddress,
  1260. IN ULONG NumberOfUchars,
  1261. IN UCHAR InIoSpace,
  1262. IN BOOLEAN bLargePage
  1263. );
  1264. NTSTATUS
  1265. pVideoPortGetDeviceDataRegistry(
  1266. IN PVOID Context,
  1267. IN PUNICODE_STRING PathName,
  1268. IN INTERFACE_TYPE BusType,
  1269. IN ULONG BusNumber,
  1270. IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
  1271. IN CONFIGURATION_TYPE ControllerType,
  1272. IN ULONG ControllerNumber,
  1273. IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
  1274. IN CONFIGURATION_TYPE PeripheralType,
  1275. IN ULONG PeripheralNumber,
  1276. IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation
  1277. );
  1278. NTSTATUS
  1279. pVideoPortGetRegistryCallback(
  1280. IN PWSTR ValueName,
  1281. IN ULONG ValueType,
  1282. IN PVOID ValueData,
  1283. IN ULONG ValueLength,
  1284. IN PVOID Context,
  1285. IN PVOID EntryContext
  1286. );
  1287. VOID
  1288. pVPInit(
  1289. VOID
  1290. );
  1291. NTSTATUS
  1292. VpInitializeBusCallback(
  1293. IN PVOID Context,
  1294. IN PUNICODE_STRING PathName,
  1295. IN INTERFACE_TYPE BusType,
  1296. IN ULONG BusNumber,
  1297. IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
  1298. IN CONFIGURATION_TYPE ControllerType,
  1299. IN ULONG ControllerNumber,
  1300. IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
  1301. IN CONFIGURATION_TYPE PeripheralType,
  1302. IN ULONG PeripheralNumber,
  1303. IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation
  1304. );
  1305. NTSTATUS
  1306. VpCreateDevice(
  1307. IN PDRIVER_OBJECT DriverObject,
  1308. IN ULONG DeviceExtensionSize,
  1309. OUT PDEVICE_OBJECT *DeviceObject
  1310. );
  1311. ULONG
  1312. VideoPortLegacyFindAdapter(
  1313. IN PDRIVER_OBJECT DriverObject,
  1314. IN PVOID Argument2,
  1315. IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData,
  1316. IN PVOID HwContext,
  1317. IN ULONG PnpFlags
  1318. );
  1319. NTSTATUS
  1320. VideoPortFindAdapter(
  1321. IN PDRIVER_OBJECT DriverObject,
  1322. IN PVOID Argument2,
  1323. IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData,
  1324. IN PVOID HwContext,
  1325. PDEVICE_OBJECT DeviceObject,
  1326. PUCHAR nextMiniport
  1327. );
  1328. NTSTATUS
  1329. VideoPortFindAdapter2(
  1330. IN PDRIVER_OBJECT DriverObject,
  1331. IN PVOID Argument2,
  1332. IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData,
  1333. IN PVOID HwContext,
  1334. PDEVICE_OBJECT DeviceObject,
  1335. PUCHAR nextMiniport
  1336. );
  1337. NTSTATUS
  1338. VpAddDevice(
  1339. IN PDRIVER_OBJECT DriverObject,
  1340. IN PDEVICE_OBJECT PhysicalDeviceObject
  1341. );
  1342. VOID
  1343. VpDriverUnload(
  1344. IN PDRIVER_OBJECT DriverObject
  1345. );
  1346. VP_STATUS
  1347. VpRegistryCallback(
  1348. PVOID HwDeviceExtension,
  1349. PVOID Context,
  1350. PWSTR ValueName,
  1351. PVOID ValueData,
  1352. ULONG ValueLength
  1353. );
  1354. NTSTATUS
  1355. VpGetBusInterface(
  1356. PFDO_EXTENSION FdoExtension
  1357. );
  1358. PVOID
  1359. VpGetProcAddress(
  1360. IN PVOID HwDeviceExtension,
  1361. IN PUCHAR FunctionName
  1362. );
  1363. BOOLEAN
  1364. pVideoPortInterrupt(
  1365. IN PKINTERRUPT Interrupt,
  1366. IN PDEVICE_OBJECT DeviceObject
  1367. );
  1368. BOOLEAN
  1369. pVideoPortLogErrorEntry(
  1370. IN PVOID Context
  1371. );
  1372. VOID
  1373. pVideoPortLogErrorEntryDPC(
  1374. IN PKDPC Dpc,
  1375. IN PVOID DeferredContext,
  1376. IN PVOID SystemArgument1,
  1377. IN PVOID SystemArgument2
  1378. );
  1379. VOID
  1380. pVideoPortMapToNtStatus(
  1381. IN PSTATUS_BLOCK StatusBlock
  1382. );
  1383. NTSTATUS
  1384. pVideoPortMapUserPhysicalMem(
  1385. IN PFDO_EXTENSION FdoExtension,
  1386. IN HANDLE ProcessHandle OPTIONAL,
  1387. IN PHYSICAL_ADDRESS PhysicalAddress,
  1388. IN OUT PULONG Length,
  1389. IN OUT PULONG InIoSpace,
  1390. IN OUT PVOID *VirtualAddress
  1391. );
  1392. BOOLEAN
  1393. pVideoPortSynchronizeExecution(
  1394. PVOID HwDeviceExtension,
  1395. VIDEO_SYNCHRONIZE_PRIORITY Priority,
  1396. PMINIPORT_SYNCHRONIZE_ROUTINE SynchronizeRoutine,
  1397. PVOID Context
  1398. );
  1399. VOID
  1400. pVideoPortHwTimer(
  1401. IN PDEVICE_OBJECT DeviceObject,
  1402. PVOID Context
  1403. );
  1404. BOOLEAN
  1405. pVideoPortResetDisplay(
  1406. IN ULONG Columns,
  1407. IN ULONG Rows
  1408. );
  1409. BOOLEAN
  1410. pVideoPortMapStoD(
  1411. IN PVOID DeviceExtension,
  1412. IN SYSTEM_POWER_STATE SystemState,
  1413. OUT PDEVICE_POWER_STATE DeviceState
  1414. );
  1415. //
  1416. // agp.c
  1417. //
  1418. BOOLEAN
  1419. VpQueryAgpInterface(
  1420. PFDO_EXTENSION DeviceExtension,
  1421. IN USHORT Version
  1422. );
  1423. PHYSICAL_ADDRESS
  1424. AgpReservePhysical(
  1425. IN PVOID Context,
  1426. IN ULONG Pages,
  1427. IN VIDEO_PORT_CACHE_TYPE Caching,
  1428. OUT PVOID *PhysicalReserveContext
  1429. );
  1430. VOID
  1431. AgpReleasePhysical(
  1432. PVOID Context,
  1433. PVOID PhysicalReserveContext
  1434. );
  1435. BOOLEAN
  1436. AgpCommitPhysical(
  1437. PVOID Context,
  1438. PVOID PhysicalReserveContext,
  1439. ULONG Pages,
  1440. ULONG Offset
  1441. );
  1442. VOID
  1443. AgpFreePhysical(
  1444. IN PVOID Context,
  1445. IN PVOID PhysicalReserveContext,
  1446. IN ULONG Pages,
  1447. IN ULONG Offset
  1448. );
  1449. PVOID
  1450. AgpReserveVirtual(
  1451. IN PVOID Context,
  1452. IN HANDLE ProcessHandle,
  1453. IN PVOID PhysicalReserveContext,
  1454. OUT PVOID *VirtualReserveContext
  1455. );
  1456. VOID
  1457. AgpReleaseVirtual(
  1458. IN PVOID Context,
  1459. IN PVOID VirtualReserveContext
  1460. );
  1461. PVOID
  1462. AgpCommitVirtual(
  1463. IN PVOID Context,
  1464. IN PVOID VirtualReserveContext,
  1465. IN ULONG Pages,
  1466. IN ULONG Offset
  1467. );
  1468. VOID
  1469. AgpFreeVirtual(
  1470. IN PVOID Context,
  1471. IN PVOID VirtualReserveContext,
  1472. IN ULONG Pages,
  1473. IN ULONG Offset
  1474. );
  1475. BOOLEAN
  1476. AgpSetRate(
  1477. IN PVOID Context,
  1478. IN ULONG AgpRate
  1479. );
  1480. VP_STATUS
  1481. VpGetAgpServices2(
  1482. IN PVOID pHwDeviceExtension,
  1483. OUT PVIDEO_PORT_AGP_INTERFACE_2 pAgpInterface
  1484. );
  1485. //
  1486. // ???
  1487. //
  1488. BOOLEAN
  1489. CreateBitField(
  1490. PREGION *Region,
  1491. ULONG Length
  1492. );
  1493. VOID
  1494. ModifyRegion(
  1495. PREGION Region,
  1496. ULONG Offset,
  1497. ULONG Length,
  1498. BOOLEAN Set
  1499. );
  1500. BOOLEAN
  1501. FindFirstRun(
  1502. PREGION Region,
  1503. PULONG Offset,
  1504. PULONG Length
  1505. );
  1506. NTSTATUS
  1507. VpAppendToRequirementsList(
  1508. IN PDEVICE_OBJECT DeviceObject,
  1509. IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *RequirementsList,
  1510. IN ULONG NumAccessRanges,
  1511. IN PVIDEO_ACCESS_RANGE AccessRanges
  1512. );
  1513. BOOLEAN
  1514. VpIsLegacyAccessRange(
  1515. PFDO_EXTENSION fdoExtension,
  1516. PVIDEO_ACCESS_RANGE AccessRange
  1517. );
  1518. BOOLEAN
  1519. VpIsResourceInList(
  1520. PCM_PARTIAL_RESOURCE_DESCRIPTOR pResource,
  1521. PCM_FULL_RESOURCE_DESCRIPTOR pFullResource,
  1522. PCM_RESOURCE_LIST removeList
  1523. );
  1524. PCM_RESOURCE_LIST
  1525. VpRemoveFromResourceList(
  1526. PCM_RESOURCE_LIST OriginalList,
  1527. ULONG NumAccessRanges,
  1528. PVIDEO_ACCESS_RANGE AccessRanges
  1529. );
  1530. VOID
  1531. VpEnableDisplay(
  1532. PFDO_EXTENSION fdoExtension,
  1533. BOOLEAN bState
  1534. );
  1535. VOID
  1536. VpWin32kCallout(
  1537. PVIDEO_WIN32K_CALLBACKS_PARAMS calloutParams
  1538. );
  1539. BOOLEAN
  1540. pCheckActiveMonitor(
  1541. PCHILD_PDO_EXTENSION pChildDeviceExtension
  1542. );
  1543. BOOLEAN
  1544. VpAllowFindAdapter(
  1545. PFDO_EXTENSION fdoExtension
  1546. );
  1547. VOID
  1548. InitializePowerStruct(
  1549. IN PIRP Irp,
  1550. OUT PVIDEO_POWER_MANAGEMENT vpPower,
  1551. OUT BOOLEAN * bWakeUp
  1552. );
  1553. BOOLEAN
  1554. VpTranslateResource(
  1555. IN PFDO_EXTENSION fdoExtension,
  1556. IN PULONG InIoSpace,
  1557. IN PPHYSICAL_ADDRESS PhysicalAddress,
  1558. OUT PPHYSICAL_ADDRESS TranslatedAddress
  1559. );
  1560. ULONG
  1561. GetCmResourceListSize(
  1562. PCM_RESOURCE_LIST CmResourceList
  1563. );
  1564. VOID
  1565. AddToResourceList(
  1566. ULONG BusNumber,
  1567. ULONG Slot
  1568. );
  1569. BOOLEAN
  1570. CheckResourceList(
  1571. ULONG BusNumber,
  1572. ULONG Slot
  1573. );
  1574. BOOLEAN
  1575. VpTranslateBusAddress(
  1576. IN PFDO_EXTENSION fdoExtension,
  1577. IN PPHYSICAL_ADDRESS IoAddress,
  1578. IN OUT PULONG addressSpace,
  1579. IN OUT PPHYSICAL_ADDRESS TranslatedAddress
  1580. );
  1581. VOID
  1582. pVideoPortDpcDispatcher(
  1583. IN PKDPC Dpc,
  1584. IN PVOID HwDeviceExtension,
  1585. IN PMINIPORT_DPC_ROUTINE DpcRoutine,
  1586. IN PVOID Context
  1587. );
  1588. #if DBG
  1589. VOID
  1590. DumpRequirements(
  1591. PIO_RESOURCE_REQUIREMENTS_LIST Requirements
  1592. );
  1593. VOID
  1594. DumpResourceList(
  1595. PCM_RESOURCE_LIST pcmResourceList
  1596. );
  1597. PIO_RESOURCE_REQUIREMENTS_LIST
  1598. BuildRequirements(
  1599. PCM_RESOURCE_LIST pcmResourceList
  1600. );
  1601. VOID
  1602. DumpUnicodeString(
  1603. IN PUNICODE_STRING p
  1604. );
  1605. #endif
  1606. PCM_PARTIAL_RESOURCE_DESCRIPTOR
  1607. RtlUnpackPartialDesc(
  1608. IN UCHAR Type,
  1609. IN PCM_RESOURCE_LIST ResList,
  1610. IN OUT PULONG Count
  1611. );
  1612. NTSTATUS
  1613. pVideoMiniDeviceIoControl(
  1614. IN PDEVICE_OBJECT hDevice,
  1615. IN ULONG dwIoControlCode,
  1616. IN PVOID lpInBuffer,
  1617. IN ULONG nInBufferSize,
  1618. OUT PVOID lpOutBuffer,
  1619. IN ULONG nOutBufferSize
  1620. );
  1621. ULONG
  1622. pVideoPortGetVgaStatusPci(
  1623. PVOID HwDeviceExtension
  1624. );
  1625. BOOLEAN
  1626. VpIsVgaResource(
  1627. PVIDEO_ACCESS_RANGE AccessRange
  1628. );
  1629. VOID
  1630. VpInterfaceDefaultReference(
  1631. IN PVOID pContext
  1632. );
  1633. VOID
  1634. VpInterfaceDefaultDereference(
  1635. IN PVOID pContext
  1636. );
  1637. BOOLEAN
  1638. VpEnableAdapterInterface(
  1639. PDEVICE_SPECIFIC_EXTENSION DoSpecificExtension
  1640. );
  1641. VOID
  1642. VpDisableAdapterInterface(
  1643. PFDO_EXTENSION fdoExtension
  1644. );
  1645. ULONG
  1646. VpGetDeviceCount(
  1647. PVOID HwDeviceExtension
  1648. );
  1649. VOID
  1650. VpEnableNewRegistryKey(
  1651. PFDO_EXTENSION FdoExtension,
  1652. PDEVICE_SPECIFIC_EXTENSION DoSpecificExtension,
  1653. PUNICODE_STRING RegistryPath,
  1654. ULONG RegistryIndex
  1655. );
  1656. VOID
  1657. VpInitializeKey(
  1658. PDEVICE_OBJECT PhysicalDeviceObject,
  1659. PWSTR NewRegistryPath
  1660. );
  1661. VOID
  1662. VpInitializeLegacyKey(
  1663. PWSTR OldRegistryPath,
  1664. PWSTR NewRegistryPath
  1665. );
  1666. NTSTATUS
  1667. VpCopyRegistry(
  1668. HANDLE hKeyRootSrc,
  1669. HANDLE hKeyRootDst,
  1670. PWSTR SrcKeyPath,
  1671. PWSTR DstKeyPath
  1672. );
  1673. VP_STATUS
  1674. VPSetRegistryParameters(
  1675. PVOID HwDeviceExtension,
  1676. PWSTR ValueName,
  1677. PVOID ValueData,
  1678. ULONG ValueLength,
  1679. PWSTR RegistryPath,
  1680. ULONG RegistryPathLength
  1681. );
  1682. VP_STATUS
  1683. VPGetRegistryParameters(
  1684. PVOID HwDeviceExtension,
  1685. PWSTR ParameterName,
  1686. UCHAR IsParameterFileName,
  1687. PMINIPORT_GET_REGISTRY_ROUTINE CallbackRoutine,
  1688. PVOID Context,
  1689. PWSTR RegistryPath,
  1690. ULONG RegistryPathLength
  1691. );
  1692. BOOLEAN
  1693. VpGetServiceSubkey(
  1694. PUNICODE_STRING RegistryPath,
  1695. HANDLE* pServiceSubKey
  1696. );
  1697. VP_STATUS
  1698. VpInt10AllocateBuffer(
  1699. IN PVOID Context,
  1700. OUT PUSHORT Seg,
  1701. OUT PUSHORT Off,
  1702. IN OUT PULONG Length
  1703. );
  1704. VP_STATUS
  1705. VpInt10FreeBuffer(
  1706. IN PVOID Context,
  1707. IN USHORT Seg,
  1708. IN USHORT Off
  1709. );
  1710. VP_STATUS
  1711. VpInt10ReadMemory(
  1712. IN PVOID Context,
  1713. IN USHORT Seg,
  1714. IN USHORT Off,
  1715. OUT PVOID Buffer,
  1716. IN ULONG Length
  1717. );
  1718. VP_STATUS
  1719. VpInt10WriteMemory(
  1720. IN PVOID Context,
  1721. IN USHORT Seg,
  1722. IN USHORT Off,
  1723. OUT PVOID Buffer,
  1724. IN ULONG Length
  1725. );
  1726. VP_STATUS
  1727. VpInt10CallBios(
  1728. PVOID HwDeviceExtension,
  1729. PINT10_BIOS_ARGUMENTS BiosArguments
  1730. );
  1731. VOID
  1732. pVpBugcheckCallback(
  1733. IN KBUGCHECK_CALLBACK_REASON Reason,
  1734. IN PKBUGCHECK_REASON_CALLBACK_RECORD Record,
  1735. IN OUT PVOID ReasonSpecificData,
  1736. IN ULONG ReasonSpecificDataLength
  1737. );
  1738. VOID
  1739. VpAcquireLock(
  1740. VOID
  1741. );
  1742. VOID
  1743. VpReleaseLock(
  1744. VOID
  1745. );
  1746. PVOID
  1747. VpAllocateNonPagedPoolPageAligned(
  1748. ULONG Size
  1749. );
  1750. VOID
  1751. pVpGeneralBugcheckHandler(
  1752. PKBUGCHECK_SECONDARY_DUMP_DATA DumpData
  1753. );
  1754. VOID
  1755. pVpWriteFile(
  1756. PWSTR pwszFileName,
  1757. PVOID pvBuffer,
  1758. ULONG ulSize
  1759. );
  1760. VP_STATUS
  1761. pVpFlushRegistry(
  1762. PWSTR pwszRegKey
  1763. );
  1764. PDEVICE_OBJECT
  1765. pVpGetFdo(
  1766. PDEVICE_OBJECT pPdo
  1767. );
  1768. #endif // ifndef __VIDEOPRT_H__