Pass through calls we don’t handle to the original AppleTalk stack.

It is now possible to have AFP volumes mounted over both AppleTalk and TCP/IP simultaneously.
This commit is contained in:
Stephen Heumann 2017-04-09 20:56:19 -05:00
parent 6c6dff0e18
commit 3b2f1b6a25
10 changed files with 102 additions and 37 deletions

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -17,6 +17,6 @@ typedef struct ATIPMapping {
extern struct ATIPMapping atipMapping;
void DoLookupName(NBPLookupNameRec *commandRec);
LongWord DoLookupName(NBPLookupNameRec *commandRec);
#endif

View File

@ -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

40
cmdproc.macros Normal file
View File

@ -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

View File

@ -4,6 +4,7 @@
#include <AppleTalk.h>
#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) {

View File

@ -1,6 +1,12 @@
#ifndef INSTALLCMDS_H
#define INSTALLCMDS_H
#include <AppleTalk.h>
#define MAX_CMD rpmFlushSessionCommand
extern LongWord oldCmds[MAX_CMD + 1];
void installCmds(void);
#endif

View File

@ -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;