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.

118 lines
3.2 KiB

  1. /*========================================================================== *
  2. *
  3. * Copyright (C) 1994-1998 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 "ddrawpr.h"
  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. BOOLEAN Cached;
  38. CHECK_GET_AGPI(hdev, pai);
  39. if (fIsUC)
  40. {
  41. Cached = FALSE;
  42. }
  43. else
  44. {
  45. Cached = TRUE;
  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 OsAGPDecommitAll( HANDLE hdev, PVOID pvReservation, DWORD dwNumPages )
  77. {
  78. AGP_INTERFACE *pai;
  79. CHECK_GET_AGPI(hdev, pai);
  80. // Decommit memory.
  81. pai->AgpServices.AgpFreePhysical(pai->Context, pvReservation,
  82. dwNumPages, 0);
  83. return TRUE;
  84. } /* OsAGPDecommitAll */
  85. /*
  86. * OsAGPFree
  87. *
  88. * Free a previously reserved range.
  89. */
  90. BOOL OsAGPFree( HANDLE hdev, PVOID pvReservation )
  91. {
  92. AGP_INTERFACE *pai;
  93. CHECK_GET_AGPI(hdev, pai);
  94. pai->AgpServices.AgpReleasePhysical(pai->Context,
  95. pvReservation);
  96. return TRUE;
  97. } /* OsAGPFree */
  98. #endif // !WIN95