winedos: fix himem

Markus Amsler markus.amsler at oribi.org
Sat Sep 18 10:42:04 CDT 2004


With this patch I'm able to start win16 apps, with dos area not in the 
first megabyte.

Changelog:
* Respect kernel exported UMB start address.
-------------- next part --------------
Index: dlls/winedos/himem.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/himem.c,v
retrieving revision 1.7
diff -u -r1.7 himem.c
--- dlls/winedos/himem.c	18 Nov 2003 00:06:15 -0000	1.7
+++ dlls/winedos/himem.c	18 Sep 2004 14:43:00 -0000
@@ -21,6 +21,8 @@
 #include "dosexe.h"
 #include "wine/debug.h"
 
+#include "wine/winbase16.h"
+
 WINE_DEFAULT_DEBUG_CHANNEL(dosmem);
 
 /*
@@ -31,7 +33,7 @@
  *   b8000 - bffff : VGA text             (vga.c)
  *   c0000 - cffff : EMS frame            (int67.c)
  *   d0000 - effff : Free memory for UMBs (himem.c)
- *   f0000 - fffff : BIOS stuff           (msdos/dosmem.c)
+ *   f0000 - fffff : BIOS stuff           (kernel/dosmem.c)
  *  100000 -10ffff : High memory area     (unused)
  */
 
@@ -44,13 +46,13 @@
 /*
  * First and last address available for upper memory blocks.
  */
-#define DOSVM_UMB_BOTTOM 0xd0000
-#define DOSVM_UMB_TOP    0xeffff
+static DWORD DOSVM_umb_bottom = 0;
+static DWORD DOSVM_umb_top = 0;
 
 /*
  * First free address for upper memory blocks.
  */
-static DWORD DOSVM_umb_free = DOSVM_UMB_BOTTOM;
+static DWORD DOSVM_umb_free = 0;
 
 
 /***********************************************************************
@@ -72,7 +74,7 @@
   
   size = ((size + 15) >> 4) << 4;
   
-  if(DOSVM_umb_free + size - 1 > DOSVM_UMB_TOP) {
+  if(DOSVM_umb_free + size - 1 > DOSVM_umb_top) {
     ERR("Out of upper memory area.\n");
     return 0;
   }
@@ -156,6 +158,8 @@
  */
 void DOSVM_InitSegments( void )
 {
+    LDT_ENTRY entry;
+    FARPROC16 proc;
     LPSTR ptr;
     int   i;
 
@@ -210,6 +214,17 @@
         0xfb, 0x66, 0xcb  /* sti and 32-bit far return */
     };
 
+    /*
+     * Get kernel exported UMB base address.
+     */
+    proc = GetProcAddress16( GetModuleHandle16( "KERNEL" ), 
+                             (LPCSTR)(ULONG_PTR)179 );  /* KERNEL.179: __D000H */
+    wine_ldt_get_entry( LOWORD(proc), &entry );
+    DOSVM_umb_bottom = (DWORD) wine_ldt_get_base( &entry );
+
+    DOSVM_umb_top = DOSVM_umb_bottom + 0x1ffff;
+    DOSVM_umb_free = DOSVM_umb_bottom;
+    
     /*
      * Allocate pointer array.
      */


More information about the wine-patches mailing list