Source code of Windows XP (NT5)
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.

167 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. xmscmt86.c
  5. Abstract:
  6. This module conains the memory commit/decommit/move routines
  7. for risc.
  8. Author:
  9. Dave Hastings (daveh) creation-date 25-Jan-1994
  10. Revision History:
  11. --*/
  12. #include <xms.h>
  13. #include <suballoc.h>
  14. #include <softpc.h>
  15. NTSTATUS
  16. xmsCommitBlock(
  17. ULONG BaseAddress,
  18. ULONG Size
  19. )
  20. /*++
  21. Routine Description:
  22. This routine commits a block of memory using sas_manage_xms.
  23. Arguments:
  24. BaseAddress -- Supplies the base address to commit memory at
  25. Size -- Supplies the size of the block to commit
  26. Return Value:
  27. 0 if successfull
  28. --*/
  29. {
  30. BOOL Status;
  31. //
  32. // Perform the allocation
  33. //
  34. Status = sas_manage_xms(
  35. (PVOID)BaseAddress,
  36. Size,
  37. 1
  38. );
  39. //
  40. // We elected to have 0 indicate success, because that allows
  41. // us to directly pass back NTSTATUS codes. On x86 we use
  42. // NT memory management to do the commit for us, and the returned
  43. // status code contains more information than just success or failure
  44. //
  45. if (Status) {
  46. return STATUS_SUCCESS;
  47. } else {
  48. return -1;
  49. }
  50. }
  51. NTSTATUS
  52. xmsDecommitBlock(
  53. ULONG BaseAddress,
  54. ULONG Size
  55. )
  56. /*++
  57. Routine Description:
  58. This routine commits a block of memory using sas_manage_xms.
  59. Arguments:
  60. BaseAddress -- Supplies the base address to decommit memory at
  61. Size -- Supplies the size of the block to decommit
  62. Return Value:
  63. 0 if successful
  64. --*/
  65. {
  66. BOOL Status;
  67. //
  68. // Perform the allocation
  69. //
  70. Status = sas_manage_xms(
  71. (PVOID)BaseAddress,
  72. Size,
  73. 2
  74. );
  75. //
  76. // We elected to have 0 indicate success, because that allows
  77. // us to directly pass back NTSTATUS codes. On x86 we use
  78. // NT memory management to do the commit for us, and the returned
  79. // status code contains more information than just success or failure
  80. //
  81. if (Status) {
  82. return STATUS_SUCCESS;
  83. } else {
  84. return -1;
  85. }
  86. }
  87. VOID
  88. xmsMoveMemory(
  89. ULONG Destination,
  90. ULONG Source,
  91. ULONG Count
  92. )
  93. /*++
  94. Routine Description:
  95. This routine moves a block of memory, and notifies the emulator.
  96. It correctly handles overlapping source and destination
  97. Arguments:
  98. Destination -- Supplies a pointer to the destination Intel (NOT Linear)
  99. Address
  100. Source -- Supplies a pointer to the source Intel Address
  101. Count -- Supplies the number of bytes to move
  102. Return Value:
  103. None.
  104. --*/
  105. {
  106. ULONG SoftpcBase;
  107. //
  108. // Get the linear address of the beginning of Intel memory
  109. //
  110. SoftpcBase = (ULONG) GetVDMAddr(0,0);
  111. //
  112. // Move the memory
  113. //
  114. RtlMoveMemory(
  115. (PVOID)((ULONG)Destination + SoftpcBase),
  116. (PVOID)((ULONG)Source + SoftpcBase),
  117. Count
  118. );
  119. // WARNING!!!! Donot use Sim32FlushVDMPoiner unless you know the exact segment
  120. // address. In this case, we have no idea what the segment value is, all we
  121. // know is its "linear address".
  122. sas_overwrite_memory((PBYTE)Destination, Count);
  123. }