diff --git a/Driver/baxnet/README b/Driver/baxnet/README index b9e8b62..5c70646 100644 --- a/Driver/baxnet/README +++ b/Driver/baxnet/README @@ -1,17 +1,29 @@ -Short: V2.00, SANA-II network drivers for several adapters +Short: V2.15, SANA-II network drivers for several adapters Author: Henryk Richter Uploader: henryk.richter@gmx.net Type: driver/net Architecture: m68k-amigaos Requires: OS 2.04+ -This package contains network drivers for the following hardware: -- ZII LAN IDE CP (matze, scrat and buggs @a1k.org) +This package contains network drivers and test utilities for the +following hardware: + +- ZII LAN IDE CP (matze and buggs @a1k.org) OSS Zorro-II card with ENC624J600 ethernet controller, autoboot - IDE and Clockport + IDE and Clockport (see https://gitlab.com/MHeinrichs/Zorro-LAN-IDE) + - Vampire500/600 with ENC28J60 module connected to the SD-card slot -- Vampire500V2+ with ENC28J60 module connected to the expansion port + (sdnet.device) -Full source code is included. Please refer to README.sdnet and -README.enc for installation and operation instructions +- Vampire500V2+ or Vampire1200V2 with ENC28J60 module connected to + the expansion port (v2expeth.device) + +- Vampire500V2+ with Wiznet W5500 module connected to the expansion + port (requires adapter PCB) + +- VampireV4 (assumes HW registers didn't change since the time of my + initial implementation, YMMV) + +Full source code (GPL V3) 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 97d548d..31235c9 100644 --- a/Driver/baxnet/README.enc +++ b/Driver/baxnet/README.enc @@ -1,10 +1,9 @@ -ENC624J6Net - A SANA-II driver for the Scratze card +ENC624J6Net - A SANA-II driver for the Zorro-LAN-IDE card ENC624J6Net Copyright (C) 2018 Henryk Richter This driver is supposed to support ENC624J600 based ethernet on the -ZII LAN IDE CP card designed by Matze (a1k.org), Buggs (a1k.org) -and Scrat (a1k.org). +ZII LAN IDE CP card designed by Matze (a1k.org) and Buggs (a1k.org). Please see at the end of the file for information about licensing conditions. @@ -23,8 +22,8 @@ the 68000/68010 version to enc624j6net.device before use. So far, successful tests have been done with the free AmiTCP/IP 3.0b2, AmiTCP4.0-4.2, Genesis, MiamiDX and RoadShow. -The Zorro board itself should be visible in early startup with manufacturer -ID 2588 and card ID 123. +The Zorro board itself should be visible in Early Startup and ShowConfig +with manufacturer ID 2588 and card ID 123. @@ -34,10 +33,10 @@ Configuration options No special configuration of the driver is necessary for normal operation. The configuration options outlined below are documented for tuning purposes. -The config to be placed in ENVARC:sana2/enc624j6net.config and consists +The config is to be placed in ENVARC:sana2/enc624j6net.config and consists of a single line with parameters (much like CLI parameters). -PRIORITY=PRI/K/N,BPS/K/N,MTU/K/N,FULLDUPLEX/S,FLOWCONTROL/S,TIMER/K/N,MULTICAST/S +PRIORITY=PRI/K/N,BPS/K/N,MTU/K/N,FULLDUPLEX/S,FLOWCONTROL/S,TIMER/K/N,MULTICAST/S,MAC/K FULLDUPLEX - change Ethernet module into full duplex mode, caution: requires manual configuration of duplex mode @@ -60,13 +59,41 @@ PRIORITY=PRI/K/N,BPS/K/N,MTU/K/N,FULLDUPLEX/S,FLOWCONTROL/S,TIMER/K/N,MULTICAST/ FLOWCONTROL - enable automatic flow control that throttles incoming data when the hardware buffer gets full + MAC - explicitly set MAC address (default: read from hardware), + use hexadecimal notation like AA:BB:CC:DD:EE:FF + example (useful for DSL via PPPoE with AmiTCP): echo "MTU=1492 PRIORITY=6" >ENVARC:sana2/enc624j6net.config +Troubleshooting: +---------------- + +It has been reported that the MMU.library marked the LAN part +of the card as invalid in at least one Zorro-III configuration +such that the respective I/O space got inaccessible to the driver. +Should "muscan" report "I/O space Invalid" for the slot assigned +to the card (compare with "showConfig" or "Scout->Expansions"),then +an additional line in the MMU configuration file might help. Add +the following to the MMU-Configuration: + +For 2588 123 SetCacheMode {base} 0x10000 Valid CacheInhibit IOSpace Changelog: ---------- +2.15 - fixed multicast mapping code + - added recent Microchip OUIs to MAC address validation list + (2020 and later) + - disabled automatic MMU configuration as commonly redundant + +2.13 - explicit MMU parameters for LAN address space, if mmu.library + is present in the system + +2.11 - try to finish up auto neg and duplex setup when going online + - improved startup/shutdown of the server process + +2.10 - option to set MAC address for first board explicitly + 2.9 - better support for Envoy: automatically select a higher task priority in presence of Envoy services diff --git a/Driver/baxnet/bin/enc624j6net.device b/Driver/baxnet/bin/enc624j6net.device old mode 100644 new mode 100755 index a72d620..6f798bb 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 old mode 100644 new mode 100755 index 8e977e2..419d35c Binary files a/Driver/baxnet/bin/enc624j6net.device_68000 and b/Driver/baxnet/bin/enc624j6net.device_68000 differ diff --git a/Driver/baxnet/bin/miitool b/Driver/baxnet/bin/miitool old mode 100644 new mode 100755 diff --git a/Driver/baxnet/source/Common.mk b/Driver/baxnet/source/Common.mk index e2579df..751a373 100644 --- a/Driver/baxnet/source/Common.mk +++ b/Driver/baxnet/source/Common.mk @@ -27,8 +27,8 @@ compiler_vcc = 0 # prefix for system includes (ASM) # native AmigaOS compilation: set PREFX=GG: or PREFX=ADE:, depending on toolchain ############################################################################### -#PREFX = /opt/amigaos-68k/ -PREFX = gg: +PREFX = /opt/amigaos-68k/ +#PREFX = gg: SYSINC = $(PREFX)os-include ############################################################################### @@ -39,8 +39,9 @@ SYSINC = $(PREFX)os-include ifeq ($(compiler_vcc),1) # VBCC (use explicit vlink line for LINK= if complaints about R_PC happen) +# -Rshort CCX = vc -LINK = vlink -bamigahunk -x -s -mrel -Cvbcc -Bstatic -nostdlib #-Rshort +LINK = vlink -bamigahunk -x -s -mrel -Cvbcc -Bstatic -nostdlib -Rshort LINKEXE = vlink -bamigahunk -x -s -mrel -Cvbcc -Bstatic #LINK = $(CCX) -nostdlib CFLAGS = -Os -+ -sc -c99 -cpu=$(CPU) @@ -138,6 +139,7 @@ ifeq ($(debug),1) CFLAGS += -DDEBUG -g CFLAGS2 += -DDEBUG -g #LINKLIBS = -L$(PREFX)/lib -ldebug +#ASMOBJECTS += kprintf.o endif ############################################################################### diff --git a/Driver/baxnet/source/Makefile.enc b/Driver/baxnet/source/Makefile.enc index d560df1..86f45ae 100644 --- a/Driver/baxnet/source/Makefile.enc +++ b/Driver/baxnet/source/Makefile.enc @@ -23,7 +23,7 @@ #DEVICEREVISION=95 #DEVICEDATE=08.09.2018 SUBDIR=enc624j6net -ASMOBJECTS = $(SUBDIR)/enc624j6l.o $(SUBDIR)/intervaltimer.o kprintf.o +ASMOBJECTS = $(SUBDIR)/enc624j6l.o $(SUBDIR)/intervaltimer.o kprintf.o #mmustuff.o ############################################################################### # Devices to build (1 or 2, keep DEVICEID2 empty if only one build is desired) @@ -31,13 +31,13 @@ ASMOBJECTS = $(SUBDIR)/enc624j6l.o $(SUBDIR)/intervaltimer.o kprintf.o ############################################################################### DEVICEID=enc624j6net.device -DEFINES = -DHW_DMA_TX # -DPROTO_V2EXPNET -ASMDEFS = -DHW_DMA_TX # -DPROTO_V2EXPNET +DEFINES = -DHW_DMA_TX #-DUSEMMU # +ASMDEFS = -DHW_DMA_TX # CPU = 68060 DEVICEID2=enc624j6net.device_68000 -DEFINES2 = # -DPROTO_V2EXPNET -ASMDEFS2 = # -DPROTO_V2EXPNET +DEFINES2 = # +ASMDEFS2 = # CPU2 = 68000 SAME_DEVNAME=1 diff --git a/Driver/baxnet/source/Makefile.v4 b/Driver/baxnet/source/Makefile.v4 new file mode 100644 index 0000000..c5351f4 --- /dev/null +++ b/Driver/baxnet/source/Makefile.v4 @@ -0,0 +1,50 @@ +############################################################################### +# +# VAMPIREGFX makefile for vbcc +# +# author: Henryk Richter +# +# concept: +# +# tools required: +# - vbcc, defaulting to m68k-amigaos +# - vlink +# - vasm +# +# porting: +# +############################################################################### + +############################################################################### +# Date, version, extra objects to build +# +############################################################################### +#DEVICEVERSION=1 +#DEVICEREVISION=95 +#DEVICEDATE=08.09.2018 +SUBDIR=v4net +ASMOBJECTS = $(SUBDIR)/vampuuid.o $(SUBDIR)/v4l.o $(SUBDIR)/intervaltimer.o kprintf.o + +############################################################################### +# Devices to build (1 or 2, keep DEVICEID2 empty if only one build is desired) +# +############################################################################### + +DEVICEID=v4net.device +DEFINES = #-DHW_DMA_TX # -DPROTO_V2EXPNET +ASMDEFS = #-DHW_DMA_TX # -DPROTO_V2EXPNET +CPU = 68060 + +#DEVICEID2=v4net.device_68000 +#DEFINES2 = # -DPROTO_V2EXPNET +#ASMDEFS2 = # -DPROTO_V2EXPNET +#CPU2 = 68000 +#SAME_DEVNAME=1 + +############################################################################### +# import generic ruleset +# +############################################################################### +include Common.mk + + diff --git a/Driver/baxnet/source/Makefile.vwiz b/Driver/baxnet/source/Makefile.vwiz new file mode 100644 index 0000000..dff25a5 --- /dev/null +++ b/Driver/baxnet/source/Makefile.vwiz @@ -0,0 +1,51 @@ +############################################################################### +# +# VWiznet build instructions +# +# 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) +# - vlink or GNU ld +# - vasm (vasmm68k_mot) +# - system headers (default: /opt/amigaos-68k/os-include, see Common.mk) +# +# porting: +# see smakefile for native building using SAS/C +# +############################################################################### + +############################################################################### +# Name, version +# +############################################################################### +#DEVICEVERSION=1 +#DEVICEREVISION=95 +#DEVICEDATE=09.09.2018 +#DEVICEEXTRA=Beta +ASMOBJECTS = $(SUBDIR)/vampuuid.o $(SUBDIR)/intervaltimer.o $(SUBDIR)/w5500l.o +SUBDIR=qwiznet + +# two flavours of the same code base may be build with this setup +# leave DEVICEID2 empty to disable second build +DEVICEID=vwiznet600sd.device +DEFINES = # -DPROTO_V2EXPNET +ASMDEFS = # -DPROTO_V2EXPNET +CPU = 68060 + +DEVICEID2=vwiznet500ex.device +DEFINES2 = -DPROTO_V2EXPNET +ASMDEFS2 = -DPROTO_V2EXPNET +CPU2 = 68020 + +############################################################################### +# import generic ruleset +# +############################################################################### + +include Common.mk + diff --git a/Driver/baxnet/source/device.c b/Driver/baxnet/source/device.c index 5346b91..313e5a7 100644 --- a/Driver/baxnet/source/device.c +++ b/Driver/baxnet/source/device.c @@ -120,6 +120,8 @@ ASM SAVEDS struct Device *DevInit( ASMR(d0) DEVBASEP ASMREG(d0) db->db_SegList = seglist; db->db_Flags = 0; + InitSemaphore( &db->db_Sem ); /* server start/stop/online/offline */ + dbNewList( &db->db_BufferManagement ); for(i=0 ; i < MAX_UNITS ; i++ ) @@ -137,9 +139,12 @@ ASM SAVEDS struct Device *DevInit( ASMR(d0) DEVBASEP ASMREG(d0) } ok = 0; - if( (DOSBase = OpenLibrary("dos.library", 36)) ) + if( (DOSBase = OpenLibrary( (STRPTR)"dos.library", 36)) ) { - if( (UtilityBase = OpenLibrary("utility.library", 37)) ) +#ifdef USEMMU + MMUBase = OpenLibrary( (STRPTR)"mmu.library",46 ); +#endif + if( (UtilityBase = OpenLibrary( (STRPTR)"utility.library", 37)) ) { /* Search HW */ ok = hw_Find_Boards( db ); @@ -182,10 +187,16 @@ ASM SAVEDS LONG DevOpen( ASMR(a1) struct IOSana2Req *ioreq ASMREG(a1), D(("DevOpen for %ld\n",unit)); - db->db_Lib.lib_OpenCnt++; /* avoid Expunge, see below for separate "unit" open count */ + /* avoid Expunge, see below for separate "unit" open count */ + //ObtainSemaphore( &db->db_Sem ); /* probably overkill */ + db->db_Lib.lib_OpenCnt++; + //ReleaseSemaphore( &db->db_Sem ); + db->db_ID++; /* opener ID (always >0) */ - if( unit < db->db_NBoards ) + if( (unit < db->db_NBoards) && + (ioreq->ios2_Req.io_Message.mn_Length >= sizeof( struct IOSana2Req ) ) + ) { ObtainSemaphore( &db->db_Units[unit].du_Sem ); /* lock current board */ @@ -222,9 +233,6 @@ ASM SAVEDS LONG DevOpen( ASMR(a1) struct IOSana2Req *ioreq ASMREG(a1), if( flags & SANA2OPF_PROM ) /* implies _MINE by spec */ db->db_Units[unit].du_Flags |= DUF_PROMISC; - hw_GetMacAddress( db, unit, &db->db_Units[unit].du_HWAddr[0] ); - hw_GetMacAddress( db, unit, &db->db_Units[unit].du_CFGAddr[0] ); - ok = 0; dbm = (struct db_BufferManagement *)AllocMem( sizeof(struct db_BufferManagement),MEMF_ANY|MEMF_CLEAR); if( dbm ) @@ -246,7 +254,7 @@ ASM SAVEDS LONG DevOpen( ASMR(a1) struct IOSana2Req *ioreq ASMREG(a1), /* v1.95: disabled CopyToBuffer32 due to problems with MiamiDX */ /* v1.99: try identifying Miami */ /* MiamiDX requires byte count to be a multiple of 4 */ - if( FindPort("MIAMI.1") ) /* Miami active ? */ + if( FindPort( (STRPTR)"MIAMI.1") ) /* Miami active ? */ { dbm->dbm_CopyToBuffer32 = (0); dbm->dbm_CopyFromBuffer32 = (0); @@ -269,11 +277,19 @@ ASM SAVEDS LONG DevOpen( ASMR(a1) struct IOSana2Req *ioreq ASMREG(a1), dbm->dbm_ID = db->db_ID; ok = 1; } + + /* the server is started with the Semaphore locked, to avoid + the race condition of getting instantiated twice + */ if( ok ) { /* start server if necessary */ ok = dbStartServer( db, unit ); } + + hw_GetMacAddress( db, unit, &db->db_Units[unit].du_HWAddr[0] ); + hw_GetMacAddress( db, unit, &db->db_Units[unit].du_CFGAddr[0] ); + if( ok ) { ret = 0; @@ -352,8 +368,12 @@ ASM SAVEDS BPTR DevClose( ASMR(a1) struct IOSana2Req *ioreq ASMREG(a1), (db->db_Units[unit].du_Flags & DUF_ONLINE ) ) { +#if 1 + dbSignalServer( db , SIGBREAKF_CTRL_D, 1 ); /* signal server to shut down unit (and lock the semaphore while doing so) */ +#else Signal( (struct Task*)db->db_ServerProc, SIGBREAKF_CTRL_D); Delay(1); +#endif } ObtainSemaphore( &db->db_Units[unit].du_Sem ); /* lock current board */ @@ -365,6 +385,30 @@ ASM SAVEDS BPTR DevClose( ASMR(a1) struct IOSana2Req *ioreq ASMREG(a1), ReleaseSemaphore( &db->db_Units[unit].du_Sem ); +#if 1 + /* now check if the device is no longer in use in any unit (=global OpenCnt) + and shut down server if that is the case + */ + ObtainSemaphore( &db->db_Sem ); + if( db->db_Lib.lib_OpenCnt == 0 ) + { + ULONG i; + struct SanaReadType *type; + + dbStopServer(db,0); + + for( i=0 ; i < db->db_NBoards ; i++ ) + { + while( (type = GetHead( &db->db_Units[i].du_ReadTypes ) )) + { + dbDeleteType( db, i, type->srt_Type ); + } + + } + } + ReleaseSemaphore( &db->db_Sem ); +#endif + if (db->db_Lib.lib_Flags & LIBF_DELEXP) ret = DevExpunge(db); @@ -375,10 +419,9 @@ ASM SAVEDS BPTR DevClose( ASMR(a1) struct IOSana2Req *ioreq ASMREG(a1), ASM SAVEDS BPTR DevExpunge( ASMR(a6) DEVBASEP ASMREG(a6) ) { BPTR seglist = db->db_SegList; - ULONG i; - struct SanaReadType *type; - if( db->db_Lib.lib_OpenCnt ) + /* don't go if the server is still up (for whatever reason) */ + if( (db->db_Lib.lib_OpenCnt) || (db->db_ServerProc) ) { db->db_Lib.lib_Flags |= LIBF_DELEXP; return (0); @@ -388,6 +431,8 @@ ASM SAVEDS BPTR DevExpunge( ASMR(a6) DEVBASEP ASMREG(a6) Remove((struct Node*)db); /* remove device node from system */ Permit(); +#if 0 + /* moved to CloseDevice() */ dbStopServer(db,0); for( i=0 ; i < db->db_NBoards ; i++ ) @@ -398,6 +443,7 @@ ASM SAVEDS BPTR DevExpunge( ASMR(a6) DEVBASEP ASMREG(a6) } } +#endif /* last steps: libraries */ CloseLibrary(DOSBase); @@ -816,9 +862,9 @@ LONG Need_HighPri( DEVBASEP ) return 0; } - if( FindPort("Services Manager") ) + if( FindPort( (STRPTR)"Services Manager") ) return 1; - if( FindPort("Accounts Manager") ) + if( FindPort( (STRPTR)"Accounts Manager") ) return 1; return 0; @@ -833,34 +879,43 @@ static LONG dbStartServer( DEVBASEP, LONG unit ) LONG ret = 0,i,pri; struct TagItem sv_tags[5]; - /* server running ? */ - if( db->db_ServerProc ) + ObtainSemaphore( &db->db_Sem ); + + do { + /* server running ? */ + if( db->db_ServerProc ) + { if( Need_HighPri( db ) ) SetTaskPri((struct Task*)db->db_ServerProc,HIGHPRI); - return 1; - } + ret = 1; + break; /* ReleaseSemaphore */ + } - if(!(port = CreateMsgPort() )) - return 0; - - pri = 0; - if( Need_HighPri( db ) ) + if(!(port = CreateMsgPort() )) + break; /* ReleaseSemaphore */ + + pri = 0; + if( Need_HighPri( db ) ) pri = HIGHPRI; - else - if( FindPort("AMITCP") ) /* AmiTCP active ? */ + else + { + if( FindPort( (STRPTR)"AMITCP") ) /* AmiTCP active ? */ pri = 6; + if( FindPort( (STRPTR)"BAXTCP") ) /* BaxTCP active ? */ + pri = 6; + } - sv_tags[i=0].ti_Tag = NP_Entry; - sv_tags[i++].ti_Data = (ULONG)ServerTask; - sv_tags[i ].ti_Tag = NP_Name; - sv_tags[i++].ti_Data = (ULONG)db->db_Lib.lib_Node.ln_Name; - sv_tags[i ].ti_Tag = NP_Priority; - sv_tags[i++].ti_Data = (ULONG)pri; - sv_tags[i ].ti_Tag = TAG_DONE; + sv_tags[i=0].ti_Tag = NP_Entry; + sv_tags[i++].ti_Data = (ULONG)ServerTask; + sv_tags[i ].ti_Tag = NP_Name; + sv_tags[i++].ti_Data = (ULONG)db->db_Lib.lib_Node.ln_Name; + sv_tags[i ].ti_Tag = NP_Priority; + sv_tags[i++].ti_Data = (ULONG)pri; + sv_tags[i ].ti_Tag = TAG_DONE; - if( (db->db_ServerProc = CreateNewProc(sv_tags))) - { + if( (db->db_ServerProc = CreateNewProc(sv_tags))) + { /* server is running, wait for response */ volatile struct ServerMsg msg; @@ -874,11 +929,15 @@ static LONG dbStartServer( DEVBASEP, LONG unit ) WaitPort( port ); ret = msg.sm_result; /* should be 1 */ D(("Server answered with %ld\n",ret)); - } - if( !ret ) + } + if( !ret ) db->db_ServerProc = (0); - DeleteMsgPort( port ); + DeleteMsgPort( port ); + + } while(0); + + ReleaseSemaphore( &db->db_Sem ); return ret; } @@ -886,12 +945,16 @@ static LONG dbStartServer( DEVBASEP, LONG unit ) /* stop Server function */ /* note: server is global right now */ +/* note: this code assumes to run with locked Semaphore (db_Sem) */ static LONG dbStopServer( DEVBASEP, LONG unit ) { ULONG i=1; volatile struct Task *P; /* server deletes itself from devbase */ + dbSignalServer( db, SIGBREAKF_CTRL_C, 0 ); + + /* failsafe: when the server does not come down, hammer it with CTRL_C */ while( (P=(volatile struct Task*)db->db_ServerProc) ) { Signal( (struct Task*)P, SIGBREAKF_CTRL_C); @@ -902,6 +965,47 @@ static LONG dbStopServer( DEVBASEP, LONG unit ) return 0; } +/* Signal server and wait for response */ +/* notes: + - server is global right now + - a Semaphore is used to ensure one signal per call only + - a signal is allocated, if possible +*/ +static LONG dbSignalServer( DEVBASEP, ULONG sig, ULONG flags ) +{ + ULONG mysig = SIGBREAKF_CTRL_D; /* failsafe */ + LONG sigbit=-1; + + sigbit = AllocSignal(-1); + if( sigbit >= 0 ) + mysig = 1<db_Sem ); /* lock access to server state */ + if( db->db_ServerProc ) + { + /* important: we might land here from various tasks/procs: always update + task pointer, always lock semaphore + */ + db->db_ServerSigMask = mysig; + db->db_Task = FindTask(NULL); + + Signal( (struct Task*)db->db_ServerProc, sig ); + + /* TODO: check "sig" for valid server signals, + currently: SIGBREAKF_CTRL_D,SIGBREAKF_CTRL_F,SIGBREAKF_CTRL_C + and otherwise don't wait */ + Wait( mysig ); + db->db_Task = NULL; /* no waiting is pending */ + } + if( flags & 1 ) + ReleaseSemaphore( &db->db_Sem ); /* unlock access to server state */ + + if( sigbit >= 0 ) + FreeSignal(sigbit); + + return 0; +} /* delete all buffers (type references) associated with device opener diff --git a/Driver/baxnet/source/device.h b/Driver/baxnet/source/device.h index 3474a54..1860306 100644 --- a/Driver/baxnet/source/device.h +++ b/Driver/baxnet/source/device.h @@ -33,6 +33,7 @@ #define SysBase db->db_SysBase #define DOSBase db->db_DOSBase #define UtilityBase db->db_UtilityBase +#define MMUBase db->db_MMUBase //#define VampireBase db->db_VampireBase /* old sana2.h ? */ @@ -103,6 +104,7 @@ struct devbase { struct Library *db_SysBase; /* Exec Base */ struct Library *db_DOSBase; struct Library *db_UtilityBase; + struct Library *db_MMUBase; ULONG db_NBoards; ULONG db_ID; /* device opener ID enumeration */ @@ -110,6 +112,8 @@ struct devbase { than 1 network card of the same type, anyway ? */ /* server process data */ + struct SignalSemaphore db_Sem; /* lock server state communication to one caller */ + /* (see per-unit Semaphore for queue stuff) */ volatile struct Process *db_ServerProc; /* process of main queue server */ struct Task *db_Task; /* server shutdown task address (non permanently available) */ ULONG db_ServerSigMask; /* shutdown signal */ @@ -249,6 +253,7 @@ static LONG dbIsInList( struct List *, struct Node * ); static LONG dbStartServer( DEVBASETYPE*, LONG ); static LONG dbStopServer( DEVBASETYPE*, LONG ); +static LONG dbSignalServer( DEVBASETYPE*, ULONG, ULONG ); static void dbDeleteBuffers( DEVBASETYPE*, struct IOSana2Req * ); diff --git a/Driver/baxnet/source/device.i b/Driver/baxnet/source/device.i index 5433985..d4de421 100644 --- a/Driver/baxnet/source/device.i +++ b/Driver/baxnet/source/device.i @@ -112,6 +112,7 @@ DUF_PROMISC EQU (1<0 ok, link change handled ; @@ -1080,7 +1138,7 @@ _enc624j6l_IntServer_List: ; _enc624j6l_CheckLinkChange: move.l a0,d0 - beq.s .rts + beq.s .err ;error: we don't have a board ; link change events are captured with Interrupts and stored ; in the (custom) PLinkChange location (per board) by init and @@ -1145,7 +1203,8 @@ _enc624j6l_CheckLinkChange: moveq #0,d0 .rts: rts - +.err: moveq #HW_MAC_INVALID,d0 ;-1 + rts ;--------------------------------------------------------------------------------------- ; @@ -1272,6 +1331,305 @@ _enc624j6l_HaveRecv: bra.s .rts + ifne OPT_Z2_WORDREAD +;--------------------------------------------------------------------------------------- +; +; receive single frame from HW into supplied memory buffer (Z2 Only) +; +; input: A0 - APTR mmapped board base address +; A1 - APTR buffer for received frame +; D0 - SHORT maximum size in buffer +; +; output: D0 <0 - error (i.e. frame too large) +; 0 - no pending frames +; >0 - size of received frame in buffer +; +; trash: - +; +; notes: +; + + +_enc624j6l_RecvFrameZ2: +;WORD READS ONLY + movem.l d2-d7/a1-a3,-(sp) + move.l a0,d1 + beq .err + + 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 + + ifne DEBUG + READREG ERXHEAD,A0,d4 + READREG ERXTAIL,A0,d5 + endc + + ;----------- check next packet pointer and verify expected state ----------- + READREG PNextPacket,a0,d7 ;get user read pointer from private space + ;lea (a0,d7.w),a2 ;read ptr for next packet address + ;READREG 0,a2,d0 ;next packet pointer + + READSRAM a0,d7,d0 ;move (a0,d7.w),d0 + ifeq _OPT_BUFFER_SWAP + rol.w #8,d0 ;swap pointer to Big Endian + endc + + ;verify next packet pointer, re-initialize recv if this is invalid + cmp #RXSTOP_INIT,d0 ;bad pointer (<0 or >end of memory) + bhi.w .recv_err + cmp d0,d7 + bgt.s .maybewrap + ;unwrapped next packet + move d0,d1 + bra.s .ptrcheck +.maybewrap: + ;wrapped next packet ? + move #RXSTOP_INIT+1-RXSTART_INIT,d1 ;unwrap distance + add.w d0,d1 ;next pkt + unwrap distance +.ptrcheck: + sub.w d7,d1 ;length of pkt + cmp #MAX_FRAMELEN+2+6+2,d1 ;must be smaller than max framelen + ptr + status vector + alignment + bhi .recv_err ;-> reinit recv (am I paranoid ? -> try ENC28J60, then you know why...) + + ;------------------ check receive status vector ----------------------------- + addq.w #2,d7 ;increment pointer + WRAPINDEX d7 ;wrap D7 if beyond buffer + + ifne 0 + READSRAM a0,d7,d2 ;move (a0,d7.w),d0 + ifeq _OPT_BUFFER_SWAP + rol.w #8,d2 ;swap pointer to Big Endian + endc + and.w #$f800,d2 ;verify (should be all zeros in upper 9 bits) + bne .recv_err ;receive buffer is wrong -> re-initialize + endc + + addq.w #4,d7 ;increment pointer + WRAPINDEX d7 ;wrap D7 if beyond buffer + + WRITEREG PNextPacket,a0,d0 ;write pointer for next packet + + ifne 0 + ;lea (a0,d7.w),a2 ;new read pointer for length + ;READREG 0,a2,d0 ;last control word = length (byte count) + READSRAM a0,d7,d2 ;move (a0,d7.w),d0 + ifeq _OPT_BUFFER_SWAP + rol.w #8,d2 ;swap pointer to Big Endian + endc ;_OPT_BUFFER_SWAP + endc ;0 + + ;D1 is the distance to the next frame = stored length + recv vevtor + subq #6+2,d1 ;STATUS VECTOR, Pointer + move d1,d0 ; + + subq #4,d0 ;subtract CRC length + + addq.w #2,d7 ;increment pointer (skip status vector length field) + WRAPINDEX d7 ;wrap D7 if beyond buffer + + ;d0.w: length (without crc) + ;d7.w: read position (beginning of frame, dest MAC) + ;a0: board I/O + ;a1: dest pointer + move.l a1,a3 + + ifne _OPT_RECV + move.l d7,d1 ;start + ;and.l #$FFFF,d1 ;keep only lower address + add.w d0,d1 ;start+bytes + bvs.s .nooptrecv ;what? beyond 16 Bit ? -> we really should consider this an error, really :-) + cmp.w #RXSTOP_INIT,d1 ; + bgt.s .nooptrecv ;sadly, we cannot use faster routine atm, because we have a wrap around in the SRAM buffer + + ifne _OPT_ADR_QUIRK + eor.w #$6000,d7 + endc ;_OPT_ADR_QUIRK + + lea (a0,d7.w),a2 ;read pointer + ifeq _OPT_BUFFER_SWAP + btst #1,d7 ;do we have a read address that`s not long aligned? + beq.s .no_impair + move.w (a2)+,(a1)+ ;long-align address + subq #2,d0 + ble.w .end_read ;should not happen (>14 per valid frame) + moveq #15,d1 ; + move.l d0,d2 ;total bytes + and.l d0,d1 ;remainder: max 15 bytes + lsr.w #4,d2 ;total/16 + addq #2,d0 + bra.s .impair +.no_impair: + move.l d0,d2 ;total bytes + moveq #15,d1 ; + lsr.w #4,d2 ;total/16 + and.l d0,d1 ;remainder: max 15 bytes +.impair: + addq #3,d1 ;remainder, rounded up to +3 bytes + subq #1,d2 ;dbf + blt.s .nopt16_read ;less than 16 bytes -> bail out + bra.s .opt16_read +.opt16_loop: + move.w d3,(a1)+ +.opt16_read: + rept 3 + move.w (a2)+,(a1)+ + move.w (a2)+,(a1)+ + endr + move.w (a2)+,(a1)+ + move.w (a2)+,d3 + dbf d2,.opt16_loop + move.w d3,(a1)+ +.nopt16_read: + else ;_OPT_BUFFER_SWAP + moveq #3,d1 ;round bytes up + add d0,d1 ;byte count + 3 + endc ;_OPT_BUFFER_SWAP + lsr #2,d1 ;converted to dword count = ceil(bytes/4) + subq #1,d1 ;longwords - 1 + blt.s .end_read +.opt_read: + ifne _OPT_BUFFER_SWAP + move.w (a2)+,d2 ;get current word + rol.w #8,d2 ;swap buffer to Big Endian + move.w d2,(a1)+ + move.w (a2)+,d2 + rol.w #8,d2 ;swap buffer to Big Endian + move.w d2,(a1)+ + else ;_OPT_BUFFER_SWAP + move.w (a2)+,(a1)+ + move.w (a2)+,(a1)+ + endc ;_OPT_BUFFER_SWAP + dbf d1,.opt_read + bra.s .end_read + +.nooptrecv: + ;DEBUG ONLY + ;bra.s .emergency_slow + ;DEBUG ONLY + + ifeq _OPT_BUFFER_SWAP ;1 + ; + ;wraparound aware loop for big endian buffer + ; + move.w #RXSTOP_INIT+1,d1 ;end address $6000 + lea (a0,d7.w),a2 ;read pointer + sub.w d7,d1 ;minus start pointer = number of bytes until wrap + cmp.w d0,d1 ; + bhi.s .emergency_slow ;don`t trust anyone: if d1<0 or >total_length, then branch to slow routine + + move d1,d2 + lsr #2,d2 ;we copy long words + subq #1,d2 ;dbf + blt.s .nowords_beforewrap ; +.loop_beforewrap: + move.w (a2)+,(a1)+ + move.w (a2)+,(a1)+ + dbf d2,.loop_beforewrap + +.nowords_beforewrap: ; + btst #1,d7 ;uneven longword address before wraparound ? + beq.s .copy_afterwrap + move.w (a2)+,(a1)+ ;copy word from uneven address +.copy_afterwrap: + + move #RXSTART_INIT,d7 ;wrap + lea (a0,d7.w),a2 ;read pointer + + move d0,d2 ;total bytes to read + sub.w d1,d2 ;remaining=total-copied (D1=RXSTOP_INIT+1-D7) + ble.s .end_read ;done, if zero + + move d2,d1 ; + lsr #2,d2 ;we copy long words + bra.s .enter_afterwrap +.loop_afterwrap: + move.w (a2)+,(a1)+ + move.w (a2)+,(a1)+ +.enter_afterwrap: + dbf d2,.loop_afterwrap + + and.b #3,d1 ;btst #1,d1 ;1 byte or short remaining ? + beq.s .end_read + move.w (a2)+,(a1)+ + bra.s .end_read + +.emergency_slow: + endc ;_OPT_BUFFER_SWAP + endc ;_OPT_RECV + + ;generic loop: check for position overflows with each word + ; + ;CAUTION: DWORD loop doesn`t apply here since buffer is organized + ; in multiples of two bytes, same for frame lengths and + ; possible wraparounds + ; + moveq #1,d2 ;mask for lower bit + move d0,d1 ;byte count + lsr #1,d1 ;converted to word count + and.l d0,d2 ;if lower bits are set -> + bne.s .generic_read ;read 1 word more if impair byte/word count + subq #1,d1 ;words - 1 +.generic_read: + move.w (a0,d7.w),d2 ;get current word + ifne _OPT_BUFFER_SWAP + rol.w #8,d2 ;swap buffer to Big Endian + endc + move.w d2,(a1)+ ; store currend word + addq #2,d7 ;increment position + WRAPINDEX d7 ;wrap D7 if beyond buffer + dbf d1,.generic_read + +.end_read: + ;frame copied, now advance HW pointer + READREG PNextPacket,a0,d1 ;write pointer for next packet + cmp #RXSTART_INIT,d1 + bne.s .tail_nowrap + move #(RXSTOP_INIT&$fffe)+2,d1 +.tail_nowrap: + subq #2,d1 + WRITEREG ERXTAIL,a0,d1 ;tail pointer in buffer = rx-2, wraparound + + move #ECON1_PKTDEC,d1 + SETREG ECON1,a0,d1 ;set packet decrement ("frame", actually) + + ext.l d0 + ifne ADD_4RX + addq.l #4,d0 ;+4 (fake CRC) for Shapeshifter, also see server.c plain copy mode + endc + + cmp.w #14,d0 + bge.s .rts + + moveq #0,d0 +.rts: + movem.l (sp)+,d2-d7/a1-a3 + rts +.err: moveq #-1,d0 ;receive error + bra.s .rts + +.recv_err: + moveq #0,d0 + READREG ESTAT,a0,d2 ;number of pending frames + move.b d2,d0 ;clear out count (ESTAT_PKTCNT7...ESTAT_PKTCNT0) + beq.s .rts ;nothing in buffer, return sheer emptiness + + ;serious problem: we need to re-initialize the recv buffer here + bsr _enc624j6l_RXReset + + moveq #ECON1_RXEN,d0 ;re-enable reception + SETREG ECON1,a0,d0 + + moveq #0,d0 + bra.s .rts + + + + + endc + ;--------------------------------------------------------------------------------------- ; ; receive single frame from HW into supplied memory buffer @@ -1289,10 +1647,17 @@ _enc624j6l_HaveRecv: ; notes: ; _enc624j6l_RecvFrame: ; + ifne OPT_Z2_WORDREAD + tst.l Z2Mode + bne.w _enc624j6l_RecvFrameZ2 + endc + movem.l d2-d7/a1-a3,-(sp) move.l a0,d1 beq .err + + moveq #0,d0 READREG ESTAT,a0,d2 ;number of pending frames move.b d2,d0 ;clear out count (ESTAT_PKTCNT7...ESTAT_PKTCNT0) @@ -1899,4 +2264,12 @@ _enc624j6l_UMinDelay: ;recvcount: dc.l 0 ;recvlist: ds.w 65536 +;separate section necessary with SAS/C + section data,data + +Z2Mode: +_enc624j6l_Z2Mode: + dc.l 0 + + END diff --git a/Driver/baxnet/source/enc624j6net/enc624j6l.h b/Driver/baxnet/source/enc624j6net/enc624j6l.h index 9a7bd27..d81390c 100644 --- a/Driver/baxnet/source/enc624j6net/enc624j6l.h +++ b/Driver/baxnet/source/enc624j6net/enc624j6l.h @@ -362,5 +362,6 @@ ASM SAVEDS int enc624j6l_WritePHY( ASMR(d0) unsigned long phyreg ASMREG(d0), ASMR(d1) unsigned short data ASMREG(d1) ); +extern unsigned long enc624j6l_Z2Mode; #endif /* _INC_ENC624J6L_H */ diff --git a/Driver/baxnet/source/enc624j6net/hw.c b/Driver/baxnet/source/enc624j6net/hw.c index 0fd8054..35d94b8 100644 --- a/Driver/baxnet/source/enc624j6net/hw.c +++ b/Driver/baxnet/source/enc624j6net/hw.c @@ -9,21 +9,26 @@ */ #include #include +#include /*#include #include */ #include #include #include - #include "device.h" #include "hw.h" #include "enc624j6l.h" #include "registers.h" +#include "mmustuff.h" extern const BYTE DeviceName[]; +#ifndef AFF_68060 +#define AFF_68060 (1<<10) +#endif + #define ENC_MANUFACTURER 2588 #define ENC_BOARD 123 @@ -90,11 +95,12 @@ ASM SAVEDS LONG hw_Find_Boards( ASMR(a0) DEVBASEP ASMREG(a0) ) struct ConfigDev *cfg = (0); APTR boardbase; - if( (ExpansionBase = OpenLibrary( (BYTE*)exp_name, 37 )) ) + if( (ExpansionBase = OpenLibrary( (STRPTR)exp_name, 37 )) ) { /* TODO: actually verify that we have a module here */ /* ret = 1; */ + enc624j6l_Z2Mode = 0; for( i=0 ; i < MAX_UNITS ; i++ ) { cfg = FindConfigDev( cfg, ENC_MANUFACTURER, ENC_BOARD ); @@ -103,10 +109,29 @@ ASM SAVEDS LONG hw_Find_Boards( ASMR(a0) DEVBASEP ASMREG(a0) ) boardbase = (APTR)cfg->cd_BoardAddr; db->db_Units[i].duh_BASE = boardbase; D(("Board at %lx\n",(ULONG)cfg->cd_BoardAddr )); + + /* on Z2 ? */ + if( boardbase <= (APTR)0x40000000 ) + { + struct ExecBase *EB = (struct ExecBase *)SysBase; + /* 68000-68030 ? */ + if( !(EB->AttnFlags & (AFF_68040|AFF_68060) )) + enc624j6l_Z2Mode = 1; + } +#ifdef USEMMU + if( MMUBase ) + { + /* sometimes (A3000 with SuperKickstart), the MMU table is just wrong, fix "Invalid" bit, if necessary */ + setupMMU( boardbase, 0x10000, 0, db ); + } +#endif + /* bring board to sane state (i.e. perform soft reset) */ /* if( boardbase < (APTR)0x40000000 ) */ /* debug only */ enc624j6l_CheckBoard( boardbase ); + + } ret = i; D(("%ld boards found\n",ret)); @@ -300,12 +325,30 @@ ASM SAVEDS void hw_ConfigInit( ASMR(a0) DEVBASEP ASMREG(a0) ) } +UBYTE hex2char( STRPTR src ) +{ + UBYTE cur = 0; + + cur = *src; + + if( cur >= 'a' ) + cur &= ~32; + + if( (cur < '0') || (cur>'F') ) + return 0; + + cur = ( cur < 'A' ) ? cur-'0' : cur-'A'+10; + + return cur; +} + ASM SAVEDS void hw_ConfigUpdate( ASMR(a0) DEVBASEP ASMREG(a0), ASMR(a1) void*argsv ASMREG(a1)) { struct HWConfig *args = (struct HWConfig *)argsv; /* see hwprivate.h */ struct HWData *hwd = &db->db_hwdat; + D(("hw_ConfigUpdate\n")); if( args->timervalue ) hwd->timervalue = *args->timervalue; if( args->fullduplex ) @@ -314,6 +357,28 @@ ASM SAVEDS void hw_ConfigUpdate( ASMR(a0) DEVBASEP ASMREG(a0), hwd->flowcontrol = 1; if( args->multicast ) hwd->multicast = 1; + if( args->conf_mac ) /* user-configured MAC address */ + { + int i=0,val; + STRPTR src = args->conf_mac; + + while( i < 6 ) + { + val = hex2char( src++ ) << 4; + val |= hex2char( src++ ); + if( (*src++ != ':') && (i<5) ) + break; + db->db_Units[0].du_CFGAddr[i] = val; +/* db->db_Units[0].du_HWAddr[i] = val; */ + i++; + } + D(("Configured MAC %s (-> %02lx%02lx%02lx%02lx%02lx%02lx\n",\ + args->conf_mac, \ + db->db_Units[0].du_CFGAddr[0], db->db_Units[0].du_CFGAddr[1],\ + db->db_Units[0].du_CFGAddr[2], db->db_Units[0].du_CFGAddr[3],\ + db->db_Units[0].du_CFGAddr[4], db->db_Units[0].du_CFGAddr[5] )); + enc624j6l_SetMAC( db->db_Units[0].duh_BASE, db->db_Units[0].du_CFGAddr ); + } } /* @@ -408,7 +473,9 @@ ASM SAVEDS LONG hw_get_mac_status( ASMR(a0) DEVBASEP ASMREG( 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; @@ -548,6 +615,17 @@ ASM void INCMAC( ASMR(a0) UBYTE *curmc ASMREG(a0) ) } } +ASM void COPYMAC( ASMR(a0) UBYTE *dest ASMREG(a0), + ASMR(a1) UBYTE *src ASMREG(a1) ) +{ + dest[0] = src[0]; + dest[1] = src[1]; + dest[2] = src[2]; + dest[3] = src[3]; + dest[4] = src[4]; + dest[5] = src[5]; +} + /* TODO: implement Multicast hashing */ ASM SAVEDS LONG hw_change_multicast( ASMR(a0) DEVBASEP ASMREG(a0), ASMR(d0) ULONG unit ASMREG(d0), @@ -560,7 +638,7 @@ ASM SAVEDS LONG hw_change_multicast( ASMR(a0) DEVBASEP ASMREG( USHORT mc_hashes[4] = {0,0,0,0}; /* EHT1, EHT2, EHT3, EHT4 */ USHORT *hash_tab; struct MCastEntry *mc; - UBYTE *curmc; + UBYTE curmc[6]; flags = PIO_INIT_BROAD_CAST; @@ -581,7 +659,7 @@ ASM SAVEDS LONG hw_change_multicast( ASMR(a0) DEVBASEP ASMREG( mc->mce_Node.mln_Succ ; mc=(struct MCastEntry*)mc->mce_Node.mln_Succ ) { - curmc = mc->mce_start; + COPYMAC( curmc, mc->mce_start ); while( CMPleMAC( curmc, mc->mce_stop ) ) { D(("CMPleMAC %ld %02lx%02lx%02lx%02lx%02lx%02lx - %02lx%02lx%02lx%02lx%02lx%02lx\n",\ @@ -594,7 +672,7 @@ ASM SAVEDS LONG hw_change_multicast( ASMR(a0) DEVBASEP ASMREG( (ULONG)mc->mce_stop[4],(ULONG)mc->mce_stop[5] \ )); - crc = myhw_CRC32( mc->mce_start, 6 ); + crc = myhw_CRC32( curmc, 6 ); curhash = (crc & 0x1f800000)>>23; /* 2 bit reg, 4 bit hash pos in reg */ mc_hashes[ ((curhash >> 4)&3) ] |= 1<<(curhash&0xf); INCMAC( curmc ); diff --git a/Driver/baxnet/source/enc624j6net/hwprivate.h b/Driver/baxnet/source/enc624j6net/hwprivate.h index 3f2127f..43e3f75 100644 --- a/Driver/baxnet/source/enc624j6net/hwprivate.h +++ b/Driver/baxnet/source/enc624j6net/hwprivate.h @@ -41,7 +41,7 @@ struct HWData { #define HW_CONFIGFILE "ENV:SANA2/enc624j6net.config" /* appended to COMMON_TEMPLATE */ -#define HW_CONFIGTEMPLATE "TIMER/K/N,FULLDUPLEX/S,MULTICAST/S,FLOWCONTROL/S" +#define HW_CONFIGTEMPLATE "TIMER/K/N,FULLDUPLEX/S,MULTICAST/S,FLOWCONTROL/S,MAC/K" /* referenced by server.c, hw.c */ struct HWConfig @@ -51,6 +51,7 @@ struct HWConfig ULONG fullduplex; ULONG multicast; ULONG flowcontrol; + STRPTR conf_mac; /* user config MAC address */ }; #endif /* _INC_HWPRIVATE_H */ diff --git a/Driver/baxnet/source/enc624j6net/macros.i b/Driver/baxnet/source/enc624j6net/macros.i index e30a27b..40738c2 100644 --- a/Driver/baxnet/source/enc624j6net/macros.i +++ b/Driver/baxnet/source/enc624j6net/macros.i @@ -8,7 +8,7 @@ _OPT_BUFFER_SWAP EQU 0 ;perform byte swap on buffer ops (1) or assume native endian (0) _OPT_REG_SWAP EQU 0 ;perform byte swap on register ops (1) or assume native endian (0) _OPT_ADR_QUIRK EQU 0 ;address lines 12/13 are swapped (1) or linear addressing (0) -_OPT_FLOWCONTROL EQU 0 ;perform flow control on RX (1) or not (0) +_OPT_FLOWCONTROL EQU 0 ;perform flow control on RX (1) or not (0), obsolete (runtime option now) _OPT_RECV EQU 1 ;faster recv (1) or generic (0) _OPT_CHECKLINK_TX EQU 0 ;check for link changes in TX (1) or expect from outside (0) -> see server.c @@ -123,4 +123,4 @@ WRAPINDEX macro ble.s .nowrap\0\@ add.w #RXSTART_INIT-RXSTOP_INIT-1,\1 .nowrap\0\@ - endm \ No newline at end of file + endm diff --git a/Driver/baxnet/source/kprintf.asm b/Driver/baxnet/source/kprintf.asm index 0365136..a58d77d 100644 --- a/Driver/baxnet/source/kprintf.asm +++ b/Driver/baxnet/source/kprintf.asm @@ -1,10 +1,10 @@ - incdir include: - ifnd _LVOSupervisor - include lvo/exec_lib.i + ;incdir include: + ;ifnd _LVOSupervisor + ;include lvo/exec_lib.i ;include exec/exec_lib.i - endc - include exec/execbase.i - include device.i + ;endc + ;include exec/execbase.i + ;include device.i ifnd _LVORawDoFmt @@ -52,10 +52,10 @@ _KPrintFa0a1: rts ;DEBUG - dc.l $deadbeef - dc.l sds_SIZEOF - dc.l sv_SIZEOF - dc.l du_SIZEOF - dc.l db_SIZEOF +; dc.l $deadbeef +; dc.l sds_SIZEOF +; dc.l sv_SIZEOF +; dc.l du_SIZEOF +; dc.l db_SIZEOF diff --git a/Driver/baxnet/source/miitool.c b/Driver/baxnet/source/miitool.c index 5aff7da..a2143ad 100644 --- a/Driver/baxnet/source/miitool.c +++ b/Driver/baxnet/source/miitool.c @@ -174,7 +174,7 @@ LONG get_device(struct prgdata *prg, BYTE *name, LONG unit ) static BOOL findcmd(struct NSDeviceQueryResult *nsdqr, UWORD cmd) { UWORD *p; - for (p = nsdqr->SupportedCommands; (*p); ++p) + for (p = nsdqr->nsdqr_SupportedCommands; (*p); ++p ) if (*p == cmd) return TRUE; return FALSE; @@ -204,9 +204,9 @@ LONG probe_device( struct prgdata *prg ) return 0; } - if (nsdqr.DeviceType != NSDEVTYPE_SANA2) + if ( nsdqr.nsdqr_DeviceType != NSDEVTYPE_SANA2 ) { - Printf("Device is not a SANA-II device (type %ld, needed %ld\n).", (LONG)nsdqr.DeviceType, (LONG) NSDEVTYPE_SANA2); + Printf("Device is not a SANA-II device (type %ld, needed %ld\n).", (LONG)nsdqr.nsdqr_DeviceType, (LONG) NSDEVTYPE_SANA2 ); return 0; } diff --git a/Driver/baxnet/source/mmustuff.c b/Driver/baxnet/source/mmustuff.c new file mode 100644 index 0000000..c37c37c --- /dev/null +++ b/Driver/baxnet/source/mmustuff.c @@ -0,0 +1,109 @@ +/* + set up MMU for flash access using mmu.library + + (C) 2022 Henryk Richter + + The F0 area (0xF00000-0xF7ffff) is known to be + reserved by Commodore for diagnostic ROMs (or + BootROMs), as well as additional kickstart modules. + + Some configurations of the MMU will mark this + area as ROM such that write attempts are inhibited + by the processor itself. + + This code will revert any existing remapping (to + RAM) and set up useable cache flags such that the + Flash can be written to. + +*/ +#define __NOLIBBASE__ +#include +#include +#include +#include "debug.h" +#include "mmustuff.h" + + +//extern struct Library *MMUBase; +//extern struct DosLibrary *DOSBase; + +#define CACHEFLAGS (MAPP_CACHEINHIBIT|MAPP_COPYBACK|MAPP_NONSERIALIZED|MAPP_IMPRECISE) + +#define ROMFLAGS (MAPP_CACHEINHIBIT|MAPP_GLOBAL|MAPP_IO|MAPP_USER0) +#define ROMCFLAGS (MAPP_CACHEINHIBIT|MAPP_COPYBACK|MAPP_NONSERIALIZED|MAPP_IMPRECISE|MAPP_GLOBAL|MAPP_IO|MAPP_WRITEPROTECTED|MAPP_ROM|MAPP_INVALID) + +#ifdef __VBCC__ +#define BCAST +#else +#define BCAST (ULONG) +#endif + + +/* + set up MMU as I/O space from "base", "size" bytes, + keep flags==0 for now + + the device pointer is used to fetch the MMUbase from it, nothing more +*/ +ASM SAVEDS LONG setupMMU( ASMR(a0) void *base ASMREG(a0), + ASMR(d0) LONG size ASMREG(d0), + ASMR(d1) ULONG flags ASMREG(d1), + ASMR(a6) DEVBASEP ASMREG(a6) ) +{ + struct MMUContext *ctx,*sctx; /* default context, supervisor context */ + ULONG props; + struct MinList *ctxl,*sctxl; + struct TagItem tgs[2] = {{TAG_DONE,0},{TAG_DONE,0} }; + + if( !MMUBase ) + return 1; /* cannot setup MMU without MMULib */ + + ctx=DefaultContext(); + sctx=SuperContext(ctx); + + props = GetPropertiesA(sctx,BCAST base,tgs); + props |= GetPropertiesA(sctx,BCAST base,tgs); + + D(( (STRPTR)"Current MMU props on 0x%lx area: 0x%lx\n",(ULONG)base,props)); + + LockContextList(); + LockMMUContext(ctx); + LockMMUContext(sctx); + + if( (props & MAPP_REMAPPED) ) + { + D(( (STRPTR)"Memory was remapped elsewhere, reverting to physical location\n" )); + + if( (ctxl=GetMapping(ctx))) + { + if( (sctxl=GetMapping(sctx))) + { + if( SetPropertiesA(ctx,0,MAPP_REMAPPED|CACHEFLAGS,BCAST base,size,tgs) ) + { + if( SetPropertiesA(sctx,0,MAPP_REMAPPED|CACHEFLAGS,BCAST base,size,tgs) ) + { + } + } + ReleaseMapping(sctx,sctxl); + } + ReleaseMapping(ctx,ctxl); + } + } + + /* set desired flags */ + SetPropertiesA(ctx,ROMFLAGS,ROMCFLAGS, BCAST base,size,tgs); + SetPropertiesA(sctx,ROMFLAGS,ROMCFLAGS,BCAST base,size,tgs); + + RebuildTrees(ctx,sctx,NULL); + + UnlockMMUContext(sctx); + UnlockMMUContext(ctx); + UnlockContextList(); + + props = GetPropertiesA(sctx,BCAST base,tgs); + props |= GetPropertiesA(sctx,BCAST base,tgs); + D(( (STRPTR)"New MMU props on 0x%lx area: 0x%lx\n",(ULONG)base,props)); + + return 0; +} + diff --git a/Driver/baxnet/source/mmustuff.h b/Driver/baxnet/source/mmustuff.h new file mode 100644 index 0000000..15c4453 --- /dev/null +++ b/Driver/baxnet/source/mmustuff.h @@ -0,0 +1,30 @@ +/* + set up MMU for flash access using mmu.library + + (C) 2022 Henryk Richter + + The F0 area (0xF00000-0xF7ffff) is known to be + reserved by Commodore for diagnostic ROMs (or + BootROMs), as well as additional kickstart modules. + + Some configurations of the MMU will mark this + area as ROM such that write attempts are inhibited + by the processor itself. + + This code will revert any existing remapping (to + RAM) and set up useable cache flags such that the + Flash can be written to. + +*/ +#ifndef _INC_MMUSTUFF_H +#define _INC_MMUSTUFF_H + +#include "compiler.h" +#include "device.h" + +ASM SAVEDS LONG setupMMU( ASMR(a0) void *base ASMREG(a0), + ASMR(d0) LONG size ASMREG(d0), + ASMR(d1) ULONG flags ASMREG(d1), + ASMR(a6) DEVBASEP ASMREG(a6) ); + +#endif diff --git a/Driver/baxnet/source/server.c b/Driver/baxnet/source/server.c index cc6ec6d..0c55e4f 100644 --- a/Driver/baxnet/source/server.c +++ b/Driver/baxnet/source/server.c @@ -154,7 +154,7 @@ static LONG server_setOnline( DEVBASEP , ULONG unit, ULONG evt ) struct Library *TimerBase; MemSet( &timereq, 0, sizeof(struct timerequest)); - OpenDevice("timer.device", 0, (struct IORequest*)&timereq, 0); + OpenDevice( (STRPTR)"timer.device", 0, (struct IORequest*)&timereq, 0); TimerBase = (struct Library *)timereq.tr_node.io_Device; GetSysTime( &db->db_Units[unit].du_DevStats.LastStart ); CloseDevice( (struct IORequest*)&timereq); @@ -293,7 +293,7 @@ static LONG server_Config( DEVBASEP ) hw_ConfigInit( db ); /* hw defaults */ - if((cfgfile = Open(HW_CONFIGFILE, MODE_OLDFILE))) /* see hwprivate.h for CONFIGFILE */ + if((cfgfile = Open( (STRPTR)HW_CONFIGFILE, MODE_OLDFILE))) /* see hwprivate.h for CONFIGFILE */ { struct HWConfig args; /* see hwprivate.h */ struct RDArgs *readargs; @@ -302,7 +302,7 @@ static LONG server_Config( DEVBASEP ) MemSet( &args, 0, sizeof( args ) ); - readargs = ReadArgs( (BYTE*)configtemplate, (LONG *)&args, NULL); + readargs = ReadArgs( (STRPTR)configtemplate, (LONG *)&args, NULL); Close( SelectInput( cfgfile ) ); /* restore default input and retrieve cfgfile */ @@ -354,7 +354,7 @@ static LONG server_changeMulticast( DEVBASEP, ULONG unit, struct IOSana2Req *ior entry = (struct MCastEntry *)db->db_svdat.sv_mclist.lh_Head; while( entry->mce_Node.mln_Succ ) { - if( CMPeqMAC( entry->mce_start, ioreq->ios2_SrcAddr ) ) + if( CMPeqMAC( (BYTE*)entry->mce_start, (BYTE*)ioreq->ios2_SrcAddr ) ) break; entry = (struct MCastEntry *)entry->mce_Node.mln_Succ; } @@ -1143,11 +1143,17 @@ VOID SAVEDS ServerTask(void) server_HandleS2Commands( db ); gotmask &= ~portsigmask; } + /* Important: first check CTRL_D to go offline cleanly + before acting on CTRL_C + */ if( gotmask & SIGBREAKF_CTRL_D ) { D(("Got CTRL-D in Server. Checking Online status\n")); gotmask &= ~SIGBREAKF_CTRL_D; server_CloseDevice_offline( db ); + /* acknowledge command (unless CTRL_C was also set) */ + if( (db->db_Task) && (!(gotmask & SIGBREAKF_CTRL_C)) ) + Signal( db->db_Task, db->db_ServerSigMask ); } if( gotmask & SIGBREAKF_CTRL_C ) { @@ -1161,10 +1167,16 @@ VOID SAVEDS ServerTask(void) QuitServer: if( db ) - db->db_ServerProc = (0); + { + db->db_ServerProc = (0); + /* acknowledge command */ + if( db->db_Task ) + Signal( db->db_Task, db->db_ServerSigMask ); + } { /* revert to "real" execbase, in case that we never got the startup msg */ struct { struct Library *db_SysBase; } *db = (void*)0x4; + D(("Server exiting")); Forbid(); } diff --git a/Driver/baxnet/source/smakefile.enc b/Driver/baxnet/source/smakefile.enc index 8a078ba..11287ae 100644 --- a/Driver/baxnet/source/smakefile.enc +++ b/Driver/baxnet/source/smakefile.enc @@ -30,7 +30,8 @@ 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 = DEFINE HW_DMA_TX=1 +DEFINES1 = DEFINE HW_DMA_TX=1 +#DEFINES1 = $(DEFINES1) DEFINE USEMMU=1 ASMDEFS1 = -DHW_DMA_TX=1 #CPU = 68020 diff --git a/Driver/baxnet/source/smakefile.v4 b/Driver/baxnet/source/smakefile.v4 new file mode 100644 index 0000000..b5d35d6 --- /dev/null +++ b/Driver/baxnet/source/smakefile.v4 @@ -0,0 +1,165 @@ +############################################################################### +# +# SAS/C Makefile for V4 ETH +# +# 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=v4net +ASMOBJECTS = $(SUBDIR)/vampuuid.o$(TYPE) $(SUBDIR)/intervaltimer.o$(TYPE) \ + $(SUBDIR)/v4l.o$(TYPE) kprintf.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=v4net.device +#DEFINES1 = DEFINE HW_DMA_TX=1 +#ASMDEFS1 = -DHW_DMA_TX +#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 ALLREADREQS=1 +#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) -f smakefile.v4 TYPE=4 v4net.device DEVICEID=v4net.device CPU=68020 + +v4net.device: $(OBJECTS) + -$(LD) $(OBJECTS) LIB sc:lib/sc.lib $(LDFLAGS) TO $(DEVICEID) + +clean: + -$(RM) v4net.device \#?.o4 $(SUBDIR)/\#?.o4 + +install: + copy v4net.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.vwiz b/Driver/baxnet/source/smakefile.vwiz new file mode 100644 index 0000000..834aa13 --- /dev/null +++ b/Driver/baxnet/source/smakefile.vwiz @@ -0,0 +1,169 @@ +############################################################################### +# +# SAS/C Makefile for VWizNet +# +# 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=qwiznet +ASMOBJECTS = $(SUBDIR)/vampuuid.o$(TYPE) $(SUBDIR)/intervaltimer.o$(TYPE) \ + $(SUBDIR)/w5500l.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=vwiznet500ex.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.vwiz TYPE=sd vwiznet600sd.device DEVICEID=vwiznet600sd.device CPU=68020 + $(MAKE) -f smakefile.vwiz TYPE=ex vwiznet500ex.device DEVICEID=vwiznet500ex.device CPU=68020 \ + "DEFINES1=DEFINE PROTO_V2EXPNET" ASMDEFS1=-DPROTO_V2EXPNET + +vwiznet600sd.device: $(OBJECTS) + -$(LD) $(OBJECTS) LIB sc:lib/sc.lib $(LDFLAGS) TO $(DEVICEID) + +vwiznet500ex.device: $(OBJECTS) + -$(LD) $(OBJECTS) LIB sc:lib/sc.lib $(LDFLAGS) TO $(DEVICEID) + +clean: + -$(RM) vwiznet600sd.device vwiznet500ex.device \#?.oex \#?.osd $(SUBDIR)/\#?.oex $(SUBDIR)/\#?.osd + +install: + copy vwiznet600sd.device vwiznet500ex.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 index 27cbefb..0271401 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 9 +#define DEVICEREVISION 15 #define DEVICEEXTRA /* #define DEVICEEXTRA Beta */ -#define DEVICEDATE 23.08.20 +#define DEVICEDATE 1.3.26 #endif