diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/mvdm/xms.486/xms.c | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/mvdm/xms.486/xms.c')
-rw-r--r-- | private/mvdm/xms.486/xms.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/private/mvdm/xms.486/xms.c b/private/mvdm/xms.486/xms.c new file mode 100644 index 000000000..841513b42 --- /dev/null +++ b/private/mvdm/xms.486/xms.c @@ -0,0 +1,103 @@ +/* + * xms.c - Main Module of XMS DLL. + * + * Sudeepb 15-May-1991 Craeted + * williamh 25-Sept-1992 added UMB support + * williamh 10-10-1992 added A20 line support + */ + +#include <xms.h> +#include <suballoc.h> +#include "umb.h" +#include "memapi.h" + +/* XMSInit - XMS Initialiazation routine. (This name may change when XMS is + * converted to DLL). + * + * Entry + * None + * + * Exit + * None + */ + +ULONG xmsMemorySize = (ULONG)0; // Total XMS meory in K + +extern BOOL VDMForWOW; + +PVOID ExtMemSA; + +BOOL XMSInit (int argc, char *argv[]) +{ + DWORD Size; + PVOID Address; + ULONG VdmAddress, XmsSize; + NTSTATUS Status; + + if (!xmsMemorySize) + return FALSE; + + Size = 0; + Address = NULL; + // commit all free UMBs. + ReserveUMB(UMB_OWNER_RAM, &Address, &Size); + + XmsSize = xmsMemorySize * 1024 - (64*1024); + +#ifndef i386 + Status = VdmAllocateVirtualMemory(&VdmAddress, + XmsSize, + FALSE); + + if (Status == STATUS_NOT_IMPLEMENTED) { + + // Old emulator, just assume base address +#endif ; //i386 + // + // Initialize the sub allocator + // + ExtMemSA = SAInitialize( + 1024 * 1024 + 64*1024, + XmsSize, + xmsCommitBlock, + xmsDecommitBlock, + xmsMoveMemory + ); + +#ifndef i386 + } else { + + // + // New emulator. Make sure the reserve worked + // + + if (!NT_SUCCESS(Status)) { + ASSERT(FALSE); + return FALSE; + } + + // + // We only work correctly if emulator returned this value + // + if (VdmAddress != (1024 * 1024 + 64*1024)) { + ASSERT(FALSE); + return FALSE; + } + + ExtMemSA = SAInitialize( + VdmAddress, + XmsSize, + VdmCommitVirtualMemory, + VdmDeCommitVirtualMemory, + xmsMoveMemory + ); + + } +#endif // i386 + + if (ExtMemSA == NULL) { + return FALSE; + } + + return TRUE; +} |