1 /******************************************************************************
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
12 * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
13 * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
14 * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD,
15 * XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE
16 * FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR OBTAINING
17 * ANY THIRD PARTY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
18 * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
19 * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY
20 * WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM
21 * CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND
22 * FITNESS FOR A PARTICULAR PURPOSE.
25 * Xilinx hardware products are not intended for use in life support
26 * appliances, devices, or systems. Use in such applications is
27 * expressly prohibited.
30 * (c) Copyright 2002-2004 Xilinx Inc.
31 * All rights reserved.
34 * You should have received a copy of the GNU General Public License along
35 * with this program; if not, write to the Free Software Foundation, Inc.,
36 * 675 Mass Ave, Cambridge, MA 02139, USA.
38 ******************************************************************************/
39 /*****************************************************************************/
44 * The XEmac driver. Functions in this file are the minimum required functions
45 * for this driver. See xemac.h for a detailed description of the driver.
48 * MODIFICATION HISTORY:
50 * Ver Who Date Changes
51 * ----- ---- -------- -------------------------------------------------------
52 * 1.00a rpm 07/31/01 First release
53 * 1.00b rpm 02/20/02 Repartitioned files and functions
54 * 1.00b rpm 07/23/02 Removed the PHY reset from Initialize()
55 * 1.00b rmm 09/23/02 Removed commented code in Initialize(). Recycled as
56 * XEmac_mPhyReset macro in xemac_l.h.
57 * 1.00c rpm 12/05/02 New version includes support for simple DMA
58 * 1.00c rpm 12/12/02 Changed location of IsStarted assignment in XEmac_Start
59 * to be sure the flag is set before the device and
60 * interrupts are enabled.
61 * 1.00c rpm 02/03/03 SelfTest was not clearing polled mode. Take driver out
62 * of polled mode in XEmac_Reset() to fix this problem.
63 * 1.00c rmm 05/13/03 Fixed diab compiler warnings relating to asserts.
65 ******************************************************************************/
67 /***************************** Include Files *********************************/
69 #include "xbasic_types.h"
72 #include "xipif_v1_23_b.h" /* Uses v1.23b of the IPIF */
74 /************************** Constant Definitions *****************************/
76 /**************************** Type Definitions *******************************/
78 /***************** Macros (Inline Functions) Definitions *********************/
80 /************************** Function Prototypes ******************************/
82 static XStatus ConfigureDma(XEmac * InstancePtr);
83 static XStatus ConfigureFifo(XEmac * InstancePtr);
84 static void StubFifoHandler(void *CallBackRef);
85 static void StubErrorHandler(void *CallBackRef, XStatus ErrorCode);
86 static void StubSgHandler(void *CallBackRef, XBufDescriptor * BdPtr,
89 /************************** Variable Definitions *****************************/
91 /*****************************************************************************/
94 * Initialize a specific XEmac instance/driver. The initialization entails:
95 * - Initialize fields of the XEmac structure
96 * - Clear the Ethernet statistics for this device
97 * - Initialize the IPIF component with its register base address
98 * - Configure the FIFO components with their register base addresses.
99 * - If the device is configured with DMA, configure the DMA channel components
100 * with their register base addresses. At some later time, memory pools for
101 * the scatter-gather descriptor lists may be passed to the driver.
102 * - Reset the Ethernet MAC
104 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
105 * @param DeviceId is the unique id of the device controlled by this XEmac
106 * instance. Passing in a device id associates the generic XEmac
107 * instance to a specific device, as chosen by the caller or application
112 * - XST_SUCCESS if initialization was successful
113 * - XST_DEVICE_IS_STARTED if the device has already been started
114 * - XST_DEVICE_NOT_FOUND if device configuration information was not found for
115 * a device with the supplied device ID.
121 ******************************************************************************/
123 XEmac_Initialize(XEmac * InstancePtr, u16 DeviceId)
126 XEmac_Config *ConfigPtr; /* configuration information */
128 XASSERT_NONVOID(InstancePtr != NULL);
131 * If the device is started, disallow the initialize and return a status
132 * indicating it is started. This allows the user to stop the device
133 * and reinitialize, but prevents a user from inadvertently initializing
135 if (InstancePtr->IsStarted == XCOMPONENT_IS_STARTED) {
136 return XST_DEVICE_IS_STARTED;
140 * Lookup the device configuration in the temporary CROM table. Use this
141 * configuration info down below when initializing this component.
143 ConfigPtr = XEmac_LookupConfig(DeviceId);
144 if (ConfigPtr == NULL) {
145 return XST_DEVICE_NOT_FOUND;
149 * Set some default values
151 InstancePtr->IsReady = 0;
152 InstancePtr->IsStarted = 0;
153 InstancePtr->IpIfDmaConfig = ConfigPtr->IpIfDmaConfig;
154 InstancePtr->HasMii = ConfigPtr->HasMii;
155 InstancePtr->HasMulticastHash = FALSE;
157 /* Always default polled to false, let user configure this mode */
158 InstancePtr->IsPolled = FALSE;
159 InstancePtr->FifoRecvHandler = StubFifoHandler;
160 InstancePtr->FifoSendHandler = StubFifoHandler;
161 InstancePtr->ErrorHandler = StubErrorHandler;
162 InstancePtr->SgRecvHandler = StubSgHandler;
163 InstancePtr->SgSendHandler = StubSgHandler;
166 * Clear the statistics for this driver
168 XEmac_mClearStruct((u8 *) & InstancePtr->Stats, sizeof (XEmac_Stats));
171 * Initialize the device register base addresses
173 InstancePtr->BaseAddress = ConfigPtr->BaseAddress;
176 * Configure the send and receive FIFOs in the MAC
178 Result = ConfigureFifo(InstancePtr);
179 if (Result != XST_SUCCESS) {
184 * If the device is configured for DMA, configure the send and receive DMA
185 * channels in the MAC.
187 if (XEmac_mIsDma(InstancePtr)) {
188 Result = ConfigureDma(InstancePtr);
189 if (Result != XST_SUCCESS) {
195 * Indicate the component is now ready to use. Note that this is done before
196 * we reset the device and the PHY below, which may seem a bit odd. The
197 * choice was made to move it here rather than remove the asserts in various
198 * functions (e.g., Reset() and all functions that it calls). Applications
199 * that use multiple threads, one to initialize the XEmac driver and one
200 * waiting on the IsReady condition could have a problem with this sequence.
202 InstancePtr->IsReady = XCOMPONENT_IS_READY;
205 * Reset the MAC to get it into its initial state. It is expected that
206 * device configuration by the user will take place after this
207 * initialization is done, but before the device is started.
209 XEmac_Reset(InstancePtr);
214 /*****************************************************************************/
217 * Start the Ethernet controller as follows:
218 * - If not in polled mode
219 * - Set the internal interrupt enable registers appropriately
220 * - Enable interrupts within the device itself. Note that connection of
221 * the driver's interrupt handler to the interrupt source (typically
222 * done using the interrupt controller component) is done by the higher
224 * - If the device is configured with scatter-gather DMA, start the DMA
225 * channels if the descriptor lists are not empty
226 * - Enable the transmitter
227 * - Enable the receiver
229 * The PHY is enabled after driver initialization. We assume the upper layer
230 * software has configured it and the EMAC appropriately before this function
233 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
237 * - XST_SUCCESS if the device was started successfully
238 * - XST_NO_CALLBACK if a callback function has not yet been registered using
239 * the SetxxxHandler function. This is required if in interrupt mode.
240 * - XST_DEVICE_IS_STARTED if the device is already started
241 * - XST_DMA_SG_NO_LIST if configured for scatter-gather DMA and a descriptor
242 * list has not yet been created for the send or receive channel.
246 * The driver tries to match the hardware configuration. So if the hardware
247 * is configured with scatter-gather DMA, the driver expects to start the
248 * scatter-gather channels and expects that the user has set up the buffer
249 * descriptor lists already. If the user expects to use the driver in a mode
250 * different than how the hardware is configured, the user should modify the
251 * configuration table to reflect the mode to be used. Modifying the config
252 * table is a workaround for now until we get some experience with how users
253 * are intending to use the hardware in its different configurations. For
254 * example, if the hardware is built with scatter-gather DMA but the user is
255 * intending to use only simple DMA, the user either needs to modify the config
256 * table as a workaround or rebuild the hardware with only simple DMA.
258 * This function makes use of internal resources that are shared between the
259 * Start, Stop, and SetOptions functions. So if one task might be setting device
260 * options while another is trying to start the device, the user is required to
261 * provide protection of this shared data (typically using a semaphore).
263 ******************************************************************************/
265 XEmac_Start(XEmac * InstancePtr)
270 XASSERT_NONVOID(InstancePtr != NULL);
271 XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);
274 * If it is already started, return a status indicating so
276 if (InstancePtr->IsStarted == XCOMPONENT_IS_STARTED) {
277 return XST_DEVICE_IS_STARTED;
281 * If not polled, enable interrupts
283 if (!InstancePtr->IsPolled) {
285 * Verify that the callbacks have been registered, then enable
288 if (XEmac_mIsSgDma(InstancePtr)) {
289 if ((InstancePtr->SgRecvHandler == StubSgHandler) ||
290 (InstancePtr->SgSendHandler == StubSgHandler)) {
291 return XST_NO_CALLBACK;
294 /* Enable IPIF interrupts */
295 XIIF_V123B_WRITE_DIER(InstancePtr->BaseAddress,
296 XEM_IPIF_DMA_DFT_MASK |
297 XIIF_V123B_ERROR_MASK);
298 XIIF_V123B_WRITE_IIER(InstancePtr->BaseAddress,
299 XEM_EIR_DFT_SG_MASK);
301 /* Enable scatter-gather DMA interrupts */
302 XDmaChannel_SetIntrEnable(&InstancePtr->RecvChannel,
303 XEM_DMA_SG_INTR_MASK);
304 XDmaChannel_SetIntrEnable(&InstancePtr->SendChannel,
305 XEM_DMA_SG_INTR_MASK);
307 if ((InstancePtr->FifoRecvHandler == StubFifoHandler) ||
308 (InstancePtr->FifoSendHandler == StubFifoHandler)) {
309 return XST_NO_CALLBACK;
312 /* Enable IPIF interrupts (used by simple DMA also) */
313 XIIF_V123B_WRITE_DIER(InstancePtr->BaseAddress,
314 XEM_IPIF_FIFO_DFT_MASK |
315 XIIF_V123B_ERROR_MASK);
316 XIIF_V123B_WRITE_IIER(InstancePtr->BaseAddress,
317 XEM_EIR_DFT_FIFO_MASK);
320 /* Enable the global IPIF interrupt output */
321 XIIF_V123B_GINTR_ENABLE(InstancePtr->BaseAddress);
325 * Indicate that the device is started before we enable the transmitter
326 * or receiver. This needs to be done before because as soon as the
327 * receiver is enabled we may get an interrupt, and there are functions
328 * in the interrupt handling path that rely on the IsStarted flag.
330 InstancePtr->IsStarted = XCOMPONENT_IS_STARTED;
333 * Enable the transmitter, and receiver (do a read/modify/write to preserve
334 * current settings). There is no critical section here since this register
335 * is not modified during interrupt context.
337 ControlReg = XIo_In32(InstancePtr->BaseAddress + XEM_ECR_OFFSET);
338 ControlReg &= ~(XEM_ECR_XMIT_RESET_MASK | XEM_ECR_RECV_RESET_MASK);
339 ControlReg |= (XEM_ECR_XMIT_ENABLE_MASK | XEM_ECR_RECV_ENABLE_MASK);
341 XIo_Out32(InstancePtr->BaseAddress + XEM_ECR_OFFSET, ControlReg);
344 * If configured with scatter-gather DMA and not polled, restart the
345 * DMA channels in case there are buffers ready to be sent or received into.
346 * The DMA SgStart function uses data that can be modified during interrupt
347 * context, so a critical section is required here.
349 if ((XEmac_mIsSgDma(InstancePtr)) && (!InstancePtr->IsPolled)) {
350 XIIF_V123B_GINTR_DISABLE(InstancePtr->BaseAddress);
353 * The only error we care about is if the list has not yet been
354 * created, or on receive, if no buffer descriptors have been
355 * added yet (the list is empty). Other errors are benign at this point.
357 Result = XDmaChannel_SgStart(&InstancePtr->RecvChannel);
358 if ((Result == XST_DMA_SG_NO_LIST)
359 || (Result == XST_DMA_SG_LIST_EMPTY)) {
360 XIIF_V123B_GINTR_ENABLE(InstancePtr->BaseAddress);
364 Result = XDmaChannel_SgStart(&InstancePtr->SendChannel);
365 if (Result == XST_DMA_SG_NO_LIST) {
366 XIIF_V123B_GINTR_ENABLE(InstancePtr->BaseAddress);
370 XIIF_V123B_GINTR_ENABLE(InstancePtr->BaseAddress);
376 /*****************************************************************************/
379 * Stop the Ethernet MAC as follows:
380 * - If the device is configured with scatter-gather DMA, stop the DMA
381 * channels (wait for acknowledgment of stop)
382 * - Disable the transmitter and receiver
383 * - Disable interrupts if not in polled mode (the higher layer software is
384 * responsible for disabling interrupts at the interrupt controller)
386 * The PHY is left enabled after a Stop is called.
388 * If the device is configured for scatter-gather DMA, the DMA engine stops at
389 * the next buffer descriptor in its list. The remaining descriptors in the list
390 * are not removed, so anything in the list will be transmitted or received when
391 * the device is restarted. The side effect of doing this is that the last
392 * buffer descriptor processed by the DMA engine before stopping may not be the
393 * last descriptor in the Ethernet frame. So when the device is restarted, a
394 * partial frame (i.e., a bad frame) may be transmitted/received. This is only a
395 * concern if a frame can span multiple buffer descriptors, which is dependent
396 * on the size of the network buffers.
398 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
402 * - XST_SUCCESS if the device was stopped successfully
403 * - XST_DEVICE_IS_STOPPED if the device is already stopped
407 * This function makes use of internal resources that are shared between the
408 * Start, Stop, and SetOptions functions. So if one task might be setting device
409 * options while another is trying to start the device, the user is required to
410 * provide protection of this shared data (typically using a semaphore).
412 ******************************************************************************/
414 XEmac_Stop(XEmac * InstancePtr)
418 XASSERT_NONVOID(InstancePtr != NULL);
419 XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);
422 * If the device is already stopped, do nothing but return a status
425 if (InstancePtr->IsStarted != XCOMPONENT_IS_STARTED) {
426 return XST_DEVICE_IS_STOPPED;
430 * If configured for scatter-gather DMA, stop the DMA channels. Ignore
431 * the XST_DMA_SG_IS_STOPPED return code. There is a critical section
432 * here between SgStart and SgStop, and SgStart can be called in interrupt
433 * context, so disable interrupts while calling SgStop.
435 if (XEmac_mIsSgDma(InstancePtr)) {
436 XBufDescriptor *BdTemp; /* temporary descriptor pointer */
438 XIIF_V123B_GINTR_DISABLE(InstancePtr->BaseAddress);
440 (void) XDmaChannel_SgStop(&InstancePtr->SendChannel, &BdTemp);
441 (void) XDmaChannel_SgStop(&InstancePtr->RecvChannel, &BdTemp);
443 XIIF_V123B_GINTR_ENABLE(InstancePtr->BaseAddress);
447 * Disable the transmitter and receiver. There is no critical section
448 * here since this register is not modified during interrupt context.
450 ControlReg = XIo_In32(InstancePtr->BaseAddress + XEM_ECR_OFFSET);
451 ControlReg &= ~(XEM_ECR_XMIT_ENABLE_MASK | XEM_ECR_RECV_ENABLE_MASK);
452 XIo_Out32(InstancePtr->BaseAddress + XEM_ECR_OFFSET, ControlReg);
455 * If not in polled mode, disable interrupts for IPIF (includes MAC and
458 if (!InstancePtr->IsPolled) {
459 XIIF_V123B_GINTR_DISABLE(InstancePtr->BaseAddress);
462 InstancePtr->IsStarted = 0;
467 /*****************************************************************************/
470 * Reset the Ethernet MAC. This is a graceful reset in that the device is stopped
471 * first. Resets the DMA channels, the FIFOs, the transmitter, and the receiver.
472 * The PHY is not reset. Any frames in the scatter-gather descriptor lists will
473 * remain in the lists. The side effect of doing this is that after a reset and
474 * following a restart of the device, frames that were in the list before the
475 * reset may be transmitted or received. Reset must only be called after the
476 * driver has been initialized.
478 * The driver is also taken out of polled mode if polled mode was set. The user
479 * is responsbile for re-configuring the driver into polled mode after the
482 * The configuration after this reset is as follows:
484 * - Disabled transmitter and receiver
485 * - Enabled PHY (the PHY is not reset)
486 * - MAC transmitter does pad insertion, FCS insertion, and source address
488 * - MAC receiver does not strip padding or FCS
489 * - Interframe Gap as recommended by IEEE Std. 802.3 (96 bit times)
490 * - Unicast addressing enabled
491 * - Broadcast addressing enabled
492 * - Multicast addressing disabled (addresses are preserved)
493 * - Promiscuous addressing disabled
494 * - Default packet threshold and packet wait bound register values for
495 * scatter-gather DMA operation
496 * - MAC address of all zeros
499 * The upper layer software is responsible for re-configuring (if necessary)
500 * and restarting the MAC after the reset. Note that the PHY is not reset. PHY
501 * control is left to the upper layer software. Note also that driver statistics
502 * are not cleared on reset. It is up to the upper layer software to clear the
503 * statistics if needed.
505 * When a reset is required due to an internal error, the driver notifies the
506 * upper layer software of this need through the ErrorHandler callback and
507 * specific status codes. The upper layer software is responsible for calling
508 * this Reset function and then re-configuring the device.
510 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
522 * The reset is accomplished by setting the IPIF reset register. This takes
523 * care of resetting all hardware blocks, including the MAC.
525 ******************************************************************************/
527 XEmac_Reset(XEmac * InstancePtr)
529 XASSERT_VOID(InstancePtr != NULL);
530 XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);
533 * Stop the device first
535 (void) XEmac_Stop(InstancePtr);
538 * Take the driver out of polled mode
540 InstancePtr->IsPolled = FALSE;
543 * Reset the entire IPIF at once. If we choose someday to reset each
544 * hardware block separately, the reset should occur in the direction of
545 * data flow. For example, for the send direction the reset order is DMA
546 * first, then FIFO, then the MAC transmitter.
548 XIIF_V123B_RESET(InstancePtr->BaseAddress);
550 if (XEmac_mIsSgDma(InstancePtr)) {
552 * After reset, configure the scatter-gather DMA packet threshold and
553 * packet wait bound registers to default values. Ignore the return
554 * values of these functions since they only return error if the device
557 (void) XEmac_SetPktThreshold(InstancePtr, XEM_SEND,
558 XEM_SGDMA_DFT_THRESHOLD);
559 (void) XEmac_SetPktThreshold(InstancePtr, XEM_RECV,
560 XEM_SGDMA_DFT_THRESHOLD);
561 (void) XEmac_SetPktWaitBound(InstancePtr, XEM_SEND,
562 XEM_SGDMA_DFT_WAITBOUND);
563 (void) XEmac_SetPktWaitBound(InstancePtr, XEM_RECV,
564 XEM_SGDMA_DFT_WAITBOUND);
568 /*****************************************************************************/
571 * Set the MAC address for this driver/device. The address is a 48-bit value.
572 * The device must be stopped before calling this function.
574 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
575 * @param AddressPtr is a pointer to a 6-byte MAC address.
579 * - XST_SUCCESS if the MAC address was set successfully
580 * - XST_DEVICE_IS_STARTED if the device has not yet been stopped
586 ******************************************************************************/
588 XEmac_SetMacAddress(XEmac * InstancePtr, u8 * AddressPtr)
592 XASSERT_NONVOID(InstancePtr != NULL);
593 XASSERT_NONVOID(AddressPtr != NULL);
594 XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);
597 * The device must be stopped before setting the MAC address
599 if (InstancePtr->IsStarted == XCOMPONENT_IS_STARTED) {
600 return XST_DEVICE_IS_STARTED;
604 * Set the device station address high and low registers
606 MacAddr = (AddressPtr[0] << 8) | AddressPtr[1];
607 XIo_Out32(InstancePtr->BaseAddress + XEM_SAH_OFFSET, MacAddr);
609 MacAddr = (AddressPtr[2] << 24) | (AddressPtr[3] << 16) |
610 (AddressPtr[4] << 8) | AddressPtr[5];
612 XIo_Out32(InstancePtr->BaseAddress + XEM_SAL_OFFSET, MacAddr);
617 /*****************************************************************************/
620 * Get the MAC address for this driver/device.
622 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
623 * @param BufferPtr is an output parameter, and is a pointer to a buffer into
624 * which the current MAC address will be copied. The buffer must be at
635 ******************************************************************************/
637 XEmac_GetMacAddress(XEmac * InstancePtr, u8 * BufferPtr)
642 XASSERT_VOID(InstancePtr != NULL);
643 XASSERT_VOID(BufferPtr != NULL);
644 XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);
646 MacAddrHi = XIo_In32(InstancePtr->BaseAddress + XEM_SAH_OFFSET);
647 MacAddrLo = XIo_In32(InstancePtr->BaseAddress + XEM_SAL_OFFSET);
649 BufferPtr[0] = (u8) (MacAddrHi >> 8);
650 BufferPtr[1] = (u8) MacAddrHi;
651 BufferPtr[2] = (u8) (MacAddrLo >> 24);
652 BufferPtr[3] = (u8) (MacAddrLo >> 16);
653 BufferPtr[4] = (u8) (MacAddrLo >> 8);
654 BufferPtr[5] = (u8) MacAddrLo;
657 /******************************************************************************/
660 * Configure DMA capabilities.
662 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
666 * - XST_SUCCESS if successful initialization of DMA
672 ******************************************************************************/
674 ConfigureDma(XEmac * InstancePtr)
679 * Initialize the DMA channels with their base addresses. We assume
680 * scatter-gather DMA is the only possible configuration. Descriptor space
681 * will need to be set later by the upper layer.
683 Result = XDmaChannel_Initialize(&InstancePtr->RecvChannel,
684 InstancePtr->BaseAddress +
685 XEM_DMA_RECV_OFFSET);
686 if (Result != XST_SUCCESS) {
690 Result = XDmaChannel_Initialize(&InstancePtr->SendChannel,
691 InstancePtr->BaseAddress +
692 XEM_DMA_SEND_OFFSET);
697 /******************************************************************************/
700 * Configure the send and receive FIFO components with their base addresses
701 * and interrupt masks. Currently the base addresses are defined constants.
703 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
707 * XST_SUCCESS if successful initialization of the packet FIFOs
713 ******************************************************************************/
715 ConfigureFifo(XEmac * InstancePtr)
720 * Return status from the packet FIFOs initialization is ignored since
721 * they always return success.
723 Result = XPacketFifoV100b_Initialize(&InstancePtr->RecvFifo,
724 InstancePtr->BaseAddress +
725 XEM_PFIFO_RXREG_OFFSET,
726 InstancePtr->BaseAddress +
727 XEM_PFIFO_RXDATA_OFFSET);
728 if (Result != XST_SUCCESS) {
732 Result = XPacketFifoV100b_Initialize(&InstancePtr->SendFifo,
733 InstancePtr->BaseAddress +
734 XEM_PFIFO_TXREG_OFFSET,
735 InstancePtr->BaseAddress +
736 XEM_PFIFO_TXDATA_OFFSET);
740 /******************************************************************************/
743 * This is a stub for the scatter-gather send and recv callbacks. The stub
744 * is here in case the upper layers forget to set the handlers.
746 * @param CallBackRef is a pointer to the upper layer callback reference
747 * @param BdPtr is a pointer to the first buffer descriptor in a list
748 * @param NumBds is the number of descriptors in the list.
758 ******************************************************************************/
760 StubSgHandler(void *CallBackRef, XBufDescriptor * BdPtr, u32 NumBds)
762 XASSERT_VOID_ALWAYS();
765 /******************************************************************************/
768 * This is a stub for the non-DMA send and recv callbacks. The stub is here in
769 * case the upper layers forget to set the handlers.
771 * @param CallBackRef is a pointer to the upper layer callback reference
781 ******************************************************************************/
783 StubFifoHandler(void *CallBackRef)
785 XASSERT_VOID_ALWAYS();
788 /******************************************************************************/
791 * This is a stub for the asynchronous error callback. The stub is here in
792 * case the upper layers forget to set the handler.
794 * @param CallBackRef is a pointer to the upper layer callback reference
795 * @param ErrorCode is the Xilinx error code, indicating the cause of the error
805 ******************************************************************************/
807 StubErrorHandler(void *CallBackRef, XStatus ErrorCode)
809 XASSERT_VOID_ALWAYS();
812 /*****************************************************************************/
815 * Lookup the device configuration based on the unique device ID. The table
816 * EmacConfigTable contains the configuration info for each device in the system.
818 * @param DeviceId is the unique device ID of the device being looked up.
822 * A pointer to the configuration table entry corresponding to the given
823 * device ID, or NULL if no match is found.
829 ******************************************************************************/
831 XEmac_LookupConfig(u16 DeviceId)
833 XEmac_Config *CfgPtr = NULL;
836 for (i = 0; i < XPAR_XEMAC_NUM_INSTANCES; i++) {
837 if (XEmac_ConfigTable[i].DeviceId == DeviceId) {
838 CfgPtr = &XEmac_ConfigTable[i];