booting entirely from the bios

This commit is contained in:
minjaesong
2020-10-31 22:23:26 +09:00
parent ca906d8606
commit 055b825cca
7 changed files with 86 additions and 60 deletions

View File

@@ -300,9 +300,23 @@ function println(s) {
else
sys.println(s);
}
function printerr(s) {
print("\x1B[31m"+s+"\x1B[m");
}
function printerrln(s) {
println("\x1B[31m"+s+"\x1B[m");
}
function read() {
return sys.read();
}
String.prototype.trimNull = function() {
let cnt = this.length - 1
while (cnt >= 0) {
if (this.charCodeAt(cnt) != 0) break;
cnt -= 1;
}
return this.slice(0, cnt + 1);
}
// ncurses-like terminal control
var con = {};
con.getch = function() {

View File

@@ -7,27 +7,6 @@ println("TERRAN Megatrends inc.");
let memptr = 0;
const memtestptn = [
// Overclockers will LOVE this!
//[0x00,0x00,0x00,0x00 , 0xFF,0xFF,0xFF,0xFF , 0x00,0x00,0x00,0x00 , 0xFF,0xFF,0xFF,0xFF],
//[0xAA,0x55,0xAA,0x55 , 0xAA,0x55,0xAA,0x55 , 0xAA,0x55,0xAA,0x55 , 0xAA,0x55,0xAA,0x55],
//[0x00,0xFF,0x00,0xFF , 0xFF,0x00,0xFF,0x00 , 0x00,0xFF,0x00,0xFF , 0xFF,0x00,0xFF,0x00],
//[0x69,0x69,0x69,0x69 , 0xA5,0xA5,0xA5,0xA5 , 0x69,0x69,0x69,0x69 , 0xA5,0xA5,0xA5,0xA5],
//[0x0F,0x0F,0x0F,0x0F , 0x1E,0x1E,0x1E,0x1E , 0x3C,0x3C,0x3C,0x3C , 0x78,0x78,0x78,0x78],
//[0xC7,0x1C,0x71,0xC7 , 0x8E,0x38,0xE3,0x8E , 0x1C,0x71,0xC7,0x1C , 0x38,0xE3,0x8E,0x38],
//[0x71,0xC7,0x1C,0x71 , 0xE3,0x8E,0x38,0xE3 , 0x01,0x02,0x04,0x08 , 0x10,0x20,0x40,0x80],
//[0x00,0x00,0xFF,0xFF , 0x00,0x00,0xFF,0xFF , 0x00,0x01,0xFF,0xFE , 0x00,0x01,0xFF,0xFE],
//[0x00,0x03,0xFF,0xFC , 0x00,0x03,0xFF,0xFC , 0x00,0x07,0xFF,0xF8 , 0x00,0x07,0xFF,0xF8],
//[0x00,0x0F,0xFF,0xF0 , 0x00,0x0F,0xFF,0xF0 , 0x00,0x1F,0xFF,0xE0 , 0x00,0x1F,0xFF,0xE0],
//[0x00,0x3F,0xFF,0xC0 , 0x00,0x3F,0xFF,0xC0 , 0x00,0x7F,0xFF,0x80 , 0x00,0x7F,0xFF,0x80],
//[0x00,0xFF,0xFF,0x00 , 0x00,0xFF,0xFF,0x00 , 0x01,0xFF,0xFE,0x00 , 0x01,0xFF,0xFE,0x00],
//[0x03,0xFF,0xFC,0x00 , 0x03,0xFF,0xFC,0x00 , 0x07,0xFF,0xF8,0x00 , 0x07,0xFF,0xF8,0x00],
//[0x0F,0xFF,0xF0,0x00 , 0x0F,0xFF,0xF0,0x00 , 0x1F,0xFF,0xE0,0x00 , 0x1F,0xFF,0xE0,0x00],
//[0x3F,0xFF,0xC0,0x00 , 0x3F,0xFF,0xC0,0x00 , 0x7F,0xFF,0x80,0x00 , 0x7F,0xFF,0x80,0x00],
[0x00,0xFF,0xAA,0x55 , 0x69,0x0F,0xA5,0x1E , 0xC7,0x71,0x8E,0xE3 , 0xCA,0xFE,0xBA,0xBE],
[0xFF,0xFF,0xFF,0xFF , 0xFF,0xFF,0xFF,0xFF , 0xFF,0xFF,0xFF,0xFF , 0xFF,0xFF,0xFF,0xFF]
];
@@ -82,5 +61,20 @@ Object.freeze(_BIOS);
///////////////////////////////////////////////////////////////////////////////
// TODO load a bootsector using 'LOADBOOT'
con.move(4,1);
// load a bootsector using 'LOADBOOT'
let portNumber = 0;
let driveStatus = 0;
while (portNumber < 4) {
if (com.areYouThere(portNumber)) {
com.sendMessage(portNumber, "LOADBOOT");
driveStatus = com.getStatusCode(portNumber);
if (driveStatus == 0) break;
}
portNumber += 1;
}
if (portNumber < 4) {
eval(com.fetchResponse(portNumber).trimNull());
}
else {
printerrln("No bootable medium found.");
}