Open RossComputerGuy opened 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)
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
Hard disks are not needed to run on bare metal, an in-memory initram could be used instead.
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.
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;
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.
@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 ;-)
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