diff --git a/Makefile.mk b/Makefile.mk index 0c9d7b5..a456c40 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -9,7 +9,7 @@ AFPMOUNTER_PROG = afpmounter DUMPCMDTBL_OBJS = dumpcmdtbl.o asmglue.o DUMPCMDTBL_PROG = dumpcmdtbl -AFPBRIDGE_OBJS = afpbridge.o aspinterface.o dsi.o readtcp.o endian.o tcpconnection.o atipmapping.o asmglue.o installcmds.o cmdproc.o callat.o +AFPBRIDGE_OBJS = afpinit.o afpbridge.o aspinterface.o dsi.o readtcp.o endian.o tcpconnection.o atipmapping.o asmglue.o installcmds.o cmdproc.o callat.o AFPBRIDGE_PROG = afpbridge PROGS = $(DSITEST_PROG) $(AFPMOUNTER_PROG) $(DUMPCMDTBL_PROG) $(AFPBRIDGE_PROG) @@ -28,10 +28,15 @@ $(DUMPCMDTBL_PROG): $(DUMPCMDTBL_OBJS) $(AFPBRIDGE_PROG): $(AFPBRIDGE_OBJS) occ $(CFLAGS) -o $@ $(AFPBRIDGE_OBJS) + chtyp -tpif $@ %.macros: %.asm macgen $< $@ /lang/orca/Libraries/ORCAInclude/m16.* +.PHONY: install +install: $(AFPBRIDGE_PROG) + cp $(AFPBRIDGE_PROG) "*/System/System.Setup" + .PHONY: clean clean: $(RM) $(PROGS) *.o *.root > .null diff --git a/afpbridge.c b/afpbridge.c index bbd3e87..9826fe2 100644 --- a/afpbridge.c +++ b/afpbridge.c @@ -1,40 +1,66 @@ +#pragma rtl + +#include #include -#include +#include #include -#include #include "installcmds.h" #include "aspinterface.h" -#include "dsi.h" #include "asmglue.h" -int main(void) { - Boolean loadedTCP = FALSE; - Boolean startedTCP = FALSE; - - if (!TCPIPStatus() || toolerror()) { - LoadOneTool(54, 0x0300); /* load Marinetti 3.0+ */ - if (toolerror()) - goto error; - loadedTCP = TRUE; - TCPIPStartUp(); - if (toolerror()) - goto error; - startedTCP = TRUE; - } +void pollTask(void); +static struct RunQRec { + Long reserved1; + Word period; + Word signature; + Long reserved2; + Byte jml; + void (*proc)(void); +} runQRec; + + +int main(void) { + LoadOneTool(54, 0x0300); /* load Marinetti 3.0+ */ + if (toolerror()) + goto error; + + /* + * 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 + * TCPIPStartUp and TCPIPShutDown, but those don't actually do + * anything, so the practical effect is that Marinetti will always + * be available once its init has loaded (which may not have happened + * yet when this init loads). + */ + SetDefaultTPT(); + + RamForbid(); installCmds(); - - while (TRUE) { - IncBusyFlag(); - PollAllSessions(); - DecBusyFlag(); - asm { cop 0x7f } - } - + RamPermit(); + + runQRec.period = 1; + runQRec.signature = 0xA55A; + runQRec.jml = 0x5C; + runQRec.proc = pollTask; + AddToRunQ((Pointer)&runQRec); + error: - if (startedTCP) - TCPIPShutDown(); - if (loadedTCP) - UnloadOneTool(54); return; } + + +#pragma databank 1 +void pollTask(void) { + Word stateReg; + + IncBusyFlag(); + stateReg = ForceRomIn(); + + PollAllSessions(); + runQRec.period = 4*60; + + RestoreStateReg(stateReg); + DecBusyFlag(); +} +#pragma databank 0 diff --git a/afpinit.asm b/afpinit.asm new file mode 100644 index 0000000..393cdee --- /dev/null +++ b/afpinit.asm @@ -0,0 +1,20 @@ + case on + +dummy private + jml InitStart + end + +unloadFlagPtr data + ds 4 + end + +InitStart private + tay + tsc + clc + adc #4 + sta >unloadFlagPtr + lda #0 + sta >unloadFlagPtr+2 + tya + end diff --git a/asmglue.asm b/asmglue.asm index d8e9526..6fc74ef 100644 --- a/asmglue.asm +++ b/asmglue.asm @@ -39,7 +39,3 @@ RestoreStateReg start long m rtl end - -completionRtn data - ds 4 - end diff --git a/installcmds.c b/installcmds.c index 4a8ae22..e9b6942 100644 --- a/installcmds.c +++ b/installcmds.c @@ -5,8 +5,6 @@ #include "asmglue.h" #include "cmdproc.h" -extern LongWord completionRtn; - typedef struct NewCmd { Word cmdNum; void (*cmdAddr)(void); @@ -27,16 +25,9 @@ LongWord *cmdTable = (LongWord *)0xE1D600; LongWord oldCmds[MAX_CMD + 1]; /* holds old entries for commands we changed */ -ATGetInfoRec getInfoRec; - void installCmds(void) { Word savedStateReg; NewCmd *cmd; - - getInfoRec.async = 0; - getInfoRec.command = atGetInfoCommand; - _CALLAT(&getInfoRec); - completionRtn = getInfoRec.completionRtn; savedStateReg = ForceLCBank2();