diff --git a/src/browser/network.js b/src/browser/network.js index cbaa74f5..3b4c8592 100644 --- a/src/browser/network.js +++ b/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)); }; diff --git a/src/debug.macro.js b/src/debug.macro.js index cbb2d9cc..140dd718 100644 --- a/src/debug.macro.js +++ b/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) diff --git a/src/ide.js b/src/ide.js index 7064de3d..f4b8b68b 100644 --- a/src/ide.js +++ b/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) diff --git a/src/instructions.macro.js b/src/instructions.macro.js index 177e54c1..17bbb5ca 100644 --- a/src/instructions.macro.js +++ b/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]; diff --git a/src/io.js b/src/io.js index c824952f..1758c977 100644 --- a/src/io.js +++ b/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; }; diff --git a/src/memory.js b/src/memory.js index 4dd57c3d..299c642c 100644 --- a/src/memory.js +++ b/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) diff --git a/src/pic.js b/src/pic.js index 0e4c2487..b250c53a 100644 --- a/src/pic.js +++ b/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; diff --git a/src/pit.js b/src/pit.js index c3f0a07b..607d690c 100644 --- a/src/pit.js +++ b/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;