From 9ea3f1d2fb2c902cc0fd3332cb567537d74c27b8 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Mon, 24 Apr 2017 23:16:40 -0500 Subject: [PATCH] Don't call the ATalk driver's attention vector routine for DSI connections. It is hard-coded to work with session numbers 1-8, and it may trash memory when passed higher session numbers. This was causing crashes after disconnecting in some cases. This patch just bypasses the attention vector routine completely for DSI sessions (it's still called for sessions 1-8, i.e. ASP sessions). This should be OK, because its only real function was to display alerts about the connection being closed. --- afpbridge.c | 17 +++++++++++++++++ cmdproc.asm | 28 ++++++++++++++++++++++++++++ cmdproc.h | 3 +++ 3 files changed, 48 insertions(+) diff --git a/afpbridge.c b/afpbridge.c index 9160032..9303436 100644 --- a/afpbridge.c +++ b/afpbridge.c @@ -12,6 +12,7 @@ #include "installcmds.h" #include "aspinterface.h" #include "asmglue.h" +#include "cmdproc.h" const char bootInfoString[] = "AFPBridge v1.0b1"; LongWord version = 0x01006001; /* in rVersion format */ @@ -69,6 +70,7 @@ int main(void) { FSTInfoRecGS fstInfoRec; NotifyProcRecGS addNotifyProcRec; VersionMessageRec versionMessageRec; + PFIHooksRec pfiHooksRec; /* * Check for presence of AppleShare FST. We error out and unload @@ -137,6 +139,21 @@ int main(void) { oldSoftReset = *SoftResetPtr; *SoftResetPtr = ((LongWord)&resetRoutine << 8) | JML; + /* + * Install our own attention vector that bypasses the one in the + * ATalk driver in problematic cases (for session number > 8). + */ + pfiHooksRec.async = 0; + pfiHooksRec.command = pfiHooksCommand; + pfiHooksRec.hookFlag = 0; /* get GS/OS hooks */ + _CALLAT(&pfiHooksRec); + if (pfiHooksRec.result == 0) { + jmlOldAttentionVec = (pfiHooksRec.attentionVector << 8) | JML; + pfiHooksRec.attentionVector = (LongWord)&attentionVec; + pfiHooksRec.hookFlag = pfiHooksSetHooks; /* set GS/OS hooks */ + _CALLAT(&pfiHooksRec); + } + return; error: diff --git a/cmdproc.asm b/cmdproc.asm index 5ad3d93..7483b7c 100644 --- a/cmdproc.asm +++ b/cmdproc.asm @@ -1,6 +1,8 @@ case on mcopy cmdproc.macros +SESSION_NUM_START gequ $F8 + RamGoComp gequ $E1100C RamForbid gequ $E11018 RamPermit gequ $E1101C @@ -128,3 +130,29 @@ skip jsl RamPermit plb rtl end + +* Replacement attention vector to be called from PFI. +* This calls the previous attention vector (from the ATalk driver) for ASP +* sessions (numbered 1-8), but not for the higher-numbered DSI sessions. +* This is needed because ATalk's attention vector is hard-coded for session +* numbers 1-8 only and trashes memory when called with higher numbers. +attentionVec start + phd + phy + phx + tsc + tcd + lda [1] + plx + ply + pld + + and #$00FF + cmp #SESSION_NUM_START + bge skip +jmlOldAttentionVec entry + jml attentionVec ;to be changed to old attention vec +skip clc + rtl + end + diff --git a/cmdproc.h b/cmdproc.h index e49a316..aaa8af1 100644 --- a/cmdproc.h +++ b/cmdproc.h @@ -13,4 +13,7 @@ void pfiListSessions2CmdProc(void); extern LongWord jslOldPFIListSessions2; void CallCompletionRoutine(void *); +extern void attentionVec(void); +extern LongWord jmlOldAttentionVec; + #endif