From e5d49d2072d740d6ebc6570a68c9288b3744324a Mon Sep 17 00:00:00 2001 From: Ulf Wohlers Date: Tue, 8 Apr 2003 16:25:31 +0000 Subject: [PATCH] added xms.h Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@888 --- src/ints/xms.cpp | 141 ++++++--------------------------------------- src/ints/xms.h | 34 +++++++++++ visualc/dosbox.dsp | 4 ++ 3 files changed, 56 insertions(+), 123 deletions(-) create mode 100644 src/ints/xms.h diff --git a/src/ints/xms.cpp b/src/ints/xms.cpp index 61a2f9fe..02948fd7 100644 --- a/src/ints/xms.cpp +++ b/src/ints/xms.cpp @@ -25,6 +25,7 @@ #include "dos_system.h" #include "setup.h" #include "inout.h" +#include "xms.h" #define XMS_HANDLES 50 /* 50 XMS Memory Blocks */ #define XMS_VERSION 0x0300 /* version 3.00 */ @@ -83,7 +84,7 @@ struct XMS_MemMove{ } GCC_ATTRIBUTE(packed); #pragma pack (pop) -static Bit8u XMS_EnableA20(bool enable) +static Bitu XMS_EnableA20(bool enable) { Bit8u val = IO_Read (0x92); if (enable) IO_Write(0x92,val | 2); @@ -91,96 +92,17 @@ static Bit8u XMS_EnableA20(bool enable) return 0; }; -static Bit8u XMS_GetEnabledA20(void) +static Bitu XMS_GetEnabledA20(void) { return (IO_Read(0x92)&2)>0; }; -static Bitu xms_size; -static void* xms_block[C_MEM_MAX_SIZE]; - static Bit16u call_xms; static RealPt xms_callback; static XMS_Block xms_handles[XMS_HANDLES]; -#define GETBIGBLOCKNR(nr) nr/(1024*1024) - -static bool AllocateBigBlock(Bitu block1, Bitu block2) -{ - Bitu size,phys; - - if ((block1<1) || (block1>xms_size)) return false; - if ((block2<1) || (block2>xms_size)) return false; - if (block2=XMS_HANDLES) || !xms_handles[handle].active || !xms_handles[handle].allocated ) { @@ -269,7 +192,7 @@ static Bit8u XMS_FreeMemory(Bitu handle) return 0; }; -static Bit8u XMS_MoveMemory(PhysPt bpt) +static Bitu XMS_MoveMemory(PhysPt bpt) { XMS_MemMove block; /* Fill the block with mem_read's and shit */ @@ -311,7 +234,7 @@ static Bit8u XMS_MoveMemory(PhysPt bpt) return 0; } -static Bit8u XMS_LockMemory(Bitu handle, Bit32u& address) +static Bitu XMS_LockMemory(Bitu handle, Bit32u& address) { /* Check for a valid handle */ if (!handle || (handle>=XMS_HANDLES) || !xms_handles[handle].active || !xms_handles[handle].allocated ) { @@ -322,7 +245,7 @@ static Bit8u XMS_LockMemory(Bitu handle, Bit32u& address) return 0; }; -static Bit8u XMS_UnlockMemory(Bitu handle) +static Bitu XMS_UnlockMemory(Bitu handle) { /* Check for a valid handle */ if (!handle || (handle>=XMS_HANDLES) || !xms_handles[handle].active || !xms_handles[handle].allocated ) { @@ -335,7 +258,7 @@ static Bit8u XMS_UnlockMemory(Bitu handle) return XMS_BLOCK_NOT_LOCKED; }; -static Bit8u XMS_GetHandleInformation(Bitu handle, Bit8u& lockCount, Bit8u& numFree, Bit16u& size) +static Bitu XMS_GetHandleInformation(Bitu handle, Bit8u& lockCount, Bit8u& numFree, Bit16u& size) { /* Check for a valid handle */ if (!handle || (handle>=XMS_HANDLES) || !xms_handles[handle].active || !xms_handles[handle].allocated ) { @@ -348,7 +271,7 @@ static Bit8u XMS_GetHandleInformation(Bitu handle, Bit8u& lockCount, Bit8u& numF return 0; }; -static Bit8u XMS_ResizeMemory(Bitu handle, Bitu newSize) +static Bitu XMS_ResizeMemory(Bitu handle, Bitu newSize) { /* Check for a valid handle */ if (!handle || (handle>=XMS_HANDLES) || !xms_handles[handle].active || !xms_handles[handle].allocated ) { @@ -389,7 +312,8 @@ static Bit8u XMS_ResizeMemory(Bitu handle, Bitu newSize) } // Resize and allocate new mem xms_handles[handle].size = newSize; - xms_handles[handle].allocated = CheckAllocationArea(xms_handles[handle].phys,xms_handles[handle].size*1024); + xms_handles[handle].allocated = 1; + //CheckAllocationArea(xms_handles[handle].phys,xms_handles[handle].size*1024); } else if (newSize>xms_handles[handle].size) { // Lets see if successor has enough free space to do that @@ -412,7 +336,8 @@ static Bit8u XMS_ResizeMemory(Bitu handle, Bitu newSize) }; // Resize and allocate new mem xms_handles[handle].size = newSize; - xms_handles[handle].allocated = CheckAllocationArea(xms_handles[handle].phys,xms_handles[handle].size*1024); + xms_handles[handle].allocated = 1; + //CheckAllocationArea(xms_handles[handle].phys,xms_handles[handle].size*1024); } else { // No more free mem ? LOG(LOG_ERROR,"XMS: Resize failure: out of mem 2"); @@ -510,16 +435,9 @@ Bitu XMS_Handler(void) { return CBRET_NONE; } -static void XMS_ShutDown(Section * sec) { - for (Bitu i=0; i(sec); - Bitu size=xms_size=section->Get_int("xmssize"); + Bitu size=section->Get_int("xmssize"); if (!size) return; if (size>C_MEM_MAX_SIZE-1) size=C_MEM_MAX_SIZE-1; DOS_AddMultiplexHandler(multiplex_xms); @@ -543,28 +461,5 @@ void XMS_Init(Section* sec) { xms_handles[1].active=true; xms_handles[1].phys=1088*1024; /* right behind the hma area */ xms_handles[1].size=size*1024-64; - - // Setup default handlers for unallocated xms - Bitu start = xms_handles[1].phys; - Bitu end = start + xms_handles[1].size*1024; - for (Bitu p=PAGE_COUNT(start);pAddDestroyFunction(&XMS_ShutDown); } diff --git a/src/ints/xms.h b/src/ints/xms.h new file mode 100644 index 00000000..976dcde1 --- /dev/null +++ b/src/ints/xms.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2002-2003 The DOSBox Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __XMS_H__ +#define __XMS_H__ + +Bitu XMS_QueryFreeMemory (Bit16u& largestFree, Bit16u& totalFree); +Bitu XMS_AllocateMemory (Bitu size, Bit16u& handle); +Bitu XMS_FreeMemory (Bitu handle); +Bitu XMS_MoveMemory (PhysPt bpt); +Bitu XMS_LockMemory (Bitu handle, Bit32u& address); +Bitu XMS_UnlockMemory (Bitu handle); +Bitu XMS_GetHandleInformation(Bitu handle, Bit8u& lockCount, Bit8u& numFree, Bit16u& size); +Bitu XMS_ResizeMemory (Bitu handle, Bitu newSize); + +Bitu XMS_EnableA20 (bool enable); +Bitu XMS_GetEnabledA20 (void); + +#endif \ No newline at end of file diff --git a/visualc/dosbox.dsp b/visualc/dosbox.dsp index a05f882a..58c2e78a 100644 --- a/visualc/dosbox.dsp +++ b/visualc/dosbox.dsp @@ -556,6 +556,10 @@ SOURCE=..\src\ints\mouse.cpp SOURCE=..\src\ints\xms.cpp # End Source File +# Begin Source File + +SOURCE=..\src\ints\xms.h +# End Source File # End Group # Begin Group "misc"