diff --git a/Driver/baxnet/README b/Driver/baxnet/README index 82ff4cc..b9e8b62 100644 --- a/Driver/baxnet/README +++ b/Driver/baxnet/README @@ -12,6 +12,6 @@ This package contains network drivers for the following hardware: - Vampire500/600 with ENC28J60 module connected to the SD-card slot - Vampire500V2+ with ENC28J60 module connected to the expansion port -Full source code is included (GPL). Please refer to README.sdnet and +Full source code is included. Please refer to README.sdnet and README.enc for installation and operation instructions diff --git a/Driver/baxnet/README.enc b/Driver/baxnet/README.enc index 67d0e0d..8c925f6 100644 --- a/Driver/baxnet/README.enc +++ b/Driver/baxnet/README.enc @@ -63,6 +63,8 @@ PRIORITY=PRI/K/N,BPS/K/N,MTU/K/N,FULLDUPLEX/S,FLOWCONTROL/S,TIMER/K/N,MULTICAST/ Changelog: ---------- +1.93 - recompiled using SAS/C, now 1kB smaller + 1.91 - first Beta of completely rewritten driver - support for concurrent IP stacks - faster handling of statistics diff --git a/Driver/baxnet/README.sdnet b/Driver/baxnet/README.sdnet index 70b5816..13c126f 100644 --- a/Driver/baxnet/README.sdnet +++ b/Driver/baxnet/README.sdnet @@ -2,8 +2,9 @@ SDNet - A SANA-II driver for ENC28J60 10BaseT ethernet modules Copyright (C) 2016-2018 Henryk Richter -This driver is supposed to support ENC28J60 modules hooked up to the MicroSD -slot of Vampire 500/600 cards or the expansion port of Vampire 500V2+ cards. +This driver is supposed to support ENC28J60 modules hooked up to the +MicroSD slot of Vampire 500/600 cards (sdnet.device) or the +expansion port of Vampire 500V2+ cards (v2expeth.device). Installation: @@ -24,14 +25,14 @@ in the ROM of Vampire Cards since the Gold2.5 release. Also, make sure that the Vampire SD Card driver (sagasd.device) is not present in the system or at least inactive when using sdnet.device. Both pieces of software bang the same hardware registers. v2expeth.device may be used safely -in conjunction with the SD card driver. +in conjunction with the SD card driver. Vampire500 Expansion port Hardware ----------------------------------- Please see http://wiki.apollo-accelerators.com/doku.php/expansionport for -guidance. +cabling guidance. MicroSD Slot Hardware: @@ -67,7 +68,7 @@ looking at the connectors) to the ENC28J60 module: | 2 ---- /CS -------------------- /CS | 1 ---- /INT -- __________ -- /INT ------ ------------- \_| 3.3 kOhm |_/ - \___| `----------´ + \___| `----------´ As there is a myriad of ENC28J60 modules available, the naming scheme on a particular board might differ. Please be aware the some of the boards @@ -151,13 +152,16 @@ NOSPECIALSTATS/S,PRIORITY=PRI/K/N,BPS/K/N,MTU/K/N,FULLDUPLEX/S,SPISPEED/K/N, TIMER/K/N,MULTICAST/S SPISPEED - SPI clock divider (1-10, default 2), controls maximum - clock of SPI bus. Actual I/O clock is Core_Clock/(3+SPISPEED). + clock of SPI bus. Actual I/O clock is Core_Clock/(2+SPISPEED). FULLDUPLEX - change Ethernet module into full duplex mode, - caution: requires manual configuration of duplex mode - on the switch, too. + caution: requires MANUAL configuration of duplex mode + on the SWITCH, TOO! Otherwise you get a heavy + amount of collisions and bad performance! - PRIORITY - server task priority (default 1) + PRIORITY - server task priority (default 1). It depends on the TCP/IP stack + whether a priority higher than 1 gives performance benefits. I'd + suggest to leave the setting at default, at least for Roadshow. BPS - bit per seconds for statistics purposes @@ -169,13 +173,29 @@ TIMER/K/N,MULTICAST/S MULTICAST - obsolete, kept for config file backwards compatibility with old driver - example (useful for DSL via PPPoE on x11 core with AmiTCP): + INTERRUPT - (V2EXPETH ONLY!), from Gold 2.10 release and v2expeth.device + 1.94 onwards, you can enable the interrupts and avoid polling. + It is suggested to disable the timer in that case. + See below for an example + + example1 (useful for DSL via PPPoE on x11 core with AmiTCP): echo "MTU=1492 SPISPEED=1 PRIORITY=6" >ENVARC:sana2/sdnet.config + example2 (V500 expansion port, Gold 2.10 or later, interrupt driven): + echo "TIMER=0 INTERRUPT SPISPEED=1" >ENVARC:sana2/v2expeth.config + Changelog: ---------- +1.95 - workaround for MiamiDX bugs, 32 Bit Buffer copy routines could not be + used safely with it. + +1.94 - implemented interrupts for modules connected to V500v2+ expansion port + +1.93 - minor restructuring, SAS/C makefile added + - smaller binaries (functionally identical) + 1.92 - workaround for linker issue, version bump 1.91 - minor cleanups diff --git a/Driver/baxnet/bin/enc624j6net.device b/Driver/baxnet/bin/enc624j6net.device index a4b1170..ec65c6a 100755 Binary files a/Driver/baxnet/bin/enc624j6net.device and b/Driver/baxnet/bin/enc624j6net.device differ diff --git a/Driver/baxnet/bin/enc624j6net.device_68000 b/Driver/baxnet/bin/enc624j6net.device_68000 index 7b18830..66b079c 100755 Binary files a/Driver/baxnet/bin/enc624j6net.device_68000 and b/Driver/baxnet/bin/enc624j6net.device_68000 differ diff --git a/Driver/baxnet/bin/sdnet.device b/Driver/baxnet/bin/sdnet.device index 8b029ee..accb983 100755 Binary files a/Driver/baxnet/bin/sdnet.device and b/Driver/baxnet/bin/sdnet.device differ diff --git a/Driver/baxnet/bin/sdnettest b/Driver/baxnet/bin/sdnettest new file mode 100644 index 0000000..aec16c4 Binary files /dev/null and b/Driver/baxnet/bin/sdnettest differ diff --git a/Driver/baxnet/bin/v2expeth.device b/Driver/baxnet/bin/v2expeth.device index d6bc674..6f52051 100755 Binary files a/Driver/baxnet/bin/v2expeth.device and b/Driver/baxnet/bin/v2expeth.device differ diff --git a/Driver/baxnet/bin/v2expethtest b/Driver/baxnet/bin/v2expethtest new file mode 100644 index 0000000..7df03b9 Binary files /dev/null and b/Driver/baxnet/bin/v2expethtest differ diff --git a/Driver/baxnet/source/Common.mk b/Driver/baxnet/source/Common.mk index 2f1e7d0..32a9a79 100644 --- a/Driver/baxnet/source/Common.mk +++ b/Driver/baxnet/source/Common.mk @@ -19,7 +19,7 @@ # ############################################################################### # debug = 1 will include string debugging for terminal/sushi/sashimi -debug = 1 +debug = 0 # compiler_vcc = 1 will trigger VBCC, else GCC compiler_vcc = 1 diff --git a/Driver/baxnet/source/Makefile.enc b/Driver/baxnet/source/Makefile.enc index ab837d8..b0eae30 100644 --- a/Driver/baxnet/source/Makefile.enc +++ b/Driver/baxnet/source/Makefile.enc @@ -19,9 +19,9 @@ # Date, version, extra objects to build # ############################################################################### -DEVICEVERSION=1 -DEVICEREVISION=92 -DEVICEDATE=10.06.2018 +#DEVICEVERSION=1 +#DEVICEREVISION=95 +#DEVICEDATE=08.09.2018 SUBDIR=enc624j6net ASMOBJECTS = $(SUBDIR)/enc624j6l.o $(SUBDIR)/intervaltimer.o diff --git a/Driver/baxnet/source/Makefile.sdnet b/Driver/baxnet/source/Makefile.sdnet index 2d493b1..ac41e88 100644 --- a/Driver/baxnet/source/Makefile.sdnet +++ b/Driver/baxnet/source/Makefile.sdnet @@ -5,6 +5,8 @@ # author: Henryk Richter # # concept: +# this makefile is intended mainly for cross compilation, +# although building on AmigaOS works (see Common.mk) # # tools required: # - vbcc or m68k-amigaos-gcc (Default: gcc) @@ -13,6 +15,7 @@ # - system headers (default: /opt/amigaos-68k/os-include, see Common.mk) # # porting: +# see smakefile for native building using SAS/C # ############################################################################### @@ -20,10 +23,10 @@ # Name, version # ############################################################################### -DEVICEVERSION=1 -DEVICEREVISION=92 -DEVICEDATE=27.06.2018 -DEVICEEXTRA=Beta +#DEVICEVERSION=1 +#DEVICEREVISION=95 +#DEVICEDATE=08.09.2018 +#DEVICEEXTRA=Beta ASMOBJECTS = $(SUBDIR)/vampuuid.o $(SUBDIR)/intervaltimer.o $(SUBDIR)/enc28j60.o $(SUBDIR)/enc28j60l.o SUBDIR=sdnet @@ -33,11 +36,16 @@ DEVICEID=sdnet.device DEFINES = # -DPROTO_V2EXPNET ASMDEFS = # -DPROTO_V2EXPNET CPU = 68020 +TESTTOOL = sdnettest DEVICEID2=v2expeth.device DEFINES2 = -DPROTO_V2EXPNET ASMDEFS2 = -DPROTO_V2EXPNET CPU2 = 68020 +TESTTOOL2 = v2expethtest + +# additional housekeeping +EXTRACLEAN = $(SUBDIR)/sdnettest.o $(SUBDIR)/sdnettest.2o ############################################################################### # import generic ruleset @@ -46,3 +54,15 @@ CPU2 = 68020 include Common.mk +############################################################################### +# ruleset for test tools +# +############################################################################### + +$(TESTTOOL) : $(ASMOBJECTS) $(SUBDIR)/sdnettest.o + $(LINKEXE) $(LDFLAGS) -o $@ $(SUBDIR)/sdnettest.o $(ASMOBJECTS) + +$(TESTTOOL2) : $(ASMOBJECTS) $(SUBDIR)/sdnettest.2o + $(LINKEXE) $(LDFLAGS) -o $@ $(SUBDIR)/sdnettest.2o $(ASMOBJECTS) + + diff --git a/Driver/baxnet/source/debug.h b/Driver/baxnet/source/debug.h index 33fd77d..30947cc 100644 --- a/Driver/baxnet/source/debug.h +++ b/Driver/baxnet/source/debug.h @@ -11,7 +11,6 @@ #define _INC_DEBUG_H #ifdef DEBUG -#include extern void KPrintF(char *, ...), KGetChar(void); #define D(_x_) do { KPrintF("%s:%ld:",__FILE__,__LINE__); KPrintF _x_; } while(0) diff --git a/Driver/baxnet/source/device.c b/Driver/baxnet/source/device.c index fa7c75b..ac14f9e 100644 --- a/Driver/baxnet/source/device.c +++ b/Driver/baxnet/source/device.c @@ -27,11 +27,56 @@ #include #include #include +#ifdef HAVE_VERSION_H +#include "version.h" +#endif +/* NSD support is optional */ +#ifdef NEWSTYLE +#include +#include /* new extension, code can be built without this include (but also without ext query then...) */ + +const UWORD dev_supportedcmds[] = { + NSCMD_DEVICEQUERY, + CMD_READ, + CMD_WRITE, + S2_READORPHAN, + S2_BROADCAST, + S2_MULTICAST, + S2_ONEVENT, + S2_ONLINE, + S2_OFFLINE, + S2_CONFIGINTERFACE, + S2_GETSTATIONADDRESS, + S2_DEVICEQUERY, + S2_TRACKTYPE, + S2_UNTRACKTYPE, + S2_GETTYPESTATS, + S2_GETGLOBALSTATS, + S2_ADDMULTICASTADDRESS, + S2_DELMULTICASTADDRESS, +#ifdef S2_DEVICEQUERYEXT + S2_DEVICEQUERYEXT, +#endif + 0 +}; + +const struct NSDeviceQueryResult NSDQueryAnswer = { + 0, + 16, /* up to SupportedCommands (inclusive) */ + NSDEVTYPE_SANA2, + 0, /* subtype */ + (UWORD*)dev_supportedcmds +}; +#endif + #include "device.h" #include "hw.h" #include "macros.h" + + + ASM SAVEDS struct Device *DevInit( ASMR(d0) DEVBASEP ASMREG(d0), ASMR(a0) BPTR seglist ASMREG(a0), ASMR(a6) struct Library *_SysBase ASMREG(a6) ) @@ -151,8 +196,11 @@ ASM SAVEDS LONG DevOpen( ASMR(a1) struct IOSana2Req *ioreq ASMREG(a1), (struct TagItem *)ioreq->ios2_BufferManagement))); dbm->dbm_CopyFromBuffer = (BMCALL)((void (*)())(GetTagData(S2_CopyFromBuff, 0, (struct TagItem *)ioreq->ios2_BufferManagement))); -#if 0 - dbm->dbm_CopyToBuffer32 = (0); /* DEBUG */ + + /* v1.95: disable CopyToBuffer32 due to problems with MiamiDX */ + /* MiamiDX requires byte count to be a multiple of 4 */ +#if 1 + dbm->dbm_CopyToBuffer32 = (0); dbm->dbm_CopyFromBuffer32 = (0); #else dbm->dbm_CopyToBuffer32 = (BMCALL)((void (*)())(GetTagData(S2_CopyToBuff32, 0, @@ -236,7 +284,13 @@ ASM SAVEDS BPTR DevClose( ASMR(a1) struct IOSana2Req *ioreq ASMREG(a1), db->db_Units[unit].du_OpenCount--; ReleaseSemaphore( &db->db_Units[unit].du_Sem ); - + + /* clear flags */ + if( !(db->db_Units[unit].du_OpenCount) ) + { + db->db_Units[unit].du_Flags &= ~(DUF_EXCLUSIVE|DUF_PROMISC); + } + /* give server time to offline down the hardware */ if( (db->db_ServerProc) && !(db->db_Units[unit].du_OpenCount) && @@ -517,6 +571,31 @@ ASM SAVEDS VOID DevBeginIO( ASMR(a1) struct IOSana2Req *ioreq ASMREG(a1), ioreq->ios2_Req.io_Error = S2ERR_NO_ERROR; ioreq->ios2_WireError = S2WERR_GENERIC_ERROR; break; +#ifndef NSCMD_DEVICEQUERY +#warning "Building without NSD support" +#else + case NSCMD_DEVICEQUERY: + { + struct IOStdReq *stdrq = (struct IOStdReq *)ioreq; + + if( (!stdrq->io_Data) || (stdrq->io_Length < sizeof( NSDQueryAnswer ) ) ) + { + ioreq->ios2_Req.io_Error = IOERR_BADLENGTH; + } + else + { + CopyMem( (void*)&NSDQueryAnswer, stdrq->io_Data, sizeof( NSDQueryAnswer ) ); + stdrq->io_Actual = sizeof( NSDQueryAnswer ); + ioreq->ios2_Req.io_Error = 0; + } + } + break; + /* query contents may ask for live data: handle in server.c */ + case S2_DEVICEQUERYEXT: + dbForwardIO( db, ioreq ); + ioreq = (0); + break; +#endif case CMD_RESET: case CMD_UPDATE: @@ -525,7 +604,8 @@ ASM SAVEDS VOID DevBeginIO( ASMR(a1) struct IOSana2Req *ioreq ASMREG(a1), case CMD_START: case CMD_FLUSH: ioreq->ios2_Req.io_Error = IOERR_NOCMD; - ioreq->ios2_WireError = S2WERR_GENERIC_ERROR; + /* we might not get a SANA-II request at this point, don't assume anything about struct */ + /* ioreq->ios2_WireError = S2WERR_GENERIC_ERROR; */ break; case S2_ADDMULTICASTADDRESS: diff --git a/Driver/baxnet/source/deviceheader.c b/Driver/baxnet/source/deviceheader.c index 04994dc..eb9a74f 100644 --- a/Driver/baxnet/source/deviceheader.c +++ b/Driver/baxnet/source/deviceheader.c @@ -15,6 +15,9 @@ #include #include #include +#ifdef HAVE_VERSION_H +#include "version.h" +#endif #include "compiler.h" #include "device.h" @@ -32,7 +35,7 @@ extern const char DeviceName[]; extern const char DeviceVersionString[]; extern const APTR DeviceInitTab[]; -const struct Resident _00RomTag = { +static const struct Resident _00RomTag = { RTC_MATCHWORD, ( struct Resident* ) &_00RomTag, ( struct Resident* ) &_00RomTag + 1, diff --git a/Driver/baxnet/source/deviceinit.c b/Driver/baxnet/source/deviceinit.c index de66062..010dcad 100644 --- a/Driver/baxnet/source/deviceinit.c +++ b/Driver/baxnet/source/deviceinit.c @@ -12,6 +12,10 @@ #include #include #include + +#ifdef HAVE_VERSION_H +#include "version.h" +#endif #include "device.h" #include "hw.h" #include "macros.h" @@ -24,7 +28,8 @@ #define DEVICEEXTRA #endif -const char DeviceVersionString[] = "$VER: " xstr(DEVICENAME) " " xstr(DEVICEVERSION) "." xstr(DEVICEREVISION) xstr(DEVICEEXTRA) " (" xstr(DEVICEDATE) ")"; +static const char _DeviceVersionString[] = "$VER: " xstr(DEVICENAME) " " xstr(DEVICEVERSION) "." xstr(DEVICEREVISION) xstr(DEVICEEXTRA) " (" xstr(DEVICEDATE) ")"; +const char *DeviceVersionString = (const char *)_DeviceVersionString; const char DeviceName[] = xstr(DEVICENAME); @@ -57,7 +62,7 @@ struct DeviceInitData INITBYTE( STRUCTOFFSET(Library,lib_Flags), LIBF_SUMUSED|LIBF_CHANGED ), INITWORD( STRUCTOFFSET(Library,lib_Version), DEVICEVERSION ), INITWORD( STRUCTOFFSET(Library,lib_Revision), DEVICEREVISION ), - 0x80, (UBYTE) ((LONG)STRUCTOFFSET(Library,lib_IdString)), (ULONG) &DeviceVersionString[6], + 0x80, (UBYTE) ((LONG)STRUCTOFFSET(Library,lib_IdString)), (ULONG) &_DeviceVersionString[6], (ULONG) 0 }; diff --git a/Driver/baxnet/source/enc624j6net/enc624j6l.asm b/Driver/baxnet/source/enc624j6net/enc624j6l.asm index 675e325..76fe790 100755 --- a/Driver/baxnet/source/enc624j6net/enc624j6l.asm +++ b/Driver/baxnet/source/enc624j6net/enc624j6l.asm @@ -18,10 +18,11 @@ ; - RXSTART_INIT = $0c00 -> currently $2000 due to previous location bug ; -; incdir Temp:Amiga/src/Zorro-LAN-IDE.git/Driver/enc624j6net/ + incdir src:baxnet/trunk/source/ + ;Temp:Amiga/src/Zorro-LAN-IDE.git/Driver/enc624j6net/ include "enc624j6net/registers.i" include "enc624j6net/macros.i" - include lvo/exec_lib.i + ; enable debugging code block DEBUG EQU 1 ; @@ -34,7 +35,7 @@ ADD_4RX EQU 1 ;add 4 to valid RX size (fake CRC), fixes shapeshifter RAW treatme PSTART_INIT EQU $0BF0 ; 16 Bytes private storage for driver PSTOP_INIT EQU $0BFF ; (see below for definitions) -RXSTART_INIT EQU $2000 ; start of RX buffer, room for 14 packets +RXSTART_INIT EQU $0C00 ; start of RX buffer, room for 14 packets RXSTOP_INIT EQU $5fff ; end of RX buffer TXSTART_INIT EQU $0000 ; start of TX buffer, room for 2 packets @@ -109,8 +110,9 @@ ENC_BOARDID EQU 123 ;ZII-IDE-LAN-CP XDEF _enc624j6l_DisableInterrupt XDEF _enc624j6l_EnableGlobalInterrupt XDEF _enc624j6l_DisableGlobalInterrupt - XDEF _enc624j6l_broadcast_multicast_filter + XDEF _enc624j6l_bc_mc_filter + XDEF _enc624j6l_ReadPHY ; ; System includes ; @@ -220,6 +222,11 @@ opendos: tst.l d0 ble error + move.l _boardbase(pc),a0 +; moveq #PHSTAT1,d0 ;AUTONEG DONE, forced speeds/duplex + moveq #PHSTAT3,d0 ;AUTONEG DONE, forced speeds/duplex + bsr _enc624j6l_ReadPHY + ;---------- transmit test stuff --------------- moveq #100,d2 .txtest: @@ -530,7 +537,7 @@ _enc624j6l_Init: moveq #ECON1_RXEN,d0 ;no RX, my dear (yet) CLRREG ECON1,a0,d0 ; - ;set clock out frequency (see defines above) + ;33.333Mhz clock out frequency (see defines above) move.w #CLOCK_DEF_CLR,d0 ;clr mask CLRREG ECON2,a0,d0 move.w #CLOCK_DEF_SET,d0 ;set mask @@ -545,7 +552,7 @@ _enc624j6l_Init: WRITEREG ERXST,a0,d0 ;set RX start pointer (end will be $5fff) WRITEREG PNextPacket,a0,d0 ;set user read pointer - bsr _enc624j6l_broadcast_multicast_filter ;in: A0/D1, out: D0 + bsr _enc624j6l_bc_mc_filter ;in: A0/D1, out: D0 move #RXSTOP_INIT&$fffe,d0 WRITEREG ERXTAIL,a0,d0 ;tail pointer in buffer = rx-2, wraparound @@ -604,7 +611,7 @@ _enc624j6l_Init: ; D1 - init flags ;out: D0 >0 = OK ; <=0 = FAIL -_enc624j6l_broadcast_multicast_filter: +_enc624j6l_bc_mc_filter: move.l a0,d0 beq.s .rts @@ -826,7 +833,7 @@ _enc624j6l_DisableInterrupt: moveq #0,d0 ;magic trick: the board enables Interrupts lea $4000(a0),a0 - move.w d0,($4000,a0) + move.w d0,$4000(a0) ;was $4002 lea -$4000(a0),a0 ;WRITEREG $8000,a0,d0 ;only with this "sesame" @@ -892,14 +899,18 @@ _enc624j6l_IntServer_List: bra.s .intdis_loop .boardsdone: - ifne 1 + ;faster: get from extended Driver board list instead from ZII/ZIII card + ifne 1 - move.l (a6)+,d0 ;Sigtask + move.l (a6)+,d0 ;SigTask beq.s .rts - move.l d0,a1 - + + move.l (a6)+,d1 ;SigBit + move.l d0,a1 ;SigTask + + move.l (a6)+,a6 ;ExecBase moveq #0,d0 - move.l (a6)+,d1 ;Sigbit + bset d1,d0 else @@ -915,10 +926,11 @@ _enc624j6l_IntServer_List: READREG PSigBit,a0,d1 ;get signal bit bset d1,d0 ;signal mask + move.l 4.w,a6 + endc - move.l 4.w,a6 - jsr _LVOSignal(a6) + jsr _LVOSignal(a6) .rts move.l (sp)+,a6 @@ -1083,8 +1095,9 @@ _enc624j6l_HaveRecv: move.l a0,d0 beq.s .err - READREG ESTAT,a0,d0 - and.l #$ff,d0 ;ESTAT_PKTCNT7...ESTAT_PKTCNT0 + moveq #0,d0 + READREG ESTAT,a0,d1 + move.b d1,d0 ;ESTAT_PKTCNT7...ESTAT_PKTCNT0 .rts: rts .err: moveq #-1,d0 @@ -1112,8 +1125,9 @@ _enc624j6l_RecvFrame: ; move.l a0,d1 beq .err - READREG ESTAT,a0,d0 ;number of pending frames - and.l #$ff,d0 ;clear out count (ESTAT_PKTCNT7...ESTAT_PKTCNT0) + moveq #0,d0 + READREG ESTAT,a0,d2 ;number of pending frames + move.b d2,d0 ;clear out count (ESTAT_PKTCNT7...ESTAT_PKTCNT0) beq .rts ;nothing in buffer, return sheer emptiness ;at least one frame in buffer @@ -1280,12 +1294,6 @@ _enc624j6l_RecvFrame: ; bge.s .rts moveq #0,d0 - -; cmp.l #$d8803977,6(a3) -; beq .rts -; moveq #0,d0 -; clr.l 6(a3) - .rts: movem.l (sp)+,d2-d7/a1-a3 rts @@ -1319,7 +1327,7 @@ _enc624j6l_RecvFrame: ; ; notes: ; _enc624j6l_TransmitFrame: - movem.l d2-d4/a2,-(sp) + movem.l d2-d5/a2,-(sp) ;---------------- parameter check ------------------------------------- @@ -1344,13 +1352,6 @@ _enc624j6l_TransmitFrame: move.l a1,d1 ;no send frame ? beq.w .err ;exit - move.w d0,d4 ;still need length later - addq #7,d0 ;round up - asr.w #3,d0 ;size/8 = words - subq.w #1,d0 ;dbf... - blt.w .err ;size<2 ? bail out - - ;------ double-buffered frame copy to send buffer --------------------- READREG PNextTX,a0,d2 ;"last written, maybe still pending frame" and.w #PSwapTX,d2 ;sanity, leave only desired bits @@ -1358,6 +1359,40 @@ _enc624j6l_TransmitFrame: WRITEREG PNextTX,a0,d2 ;remember pointer (d2 also for ETXST later) lea (a0,d2.w),a2 ;write pointer for frame + + ifeq _OPT_BUFFER_SWAP + + ;faster TX when buffer swapping is not necessary + move.l d0,d4 ;remember length + moveq #63,d5 ; + and.l d5,d0 ;remainder of 64 byte copy loop + move.l d4,d5 ;length in bytes + asr.w #6,d5 ;64 byte blocks + subq.w #1,d5 ;dbf + blt.s .smallcopy + bra.s .largecopy_start + +.largecopy: + move.l d1,(a2)+ +.largecopy_start: + rept 15 + move.l (a1)+,(a2)+ ;save to SRAM + endr + move.l (a1)+,d1 + dbf d5,.largecopy + + move.l d1,(a2)+ + bra.s .smallcopy + + endc ;_OPT_BUFFER_SWAP + + move.w d0,d4 ;still need length later +.smallcopy: + addq #7,d0 ;round up + asr.w #3,d0 ;size/8 = words + subq.w #1,d0 ;dbf... + blt.w .err ;size<2 ? bail out + swap d4 move.w #8,d4 .txcopy: @@ -1375,14 +1410,16 @@ _enc624j6l_TransmitFrame: swap d3 move.l d1,(a2)+ ;save to SRAM move.l d3,(a2)+ ;save to SRAM - else + else ;_OPT_BUFFER_SWAP move.l (a1)+,(a2)+ ;save to SRAM move.l (a1)+,(a2)+ ;save to SRAM - endc + endc ;_OPT_BUFFER_SWAP dbf d0,.txcopy + swap d4 + ;---------------- wait on last frame ---------------------------------- move #200,d3 .txwait: @@ -1410,7 +1447,7 @@ _enc624j6l_TransmitFrame: SETREG ECON1,a0,d1 ; .err: - movem.l (sp)+,d2-d4/a2 + movem.l (sp)+,d2-d5/a2 rts ifne _OPT_CHECKLINK_TX @@ -1422,7 +1459,61 @@ _enc624j6l_TransmitFrame: bra.s .linkchgdone endc + +;--------------------------------------------------------------------------------------- +; +; read PHY register (16 Bit) +; +; input: A0 - APTR mmapped board base address +; D0 - LONG Phy register (5 valid bits) +; +; output: LONG D0 <0 - error (bad register index) +; - 16 Bit PHY reg contents +; +; trash: - +; +; notes: +;; +; +; +_enc624j6l_ReadPHY: + moveq #31,d1 + cmp.l d1,d0 + bhi.w .err + bset #8,d0 ;$100 + PHY_REG + WRITEREG MIREGADR,a0,d0 ;set PHY register address + moveq #1,d0 + WRITEREG MICMD,a0,d0 ;read command + + moveq #25,d0 ;25 us delay (at least) + bsr _enc624j6l_UMinDelay ; + + moveq #100,d1 +.waitloop: + READREG MISTAT,a0,d0 + btst #0,d0 + beq.s .notbusy + + tst.b $BFE301 ;1 CIA access = 1.4 us + subq.w #1,d1 ;>165 us exceeded ? -> something is wrong, SPEC says 25.6 us + blt.s .notbusy ;error + + bra.s .waitloop +.notbusy + moveq #0,d0 + WRITEREG MICMD,a0,d0 ;cancel read command + + tst.w d1 ;did we run into timeout ? + blt.s .err ;yes, we don't have anything worthwhile + + READREG MIRD,a0,d1 + moveq #0,d0 + move.w d1,d0 + rts +.err: + moveq #-1,d0 + rts ;------------------------------------------------------------------------------------------------ ;------------------------------------------------------------------------------------------------ ; diff --git a/Driver/baxnet/source/enc624j6net/enc624j6l.h b/Driver/baxnet/source/enc624j6net/enc624j6l.h index 969180b..4e4e91f 100644 --- a/Driver/baxnet/source/enc624j6net/enc624j6l.h +++ b/Driver/baxnet/source/enc624j6net/enc624j6l.h @@ -232,7 +232,7 @@ ASM SAVEDS int enc624j6l_SetOnline( ASMR(a0) void *board ASMREG(a0) ); output: <0 - error >=0 - OK */ -ASM SAVEDS int enc624j6l_broadcast_multicast_filter( +ASM SAVEDS int enc624j6l_bc_mc_filter( ASMR(a0) void *board ASMREG(a0), ASMR(d1) unsigned long flags ASMREG(d1) ); @@ -326,6 +326,19 @@ ASM SAVEDS void enc624j6l_IntServer_List( void ); */ ASM SAVEDS int enc624j6l_CheckLinkChange( ASMR(a0) void *board ASMREG(a0) ); +/* + Purpose: read PHY register + + input: board - mmapped board base address + flags - broadcast,promiscous, multicast + + output: <0 - error + >=0 - OK +*/ +ASM SAVEDS int enc624j6l_ReadPHY( + ASMR(a0) void *board ASMREG(a0), + ASMR(d0) unsigned long phyreg ASMREG(d0) ); + #endif /* _INC_ENC624J6L_H */ diff --git a/Driver/baxnet/source/enc624j6net/enc624test.c b/Driver/baxnet/source/enc624j6net/enc624test.c new file mode 100644 index 0000000..902e266 --- /dev/null +++ b/Driver/baxnet/source/enc624j6net/enc624test.c @@ -0,0 +1,110 @@ +/* + enc624test.c + + (C) 2018 Henryk Richter + + Matze-Scrat-Buggs ZII card hardware test + + +*/ +#include +#include + +#define ENC_MANUFACTURER 2588 +#define ENC_BOARD 123 + +#include +#include +#include +#include + +#if 0 +#include "device.h" +#include "hw.h" + +#include "enc624j6l.h" +#endif +#include "registers.h" + + +#define READREG(_x_,_off_) *( (volatile USHORT*)( (volatile UBYTE*)(_x_) + (_off_)) ) +#define WRITEREG(_x_,_off_,_y_) *( (volatile USHORT*)( (volatile UBYTE*)(_x_) + (_off_)) ) = (_y_); +#define SETREG(_x_,_off_,_y_) *( (volatile USHORT*)( (volatile UBYTE*)(_x_) + (_off_) + SET_OFFSET )) = (_y_); +#define CLRREG(_x_,_off_,_y_) *( (volatile USHORT*)( (volatile UBYTE*)(_x_) + (_off_) + CLR_OFFSET )) = (_y_); + +const BYTE exp_name[] = "expansion.library"; + +int main( int argc, char **argv ) +{ + LONG ret = 0; + ULONG ul; + volatile APTR board = (0); + volatile UBYTE *uboard; + struct Library *ExpansionBase; + struct ConfigDev *cfg = (0); + + ExpansionBase = OpenLibrary( (BYTE*)exp_name, 37 ); + if( !ExpansionBase ) + { + Printf("Cannot open Expansion. quitting\n"); + goto quit; + } + + cfg = FindConfigDev( cfg, ENC_MANUFACTURER, ENC_BOARD ); + if( cfg ) + { + board = (volatile APTR)cfg->cd_BoardAddr; + } + if( !board ) + { + Printf("Board %ld / %ld not found in expansions\n",(ULONG)ENC_MANUFACTURER,(ULONG)ENC_BOARD); + goto quit; + } + Printf("Board found at 0x%lx\n",(ULONG)board); + + /* 16 Bit R/W Test */ + Printf("16 Bit reg test\n",(ULONG)board); + WRITEREG( board, EUDAST, 0x1234 ); + ul = READREG( board, EUDAST ); + if( ul != 0x1234 ) + { + Printf("Board error: wrote 0x1234, got 0x%lx\n",ul); + ret = 1; + } + WRITEREG( board, EUDAST, 0x0000 ); + + /* Byte R/W tests */ + Printf("8 Bit buffer tests\n",(ULONG)board); + + WRITEREG( board, 0xBFE, 0x0000 ); + uboard = (volatile UBYTE*)board; + + *(uboard+0xBFE) = 0xda; + ul = READREG( board, 0xBFE ); + if( ul != 0xda00 ) + { + Printf("Board error: expected 0xDA00, got 0x%lx on upper byte test\n",ul); + ret = 1; + } + + WRITEREG( board, 0xBFE, 0x0000 ); + *(uboard+0xBFF) = 0xbf; + ul = READREG( board, 0xBFE ); + if( ul != 0x00bf ) + { + Printf("Board error: expected 0x00BF, got 0x%lx on lower byte test\n",ul); + ret = 1; + } + + if( ret ) + Printf("Error(s) encountered\n"); + else + Printf("Board looking good as far as tested\n"); + +quit: + if( ExpansionBase ) + CloseLibrary(ExpansionBase); + + return ret; +} + diff --git a/Driver/baxnet/source/enc624j6net/hw.c b/Driver/baxnet/source/enc624j6net/hw.c index 57d13f2..1235cde 100644 --- a/Driver/baxnet/source/enc624j6net/hw.c +++ b/Driver/baxnet/source/enc624j6net/hw.c @@ -3,7 +3,7 @@ (C) 2018 Henryk Richter - SDNet hardware interface to device + Matze-Scrat-Buggs ZII card hardware interface to device */ @@ -73,6 +73,8 @@ void myhw_ControlIntervalTimer( DEVBASEP ); hw_config_init() - set defaults for HW hw_config_update() - update config of HW + + hw_get_mac_status() - running parameters */ const BYTE exp_name[] = "expansion.library"; @@ -85,11 +87,10 @@ ASM SAVEDS LONG hw_Find_Boards( ASMR(a0) DEVBASEP ASMREG(a0) ) struct Library *ExpansionBase; struct ConfigDev *cfg = (0); - if( (ExpansionBase = OpenLibrary( exp_name, 37 )) ) + if( (ExpansionBase = OpenLibrary( (BYTE*)exp_name, 37 )) ) { - /* TODO: check for expansion port, i.e. distinguish V500/V600 */ /* TODO: actually verify that we have a module here */ - ret = 1; + /* ret = 1; */ for( i=0 ; i < MAX_UNITS ; i++ ) { @@ -322,8 +323,64 @@ ASM SAVEDS LONG hw_check_link_change( ASMR(a0) DEVBASEP ASMREG( return 1; /* don't signal panic to the outside, everything is under control */ } +/* obtain running parameters of Ethernet MAC: link up/down, Speed, Duplex */ +ASM SAVEDS LONG hw_get_mac_status( ASMR(a0) DEVBASEP ASMREG(a0), + ASMR(d0) ULONG unit ASMREG(d0) ) +{ + struct HWData *hwd = &db->db_hwdat; + APTR boardbase = db->db_Units[unit].duh_BASE; + + LONG ret; + LONG phstat3; + LONG phstat1; + LONG phcon1; + + enc624j6l_ReadPHY( boardbase, PHSTAT1 ); + phstat3 = enc624j6l_ReadPHY( boardbase, PHSTAT3 ); + phcon1 = enc624j6l_ReadPHY( boardbase, PHCON1 ); + phstat1 = enc624j6l_ReadPHY( boardbase, PHSTAT1 ); /* read again to see whether link is established */ + if( ( phstat1 < 0 ) || ( phstat3 < 0 ) ) + return HW_MAC_INVALID; /* no valid data found */ + + /* a) check Link */ + ret = 0; + if( phstat1 & PHSTAT1_LLSTAT ) + { + ret |= HW_MAC_LINK_UP; + +/* if( phstat1 & PHSTAT1_ANDONE ) */ /* autonegotiation successful */ + if( phcon1 & PHCON1_ANEN ) /* autonegotiation enabled */ + ret |= HW_MAC_AUTONEGOTIATION; + + phstat3 = (phstat3>>2)&7; /* get active Speed/Duplex */ + switch( phstat3 ) + { + case 6: + if( hwd->flowcontrol ) + ret |= (HW_MAC_ON_FDX_FC<flowcontrol ) + ret |= (HW_MAC_ON_FDX_FC<lh_Head->ln_Succ ) flags |= PIO_INIT_MULTI_CAST; - enc624j6l_broadcast_multicast_filter(boardbase, flags );/* flags & (PIO_INIT_BROAD_CAST|PIO_INIT_MULTI_CAST) ); */ + enc624j6l_bc_mc_filter(boardbase, flags );/* flags & (PIO_INIT_BROAD_CAST|PIO_INIT_MULTI_CAST) ); */ @@ -366,6 +423,7 @@ void myhw_ControlInterrupts( DEVBASEP ) hwd->hwd_act_boards[flag] = (0); /* NULL-terminate */ hwd->hwd_act_boards[flag+1] = (APTR)FindTask(0); /* append task */ hwd->hwd_act_boards[flag+2] = (APTR)hwd->hwd_IntSig; /* append sigbit */ + hwd->hwd_act_boards[flag+3] = (APTR)db->db_SysBase; /* append ExecBase *((APTR*)0x4); */ if( flag ) /* determine on/off switch */ { diff --git a/Driver/baxnet/source/enc624j6net/hwprivate.h b/Driver/baxnet/source/enc624j6net/hwprivate.h index 983fcca..5207661 100644 --- a/Driver/baxnet/source/enc624j6net/hwprivate.h +++ b/Driver/baxnet/source/enc624j6net/hwprivate.h @@ -15,11 +15,14 @@ /* sdnet/v2expnet specific: polling timer */ #include "intervaltimer.h" +#define HW_VENDOR "a1k.org Matze Buggs Scrat" +#define HW_PRODUCT "Zorro LAN IDE CP" + /* this struct is available in devicebase and should carry global information */ struct HWData { struct Interrupt hwd_Interrupt; /* keep the interrupt at top of HWData !! */ struct SignalSemaphore hwd_Sem; /* list locking (global per unit) */ - APTR hwd_act_boards[MAX_UNITS+1+2]; /* poll all active boards by ptr in interrupt, NULL terminated, followed by SigTask,Sigbit */ + APTR hwd_act_boards[MAX_UNITS+1+3]; /* poll all active boards by ptr in interrupt, NULL terminated, followed by SigTask,Sigbit,ExecBase */ ULONG hwd_SigMask; /* signal mask to wait for in server main instance */ diff --git a/Driver/baxnet/source/enc624j6net/registers.h b/Driver/baxnet/source/enc624j6net/registers.h index 0af65ee..08e5559 100644 --- a/Driver/baxnet/source/enc624j6net/registers.h +++ b/Driver/baxnet/source/enc624j6net/registers.h @@ -439,6 +439,17 @@ #define EIDLED_REVID1 (1<<1) #define EIDLED_REVID0 (1) +/* ; PHY REGISTERS */ +#define PHCON1 0 +#define PHSTAT1 1 +#define PHANA 4 +#define PHANLPA 5 +#define PHANE 6 +#define PHCON2 0x11 +#define PHSTAT2 0x1b +#define PHSTAT3 0x1f + + /* PHCON1 bits --------- */ #define PHCON1_PRST (1<<15) #define PHCON1_PLOOPBK (1<<14) diff --git a/Driver/baxnet/source/enc624j6net/registers.i b/Driver/baxnet/source/enc624j6net/registers.i index dfb1306..ad343fa 100644 --- a/Driver/baxnet/source/enc624j6net/registers.i +++ b/Driver/baxnet/source/enc624j6net/registers.i @@ -437,6 +437,16 @@ EIDLED_REVID2 EQU (1<<2) EIDLED_REVID1 EQU (1<<1) EIDLED_REVID0 EQU (1) +; PHY REGISTERS +PHCON1 EQU 0 +PHSTAT1 EQU 1 +PHANA EQU 4 +PHANLPA EQU 5 +PHANE EQU 6 +PHCON2 EQU $11 +PHSTAT2 EQU $1b +PHSTAT3 EQU $1f + ; PHCON1 bits --------- PHCON1_PRST EQU (1<<15) PHCON1_PLOOPBK EQU (1<<14) @@ -598,5 +608,6 @@ CLOCK_16_SET EQU (ECON2_COCON2) ;set mask CLOCK_4_CLR EQU (ECON2_COCON2) ;clr mask CLOCK_4_SET EQU (ECON2_COCON3|ECON2_COCON0|ECON2_COCON1) ;set mask +; changed to 25 MHz for ZIII firmware CLOCK_DEF_CLR EQU CLOCK_25_CLR CLOCK_DEF_SET EQU CLOCK_25_SET diff --git a/Driver/baxnet/source/hw.h b/Driver/baxnet/source/hw.h index b6f2091..4a7098a 100644 --- a/Driver/baxnet/source/hw.h +++ b/Driver/baxnet/source/hw.h @@ -20,6 +20,41 @@ struct devbase; #define DEVBASEP DEVBASETYPE *db #endif +/* states for each NIC speed */ +#define HW_MAC_ISACTIVE(_status_,_spd_) ( ((_status_)>>(_spd_)) & 3 ) /* returns 0 if inactive, 0...3 if active */ +#define HW_MAC_OFF 0 /* this speed is inactive */ +#define HW_MAC_ON 1 /* on, half duplex */ +#define HW_MAC_ON_FDX 2 /* on, full duplex */ +#define HW_MAC_ON_FDX_FC 3 /* on, full duplex, flow-control */ + +/* + MAC definitions + (flag Mask) + -> conceptually, this layout can be used for current + running mode as well as autonegotiation capabilities + masks for local NIC and peer + -> is fiber optic Ethernet relevant for us Amigans? +*/ +#define HW_MAC_INVALID (-1) /* no info available */ +#define HW_MAC_LINK_UP 1 /* link is up */ +#define HW_MAC_AUTONEGOTIATION 2 /* autonegotiation enabled */ + +/* two bits each to handle the four different states per speed */ +#define HW_MACB_SPEED10 2 /* bit for 10 MBit/s mask */ +#define HW_MACB_SPEED100 4 /* bit for 100 MBit/s mask */ +#define HW_MACB_SPEED100T2 6 /* bit for 100 MBit/s mask (100BaseT2) */ +#define HW_MACB_SPEED100T4 8 /* bit for 100 MBit/s mask (100BaseT4) */ +#define HW_MACB_SPEED1000 10 /* ... */ +#define HW_MACB_SPEED2500 12 +#define HW_MACB_SPEED5000 14 +#define HW_MACB_SPEED10000 16 /* Am I optimistic ? */ +#define HW_MACB_SPEEDS_END 18 /* this is the next free bit */ +#define HW_MAC_SPEEDSMASK ((1< +; +; Hardware dependent definitions +; +; +; + ifnd _INC_HW_I +_INC_HW_I EQU 1 + +;/* states for each NIC speed */ +HW_MAC_OFF EQU 0 ; this speed is inactive +HW_MAC_ON EQU 1 ; on, half duplex +HW_MAC_ON_FDX EQU 2 ; on, full duplex +HW_MAC_ON_FDX_FC EQU 3 ; on, full duplex, flow-control + +; +; +; MAC definitions +; (flag Mask) +; -> conceptually, this layout can be used for current +; running mode as well as autonegotiation capabilities +; masks for local NIC and peer +; +HW_MAC_INVALID EQU -1 ; no info available +HW_MACB_LINK_UP EQU 0 +HW_MACB_AUTONEGOTIATION EQU 1 +HW_MAC_LINK_UP EQU (1<=SANA2R2 networking device */ +#define NSDEVTYPE_AUDIO 8 /* like audio.device */ +#define NSDEVTYPE_CLIPBOARD 9 /* like clipboard.device */ +#define NSDEVTYPE_PRINTER 10 /* like printer.device */ +#define NSDEVTYPE_SERIAL 11 /* like serial.device */ +#define NSDEVTYPE_PARALLEL 12 /* like parallel.device */ + + +/*------------------------------------------------------------------------*/ +/* The following defines should really be part of device specific + * includes. So we protect them from being redefined. + */ +#ifndef NSCMD_TD_READ64 +/* + * An early new style trackdisk like device can also return this + * new identifier for TD_GETDRIVETYPE. This should no longer + * be the case though for newly written or updated NSD devices. + * This identifier is ***OBSOLETE*** + */ + +#define DRIVE_NEWSTYLE (0x4E535459L) /* 'NSTY' */ + + +/* + * At the moment, only four new style commands in the device + * specific range and their ETD counterparts may be implemented. + */ + +#define NSCMD_TD_READ64 0xC000 +#define NSCMD_TD_WRITE64 0xC001 +#define NSCMD_TD_SEEK64 0xC002 +#define NSCMD_TD_FORMAT64 0xC003 + +#define NSCMD_ETD_READ64 0xE000 +#define NSCMD_ETD_WRITE64 0xE001 +#define NSCMD_ETD_SEEK64 0xE002 +#define NSCMD_ETD_FORMAT64 0xE003 +#endif /* NSCMD_TD_READ64 */ + +/*------------------------------------------------------------------------*/ + +#endif /* DEVICES_NEWSTYLE_H */ diff --git a/Driver/baxnet/source/sana2devqueryext.h b/Driver/baxnet/source/sana2devqueryext.h new file mode 100644 index 0000000..437fe11 --- /dev/null +++ b/Driver/baxnet/source/sana2devqueryext.h @@ -0,0 +1,80 @@ +#ifndef SANA2_SANA2DEVQUERYEXT_H +#define SANA2_SANA2DEVQUERYEXT_H + +/* +** $VER: sana2devqueryext.h 0.12 (10-Jun-2018) +** Definitions for SANA-II extended device query +** (c) 2018, Timm S. Mueller and Olaf Barthel +** +** Permission is hereby granted, free of charge, to any person obtaining +** a copy of this file, without limitation the rights to copy, publish, +** and distribute this file in unmodified form, and to use it for the +** creation of software. +** We strongly advise you not to release software into the public based on +** modifications or extensions of the definitions below, without seeking +** prior agreement with the authors regarding your changes. +** +** Application protocol: +** 1. Using NSCMD_DEVICEQUERY, check for availability of S2_DEVICEQUERYEXT. +** 2. For each attribute provide a struct S2DevQueryExtParam. Fill in a +** pointer to your data, its length, and initialize Actual to 0. +** 3. For each attribute requested, supply a tagitem with a pointer to the +** respective S2DevQueryExtParam structure as its value. Pass the taglist +** in ios2_Data. After return from the device and no I/O error, +** 4. check for the expected data size using param.Actual == sizeof(value). +** Check for the presence of any returned data using param.Actual != 0. +** The length of strings include a terminating zero byte, so param.Actual +** for a string of length 0 would be 1. +** 5. To only retrieve the number of bytes that would be written, set +** param.Data to NULL. +** 6. Unless otherwise noted, numerical values are of type ULONG by default. +** +** Driver protocol: +** 1. Support S2_DEVICEQUERYEXT per NSCMD_DEVICEQUERY. +** 2. Iterate supplied tags in ios2_Data. For each tag, +** 3. if param->Data is NULL, write the length that would be written +** into param->Actual. In the case of strings, always include the +** terminating zero byte in this length. +** 4. If param->Data is not NULL, check for +** param->Length >= sizeof(your_data). Copy your data into the +** buffer provided by param->Data. Under no circumstance may the length +** being written exceed param->Length. Write the length actually being +** written into param->Actual. At your discretion, shorten informative, +** non-indexing strings to fit into the user-supplied buffer -- but you +** are not allowed to write strings without a terminating zero byte, +** which must fit into the buffer as indicated by param->Length. +*/ + +#include + +struct S2DevQueryExtParam +{ + APTR Data; /* Ptr to data buffer you provide */ + LONG Length; /* Length of data buffer you provide */ + LONG Actual; /* Number of bytes actually written */ +}; + +#define S2_DEVICEQUERYEXT (S2_START + 0x100) +#define S2_DevQueryExtTagBase (S2_Dummy + 0x100) + +/* ptr to string containing the vendor name: */ +#define S2_DevQueryExtVendorName (S2_DevQueryExtTagBase + 1) +/* ptr to string containing the product name: */ +#define S2_DevQueryExtProductName (S2_DevQueryExtTagBase + 2) +/* Current physical link status, see definitions below: */ +#define S2_DevQueryExtLinkStatus (S2_DevQueryExtTagBase + 3) +/* Current physical link speed, see definitions below: */ +#define S2_DevQueryExtLinkSpeed (S2_DevQueryExtTagBase + 4) + +#define S2_DEVQUERYEXT_LINK_UNDEFINED 0xffffffff +#define S2_DEVQUERYEXT_LINK_DOWN 0 +#define S2_DEVQUERYEXT_LINK_UP 1 + +#define S2_DEVQUERYEXT_SPEED_UNDEFINED 0xffffffff +#define S2_DEVQUERYEXT_SPEED_OTHER 0 +#define S2_DEVQUERYEXT_SPEED_10M 1 +#define S2_DEVQUERYEXT_SPEED_100M 2 +#define S2_DEVQUERYEXT_SPEED_1000M 3 +#define S2_DEVQUERYEXT_SPEED_10000M 4 + +#endif diff --git a/Driver/baxnet/source/sdnet/enc28j60.c b/Driver/baxnet/source/sdnet/enc28j60.c index b3b7541..ef6a16b 100644 --- a/Driver/baxnet/source/sdnet/enc28j60.c +++ b/Driver/baxnet/source/sdnet/enc28j60.c @@ -337,7 +337,7 @@ u08 enc28j60_init(const u08 macaddr[6], u08 flags) SetBank(EIR); writeOp(ENC28J60_BIT_FIELD_CLR, EIR, EIR_DMAIF|EIR_LINKIF|EIR_TXIF|EIR_TXERIF|EIR_RXERIF|EIR_PKTIF); - writeOp(ENC28J60_BIT_FIELD_SET, EIE, EIE_INTIE|EIE_PKTIE|EIE_LINKIE|EIE_TXIE|EIE_TXERIE|EIE_RXERIE); + writeOp(ENC28J60_BIT_FIELD_SET, EIE, EIE_INTIE|EIE_PKTIE); /* |EIE_LINKIE|EIE_TXIE|EIE_TXERIE|EIE_RXERIE); */ writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_RXEN); @@ -441,6 +441,9 @@ u08 enc28j60_status(u08 status_id, u08 *value) case PIO_STATUS_LINK_UP: *value = (readPhyByte(PHSTAT2) >> 2) & 1; return PIO_OK; + case PIO_STATUS_FULLDPX: + *value = (readRegByte(MACON3) & MACON3_FULDPX) ? 1 : 0;/* + (((u16)readRegByte(MACON1+3))<<8); */ + return PIO_OK; default: *value = 0; return PIO_NOT_FOUND; @@ -469,6 +472,13 @@ u08 enc28j60_send(const u08 *data, u16 size) } /* write buffer */ +#if 0 + if(0) + { u08* d = (u08*)data; + d[size]=0; + size=(size+1)&0xfffe; + } +#endif enc28j60l_WriteBuffer( (u08*)data, size, TXSTART_INIT ); /* initiate send */ @@ -559,6 +569,14 @@ u08 enc28j60_recv(u08 *data, u16 max_size, u16 *got_size) /* read packet */ readBuf(len, data); +#if 0 + { + data[len]=0; + data[len+1]=0; + data[len+2]=0; + data[len+3]=0; + } +#endif next_pkt(); return result; diff --git a/Driver/baxnet/source/sdnet/enc28j60.h b/Driver/baxnet/source/sdnet/enc28j60.h index e45e668..73ce70f 100644 --- a/Driver/baxnet/source/sdnet/enc28j60.h +++ b/Driver/baxnet/source/sdnet/enc28j60.h @@ -42,6 +42,7 @@ /* status flags */ #define PIO_STATUS_VERSION 0 #define PIO_STATUS_LINK_UP 1 +#define PIO_STATUS_FULLDPX 2 /* control ids */ #define PIO_CONTROL_FLOW 0 diff --git a/Driver/baxnet/source/sdnet/enc28j60l.asm b/Driver/baxnet/source/sdnet/enc28j60l.asm index 598d81d..c988c9f 100755 --- a/Driver/baxnet/source/sdnet/enc28j60l.asm +++ b/Driver/baxnet/source/sdnet/enc28j60l.asm @@ -6,6 +6,9 @@ ; Note: This code is in some places intentionally saving more registers than ; required by the AmigaOS ABI. ; + ifnd _LVOSignal +_LVOSignal EQU -324 + endc ; enable debugging code block DEBUG EQU 0 @@ -32,6 +35,12 @@ _OPT_SHORT_DELAY EQU 1 ;small delays by a single CIA read XDEF _enc28j60l_Shutdown XDEF _enc28j60l_SetSPISpeed + ifd PROTO_V2EXPNET + ; interrupt stuff, used only with V2EXPETH right now + XDEF _enc28j60l_IntServer_List + XDEF _enc28j60l_EnableInterrupt + XDEF _enc28j60l_DisableInterrupt + endc ; ; ; hardware support functions without SPI register banging @@ -300,6 +309,7 @@ SDCARD_DATA_R EQU $00DE0010 SDCARD_CFG_W EQU $00DE0014 SDCARD_STATUS_R EQU $00DE0016 SDCARD_CFG_SPEED EQU $00DE001C +SDCARD_INT_ENABLE EQU $00DE0018 else ;PROTO_V2EXPNET ; PROTO_SDNET SDCARD_DATA_W EQU $00DE0000 @@ -307,6 +317,7 @@ SDCARD_DATA_R EQU $00DE0000 SDCARD_CFG_W EQU $00DE0004 SDCARD_STATUS_R EQU $00DE0006 SDCARD_CFG_SPEED EQU $00DE000C +SDCARD_INT_ENABLE EQU $00DE0008 endc ;PROTO_V2EXPNET SDCARD_SPEED EQU $20 ;this one is obsolete @@ -999,6 +1010,107 @@ skip$ rts$ rts + ;----------------------------------------------------------------------- + ifd PROTO_V2EXPNET + +;--------------------------------------------------------------------------------------- +; +; Hardware interrupt service routine for a list of boards +; +; In: A1 - is_data = board base address list +; +; Out: - +; +; Notes: - assumes that init() was called before +; - process list of board addresses and check for active interrupt(s) +; list layout: +; ULONG enableflag +; APTR board1, +; APTR board2,... +; APTR (0) +; APTR sigtask +; ULONG sigbit +; +_enc28j60l_IntServer_List: + movem.l d3/a6,-(sp) + + move.l a1,d0 ;no pointer supplied ? -> return + beq.s .rts + move.l a1,a6 + + tst.l (a1)+ ;interrupt processing enabled ? + beq.s .rts_disable ; + + moveq #0,d1 +.boardloop: + move.l (a1)+,d0 ;next entry from list + beq.s .done ; + move.l d0,a0 ;current board + + move.b #EPKTCNT,d0 + bsr _enc28j60l_ReadRegByte + or.b d0,d1 + + bra.s .boardloop +.done: + tst.w d1 + beq.s .rts + + clr.l (a6)+ ;disable interrupt processing further on + + ; clear EIE_INTIE in all active boards directly from here +.intdis_loop: + move.l (a6)+,d0 + beq.s .boardsdone + + move.w #$0000,SDCARD_INT_ENABLE + ; + ;move.w #ENC28J60_BIT_FIELD_CLR,d3 + ;moveq #EIE,d0 + ;moveq #EIE_INTIE|EIE_PKTIE,d1 + ;bsr _enc28j60l_WriteOp + + bra.s .intdis_loop +.boardsdone: + + move.l (a6)+,d0 ;Sigtask + beq.s .rts + move.l d0,a1 + + moveq #0,d0 + move.l (a6)+,d1 ;Sigbit + bset d1,d0 + + move.l 4.w,a6 + jsr _LVOSignal(a6) + +.rts: + movem.l (sp)+,d3/a6 + moveq #0,d0 ;set Z flag + rts +.rts_disable: ; + move.w #$0000,SDCARD_INT_ENABLE + bra.s .rts + + + ; TODO: enable/disable interrupt on board +_enc28j60l_EnableInterrupt: + move.w #$8000,SDCARD_INT_ENABLE + rts + +_enc28j60l_DisableInterrupt: + move.w #$0000,SDCARD_INT_ENABLE + rts + + endc ;ifd PROTO_V2EXPNET + ;----------------------------------------------------------------------- + + + + ; DEBUG + ;ifd PROTO_V2EXPNET + ;dc.b "exp net variant built." + ;endc ; section data,data diff --git a/Driver/baxnet/source/sdnet/enc28j60l.h b/Driver/baxnet/source/sdnet/enc28j60l.h index db13e72..7422faa 100644 --- a/Driver/baxnet/source/sdnet/enc28j60l.h +++ b/Driver/baxnet/source/sdnet/enc28j60l.h @@ -12,6 +12,49 @@ #include "compiler.h" +/* + Purpose: interrupt service routine ( after EnableInterrupt() ) + + This function will signal the task passed at EnableInterrupt time with + the given sigbit when at least one frame is pending. + + input: - + output: - +*/ +ASM SAVEDS void enc28j60l_IntServer_List( void ); + +/* + Purpose: enable HW interrupt + + input: board - mmapped board base address + SigTask - task to signal upon interrupt (or NULL) + SigBit - Signal bit to send upon interrupt (or -1) + IntMask - ENC HW interrupts to enable (set 0, for now) = RX PACKET only + + output: <0 - error + >=0 - OK + + notes: +*/ +ASM SAVEDS int enc28j60l_EnableInterrupt( ASMR(a0) void *board ASMREG(a0), + ASMR(a1) void* SigTask ASMREG(a1), + ASMR(d0) int SigBit ASMREG(d0), + ASMR(d1) unsigned int IntMask ASMREG(d1) ); + + +/* + Purpose: disable HW interrupt + + input: board - mmapped board base address + + output: <0 - error + >=0 - OK + + notes: +*/ +ASM SAVEDS int enc28j60l_DisableInterrupt( ASMR(a0) void *board ASMREG(a0) ); + + /* Purpose: prepare SPI for use input: - diff --git a/Driver/baxnet/source/sdnet/hw.c b/Driver/baxnet/source/sdnet/hw.c index 3924baa..cf695b0 100644 --- a/Driver/baxnet/source/sdnet/hw.c +++ b/Driver/baxnet/source/sdnet/hw.c @@ -16,6 +16,8 @@ #include #include "vampuuid.h" #include "enc28j60.h" +#include +#include "enc28j60l.h" #ifndef PROTO_V2EXPNET #define PORTID V_SDPORT @@ -27,6 +29,9 @@ extern const BYTE DeviceName[]; /* use generic board fields in current unit */ #define hw_allocated du_hwl0 +#define duh_online du_hwl1 +#define duh_BASE du_hwp0 + #define HW_INTERVALDEF 10000 #define HW_DEFSPI 2 @@ -58,6 +63,21 @@ extern const BYTE DeviceName[]; hw_config_update() - update config of HW */ +#ifdef PROTO_V2EXPNET +#define USE_INTERRUPT + +/* used only if interrupts are in play (currently V2ExpETH) */ +void myhw_ControlInterrupts( DEVBASEP ); +const BYTE intname[] = "v2expeth SanaII driver"; +#define HW_INTSOURCE INTB_PORTS /* Int 2 */ + +#else + +#define myhw_ControlInterrupts( _a_ ) + +#endif + + const BYTE vres_name[] = V_VAMPIRENAME; /* return number of boards present in system */ @@ -156,12 +176,25 @@ ASM SAVEDS LONG hw_Setup( ASMR(a0) DEVBASEP ASMREG(a0) ) LONG ret = 0; struct HWData *hwd = &db->db_hwdat; + +#ifdef USE_INTERRUPT + hwd->IntSig = AllocSignal(-1); + hwd->hwd_Interrupt.is_Data = (0); +#ifdef PROTO_V2EXPNET + db->db_Units[0].duh_BASE = (void*)0xDE0010; +#else + db->db_Units[0].duh_BASE = (void*)0xDE0000; +#endif +#else hwd->IntSig = -1; +#endif if( InitIntervalTimer( &hwd->ivtimer ) > 0 ) { hwd->SigMask = hwd->ivtimer.IVT_SigMask; - +#ifdef USE_INTERRUPT + hwd->SigMask |= (1<<(hwd->IntSig)); +#endif ret = 1; } @@ -173,6 +206,9 @@ ASM SAVEDS void hw_Shutdown( ASMR(a0) DEVBASEP ASMREG(a0) ) { struct HWData *hwd = &db->db_hwdat; + db->db_Units[0].duh_online = 0; + myhw_ControlInterrupts( db ); + if( hwd->IntSig >= 0 ) FreeSignal( hwd->IntSig ); @@ -206,8 +242,14 @@ ASM SAVEDS LONG hw_Attach( ASMR(a0) DEVBASEP ASMREG(a0), ret = 0; else { + db->db_Units[0].duh_online = 1; /* used for int server and interval timer setup */ + enc28j60_SetSPISpeed( hwd->spispeed ); - StartIntervalTimer( &hwd->ivtimer, hwd->timervalue ); + + myhw_ControlInterrupts( db ); + + if( hwd->timervalue > 0 ) + StartIntervalTimer( &hwd->ivtimer, hwd->timervalue ); } return ret; @@ -220,7 +262,13 @@ ASM SAVEDS void hw_Detach( ASMR(a0) DEVBASEP ASMREG(a0), if( !unit ) { struct HWData *hwd = &db->db_hwdat; + + db->db_Units[unit].duh_online = 0; /* used for int server and interval timer setup */ + myhw_ControlInterrupts( db ); /* start and/or stop (based on duh_online) */ + StopIntervalTimer( &hwd->ivtimer ); + + myhw_ControlInterrupts( db ); /* start and/or stop (based on duh_online) */ enc28j60_exit(); } } @@ -235,6 +283,7 @@ ASM SAVEDS void hw_ConfigInit( ASMR(a0) DEVBASEP ASMREG(a0) ) hwd->fullduplex = 0; hwd->spispeed = HW_DEFSPI; /* default (see above) */ hwd->multicast = 0; + hwd->interrupt = 0; /* def: don`t enable interrupt */ #if 0 USHORT i; @@ -262,6 +311,8 @@ ASM SAVEDS void hw_ConfigUpdate( ASMR(a0) DEVBASEP ASMREG(a0), hwd->spispeed = *args->spispeed; if( args->multicast ) hwd->multicast = 1; + if( args->interrupt ) + hwd->interrupt = 1; } @@ -270,6 +321,12 @@ ASM SAVEDS LONG hw_send_frame( ASMR(a0) DEVBASEP ASMREG(a0), ASMR(a1) UBYTE *frame ASMREG(a1), ASMR(d1) ULONG framesize ASMREG(d1) ) { +#ifdef USE_INTERRUPT + struct HWData *hwd = &db->db_hwdat; + + hwd->hwd_act_boards[0] = (void*)(0); /* disable interrupt processing */ +#endif + enc28j60_send( frame, framesize ); return 1; } @@ -278,7 +335,21 @@ ASM SAVEDS LONG hw_send_frame( ASMR(a0) DEVBASEP ASMREG(a0), ASM SAVEDS LONG hw_recv_pending( ASMR(a0) DEVBASEP ASMREG(a0), ASMR(d0) ULONG unit ASMREG(d0) ) { +#ifdef USE_INTERRUPT + LONG ret; + struct HWData *hwd = &db->db_hwdat; + void *tmp = hwd->hwd_act_boards[0]; + + hwd->hwd_act_boards[0] = (void*)(0); /* disable interrupt processing */ + + ret = (LONG)enc28j60_has_recv(); + + hwd->hwd_act_boards[0] = tmp; /* restore interrupt processing enable flag */ + + return ret; +#else return (LONG)enc28j60_has_recv(); +#endif } @@ -288,9 +359,14 @@ ASM SAVEDS LONG hw_recv_frame( ASMR(a0) DEVBASEP ASMREG(a0), { volatile SHORT sz; LONG ret; +#ifdef USE_INTERRUPT + struct HWData *hwd = &db->db_hwdat; + + hwd->hwd_act_boards[0] = (void*)(0); /* disable interrupt processing */ +#endif /* important: don't call this without enc28j60_has_recv() > 0 check */ - if( PIO_OK != enc28j60_recv( frame, 1518, (short*)&sz ) ) + if( PIO_OK != enc28j60_recv( frame, 1518, (unsigned short*)&sz ) ) ret = 0; else ret = (LONG)sz; @@ -311,9 +387,43 @@ ASM SAVEDS ULONG hw_recv_sigmask( ASMR(a0) DEVBASEP ASMREG(a0) ASM SAVEDS LONG hw_check_link_change( ASMR(a0) DEVBASEP ASMREG(a0), ASMR(d0) ULONG unit ASMREG(d0) ) { +#ifdef USE_INTERRUPT + struct HWData *hwd = &db->db_hwdat; + + if( hwd->hwd_Interrupt.is_Data ) /* interrupt running ? */ + { + hwd->hwd_act_boards[0] = (void*)(1); /* re-enable interrupt processing */ + /* re-enable interrupt when server goes to sleep */ + enc28j60l_EnableInterrupt( db->db_Units[unit].duh_BASE, FindTask(0), (int)hwd->IntSig, 0 ); + } +#endif return 0; } +/* obtain running parameters of Ethernet MAC: link up/down, Speed, Duplex */ +/* note: */ +/* if this call is unsupported then return HW_MAC_INVALID */ +ASM SAVEDS LONG hw_get_mac_status( ASMR(a0) DEVBASEP ASMREG(a0), + ASMR(d0) ULONG unit ASMREG(d0) ) +{ + LONG ret = 0; /* def: link down */ + UBYTE status; + + enc28j60_status( PIO_STATUS_LINK_UP, &status ); + if( status ) + { + ret = HW_MAC_LINK_UP; /* LINK_UP may be redundant */ + + enc28j60_status( PIO_STATUS_FULLDPX, &status ); + if( status ) + ret |= HW_MAC_ON_FDX<db_hwdat; + LONG i,flag; + + if( !hwd->interrupt ) + return; + + flag = 0; + for( i=0 ; i < db->db_NBoards ; i++ ) + { + if( db->db_Units[i].duh_online ) + { + hwd->hwd_act_boards[flag+1] = db->db_Units[i].duh_BASE; + flag++; + } + } + hwd->hwd_act_boards[flag+1] = (0); /* NULL-terminate */ + hwd->hwd_act_boards[flag+2] = (APTR)FindTask(0); /* append task */ + hwd->hwd_act_boards[flag+3] = (APTR)hwd->IntSig; /* append sigbit */ + + if( flag ) /* determine on/off switch */ + { + /* at least 1 board is online */ + hwd->hwd_act_boards[0] = (void*)(1); /* enable interrupt processing */ + + if( hwd->hwd_Interrupt.is_Data ) + flag = 0; /* no change */ + else flag = 1; /* start interrupt */ + } + else + { + hwd->hwd_act_boards[0] = 0; /* disable interrupt processing */ + + if( hwd->hwd_Interrupt.is_Data ) + flag = -1; /* stop interrupt */ + else flag = 0; /* no change */ + } + + /* flag is >0 = start, <0 = stop or 0 = no change */ + if( flag > 0 ) + { + hwd->hwd_Interrupt.is_Code = (void(*)())enc28j60l_IntServer_List; + hwd->hwd_Interrupt.is_Data = &hwd->hwd_act_boards[0]; + hwd->hwd_Interrupt.is_Node.ln_Type = NT_INTERRUPT; + hwd->hwd_Interrupt.is_Node.ln_Pri = 51; + hwd->hwd_Interrupt.is_Node.ln_Name = (char*)intname; + AddIntServer( HW_INTSOURCE, &hwd->hwd_Interrupt ); + } + + for( i=0 ; i < db->db_NBoards ; i++ ) + { + if( db->db_Units[i].duh_online ) + { + enc28j60l_EnableInterrupt( db->db_Units[i].duh_BASE, FindTask(0), (int)hwd->IntSig, 0 ); + } + else + { + enc28j60l_DisableInterrupt( db->db_Units[i].duh_BASE ); + } + } + + if( flag < 0 ) + { + hwd->hwd_Interrupt.is_Data = (0); + RemIntServer( HW_INTSOURCE, &hwd->hwd_Interrupt ); + hwd->hwd_Interrupt.is_Code = (0); + } + +} +#endif + diff --git a/Driver/baxnet/source/sdnet/hwprivate.h b/Driver/baxnet/source/sdnet/hwprivate.h index 52465e5..ce907e1 100644 --- a/Driver/baxnet/source/sdnet/hwprivate.h +++ b/Driver/baxnet/source/sdnet/hwprivate.h @@ -15,29 +15,49 @@ /* sdnet/v2expnet specific: polling timer */ #include "intervaltimer.h" +#define HW_VENDOR "Henryk Richter" + /* this struct is available in devicebase and should carry global information */ struct HWData { - ULONG SigMask; /* signal mask to wait for in server main instance */ + struct Interrupt hwd_Interrupt; /* keep the interrupt at top of HWData !! */ + APTR hwd_act_boards[MAX_UNITS+1+2+1]; /* poll all active boards by ptr in interrupt, NULL terminated, followed by SigTask,Sigbit */ + /* contents of hwd_act_boards: + 1 ULONG processing ENABLE (1) or DISABLE (0) + n ULONG BOARD LIST, NULL terminated + 1 ULONG SigTask + 1 ULONG SigBit + */ struct IVT_TimerStruct ivtimer; /* Timer interval handling (via Interrupt) */ LONG IntSig; + ULONG SigMask; /* signal mask to wait for in server main instance */ /* config options */ ULONG timervalue; /* polling interval in ms */ ULONG fullduplex; /* force full duplex */ ULONG spispeed; /* SPI clock divider (>=1) */ ULONG multicast; /* multicast recv enable */ + ULONG interrupt; /* enable interrupt */ }; /* referenced from server.c */ #if (defined PROTO_V2EXPNET) -#define HW_CONFIGFILE "ENV:SANA2/v2expeth.config" -#else -#define HW_CONFIGFILE "ENV:SANA2/sdnet.config" -#endif +#define HW_CONFIGFILE "ENV:SANA2/v2expeth.config" +/* appended to COMMON_TEMPLATE */ +#define HW_CONFIGTEMPLATE "TIMER/K/N,FULLDUPLEX/S,SPISPEED/K/N,MULTICAST/S,INTERRUPT/S" +#define HW_PRODUCT "VampireV500V2 ENC28J60 ExpansionPort" + +#else + +#define HW_CONFIGFILE "ENV:SANA2/sdnet.config" /* appended to COMMON_TEMPLATE */ #define HW_CONFIGTEMPLATE "TIMER/K/N,FULLDUPLEX/S,SPISPEED/K/N,MULTICAST/S" +#define HW_PRODUCT "Vampire SDNet ENC28J60" + +/* appended to COMMON_TEMPLATE */ +#endif + /* referenced by server.c, hw.c */ struct HWConfig @@ -47,6 +67,7 @@ struct HWConfig ULONG fullduplex; ULONG *spispeed; ULONG multicast; + ULONG interrupt; }; #endif /* _INC_HWPRIVATE_H */ diff --git a/Driver/baxnet/source/server.c b/Driver/baxnet/source/server.c index 78e7373..15e5c9e 100644 --- a/Driver/baxnet/source/server.c +++ b/Driver/baxnet/source/server.c @@ -15,11 +15,21 @@ #include #include +#ifdef HAVE_VERSION_H +#include "version.h" +#endif + #include "device.h" #include "hw.h" #include "macros.h" #include "server.h" +#ifdef NEWSTYLE +#include +#include /* new extension, code can be built without this include (but also without ext query then...) */ +static LONG server_queryext( DEVBASEP, ULONG unit, struct IOSana2Req *ioreq ); +#endif + /* (avoid external link libraries) this call is not time critical */ static void MemSet( void *a, ULONG val, ULONG size ) @@ -292,6 +302,7 @@ static LONG server_Config( DEVBASEP ) return SERR_OK; } + static LONG CMPeqMAC( BYTE *a, BYTE *b ) { LONG i; @@ -303,6 +314,7 @@ static LONG CMPeqMAC( BYTE *a, BYTE *b ) return 1; } + static LONG server_changeMulticast( DEVBASEP, ULONG unit, struct IOSana2Req *ioreq, ULONG add_del ) { /* step 1: find start address in active list */ @@ -431,7 +443,20 @@ static LONG server_HandleS2Commands( DEVBASEP ) ioreq->ios2_WireError = S2WERR_GENERIC_ERROR; } break; - +#ifdef S2_DEVICEQUERYEXT + case S2_DEVICEQUERYEXT: + if( server_queryext( db, unit, ioreq ) ) + { + ioreq->ios2_Req.io_Error = S2ERR_NO_ERROR; + ioreq->ios2_WireError = S2WERR_GENERIC_ERROR; + } + else + { + ioreq->ios2_Req.io_Error = S2ERR_BAD_ARGUMENT; + ioreq->ios2_WireError = S2WERR_GENERIC_ERROR; + } + break; +#endif default: /* shouldn't happen */ ioreq->ios2_Req.io_Error = S2ERR_NOT_SUPPORTED; ioreq->ios2_WireError = S2WERR_GENERIC_ERROR; @@ -444,6 +469,90 @@ static LONG server_HandleS2Commands( DEVBASEP ) return SERR_OK; } +#ifdef S2_DEVICEQUERYEXT +const char server_vendorstring[] = HW_VENDOR; +const char server_productstring[] = HW_PRODUCT; +static LONG server_queryext( DEVBASEP, ULONG unit, struct IOSana2Req *ioreq ) +{ + struct TagItem *tlist; + ULONG tval,tval2; + LONG len; + struct S2DevQueryExtParam *s2qep; + ULONG *lgp; + + tlist = (struct TagItem*)ioreq->ios2_Data; + + /* 3*4 Bytes needed for one Tag + TAG_DONE */ + if( (ioreq->ios2_DataLength < 12) || (!tlist) ) + return 0; + + tval = GetTagData( S2_DevQueryExtVendorName, 0, tlist ); + if( tval ) + { + s2qep = (struct S2DevQueryExtParam *)tval; + + len = min( s2qep->Length, sizeof(server_vendorstring) ); + CopyMem( (void*)server_vendorstring, s2qep->Data, len ); + s2qep->Actual = len; + } + + tval = GetTagData( S2_DevQueryExtProductName, 0, tlist ); + if( tval ) + { + s2qep = (struct S2DevQueryExtParam *)tval; + + len = min( s2qep->Length, sizeof(server_productstring) ); + CopyMem( (void*)server_productstring, s2qep->Data, len ); + s2qep->Actual = len; + } + + + tval = GetTagData( S2_DevQueryExtLinkStatus, 0, tlist ); + tval2 = GetTagData( S2_DevQueryExtLinkSpeed, 0, tlist ); + if( (tval) || (tval2) ) + { + /* ask hardware about link/speed status */ + len = hw_get_mac_status(db, unit); + if( len != HW_MAC_INVALID ) + { + if( tval ) /* S2_DevQueryExtLinkStatus */ + { + s2qep = (struct S2DevQueryExtParam *)tval; + if( s2qep->Length >= 4 ) + { + lgp = (ULONG*)s2qep->Data; + *lgp = (len & HW_MAC_LINK_UP) ? S2_DEVQUERYEXT_LINK_UP : S2_DEVQUERYEXT_LINK_DOWN; + s2qep->Actual = 4; + } + } + if( tval2 ) /* S2_DevQueryExtLinkSpeed */ + { + s2qep = (struct S2DevQueryExtParam *)tval2; + if( s2qep->Length >= 4 ) + { + lgp = (ULONG*)s2qep->Data; + + tval = S2_DEVQUERYEXT_SPEED_UNDEFINED; + if( len & HW_MAC_LINK_UP) + { + if( HW_MAC_ISACTIVE(len,HW_MACB_SPEED10) ) + tval = S2_DEVQUERYEXT_SPEED_10M; + if( HW_MAC_ISACTIVE(len,HW_MACB_SPEED100) ) + tval = S2_DEVQUERYEXT_SPEED_100M; + if( HW_MAC_ISACTIVE(len,HW_MACB_SPEED1000) ) + tval = S2_DEVQUERYEXT_SPEED_1000M; + } + *lgp = tval; + s2qep->Actual = 4; + } + } + } + } + + return 1; +} + +#endif /* error conditions sent via EventQueue */ @@ -505,7 +614,7 @@ LONG server_writeerror( DEVBASEP, ULONG unit, struct IOSana2Req *ioreq, LONG cod /* note: entering here with locked semaphore */ static LONG write_frame( DEVBASEP, ULONG unit, struct IOSana2Req *ioreq ) { - LONG ret = SERR_OK; + LONG ret;/* = SERR_OK;*/ UBYTE *copy_ptr,*frame; ULONG framesize; struct db_BufferManagement *dbm; @@ -644,6 +753,7 @@ static void server_read_frame( DEVBASEP, ULONG unit, struct IOSana2Req *ioreq, U dbm = (struct db_BufferManagement *)ioreq->ios2_BufferManagement; D(("ReadFrm IO %lx, DBM %lx frm %lx frmsz %ld\n",(ULONG)ioreq,(ULONG)dbm,(ULONG)frame,framesize)); + if(!(*dbm->dbm_CopyToBuffer32)(ioreq->ios2_Data, frame, framesize )) { if(!(*dbm->dbm_CopyToBuffer)(ioreq->ios2_Data, frame, framesize )) @@ -757,7 +867,7 @@ end: VOID SAVEDS ServerTask(void) { struct ServerMsg *msg; - ULONG wmask,gotmask,spcmask,portsigmask,recvmask,i=0,action; + ULONG wmask,gotmask,spcmask,portsigmask,recvmask,i,action; struct IOSana2Req*wr; struct DevUnit *curunit; DEVBASEP = (0); /* Don`t call Libraries until server_startup() succeeds! */ diff --git a/Driver/baxnet/source/smakefile b/Driver/baxnet/source/smakefile new file mode 100644 index 0000000..4aee800 --- /dev/null +++ b/Driver/baxnet/source/smakefile @@ -0,0 +1,169 @@ +############################################################################### +# +# SAS/C Makefile for SDNet and V2EXPETH +# +# author: Henryk Richter +# +# tools required: +# working SAS/C installation (sc:, sc:include and sc:netinclude assigned, +# "sc", "smake" and "slink in path) +# vasm in path (vasmm68k_mot) +# +############################################################################### + +############################################################################### +# Name, version +# +############################################################################### +#DEVICEVERSION=1 +#DEVICEREVISION=95 +#DEVICEDATE=08.09.2018 +#DEVICEEXTRA=Beta + +SUBDIR=sdnet +ASMOBJECTS = $(SUBDIR)/vampuuid.o$(TYPE) $(SUBDIR)/intervaltimer.o$(TYPE) \ + $(SUBDIR)/enc28j60.o$(TYPE) $(SUBDIR)/enc28j60l.o$(TYPE) + +# +# more than one flavour of the same code base may be build with this setup +# +# some arguments are passed down recursively (example): +#DEVICEID=v2expeth.device +#DEFINES1 = -DPROTO_V2EXPNET +#ASMDEFS = -DPROTO_V2EXPNET +#CPU = 68020 + + +############################################################################### +# +# common.smk (SAS/C variant of common.mk) +# +# author: Henryk Richter +# +# note: when switching between different hardware targets, don`t forget +# "make clean" in between +############################################################################### +# debug = 1 will include string debugging for terminal/sushi/sashimi +# not enabled yet in SAS/C makefile +debug = 0 + +############################################################################### +# prefix for system includes (ASM) +# +############################################################################### +PREFX = sc: +SYSINC = $(PREFX)include + + +############################################################################### +# +# compiler executables and support calls +# +############################################################################### +RM = delete force quiet +CC = sc +LD = slink +MAKE = smake +CFLAGS = NOVER NOICONS nostackcheck math=standard strmerge strsect=code parameters=regs data=near opt optsize +LDFLAGS = NOICONS SC SD ND + +VASM = vasmm68k_mot +VASMFORMAT = -m$(CPU) -Fhunk -nowarn=2064 -quiet -I$(SYSINC) + + +############################################################################### +# +# paths to the local includes +# +############################################################################### + +IPATH = + +############################################################################### +# +# compile-level feature definitions +# +############################################################################### + +# see all: target for defaults in $(DEFINES) +DEFINES = $(DEFINES1) CPU=$(CPU) +#DEFINES = $(DEFINES) DEFINE DEVICEVERSION=$(DEVICEVERSION) +#DEFINES = $(DEFINES) DEFINE DEVICEREVISION=$(DEVICEREVISION) +#DEFINES = $(DEFINES) DEFINE DEVICEDATE=$(DEVICEDATE) +#DEFINES = $(DEFINES) DEFINE DEVICEEXTRA=$(DEVICEEXTRA) +DEFINES = $(DEFINES) DEFINE NEWSTYLE=1 +DEFINES = $(DEFINES) DEFINE HAVE_VERSION_H=1 +DEFINES = $(DEFINES) DEFINE DEVICENAME=$(DEVICEID) +ASMDEFS = $(ASMDEFS1) +#-DDEVICEVERSION=$(DEVICEVERSION) -DDEVICEREVISION=$(DEVICEREVISION) + +############################################################################### +# +# debug +# +############################################################################### +#ifeq ($(debug),1) +#CFLAGS += -DDEBUG -g +#CFLAGS2 += -DDEBUG -g +#LINKLIBS = -L$(PREFX)/lib -ldebug +#endif + +############################################################################### +# +# compiler flags and optimization levels +# +############################################################################### + +CFLAGS = $(CFLAGS) INCLUDEDIR="" INCLUDEDIR=$(SUBDIR) $(DEFINES) + +############################################################################### +# +# objects to build +# +############################################################################### +# ASM based alternative to deviceheader.o would be romtag.o + +OBJECTS = deviceheader.o$(TYPE) deviceinit.o$(TYPE) device.o$(TYPE) \ + server.o$(TYPE) $(SUBDIR)/hw.o$(TYPE) + +OBJECTS = $(OBJECTS) $(ASMOBJECTS) + +BUILDDEPS = device.h server.h hw.h macros.h compiler.h + +############################################################################### +# +# rules and commands +# +############################################################################### + +.asm.o$(TYPE): $(BUILDDEPS) $*.asm + $(VASM) $(VASMFORMAT) $(ASMDEFS) -o $@ $*.asm + +.c.o$(TYPE): $(BUILDDEPS) $*.c + $(CC) $(CFLAGS) OBJECTNAME $@ $*.c + +all: + $(MAKE) TYPE=sd sdnet.device DEVICEID=sdnet.device CPU=68020 + $(MAKE) TYPE=ex v2expeth.device DEVICEID=v2expeth.device CPU=68020 \ + "DEFINES1=DEFINE PROTO_V2EXPNET" ASMDEFS1=-DPROTO_V2EXPNET + +sdnet.device: $(OBJECTS) + -$(LD) $(OBJECTS) LIB sc:lib/sc.lib $(LDFLAGS) TO $(DEVICEID) + +v2expeth.device: $(OBJECTS) + -$(LD) $(OBJECTS) LIB sc:lib/sc.lib $(LDFLAGS) TO $(DEVICEID) + +clean: + -$(RM) sdnet.device v2expeth.device \#?.oex *.osd $(SUBDIR)/\#?.oex $(SUBDIR)/\#?.osd + +install: + copy sdnet.device v2expeth.device DEVS:Networks + + + +# dependencies +device.o$(TYPE): device.c device.h server.h hw.h macros.h compiler.h +server.o$(TYPE): server.c device.h server.h hw.h macros.h compiler.h +deviceinit.o$(TYPE): deviceinit.c device.h server.h hw.h macros.h compiler.h +deviceheader.o$(TYPE): deviceheader.c device.h server.h hw.h macros.h compiler.h + diff --git a/Driver/baxnet/source/smakefile.enc b/Driver/baxnet/source/smakefile.enc new file mode 100644 index 0000000..c578568 --- /dev/null +++ b/Driver/baxnet/source/smakefile.enc @@ -0,0 +1,169 @@ +############################################################################### +# +# SAS/C Makefile for ENC624J6net +# +# author: Henryk Richter +# +# tools required: +# working SAS/C installation (sc:, sc:include and sc:netinclude assigned, +# "sc", "smake" and "slink in path) +# vasm in path (vasmm68k_mot) +# +# call: +# smake -f smakefile.enc +# +############################################################################### + +############################################################################### +# Name, version +# +############################################################################### +#DEVICEVERSION=1 +#DEVICEREVISION=95 +#DEVICEDATE=08.09.2018 +#DEVICEEXTRA=Beta + +SUBDIR=enc624j6net +ASMOBJECTS = $(SUBDIR)/enc624j6l.o$(TYPE) $(SUBDIR)/intervaltimer.o$(TYPE) + + +# more than one flavour of the same code base may be build with this setup +# arguments passed down recursively (example): +#DEVICEID=v2expeth.device +#DEFINES1 = -DPROTO_V2EXPNET +#ASMDEFS = -DPROTO_V2EXPNET +#CPU = 68020 + + +############################################################################### +# +# common.smk (SAS/C variant of common.mk) +# +# author: Henryk Richter +# +# note: when switching between different hardware targets, don`t forget +# "make clean" in between +############################################################################### +# debug = 1 will include string debugging for terminal/sushi/sashimi +# not enabled yet in SAS/C makefile +debug = 0 + +############################################################################### +# prefix for system includes (ASM) +# +############################################################################### +PREFX = sc: +SYSINC = $(PREFX)include + + +############################################################################### +# +# compiler executables and support calls +# +############################################################################### +RM = delete force quiet +CC = sc +LD = slink +MAKE = smake +CFLAGS = NOVER NOICONS nostackcheck math=standard strmerge strsect=code parameters=regs data=near opt optsize +LDFLAGS = NOICONS SC SD ND + +VASM = vasmm68k_mot +VASMFORMAT = -m$(CPU) -Fhunk -nowarn=2064 -quiet -I$(SYSINC) + + +############################################################################### +# +# paths to the local includes +# +############################################################################### + +IPATH = + +############################################################################### +# +# compile-level feature definitions +# +############################################################################### + +# see all: target for defaults in $(DEFINES) +DEFINES = $(DEFINES1) CPU=$(CPU) +#DEFINES = $(DEFINES) DEFINE DEVICEVERSION=$(DEVICEVERSION) +#DEFINES = $(DEFINES) DEFINE DEVICEREVISION=$(DEVICEREVISION) +#DEFINES = $(DEFINES) DEFINE DEVICEDATE=$(DEVICEDATE) +DEFINES = $(DEFINES) DEFINE NEWSTYLE=1 +DEFINES = $(DEFINES) DEFINE HAVE_VERSION_H=1 +DEFINES = $(DEFINES) DEFINE DEVICENAME=$(DEVICEID) +#DEFINES = $(DEFINES) DEFINE DEVICEEXTRA=$(DEVICEEXTRA) +ASMDEFS = $(ASMDEFS1) +#-DDEVICEVERSION=$(DEVICEVERSION) -DDEVICEREVISION=$(DEVICEREVISION) + +############################################################################### +# +# debug +# +############################################################################### +#ifeq ($(debug),1) +#CFLAGS += -DDEBUG -g +#CFLAGS2 += -DDEBUG -g +#LINKLIBS = -L$(PREFX)/lib -ldebug +#endif + +############################################################################### +# +# compiler flags and optimization levels +# +############################################################################### + +CFLAGS = $(CFLAGS) INCLUDEDIR="" INCLUDEDIR=$(SUBDIR) $(DEFINES) + +############################################################################### +# +# objects to build +# +############################################################################### +# ASM based alternative to deviceheader.o would be romtag.o + +OBJECTS = deviceheader.o$(TYPE) deviceinit.o$(TYPE) device.o$(TYPE) \ + server.o$(TYPE) $(SUBDIR)/hw.o$(TYPE) + +OBJECTS = $(OBJECTS) $(ASMOBJECTS) + +BUILDDEPS = device.h server.h hw.h macros.h compiler.h + +############################################################################### +# +# rules and commands +# +############################################################################### + +.asm.o$(TYPE): $(BUILDDEPS) $*.asm + $(VASM) $(VASMFORMAT) $(ASMDEFS) -o $@ $*.asm + +.c.o$(TYPE): $(BUILDDEPS) $*.c + $(CC) $(CFLAGS) OBJECTNAME $@ $*.c + +all: + $(MAKE) -f smakefile.enc TYPE=20 enc624j6net.device DEVICEID=enc624j6net.device CPU=68020 + $(MAKE) -f smakefile.enc TYPE=00 enc624j6net.device_68000 DEVICEID=enc624j6net.device CPU=68000 + +enc624j6net.device: $(OBJECTS) + -$(LD) $(OBJECTS) LIB sc:lib/sc.lib $(LDFLAGS) TO $(DEVICEID) + +enc624j6net.device_68000: $(OBJECTS) + -$(LD) $(OBJECTS) LIB sc:lib/sc.lib $(LDFLAGS) TO $(DEVICEID)_68000 + +clean: + -$(RM) enc624j6net.device enc624j6net.device_68000 \#?.o00 *.o20 $(SUBDIR)/\#?.o00 $(SUBDIR)/\#?.o20 + +install: + copy enc624j6net.device DEVS:Networks + + + +# dependencies +device.o$(TYPE): device.c device.h server.h hw.h macros.h compiler.h +server.o$(TYPE): server.c device.h server.h hw.h macros.h compiler.h +deviceinit.o$(TYPE): deviceinit.c device.h server.h hw.h macros.h compiler.h +deviceheader.o$(TYPE): deviceheader.c device.h server.h hw.h macros.h compiler.h + diff --git a/Driver/baxnet/source/version.h b/Driver/baxnet/source/version.h new file mode 100644 index 0000000..28aeab2 --- /dev/null +++ b/Driver/baxnet/source/version.h @@ -0,0 +1,16 @@ +/* + version.h + + (C) 2018 Henryk Richter + + version and date handling +*/ +#ifndef _INC_VERSION_H +#define _INC_VERSION_H + +#define DEVICEVERSION 1 +#define DEVICEREVISION 98 +#define DEVICEEXTRA Beta +#define DEVICEDATE 02.01.2019 + +#endif diff --git a/Logic/LAN_IDE/LAN_IDE.gise b/Logic/LAN_IDE/LAN_IDE.gise index 18b80ab..e36f04c 100644 --- a/Logic/LAN_IDE/LAN_IDE.gise +++ b/Logic/LAN_IDE/LAN_IDE.gise @@ -32,6 +32,7 @@ + @@ -39,10 +40,13 @@ + + + @@ -63,10 +67,12 @@ - + + + @@ -84,31 +90,38 @@ - + + - - + + + + + + + + + + + + - + - - - - diff --git a/Logic/LAN_IDE/LAN_IDE.xise b/Logic/LAN_IDE/LAN_IDE.xise index 0ee7371..18101b5 100644 --- a/Logic/LAN_IDE/LAN_IDE.xise +++ b/Logic/LAN_IDE/LAN_IDE.xise @@ -63,7 +63,7 @@ - + @@ -97,7 +97,7 @@ - + @@ -112,7 +112,7 @@ - + @@ -155,7 +155,7 @@ - + diff --git a/Logic/LAN_IDE/LAN_IDE_CP.vhd b/Logic/LAN_IDE/LAN_IDE_CP.vhd index 7ad1542..10bc2f3 100644 --- a/Logic/LAN_IDE/LAN_IDE_CP.vhd +++ b/Logic/LAN_IDE/LAN_IDE_CP.vhd @@ -738,7 +738,7 @@ begin CP_RD_S <= not RW; CP_WE_S <= RW; end if; - CP_WE_QUIRK <= CP_WE_S; + CP_WE_QUIRK <= CP_WE_S; --the clockport write must be low exactly one 7MHz cycle! end if; end process cp_rw_gen; diff --git a/Logic/LAN_IDE/LAN_IDE_CP_envsettings.html b/Logic/LAN_IDE/LAN_IDE_CP_envsettings.html index 7702385..63110bd 100644 --- a/Logic/LAN_IDE/LAN_IDE_CP_envsettings.html +++ b/Logic/LAN_IDE/LAN_IDE_CP_envsettings.html @@ -146,7 +146,7 @@ -fsm_encoding   -Auto +Compact AUTO diff --git a/Logic/LAN_IDE/LAN_IDE_CP_summary.html b/Logic/LAN_IDE/LAN_IDE_CP_summary.html index 31b92c3..3cc93e5 100644 --- a/Logic/LAN_IDE/LAN_IDE_CP_summary.html +++ b/Logic/LAN_IDE/LAN_IDE_CP_summary.html @@ -13,7 +13,7 @@ Module Name: LAN_IDE_CP Implementation State: -Translated +Fitted Target Device: @@ -25,7 +25,7 @@ No Errors Product Version:ISE 14.7
  • Warnings:
-53 Warnings (1 new) +46 Warnings (0 new) Design Goal: @@ -65,9 +65,9 @@ System Settings Detailed Reports [-] Report NameStatusGenerated ErrorsWarningsInfos -Synthesis ReportCurrentMi 2. Jan 00:55:49 2019052 Warnings (1 new)10 Infos (0 new) -Translation ReportCurrentMi 2. Jan 00:55:56 201901 Warning (0 new)0 -CPLD Fitter Report (Text)Out of DateMi 2. Jan 00:55:22 201908 Warnings (1 new)1 Info (1 new) +Synthesis ReportCurrentDo 3. Jan 00:09:07 2019046 Warnings (0 new)10 Infos (0 new) +Translation ReportCurrentDo 3. Jan 00:09:14 2019000 +CPLD Fitter Report (Text)CurrentDo 3. Jan 00:09:53 201903 Warnings (1 new)1 Info (1 new) Power Report       
@@ -77,5 +77,5 @@ System Settings
-
Date Generated: 01/02/2019 - 00:55:58
+
Date Generated: 01/03/2019 - 00:29:33
\ No newline at end of file diff --git a/Logic/LAN_IDE/iseconfig/LAN_IDE.projectmgr b/Logic/LAN_IDE/iseconfig/LAN_IDE.projectmgr index 705e3e2..059c995 100644 --- a/Logic/LAN_IDE/iseconfig/LAN_IDE.projectmgr +++ b/Logic/LAN_IDE/iseconfig/LAN_IDE.projectmgr @@ -79,13 +79,13 @@ 1 - + 0 0 000000ff000000000000000100000001000000000000000000000000000000000000000000000000f8000000010000000100000000000000000000000064ffffffff000000810000000000000001000000f80000000100000000 false - + diff --git a/Logic/LAN_IDE/iseconfig/LAN_IDE_CP.xreport b/Logic/LAN_IDE/iseconfig/LAN_IDE_CP.xreport index cf1ee38..9cdfc6a 100644 --- a/Logic/LAN_IDE/iseconfig/LAN_IDE_CP.xreport +++ b/Logic/LAN_IDE/iseconfig/LAN_IDE_CP.xreport @@ -1,9 +1,9 @@
- 2019-01-02T00:24:39 + 2019-01-03T00:29:34 LAN_IDE_CP - 2018-12-17T23:59:32 + 2019-01-02T00:55:58 C:/Users/Matze/Amiga/Hardwarehacks/Zorro-LAN-IDE/Logic/LAN_IDE/iseconfig/LAN_IDE_CP.xreport C:/Users/Matze/Amiga/Hardwarehacks/Zorro-LAN-IDE/Logic/LAN_IDE\ 2016-12-13T22:08:29