From 17421e0ba5cc78ced88e6c47f5447855f2ea0ab8 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sun, 2 Apr 2017 19:01:49 -0500 Subject: [PATCH] Add support for calling asynchronous completion routines. At this point it can connect and largely work, but there are still several issues. --- Makefile.mk | 4 ++-- aspinterface.c | 5 ++++- cmdproc.asm | 40 ++++++++++++++++++++++++++++++++++++---- cmdproc.h | 7 +++++++ installcmds.c | 2 +- 5 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 cmdproc.h diff --git a/Makefile.mk b/Makefile.mk index 7d8e735..0c9d7b5 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -1,6 +1,6 @@ CFLAGS = -i -w -DSITEST_OBJS = dsitest.o aspinterface.o dsi.o readtcp.o endian.o tcpconnection.o atipmapping.o asmglue.o +DSITEST_OBJS = dsitest.o aspinterface.o dsi.o readtcp.o endian.o tcpconnection.o atipmapping.o asmglue.o cmdproc.o DSITEST_PROG = dsitest AFPMOUNTER_OBJS = afpmounter.o callat.o endian.o @@ -14,7 +14,7 @@ AFPBRIDGE_PROG = afpbridge PROGS = $(DSITEST_PROG) $(AFPMOUNTER_PROG) $(DUMPCMDTBL_PROG) $(AFPBRIDGE_PROG) -.PHONY: $(PROGS) +.PHONY: default default: $(PROGS) $(DSITEST_PROG): $(DSITEST_OBJS) diff --git a/aspinterface.c b/aspinterface.c index eb93bc4..19915eb 100644 --- a/aspinterface.c +++ b/aspinterface.c @@ -10,6 +10,7 @@ #include "endian.h" #include "readtcp.h" #include "asmglue.h" +#include "cmdproc.h" static void CompleteCommand(Session *sess, Word result); static void EndSession(Session *sess, Boolean callAttnRoutine); @@ -253,7 +254,9 @@ static void CompleteCommand(Session *sess, Word result) { commandRec->result = result; - // TODO call completion routine + if ((commandRec->async & AT_ASYNC) && commandRec->completionPtr != NULL) { + CallCompletionRoutine((void *)commandRec->completionPtr); + } } diff --git a/cmdproc.asm b/cmdproc.asm index fc5658d..49ebb72 100644 --- a/cmdproc.asm +++ b/cmdproc.asm @@ -1,13 +1,16 @@ case on +RamGoComp gequ $E1100C +RamForbid gequ $E11018 +RamPermit gequ $E1101C + * Location of command rec ptr on entry to an AppleTalk command procedure * (in the system zero page, which is the current direct page) cmdRecPtr gequ $80 -* Bogus segment to go into the .root file and force generation of .a/.o file -bogus private - nop - end +* Location to put completion routine ptr before calling RamGoComp +compPtr gequ $84 + * AppleTalk command procedure (which acts as a dispatcher for all commands) cmdProc start @@ -21,3 +24,32 @@ cmdProc start sta 6,s jml DispatchASPCommand end + + +CallCompletionRoutine start + phb + jsl ForceLCBank2 ;use LC bank 2 + pha + phd + lda #0 ;set direct page = system zero page + tcd + + jsl RamForbid + lda 9,s + sta compPtr + lda 9+2,s + sta compPtr+2 + ora 9,s + beq skip ;skip call if compPtr = 0 + jsl >RamGoComp +skip jsl RamPermit + pld + jsl RestoreStateReg + + pla + sta 3,s + pla + sta 3,s + plb + rtl + end diff --git a/cmdproc.h b/cmdproc.h new file mode 100644 index 0000000..ca28fda --- /dev/null +++ b/cmdproc.h @@ -0,0 +1,7 @@ +#ifndef CMDPROC_H +#define CMDPROC_H + +void cmdProc(void); +void CallCompletionRoutine(void *); + +#endif diff --git a/installcmds.c b/installcmds.c index 3f1c70d..4a8ae22 100644 --- a/installcmds.c +++ b/installcmds.c @@ -3,8 +3,8 @@ #include #include #include "asmglue.h" +#include "cmdproc.h" -extern void cmdProc(void); extern LongWord completionRtn; typedef struct NewCmd {