NEW
  AUTO 3,1
				.LIST OFF	
				.OP	65C02
				.OR	$2000
				.TF lib/libetalk
*--------------------------------------
				.INB inc/macros.i
				.INB inc/a2osx.i
				.INB inc/nic.i
				.INB inc/eth.i
				.INB inc/lib.net.i
				.INB inc/libetalk.i
*--------------------------------------
ZPFrameInPtr	.EQ ZPLIB
ZPFrameInLen	.EQ ZPLIB+2

ZPDataInPtr		.EQ ZPLIB+4
ZPDataInLen		.EQ ZPLIB+6

ZPFrameOutPtr	.EQ ZPLIB+8
ZPFrameOutLen 	.EQ ZPLIB+10

ZPDataOutPtr	.EQ ZPLIB+12
ZPDataOutLen	.EQ ZPLIB+14

ZPPtrADDR		.EQ ZPLIB+16
ZPPtrMAC		.EQ ZPLIB+18

ZPCachePtr		.EQ ZPLIB+24
ZPTmpPtr1		.EQ ZPLIB+26

*--------------------------------------
*			File Header (16 Bytes)
*--------------------------------------
CS.START		cld
				jmp (.1,x)
				.DA #$61				6502,Level 1 (65c02)
				.DA #1					BIN Layout Version 1
				.DA 0
				.DA CS.END-CS.START
				.DA 0
				.DA 0
				.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1				.DA LIB.LOAD
				.DA LIB.UNLOAD	
				.DA CFG.SET
				.DA CFG.GET
				.DA INCOMING
				.DA PULSE

				.DA AARP.CLEAR
				.DA AARP.QUERY
				.DA AARP.ADD
				.DA AARP.GetCACHE

L.IOCTL			.DA IOCTL
			
L.AARP.REQ		.DA AARP.REQ
L.AARP.REP		.DA AARP.REP

L.AARP.CACHE	.DA AARP.CACHE
*--------------------------------------
L.ETKCFG		.DA ETKCFG
				.DA 0
*--------------------------------------
LIB.LOAD		ldx RefCount
				bne .8

				jsr AARP.CLEAR
.8				inc RefCount

				clc
				rts
*--------------------------------------
LIB.UNLOAD		dec RefCount
				clc
				rts
*--------------------------------------
INCOMING		sta hFrameIn

				>PULLW ZPTmpPtr1
				ldy #S.IOCTL.BUFPTR+3
.1				lda (ZPTmpPtr1),y		Get Frame Ptr & Len
				sta ZPFrameInPtr-S.IOCTL.BUFPTR,y
				dey
				bpl .1

				ldy #S.ETH.SNAP.PROTO
				lda (ZPFrameInPtr),y
				tax
				iny
				lda (ZPFrameInPtr),y
				cmp #S.ETH.SNAP.PROTO.AARP
				bne .2
				cpx /S.ETH.SNAP.PROTO.AARP
				bne .2
				jmp	AARP.IN
.2				cmp #S.ETH.SNAP.PROTO.DDP
				bne .9
				cpx /S.ETH.SNAP.PROTO.DDP
				bne .9

				jmp DDP.IN

.9				sec
				rts
*--------------------------------------
*--------------------------------------
* A = S.EVT.F
*--------------------------------------
PULSE			and #S.EVT.F.T1SEC
				beq .9

.9				rts
*--------------------------------------
				.INB usr/src/lib/libetalk.s.aarp
				.INB usr/src/lib/libetalk.s.cfg
				.INB usr/src/lib/libetalk.s.ddp
				.INB usr/src/lib/libetalk.s.elap
				.INB usr/src/lib/libetalk.s.frm
				.INB usr/src/lib/libetalk.s.rtmp
*--------------------------------------
CS.END
*--------------------------------------
AARP.REQ		.HS 090007FFFFFF		S.ETH.DSTMAC
AARP.REQ.SRCMAC	.BS 6
				.DA #0,#36				S.ETH.802.3.LENGTH
				.HS AA					S.ETH.802.2.DSTSAP
				.HS AA					S.ETH.802.2.SRCSAP
				.HS 03					S.ETH.802.2.CTRL
				.HS 00.00.00.80.F3		S.ETH.SNAP.PROTO
				.HS 00.01.80.9B.06.04
				.HS 0001				Request
AARP.REQ.SHA	.BS 6
AARP.REQ.SPA	.BS 4
AARP.REQ.THA	.BS 6
AARP.REQ.TPA	.BS 4
				.BS AARP.REQ+60-*
AARP.REQ.LEN	.EQ 60
*--------------------------------------
AARP.REP		.EQ *
AARP.REP.DSTMAC	.BS 6
AARP.REP.SRCMAC	.BS 6
				.DA #0,#36				S.ETH.802.3.LENGTH
				.HS AA					S.ETH.802.2.DSTSAP
				.HS AA					S.ETH.802.2.SRCSAP
				.HS 03					S.ETH.802.2.CTRL
				.HS 00.00.00.80.F3		S.ETH.SNAP.PROTO
				.HS 00.01.80.9B.06.04
				.HS 0002				Response
AARP.REP.SHA	.BS 6
AARP.REP.SPA	.BS 4
AARP.REP.THA	.BS 6
AARP.REP.TPA	.BS 4
				.BS AARP.REP+60-*
AARP.REP.LEN	.EQ 60
*--------------------------------------
RefCount		.BS 1
IOCTL			.BS S.IOCTL
hFrameIn		.BS 1
ETKCFG			.BS S.ETKCFG
AARP.CACHE		.BS K.AARPCACHE.SIZE*S.AARPCACHE
AARP.TmpCache	.BS S.AARPCACHE
TmpDWord		.BS 4
TmpOffset		.BS 2
*--------------------------------------
MAN
SAVE usr/src/lib/libetalk.s
ASM
