Make afpbridge an init.

This currently uses the run queue to poll for messages from the server, which works OK in typical desktop programs but not in other environments.
This commit is contained in:
Stephen Heumann 2017-04-05 00:13:09 -05:00
parent 1f6122ba39
commit 503b15b5e4
5 changed files with 81 additions and 43 deletions

View File

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

View File

@ -1,40 +1,66 @@
#pragma rtl
#include <appletalk.h>
#include <locator.h>
#include <tcpip.h>
#include <desk.h>
#include <orca.h>
#include <stdlib.h>
#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

20
afpinit.asm Normal file
View File

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

View File

@ -39,7 +39,3 @@ RestoreStateReg start
long m
rtl
end
completionRtn data
ds 4
end

View File

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