mirror of
https://github.com/sheumann/NetDisk.git
synced 2024-11-30 23:49:35 +00:00
Keep our driver installed on switch back from P8.
This commit is contained in:
parent
2d00030eba
commit
4ac24d75f4
22
driver.c
22
driver.c
@ -258,7 +258,9 @@ static Word DoMountURL(struct GSOSDP *dp) {
|
|||||||
err = CheckTwoImg(sess);
|
err = CheckTwoImg(sess);
|
||||||
if (err != OPERATION_SUCCESSFUL) {
|
if (err != OPERATION_SUCCESSFUL) {
|
||||||
EndNetDiskSession(sess);
|
EndNetDiskSession(sess);
|
||||||
// TODO error
|
// TODO better error
|
||||||
|
dp->transferCount = 0;
|
||||||
|
return drvrIOError;
|
||||||
}
|
}
|
||||||
|
|
||||||
dp->dibPointer->extendedDIBPtr = sess;
|
dp->dibPointer->extendedDIBPtr = sess;
|
||||||
@ -328,8 +330,18 @@ static Word DoEject(struct GSOSDP *dp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Word DoShutdown(struct GSOSDP *dp) {
|
static Word DoShutdown(struct GSOSDP *dp) {
|
||||||
EndNetDiskSession(dp->dibPointer->extendedDIBPtr);
|
/*
|
||||||
dp->dibPointer->extendedDIBPtr = NULL;
|
* We don't actually end the session here, because this may just be
|
||||||
//TODO should return error unless all of our other DIBs are already shut down?
|
* a switch to P8. If so, this driver won't work within P8, but if we
|
||||||
return 0;
|
* 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;
|
||||||
}
|
}
|
@ -5,25 +5,41 @@
|
|||||||
#include <misctool.h>
|
#include <misctool.h>
|
||||||
#include <tcpip.h>
|
#include <tcpip.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
#include <gsos.h>
|
||||||
#include <orca.h>
|
#include <orca.h>
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
#include "installdriver.h"
|
#include "installdriver.h"
|
||||||
|
#include "asmglue.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
const char bootInfoString[] = "NetDisk " BOOT_INFO_VERSION;
|
const char bootInfoString[] = "NetDisk " BOOT_INFO_VERSION;
|
||||||
|
|
||||||
Word *unloadFlagPtr;
|
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) {
|
static void setUnloadFlag(void) {
|
||||||
if (unloadFlagPtr != NULL && *unloadFlagPtr == 0)
|
if (unloadFlagPtr != NULL && *unloadFlagPtr == 0)
|
||||||
*unloadFlagPtr = 1;
|
*unloadFlagPtr = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
for (int i = 1; i < 256; i++) {
|
|
||||||
UnloadOneTool(i); // event mgr
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load Marinetti.
|
* Load Marinetti.
|
||||||
* We may get an error if the TCPIP init isn't loaded yet, but we ignore it.
|
* 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. */
|
/* We're not going to error out, so show boot info. */
|
||||||
ShowBootInfo(bootInfoString, NULL);
|
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)¬ificationProcRec};
|
||||||
|
AddNotifyProcGS(&addNotifyProcRec);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Put Marinetti in the default TPT so its tool stub won't be unloaded,
|
* 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
|
* even if UnloadOneTool is called on it. Programs may still call
|
||||||
@ -61,3 +85,22 @@ error:
|
|||||||
setUnloadFlag();
|
setUnloadFlag();
|
||||||
return;
|
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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user