From 3b2f1b6a25ecde0fa07ace9293f2c7765c7c244d Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sun, 9 Apr 2017 20:56:19 -0500 Subject: [PATCH] =?UTF-8?q?Pass=20through=20calls=20we=20don=E2=80=99t=20h?= =?UTF-8?q?andle=20to=20the=20original=20AppleTalk=20stack.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is now possible to have AFP volumes mounted over both AppleTalk and TCP/IP simultaneously. --- Makefile.mk | 2 +- aspinterface.c | 22 +++++++++++++++++----- aspinterface.h | 2 +- atipmapping.c | 11 ++++++----- atipmapping.h | 2 +- cmdproc.asm | 43 +++++++++++++++++++++++++++++-------------- cmdproc.macros | 40 ++++++++++++++++++++++++++++++++++++++++ installcmds.c | 3 +-- installcmds.h | 6 ++++++ tcpconnection.c | 8 -------- 10 files changed, 102 insertions(+), 37 deletions(-) create mode 100644 cmdproc.macros diff --git a/Makefile.mk b/Makefile.mk index cd2039f..e53034b 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -4,7 +4,7 @@ COMMAND = $(!eq,$(CMNDNAME),$(CC) $(CMNDNAME) $(USEORCALIBS)&&$(CC)) $(CMNDARGS) CFLAGS = -i -w -O95 -DSITEST_OBJS = dsitest.o aspinterface.o dsi.o readtcp.o endian.o tcpconnection.o atipmapping.o asmglue.o cmdproc.o +DSITEST_OBJS = dsitest.o aspinterface.o dsi.o readtcp.o endian.o tcpconnection.o atipmapping.o asmglue.o cmdproc.o installcmds.o DSITEST_PROG = dsitest AFPMOUNTER_OBJS = afpmounter.o callat.o endian.o diff --git a/aspinterface.c b/aspinterface.c index 8d4c02d..cd6b50a 100644 --- a/aspinterface.c +++ b/aspinterface.c @@ -11,6 +11,8 @@ #include "readtcp.h" #include "asmglue.h" #include "cmdproc.h" +#include "installcmds.h" +#include "atipmapping.h" typedef struct FPReadRec { Word CommandCode; /* includes pad byte */ @@ -35,7 +37,7 @@ static void DoSPWrite(Session *sess, ASPWriteRec *commandRec); Session sessionTbl[MAX_SESSIONS]; #pragma databank 1 -void DispatchASPCommand(SPCommandRec *commandRec) { +LongWord DispatchASPCommand(SPCommandRec *commandRec) { Session *sess; unsigned int i; Word stateReg; @@ -45,6 +47,13 @@ void DispatchASPCommand(SPCommandRec *commandRec) { if (commandRec->command == aspGetStatusCommand || commandRec->command==aspOpenSessionCommand) { + if (((ASPGetStatusRec*)commandRec)->slsNet != atipMapping.networkNumber + || ((ASPGetStatusRec*)commandRec)->slsNode != atipMapping.node + || ((ASPGetStatusRec*)commandRec)->slsSocket != atipMapping.socket) + { + goto callOrig; + } + for (i = 0; i < MAX_SESSIONS; i++) { if (sessionTbl[i].dsiStatus == unused) break; @@ -57,16 +66,14 @@ void DispatchASPCommand(SPCommandRec *commandRec) { sess->spCommandRec = commandRec; if (!StartTCPConnection(sess)) { - FlagFatalError(sess, 0); + FlagFatalError(sess, commandRec->result); goto ret; } sess->dsiStatus = awaitingHeader; InitReadTCP(sess, DSI_HEADER_SIZE, &sess->reply); } else { if (commandRec->refNum < SESSION_NUM_START) { - // TODO call original AppleTalk routine (or do it earlier) - commandRec->result = atInvalidCmdErr; - goto ret; + goto callOrig; } /* @@ -135,6 +142,11 @@ void DispatchASPCommand(SPCommandRec *commandRec) { ret: RestoreStateReg(stateReg); + return 0; + +callOrig: + RestoreStateReg(stateReg); + return oldCmds[commandRec->command]; } #pragma databank 0 diff --git a/aspinterface.h b/aspinterface.h index ce3cfb1..3e0bd19 100644 --- a/aspinterface.h +++ b/aspinterface.h @@ -14,7 +14,7 @@ extern Session sessionTbl[MAX_SESSIONS]; -void DispatchASPCommand(SPCommandRec *commandRec); +LongWord DispatchASPCommand(SPCommandRec *commandRec); void CompleteASPCommand(Session *sess, Word result); void FinishASPCommand(Session *sess); void FlagFatalError(Session *sess, Word errorCode); diff --git a/atipmapping.c b/atipmapping.c index 6a7523e..6c5abaa 100644 --- a/atipmapping.c +++ b/atipmapping.c @@ -9,6 +9,7 @@ #include "atipmapping.h" #include "asmglue.h" #include "aspinterface.h" +#include "installcmds.h" struct ATIPMapping atipMapping; @@ -25,11 +26,11 @@ static int nextSocket = 1; commandRec->result = (x); \ commandRec->actualMatch = 0; \ RestoreStateReg(stateReg); \ - return; \ + return 0; \ } while (0) #pragma databank 1 -void DoLookupName(NBPLookupNameRec *commandRec) { +LongWord DoLookupName(NBPLookupNameRec *commandRec) { cvtRec hostInfo; dnrBuffer dnrInfo; Byte *curr, *dest; @@ -146,11 +147,11 @@ haveMapping: commandRec->actualMatch = 1; commandRec->result = 0; RestoreStateReg(stateReg); - return; + return 0; passThrough: - // TODO pass through to actual NBP - return_error(nbpNameErr); + RestoreStateReg(stateReg); + return oldCmds[commandRec->command]; } #pragma databank 0 diff --git a/atipmapping.h b/atipmapping.h index dc26330..90a817c 100644 --- a/atipmapping.h +++ b/atipmapping.h @@ -17,6 +17,6 @@ typedef struct ATIPMapping { extern struct ATIPMapping atipMapping; -void DoLookupName(NBPLookupNameRec *commandRec); +LongWord DoLookupName(NBPLookupNameRec *commandRec); #endif diff --git a/cmdproc.asm b/cmdproc.asm index 70abcb5..2d4b774 100644 --- a/cmdproc.asm +++ b/cmdproc.asm @@ -1,4 +1,5 @@ case on + mcopy cmdproc.macros RamGoComp gequ $E1100C RamForbid gequ $E11018 @@ -14,27 +15,41 @@ compPtr gequ $84 * AppleTalk command procedure (which acts as a dispatcher for all commands) cmdProc start - lda 3,s - pha - lda 3,s + lda cmdRecPtr+2 pha lda cmdRecPtr - sta 4,s - lda cmdRecPtr+2 - sta 6,s - jml DispatchASPCommand + pha + jsl DispatchASPCommand + cmp #0 + bne doOrig + cpx #0 + bne doOrig + rtl +doOrig short i ;push original procedure ptr + phx + long i + dec a + pha + rtl ;jump to it end nbpCmdProc start - lda 3,s - pha - lda 3,s + lda cmdRecPtr+2 pha lda cmdRecPtr - sta 4,s - lda cmdRecPtr+2 - sta 6,s - jml DoLookupName + pha + jsl DoLookupName + cmp #0 + bne doOrig + cpx #0 + bne doOrig + rtl +doOrig short i ;push original procedure ptr + phx + long i + dec a + pha + rtl ;jump to it end CallCompletionRoutine start diff --git a/cmdproc.macros b/cmdproc.macros new file mode 100644 index 0000000..bd531fa --- /dev/null +++ b/cmdproc.macros @@ -0,0 +1,40 @@ + macro +&l long &a,&b + lclb &i + lclb &m +&a amid &a,1,1 +&m setb ("&a"="M").or.("&a"="m") +&i setb ("&a"="I").or.("&a"="i") + aif c:&b=0,.a +&b amid &b,1,1 +&m setb ("&b"="M").or.("&b"="m").or.&m +&i setb ("&b"="I").or.("&b"="i").or.&i +.a +&l rep #&m*32+&i*16 + aif .not.&m,.b + longa on +.b + aif .not.&i,.c + longi on +.c + mend + macro +&l short &a,&b + lclb &i + lclb &m +&a amid &a,1,1 +&m setb ("&a"="M").or.("&a"="m") +&i setb ("&a"="I").or.("&a"="i") + aif c:&b=0,.a +&b amid &b,1,1 +&m setb ("&b"="M").or.("&b"="m").or.&m +&i setb ("&b"="I").or.("&b"="i").or.&i +.a +&l sep #&m*32+&i*16 + aif .not.&m,.b + longa off +.b + aif .not.&i,.c + longi off +.c + mend diff --git a/installcmds.c b/installcmds.c index fe1c62a..ef71705 100644 --- a/installcmds.c +++ b/installcmds.c @@ -4,6 +4,7 @@ #include #include "asmglue.h" #include "cmdproc.h" +#include "installcmds.h" typedef struct NewCmd { Word cmdNum; @@ -22,8 +23,6 @@ NewCmd newCmds[] = { LongWord *cmdTable = (LongWord *)0xE1D600; -#define MAX_CMD rpmFlushSessionCommand - LongWord oldCmds[MAX_CMD + 1]; /* holds old entries for commands we changed */ void installCmds(void) { diff --git a/installcmds.h b/installcmds.h index 468babf..90d3411 100644 --- a/installcmds.h +++ b/installcmds.h @@ -1,6 +1,12 @@ #ifndef INSTALLCMDS_H #define INSTALLCMDS_H +#include + +#define MAX_CMD rpmFlushSessionCommand + +extern LongWord oldCmds[MAX_CMD + 1]; + void installCmds(void); #endif diff --git a/tcpconnection.c b/tcpconnection.c index e1be2cd..7b9c5c8 100644 --- a/tcpconnection.c +++ b/tcpconnection.c @@ -21,14 +21,6 @@ BOOLEAN StartTCPConnection(Session *sess) { LongWord initialTime; commandRec = (ASPOpenSessionRec *)sess->spCommandRec; - - if (commandRec->slsNet != atipMapping.networkNumber - || commandRec->slsNode != atipMapping.node - || commandRec->slsSocket != atipMapping.socket) - { - commandRec->result = aspNetworkErr; - return FALSE; - } sess->atipMapping = atipMapping;