00001 /* This file provides the header for the functions 00002 the uIP stack needs to communicate with the driver */ 00003 00004 #ifndef TAPDEV_H 00005 #define TAPDEV_H 00006 00007 #include "xexception_l.h" 00008 #include "xbasic_types.h" 00009 #include "xpseudo_asm.h" 00010 00011 typedef Xuint8 u8_t; 00012 typedef Xuint16 u16_t; 00013 typedef Xuint32 u32_t; 00014 typedef Xint8 s8_t; 00015 typedef Xint16 s16_t; 00016 typedef Xint32 s32_t; 00017 00018 #include "xparameters.h" /* defines XPAR values */ 00019 #include "xtemac.h" /* defines XTemac API */ 00020 #include "stdio.h" /* stdio */ 00021 00022 /* From xparameters.h */ 00023 #define TEMAC_DEVICE_ID XPAR_PLB_TEMAC_0_DEVICE_ID 00024 00025 #define TEMAC_PHY_DELAY_SEC 4 /* Amount of time to delay waiting on PHY */ 00026 00027 /* Define an aligned data type for an ethernet frame. This declaration is 00028 specific to the GNU compiler */ 00029 //typedef char EthernetFrame[XTE_MAX_FRAME_SIZE] __attribute__ ((aligned (8))); 00030 00031 XTemac TemacInstance; /* Device instance used throughout examples */ 00032 extern char TemacMAC[]; /* MAC address, defined in tapdev.c */ 00033 extern int TemacLinkSpeed; /* Speed selection - should be 10, 100 or 1000 */ 00034 extern Xuint16 TemacInitReg0; /* If set, TemacConfigurePhy will be called for PHY Reg0 */ 00035 extern unsigned TemacLostFrames; /* Conted number of lost ethernet frames */ 00036 00037 //EthernetFrame TxFrame; /* Transmit frame buffer */ 00038 //EthernetFrame RxFrame; /* Receive frame buffer */ 00039 00040 /* Functions implemented in tapdev.c */ 00041 00042 // initializes the TEMAC 00043 int tapdev_init(); 00044 int TemacConfigurePhy(XTemac *TemacInstancePtr, Xuint16 reg0set); 00045 00046 // writes data to the outgoing FIFO 00047 void tapdev_write_to_fifo_partial(Xuint8 *buf, Xuint16 len); 00048 // writes an end of frame to the outgoing FIFO 00049 void tapdev_write_to_fifo_end_of_packet(Xuint8 *buf, Xuint16 len); 00050 00051 // send the outgoing FIFO 00052 void tapdev_send(Xuint16 len); 00053 void tapdev_send_fullpacket(Xuint8 *buf, Xuint16 len); 00054 00055 // tries to read a frame from the ingoing FIFO 00056 int tapdev_tryread_full_packet(Xuint8 *pbuf, Xuint32 len); 00057 00058 void tapdev_read_from_fifo_new_packet(Xuint32 *RxFrameLenght); 00059 void tapdev_read_from_fifo_partial(Xuint8 *buf, Xuint32 len); 00060 void tapdev_read_from_fifo_flush_end_of_packet(); 00061 00062 // returns the number of free bytes in the outgoing FIFO 00063 Xuint32 tapdev_freebytes(); 00064 00065 XStatus TemacGetTxStatus(); 00066 XStatus TemacGetRxStatus(); 00067 XStatus TemacResetDevice(); 00068 Xuint32 TemacDetectPHY(XTemac *TemacInstancePtr); 00069 int TemacReadoutPhyRegisters(XTemac *TemacInstancePtr); 00070 Xuint16 TemacReadCtrlReg(unsigned reg, Xuint32* retVal); 00071 Xuint16 TemacWriteCtrlReg(unsigned reg, Xuint32 val); 00072 int TemacPrintPhyRegisters(); 00073 void TemacPrintConfig(); 00074 00075 00076 #endif