mac-rom/DeclData/DeclNet/AtalkMacros.a

398 lines
12 KiB
Plaintext
Raw Permalink Normal View History

;
; File: ATMacros.a
;
; Contains: Assembly macros used by AppleTalk
;
; Written by: Mike Shoemaker
;
; Copyright: <09> 1990-1993 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <SM2> 12/13/93 PN Roll in KAOS and Horror to add support for Malcom and AJ
; <1> 10/6/92 GDW New location for ROMLink tool.
; <SM2> 6/22/92 mal Added some labels to VERSION macro and added VMImmumebit equate.
; <SM3> 5/4/92 CSS moved to ethernet folder to get build to work
; <2> 3/19/92 kc Roll in Terror/Horror Changes.
; <SM1> 2/??/92 kc first checked in
; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; Pre-SuperMario ROM comments begin here.
; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <H2> 01/22/92 jmp (BG,Z2) Added some additional macros for new ethernet changes.
; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; Pre-Horror ROM comments begin here.
; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <T1> 3/27/91 jmp first checked in
; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; Pre-TERROR ROM comments begin here.
; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <8> 1/30/91 mbs cj,#82011: Move years after company name in copyright message.
; <7> 12/17/90 mbs The ALIGN directive does not work for the IIGS assembler. Use
; IF ENDIF to generate an extra dc.b 0 if necessary. Yes except
; for the ALIGN, the entire macro worked under the IIGS
; assembler!.
; <6> 11/28/90 mbs In the VERSION macro, when the release stage is 'released', pad
; the version with two trailing spaces so that the length remains
; the same when changing from an f1 to a Golden Master build.
; <5> 11/26/90 mbs Did not handle 3-digit major version number
; <4> 11/12/90 mbs Steven pointed out that verUs is zero, not 1.
; <3> 11/10/90 mbs Add optional parameter to set the label at the front of the
; version structure.
; <2> 11/09/90 mbs Add 'v' in front of version number in long string
; 11/9/90 mbs First written
;
; To Do:
;
; WARNING -- CAN'T USE IF (__IncludingATalkMacros__ == 'UNDEFINED') because
; 6502 assember barfs and doesn't include the file.
PRINT PUSH, OFF
;==========================================================================================
; VERSION
;
; USAGE:
; VERSION <Name>, <Major Version>, <Minor Version>,
; <release stage>, <Revision level>,
; <Copyright Years> [, <Engineering Suffix> [, <Version Label> ] ]
;
; The name field should be quoted if more than one word.
; The copyright years field may or may not be quoted. The macro works either way
; It is OK to leave the engineering suffix field empty.
;
; The start of the version information is given the Label 'VersionInfo', unless
; you specify the last parameter; then it will be used. It must not be quoted.
;
; Example for EtherTalk 1.2a3q1 copyrighted 1987-1990
;
; VERSION 'EtherTalk', 1, 2, 0, alpha, 3, '1987-1990', 'q1'
;==========================================================================================
ATM_development EQU $20 ; These are used in the 3rd byte of the 4-byte version #
ATM_alpha EQU $40 ; .. to indicate release stage
ATM_beta EQU $60
ATM_final EQU $80
ATM_release EQU $80
ATM_verUS EQU 0
MACRO
VERSION &sName, &nMajor, &nMinor, &nBug, \
&sStage, &nRevision, &sCopyright, &sEngr='', &sLabel0=VersionInfo,&sLabel1=End
&sLabel0 ;Make label for this version information
LCLA &nStage ;Numeric representation of stage
LCLC &cStage ;Character representation of stage
LCLA &nPadBytes ;Add padding at end of record to <K2>
;allow room for expansion if we <K2>
;have to add bug release digits <K2>
;to the version # <K2>
LCLC &StrSetting ;To save current string setting
&StrSetting SETC &SETTING('STRING') ;Save current string setting
STRING PASCAL ;Set string state to Pascal
;
; Do some error checking
;
IF &UPCASE(&sStage)='ALPHA' THEN
&nStage SETA ATM_alpha
&cStage SETC 'a'
ELSEIF &UPCASE(&sStage)='BETA' THEN
&nStage SETA ATM_beta
&cStage SETC 'b'
ELSEIF &UPCASE(&sStage)='DEVELOPMENT' THEN
&nStage SETA ATM_development
&cStage SETC 'd'
ELSEIF &UPCASE(&sStage)='FINAL' THEN
&nStage SETA ATM_final
&cStage SETC 'f'
ELSEIF &UPCASE(&sStage)='RELEASE' THEN
&nStage SETA ATM_release
&cStage SETC 'x'
ELSE
AERROR 'The stage parameter to VERSION must be: development, alpha, beta, final or release'
ENDIF
IF (&nMinor > 15) THEN
AERROR 'The Minor version must be less than 16'
ENDIF
IF (&nBug > 15) THEN
AERROR 'The Bug fix version must be less than 16'
ENDIF
;
; Generate the 4-byte version numbers
;
dc.b &nMajor ;Major version number
dc.b (&nMinor * 16) + &nBug ;Build 2nd byte of version
dc.b &nStage, &nRevision ;stage and revision level
;
; Generate the integer country code
;
dc.w ATM_verUS ;Country Code
;
; Build Version string from major/minor version string
;
LCLC &lShortVer
;
; Make 1st digit of version string
;
IF (&nMajor >= 100) THEN
&lShortVer SETC &CONCAT(&CHR(&nMajor / 100 + $30), \
&CHR((&nMajor MOD 100) / 10 + $30), \
&CHR(&nMajor MOD 10 + $30))
ELSE
IF (&nMajor >= 10) THEN
&lShortVer SETC &CONCAT(&CHR(&nMajor / 10 + $30), &CHR(&nMajor MOD 10 + $30))
ELSE
&lShortVer SETC &CHR(&nMajor + $30)
ENDIF
ENDIF
;
; Append 2nd digit of version number (ie: 1.0)
;
IF (&nMinor >= 10) THEN
&lShortVer SETC &CONCAT(&lShortVer,'.',&CONCAT(&CHR(&nMinor / 10 + $30), &CHR(&nMinor MOD 10 + $30)))
ELSE
&lShortVer SETC &CONCAT(&lShortVer,'.',&CHR(&nMinor + $30))
ENDIF
;
; Append third digit of version number if non-zero (ie: 1.0.2). If zero, leave <K2>
; room for the extra characters at the end of the record <K2>
;
IF (&nBug <> 0) THEN
&nPadBytes SETA 0 ; Will not need padding <K2>
IF (&nBug >= 10) THEN
&lShortVer SETC &CONCAT(&lShortVer,'.',&CONCAT(&CHR(&nBug / 10 + $30), &CHR(&nBug MOD 10 + $30)))
ELSE
&lShortVer SETC &CONCAT(&lShortVer,'.',&CHR(&nBug + $30))
ENDIF
ELSE
&nPadBytes SETA 1 ; Leave room for padding <K2>
ENDIF
; Append stage letter and revision if not a release version.
; For release version, append two spaces. This way the string does not change length
; between an 'f1' build and a GM build.
IF (&cStage <> 'x') THEN
&lShortVer SETC &CONCAT(&lShortVer,&cStage)
IF (&nRevision >= 10) THEN
&lShortVer SETC &CONCAT(&lShortVer,&CONCAT(&CHR(&nRevision / 10 + $30), &CHR(&nRevision MOD 10 + $30)))
ELSE
&lShortVer SETC &CONCAT(&lShortVer,&CHR(&nRevision + $30))
ENDIF
ELSE
&lShortVer SETC &CONCAT(&lShortVer, ' ') ; Append two spaces if release
ENDIF
;
; Emit the short string
;
dc.b '&lShortVer'
; ALIGN directive doesn't exist on IIGS assembler so do it the hard way...
IF ((&LEN(&lShortVer) +1) MOD 2) = 1 THEN
dc.b 0
ENDIF
;
; Trim the beginning and ending quotes from the name, copyright years, and
; engineering suffix if present
;
LCLC &lName
LCLC &lCopyright
LCLC &lEngr
IF &SUBSTR(&sName, 1, 1) = &CHR($27) THEN
&lName SETC &SUBSTR(&sName, 2, &LEN(&sName) - 2)
ELSE
&lName SETC &sName
ENDIF
IF &SUBSTR(&sCopyright, 1, 1) = &CHR($27) THEN
&lCopyright SETC &SUBSTR(&sCopyright, 2, &LEN(&sCopyright) - 2)
ELSE
&lCopyright SETC &sCopyright
ENDIF
IF &SUBSTR(&sEngr, 1, 1) = &CHR($27) THEN
&lEngr SETC &SUBSTR(&sEngr, 2, &LEN(&sEngr) - 2)
ELSE
&lEngr SETC &sEngr
ENDIF
;
; Build the long string
;
LCLC &lLongVer ; Define a local variable to hold it
&lLongVer SETC &CONCAT(&lName,' v',&lShortVer,&lEngr,'; <20> Apple Computer, Inc. ',&lCopyright)
;
; Emit the long string
;
LCLC &sLongVerLabel ;<K2 start>
LCLC &sLongVerLabelEnd ;
&sLongVerLabel SETC &CONCAT(&sLabel0, 'LongStr') ;
&sLongVerLabel ;
dc.b '&lLongVer' ;
IF ((&LEN(&lLongVer) +1) MOD 2) = 1 THEN ; Align things
dc.b 0
ENDIF
;
; If this is an "xx.x" release rather than an "xx.x.x" release, leave room so that
; if we have to rev the version # to x.x.x, the size of the record will not change.
;
IF (&nPadBytes) THEN
dc.b 0,0,0,0
ENDIF
&sLongVerLabelEnd SETC &CONCAT(&sLongVerLabel, 'End')
&sLongVerLabelEnd
;
; Clean up and we're done
;
LCLC &sEndLabel ;Make label for end of version information
&sEndLabel SETC &CONCAT(&sLabel0, &sLabel1)
&sEndLabel
STRING &StrSetting ;Restore string setting
ENDM
EJECT
;==========================================================================================
; SCCLOCKOUT
;
; Macro for disabling interrupts.
;==========================================================================================
SRIntMaskBits EQU $0700 ; The 3 interrupt level bit in the SR
SRIntMaskBitsCMP EQU $F8FF ; The 3 interrupt level bit in the SR
SRIntLevel6 EQU $0600 ; Level 6 interrupt mask
SRIntLevel6MASK EQU $FEFF ; Level 6 interrupt AND value
SRIntLevel5MASK EQU $FDFF ; Level 5 interrupt AND value <K2>
MACRO
_SCCLOCKOUT
ORI.W #SRIntMaskBits,SR ; Set all of the INT bits
ANDI.W #SRIntLevel6MASK,SR ; Set to priority 6
ENDM
;==========================================================================================
; _SETINTMASK
;
; Macro for setting the interrupt level to an arbitrary level. Pass the level in
; a Data register.
;==========================================================================================
MACRO
_SETINTMASK &sReg
move.w SR,-(SP)
andi.w #SRIntMaskBitsCMP,(SP)
or.w &sReg,(SP)
move.w (SP)+,SR
ENDM
;==========================================================================================
; VSCCEnable
;
; Macro for disabling interrupts.
; Pass address register holding MPP vars, and a temporary Data register
;==========================================================================================
MACRO
_VSCCENABLE &sMPPVarsReg, &tmpReg
MOVE.W SR, &tmpReg
ANDI.W #SRIntMaskBitsCMP,&tmpReg ; Clear all of the INT bits
EORI.W #$2000, &tmpReg ; Toggle the 2000 bit
move.w vSCCEnable(&sMPPVarsReg),-(SP) ; Push vscc enable
EOR.W &tmpReg, (SP) ; Or in the int bits (and toggles 2000)
; Stupid machine won't let memory be the source on an XOR instruction
MOVE.W (SP)+,SR ; Set SR
ENDM
;==========================================================================================
; These Macros & Equates are used to call the multipurpose function dispatcher in the
; Lap Manager. None of these functionn have jack to do with the Lap Manager, but they
; provide a way for code to get the functions without having to link with the library
; containing them. Of course, they require that a Lap Manager be present.
;==========================================================================================
;
; Macro used in following macros
;
MACRO
_L21Common &nVal
LCLC &cLabel ; Used to make a semi-unique label
&cLabel SETC &CONCAT('@L21Ret',&nVal)
pea &cLabel ; Want to return to here
move.l LAPMgrPtr,D0 ; Ptr to Lap Manager
add.l #LAPMgrCall,D0 ; Ptr to dispatch entry point
move.l D0,-(SP) ; Put on stack
move.l #((&nVal << 16) + LInt21Dispatch),D0
rts ; Call Lap Manager
&cLabel
ENDM
;
; Macros to call Lap Manager Dispatch routines
;
; Returns non-zero in D0.L if Extensions are disabled at boot time. Always returns zero on
; System 6. Sets condition codes
MACRO
_LExtensionsDisabled
_L21Common L21ExtensionsDisabled
ENDM
; pascal Handle GetBestResource(OSType theType, short theID)
MACRO
_LGetBestResource
_L21Common L21GetBestResource
ENDM
; pascal Boolean TrapAvailable(short theTrap)
MACRO
_LTrapAvailable
_L21Common L21TrapAvailable
ENDM
;==========================================================================================
; New Macros go here
;==========================================================================================
;
; MACROS for SNMP counters <K2>
;
MACRO
_IncrCount &SNMPCounter
ADDQ.L #1, SNMPVars.&SNMPCounter(A2) ; increment whatever SNMP counter
ENDM
VMImmuneBit EQU 0 ; bit in driver DCE flags to tell VM to leave paramblocks alone
PRINT POP
; END ATMacros.a