- Driver optimization

This commit is contained in:
HenrykRichter
2017-12-27 09:34:03 +01:00
parent cb1743d4a2
commit dde9bf1d4e
7 changed files with 88 additions and 50 deletions
Binary file not shown.
+11 -7
View File
@@ -255,7 +255,7 @@ PRIVATE APTR pb_AllocExpansion( ULONG portid, BASEPTR )
struct BufferManagement *bm;
LONG rv = 0; /* get rid of warning with opt build */
d(("entered\n"));
d(("entered for unit %ld\n",unit));
/* Make sure our open remains single-threaded. */
ObtainSemaphore(&pb->pb_Lock);
@@ -304,6 +304,7 @@ PRIVATE APTR pb_AllocExpansion( ULONG portid, BASEPTR )
if( !cfg )
break;
pb->pb_HWBase.hwb_boards[i] = cfg->cd_BoardAddr;
d(("board at = %ld\n",(ULONG)pb->pb_HWBase.hwb_boards[i] ));
}
pb->pb_HWBase.hwb_boards[i] = (0);
}
@@ -383,10 +384,10 @@ PRIVATE APTR pb_AllocExpansion( ULONG portid, BASEPTR )
}
#else /* PROTO_SDNET */
unsigned char addr[6] = { 0x1a,0x11,0xaf,0xa0,0x47,0x11 };
#endif /* PROTO_SDNET */
#endif /* PROTO_ENC624NET */
memcpy(pb->pb_CfgAddr, addr, HW_ADDRFIELDSIZE);
memcpy(pb->pb_DefAddr, addr, HW_ADDRFIELDSIZE);
#endif /* PROTO_SDNET */
#endif /* PROTO_ENC624NET */
}
/*
@@ -438,7 +439,7 @@ PRIVATE APTR pb_AllocExpansion( ULONG portid, BASEPTR )
{
d(("starting server"));
if (pb->pb_Server = CreateNewProcTags(NP_Entry, ServerTask, NP_Name,
NP_Priority, 9, SERVERTASKNAME, TAG_DONE))
NP_Priority, 59, SERVERTASKNAME, TAG_DONE))
{
ss.ss_Error = 1;
ss.ss_PLIPBase = pb;
@@ -670,12 +671,15 @@ PRIVATE APTR pb_AllocExpansion( ULONG portid, BASEPTR )
switch(ios2->ios2_Req.io_Command)
{
case CMD_READ:
/*
if (pb->pb_Flags & PLIPF_OFFLINE)
{
ios2->ios2_Req.io_Error = S2ERR_OUTOFSERVICE;
ios2->ios2_WireError = S2WERR_UNIT_OFFLINE;
}
else if (ios2->ios2_BufferManagement == NULL)
else
*/
if (ios2->ios2_BufferManagement == NULL)
{
ios2->ios2_Req.io_Error = S2ERR_BAD_ARGUMENT;
ios2->ios2_WireError = S2WERR_BUFF_ERROR;
@@ -684,7 +688,7 @@ PRIVATE APTR pb_AllocExpansion( ULONG portid, BASEPTR )
{
ios2->ios2_Req.io_Flags &= ~SANA2IOF_QUICK;
ObtainSemaphore(&pb->pb_ReadListSem);
AddTail((struct List*)&pb->pb_ReadList, (struct Node*)ios2);
AddHead((struct List*)&pb->pb_ReadList, (struct Node*)ios2);
ReleaseSemaphore(&pb->pb_ReadListSem);
ios2 = NULL;
}
@@ -806,7 +810,7 @@ PRIVATE APTR pb_AllocExpansion( ULONG portid, BASEPTR )
case S2_GETTYPESTATS:
if (!gettrackrec(pb, ios2->ios2_PacketType, (struct Sana2PacketTypeStats *)ios2->ios2_StatData))
{
ios2->ios2_Req.io_Error = S2ERR_BAD_STATE;
ios2->ios2_Req.io_Error = S2ERR_NO_ERROR; /*S2ERR_BAD_STATE;*/
ios2->ios2_WireError = S2WERR_NOT_TRACKED;
}
break;
+31 -2
View File
@@ -29,12 +29,12 @@
DEBUG EQU 1
;
; FIXME: needs verification
; also: either swap buffer or registers/pointers etc.
;------------------ options, some depend on hardware (CPLD) configuration -------------------------
_OPT_BUFFER_SWAP EQU 1 ;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 1 ;address lines 12/13 are swapped (1) or linear addressing (0)
_OPT_FLOWCONTROL EQU 1 ;perform flow control on RX (1) or not (0)
_OPT_RECV EQU 1 ;faster recv (1) or generic (0)
;
; options for buffer memory configuration, please reserve some space for private variables
@@ -1662,6 +1662,34 @@ _enc624j6l_RecvFrame: ;
;a1: dest pointer
move.l a1,a3
ifne _OPT_RECV
move d7,d1 ;start
move #$7000,d2 ;mask
add d0,d1 ;start+bytes
and d2,d1 ;keep only multiples of $1000
and d7,d2 ;keep only multiples of $1000
cmp d1,d2
bne.s .nooptrecv ;sadly, we cannot use faster routine atm
ifne _OPT_ADR_QUIRK
eor.w #$6000,d7
endc
lea (a0,d7.w),a2 ;read pointer
move d0,d1 ;byte count
lsr #1,d1 ;converted to word count
bcs.s .opt_read ;read 1 byte more if impair byte count
subq #1,d1 ;words - 1
.opt_read:
move (a2)+,d2 ;get current word
ifne _OPT_BUFFER_SWAP
rol.w #8,d2 ;swap buffer to Big Endian
endc
move d2,(a1)+
dbf d1,.opt_read
bra.s .end_read
.nooptrecv:
endc ;_OPT_RECV
;generic loop: check for position overflows with each word
move d0,d1 ;byte count
lsr #1,d1 ;converted to word count
@@ -1678,6 +1706,7 @@ _enc624j6l_RecvFrame: ;
move d2,(a1)+
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
+3 -9
View File
@@ -421,19 +421,16 @@ GLOBAL REGARGS BOOL hw_send_frame(struct PLIPBase *pb, struct HWFrame *frame)
}
GLOBAL REGARGS BOOL hw_recv_pending(struct PLIPBase *pb)
GLOBAL REGARGS LONG hw_recv_pending(struct PLIPBase *pb)
{
#ifdef PROTO_ENC624NET
struct HWBase *hwb = &pb->pb_HWBase;
int num = enc624j6l_HaveRecv( BOARD );
LONG num = enc624j6l_HaveRecv( BOARD );
#else
u08 num;
num = enc28j60_has_recv();
#endif
if( num > 0 )
return TRUE;
else
return FALSE;
return (LONG)num;
}
/* important: don't call this without enc28j60_has_recv() > 0 check */
@@ -446,13 +443,10 @@ GLOBAL REGARGS BOOL hw_recv_frame(struct PLIPBase *pb, struct HWFrame *frame)
struct HWBase *hwb = &pb->pb_HWBase;
len = enc624j6l_RecvFrame( BOARD, ptr+sizeof(USHORT), 1518 );
frame->hwf_Size = len;
if( len > 0 )
rc = TRUE;
else
frame->hwf_Size = 0;
#else
BOOL rc = FALSE;
u08 *ptr = (u08*)frame;
+1 -1
View File
@@ -102,7 +102,7 @@ struct PLIPBase
UBYTE pb_Unit; /* unit of 1st OpenDevice() */
UBYTE pb_pad1; /* make the following long alligned */
BPTR pb_SegList; /* pointer to code */
struct Library * pb_VampireBase;
struct Library * pb_VampireBase; /* used for sdnet only */
struct Library * pb_ExpansionBase;
struct Library * pb_UtilityBase;
struct Library * pb_DOSBase;
+1 -1
View File
@@ -50,7 +50,7 @@ GLOBAL REGARGS BOOL hw_send_frame(struct PLIPBase *pb, struct HWFrame *frame);
GLOBAL REGARGS BOOL hw_send_magic_pkt(struct PLIPBase *pb, USHORT magic);
GLOBAL REGARGS ULONG hw_recv_sigmask(struct PLIPBase *pb);
GLOBAL REGARGS BOOL hw_recv_pending(struct PLIPBase *pb);
GLOBAL REGARGS LONG hw_recv_pending(struct PLIPBase *pb);
GLOBAL REGARGS BOOL hw_recv_frame(struct PLIPBase *pb, struct HWFrame *frame);
GLOBAL REGARGS void hw_config_init(struct PLIPBase *pb);
+23 -12
View File
@@ -48,6 +48,12 @@
*/
typedef enum { AW_OK, AW_BUFFER_ERROR, AW_ERROR } AW_RESULT;
/*
** definitions
*/
#define SINGLE_RW 1
/*E*/
/*F*/ /* imports */
/* external functions */
@@ -234,13 +240,6 @@ PRIVATE REGARGS VOID dos2reqs(BASEPTR);
nextwrite = (struct IOSana2Req *) currentwrite->ios2_Req.io_Message.mn_Node.ln_Succ;
currentwrite = nextwrite )
{
/*
if (hw_recv_pending(pb))
{
d(("incoming data!"));
break;
}
*/
code = write_frame(pb, currentwrite);
if (code == AW_BUFFER_ERROR) /* BufferManagement callback error */
@@ -683,8 +682,10 @@ PRIVATE REGARGS BOOL read_frame(struct IOSana2Req *req, struct HWFrame *frame)
if (init(pb))
{
ULONG recv=0, portsigmask, recvsigmask, wmask;
ULONG recv=0, portsigmask, recvsigmask, wmask,specialmask;
LONG haverec;
BOOL running;
struct IOSana2Req *wr;
/* Ok, we are fine and will tell this mother personally :-) */
pb->pb_Startup->ss_Error = 0;
@@ -695,6 +696,7 @@ PRIVATE REGARGS BOOL read_frame(struct IOSana2Req *req, struct HWFrame *frame)
portsigmask = 1 << pb->pb_ServerPort->mp_SigBit;
recvsigmask = hw_recv_sigmask(pb);
specialmask = portsigmask | SIGBREAKF_CTRL_C;
wmask = SIGBREAKF_CTRL_F | SIGBREAKF_CTRL_C | portsigmask | recvsigmask;
@@ -706,32 +708,40 @@ PRIVATE REGARGS BOOL read_frame(struct IOSana2Req *req, struct HWFrame *frame)
/* send packets if any */
d2(("*+ do_write\n"));
wr = (struct IOSana2Req *)pb->pb_WriteList.lh_Head;
if( wr->ios2_Req.io_Message.mn_Node.ln_Succ )
{
dowritereqs(pb);
}
d2(("*- do_write\n"));
/* if no recv is pending then wait for incoming signals */
if (!hw_recv_pending(pb)) {
haverec = hw_recv_pending(pb);
if( !haverec )
{
d2(("**> wait\n"));
recv = Wait(wmask);
d2(("**> wait: got 0x%08lx\n", recv));
haverec = hw_recv_pending(pb);
}
/* accept pending receive and start reading */
if (hw_recv_pending(pb))
if( haverec )
{
d2(("*+ do_read\n"));
doreadreqs(pb);
d2(("*- do_read\n"));
}
if( recv & specialmask )
{
/* handle SANA-II send requests */
if (recv & portsigmask)
{
d(("SANA-II request(s)\n"));
dos2reqs(pb);
recv &= ~portsigmask;
}
/* stop server task */
if (recv & SIGBREAKF_CTRL_C)
{
@@ -740,6 +750,7 @@ PRIVATE REGARGS BOOL read_frame(struct IOSana2Req *req, struct HWFrame *frame)
}
}
}
}
else
d(("init() failed\n"));