mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-13 06:26:05 +09:00
cpu halted flag on vm's mmio
This commit is contained in:
@@ -34,6 +34,7 @@ object VMSetupBroker {
|
||||
vm.getPrintStream = { gpu.getPrintStream() }
|
||||
vm.getErrorStream = { gpu.getErrorStream() }
|
||||
vm.getInputStream = { gpu.getInputStream() }
|
||||
vm.poke(-90L, 0)
|
||||
|
||||
vmRunners[vm.id] = VMRunnerFactory(vm.assetsDir, vm, "js")
|
||||
coroutineJobs[vm.id] = GlobalScope.launch { vmRunners[vm.id]?.executeCommand(vm.roms[0]!!.readAll()) }
|
||||
@@ -56,6 +57,7 @@ object VMSetupBroker {
|
||||
vm.getPrintStream = { TODO() }
|
||||
vm.getErrorStream = { TODO() }
|
||||
vm.getInputStream = { TODO() }
|
||||
vm.poke(-90L, -128)
|
||||
|
||||
vmRunners[vm.id]?.close()
|
||||
coroutineJobs[vm.id]?.cancel("VM kill command received")
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import com.badlogic.gdx.math.Matrix4
|
||||
import com.badlogic.gdx.utils.GdxRuntimeException
|
||||
import net.torvald.UnsafeHelper
|
||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.toUint
|
||||
import net.torvald.tsvm.FBM
|
||||
@@ -937,9 +938,9 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
||||
|
||||
override fun dispose() {
|
||||
//testTex.dispose()
|
||||
framebuffer.destroy()
|
||||
framebuffer2?.destroy()
|
||||
framebufferOut.dispose()
|
||||
try { framebuffer.destroy() } catch (_: GdxRuntimeException) {}
|
||||
try { framebuffer2?.destroy() } catch (_: GdxRuntimeException) {}
|
||||
try { framebufferOut.dispose() } catch (_: GdxRuntimeException) {}
|
||||
rendertex.dispose()
|
||||
textArea.destroy()
|
||||
textForePixmap.dispose()
|
||||
@@ -951,8 +952,8 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
||||
outFBOs.forEach { it.dispose() }
|
||||
outFBObatch.dispose()
|
||||
|
||||
try { textForeTex.dispose() } catch (_: Throwable) {}
|
||||
try { textBackTex.dispose() } catch (_: Throwable) {}
|
||||
try { textForeTex.dispose() } catch (_: GdxRuntimeException) {}
|
||||
try { textBackTex.dispose() } catch (_: GdxRuntimeException) {}
|
||||
|
||||
chrrom0.dispose()
|
||||
chrrom.dispose()
|
||||
|
||||
@@ -42,6 +42,11 @@ class IOSpace(val vm: VM) : PeriBase, InputProcessor {
|
||||
|
||||
private val keyEventBuffers = ByteArray(8)
|
||||
|
||||
private var acpiShutoff = true
|
||||
private var bmsIsCharging = false
|
||||
private var bmsHasBattery = false
|
||||
private var bmsIsBatteryOperated = false
|
||||
|
||||
init {
|
||||
//blockTransferPorts[1].attachDevice(TestFunctionGenerator())
|
||||
//blockTransferPorts[0].attachDevice(TestDiskDrive(vm, 0, File("assets")))
|
||||
@@ -76,6 +81,7 @@ class IOSpace(val vm: VM) : PeriBase, InputProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun peek(addr: Long): Byte? {
|
||||
return mmio_read(addr)
|
||||
}
|
||||
@@ -105,6 +111,9 @@ class IOSpace(val vm: VM) : PeriBase, InputProcessor {
|
||||
|
||||
88L -> vm.romMapping.toByte()
|
||||
|
||||
89L -> ((acpiShutoff.toInt() shl 7) or (bmsIsBatteryOperated.toInt() shl 3) or (bmsHasBattery.toInt() shl 1)
|
||||
or bmsIsCharging.toInt()).toByte()
|
||||
|
||||
in 1024..2047 -> peripheralFast[addr - 1024]
|
||||
|
||||
4076L -> blockTransferPorts[0].statusCode.toByte()
|
||||
@@ -164,6 +173,7 @@ class IOSpace(val vm: VM) : PeriBase, InputProcessor {
|
||||
}
|
||||
|
||||
88L -> vm.romMapping = bi
|
||||
89L -> { acpiShutoff = byte.and(-128).isNonZero() }
|
||||
|
||||
in 1024..2047 -> peripheralFast[addr - 1024] = byte
|
||||
|
||||
|
||||
@@ -464,6 +464,33 @@ class TevdDiskDrive(private val vm: VM, private val driveNum: Int, private val t
|
||||
recipient?.writeout(TestDiskDrive.composePositiveAns("USED${DOM.usedBytes}/TOTAL${DOM.capacity}"))
|
||||
statusCode.set(TestDiskDrive.STATE_CODE_STANDBY)
|
||||
}
|
||||
else if (inputString.startsWith("TEVDDISCARDDRIVE\"")) {
|
||||
// the actual capacity of the floppy must be determined when the floppy gameitem was created
|
||||
|
||||
if (DOM.isReadOnly) {
|
||||
printdbg("! disk is read-only")
|
||||
statusCode.set(TestDiskDrive.STATE_CODE_READ_ONLY)
|
||||
return
|
||||
}
|
||||
|
||||
var commaIndex = inputString.lastIndex
|
||||
while (commaIndex > 6) {
|
||||
if (inputString[commaIndex] == ',') break; commaIndex -= 1
|
||||
}
|
||||
// sanity check if path is actually enclosed with double-quote
|
||||
if (commaIndex != 6 && inputString[commaIndex - 1] != '"') {
|
||||
statusCode.set(TestDiskDrive.STATE_CODE_ILLEGAL_COMMAND)
|
||||
return
|
||||
}
|
||||
val newName = inputString.substring(6, if (commaIndex == 6) inputString.lastIndex else commaIndex - 1)
|
||||
val driveNum =
|
||||
if (commaIndex == 6) null else inputString.substring(commaIndex + 1, inputString.length).toInt()
|
||||
|
||||
// TODO driveNum is for disk drives that may have two or more slots built; for testing purposes we'll ignore it
|
||||
|
||||
DOM.entries.clear()
|
||||
DOM.diskName = newName.toByteArray(VM.CHARSET)
|
||||
}
|
||||
else
|
||||
statusCode.set(TestDiskDrive.STATE_CODE_ILLEGAL_COMMAND)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user