Author: aandrejevic
Date: Tue Jun 2 21:59:19 2015
New Revision: 68001
URL:
http://svn.reactos.org/svn/reactos?rev=68001&view=rev
Log:
[NTVDM]
Implement XMS functions 10h, 11h and 12h by forwarding them to the
VDM DOS memory manager.
CORE-9651 CORE-9741 #resolve #comment Fixed in revision 68001.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.h
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 Jun 2
21:59:19 2015
@@ -20,6 +20,7 @@
#include "dos/dem.h"
#include "device.h"
#include "himem.h"
+#include "memory.h"
#define XMS_DEVICE_NAME "XMSXXXX0"
@@ -564,6 +565,74 @@
break;
}
+ /* Allocate UMB */
+ case 0x10:
+ {
+ WORD Segment;
+ WORD MaxAvailable;
+ BYTE OldAllocStrategy = Sda->AllocStrategy;
+ BOOLEAN OldLinkState = DosUmbLinked;
+
+ DosLinkUmb();
+ Sda->AllocStrategy = DOS_ALLOC_HIGH | DOS_ALLOC_BEST_FIT;
+ Segment = DosAllocateMemory(getDX(), &MaxAvailable);
+
+ if (Segment)
+ {
+ setAX(1);
+ setBX(Segment);
+ }
+ else
+ {
+ setAX(0);
+ setBL(MaxAvailable ? XMS_STATUS_SMALLER_UMB : XMS_STATUS_OUT_OF_UMBS);
+ setDX(MaxAvailable);
+ }
+
+ Sda->AllocStrategy = OldAllocStrategy;
+ if (!OldLinkState) DosUnlinkUmb();
+ break;
+ }
+
+ /* Free UMB */
+ case 0x11:
+ {
+ if (DosFreeMemory(getDX()))
+ {
+ setAX(1);
+ }
+ else
+ {
+ setAX(0);
+ setBL(XMS_STATUS_INVALID_UMB);
+ }
+
+ break;
+ }
+
+ /* Reallocate UMB */
+ case 0x12:
+ {
+ WORD Segment;
+ WORD MaxAvailable;
+
+ Segment = DosResizeMemory(getDX(), getBX(), &MaxAvailable);
+
+ if (Segment)
+ {
+ setAX(1);
+ }
+ else
+ {
+ setAX(0);
+ setBL(Sda->LastErrorCode == ERROR_INVALID_HANDLE
+ ? XMS_STATUS_INVALID_UMB : XMS_STATUS_SMALLER_UMB);
+ setDX(MaxAvailable);
+ }
+
+ break;
+ }
+
default:
{
DPRINT1("XMS command AH = 0x%02X NOT IMPLEMENTED\n", getAH());
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.h [iso-8859-1] Tue Jun 2
21:59:19 2015
@@ -28,6 +28,9 @@
#define XMS_STATUS_LOCKED 0xAB
#define XMS_STATUS_LOCK_OVERFLOW 0xAC
#define XMS_STATUS_CANNOT_LOCK 0xAD
+#define XMS_STATUS_SMALLER_UMB 0xB0
+#define XMS_STATUS_OUT_OF_UMBS 0xB1
+#define XMS_STATUS_INVALID_UMB 0xB2
typedef struct _XMS_HANDLE
{