runtimejs / runtime

[not maintained] Lightweight JavaScript library operating system for the cloud
http://runtimejs.org
Apache License 2.0
1.93k stars 127 forks source link

Disk Acccsss #136

Open RossComputerGuy opened 7 years ago

RossComputerGuy commented 7 years ago

Hey, I found a tutorial in c on how to access ide devices. It uses the pci controller to access the drives. Can someone please port over the code? Tutorial: http://wiki.osdev.org/PCI_IDE_Controller

facekapow commented 7 years ago

Disk access via virtio is already included in the latest master (but not the latest build yet), do you specifically need it via PCI?

If the answer to that is yes, it seems to me like you're trying to use runtime.js on bare metal, which runtime is a long way from.

(btw, it'd help if you could provide info as to why you need it, per the issue guidelines)

RossComputerGuy commented 7 years ago

if you look at the website, you can find other ways to access the hard drives. I've tried to use virtio but its difficult to access the contents

piranna commented 7 years ago

Hard disks are not needed to run on bare metal, an in-memory initram could be used instead.

iefserge commented 7 years ago

Primary runtime.js target platform is KVM, implementing bare metal drivers would be extremely time consuming for a very little benefit IMO. Virtio should be faster and supported on any hardware that runs KVM.

RossComputerGuy commented 7 years ago

Will my ext2 driver work for reading the superblock. Code:

const runtime = require("runtimejs");

var dev = runtime.block.buses.virtio;
var format = dev.formatInfo;

function Val(buffer,start,end) {
    var val = "";
    for(var i = start;i < (end+1);i++) {
        val += buffer[i].toString();
    }
    return val;
}

function Superblock() {
    var buff = new Uint8Array(format.sectorSize);
    var sector = 1024 / format.sectorSize;
    dev.read(sector,buffer);

    this.TOTAL_INODES = parseInt(Val(buff,0,3));
    this.TOTAL_BLOCKS = parseInt(Val(buff,4,7));
    this.BLOCKS_FOR_SU = parseInt(Val(buff,8,11));
}

module.exports = Superblock;
facekapow commented 7 years ago

I don't about whether it'll read, but you have an error for the dev variable initializer. Add a [0] to the end of runtime.block.buses.virtio, then try it. From a quick scan, it looks like it should work with the little change.

piranna commented 7 years ago

@SpaceboyRoss01, if you are willing to create a Ext2 filesystem in Javascript, I recommend you to take a look to the fatfs npm module source code about how it uses a "block device object" to access to the underlying block device in a transparent and portable way. Also, take in account a filesystem is a somewhat complex software, but with the correct documentation you'll learn a lot ;-)