New driver

This commit is contained in:
MHeinrichs
2019-01-03 00:43:32 +01:00
parent eecd6c8918
commit e42f097a6c
44 changed files with 1639 additions and 110 deletions
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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
+24 -4
View File
@@ -5,6 +5,8 @@
# author: Henryk Richter <henryk.richter@gmx.net>
#
# 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)
-1
View File
@@ -11,7 +11,6 @@
#define _INC_DEBUG_H
#ifdef DEBUG
#include <clib/exec_protos.h>
extern void KPrintF(char *, ...), KGetChar(void);
#define D(_x_) do { KPrintF("%s:%ld:",__FILE__,__LINE__); KPrintF _x_; } while(0)
+84 -4
View File
@@ -27,11 +27,56 @@
#include <dos/dostags.h>
#include <utility/tagitem.h>
#include <exec/lists.h>
#ifdef HAVE_VERSION_H
#include "version.h"
#endif
/* NSD support is optional */
#ifdef NEWSTYLE
#include <devices/newstyle.h>
#include <devices/sana2devqueryext.h> /* 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:
+4 -1
View File
@@ -15,6 +15,9 @@
#include <exec/nodes.h>
#include <exec/initializers.h>
#include <exec/libraries.h>
#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,
+7 -2
View File
@@ -12,6 +12,10 @@
#include <dos/dostags.h>
#include <utility/tagitem.h>
#include <exec/lists.h>
#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
};
+127 -36
View File
@@ -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
;------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------
;
+14 -1
View File
@@ -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 */
@@ -0,0 +1,110 @@
/*
enc624test.c
(C) 2018 Henryk Richter <henryk.richter@gmx.net>
Matze-Scrat-Buggs ZII card hardware test
*/
#include <exec/libraries.h>
#include <proto/exec.h>
#define ENC_MANUFACTURER 2588
#define ENC_BOARD 123
#include <proto/expansion.h>
#include <proto/dos.h>
#include <libraries/configvars.h>
#include <hardware/intbits.h>
#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;
}
+64 -6
View File
@@ -3,7 +3,7 @@
(C) 2018 Henryk Richter <henryk.richter@gmx.net>
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<<HW_MACB_SPEED100);
else
ret |= (HW_MAC_ON_FDX<<HW_MACB_SPEED100);
break;
case 5:
if( hwd->flowcontrol )
ret |= (HW_MAC_ON_FDX_FC<<HW_MACB_SPEED10);
else
ret |= (HW_MAC_ON_FDX<<HW_MACB_SPEED10);
break;
case 2: ret |= (HW_MAC_ON<<HW_MACB_SPEED100);
break;
case 1: ret |= (HW_MAC_ON<<HW_MACB_SPEED10);
break;
default: break;
}
}
return ret;
}
ASM SAVEDS LONG hw_change_multicast( ASMR(a0) DEVBASEP ASMREG(a0),
ASMR(a0) ULONG unit ASMREG(d0),
ASMR(d0) ULONG unit ASMREG(d0),
ASMR(a1) struct List *mcastlist ASMREG(a1) )
{
/* TODO: implement Multicast hashing */
@@ -339,7 +396,7 @@ ASM SAVEDS LONG hw_change_multicast( ASMR(a0) DEVBASEP ASMREG(
if( mcastlist->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 */
{
+4 -1
View File
@@ -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 */
@@ -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)
@@ -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
+38 -1
View File
@@ -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<<HW_MACB_SPEEDS_END)-4)
#define HW_MAC_NEXTSPEED(_a_) ( (_a_)+2 )
/* find number of boards (stateless) */
ASM SAVEDS LONG hw_Find_Boards( ASMR(a0) DEVBASEP ASMREG(a0) );
@@ -75,9 +110,11 @@ ASM SAVEDS LONG hw_check_link_change( ASMR(a0) DEVBASEP ASMREG(
ASMR(d0) ULONG unit ASMREG(d0) );
ASM SAVEDS LONG hw_change_multicast( ASMR(a0) DEVBASEP ASMREG(a0),
ASMR(a0) ULONG unit ASMREG(d0),
ASMR(d0) ULONG unit ASMREG(d0),
ASMR(a1) struct List * ASMREG(a1) );
ASM SAVEDS LONG hw_get_mac_status( ASMR(a0) DEVBASEP ASMREG(a0),
ASMR(d0) ULONG unit ASMREG(d0) );
/* kept this global for now: Z-II/Z-III boards share the same interrupt */
ASM SAVEDS ULONG hw_recv_sigmask( ASMR(a0) DEVBASEP ASMREG(a0) );
+43
View File
@@ -0,0 +1,43 @@
;
; hw.i
;
; (C) 2018 Henryk Richter <henryk.richter@gmx.net>
;
; 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<<HW_MACB_LINK_UP) ; link is up
HW_MAC_AUTONEGOTIATION EQU (1<<HW_MACB_AUTONEGOTIATION) ; autonegotiation enabled
; two bits each to handle the four different states per speed
HW_MACB_SPEED10 EQU 2 ; bit for 10 MBit/s mask
HW_MACB_SPEED100 EQU 4 ; bit for 100 MBit/s mask
HW_MACB_SPEED1000 EQU 6 ; ...
HW_MACB_SPEED2500 EQU 8
HW_MACB_SPEED5000 EQU 10
HW_MACB_SPEED10000 EQU 12 ; Am I optimistic ?
HW_MACB_SPEEDS_END EQU 14 ; this is the next free bit
HW_MAC_SPEEDSMASK EQU ((1<<HW_MACB_SPEEDS_END)-4)
endc ;_INC_HW_I
+86
View File
@@ -0,0 +1,86 @@
#ifndef DEVICES_NEWSTYLE_H
#define DEVICES_NEWSTYLE_H
/*------------------------------------------------------------------------*/
/*
* $Id: newstyle.h 1.1 1997/05/15 18:53:15 heinz Exp $
*
* Support header for the New Style Device standard
*
* (C)1996-1997 by Amiga International, Inc.
*
*/
/*------------------------------------------------------------------------*/
/*
* At the moment there is just a single new style general command:
*/
#define NSCMD_DEVICEQUERY 0x4000
struct NSDeviceQueryResult {
/*
** Standard information, must be reset for every query
*/
ULONG DevQueryFormat; /* this is type 0 */
ULONG SizeAvailable; /* bytes available */
/*
** Common information (READ ONLY!)
*/
UWORD DeviceType; /* what the device does */
UWORD DeviceSubType; /* depends on the main type */
UWORD *SupportedCommands; /* 0 terminated list of cmd's */
/* May be extended in the future! Check SizeAvailable! */
};
#define NSDEVTYPE_UNKNOWN 0 /* No suitable category, anything */
#define NSDEVTYPE_GAMEPORT 1 /* like gameport.device */
#define NSDEVTYPE_TIMER 2 /* like timer.device */
#define NSDEVTYPE_KEYBOARD 3 /* like keyboard.device */
#define NSDEVTYPE_INPUT 4 /* like input.device */
#define NSDEVTYPE_TRACKDISK 5 /* like trackdisk.device */
#define NSDEVTYPE_CONSOLE 6 /* like console.device */
#define NSDEVTYPE_SANA2 7 /* A >=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 */
+80
View File
@@ -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 <devices/sana2.h>
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
+19 -1
View File
@@ -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;
+1
View File
@@ -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
+112
View File
@@ -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
+43
View File
@@ -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: -
+189 -4
View File
@@ -16,6 +16,8 @@
#include <vampire/vampire.h>
#include "vampuuid.h"
#include "enc28j60.h"
#include <hardware/intbits.h>
#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<<HW_MACB_SPEED10;
else
ret |= HW_MAC_ON<<HW_MACB_SPEED10;
}
return ret;
}
/* process the list of multicast addresses for an appropriate
filtering list on the hardware
@@ -323,7 +433,7 @@ ASM SAVEDS LONG hw_check_link_change( ASMR(a0) DEVBASEP ASMREG(
filter with hashes etc.
*/
ASM SAVEDS LONG hw_change_multicast( ASMR(a0) DEVBASEP ASMREG(a0),
ASMR(a0) ULONG unit ASMREG(d0),
ASMR(d0) ULONG unit ASMREG(d0),
ASMR(a1) struct List *mcastlist ASMREG(a1) )
{
u08 flags;
@@ -341,3 +451,78 @@ ASM SAVEDS LONG hw_change_multicast( ASMR(a0) DEVBASEP ASMREG(
return 1;
}
#ifdef USE_INTERRUPT
/* relies on hwd_online */
void myhw_ControlInterrupts( DEVBASEP )
{
struct HWData *hwd = &db->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
+26 -5
View File
@@ -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 */
+113 -3
View File
@@ -15,11 +15,21 @@
#include <dos/dostags.h>
#include <devices/timer.h>
#ifdef HAVE_VERSION_H
#include "version.h"
#endif
#include "device.h"
#include "hw.h"
#include "macros.h"
#include "server.h"
#ifdef NEWSTYLE
#include <devices/newstyle.h>
#include <devices/sana2devqueryext.h> /* 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! */
+169
View File
@@ -0,0 +1,169 @@
###############################################################################
#
# SAS/C Makefile for SDNet and V2EXPETH
#
# author: Henryk Richter <henryk.richter@gmx.net>
#
# 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 <henryk.richter@gmx.net>
#
# 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
+169
View File
@@ -0,0 +1,169 @@
###############################################################################
#
# SAS/C Makefile for ENC624J6net
#
# author: Henryk Richter <henryk.richter@gmx.net>
#
# 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 <henryk.richter@gmx.net>
#
# 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
+16
View File
@@ -0,0 +1,16 @@
/*
version.h
(C) 2018 Henryk Richter <henryk.richter@gmx.net>
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