cleaning up

This commit is contained in:
copy 2014-11-01 13:56:06 +01:00
parent 5fd2a1bd35
commit bfd12be557
8 changed files with 30 additions and 22 deletions

View file

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

View file

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

View file

@ -201,7 +201,7 @@ function IDEDevice(cpu, buffer, is_cd, nr)
dbg_log("Read 1F4: " + h(this.cylinder_low & 0xFF), LOG_DISK); dbg_log("Read 1F4: " + h(this.cylinder_low & 0xFF), LOG_DISK);
return this.cylinder_low & 0xFF; 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); dbg_log("Read 1F5: " + h(this.cylinder_high & 0xFF), LOG_DISK);
return this.cylinder_high & 0xFF; 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_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_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_read(this.master_port | 2, this, this.dma_read_status);
cpu.io.register_write(this.master_port | 2, this, this.dma_write_status, undefined); cpu.io.register_write(this.master_port | 2, this, this.dma_write_status);
/** @const */ /** @const */
this._state_skip = [ this._state_skip = [
@ -648,9 +648,9 @@ IDEDevice.prototype.read_status = function()
return ret; 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; this.device_control = data;
if(data & 4) if(data & 4)

View file

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

View file

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

View file

@ -44,6 +44,9 @@ function Memory(buffer, memory_size)
Memory.prototype._state_restore = function() 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.mem8 = new Uint8Array(this.buffer);
this.mem16 = new Uint16Array(this.buffer); this.mem16 = new Uint16Array(this.buffer);
this.mem32s = new Int32Array(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) 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) Memory.prototype.mmap_write16 = function(addr, value)
{ {
this.mmap_write8(addr, value & 0xff); var fn = this.memory_map_write8[addr >>> MMAP_BLOCK_BITS];
this.mmap_write8(addr + 1, value >> 8 & 0xff);
fn(addr, value & 0xFF);
fn(addr + 1, value >> 8 & 0xFF);
}; };
Memory.prototype.mmap_read32 = function(addr) Memory.prototype.mmap_read32 = function(addr)

View file

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

View file

@ -30,7 +30,7 @@ function PIT(cpu)
this.counter_reload = new Uint16Array(3); this.counter_reload = new Uint16Array(3);
this.counter_current = 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; this.counter2_out = 0;