DOSBox-X branch

Here you can discuss the development of patches.

Re: DOSBox-X branch

Postby hail-to-the-ryzen » 2018-3-16 @ 02:09

After opening a plain full screen dos box in Windows 95 OSR2 (640x480 @ 16-bit colors), there is a repeated logging of this line:
PAGING:Recursive PageFault for 46c used=0

It continues until the dos box is closed and prints about every 400,000 cpu cycles. However, it does not occur in a windowed dos box. Haven't yet determined if all S3 Trio 32/64 drivers lead to the same logging, but setting video acceleration to none has no effect with the driver tested.

The log is printed by LOG_MSG, so it requires "log console=true".

I think it is related to the video mode (tested with Quake). Video modes 3, 13, and 100 do not lead to the extensive logging of that page fault, for example, but video mode 101 (640x480) leads to repeated logging of these lines:
PAGING:Recursive PageFault for 46c used=0
ERROR INT10:Unhandled VESA Function 7 Subfunction 0

I think that INT10 error is unrelated to the page fault logging because it is specific to Quake.

At video mode 103 (800x600), the lines logged are much fewer, but the fps are low, too. Is it possible that the logging is specific to a dos box @ 640x480/16?
hail-to-the-ryzen
Member
 
Posts: 249
Joined: 2017-3-09 @ 01:34

Re: DOSBox-X branch

Postby TheGreatCodeholio » 2018-3-16 @ 03:00

The problem with INT 10h in protected mode is that, if INT 10h does anything involving paging, then the page fault handling has to revert to recursive mode because DOSBox-X's BIOS interrupt handling is non-interruptible.
DOSBox-X project: more emulation better accuracy.
DOSLIB and DOSLIB2: Learn how to tinker and hack hardware and software from DOS.
User avatar
TheGreatCodeholio
Oldbie
 
Posts: 578
Joined: 2011-8-18 @ 20:15
Location: Seattle, WA

Re: DOSBox-X branch

Postby TheGreatCodeholio » 2018-3-16 @ 03:03

Also, Quake as I understand it uses a DOS extender (CWSDPMI I think) that uses paging and a swapfile on the hard drive.
DOSBox-X project: more emulation better accuracy.
DOSLIB and DOSLIB2: Learn how to tinker and hack hardware and software from DOS.
User avatar
TheGreatCodeholio
Oldbie
 
Posts: 578
Joined: 2011-8-18 @ 20:15
Location: Seattle, WA

Re: DOSBox-X branch

Postby hail-to-the-ryzen » 2018-3-16 @ 03:26

I understand - thank you for the help.
hail-to-the-ryzen
Member
 
Posts: 249
Joined: 2017-3-09 @ 01:34

Re: DOSBox-X branch

Postby hail-to-the-ryzen » 2018-3-16 @ 06:18

If umb=true, then should xms turn on automatically and a message printed to the log?
hail-to-the-ryzen
Member
 
Posts: 249
Joined: 2017-3-09 @ 01:34

Re: DOSBox-X branch

Postby TheGreatCodeholio » 2018-3-16 @ 08:28

hail-to-the-ryzen wrote:If umb=true, then should xms turn on automatically and a message printed to the log?


If XMS is disabled (as if HIMEM.SYS were not loaded), then there is no driver to provide upper memory blocks, and umb=true doesn't mean anything anymore.
DOSBox-X project: more emulation better accuracy.
DOSLIB and DOSLIB2: Learn how to tinker and hack hardware and software from DOS.
User avatar
TheGreatCodeholio
Oldbie
 
Posts: 578
Joined: 2011-8-18 @ 20:15
Location: Seattle, WA

Re: DOSBox-X branch

Postby hail-to-the-ryzen » 2018-3-16 @ 17:04

Revisited that previous issue about opening a full screen dos box in Windows 95 OSR2. Although my tests were in a modified build, I could reproduce a warning where the pf_queue.used is >0 (independent of the expected occurrence of recursive page faults with pf_queue.used=0). This led to instability in the guest OS desktop. Traced the warning to the function below which clears memory, in this case for vesa mode 3 (monochrome text). The warning is avoided by adding a small delay to the function below or possibly in the upstream function for setting up the vesa mode. Also, this change seems reasonable since there is no configurable delay for this case of real_writew, yet there are configurable delays on the video memory accesses. Requires vmemdelay >0 to work.
Code: Select all
--- int10_modes-orig.cpp
+++ int10_modes.cpp
@@ -521,7 +521,11 @@ static void FinishSetMode(bool clearmem)
          break;
       case M_TEXT: {
          Bit16u seg = (CurMode->mode==7)?0xb000:0xb800;
-         for (Bit16u ct=0;ct<16*1024;ct++) real_writew(seg,ct*2,0x0720);
+         for (Bit16u ct=0;ct<16*1024;ct++) {
+            // LOG_MSG("Delay for clearing the memory");
+            VGAMEM_USEC_write_delay();
+            real_writew(seg,ct*2,0x0720);
+         }
          break;
       }
       case M_EGA:   
--- vga-orig.h
+++ vga.h
@@ -515,6 +515,8 @@ void SVGA_Setup_TsengET3K(void);
 void SVGA_Setup_ParadisePVGA1A(void);
 void SVGA_Setup_Driver(void);
 
+void VGAMEM_USEC_write_delay(void);
+
 // Amount of video memory required for a mode, implemented in int10_modes.cpp
 Bitu VideoModeMemSize(Bitu mode);
hail-to-the-ryzen
Member
 
Posts: 249
Joined: 2017-3-09 @ 01:34

Re: DOSBox-X branch

Postby hail-to-the-ryzen » 2018-3-17 @ 14:04

On further testing, determined the above (46c) page fault warning occurs when that memory is accessed at same time that the (B800) screen memory segment is clearing during the setup of a vesa mode. This was tested with opening a Win95 OSR2 full screen dos box. One workaround is change the original code for clearing screen memory:
Code: Select all
   case M_TEXT: {
         Bit16u seg = (CurMode->mode==7)?0xb000:0xb800;
         for (Bit16u ct=0;ct<16*1024;ct++) real_writew(seg,ct*2,0x0720);
         break;
      }

So that real_writew() is not called. Instead, let memset() clear the memory directly:
Code: Select all
      case M_TEXT:
      case M_EGA: case M_VGA:   case M_LIN8: case M_LIN4: case M_LIN15: case M_LIN16:
      case M_LIN32:
         /* Hack we just access the memory directly */
         memset(vga.mem.linear,0,vga.vmemsize);
         memset(vga.fastmem, 0, vga.vmemsize<<1);
         break;

This is not expected to occur in DOS.
hail-to-the-ryzen
Member
 
Posts: 249
Joined: 2017-3-09 @ 01:34

Re: DOSBox-X branch

Postby hail-to-the-ryzen » 2018-3-18 @ 04:53

The above workaround is not effective in DOS. Instead, the change below fixed the issue and worked effectively during some testing in DOS and Win95 OSR2:
Code: Select all
--- int10_modes-orig.cpp
+++ int10_modes.cpp
@@ -1681,17 +1681,17 @@ dac_text16:
       svga.set_video_mode(crtc_base, &modeData);
    }
 
-   FinishSetMode(clearmem);
-
    /* Set vga attrib register into defined state */
    IO_Read(mono_mode ? 0x3ba : 0x3da);
    IO_Write(0x3c0,0x20);
-   IO_Read(mono_mode ? 0x3ba : 0x3da);
 
    /* Load text mode font */
    if (CurMode->type==M_TEXT) {
       INT10_ReloadFont();
    }
+
+   FinishSetMode(clearmem);
+
    // Enable screen memory access
    IO_Write(0x3c4,1); IO_Write(0x3c5,seq_data[1] & ~0x20);
    //LOG_MSG("setmode end");
hail-to-the-ryzen
Member
 
Posts: 249
Joined: 2017-3-09 @ 01:34

Re: DOSBox-X branch

Postby danrevella » 2018-3-18 @ 16:34

Hi!!
Even on the very last version, the bios support for int 10h 1c02h is still broken.
Any help please?
danrevella
Newbie
 
Posts: 31
Joined: 2009-5-10 @ 13:34

Re: DOSBox-X branch

Postby Shane32 » 2018-3-19 @ 03:47

If an OS tries to read from an invalid c/h/s on a disk, should a failure be returned to the OS? Right now invalid values are silently ignored, converted to 'absolute' sector offsets, and read from the image file.

In my case, I tried to format a 160KB floppy image with DOS 5. For whatever reason, DOS tried to format the floppy as 360KB, which succeeded. Then I copied 360KB of files to it without an error occurring, and without an attempt to write to a position outside of the 160KB image. Obviously there was data overlap and loss, but it was undetected by the OS.

I suggest that either (a) invalid c/h/s values are reported back to the OS as an error, or (b) they are logged (LOG_MSG).

The only scenario I can think to use option B would be if an image was mounted with the wrong c/h/s values, and the OS used the values from the partition to access the drive. (Or if the opposite were true.) Since in general FAT is based on absolute sector offsets, an incorrect c/h/s by the OS would work fine with option B, but fail with option A.

On the other hand, option A should represent a more accurate simulation of an old PC, and should not pose a problem unless the chs values could not be detected properly when mounting the image.
User avatar
Shane32
Newbie
 
Posts: 12
Joined: 2018-1-01 @ 15:28

Re: DOSBox-X branch

Postby TheGreatCodeholio » 2018-3-21 @ 05:43

Haven't gotten around to INT 10h 1C02h yet, but the issue is there in the tracker.

I just finished some scripting to update dosbox-x.com with documentation from the source code using Doxygen, which may a good reference for those that want to work on the source code with me.

http://dosbox-x.com/doxygen/html/index.html
DOSBox-X project: more emulation better accuracy.
DOSLIB and DOSLIB2: Learn how to tinker and hack hardware and software from DOS.
User avatar
TheGreatCodeholio
Oldbie
 
Posts: 578
Joined: 2011-8-18 @ 20:15
Location: Seattle, WA

Re: DOSBox-X branch

Postby TheGreatCodeholio » 2018-3-25 @ 04:14

danrevella wrote:Hi!!
Even on the very last version, the bios support for int 10h 1c02h is still broken.
Any help please?


I just noticed that the INT 10 save function leaves the attribute controller flip-flop in the wrong state, and the restore function leaves the attribute controller with the Palette Address Source (bit 5) clear, which on normal VGA hardware leaves the screen blank.

I just pushed a change to INT 10h AH=1Ch handling that I think should resolve your issue. I don't have any software on hand that uses this BIOS call so I cannot 100% verify this issue is fixed.
DOSBox-X project: more emulation better accuracy.
DOSLIB and DOSLIB2: Learn how to tinker and hack hardware and software from DOS.
User avatar
TheGreatCodeholio
Oldbie
 
Posts: 578
Joined: 2011-8-18 @ 20:15
Location: Seattle, WA

Re: DOSBox-X branch

Postby TheGreatCodeholio » 2018-3-25 @ 07:08

I just incorporated the EGA mode param changes from SVN, and the +2 adjust for vtotal. The refresh rates now match DOSBox SVN for EGA modes.
DOSBox-X project: more emulation better accuracy.
DOSLIB and DOSLIB2: Learn how to tinker and hack hardware and software from DOS.
User avatar
TheGreatCodeholio
Oldbie
 
Posts: 578
Joined: 2011-8-18 @ 20:15
Location: Seattle, WA

Re: DOSBox-X branch

Postby danrevella » 2018-3-25 @ 12:15

Please excuse, maybe anyone is able to supply an extend debugger version compiled?
I have try to compiled by myself, but after many and many try I had to renonce...... I'm not able...
About a program who use int 10h Ah=1c, i remembre and old post with an utility about:
viewtopic.php?t=13820
danrevella
Newbie
 
Posts: 31
Joined: 2009-5-10 @ 13:34

Re: DOSBox-X branch

Postby hail-to-the-ryzen » 2018-4-03 @ 02:10

The dosbox-x parameter dynamic_core_cache_block_size is set at the default value of 32. This works as expected for core=dynamic. However, where setting it to 64, it may lead to a cache block overrun error. This is related to an insufficient total cache size, therefore the increased cache block size must lead to a higher use of the cache. However, where dynamic_core_cache_block_size=64 and the total cache size is increased, then there is a reproducible error for insufficient number of cache blocks (Chessmaster 3000 for DOS).

Included patch below for testing. It naively increases the caching in the dynamic core where the dynamic_core_cache_block_size is set larger than 32.
Code: Select all
diff -rupN dosbox-orig//src/cpu/core_dyn_x86/cache.h dosbox//src/cpu/core_dyn_x86/cache.h
--- dosbox-orig//src/cpu/core_dyn_x86/cache.h
+++ dosbox//src/cpu/core_dyn_x86/cache.h
@@ -483,17 +483,22 @@ static CacheBlock * cache_blocks=NULL;
 
 static bool cache_initialized = false;
 
+extern int dynamic_core_cache_block_size;
+extern int cache_total_adjust;
+
 static void cache_init(bool enable) {
    Bits i;
+   int cache_total_adjust = 1 + ((dynamic_core_cache_block_size - 1) / 32);
+   // LOG_MSG("cache_total_adjust by %i",cache_total_adjust);
    if (enable) {
       if (cache_initialized) return;
       cache_initialized = true;
       if (cache_blocks == NULL) {
-         cache_blocks=(CacheBlock*)malloc(CACHE_BLOCKS*sizeof(CacheBlock));
+         cache_blocks=(CacheBlock*)malloc((CACHE_BLOCKS*cache_total_adjust)*sizeof(CacheBlock));
          if(!cache_blocks) E_Exit("Allocating cache_blocks has failed");
-         memset(cache_blocks,0,sizeof(CacheBlock)*CACHE_BLOCKS);
+         memset(cache_blocks,0,sizeof(CacheBlock)*(CACHE_BLOCKS*cache_total_adjust));
          cache.block.free=&cache_blocks[0];
-         for (i=0;i<CACHE_BLOCKS-1;i++) {
+         for (i=0;i<(CACHE_BLOCKS*cache_total_adjust)-1;i++) {
             cache_blocks[i].link[0].to=(CacheBlock *)1;
             cache_blocks[i].link[1].to=(CacheBlock *)1;
             cache_blocks[i].cache.next=&cache_blocks[i+1];
@@ -501,12 +506,12 @@ static void cache_init(bool enable) {
       }
       if (cache_code_start_ptr==NULL) {
 #if defined (WIN32)
-         cache_code_start_ptr=(Bit8u*)VirtualAlloc(0,CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP,
+         cache_code_start_ptr=(Bit8u*)VirtualAlloc(0,(CACHE_TOTAL*cache_total_adjust)+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP,
             MEM_COMMIT,PAGE_EXECUTE_READWRITE);
          if (!cache_code_start_ptr)
-            cache_code_start_ptr=(Bit8u*)malloc(CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP);
+            cache_code_start_ptr=(Bit8u*)malloc((CACHE_TOTAL*cache_total_adjust)+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP);
 #else
-         cache_code_start_ptr=(Bit8u*)malloc(CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP);
+         cache_code_start_ptr=(Bit8u*)malloc((CACHE_TOTAL*cache_total_adjust)+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP);
 #endif
          if(!cache_code_start_ptr) E_Exit("Allocating dynamic core cache memory failed");
 
@@ -516,14 +521,14 @@ static void cache_init(bool enable) {
          cache_code+=PAGESIZE_TEMP;
 
 #if (C_HAVE_MPROTECT)
-         if(mprotect(cache_code_link_blocks,CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP,PROT_WRITE|PROT_READ|PROT_EXEC))
+         if(mprotect(cache_code_link_blocks,(CACHE_TOTAL*cache_total_adjust)+CACHE_MAXSIZE+PAGESIZE_TEMP,PROT_WRITE|PROT_READ|PROT_EXEC))
             LOG_MSG("Setting excute permission on the code cache has failed!");
 #endif
          CacheBlock * block=cache_getblock();
          cache.block.first=block;
          cache.block.active=block;
          block->cache.start=&cache_code[0];
-         block->cache.size=CACHE_TOTAL;
+         block->cache.size=(CACHE_TOTAL*cache_total_adjust);
          block->cache.next=0;                        //Last block in the list
       }
       /* Setup the default blocks for block linkage returns */
@@ -571,6 +576,8 @@ static void cache_close(void) {
 }
 
 static void cache_reset(void) {
+   int cache_total_adjust = 1 + ((dynamic_core_cache_block_size - 1) / 32);
+   // LOG_MSG("cache_total_adjust by %i",cache_total_adjust);
    if (cache_initialized) {
       for (;;) {
          if (cache.used_pages) {
@@ -583,12 +590,12 @@ static void cache_reset(void) {
       }
 
       if (cache_blocks == NULL) {
-         cache_blocks=(CacheBlock*)malloc(CACHE_BLOCKS*sizeof(CacheBlock));
+         cache_blocks=(CacheBlock*)malloc((CACHE_BLOCKS*cache_total_adjust)*sizeof(CacheBlock));
          if(!cache_blocks) E_Exit("Allocating cache_blocks has failed");
       }
-      memset(cache_blocks,0,sizeof(CacheBlock)*CACHE_BLOCKS);
+      memset(cache_blocks,0,sizeof(CacheBlock)*(CACHE_BLOCKS*cache_total_adjust));
       cache.block.free=&cache_blocks[0];
-      for (Bits i=0;i<CACHE_BLOCKS-1;i++) {
+      for (Bits i=0;i<(CACHE_BLOCKS*cache_total_adjust)-1;i++) {
          cache_blocks[i].link[0].to=(CacheBlock *)1;
          cache_blocks[i].link[1].to=(CacheBlock *)1;
          cache_blocks[i].cache.next=&cache_blocks[i+1];
@@ -596,12 +603,12 @@ static void cache_reset(void) {
 
       if (cache_code_start_ptr==NULL) {
 #if defined (WIN32)
-         cache_code_start_ptr=(Bit8u*)VirtualAlloc(0,CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP,
+         cache_code_start_ptr=(Bit8u*)VirtualAlloc(0,(CACHE_TOTAL*cache_total_adjust)+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP,
             MEM_COMMIT,PAGE_EXECUTE_READWRITE);
          if (!cache_code_start_ptr)
-            cache_code_start_ptr=(Bit8u*)malloc(CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP);
+            cache_code_start_ptr=(Bit8u*)malloc((CACHE_TOTAL*cache_total_adjust)+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP);
 #else
-         cache_code_start_ptr=(Bit8u*)malloc(CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP);
+         cache_code_start_ptr=(Bit8u*)malloc((CACHE_TOTAL*cache_total_adjust)+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP);
 #endif
          if (!cache_code_start_ptr) E_Exit("Allocating dynamic core cache memory failed");
 
@@ -611,7 +618,7 @@ static void cache_reset(void) {
          cache_code+=PAGESIZE_TEMP;
 
 #if (C_HAVE_MPROTECT)
-         if(mprotect(cache_code_link_blocks,CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP,PROT_WRITE|PROT_READ|PROT_EXEC))
+         if(mprotect(cache_code_link_blocks,(CACHE_TOTAL*cache_total_adjust)+CACHE_MAXSIZE+PAGESIZE_TEMP,PROT_WRITE|PROT_READ|PROT_EXEC))
             LOG_MSG("Setting excute permission on the code cache has failed!");
 #endif
       }
@@ -620,7 +627,7 @@ static void cache_reset(void) {
       cache.block.first=block;
       cache.block.active=block;
       block->cache.start=&cache_code[0];
-      block->cache.size=CACHE_TOTAL;
+      block->cache.size=(CACHE_TOTAL*cache_total_adjust);
       block->cache.next=0;                        //Last block in the list
 
       /* Setup the default blocks for block linkage returns */
diff -rupN dosbox-orig//src/cpu/core_dyn_x86.cpp dosbox//src/cpu/core_dyn_x86.cpp
--- dosbox-orig//src/cpu/core_dyn_x86.cpp
+++ dosbox//src/cpu/core_dyn_x86.cpp
@@ -258,6 +258,11 @@ static void dyn_restoreregister(DynReg *
 
 extern int dynamic_core_cache_block_size;
 
+/* Increase CACHE_TOTAL where block_size greater than 32 and by a factor which is rounded to next integer */
+/* dosbox.cpp defines block size as > 0  otherwise edit equation */
+extern int cache_total_adjust;
+int cache_total_adjust = 1;
+
 static bool paging_warning = true;
 
 Bits CPU_Core_Dyn_X86_Run(void) {
hail-to-the-ryzen
Member
 
Posts: 249
Joined: 2017-3-09 @ 01:34

Re: DOSBox-X branch

Postby Marty2dos » 2018-4-06 @ 19:50

Hello,

I asked this in the Game/Apps section.
Snip===
I Wonder. In the Compatibility Page of Dosbox it say it full supportet.I tried many Dosbox Version, down to version 71 and other Forks.
The Vector Grafic is damaged. The one and only where it works is your Dosbox-X Port.

Anyone has a Code Solution? Can you give me hint where did you fix this?

All Ports
Image

Dosbox-X
Image
Marty2dos
Newbie
 
Posts: 32
Joined: 2013-6-04 @ 01:43

Re: DOSBox-X branch

Postby Marty2dos » 2018-4-07 @ 17:49

I think ... i have it found.

viewtopic.php?f=33&t=59409
Marty2dos
Newbie
 
Posts: 32
Joined: 2013-6-04 @ 01:43

Re: DOSBox-X branch

Postby SooperWill99 » 2018-4-13 @ 21:42

I have a question. I know you've repeatedly said that the dynamic core was removed because you couldn't get it right with page fault handling, but will you ever get that problem sorted out and allow the dynamic core to work STABILY with page faulting (i.e. Windows 98), at least in 32-bit? I know you've recently restored the dynamic core, but as you said, it doesn't work with paging because it's incompatible with the current emulation code. So probably no Win98.
The reason why I am asking this is because I am planning on trying to install Windows 98 SE again and am worried that it will run too slow just as the version I tried last summer did (I set the core to normal and it had major performance issues with even some less demanding games as said before, but I tried an earlier version which had the dynamic core from early 2015 and it worked at full speed).
Will you be able to add this sometime in the future? Personally, it seems much more important to me than fixing PC-98 games and such. So will this ever be "fixed", or will I have to use a really old version? Or is there some OTHER way to run Windows 98 SMOOTHLY in the current version without the dynamic core AND without a huge performance dip?
SooperWill99
Newbie
 
Posts: 17
Joined: 2015-1-08 @ 01:49

Re: DOSBox-X branch

Postby hail-to-the-ryzen » 2018-4-17 @ 02:57

In sdl_gui.cpp, scrollock is often spelled as scrolllock and SDLK_SCROLLLOCK.
hail-to-the-ryzen
Member
 
Posts: 249
Joined: 2017-3-09 @ 01:34

PreviousNext

Return to DOSBox Patches

Who is online

Users browsing this forum: No registered users and 1 guest