diff --git a/Driver/baxnet/source/Common.mk b/Driver/baxnet/source/Common.mk index a9a6e89..3a71d0a 100644 --- a/Driver/baxnet/source/Common.mk +++ b/Driver/baxnet/source/Common.mk @@ -21,7 +21,7 @@ # debug = 1 will include string debugging for terminal/sushi/sashimi debug = 0 # compiler_vcc = 1 will trigger VBCC, else GCC -compiler_vcc = 0 +compiler_vcc = 1 ############################################################################### # prefix for system includes (ASM) @@ -45,6 +45,8 @@ LINKEXE = vlink -bamigahunk -x -s -mrel -Cvbcc -Bstatic #LINK = $(CCX) -nostdlib CFLAGS = -Os -+ -sc -c99 -cpu=$(CPU) CFLAGS2 = -Os -+ -sc -c99 -cpu=$(CPU2) +VASMFORMAT = -m$(CPU) -Fhunk -nowarn=2064 -quiet -I$(SYSINC) +VASMFORMAT2 = -m$(CPU2) -Fhunk -nowarn=2064 -quiet -I$(SYSINC) else @@ -54,12 +56,12 @@ LINK = $(CCX) -nostartfiles -s LINKEXE = $(CCX) -s -noixemul CFLAGS = -O3 -s -m$(CPU) -Wall -noixemul -mregparm=4 -fomit-frame-pointer -msoft-float -noixemul CFLAGS2 = -O3 -s -m$(CPU2) -Wall -noixemul -mregparm=4 -fomit-frame-pointer -msoft-float -noixemul +VASMFORMAT = -m$(CPU) -Faout -nowarn=2064 -quiet -I$(SYSINC) +VASMFORMAT2 = -m$(CPU2) -Faout -nowarn=2064 -quiet -I$(SYSINC) endif VASM = vasmm68k_mot -VASMFORMAT = -m$(CPU) -Fhunk -nowarn=2064 -quiet -I$(SYSINC) -VASMFORMAT2 = -m$(CPU2) -Fhunk -nowarn=2064 -quiet -I$(SYSINC) # unused here #HOST = $(shell uname) @@ -91,7 +93,11 @@ DEFINES += -DNEWSTYLE #DEFINES2 += -DDEVICEVERSION=$(DEVICEVERSION) -DDEVICEREVISION=$(DEVICEREVISION) #DEFINES2 += -DDEVICEDATE=$(DEVICEDATE) #DEFINES2 += -DDEVICEEXTRA=$(DEVICEEXTRA) +ifeq ($(SAME_DEVNAME),1) +DEFINES2 += -DDEVICENAME="$(DEVICEID)" +else DEFINES2 += -DDEVICENAME="$(DEVICEID2)" +endif DEFINES2 += -DHAVE_VERSION_H=1 DEFINES2 += -DNEWSTYLE #ASMDEFS2 += -DDEVICEVERSION=$(DEVICEVERSION) -DDEVICEREVISION=$(DEVICEREVISION) @@ -110,7 +116,11 @@ DEFINES += -DNEWSTYLE #DEFINES2 += -D"DEVICEVERSION=$(DEVICEVERSION)" -D"DEVICEREVISION=$(DEVICEREVISION)" #DEFINES2 += -D"DEVICEDATE=$(DEVICEDATE)" -D"DEVICENAME="$(DEVICEID2)"" #DEFINES2 += -D"DEVICEEXTRA=$(DEVICEEXTRA)" +ifeq ($(SAME_DEVNAME),1) +DEFINES2 += -D"DEVICENAME="$(DEVICEID)"" +else DEFINES2 += -D"DEVICENAME="$(DEVICEID2)"" +endif DEFINES2 += -DHAVE_VERSION_H=1 DEFINES2 += -DNEWSTYLE #ASMDEFS2 += -DDEVICEVERSION=$(DEVICEVERSION) -DDEVICEREVISION=$(DEVICEREVISION) diff --git a/Driver/baxnet/source/Makefile.enc b/Driver/baxnet/source/Makefile.enc index 195a592..5fd867a 100644 --- a/Driver/baxnet/source/Makefile.enc +++ b/Driver/baxnet/source/Makefile.enc @@ -40,6 +40,8 @@ DEFINES2 = # -DPROTO_V2EXPNET ASMDEFS2 = # -DPROTO_V2EXPNET CPU2 = 68000 +SAME_DEVNAME=1 + ############################################################################### # import generic ruleset # diff --git a/Driver/baxnet/source/debug.i b/Driver/baxnet/source/debug.i index e31327e..5d30d41 100644 --- a/Driver/baxnet/source/debug.i +++ b/Driver/baxnet/source/debug.i @@ -1,4 +1,3 @@ -;APS00000000000000000000000000000000000000000000000000000000000000000000000000000000 ; ifd DEBUG ; XDEF _AbsExecBase ; XDEF _LVORawDoFmt diff --git a/Driver/baxnet/source/device.c b/Driver/baxnet/source/device.c index cc2662e..708066f 100644 --- a/Driver/baxnet/source/device.c +++ b/Driver/baxnet/source/device.c @@ -62,6 +62,7 @@ const UWORD dev_supportedcmds[] = { 0 }; + const struct NSDeviceQueryResult NSDQueryAnswer = { 0, 16, /* up to SupportedCommands (inclusive) */ @@ -75,6 +76,14 @@ const struct NSDeviceQueryResult NSDQueryAnswer = { #include "hw.h" #include "macros.h" +const ULONG blub[6] = { + 0xDEADCAFE, + sizeof(struct Sana2DeviceStats), + sizeof(struct ServerData), + sizeof(struct DevUnit), + sizeof(struct devbase) +}; + /* enable heavy debug (D2=beginIO) */ #define D2(x) #define D4(x) diff --git a/Driver/baxnet/source/device.h b/Driver/baxnet/source/device.h index 4938f23..eb948b3 100644 --- a/Driver/baxnet/source/device.h +++ b/Driver/baxnet/source/device.h @@ -213,7 +213,7 @@ struct MCastEntry /* PROTOS */ -ASM LONG LibNull( void ); +//ASM LONG LibNull( void ); ASM SAVEDS struct Device *DevInit(ASMR(d0) DEVBASEP ASMREG(d0), ASMR(a0) BPTR seglist ASMREG(a0), diff --git a/Driver/baxnet/source/deviceheader.c b/Driver/baxnet/source/deviceheader.c index eb9a74f..6890940 100644 --- a/Driver/baxnet/source/deviceheader.c +++ b/Driver/baxnet/source/deviceheader.c @@ -22,19 +22,45 @@ #include "device.h" /* Enable this if you want pure C for the device. (disable compilation of romtag.asm in that case) - I personally prefer the small ASM blob to steer away from linking challenges. + I personally prefer a small ASM blob to steer away from linking challenges. */ #if 1 - -ASM LONG LibNull( void ) -{ - return 0; -} - extern const char DeviceName[]; extern const char DeviceVersionString[]; extern const APTR DeviceInitTab[]; +/* force moveq #0,d0;rts in front of the ROMTAG */ +#if 1 +struct myrt0 { + ULONG ret0; + struct Resident rt; +}; + +/* There is a trick here: + LibNull() is actually a function returning 0 +*/ +const struct myrt0 LibNull = +{ + 0x70004E75, + { + RTC_MATCHWORD, + ( struct Resident* ) ((char *)&LibNull+sizeof(ULONG)), + ( struct Resident* ) ((char *)&LibNull+sizeof(ULONG)+sizeof(struct Resident)), + RTF_AUTOINIT, + DEVICEVERSION, + NT_DEVICE, + 0, + (char*)DeviceName, + (char*)DeviceVersionString+6, + (APTR)DeviceInitTab + } +}; +#else +/* hope that the compiler will put LibNull first */ +ASM LONG LibNull( void ) +{ + return 0; +} static const struct Resident _00RomTag = { RTC_MATCHWORD, ( struct Resident* ) &_00RomTag, @@ -49,5 +75,7 @@ static const struct Resident _00RomTag = { }; #endif +#endif + diff --git a/Driver/baxnet/source/deviceinit.c b/Driver/baxnet/source/deviceinit.c index 010dcad..b679947 100644 --- a/Driver/baxnet/source/deviceinit.c +++ b/Driver/baxnet/source/deviceinit.c @@ -32,6 +32,7 @@ static const char _DeviceVersionString[] = "$VER: " xstr(DEVICENAME) " " xstr(DE const char *DeviceVersionString = (const char *)_DeviceVersionString; const char DeviceName[] = xstr(DEVICENAME); +ASM LONG LibNull( void ); const APTR DeviceFunctions[] = { (APTR) DevOpen, diff --git a/Driver/baxnet/source/enc624j6net/enc624j6l.asm b/Driver/baxnet/source/enc624j6net/enc624j6l.asm index 6ab6e43..8193021 100755 --- a/Driver/baxnet/source/enc624j6net/enc624j6l.asm +++ b/Driver/baxnet/source/enc624j6net/enc624j6l.asm @@ -22,6 +22,7 @@ ; enable debugging code block (comment/uncomment, see below) DEBUG EQU 0 GLOBALINT_BOARD EQU 1 ;if 1, then toggle board interrupt, else ENC624 INTIE +OPT_AVOID_DEFAULT_RESETS EQU 0 ;if 1, then check valid Microchip MAC OUI and don't reset the whole chip if the MAC address is ok incdir src:baxnet/trunk/source/ ;Temp:Amiga/src/Zorro-LAN-IDE.git/Driver/enc624j6net/ @@ -375,6 +376,7 @@ txtestlen EQU *-txtestframe ; Please note that this call will overwrite Board registers and ; buffer memory. Call before initialization. _enc624j6l_CheckBoard: ;check whether board is operating correctly +a movem.l d1-d2/a0-a1,-(sp) move.l a0,d0 @@ -395,17 +397,72 @@ _enc624j6l_CheckBoard: ;check whether board is operating correctly SETREG EUDAST,a0,d0 ;clear ENC's bus (does not change anything in its regs) READREG EUDAST,a0,d0 ; cmp.w d0,d1 ;do we get the register back ? - bne.s .err ;no -> complain + bne .err ;no -> complain + ; ------------- second initial check: can we read/write all bits? ----- + move.w #$5555,d1 + move.w d1,(a0) ;write into memory + moveq #0,d0 + SETREG EUDAST,a0,d0 ;clear ENC's bus (does not change anything in its regs) + move.w (a0),d0 + cmp.w d0,d1 ;do we get the data back ? + bne .err ;no -> complain + + not.w d1 ;move.w #$AAAA,d1 ;d1 was $5555 + move.w d1,(a0) ;write into memory + moveq #0,d0 + SETREG EUDAST,a0,d0 ;clear ENC's bus (does not change anything in its regs) + move.w (a0),d0 + cmp.w d0,d1 ;do we get the register back ? + bne .err ;no -> complain + + ; ---------------- disable board interrupt (for now) ------------------ moveq #0,d0 ;magic trick: the board enables Interrupts lea $4000(a0),a0 move.w d0,($4000,a0) ;0=disable interrupt lea -$4000(a0),a0 - ; ------------------------- reset device ------------------------------ move #EIR_CRYPTEN|EIR_MODEXIF|EIR_HASHIF|EIR_AESIF|EIR_LINKIF|EIR_PRDYIF|EIR_PKTIF|EIR_DMAIF|EIR_TXIF|EIR_TXABTIF|EIR_RXABTIF|EIR_PCFULIF,d0 CLRREG EIR,a0,d0 + ; ------------------------- reset device ------------------------------ + ifne OPT_AVOID_DEFAULT_RESETS + + READREG ESTAT,a0,d0 + and #(ESTAT_CLKRDY|ESTAT_RSTDONE|ESTAT_PHYRDY),d0 + cmp #(ESTAT_CLKRDY|ESTAT_RSTDONE|ESTAT_PHYRDY),d0 + bne.s .dorst + ; chip seems alive + + ; check whether the OUI part of the MAC address is valid, + ; by comparing with OUIs registered to Microchip + lea MAADR1L+2(a0),a1 ;after first pair of bytes + move.w -(a1),d0 + rol.w #8,d0 + swap d0 + move.w -(a1),d0 + lsl.w #8,d0 ;OUI<<8 + lea .valid_microchip_ouis(pc),a1 +.ouiloop: + tst.l (a1) + beq.s .dorst + cmp.l (a1)+,d0 + beq.s .norst + bra.s .ouiloop + +; 32 bit per entry, 0-terminated +.valid_microchip_ouis: + dc.b $00,$04,$A3,0 + dc.b $00,$1E,$C0,0 + dc.b $04,$91,$62,0 + dc.b $54,$10,$EC,0 + dc.b $80,$1F,$12,0 + dc.b $D8,$80,$39,0 + dc.b 0,0,0,0 + +.dorst: + endc OPT_AVOID_DEFAULT_RESETS + ; ifne _OPT_LONGRESET ; moveq #ECON2_ETHRST,d0 ; swap d0 @@ -433,7 +490,7 @@ _enc624j6l_CheckBoard: ;check whether board is operating correctly READREG EUDAST,A0,d0 tst.w d0 ;should have gone to 0 after reset bne.s .err ;(see above, we've written $1234) - +.norst ifne 0 ;---------- short RAM check - write phase ---------------------------- diff --git a/Driver/baxnet/source/enc624j6net/hwprivate.h b/Driver/baxnet/source/enc624j6net/hwprivate.h index ecf0992..3f2127f 100644 --- a/Driver/baxnet/source/enc624j6net/hwprivate.h +++ b/Driver/baxnet/source/enc624j6net/hwprivate.h @@ -11,6 +11,7 @@ #define _INC_HWPRIVATE_H #include "compiler.h" +#include /* sdnet/v2expnet specific: polling timer */ #include "intervaltimer.h" @@ -22,7 +23,7 @@ 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+3+1]; /* poll all active boards by ptr in interrupt, MAGIC_WORD INIT, NULL terminated, followed by SigTask,Sigbit,ExecBase */ + 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/hw.h b/Driver/baxnet/source/hw.h index 28232a3..504b16b 100644 --- a/Driver/baxnet/source/hw.h +++ b/Driver/baxnet/source/hw.h @@ -51,7 +51,7 @@ struct devbase; #define HW_MACB_SPEEDS_END 18 /* this is the next free bit */ #define HW_MAC_SPEEDSMASK ((1<Actual = lastidx; } +#else +#warning "Building server.c without S2_DevQueryExtGetMII" #endif #ifdef S2_DevQueryExtSetMII tval = GetTagData( S2_DevQueryExtSetMII, 0, tlist ); @@ -846,8 +848,8 @@ static LONG server_writequeue( DEVBASEP, ULONG unit ) type = GetSucc( type ); } } - db->db_Units[unit].du_DevStats.PacketsSent++; + ioreq->ios2_Req.io_Error = S2ERR_NO_ERROR; ioreq->ios2_WireError = S2WERR_GENERIC_ERROR; REMOVE( (struct Node*)ioreq ); diff --git a/Driver/baxnet/source/version.h b/Driver/baxnet/source/version.h index 497f59b..1a2b383 100644 --- a/Driver/baxnet/source/version.h +++ b/Driver/baxnet/source/version.h @@ -9,9 +9,9 @@ #define _INC_VERSION_H #define DEVICEVERSION 2 -#define DEVICEREVISION 3 +#define DEVICEREVISION 4 #define DEVICEEXTRA /* #define DEVICEEXTRA Beta */ -#define DEVICEDATE 04.04.2019 +#define DEVICEDATE 27.05.2019 #endif