Keep our driver installed on switch back from P8.

This commit is contained in:
Stephen Heumann 2018-08-12 15:08:26 -05:00
parent 2d00030eba
commit 4ac24d75f4
2 changed files with 64 additions and 9 deletions

View File

@ -258,7 +258,9 @@ static Word DoMountURL(struct GSOSDP *dp) {
err = CheckTwoImg(sess);
if (err != OPERATION_SUCCESSFUL) {
EndNetDiskSession(sess);
// TODO error
// TODO better error
dp->transferCount = 0;
return drvrIOError;
}
dp->dibPointer->extendedDIBPtr = sess;
@ -328,8 +330,18 @@ static Word DoEject(struct GSOSDP *dp) {
}
static Word DoShutdown(struct GSOSDP *dp) {
EndNetDiskSession(dp->dibPointer->extendedDIBPtr);
dp->dibPointer->extendedDIBPtr = NULL;
//TODO should return error unless all of our other DIBs are already shut down?
return 0;
/*
* We don't actually end the session here, because this may just be
* a switch to P8. If so, this driver won't work within P8, but if we
* leave things in place it should work again once we're back in GS/OS.
* Do end the current TCP connection, since it would probably time out.
*/
EndTCPConnection(dp->dibPointer->extendedDIBPtr);
/*
* Return error to indicate we shouldn't be purged.
* (I don't think we would be anyhow, since this isn't an
* actual device driver file, but let's do this to be safe.)
*/
return drvrIOError;
}

View File

@ -5,25 +5,41 @@
#include <misctool.h>
#include <tcpip.h>
#include <memory.h>
#include <gsos.h>
#include <orca.h>
#include "driver.h"
#include "installdriver.h"
#include "asmglue.h"
#include "version.h"
const char bootInfoString[] = "NetDisk " BOOT_INFO_VERSION;
Word *unloadFlagPtr;
static struct NotificationProcRec {
Long reserved1;
Word reserved2;
Word Signature;
Long Event_flags;
Long Event_code;
Byte jml;
void (*proc)(void);
} notificationProcRec;
#define NOTIFY_SHUTDOWN 0x20
#define NOTIFY_GSOS_SWITCH 0x04
static void notificationProc(void);
#define JML 0x5C
static void setUnloadFlag(void) {
if (unloadFlagPtr != NULL && *unloadFlagPtr == 0)
*unloadFlagPtr = 1;
}
int main(void) {
for (int i = 1; i < 256; i++) {
UnloadOneTool(i); // event mgr
}
/*
* Load Marinetti.
* We may get an error if the TCPIP init isn't loaded yet, but we ignore it.
@ -45,6 +61,14 @@ int main(void) {
/* We're not going to error out, so show boot info. */
ShowBootInfo(bootInfoString, NULL);
/* Add notification proc to be called on shutdown and switches to GS/OS */
notificationProcRec.Signature = 0xA55A;
notificationProcRec.Event_flags = NOTIFY_SHUTDOWN | NOTIFY_GSOS_SWITCH;
notificationProcRec.jml = JML;
notificationProcRec.proc = notificationProc;
NotifyProcRecGS addNotifyProcRec = {1, (ProcPtr)&notificationProcRec};
AddNotifyProcGS(&addNotifyProcRec);
/*
* Put Marinetti in the default TPT so its tool stub won't be unloaded,
* even if UnloadOneTool is called on it. Programs may still call
@ -61,3 +85,22 @@ error:
setUnloadFlag();
return;
}
/*
* Notification procedure called at shutdown time or when switching to GS/OS.
*/
#pragma databank 1
static void notificationProc(void) {
Word stateReg = ForceRomIn();
if (notificationProcRec.Event_code & NOTIFY_GSOS_SWITCH) {
/* Reinstall our driver on switch back to GS/OS from P8 */
InstallDriver();
} else if (notificationProcRec.Event_code & NOTIFY_SHUTDOWN) {
//TODO eject disks
}
RestoreStateReg(stateReg);
}
#pragma databank 0