Preparations for new interface

This commit is contained in:
copy 2014-01-05 03:19:09 +01:00
commit 0a59180db4
4 changed files with 58 additions and 16 deletions

View file

@ -1,7 +1,7 @@
"use strict";
/** @constructor */
function FloppyController(dev, floppy_image)
function FloppyController(dev, fda_image, fdb_image)
{
var
io = dev.io,
@ -22,15 +22,15 @@ function FloppyController(dev, floppy_image)
/** @const */
byte_per_sector = 512;
this.buffer = floppy_image;
this.buffer = fda_image;
if(!floppy_image)
if(!fda_image)
{
this.type = 0;
return;
}
floppy_size = floppy_image.byteLength;
floppy_size = fda_image.byteLength;
var floppy_types = {
160 : { type: 1, tracks: 40, sectors: 8 , heads: 1 },
@ -61,7 +61,7 @@ function FloppyController(dev, floppy_image)
}
else
{
throw unimpl("Unknown floppy size: " + h(floppy_image.byteLength));
throw unimpl("Unknown floppy size: " + h(fda_image.byteLength));
}
var status_reg0 = 0,
@ -303,11 +303,11 @@ function FloppyController(dev, floppy_image)
if(is_write)
{
dma.do_write(floppy_image, read_offset, read_count * sector_size, 2, done);
dma.do_write(fda_image, read_offset, read_count * sector_size, 2, done);
}
else
{
dma.do_read(floppy_image, read_offset, read_count * sector_size, 2, done);
dma.do_read(fda_image, read_offset, read_count * sector_size, 2, done);
}
function done(error)

View file

@ -58,6 +58,13 @@ function IDEDevice(dev, buffer, is_cd, nr)
dbg_assert(this.cylinder_count === (this.cylinder_count | 0));
this.stats = {
sectors_read: 0,
sectors_written: 0,
bytes_read: 0,
bytes_written: 0,
};
function push_irq()
{
if((device_control & 2) === 0)
@ -261,6 +268,9 @@ function IDEDevice(dev, buffer, is_cd, nr)
{
push_irq();
});
me.stats.sectors_written += data_port_buffer.length / me.sector_size | 0;
me.stats.bytes_written += data_port_buffer.length;
}
var next_status = -1;
@ -368,6 +378,9 @@ function IDEDevice(dev, buffer, is_cd, nr)
data_pointer = 0;
push_irq();
me.stats.sectors_read += byte_count / me.sector_size | 0;
me.stats.bytes_read += byte_count;
});
}
}
@ -429,6 +442,9 @@ function IDEDevice(dev, buffer, is_cd, nr)
dma_status |= 4;
push_irq();
me.stats.sectors_read += byte_count / me.sector_size | 0;
me.stats.bytes_read += byte_count;
});
}
}
@ -829,6 +845,9 @@ function IDEDevice(dev, buffer, is_cd, nr)
data_pointer = 0;
push_irq();
me.stats.sectors_read += byte_count / me.sector_size | 0;
me.stats.bytes_read += byte_count;
});
}
}
@ -889,6 +908,9 @@ function IDEDevice(dev, buffer, is_cd, nr)
dma_status |= 4;
push_irq();
me.stats.sectors_read += byte_count / me.sector_size | 0;
me.stats.bytes_read += byte_count;
});
}
@ -1018,6 +1040,9 @@ function IDEDevice(dev, buffer, is_cd, nr)
dma_status &= ~2 & ~1;
dma_status |= 4;
}
me.stats.sectors_written += byte_count / me.sector_size | 0;
me.stats.bytes_written += byte_count;
}
function get_lba28()

View file

@ -4,18 +4,18 @@
*
* @constructor
*/
function UART(dev)
function UART(dev, adapter)
{
var
io = dev.io,
var io = dev.io,
line = "";
io.register_write(0x3F8, function(out_byte)
{
if(out_byte === 0x0A)
{
log(line);
adapter.send_line(line);
dbg_log(line, LOG_SERIAL);
line = "";
}
else

View file

@ -17,10 +17,10 @@ function VGAScreen(dev, adapter, vga_memory_size)
VGA_BANK_SIZE = 64 * 1024,
/** @const */
MAX_XRES = 1280,
MAX_XRES = 1920,
/** @const */
MAX_YRES = 1024,
MAX_YRES = 1080,
/** @const */
MAX_BPP = 32,
@ -127,6 +127,12 @@ function VGAScreen(dev, adapter, vga_memory_size)
dev.pci.register_device(this);
this.stats = {
is_graphical: false,
res_x: 0,
res_y: 0,
bpp: 0,
};
function init()
{
@ -598,21 +604,18 @@ function VGAScreen(dev, adapter, vga_memory_size)
this.set_size_text(80, 25);
break;
case 0x10:
this.set_size_graphical(640, 350);
screen_width = 640;
screen_height = 350;
is_graphical = true;
graphical_mode_is_linear = false;
break;
case 0x12:
this.set_size_graphical(640, 480);
screen_width = 640;
screen_height = 480;
is_graphical = true;
graphical_mode_is_linear = false;
break;
case 0x13:
this.set_size_graphical(320, 200);
screen_width = 320;
screen_height = 200;
is_graphical = true;
@ -622,6 +625,15 @@ function VGAScreen(dev, adapter, vga_memory_size)
}
adapter.set_mode(is_graphical);
this.stats.is_graphical = is_graphical;
if(is_graphical)
{
this.set_size_graphical(screen_width, screen_height);
this.stats.res_x = screen_width;
this.stats.res_y = screen_height;
this.stats.bpp = 8;
}
graphical_mode = is_graphical;
@ -1038,6 +1050,11 @@ function VGAScreen(dev, adapter, vga_memory_size)
{
screen.set_size_graphical(svga_width, svga_height);
adapter.set_mode(true);
screen.stats.bpp = svga_bpp;
screen.stats.is_graphical = true;
screen.stats.res_x = svga_width;
screen.stats.res_y = svga_height;
}
}
io.register_write(0x1D0, port1D0_write);