mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-10 06:54:04 +09:00
making bootloader to load the dos kernel to run a shell
This commit is contained in:
1
assets/!BOOTSEC
Normal file
1
assets/!BOOTSEC
Normal file
@@ -0,0 +1 @@
|
|||||||
|
let p=_BIOS.FIRST_BOOTABLE_PORT;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([0]),0==r){let g=com.pullMessage(p[0]);eval(g)}else println("I/O Error");else println("TVDOS.SYS not found");
|
||||||
@@ -82,4 +82,5 @@ Object.freeze(_BIOS);
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// TODO load a bootsector using 'LOADBOOT'
|
||||||
con.move(4,1);
|
con.move(4,1);
|
||||||
17
assets/bootsec_source.js
Normal file
17
assets/bootsec_source.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// load TVDOS.SYS
|
||||||
|
let p = _BIOS.FIRST_BOOTABLE_PORT;
|
||||||
|
com.sendMessage(p[0], 'OPENR"tvdos/TVDOS.SYS",'+p[1]);
|
||||||
|
let r = com.getStatusCode(p[0]);
|
||||||
|
if (r == 0){
|
||||||
|
com.sendMessage(p[0], "READ");
|
||||||
|
r = com.getStatusCode([0]);
|
||||||
|
if (r == 0) {
|
||||||
|
let g=com.pullMessage(p[0]);
|
||||||
|
eval(g);
|
||||||
|
0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
println("I/O Error");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
println("TVDOS.SYS not found");
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
// Boot script
|
// define TVDOS
|
||||||
var _TVDOS = {};
|
var _TVDOS = {};
|
||||||
_TVDOS.VERSION = "1.0";
|
_TVDOS.VERSION = "1.0";
|
||||||
_TVDOS.DRIVES = {}; // Object where key-value pair is <drive-letter> : [serial-port, drive-number]
|
_TVDOS.DRIVES = {}; // Object where key-value pair is <drive-letter> : [serial-port, drive-number]
|
||||||
// actually figure out the drive letter association
|
// actually figure out the drive letter association
|
||||||
// Drive A is always the device we're currently on
|
// Drive A is always the device we're currently on
|
||||||
_TVDOS.DRIVES["A"] = _BIOS.FIRST_BOOTABLE_PORT;
|
_TVDOS.DRIVES["A"] = _BIOS.FIRST_BOOTABLE_PORT;
|
||||||
|
//TODO
|
||||||
|
|
||||||
|
|
||||||
Object.freeze(_TVDOS);
|
Object.freeze(_TVDOS);
|
||||||
@@ -54,3 +54,15 @@ filesystem.readAll = function(driveLetter) {
|
|||||||
return com.pullMessage(port[0]);
|
return com.pullMessage(port[0]);
|
||||||
};
|
};
|
||||||
Object.freeze(filesystem);
|
Object.freeze(filesystem);
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// install other stuffs
|
||||||
|
filesystem.open("A", "tvdos/gl.js", "R");
|
||||||
|
var GL = eval(filesystem.readAll("A"));
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Boot script
|
||||||
|
filesystem.open("A", "tvdos/command.js", "R");
|
||||||
|
eval(filesystem.readAll("A"));
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ const welcome_text = "TSVM Disk Operating System, version " + _TVDOS.VERSION;
|
|||||||
function print_prompt_text() {
|
function print_prompt_text() {
|
||||||
// oh-my-zsh-like prompt
|
// oh-my-zsh-like prompt
|
||||||
con.color_pair(239,161);
|
con.color_pair(239,161);
|
||||||
print(" "+CURRENT_DRIVE);
|
print(" "+CURRENT_DRIVE+":");
|
||||||
con.color_pair(161,253);
|
con.color_pair(161,253);
|
||||||
con.addch(16);
|
con.addch(16);
|
||||||
con.color_pair(0,253);
|
con.color_pair(0,253);
|
||||||
print("\\"+shell_pwd.join("\\"));
|
print(" \\"+shell_pwd.join("\\")+" ");
|
||||||
con.color_pair(253,255);
|
con.color_pair(253,255);
|
||||||
con.addch(16);
|
con.addch(16);
|
||||||
con.addch(32);
|
con.addch(32);
|
||||||
|
|||||||
@@ -101,4 +101,4 @@ GL.drawSpriteOver = function(sheet, xi, yi, x, y) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.freeze(GL);
|
Object.freeze(GL); // this returns frozen 'GL'
|
||||||
|
|||||||
@@ -60,30 +60,22 @@ class VMGUI(val appConfig: LwjglApplicationConfiguration) : ApplicationAdapter()
|
|||||||
val bios = fr1.readText()
|
val bios = fr1.readText()
|
||||||
fr1.close()
|
fr1.close()
|
||||||
|
|
||||||
|
|
||||||
val fr2 = FileReader("./assets/tvdos/gl.js")
|
|
||||||
val tvgl = fr2.readText()
|
|
||||||
fr2.close()
|
|
||||||
|
|
||||||
val fr3 = FileReader("./assets/tvdos/TVDOS.SYS")
|
|
||||||
val tvknl = fr3.readText()
|
|
||||||
fr3.close()
|
|
||||||
|
|
||||||
|
|
||||||
//val fr = FileReader("./assets/tvdos/command.js")
|
//val fr = FileReader("./assets/tvdos/command.js")
|
||||||
//val fr = FileReader("./assets/zippytest.js")
|
//val fr = FileReader("./assets/zippytest.js")
|
||||||
//val fr = FileReader("./assets/serialtest.js")
|
//val fr = FileReader("./assets/serialtest.js")
|
||||||
//val fr = FileReader("./assets/tvdos/fsh.js")
|
//val fr = FileReader("./assets/tvdos/fsh.js")
|
||||||
val fr = FileReader("./assets/tvdos/flsh.js")
|
//val fr = FileReader("./assets/tvdos/flsh.js")
|
||||||
//val fr = FileReader("./assets/tbas/basic.js")
|
//val fr = FileReader("./assets/tbas/basic.js")
|
||||||
//val fr = FileReader("./assets/jscon.js")
|
//val fr = FileReader("./assets/jscon.js")
|
||||||
|
val fr = FileReader("./assets/!BOOTSEC")
|
||||||
val prg = fr.readText()
|
val prg = fr.readText()
|
||||||
fr.close()
|
fr.close()
|
||||||
|
|
||||||
vmRunner = VMRunnerFactory(vm, "js")
|
vmRunner = VMRunnerFactory(vm, "js")
|
||||||
coroutineJob = GlobalScope.launch {
|
coroutineJob = GlobalScope.launch {
|
||||||
vmRunner.evalGlobal("$bios\n$tvknl\n$tvgl")
|
//vmRunner.evalGlobal("$bios")
|
||||||
vmRunner.executeCommand(prg)
|
//vmRunner.executeCommand(prg)
|
||||||
|
vmRunner.executeCommand("$bios\n$prg")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.InputProcessor
|
|||||||
import net.torvald.UnsafeHelper
|
import net.torvald.UnsafeHelper
|
||||||
import net.torvald.tsvm.VM
|
import net.torvald.tsvm.VM
|
||||||
import net.torvald.util.CircularArray
|
import net.torvald.util.CircularArray
|
||||||
|
import java.io.File
|
||||||
import kotlin.experimental.and
|
import kotlin.experimental.and
|
||||||
|
|
||||||
class IOSpace(val vm: VM) : PeriBase, InputProcessor {
|
class IOSpace(val vm: VM) : PeriBase, InputProcessor {
|
||||||
@@ -39,7 +40,7 @@ class IOSpace(val vm: VM) : PeriBase, InputProcessor {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
blockTransferPorts[1].attachDevice(TestFunctionGenerator())
|
blockTransferPorts[1].attachDevice(TestFunctionGenerator())
|
||||||
blockTransferPorts[0].attachDevice(TestDiskDrive(0))
|
blockTransferPorts[0].attachDevice(TestDiskDrive(0, File("assets/")))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun composeBlockTransferStatus(portno: Int): Int {
|
private fun composeBlockTransferStatus(portno: Int): Int {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import java.io.File
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class TestDiskDrive(private val driveNum: Int) : BlockTransferInterface(false, true) {
|
class TestDiskDrive(private val driveNum: Int, theRootPath: File? = null) : BlockTransferInterface(false, true) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val STATE_CODE_STANDBY = 0
|
const val STATE_CODE_STANDBY = 0
|
||||||
@@ -41,7 +41,7 @@ class TestDiskDrive(private val driveNum: Int) : BlockTransferInterface(false, t
|
|||||||
return sb.toByteArray()
|
return sb.toByteArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val rootPath = File("test_assets/test_drive_$driveNum")
|
private val rootPath = theRootPath ?: File("test_assets/test_drive_$driveNum")
|
||||||
|
|
||||||
private var fileOpen = false
|
private var fileOpen = false
|
||||||
private var fileOpenMode = -1 // 1: 'W", 2: 'A'
|
private var fileOpenMode = -1 // 1: 'W", 2: 'A'
|
||||||
|
|||||||
Reference in New Issue
Block a user