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.

121 lines
3.3 KiB

  1. /*========================================================================== *
  2. *
  3. * Copyright (C) 1994-1999 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: ddagpnt.c
  6. * Content: Functions for dealing with AGP memory in DirectDraw on NT
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 18-jan-97 colinmc initial implementation
  12. * 13-mar-97 colinmc Bug 6533: Pass uncached flag to VMM correctly
  13. * 07-may-97 colinmc Add support for AGP on OSR 2.1
  14. * 12-Feb-98 DrewB Split into common, Win9x and NT sections.
  15. *
  16. ***************************************************************************/
  17. #include "precomp.hxx"
  18. #ifndef WIN95
  19. // Currently the hdev passed in is the DirectDraw global, so
  20. // look up the AGP interface in it.
  21. #define GET_AGPI(hdev) (&((EDD_DIRECTDRAW_GLOBAL *)hdev)->AgpInterface)
  22. #define CHECK_GET_AGPI(hdev, pvai) \
  23. (pvai) = GET_AGPI(hdev); \
  24. ASSERTGDI((pvai)->Context != NULL, "No AGP context");
  25. // Offset to use for biasing AGP heaps.
  26. #define DDNLV_HEAP_BIAS PAGE_SIZE
  27. /*
  28. * OsAGPReserve
  29. *
  30. * Reserve resources for use as an AGP aperture.
  31. */
  32. BOOL OsAGPReserve( HANDLE hdev, DWORD dwNumPages, BOOL fIsUC, BOOL fIsWC,
  33. FLATPTR *pfpLinStart, LARGE_INTEGER *pliDevStart,
  34. PVOID *ppvReservation )
  35. {
  36. AGP_INTERFACE *pai;
  37. VIDEO_PORT_CACHE_TYPE Cached;
  38. CHECK_GET_AGPI(hdev, pai);
  39. if (fIsUC)
  40. {
  41. Cached = VpNonCached;
  42. }
  43. else
  44. {
  45. Cached = VpWriteCombined;
  46. }
  47. // On NT heaps are kept with offsets rather than pointers so
  48. // always return a base offset as the starting address. The
  49. // base offset is non-zero so that successful heap allocations
  50. // always have a non-zero value.
  51. *pfpLinStart = DDNLV_HEAP_BIAS;
  52. *pliDevStart = pai->AgpServices.
  53. AgpReservePhysical(pai->Context, dwNumPages,
  54. Cached, ppvReservation);
  55. return *ppvReservation != NULL;
  56. } /* OsAGPReserve */
  57. /*
  58. * OsAGPCommit
  59. *
  60. * Commit memory to the given portion of a previously reserved range.
  61. */
  62. BOOL OsAGPCommit( HANDLE hdev, PVOID pvReservation, DWORD dwPageOffset,
  63. DWORD dwNumPages )
  64. {
  65. AGP_INTERFACE *pai;
  66. CHECK_GET_AGPI(hdev, pai);
  67. return pai->AgpServices.AgpCommitPhysical(pai->Context,
  68. pvReservation,
  69. dwNumPages, dwPageOffset);
  70. } /* OsAGPCommit */
  71. /*
  72. * OsAGPDecommitAll
  73. *
  74. * Decommit everything in a reserved area.
  75. */
  76. BOOL OsAGPDecommit( HANDLE hdev, PVOID pvReservation, DWORD dwPageOffset,
  77. DWORD dwNumPages )
  78. {
  79. AGP_INTERFACE *pai;
  80. CHECK_GET_AGPI(hdev, pai);
  81. // Decommit memory.
  82. pai->AgpServices.AgpFreePhysical(pai->Context, pvReservation,
  83. dwNumPages, dwPageOffset );
  84. return TRUE;
  85. } /* OsAGPDecommitAll */
  86. /*
  87. * OsAGPFree
  88. *
  89. * Free a previously reserved range.
  90. */
  91. BOOL OsAGPFree( HANDLE hdev, PVOID pvReservation )
  92. {
  93. AGP_INTERFACE *pai;
  94. CHECK_GET_AGPI(hdev, pai);
  95. pai->AgpServices.AgpReleasePhysical(pai->Context,
  96. pvReservation);
  97. return TRUE;
  98. } /* OsAGPFree */
  99. #endif // !WIN95