Initial checkin of SIM sources. This includes both simlib and SIM,

itself.
This commit is contained in:
gdr-ftp 1998-02-03 07:54:12 +00:00
parent 3036f145f1
commit c4ecb61d8b
10 changed files with 520 additions and 0 deletions

17
sys/sim/Makefile Normal file
View File

@ -0,0 +1,17 @@
sim.root: sim.asm sim.mac simequates.equ
compile sim.asm keep=sim
sim: sim.root
link sim keep=sim
chtyp -t \$B6 sim
simlib.root: simlib.asm simlib.mac simequates.equ
compile simlib.asm keep=simlib
libsim: simlib.root
rm -f libsim
makelib libsim +simlib.root +simlib.a
test: test.c libsim
compile test.c keep=test
link test libsim keep=test

84
sys/sim/rom3 Normal file
View File

@ -0,0 +1,84 @@
Joe,
This is a primitive disassembly of the ROM 03 interrupt handler
firmware. You need to fix this up to look like the ROM 01 version
I have in SIM.ASM.
MasterIntHandler clc (E1/0010 JMPs here, FF/BC6C)
xce
LONG I,M
php
phb
Assume B=00E1
pea $E1E1
plb
sta |ASave ($108)
lda SHADOW shadow register
sta |ShadSave ($119)
ora #$8000
and #$9F3E
sta SHADOW shadow register
stx |XSave ($10a)
sty |YSave ($10c)
tdc
sta |DPSave ($110)
lda #$0000
tcd
SHORT I,M
bcc NotSure ; check emulation mode
lda $04,s
and #$10
adc #$70
NotSure bvs hmm2
lda #$03
sta SCCAREG SCC channel A cmd register
lda SCCAREG SCC channel A cmd register
bit |ATlkFlag
beq SerInt2
pha
and #$07
bne ChanB
lda SCCADATA SCC channel A data register
sta |SerIntData
lda SCCADATA SCC channel A data register
sta |SerIntData+1
jsl >IRQ_ATalk
bra Next
ChanB lda SCCBDATA SCC channel B data register
sta |SerIntData
lda SCCBDATA SCC channel B data register
sta |SerIntData+1
jsl >IRQ_ATalk
Next lda >$010101
sta |EmulStakSave
lda #$00
ror a
sta |$E10101
pla
bra Next2
SerInt2 pha
lda >$010101
sta |EmulStakSave
stz |$E10101
jsl >$E1021C MIDI?
pla
bcc $BD0C
clc
Next2 pha
and |SerFlag
beq NoSerial
jsl >IRQ_Serial
ror |$E10101
pla
lda |$E10101
bne NoMoreSer
LONG I,M
plb
jmp Exit
NoSerial pla
bne $BD07
NoMoreSer clv
hmm2 lda >$010101
sta |EmulStakSave
LONG I,M
....

1
sys/sim/sim.asm Normal file

File diff suppressed because one or more lines are too long

104
sys/sim/sim.doc Normal file
View File

@ -0,0 +1,104 @@
Serial Interrupt Manager Tool Set
---------------------------------
The Serial Interrupt Manager (SIM) is a code module that is installed by
a permanent init (PIF) file residing in the *:System:System.Setup
directory of an Apple IIGS. SIM arbitrates serial interrupt vector
'patches' by providing a simple interface for applications and device
drivers to handle serial interrupts (from the IIGS's built-in SCC 8530)
in a manner completely consistent with Apple's guidelines on the subject.
SIM replaces the first quarter or so of the IIGS' main interrupt handler.
Most of the code is identical to that found in the ROM, with the
following notable exception: non-MIDI asynchronous serial interrupts
are handled by dispatching to routines that can be installed by using
the SIM tool.
SCC interrupt handlers installed through SIM are called, according
to Apple guidelines, immediately _after_ checking for AppleTalk and MIDI
interrupts. This prevents AppleTalk or MIDI data loss, and provides the
lowest allowable overhead in processing asynchronous serial interrupts.
Data rates of up to 57600 baud are possible with no resulting data loss.
Since SIM handles serial interrupts through its own vector, and not
the $E10024 vector, the IIGS Serial Firmware can be used in combination
with SIM; SIM always has priority over the standard firmware handlers,
and if the firmware is used to initialize a port which is already being
handled by a SIM handler a crash may result. Any suggestions for better
arbitration of the firmware are welcome. (SIM could possibly check to see
if the firmware's SerFlag has been set, and automatically uninstall
the SIM handler and queue a warning dialog in the Scheduler.)
------------------------------------------------------------------------
SIM consists of a number of routines which are accessed via the
System 6.0 SendRequest IPC mechanism. To reduce development times, SIM
comes with a library that can be used to access SIM in a language-
independent manner.
The following call descriptions show the various SIM calls in C format.
The calls expect their arguments in C order (i.e., pushing parameters
right to left).
The return value of the calls is either zero, indicating that no error
occurred, or a non-zero integer indicating the error number. All of the
calls can return SIMNotFound in the event the SIM tool could not be located.
---------------------
int SIMVersion(void)
Returns the version number (in tool version format) of the SIM tool.
Errors:
SIMNotFound - indicates that the SIM tool could not be located
($0006) Upon receiving this error, the application should
terminate attempting to install an interrupt
handler and should notify the user that the port
could not be opened.
---------------------
int InstallIntVect(word port, longword address)
InstallIntVect installs a serial handler routine into SIM's interrupt
dispatch code. 'address' is a pointer to an interrupt handler which
conforms to the serial interrupt handlers described in the Apple IIGS
Firmware Reference (which are called through the $E10024 vector).
The following steps should be taken to install a SIM handler:
Initialize SCC, but do not enable interrupts
call InstallIntVect
Enable SCC Interrupts
Errors:
SIMInvalidPort An invalid port number was specified. The only port numbers
($0005) currently supported are SIMModemPort (2) and SIMPrinterPort (1)
SIMATalkActive The specified port is already in use by AppleTalk, and thus
($0003) cannot be used.
SIMAlreadyInst Some other system component (a driver or application) already
($0001) has an interrupt handler installed for that port.
In the last two cases, an application should notify the user that the port
is busy and cannot be used, and drivers should return an error code
appropriate to the condition.
---------------------
int RemoveIntVect(word port, longword address)
RemoveIntVect is used to uninstall a previously installed interrupt handler.
The port number and address of the handler must be specified. This prevents
a program from trying to forcibly uninstall some other program's interrupt
handler, an approach which is not acceptable.
The procedure for uninstalling an interrupt handler should be as follows:
Turn of SCC interrupts and shutdown SCC chip if desired
Call RemoveIntVect
Errors:
SIMInvalidAddr The address passed to RemoveIntVect does not match the
actual address of the handler on the specified port.
SIMNotInstalled There is no handler currently installed for the specified
port.

1
sys/sim/sim.h Normal file
View File

@ -0,0 +1 @@
/* * Serial Interrupt Manager * C Interface File * Copyright 1993, Procyon Enterprises Incorporated * Free distribution is hereby granted for use with the * SIM tool */ #ifdef __ORCAC__ /* * ORCA/C Prototypes */ extern int SIMVERSION(int *versionPtr); extern int INSTALLINTVECT(int port, unsigned long address); extern int REMOVEINTVECT(int port, unsigned long address); #else /* * APW C/other prototypes */ int SIMVERSION(); int INSTALLINTVECT(); int REMOVEINTVECT(); #endif #define SIMVersion SIMVERSION #define InstallIntVect INSTALLINTVECT #define RemoveIntVect REMOVEINTVECT #define SIMPrinterPort 1 #define SIMModemPort 2 #define SIMNoError 0 #define SIMAlreadyInst 1 #define SIMInvalidAddr 2 #define SIMATalkActive 3 #define SIMNotInstalled 4 #define SIMInvalidPort 5 #define SIMNotFound 6

152
sys/sim/sim.mac Normal file
View File

@ -0,0 +1,152 @@
MACRO
&lab long &stat
&lab anop
lcla &t
lcla &len
lclc &ch
&t seta 0
&len seta l:&stat
.a
aif &len=0,.b
&ch amid &stat,&len,1
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
aif ("&ch"="a").or.("&ch"="m"),.m
.c
&len seta &len-1
ago ^a
.i
longi on
&t seta &t+16
ago ^c
.m
longa on
&t seta &t+32
ago ^c
.b
aif &t=0,.d
rep #&t
.d
mend
MACRO
&lab short &stat
&lab anop
lcla &t
lcla &len
lclc &ch
&t seta 0
&len seta l:&stat
.a
aif &len=0,.b
&ch amid &stat,&len,1
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
aif ("&ch"="a").or.("&ch"="m"),.m
.c
&len seta &len-1
ago ^a
.i
longi off
&t seta &t+16
ago ^c
.m
longa off
&t seta &t+32
ago ^c
.b
aif &t=0,.d
sep #&t
.d
mend
MACRO
&lab str &string
&lab dc i1'l:&string',c'&string'
MEND
macro
&lab ph4 &n1
aif "&n1"="*",.f
lclc &c
&lab anop
&c amid &n1,1,1
aif "&c"="#",.d
aif s:longa=1,.a
rep #%00100000
.a
aif "&c"<>"{",.b
&c amid &n1,l:&n1,1
aif "&c"<>"}",.g
&n1 amid &n1,2,l:&n1-2
ldy #2
lda (&n1),y
pha
lda (&n1)
pha
ago .e
.b
aif "&c"<>"[",.c
ldy #2
lda &n1,y
pha
lda &n1
pha
ago .e
.c
aif "&c"<>"<",.c1
&n1 amid &n1,2,l:&n1-1
pei &n1+2
pei &n1
ago .e
.c1
lda &n1+2
pha
lda &n1
pha
ago .e
.d
&n1 amid &n1,2,l:&n1-1
pea +(&n1)|-16
pea &n1
ago .f
.e
aif s:longa=1,.f
sep #%00100000
.f
mexit
.g
mnote "Missing closing '}'",16
mend
MACRO
&lab _MMStartUp
&lab ldx #$0202
jsl $E10000
MEND
MACRO
&lab _AcceptRequests
&lab ldx #$1B01
jsl $E10000
MEND
MACRO
&lab jcs &loc
&lab bcc *+5
jmp &loc
mend
MACRO
&lab jcc &loc
&lab bcs *+5
jmp &loc
mend
MACRO
&lab _FWEntry
&lab ldx #$2403
jsl $E10000
MEND
MACRO
&lab _DInfoGS &params
&lab jsl $E100A8
dc i2"$202C"
dc i4"&params"
MEND
MACRO
&lab _DStatusGS &params
&lab jsl $E100A8
dc i2"$202D"
dc i4"&params"
MEND

1
sys/sim/simequates.equ Normal file
View File

@ -0,0 +1 @@
SIMInstallHand gequ $8000 SIMRemoveHand gequ $8001 SIMGetVersion gequ $8002 * SIM Error codes SIMNoError gequ 0 SIMAlreadyInst gequ 1 SIMInvalidAddr gequ 2 SIMATalkActive gequ 3 SIMNotInstalled gequ 4 SIMInvalidPort gequ 5 SIMNotFound gequ 6 * SIM Port codes SIMModemPort gequ 2 SIMPrinterPort gequ 1

1
sys/sim/simlib.asm Normal file
View File

@ -0,0 +1 @@
mcopy simlib.mac copy simequates.equ * High-level access library for SIM tool InstallIntVect START using SIMLibData result equ 0 subroutine (4:address,2:port),2 lda port sta SIMport lda address sta SIMaddress lda address+2 sta SIMaddress+2 lda #SIMInstallHand jsr DoSIMCall lda |Gerror sta result return 2:result END RemoveIntVect START using SIMLibData result equ 0 subroutine (4:address,2:port),2 lda port sta SIMport lda address sta SIMaddress lda address+2 sta SIMaddress+2 lda #SIMRemoveHand jsr DoSIMCall lda |Gerror sta result return 2:result END SIMVersion START using SIMLibData result equ 0 subroutine (4:versionPtr),2 lda #SIMGetVersion jsr DoSIMCall lda |Gerror sta result bne goodbye if an error, don't copy version lda Gversion sta [versionPtr] goodbye return 2:result END DoSIMCall START using SIMLibData pha push request code pea 1 how to flag ph4 #SIMName ph4 #SIMInData ph4 #pBlock _SendRequest bcc noToolErr cmp #$0120 ; nobody accepted the request beq noAccept rts noAccept lda #SIMNotFound sta |Gerror noToolErr rts END SIMLibData DATA SIMName str 'SerialIntrMgr~Entry~' pBlock dc i2'0' ; count field Gerror dc i2'0' ; error code Gversion dc i2'0' ; version number SIMInData ENTRY SIMport dc i2'0' SIMaddress dc i4'0' END

158
sys/sim/simlib.mac Normal file
View File

@ -0,0 +1,158 @@
MACRO
&lab str &string
&lab dc i1'l:&string',c'&string'
MEND
macro
&lab ph4 &n1
aif "&n1"="*",.f
lclc &c
&lab anop
&c amid &n1,1,1
aif "&c"="#",.d
aif s:longa=1,.a
rep #%00100000
.a
aif "&c"<>"{",.b
&c amid &n1,l:&n1,1
aif "&c"<>"}",.g
&n1 amid &n1,2,l:&n1-2
ldy #2
lda (&n1),y
pha
lda (&n1)
pha
ago .e
.b
aif "&c"<>"[",.c
ldy #2
lda &n1,y
pha
lda &n1
pha
ago .e
.c
aif "&c"<>"<",.c1
&n1 amid &n1,2,l:&n1-1
pei &n1+2
pei &n1
ago .e
.c1
lda &n1+2
pha
lda &n1
pha
ago .e
.d
&n1 amid &n1,2,l:&n1-1
pea +(&n1)|-16
pea &n1
ago .f
.e
aif s:longa=1,.f
sep #%00100000
.f
mexit
.g
mnote "Missing closing '}'",16
mend
MACRO
&lab subroutine &parms,&work
&lab anop
aif c:&work,.a
lclc &work
&work setc 0
.a
gbla &totallen
gbla &worklen
&worklen seta &work
&totallen seta 0
aif c:&parms=0,.e
lclc &len
lclc &p
lcla &i
&i seta c:&parms
.b
&p setc &parms(&i)
&len amid &p,2,1
aif "&len"=":",.c
&len amid &p,1,2
&p amid &p,4,l:&p-3
ago .d
.c
&len amid &p,1,1
&p amid &p,3,l:&p-2
.d
&p equ &totallen+3+&work
&totallen seta &totallen+&len
&i seta &i-1
aif &i,^b
.e
tsc
sec
sbc #&work
tcs
inc a
phd
tcd
phb
phk
plb
mend
MACRO
&lab return &r
&lab anop
lclc &len
aif c:&r,.a
lclc &r
&r setc 0
&len setc 0
ago .h
.a
&len amid &r,2,1
aif "&len"=":",.b
&len amid &r,1,2
&r amid &r,4,l:&r-3
ago .c
.b
&len amid &r,1,1
&r amid &r,3,l:&r-2
.c
aif &len<>2,.d
ldy &r
ago .h
.d
aif &len<>4,.e
ldx &r+2
ldy &r
ago .h
.e
aif &len<>10,.g
ldy #&r
ldx #^&r
ago .h
.g
mnote 'Not a valid return length',16
mexit
.h
aif &totallen=0,.i
lda &worklen+1
sta &worklen+&totallen+1
lda &worklen
sta &worklen+&totallen
.i
plb
pld
tsc
clc
adc #&worklen+&totallen
tcs
aif &len=0,.j
tya
.j
rtl
mend
MACRO
&lab _SendRequest
&lab ldx #$1C01
jsl $E10000
MEND

1
sys/sim/test.c Normal file
View File

@ -0,0 +1 @@
#include <stdio.h> #include "sim.h" #pragma optimize 9 asm void TestHandler() { sec rtl } int main(int argc, char *argv[]) { int v,e; e = SIMVersion(&v); if (e) { printf("SIM Error Code: %d\n",e); exit(1); } printf("SIM Version Code: %04X\n",v); e = InstallIntVect(2,(unsigned long) TestHandler); if (e) { printf("(Install) SIM Error Code: %d\n",e); exit(1); } e = RemoveIntVect(2,(unsigned long) TestHandler); if (e) { printf("(Remove) SIM Error Code: %d\n",e); exit(1); } }