Author: aandrejevic
Date: Tue May 12 03:37:00 2015
New Revision: 67675
URL:
http://svn.reactos.org/svn/reactos?rev=67675&view=rev
Log:
[NTVDM]
Fix the XMS driver. AH = 08h is supposed to return the size of the
largest free block in AX, and the total amount of *free* memory
in DX.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c [iso-8859-1] Tue May 12
03:37:00 2015
@@ -185,6 +185,28 @@
return Entry->Size ? Entry : NULL;
}
+static WORD XmsGetLargestFreeBlock(VOID)
+{
+ WORD Result = 0;
+ DWORD CurrentIndex = 0;
+ ULONG RunStart;
+ ULONG RunSize;
+
+ while (CurrentIndex < XMS_BLOCKS)
+ {
+ RunSize = RtlFindNextForwardRunClear(&AllocBitmap, CurrentIndex,
&RunStart);
+ if (RunSize == 0) break;
+
+ /* Update the maximum */
+ if (RunSize > Result) Result = RunSize;
+
+ /* Go to the next run */
+ CurrentIndex = RunStart + RunSize;
+ }
+
+ return Result;
+}
+
static CHAR XmsAlloc(WORD Size, PWORD Handle)
{
BYTE i;
@@ -380,8 +402,8 @@
/* Query Free Extended Memory */
case 0x08:
{
- setAX(FreeBlocks);
- setDX(XMS_BLOCKS);
+ setAX(XmsGetLargestFreeBlock());
+ setDX(FreeBlocks);
setBL(XMS_STATUS_SUCCESS);
break;
}