DOS / Give DOS apps 638k conventional memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now that all unnecessary allocations of conventional memory have
been removed, this small patch is enough to give DOS applications
638k of free conventional memory. This should be enough for
even the most demanding DOS applications.



Changelog:
  Give DOS applications 638k of free conventional memory.



Index: msdos/dosmem.c
===================================================================
RCS file: /home/wine/wine/msdos/dosmem.c,v
retrieving revision 1.47
diff -u -r1.47 dosmem.c
--- msdos/dosmem.c	10 Dec 2002 19:58:39 -0000	1.47
+++ msdos/dosmem.c	11 Dec 2002 18:50:59 -0000
@@ -85,6 +85,11 @@
  * and only relocated to NULL when absolutely necessary */
 static char *DOSMEM_sysmem;
 
+/* Start of DOS conventional memory */
+static char *DOSMEM_membase;
+
+static void DOSMEM_InitMemory(void);
+
 /***********************************************************************
  *           DOSMEM_MemoryTop
  *
@@ -102,7 +107,36 @@
  */
 static dosmem_info *DOSMEM_InfoBlock(void)
 {
-    return (dosmem_info*)(DOSMEM_dosmem+0x10000); /* 64K */
+    if (!DOSMEM_membase)
+    {
+        DWORD         reserve;
+
+        /*
+         * Reserve either:
+         * - lowest 64k for NULL pointer catching (Win16)
+         * - lowest 1k for interrupt handlers and 
+         *   another 0.5k for BIOS, DOS and intra-application
+         *   areas (DOS)
+         */
+        if (DOSMEM_dosmem != DOSMEM_sysmem)
+            reserve = 0x10000; /* 64k */
+        else
+            reserve = 0x600; /* 1.5k */
+
+        /*
+         * Round to paragraph boundary in order to make 
+         * sure the alignment is correct.
+         */
+        reserve = ((reserve + 15) >> 4) << 4;
+
+        /*
+         * Set DOS memory base and initialize conventional memory.
+         */
+        DOSMEM_membase = DOSMEM_dosmem + reserve;
+        DOSMEM_InitMemory();
+    }
+
+    return (dosmem_info*)DOSMEM_membase;
 }
 
 /***********************************************************************
@@ -311,9 +345,6 @@
  */
 static void DOSMEM_InitMemory(void)
 {
-   /* Low 64Kb are reserved for DOS/BIOS so the useable area starts at
-    * 1000:0000 and ends at 9FFF:FFEF. */
-
     dosmem_info*        info_block = DOSMEM_InfoBlock();
     dosmem_entry*       root_block = DOSMEM_RootBlock();
     dosmem_entry*       dm;
@@ -330,8 +361,12 @@
 		     | DM_BLOCK_DEBUG
 #endif
 		     ;
+
+    TRACE( "DOS conventional memory initialized, %d bytes free.\n", 
+           DOSMEM_Available() );
 }
 
+
 /**********************************************************************
  *		setup_dos_mem
  *
@@ -403,7 +438,6 @@
                                                0x10000, 0, WINE_LDT_FLAGS_DATA );
         DOSMEM_FillBiosSegments();
         DOSMEM_FillIsrTable();
-        DOSMEM_InitMemory();
         already_done = 1;
     }
     else if (dos_init && !already_mapped)



-- 
Jukka Heinonen <http://www.iki.fi/jhei/>


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux