Browse Source

cleaning up

copy 9 years ago
parent
commit
bfd12be557
8 changed files with 30 additions and 22 deletions
  1. 0 1
      src/browser/network.js
  2. 2 2
      src/debug.macro.js
  3. 5 5
      src/ide.js
  4. 4 4
      src/instructions.macro.js
  5. 6 6
      src/io.js
  6. 10 3
      src/memory.js
  7. 2 0
      src/pic.js
  8. 1 1
      src/pit.js

+ 0 - 1
src/browser/network.js

@@ -23,7 +23,6 @@ function NetworkAdapter(url)
 
 NetworkAdapter.prototype.handle_message = function(e)
 {
-    //console.log("onmessage", e);
     this.send_data(new Uint8Array(e.data));
 };
 

+ 2 - 2
src/debug.macro.js

@@ -45,8 +45,8 @@
             // write seabios debug output to console
             var seabios_debug = "";
 
-            cpu.io.register_write(0x402, handle); // seabios
-            cpu.io.register_write(0x500, handle); // vgabios
+            cpu.io.register_write(0x402, this, handle); // seabios
+            cpu.io.register_write(0x500, this, handle); // vgabios
         }
 
         function handle(out_byte)

+ 5 - 5
src/ide.js

@@ -201,7 +201,7 @@ function IDEDevice(cpu, buffer, is_cd, nr)
         dbg_log("Read 1F4: " + h(this.cylinder_low & 0xFF), LOG_DISK);
         return this.cylinder_low & 0xFF;
     });
-    cpu.io.register_read(this.ata_port | 5, this, function(port)
+    cpu.io.register_read(this.ata_port | 5, this, function()
     {
         dbg_log("Read 1F5: " + h(this.cylinder_high & 0xFF), LOG_DISK);
         return this.cylinder_high & 0xFF;
@@ -263,8 +263,8 @@ function IDEDevice(cpu, buffer, is_cd, nr)
     cpu.io.register_read(this.master_port, this, this.dma_read_command8, undefined, this.dma_read_command);
     cpu.io.register_write(this.master_port, this, undefined, undefined, this.dma_write_command);
 
-    cpu.io.register_read(this.master_port | 2, this, this.dma_read_status, undefined, undefined);
-    cpu.io.register_write(this.master_port | 2, this, this.dma_write_status, undefined);
+    cpu.io.register_read(this.master_port | 2, this, this.dma_read_status);
+    cpu.io.register_write(this.master_port | 2, this, this.dma_write_status);
 
     /** @const */
     this._state_skip = [
@@ -648,9 +648,9 @@ IDEDevice.prototype.read_status = function()
     return ret;
 };
 
-IDEDevice.prototype.write_control = function(data, port)
+IDEDevice.prototype.write_control = function(data)
 {
-    dbg_log("device control: " + h(data) + " port=" + h(port), LOG_DISK);
+    dbg_log("device control: " + h(data), LOG_DISK);
     this.device_control = data;
 
     if(data & 4)

+ 4 - 4
src/instructions.macro.js

@@ -2024,8 +2024,8 @@ op(0x34, {
         cpu.trigger_gp(0);
     }
 
-    dbg_log("sysenter  cs:eip=" + h(seg    , 4) + ":" + h(cpu.sysenter_eip >>> 0, 8) + 
-                     " ss:esp=" + h(seg + 8, 4) + ":" + h(cpu.sysenter_esp >>> 0, 8), LOG_CPU);
+    //dbg_log("sysenter  cs:eip=" + h(seg    , 4) + ":" + h(cpu.sysenter_eip >>> 0, 8) + 
+    //                 " ss:esp=" + h(seg + 8, 4) + ":" + h(cpu.sysenter_esp >>> 0, 8), LOG_CPU);
 
     cpu.flags &= ~flag_vm & ~flag_interrupt;
 
@@ -2063,8 +2063,8 @@ op(0x35, {
         cpu.trigger_gp(0);
     }
 
-    dbg_log("sysenter  cs:eip=" + h(seg + 16, 4) + ":" + h(cpu.reg32s[reg_edx] >>> 0, 8) + 
-                     " ss:esp=" + h(seg + 24, 4) + ":" + h(cpu.reg32s[reg_ecx] >>> 0, 8), LOG_CPU);
+    //dbg_log("sysexit  cs:eip=" + h(seg + 16, 4) + ":" + h(cpu.reg32s[reg_edx] >>> 0, 8) + 
+    //                 " ss:esp=" + h(seg + 24, 4) + ":" + h(cpu.reg32s[reg_ecx] >>> 0, 8), LOG_CPU);
 
     cpu.instruction_pointer = cpu.reg32s[reg_edx];
     cpu.reg32s[reg_esp] = cpu.reg32s[reg_ecx];

+ 6 - 6
src/io.js

@@ -145,9 +145,9 @@ function IO(memory)
             if(!r32) r32 = fail.bind(this, 32);
         }
 
-        this.ports[port_addr].read8 = r8;
-        this.ports[port_addr].read16 = r16;
-        this.ports[port_addr].read32 = r32;
+        if(r8) this.ports[port_addr].read8 = r8;
+        if(r16) this.ports[port_addr].read16 = r16;
+        if(r32) this.ports[port_addr].read32 = r32;
         this.ports[port_addr].device = device;
     };
 
@@ -177,9 +177,9 @@ function IO(memory)
             if(!w32) w32 = fail.bind(this, 32);
         }
 
-        this.ports[port_addr].write8 = w8;
-        this.ports[port_addr].write16 = w16;
-        this.ports[port_addr].write32 = w32;
+        if(w8) this.ports[port_addr].write8 = w8;
+        if(w16) this.ports[port_addr].write16 = w16;
+        if(w32) this.ports[port_addr].write32 = w32;
         this.ports[port_addr].device = device;
     };
 

+ 10 - 3
src/memory.js

@@ -44,6 +44,9 @@ function Memory(buffer, memory_size)
 
 Memory.prototype._state_restore = function()
 {
+    //this.mem8 = new Uint8Array(this.mem32s.buffer, this.mem32s.byteOffset, this.mem32s.byteLength);
+    //this.mem16 = new Uint16Array(this.mem32s.buffer, this.mem32s.byteOffset, this.mem32s.byteLength >> 1);
+    
     this.mem8 = new Uint8Array(this.buffer);
     this.mem16 = new Uint16Array(this.buffer);
     this.mem32s = new Int32Array(this.buffer);
@@ -86,13 +89,17 @@ Memory.prototype.mmap_write8 = function(addr, value)
 
 Memory.prototype.mmap_read16 = function(addr)
 {
-    return this.mmap_read8(addr) | this.mmap_read8(addr + 1) << 8;
+    var fn = this.memory_map_read8[addr >>> MMAP_BLOCK_BITS];
+
+    return fn(addr) | fn(addr + 1) << 8;
 };
 
 Memory.prototype.mmap_write16 = function(addr, value)
 {
-    this.mmap_write8(addr, value & 0xff);
-    this.mmap_write8(addr + 1, value >> 8 & 0xff);
+    var fn = this.memory_map_write8[addr >>> MMAP_BLOCK_BITS];
+
+    fn(addr, value & 0xFF);
+    fn(addr + 1, value >> 8 & 0xFF);
 };
 
 Memory.prototype.mmap_read32 = function(addr)

+ 2 - 0
src/pic.js

@@ -66,6 +66,7 @@ function PIC(cpu, master)
                 return false;
             }
 
+            dbg_assert(irq !== 0);
             var irq_number = int_log2_table[irq];
             irq = 1 << irq_number;
 
@@ -113,6 +114,7 @@ function PIC(cpu, master)
                 return false;
             }
 
+            dbg_assert(irq !== 0);
             var irq_number = int_log2_table[irq];
             irq = 1 << irq_number;
 

+ 1 - 1
src/pit.js

@@ -30,7 +30,7 @@ function PIT(cpu)
     this.counter_reload = new Uint16Array(3);
     this.counter_current = new Uint16Array(3);
 
-        // only counter2 output can be read
+    // only counter2 output can be read
     this.counter2_out = 0;