mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-10 21:21:51 +09:00
dos kernel wip
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
println("TERRAN Megatrends inc.");
|
||||
//println("Main RAM:"+(system.maxmem() >> 10)+" KBytes");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Perform memtest
|
||||
|
||||
let memptr = 0;
|
||||
const memtestptn = [
|
||||
// Overclockers will LOVE this!
|
||||
@@ -62,4 +66,20 @@ catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 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);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
con.move(4,1);
|
||||
@@ -1,36 +1 @@
|
||||
function getStatusMessage(portNo) {
|
||||
return com.sendMessageGetBytes(portNo, "DEVSTU"+String.fromCharCode(0x17));
|
||||
}
|
||||
|
||||
let ba = com.sendMessageGetBytes(0, "DEVNAM"+String.fromCharCode(0x17));
|
||||
serial.println(ba);
|
||||
|
||||
ba = com.pullMessage(0)
|
||||
serial.print(ba);
|
||||
serial.println("# END OF MSG");
|
||||
|
||||
|
||||
|
||||
ba = com.sendMessageGetBytes(1, "DEVNAM"+String.fromCharCode(0x17));
|
||||
serial.println(ba);
|
||||
|
||||
serial.println(getStatusMessage(1));
|
||||
|
||||
ba = com.sendMessageGetBytes(1, "LIST");
|
||||
ba = com.pullMessage(1);
|
||||
println(ba);
|
||||
|
||||
serial.println(getStatusMessage(1));
|
||||
|
||||
com.sendMessage(1, "OPENR\"fsh.js\"");
|
||||
|
||||
println("Status code: "+com.getStatusCode(1));
|
||||
|
||||
com.sendMessage(1, "READ");
|
||||
println("Status code: "+com.getStatusCode(1));
|
||||
let source = com.pullMessage(1);
|
||||
println(source);
|
||||
|
||||
eval(source);
|
||||
|
||||
serial.println("k bye")
|
||||
println("Hello, world!");
|
||||
55
assets/tvdos/TVDOS.SYS
Normal file
55
assets/tvdos/TVDOS.SYS
Normal file
@@ -0,0 +1,55 @@
|
||||
// Boot script
|
||||
var _TVDOS = {};
|
||||
_TVDOS.DRIVES = {}; // Object where key-value pair is <drive-letter> : [serial-port, drive-number]
|
||||
// actually figure out the drive letter association
|
||||
// Drive A is always the device we're currently on
|
||||
_TVDOS.DRIVES["A"] = _BIOS.FIRST_BOOTABLE_PORT;
|
||||
|
||||
|
||||
|
||||
Object.freeze(_TVDOS);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var filesystem = {};
|
||||
filesystem._toPorts = function(driveLetter) {
|
||||
let port = _TVDOS.DRIVES[driveLetter.toUpperCase()];
|
||||
if (port === undefined) {
|
||||
throw Error("Drive letter '" + driveLetter.toUpperCase() + "' does not exist");
|
||||
}
|
||||
return port
|
||||
};
|
||||
filesystem._close = function(portNo) {
|
||||
com.sendMessage(portNo, "CLOSE");
|
||||
};
|
||||
filesystem._flush = function(portNo) {
|
||||
com.sendMessage(portNo, "FLUSH");
|
||||
};
|
||||
// @return true if operation committed successfully, false otherwise; throws error
|
||||
// if unknown mode or invalid drive letter was given
|
||||
filesystem.open = function(driveLetter, path, operationMode) {
|
||||
let port = filesystem._toPorts(driveLetter);
|
||||
|
||||
filesystem._flush(port[0]); filesystem._close(port[0]);
|
||||
|
||||
let mode = operationMode.toUpperCase();
|
||||
if (mode != "R" && mode != "W" && mode != "A") {
|
||||
throw Error("Unknown file opening mode: " + mode);
|
||||
}
|
||||
|
||||
com.sendMessage(port[0], "OPEN"+mode+'"'+path+'",'+port[1]);
|
||||
let response = com.getStatusCode();
|
||||
return (response == 0);
|
||||
};
|
||||
// @return the entire contents of the file in String
|
||||
filesystem.readAll = function() {
|
||||
let port = filesystem._toPorts(driveLetter);
|
||||
com.sendMessage(port[0], "READ");
|
||||
let response = com.getStatusCode();
|
||||
if (response < 0 || response >= 128) {
|
||||
let status = com.getDeviceStatus(port[0]);
|
||||
throw Error("Reading a file failed with "+status.code+": "+status.message);
|
||||
}
|
||||
return com.pullMessage(port[0]);
|
||||
};
|
||||
Object.freeze(filesystem);
|
||||
@@ -1,5 +1,5 @@
|
||||
const DOS_VERSION = "1.0";
|
||||
const PROMPT_TEXT = ">";
|
||||
let PROMPT_TEXT = ">";
|
||||
let CURRENT_DRIVE = "A";
|
||||
|
||||
let shell_pwd = [""];
|
||||
|
||||
Reference in New Issue
Block a user