working proof-of-concept hypervisor using Parallel

This commit is contained in:
minjaesong
2024-09-13 23:22:45 +09:00
parent 8bbc752d87
commit 06ea778972
7 changed files with 69 additions and 2 deletions

View File

@@ -1 +1 @@
let p=_BIOS.FIRST_BOOTABLE_PORT;com.sendMessage(p[0],"DEVRST\x17");com.sendMessage(p[0],'OPENR"tvdos/TVDOS.SYS",'+p[1]);let r=com.getStatusCode(p[0]);if(0==r)if(com.sendMessage(p[0],"READ"),r=com.getStatusCode(p[0]),0==r){let g=com.pullMessage(p[0]);eval(g)}else println("I/O Error");else println("TVDOS.SYS not found");println("Shutting down...");println("It is now safe to turn off the power")
let p=_BIOS.FIRST_BOOTABLE_PORT;com.sendMessage(p[0],"DEVRST\x17");com.sendMessage(p[0],'OPENR"tvdos/hyve.SYS",'+p[1]);let r=com.getStatusCode(p[0]);if(0==r)if(com.sendMessage(p[0],"READ"),r=com.getStatusCode(p[0]),0==r){let g=com.pullMessage(p[0]);eval(g)}else println("I/O Error");else println("TVDOS.SYS not found");println("Shutting down...");println("It is now safe to turn off the power")

View File

@@ -0,0 +1 @@
let p=_BIOS.FIRST_BOOTABLE_PORT;com.sendMessage(p[0],"DEVRST\x17");com.sendMessage(p[0],'OPENR"tvdos/TVDOS.SYS",'+p[1]);let r=com.getStatusCode(p[0]);if(0==r)if(com.sendMessage(p[0],"READ"),r=com.getStatusCode(p[0]),0==r){let g=com.pullMessage(p[0]);eval(g)}else println("I/O Error");else println("TVDOS.SYS not found");println("Shutting down...");println("It is now safe to turn off the power")

View File

@@ -0,0 +1,63 @@
/*
hyve is a hypervisor for tsvm.
## hyve boot sequence
0. bios starts up
1. bootloader calls hyve.js
2. hyve sets up itself, spawns new context which runs TVDOS.SYS
3. hands the control over to the TVDOS until SysRq sequence is struck
*/
let context = parallel.spawnNewContext()
let bios = `
// probe bootable device
var _BIOS = {};
// Syntax: [Port, Drive-number]
// Port #0-3: Serial port 1-4
// #4+ : Left for future extension
// Drive-number always starts at 1
_BIOS.FIRST_BOOTABLE_PORT = [0,1]; // ah screw it
Object.freeze(_BIOS);
///////////////////////////////////////////////////////////////////////////////
// load a bootsector using 'LOADBOOT'
let portNumber = 0;
let driveStatus = 0;
let guestExit = false;
while (portNumber < 4) {
if (com.areYouThere(portNumber)) {
com.sendMessage(portNumber,"DEVRST\x17");
com.sendMessage(portNumber, 'OPENR"tvdos/TVDOS.SYS",'+_BIOS.FIRST_BOOTABLE_PORT[1]);
driveStatus = com.getStatusCode(portNumber);
if (driveStatus == 0) break;
}
portNumber += 1;
}
if (portNumber < 4) {
com.sendMessage(portNumber,"READ");
let r = com.getStatusCode(portNumber);
if (r == 0) {
let g = com.pullMessage(portNumber);
eval(g);
}
else {
println("I/O Error");
}
}
else {
printerrln("No bootable medium found.");
}
`
let runner = parallel.attachProgram("TVDOS", context, bios)
parallel.launch(runner)
while (parallel.isRunning(runner)) {
sys.sleep(1000)
}
println(" LX4 cya!")