Flip virtio<->device relationship and begin upgrade

If multiple devices need its own virtio interface, it's cleaner for
each device to contain its own virtio than for a single virtio to manage
multiple devices.

Replaced original virtio v0.9 header in BAR0 with several virtio v1.0
PCI capabilities.

Began abstracting virtqueues.
This commit is contained in:
Ernest Wong 2018-05-19 10:37:01 +12:00 committed by Fabian
parent 2a869e24c2
commit 49221d015f
3 changed files with 1123 additions and 147 deletions

View file

@ -51,14 +51,52 @@ var FID_XATTR = 2;
* @constructor
*
* @param {FS} filesystem
* @param {CPU} cpu
*/
function Virtio9p(filesystem, bus) {
function Virtio9p(filesystem, cpu, bus) {
/** @type {FS} */
this.fs = filesystem;
/** @const @type {BusConnector} */
this.bus = bus;
// new virtio interface:
this.virtIO = new VirtIO(cpu,
{
name: "virtio-9p",
pci_id: 0x06 << 3,
device_id: 0x1049,
subsystem_device_id: 9,
common:
{
initial_port: 0xA800,
queues:
[
{
size: 32,
notify_off: 0,
}
],
features:
[
],
},
notification:
{
initial_port: 0xA900,
share_handler: false,
handlers:
[
//on_notify.bind(this),
],
},
isr_status:
{
initial_port: 0xA700,
},
});
// old virtio interface:
this.SendReply = function(x, y) {};
this.deviceid = 0x9; // 9p filesystem
this.hostfeature = 0x1; // mountpoint

View file

@ -796,7 +796,7 @@ CPU.prototype.init = function(settings, device_bus)
if(settings.fs9p)
{
this.devices.virtio = new VirtIO(this, device_bus, settings.fs9p);
this.devices.virtio_9p = new Virtio9p(settings.fs9p, this, device_bus);
}
}

File diff suppressed because it is too large Load diff