Revamped persistent storage ops to Forth-like 1K-aligned blocks

This commit is contained in:
Luxferre
2022-08-13 10:58:02 +03:00
parent 970c6f919d
commit e46d1e9195
2 changed files with 9 additions and 9 deletions
+6 -6
View File
@@ -323,10 +323,10 @@ ushort tobig(ushort val) {
/* Persistent operation handler */
ushort persistOp(FILE *pfd, ushort maddr, ushort dataLen, ushort adl, ushort adh, uchar isWrite) {
ushort persistOp(FILE *pfd, ushort maddr, ushort dataLen, ushort blk, uchar isWrite) {
ushort status = 0, proc;
if(pfd) {
fseek(pfd, ((unsigned long) adh << 16) | adl, SEEK_SET);
fseek(pfd, ((unsigned long) blk << 10), SEEK_SET); /* blocks are 1K-aligned */
if(isWrite) /* writing to the persistent area from the memory */
proc = (ushort) fwrite(&flatram[maddr], 1, dataLen, pfd);
else /* reading from the persistent area into the memory */
@@ -568,11 +568,11 @@ void equi_main_loop() {
trapout(STACK_UNDERFLOW);
portIO(popMain(), popMain(), popMain());
break;
case INS_PERSIST_READ: /* ( adh adl len maddr -- status) */
pushMain(persistOp(pfd, popMain(), popMain(), popMain(), popMain(), 0));
case INS_PERSIST_READ: /* ( blk len maddr -- status) */
pushMain(persistOp(pfd, popMain(), popMain(), popMain(), 0));
break;
case INS_PERSIST_WRITE: /* ( adh adl len maddr -- status) */
pushMain(persistOp(pfd, popMain(), popMain(), popMain(), popMain(), 1));
case INS_PERSIST_WRITE: /* ( blk len maddr -- status) */
pushMain(persistOp(pfd, popMain(), popMain(), popMain(), 1));
break;
default: /* all characters not processed before are invalid instructions */
trapout(INVALID_INSTRUCTION);