Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Disk Acccsss #136

Open
RossComputerGuy opened this issue Dec 10, 2016 · 7 comments
Open

Disk Acccsss #136

RossComputerGuy opened this issue Dec 10, 2016 · 7 comments

Comments

@RossComputerGuy
Copy link

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
Copy link
Contributor

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
Copy link
Author

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
Copy link

piranna commented Dec 11, 2016

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

@iefserge
Copy link
Member

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
Copy link
Author

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
Copy link
Contributor

facekapow commented Dec 11, 2016

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
Copy link

piranna commented Dec 11, 2016

@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 ;-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants