I'm totally at a loss now when porting the lan91c111 vxworks driver
from x86 to arm.

Now I'm on the most critical stage developing a vxWorks BSP for ARM
S3C44B0 CPU.
I'm using Tornado 2.2 for arm. And Most of the work had been done
except the net adapter part.

The process of my porting is as follows:

1)download 111-vxworks.zip from smsc.com, which is a lan91c111 vxworks
driver only for x86
http://www.smsc.com/main/catalog/lan91c111.html
Download SRC-111-VX SRC-111-VX

2) then I redefine the Macros according to my ARM BSP as told in
lan91c111End.c

=====
quoted from lan91c111End.c

EXTERNAL SUPPORT REQUIREMENTS
This driver requires several external support functions, defined as
macros:
..CS
SYS_INT_CONNECT(pDrvCtrl, routine, arg)
SYS_INT_DISCONNECT (pDrvCtrl, routine, arg)
SYS_INT_ENABLE(pDrvCtrl)
SYS_INT_DISABLE(pDrvCtrl)
SYS_OUT_BYTE(pDrvCtrl, reg, data)
SYS_IN_BYTE(pDrvCtrl, reg, data)
SYS_OUT_WORD(pDrvCtrl, reg, data)
SYS_IN_WORD(pDrvCtrl, reg, data)
..CE
=====


#ifndef SYS_BUS_INT_ACK /*YK:inmport s3c44BIntLvlAck();*/
#define SYS_BUS_INT_ACK(pDrvCtrl) \
{ \
IMPORT int s3c44BIntLvlAck(); \
s3c44BIntLvlAck (pDrvCtrl->ilevel); \
}
#endif /*SYS_BUS_INT_ACK*/


#define SYS_INT_CONNECT(pDrvCtrl,rtn,arg,pResult) \
{ \
IMPORT STATUS intConnect(); \
*pResult = intConnect ( (VOIDFUNCPTR *)
(INUM_TO_IVEC(pDrvCtrl->ivec)), \
rtn, (int)arg); \
}

#ifdef SYS_INT_ENABLE
#undef SYS_INT_ENABLE
#endif

#define SYS_INT_ENABLE(pDrvCtrl) {i ntEnable(pDrvCtrl->ilevel);}


3) defining macro in my BSP to include lan91c111, as instructed in
readme.pdf

in file "config.h",add

#ifdef INCLUDE_END
#define INCLUDE_LAN91C111_END /*Include SMSC lan91c111 driver*/
#undef INCLUDE_SNGKS32C_END /* Include Ethernet driver */
#endif /* INCLUDE_END */

in file "configNet.h",add

#ifdef INCLUDE_LAN91C111_END
#define END_LAN91C111_LOAD_FUNC lan91c111Load
#define END_LAN91C111_BUFF_LOAN 1
/*:::::*/
#define END_LAN91C111_LOAD_STRING
"0x2000300:0x18:0x18:0x2:0x3100:0x08:0x00:0x3e:0x21 :0xc7:0xf8"
IMPORT END_OBJ * END_LAN91C111_LOAD_FUNC (char *, void*);
#endif /* INCLUDE_LAN91C111_END */

END_TBL_ENTRY endDevTbl [] =
{

#ifdef INCLUDE_LAN91C111_END
{0, END_LAN91C111_LOAD_FUNC, END_LAN91C111_LOAD_STRING,
END_LAN91C111_BUFF_LOAN, NULL, FALSE},
#endif /* INCLUDE_LAN91C111_END */


{ 0, END_TBL_END, NULL, 0, NULL, FALSE},
};

After Step 3, the driver and the BSP are get connected.

4) But, after buidling the bootrom and burn it to the flash, lan91c111
doesn't work.

It got stuck in the lan91c111EndLoad process.

So I looked into the driver source, did some tests, finally found that
the malfunction was caused by the wrong IOBase type.

For x86, IOBase is 0x300 which is USHORT, but for ARM, IOBase is
0x2000300 which is UINT.

so, five functions should be revised as follows, which are
LOCAL UINT DetectPHY(LAN91C111END_DEVICE *Adapter ,UINT IOBase);
UINT ReadPhyRegister( UINT IOBase, UCHAR phyaddr, UCHAR phyreg);
VOID WritePhyRegister( UINT IOBase, UCHAR phyaddr, UCHAR phyreg, ULONG
phyregdat );
LOCAL USHORT InputMDO( UINT IOAddress );
LOCAL VOID OutputMDO( UINT IOAddress, UCHAR lev );

ALL types of IOBase are modified from USHORT to UINT.

6) After step 5, I got lan91c111EndLoad right, and the debug log goes
as follows:


Loading lan...str=0:0x2000300:0x18
:0x18:0x2:0x3100:0x08:0x00:0x3e:0x21:0xc7:0xf8
0xc701838 (t8): MAC Addr : 8: 0:3e:21:c7:f8
0xc701838 (t8): Processed all arugments
0xc701838 (t8): lan91c111Start: Interrupt connected.
0xc701838 (t8): ==> Configure Adapter
0xc701838 (t8): Duplex : 0xc701838 (t8): AUTO_NEGOTIATION
0xc701838 (t8): Speed : 0xc701838 (t8): AUTO_NEGOTIATION
0xc701838 (t8): ==> Configure Isa
0xc701838 (t8): ==> Adapter Verify
0xc701838 (t8): Card is 91C11X
0xc701838 (t8): ==> DoRAMTest
0xc701838 (t8): <== Adapter Verify
0xc701838 (t8): PHY:LAN83C183
0xc701838 (t8): <== Configure Isa
0xc701838 (t8): AUTO
0xc701838 (t8): PHY:LAN83C183
0xc701838 (t8): ==> Program National PHY
0xc701838 (t8): 100BaseTX Half Duplex!
0xc701838 (t8): <== Program National PHY
0xc701838 (t8): <== Configure Adapter
0xc701838 (t8): ==> Adapter Reset
0xc701838 (t8): New MAC Address = 08-00-3e-21-c7-f8
0xc701838 (t8): PHY:LAN83C183
0xc701838 (t8): ==> Program National PHY
0xc701838 (t8): 100BaseTX Half Duplex!
0xc701838 (t8): <== Program National PHY
0xc701838 (t8): <== Adapter Reset
0xc701838 (t8): lan91c111MemInit: called
0xc701838 (t8): lan91c111MemInit: Memory setup complete
0xc701838 (t8): VALUE OF TCR=0x 81
0xc701838 (t8): Done loading lan91c111. ..
0xc701838 (t8): IOBase 0x2000300 Ivec 0x18 ILevel 0x18 Offset 2
InitConfig 0x3100
unit 0 IOBase 0x2000300 Ivec 0x18 ILevel 0x18 Offset 2 InitConfig
0x3100

7) Now,It's time for the driver to deal with the intterupt. and I got
stuck here.
I read the driver source of the interrupt part, which seems
theoretically correct, but lan91c111 still malfunctions.

the boot process outputs:

boot device : lnc
unit number : 0
processor number : 0
host name : host
file name : vxWorks
inet on ethernet (e) : 192.168.1.117:ffffff00
host inet (h) : 192.168.1.109
user (u) : micetek
ftp password (pw) : micetek
flags (f) : 0x0
target name (tn) : micetek

Attached TCP/IP interface to lnc0.
0xc7c27d4 (tBoot): lan91c111Send: called
0xc7c27d4 (tBoot): lan91c111Send : Got Access to MMU
0xc7c27d4 (tBoot): lan91c111Send : Out of Write Function
logTask: 3 log messages lost.
interrupt: ----------- START ISR -------------
interrupt: lan91c111Int: BANK2_INT_STS 0xb30e
interrupt: lan91c111Int: IntrSts = 2
interrupt: TX
0xc7c27d4 (tBoot): RCR value = 0x300
0xc7c27d4 (tBoot): Setting promiscuous mode off!
0xc7c27d4 (tBoot): RCR value = 0x300
0xc7c27d4 (tBoot): Addr Filter Set: The Table contents are : 0x0
0xc7c27d4Attaching network (interface tBoot): Addr Filter Set: The
Table contents are : 0xlo00
0x... c7c27d4 (tBoot): Addr Filter Set: The Table contents are :
0xdone.0

0xc7c27d4 (tBoot): Addr Filter Set: The Table contents are :
0xLoad0ing...
0xc7c27d4 (tBoot): Current MCast Addrs = 0x
logTask: 7 log messages lost.
0xc7c27d4 (tBoot): CRC Value = 0x1f
0xc7c27d4 (tBoot): Current Index Value = 0x80
0xc7c27d4 (tBoot): lan91c111Send: called
0xc7c27d4 (tBoot): lan91c111Send : Got Access to MMU
0xc7c27d4 (tBoot): lan91c111Send : Out of Write Function
0xc7b2dfc (tNetTask): lan91c111Send: called
0xc7b2dfc (tNetTask): lan91c111Send : Got Access to MMU
0xc7b2dfc (tNetTask): lan91c111Send : Out of Write Function

then no more outpus were seen..

=========================

my S3C44B0 Bsp is proved to work well with RT8019 so I don't think it's
the BSP that cause the malfunction but the lan91c111 driver.

and the Driver SMSC provided has been tested using "NIC Tests" under
SmartBits. It ran fine for larger packet sizes, but the OS (not driver)
crashed for 64-byte packet size.

I was really stuck here for a few days...

To sum up, my BSP is OK with the other net adapter driver, and I'm sure
the lan91c111EndLoad process get right now,

Shall I focus on the the interrupt handling part to find the cause of
the malfunction?