#ifndef __fei82559_h__ #define __fei82559_h__ #include "type.h" #include "ethernetCapable.h" struct Fei82559 : public EthernetCapable { //~Fei82559(); struct Hw { struct ScbControlStatus { Field rus; Field cus; struct Flags { Field cx; Field fr; Field cna; Field rnr; Field mdi; Field swi; Field rsvd; Field fcp; Field all; }; struct Interrupt { Field si; Field fcp; Field er; Field rnr; Field cna; Field fr; Field cx; Field all; }; RelativeRef stat; RelativeRef ack; Field ruc; Field cuc; Field interruptGlobalMask; RelativeRef interrupt; volatile U32 all; }; RelativeRef scbControlStatus; Relative scbGeneralPointer; Relative port; struct Eeprom { static const U32 cmdLen=3; static const U32 adrLen=8; static const U32 dataLen=16; struct OpCode { static const U32 erase=0x7000000; static const U32 read =0x6000000; static const U32 write=0x5000000; static const U32 ewen =0x4c00000; static const U32 eral =0x4800000; static const U32 wral =0x4400000; static const U32 ewds =0x4000000; }; struct Control { Field ck; Field cs; Field din; Field dout; volatile U32 all; }; RelativeRef control; void bitDelay(); bool cmd(U32 cmd,U32 address=0,U32 *data=0); inline bool eraseAll() { return cmd(OpCode::eral); } inline bool ewen() { return cmd(OpCode::ewen); } inline bool ewds() { return cmd(OpCode::ewds); } inline bool read(U32 address,U32 *data) { return cmd(OpCode::read,address,data); } inline bool write(U32 address,U32 data) { return cmd(OpCode::write,address,&data); } U32 all; }; RelativeRef eeprom; struct Mdi { struct OpCode { static const U32 write=1; static const U32 read=2; }; struct Control { Field interruptEnable; Field ready; Field opCode; Field phyAdd; Field regAdd; Field data; U32 all; }; RelativeRef control; bool access(U32 phyAdd,U32 regAdd,U32 *data,U32 opCode); inline bool read (U32 phyAdd,U32 regAdd,U32 *data) { return access(phyAdd,regAdd,data,OpCode::read); } bool write(U32 phyAdd,U32 regAdd,U32 data) { return access(phyAdd,regAdd,&data,OpCode::write); } U32 all; }; RelativeRef mdi; struct Cb { struct CommandStatus { Field el; Field s; Field i; Field cid; Field h; Field nc; Field sf; Field cmd; Field c; Field ok; Field u; Field status; U32 all; }; RelativeRef commandStatus; Relative link; }; struct Nop : public Cb { RelativeRef bytes; RelativeRef words; U32 head[2]; U32 data[2]; // not used } __attribute__((packed)); struct Ias : public Cb { RelativeRef bytes; RelativeRef words; U32 head[2]; U32 data[2]; } __attribute__((packed)); struct Config : public Cb { RelativeRef bytes; U32 head[2]; U32 data[0]; } __attribute__((packed)); struct Dump : public Cb { Relative buf; U32 head[4]; U32 data[596/sizeof(U32)]; } __attribute__((packed)); struct Other { U8 dgsh[0]; } __attribute__((packed)); struct Rd : public Cb { //RelativeRef cb; Relative reserved; struct Sizes { Field size; Field actual; Field f; Field eof; U32 all; }; RelativeRef sizes; U32 head[4]; U32 data[0]; }; struct Tbd { Relative address; struct Sizes { Field length; Field el; U32 all; }; RelativeRef sizes; U32 buf[2]; }; struct Td : public Cb { //RelativeRef cb; Relative tbds; struct Sizes { Field tcbCount; Field f; Field eof; Field threshold; Field tbdNumber; U32 all; }; RelativeRef sizes; RelativeRef extTbds; U32 head[4]; U32 data[0]; }; bool doCu(Cb *cb); bool doCuResume(); bool doRu(Cb *cb); bool receiveTodo(Rd *rd,U32 len); bool receiveDone(Rd *rd,U32 *len); bool init(); bool dump(); }; struct Td : public Hw::Td { Ethernet ethernet[0]; U8 buf[ALIGN(Ethernet::MTU,32)]; }; struct Rd : public Hw::Rd { Ethernet ethernet[0]; U8 buf[ALIGN(Ethernet::MTU,32)]; }; static const U32 rdsCount=4; static const U32 tdsCount=4; Aligned buf; Hw *hw; Rd *currentRd; Td *currentTd; int debugLevel; Fei82559(); virtual bool init(); virtual void reset(); virtual Ethernet *receive(U32 *size); virtual void receive(Ethernet *e); virtual Ethernet *send(); virtual bool send(Ethernet *,U32 size); }; #endif /* __fei82559_h__ */