mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 11:51:49 +09:00
working proof-of-concept hypervisor using Parallel
This commit is contained in:
Binary file not shown.
@@ -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")
|
||||
1
assets/disk0/!BOOTSEC_old
Normal file
1
assets/disk0/!BOOTSEC_old
Normal 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")
|
||||
63
assets/disk0/tvdos/hyve.SYS
Normal file
63
assets/disk0/tvdos/hyve.SYS
Normal 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!")
|
||||
@@ -104,6 +104,8 @@ MMIO
|
||||
90 RO: BMS calculated battery percentage where 255 is 100%
|
||||
91 RO: BMS battery voltage multiplied by 10 (127 = "12.7 V")
|
||||
|
||||
92..127 RW: Used by the hypervisor
|
||||
|
||||
1024..2047 RW: Reserved for integrated peripherals (e.g. built-in status display)
|
||||
|
||||
4076..4079 RW: 8-bit status code for the port
|
||||
|
||||
@@ -293,6 +293,7 @@ class Parallel(private val vm: VM) {
|
||||
thread.interrupt()
|
||||
vm.contexts.remove(thread)
|
||||
}
|
||||
fun isRunning(thread: Thread) = thread.isAlive
|
||||
fun getThreadPool() = vm.contexts
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ object VMRunnerFactory {
|
||||
"js" -> {
|
||||
object : VMRunner(extension) {
|
||||
private val ringOneParallel = Parallel(vm)
|
||||
private val ringTwoParallel = ParallelDummy()
|
||||
private val ringTwoParallel = Parallel(vm)//ParallelDummy()
|
||||
|
||||
private val context = Context.newBuilder("js")
|
||||
.allowHostAccess(HostAccess.ALL)
|
||||
|
||||
Reference in New Issue
Block a user