Pārlūkot izejas kodu

fix large vga memory (#960)

Fabian 11 mēneši atpakaļ
vecāks
revīzija
faa10d4909
2 mainītis faili ar 12 papildinājumiem un 1 dzēšanām
  1. 1 1
      src/rust/cpu/memory.rs
  2. 11 0
      src/vga.js

+ 1 - 1
src/rust/cpu/memory.rs

@@ -71,7 +71,7 @@ pub fn in_mapped_range(addr: u32) -> bool {
 
 pub const VGA_LFB_ADDRESS: u32 = 0xE0000000;
 pub fn in_svga_lfb(addr: u32) -> bool {
-    addr >= VGA_LFB_ADDRESS && addr < unsafe { VGA_LFB_ADDRESS + vga_memory_size }
+    addr >= VGA_LFB_ADDRESS && addr <= unsafe { VGA_LFB_ADDRESS + (vga_memory_size - 1) }
 }
 
 #[no_mangle]

+ 11 - 0
src/vga.js

@@ -31,6 +31,12 @@ var VGA_PIXEL_BUFFER_SIZE = 8 * VGA_BANK_SIZE;
 /** @const */
 var VGA_MIN_MEMORY_SIZE = 4 * VGA_BANK_SIZE;
 
+/**
+ * Avoid wrapping past VGA_LFB_ADDRESS
+ * @const
+ */
+var VGA_MAX_MEMORY_SIZE = 256 * 1024 * 1024;
+
 /**
  * @const
  * @see {@link http://www.osdever.net/FreeVGA/vga/graphreg.htm#06}
@@ -354,6 +360,11 @@ function VGAScreen(cpu, bus, vga_memory_size)
         this.vga_memory_size = VGA_MIN_MEMORY_SIZE;
         dbg_log("vga memory size rounded up to " + this.vga_memory_size, LOG_VGA);
     }
+    else if(this.vga_memory_size > VGA_MAX_MEMORY_SIZE)
+    {
+        this.vga_memory_size = VGA_MAX_MEMORY_SIZE;
+        dbg_log("vga memory size rounded down to " + this.vga_memory_size, LOG_VGA);
+    }
     else if(this.vga_memory_size & (VGA_BANK_SIZE - 1))
     {
         // round up to next 64k